iPXE
Macros | Functions | Variables
hermon.c File Reference

Mellanox Hermon Infiniband HCA. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include <ipxe/pci.h>
#include <ipxe/pcibackup.h>
#include <ipxe/malloc.h>
#include <ipxe/umalloc.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_smc.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/fcoe.h>
#include <ipxe/vlan.h>
#include <ipxe/bofm.h>
#include <ipxe/nvsvpd.h>
#include <ipxe/nvo.h>
#include "hermon.h"

Go to the source code of this file.

Macros

#define HERMON_MOD_STAT_CFG_OFFSET(field)
 Calculate offset within static configuration. More...
 
#define HERMON_ETH_NUM_SEND_WQES   16
 Number of Hermon Ethernet send work queue entries. More...
 
#define HERMON_ETH_NUM_RECV_WQES   8
 Number of Hermon Ethernet receive work queue entries. More...
 
#define HERMON_ETH_NUM_CQES   32
 Number of Hermon Ethernet completion entries. More...
 
#define HERMON_SENSE_PORT_TIMEOUT   ( TICKS_PER_SEC / 2 )
 Timeout for port sensing. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static int hermon_bitmask_alloc (hermon_bitmask_t *bits, unsigned int bits_len, unsigned int num_bits)
 Allocate offsets within usage bitmask. More...
 
static void hermon_bitmask_free (hermon_bitmask_t *bits, int bit, unsigned int num_bits)
 Free offsets within usage bitmask. More...
 
static int hermon_cmd_wait (struct hermon *hermon, struct hermonprm_hca_command_register *hcr)
 Wait for Hermon command completion. More...
 
static int hermon_cmd (struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
 Issue HCA command. More...
 
static int hermon_cmd_query_dev_cap (struct hermon *hermon, struct hermonprm_query_dev_cap *dev_cap)
 
static int hermon_cmd_query_fw (struct hermon *hermon, struct hermonprm_query_fw *fw)
 
static int hermon_cmd_init_hca (struct hermon *hermon, const struct hermonprm_init_hca *init_hca)
 
static int hermon_cmd_close_hca (struct hermon *hermon)
 
static int hermon_cmd_init_port (struct hermon *hermon, unsigned int port)
 
static int hermon_cmd_close_port (struct hermon *hermon, unsigned int port)
 
static int hermon_cmd_set_port (struct hermon *hermon, int is_ethernet, unsigned int port_selector, const union hermonprm_set_port *set_port)
 
static int hermon_cmd_sw2hw_mpt (struct hermon *hermon, unsigned int index, const struct hermonprm_mpt *mpt)
 
static int hermon_cmd_hw2sw_mpt (struct hermon *hermon, unsigned int index)
 
static int hermon_cmd_write_mtt (struct hermon *hermon, const struct hermonprm_write_mtt *write_mtt)
 
static int hermon_cmd_map_eq (struct hermon *hermon, unsigned long index_map, const struct hermonprm_event_mask *mask)
 
static int hermon_cmd_sw2hw_eq (struct hermon *hermon, unsigned int index, const struct hermonprm_eqc *eqctx)
 
static int hermon_cmd_hw2sw_eq (struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
 
static int hermon_cmd_query_eq (struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
 
static int hermon_cmd_sw2hw_cq (struct hermon *hermon, unsigned long cqn, const struct hermonprm_completion_queue_context *cqctx)
 
static int hermon_cmd_hw2sw_cq (struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
 
static int hermon_cmd_query_cq (struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
 
static int hermon_cmd_rst2init_qp (struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
 
static int hermon_cmd_init2rtr_qp (struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
 
static int hermon_cmd_rtr2rts_qp (struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
 
static int hermon_cmd_rts2rts_qp (struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
 
static int hermon_cmd_2rst_qp (struct hermon *hermon, unsigned long qpn)
 
static int hermon_cmd_query_qp (struct hermon *hermon, unsigned long qpn, struct hermonprm_qp_ee_state_transitions *ctx)
 
static int hermon_cmd_conf_special_qp (struct hermon *hermon, unsigned int internal_qps, unsigned long base_qpn)
 
static int hermon_cmd_mad_ifc (struct hermon *hermon, unsigned int port, union hermonprm_mad *mad)
 
static int hermon_cmd_read_mcg (struct hermon *hermon, unsigned int index, struct hermonprm_mcg_entry *mcg)
 
static int hermon_cmd_write_mcg (struct hermon *hermon, unsigned int index, const struct hermonprm_mcg_entry *mcg)
 
static int hermon_cmd_mgid_hash (struct hermon *hermon, const union ib_gid *gid, struct hermonprm_mgm_hash *hash)
 
static int hermon_cmd_mod_stat_cfg (struct hermon *hermon, unsigned int mode, unsigned int input_mod, struct hermonprm_scalar_parameter *portion)
 
static int hermon_cmd_query_port (struct hermon *hermon, unsigned int port, struct hermonprm_query_port_cap *query_port)
 
static int hermon_cmd_sense_port (struct hermon *hermon, unsigned int port, struct hermonprm_sense_port *port_type)
 
static int hermon_cmd_run_fw (struct hermon *hermon)
 
static int hermon_cmd_unmap_icm (struct hermon *hermon, unsigned int page_count, const struct hermonprm_scalar_parameter *offset)
 
static int hermon_cmd_map_icm (struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *map)
 
static int hermon_cmd_unmap_icm_aux (struct hermon *hermon)
 
static int hermon_cmd_map_icm_aux (struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *map)
 
static int hermon_cmd_set_icm_size (struct hermon *hermon, const struct hermonprm_scalar_parameter *icm_size, struct hermonprm_scalar_parameter *icm_aux_size)
 
static int hermon_cmd_unmap_fa (struct hermon *hermon)
 
static int hermon_cmd_map_fa (struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *map)
 
static int hermon_alloc_mtt (struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
 Allocate MTT entries. More...
 
static void hermon_free_mtt (struct hermon *hermon, struct hermon_mtt *mtt)
 Free MTT entries. More...
 
static int hermon_mod_stat_cfg (struct hermon *hermon, unsigned int port, unsigned int mode, unsigned int offset, struct hermonprm_mod_stat_cfg *stat_cfg)
 Query or modify static configuration. More...
 
static int hermon_mad (struct ib_device *ibdev, union ib_mad *mad)
 Issue management datagram. More...
 
static int hermon_dump_cqctx (struct hermon *hermon, struct ib_completion_queue *cq)
 Dump completion queue context (for debugging only) More...
 
static int hermon_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Create completion queue. More...
 
static void hermon_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue. More...
 
static int hermon_alloc_qpn (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Assign queue pair number. More...
 
static void hermon_free_qpn (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Free queue pair number. More...
 
static unsigned int hermon_rate (struct ib_address_vector *av)
 Calculate transmission rate. More...
 
static unsigned int hermon_sched_queue (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Calculate schedule queue. More...
 
static int hermon_dump_qpctx (struct hermon *hermon, struct ib_queue_pair *qp)
 Dump queue pair context (for debugging only) More...
 
static int hermon_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create queue pair. More...
 
static int hermon_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Modify queue pair. More...
 
static void hermon_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair. More...
 
static unsigned int hermon_fill_nop_send_wqe (struct ib_device *ibdev __unused, struct ib_queue_pair *qp __unused, struct ib_address_vector *dest __unused, struct io_buffer *iobuf __unused, union hermon_send_wqe *wqe)
 Construct UD send work queue entry. More...
 
static unsigned int hermon_fill_ud_send_wqe (struct ib_device *ibdev, struct ib_queue_pair *qp __unused, struct ib_address_vector *dest, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
 Construct UD send work queue entry. More...
 
static unsigned int hermon_fill_mlx_send_wqe (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
 Construct MLX send work queue entry. More...
 
static unsigned int hermon_fill_rc_send_wqe (struct ib_device *ibdev, struct ib_queue_pair *qp __unused, struct ib_address_vector *dest __unused, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
 Construct RC send work queue entry. More...
 
static unsigned int hermon_fill_eth_send_wqe (struct ib_device *ibdev, struct ib_queue_pair *qp __unused, struct ib_address_vector *dest __unused, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
 Construct Ethernet send work queue entry. More...
 
static int hermon_post_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf)
 Post send work queue entry. More...
 
static int hermon_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry. More...
 
static int hermon_complete (struct ib_device *ibdev, struct ib_completion_queue *cq, union hermonprm_completion_entry *cqe)
 Handle completion. More...
 
static void hermon_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Poll completion queue. More...
 
static int hermon_dump_eqctx (struct hermon *hermon, struct hermon_event_queue *hermon_eq)
 Dump event queue context (for debugging only) More...
 
static int hermon_dump_eqes (struct hermon *hermon, struct hermon_event_queue *hermon_eq)
 Dump unconsumed event queue entries (for debugging only) More...
 
static int hermon_create_eq (struct hermon *hermon)
 Create event queue. More...
 
static void hermon_destroy_eq (struct hermon *hermon)
 Destroy event queue. More...
 
static void hermon_event_port_state_change (struct hermon *hermon, union hermonprm_event_entry *eqe)
 Handle port state event. More...
 
static void hermon_event_port_mgmnt_change (struct hermon *hermon, union hermonprm_event_entry *eqe)
 Handle port management event. More...
 
static void hermon_poll_eq (struct ib_device *ibdev)
 Poll event queue. More...
 
static int hermon_map_vpm (struct hermon *hermon, int(*map)(struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *), uint64_t va, physaddr_t pa, size_t len)
 Map virtual to physical address for firmware usage. More...
 
static int hermon_start_firmware (struct hermon *hermon)
 Start firmware running. More...
 
static void hermon_stop_firmware (struct hermon *hermon)
 Stop firmware running. More...
 
static int hermon_get_cap (struct hermon *hermon)
 Get device limits. More...
 
static uint64_t icm_align (uint64_t icm_offset, size_t len)
 Align ICM table. More...
 
static int hermon_map_icm (struct hermon *hermon, struct hermonprm_init_hca *init_hca)
 Map ICM (allocating if necessary) More...
 
static void hermon_unmap_icm (struct hermon *hermon)
 Unmap ICM. More...
 
static int hermon_reset (struct hermon *hermon)
 Reset device. More...
 
static int hermon_setup_mpt (struct hermon *hermon)
 Set up memory protection table. More...
 
static int hermon_unmap_mpt (struct hermon *hermon)
 Unmap memory protection table. More...
 
static int hermon_configure_special_qps (struct hermon *hermon)
 Configure special queue pairs. More...
 
static int hermon_start (struct hermon *hermon, int running)
 Start Hermon device. More...
 
static void hermon_stop (struct hermon *hermon)
 Stop Hermon device. More...
 
static int hermon_open (struct hermon *hermon)
 Open Hermon device. More...
 
static void hermon_close (struct hermon *hermon)
 Close Hermon device. More...
 
static int hermon_ib_open (struct ib_device *ibdev)
 Initialise Infiniband link. More...
 
static void hermon_ib_close (struct ib_device *ibdev)
 Close Infiniband link. More...
 
static int hermon_inform_sma (struct ib_device *ibdev, union ib_mad *mad)
 Inform embedded subnet management agent of a received MAD. More...
 
static int hermon_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Attach to multicast group. More...
 
static void hermon_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp __unused, union ib_gid *gid)
 Detach from multicast group. More...
 
static int hermon_register_ibdev (struct hermon *hermon, struct hermon_port *port)
 Register Hermon Infiniband device. More...
 
static void hermon_state_change_ibdev (struct hermon *hermon __unused, struct hermon_port *port, int link_up __unused)
 Handle Hermon Infiniband device port state change. More...
 
static void hermon_unregister_ibdev (struct hermon *hermon __unused, struct hermon_port *port)
 Unregister Hermon Infiniband device. More...
 
static int hermon_eth_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet via Hermon Ethernet device. More...
 
static void hermon_eth_complete_send (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
 Handle Hermon Ethernet device send completion. More...
 
static void hermon_eth_complete_recv (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct ib_address_vector *dest __unused, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Handle Hermon Ethernet device receive completion. More...
 
static void hermon_eth_poll (struct net_device *netdev)
 Poll Hermon Ethernet device. More...
 
static int hermon_eth_open (struct net_device *netdev)
 Open Hermon Ethernet device. More...
 
static void hermon_eth_close (struct net_device *netdev)
 Close Hermon Ethernet device. More...
 
static int hermon_register_netdev (struct hermon *hermon, struct hermon_port *port)
 Register Hermon Ethernet device. More...
 
static void hermon_state_change_netdev (struct hermon *hermon __unused, struct hermon_port *port, int link_up)
 Handle Hermon Ethernet device port state change. More...
 
static void hermon_unregister_netdev (struct hermon *hermon __unused, struct hermon_port *port)
 Unregister Hermon Ethernet device. More...
 
static const char * hermon_name_port_type (unsigned int port_type)
 Name port type. More...
 
static int hermon_sense_port_type (struct hermon *hermon, struct hermon_port *port)
 Sense port type. More...
 
static int hermon_set_port_type (struct hermon *hermon, struct hermon_port *port)
 Set port type. More...
 
static int hermon_bofm_harvest (struct bofm_device *bofm, unsigned int mport, uint8_t *mac)
 Harvest Ethernet MAC for BOFM. More...
 
static int hermon_bofm_update (struct bofm_device *bofm, unsigned int mport, const uint8_t *mac)
 Update Ethernet MAC for BOFM. More...
 
static struct hermonhermon_alloc (void)
 Allocate Hermon device. More...
 
static void hermon_free (struct hermon *hermon)
 Free Hermon device. More...
 
static int hermon_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void hermon_remove (struct pci_device *pci)
 Remove PCI device. More...
 
static int hermon_bofm_probe (struct pci_device *pci)
 Probe PCI device for BOFM. More...
 
static void hermon_bofm_remove (struct pci_device *pci)
 Remove PCI device for BOFM. More...
 

Variables

static uint8_t hermon_qp_st []
 Queue pair transport service type map. More...
 
static unsigned int(* hermon_fill_send_wqe [])(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
 Work queue entry constructors. More...
 
static struct ib_device_operations hermon_ib_operations
 Hermon Infiniband operations. More...
 
static struct hermon_port_type hermon_port_type_ib
 Hermon Infiniband port type. More...
 
static struct ib_queue_pair_operations hermon_eth_qp_op
 Hermon Ethernet queue pair operations. More...
 
static struct ib_completion_queue_operations hermon_eth_cq_op
 Hermon Ethernet device completion operations. More...
 
static struct net_device_operations hermon_eth_operations
 Hermon Ethernet network device operations. More...
 
static struct hermon_port_type hermon_port_type_eth
 Hermon Ethernet port type. More...
 
static struct bofm_operations hermon_bofm_operations
 Hermon BOFM operations. More...
 
static struct pci_device_id hermon_nics []
 
struct pci_driver hermon_driver __pci_driver
 
struct pci_driver hermon_bofm_driver __bofm_driver
 

Detailed Description

Mellanox Hermon Infiniband HCA.

Definition in file hermon.c.

Macro Definition Documentation

◆ HERMON_MOD_STAT_CFG_OFFSET

#define HERMON_MOD_STAT_CFG_OFFSET (   field)
Value:
( ( MLX_BIT_OFFSET ( struct hermonprm_mod_stat_cfg_st, field ) / 8 ) \
& ~( sizeof ( struct hermonprm_scalar_parameter ) - 1 ) )
#define MLX_BIT_OFFSET(_structure_st, _field)
Bit offset of a field within a pseudo_bit_t structure.
Definition: mlx_bitops.h:58

Calculate offset within static configuration.

Parameters
fieldField
Return values
offsetOffset

Definition at line 723 of file hermon.c.

◆ HERMON_ETH_NUM_SEND_WQES

#define HERMON_ETH_NUM_SEND_WQES   16

Number of Hermon Ethernet send work queue entries.

Definition at line 3365 of file hermon.c.

◆ HERMON_ETH_NUM_RECV_WQES

#define HERMON_ETH_NUM_RECV_WQES   8

Number of Hermon Ethernet receive work queue entries.

Definition at line 3368 of file hermon.c.

◆ HERMON_ETH_NUM_CQES

#define HERMON_ETH_NUM_CQES   32

Number of Hermon Ethernet completion entries.

Definition at line 3371 of file hermon.c.

◆ HERMON_SENSE_PORT_TIMEOUT

#define HERMON_SENSE_PORT_TIMEOUT   ( TICKS_PER_SEC / 2 )

Timeout for port sensing.

Definition at line 3702 of file hermon.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ hermon_bitmask_alloc()

static int hermon_bitmask_alloc ( hermon_bitmask_t bits,
unsigned int  bits_len,
unsigned int  num_bits 
)
static

Allocate offsets within usage bitmask.

Parameters
bitsUsage bitmask
bits_lenLength of usage bitmask
num_bitsNumber of contiguous bits to allocate within bitmask
Return values
bitFirst free bit within bitmask, or negative error

Definition at line 71 of file hermon.c.

73  {
74  unsigned int bit = 0;
75  hermon_bitmask_t mask = 1;
76  unsigned int found = 0;
77 
78  /* Search bits for num_bits contiguous free bits */
79  while ( bit < bits_len ) {
80  if ( ( mask & *bits ) == 0 ) {
81  if ( ++found == num_bits )
82  goto found;
83  } else {
84  found = 0;
85  }
86  bit++;
87  mask = ( mask << 1 ) | ( mask >> ( 8 * sizeof ( mask ) - 1 ) );
88  if ( mask == 1 )
89  bits++;
90  }
91  return -ENFILE;
92 
93  found:
94  /* Mark bits as in-use */
95  do {
96  *bits |= mask;
97  if ( mask == 1 )
98  bits--;
99  mask = ( mask >> 1 ) | ( mask << ( 8 * sizeof ( mask ) - 1 ) );
100  } while ( --found );
101 
102  return ( bit - num_bits + 1 );
103 }
static unsigned int unsigned int bit
Definition: bigint.h:208
uint32_t hermon_bitmask_t
A Hermon resource bitmask.
Definition: hermon.h:798
#define ENFILE
Too many open files in system.
Definition: errno.h:493
static volatile void * bits
Definition: bitops.h:27

References bit, bits, and ENFILE.

Referenced by hermon_alloc_mtt(), hermon_alloc_qpn(), and hermon_create_cq().

◆ hermon_bitmask_free()

static void hermon_bitmask_free ( hermon_bitmask_t bits,
int  bit,
unsigned int  num_bits 
)
static

Free offsets within usage bitmask.

Parameters
bitsUsage bitmask
bitStarting bit within bitmask
num_bitsNumber of contiguous bits to free within bitmask

Definition at line 112 of file hermon.c.

113  {
114  hermon_bitmask_t mask;
115 
116  for ( ; num_bits ; bit++, num_bits-- ) {
117  mask = ( 1 << ( bit % ( 8 * sizeof ( mask ) ) ) );
118  bits[ ( bit / ( 8 * sizeof ( mask ) ) ) ] &= ~mask;
119  }
120 }
static unsigned int unsigned int bit
Definition: bigint.h:208
uint32_t hermon_bitmask_t
A Hermon resource bitmask.
Definition: hermon.h:798
static volatile void * bits
Definition: bitops.h:27

References bit, and bits.

Referenced by hermon_alloc_mtt(), hermon_create_cq(), hermon_destroy_cq(), hermon_free_mtt(), and hermon_free_qpn().

◆ hermon_cmd_wait()

static int hermon_cmd_wait ( struct hermon hermon,
struct hermonprm_hca_command_register *  hcr 
)
static

Wait for Hermon command completion.

Parameters
hermonHermon device
hcrHCA command registers
Return values
rcReturn status code

Definition at line 136 of file hermon.c.

137  {
138  unsigned int wait;
139 
140  for ( wait = ( 100 * HERMON_HCR_MAX_WAIT_MS ) ; wait ; wait-- ) {
141  hcr->u.dwords[6] =
142  readl ( hermon->config + HERMON_HCR_REG ( 6 ) );
143  if ( ( MLX_GET ( hcr, go ) == 0 ) &&
144  ( MLX_GET ( hcr, t ) == hermon->toggle ) )
145  return 0;
146  udelay ( 10 );
147  }
148  return -EBUSY;
149 }
#define EBUSY
Device or resource busy.
Definition: errno.h:338
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define HERMON_HCR_REG(x)
Definition: hermon.h:958
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
void * config
PCI configuration registers.
Definition: hermon.h:868
unsigned int toggle
Command toggle.
Definition: hermon.h:873
A Hermon device.
Definition: hermon.h:864
#define HERMON_HCR_MAX_WAIT_MS
Definition: hermon.h:959

References hermon::config, EBUSY, HERMON_HCR_MAX_WAIT_MS, HERMON_HCR_REG, MLX_GET, readl(), hermon::toggle, and udelay().

Referenced by hermon_cmd().

◆ hermon_cmd()

static int hermon_cmd ( struct hermon hermon,
unsigned long  command,
unsigned int  op_mod,
const void *  in,
unsigned int  in_mod,
void *  out 
)
static

Issue HCA command.

Parameters
hermonHermon device
commandCommand opcode, flags and input/output lengths
op_modOpcode modifier (0 if no modifier applicable)
inInput parameters
in_modInput modifier (0 if no modifier applicable)
outOutput parameters
Return values
rcReturn status code

Definition at line 162 of file hermon.c.

164  {
165  struct hermonprm_hca_command_register hcr;
166  unsigned int opcode = HERMON_HCR_OPCODE ( command );
167  size_t in_len = HERMON_HCR_IN_LEN ( command );
168  size_t out_len = HERMON_HCR_OUT_LEN ( command );
169  void *in_buffer;
170  void *out_buffer;
171  unsigned int status;
172  unsigned int i;
173  int rc;
174 
175  assert ( in_len <= HERMON_MBOX_SIZE );
176  assert ( out_len <= HERMON_MBOX_SIZE );
177 
178  DBGC2 ( hermon, "Hermon %p command %04x in %zx%s out %zx%s\n",
179  hermon, opcode, in_len,
180  ( ( command & HERMON_HCR_IN_MBOX ) ? "(mbox)" : "" ), out_len,
181  ( ( command & HERMON_HCR_OUT_MBOX ) ? "(mbox)" : "" ) );
182 
183  /* Check that HCR is free */
184  if ( ( rc = hermon_cmd_wait ( hermon, &hcr ) ) != 0 ) {
185  DBGC ( hermon, "Hermon %p command interface locked\n",
186  hermon );
187  return rc;
188  }
189 
190  /* Flip HCR toggle */
191  hermon->toggle = ( 1 - hermon->toggle );
192 
193  /* Prepare HCR */
194  memset ( &hcr, 0, sizeof ( hcr ) );
195  in_buffer = &hcr.u.dwords[0];
196  if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
198  in_buffer = hermon->mailbox_in;
199  MLX_FILL_H ( &hcr, 0, in_param_h, virt_to_bus ( in_buffer ) );
200  MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
201  }
202  memcpy ( in_buffer, in, in_len );
203  MLX_FILL_1 ( &hcr, 2, input_modifier, in_mod );
204  out_buffer = &hcr.u.dwords[3];
205  if ( out_len && ( command & HERMON_HCR_OUT_MBOX ) ) {
206  out_buffer = hermon->mailbox_out;
207  MLX_FILL_H ( &hcr, 3, out_param_h,
208  virt_to_bus ( out_buffer ) );
209  MLX_FILL_1 ( &hcr, 4, out_param_l,
210  virt_to_bus ( out_buffer ) );
211  }
212  MLX_FILL_4 ( &hcr, 6,
213  opcode, opcode,
214  opcode_modifier, op_mod,
215  go, 1,
216  t, hermon->toggle );
218  &hcr, sizeof ( hcr ) );
219  if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
220  DBGC2 ( hermon, "Input mailbox:\n" );
221  DBGC2_HDA ( hermon, virt_to_phys ( in_buffer ), in_buffer,
222  ( ( in_len < 512 ) ? in_len : 512 ) );
223  }
224 
225  /* Issue command */
226  for ( i = 0 ; i < ( sizeof ( hcr ) / sizeof ( hcr.u.dwords[0] ) ) ;
227  i++ ) {
228  writel ( hcr.u.dwords[i],
229  hermon->config + HERMON_HCR_REG ( i ) );
230  barrier();
231  }
232 
233  /* Wait for command completion */
234  if ( ( rc = hermon_cmd_wait ( hermon, &hcr ) ) != 0 ) {
235  DBGC ( hermon, "Hermon %p timed out waiting for command "
236  "%04x:\n", hermon, opcode );
237  DBGC_HDA ( hermon,
239  &hcr, sizeof ( hcr ) );
240  return rc;
241  }
242 
243  /* Check command status */
244  status = MLX_GET ( &hcr, status );
245  if ( status != 0 ) {
246  DBGC ( hermon, "Hermon %p command %04x failed with status "
247  "%02x:\n", hermon, opcode, status );
248  DBGC_HDA ( hermon,
250  &hcr, sizeof ( hcr ) );
251  return -EIO;
252  }
253 
254  /* Read output parameters, if any */
255  hcr.u.dwords[3] = readl ( hermon->config + HERMON_HCR_REG ( 3 ) );
256  hcr.u.dwords[4] = readl ( hermon->config + HERMON_HCR_REG ( 4 ) );
257  memcpy ( out, out_buffer, out_len );
258  if ( out_len ) {
259  DBGC2 ( hermon, "Output%s:\n",
260  ( command & HERMON_HCR_OUT_MBOX ) ? " mailbox" : "" );
261  DBGC2_HDA ( hermon, virt_to_phys ( out_buffer ), out_buffer,
262  ( ( out_len < 512 ) ? out_len : 512 ) );
263  }
264 
265  return 0;
266 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define HERMON_HCR_OUT_LEN(_command)
Definition: hermon.h:978
#define MLX_FILL_4(_ptr, _index,...)
Definition: mlx_bitops.h:179
#define HERMON_HCR_BASE
Definition: hermon.h:957
static int hermon_cmd_wait(struct hermon *hermon, struct hermonprm_hca_command_register *hcr)
Wait for Hermon command completion.
Definition: hermon.c:136
__be32 in[4]
Definition: CIB_PRM.h:35
uint8_t opcode
Opcode.
Definition: ena.h:16
void * mailbox_in
Command input mailbox.
Definition: hermon.h:875
A command-line command.
Definition: command.h:9
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define HERMON_HCR_IN_LEN(_command)
Definition: hermon.h:977
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
__be32 out[4]
Definition: CIB_PRM.h:36
uint8_t status
Status.
Definition: ena.h:16
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define HERMON_HCR_IN_MBOX
Definition: hermon.h:974
void * mailbox_out
Command output mailbox.
Definition: hermon.h:877
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define DBGC_HDA(...)
Definition: compiler.h:506
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define DBGC2_HDA(...)
Definition: compiler.h:523
#define HERMON_HCR_REG(x)
Definition: hermon.h:958
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
#define HERMON_HCR_OUT_MBOX
Definition: hermon.h:975
void * config
PCI configuration registers.
Definition: hermon.h:868
unsigned int toggle
Command toggle.
Definition: hermon.h:873
#define DBGC2(...)
Definition: compiler.h:522
#define HERMON_HCR_OPCODE(_command)
Definition: hermon.h:976
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
#define EIO
Input/output error.
Definition: errno.h:433
A Hermon device.
Definition: hermon.h:864
void * memset(void *dest, int character, size_t len) __nonnull
#define HERMON_MBOX_SIZE
Definition: hermon.h:961

References assert(), barrier, hermon::config, DBGC, DBGC2, DBGC2_HDA, DBGC_HDA, EIO, hermon_cmd_wait(), HERMON_HCR_BASE, HERMON_HCR_IN_LEN, HERMON_HCR_IN_MBOX, HERMON_HCR_OPCODE, HERMON_HCR_OUT_LEN, HERMON_HCR_OUT_MBOX, HERMON_HCR_REG, HERMON_MBOX_SIZE, in, hermon::mailbox_in, hermon::mailbox_out, memcpy(), memset(), MLX_FILL_1, MLX_FILL_4, MLX_FILL_H, MLX_GET, opcode, out, rc, readl(), status, hermon::toggle, virt_to_bus(), virt_to_phys(), and writel().

Referenced by hermon_cmd_2rst_qp(), hermon_cmd_close_hca(), hermon_cmd_close_port(), hermon_cmd_conf_special_qp(), hermon_cmd_hw2sw_cq(), hermon_cmd_hw2sw_eq(), hermon_cmd_hw2sw_mpt(), hermon_cmd_init2rtr_qp(), hermon_cmd_init_hca(), hermon_cmd_init_port(), hermon_cmd_mad_ifc(), hermon_cmd_map_eq(), hermon_cmd_map_fa(), hermon_cmd_map_icm(), hermon_cmd_map_icm_aux(), hermon_cmd_mgid_hash(), hermon_cmd_mod_stat_cfg(), hermon_cmd_query_cq(), hermon_cmd_query_dev_cap(), hermon_cmd_query_eq(), hermon_cmd_query_fw(), hermon_cmd_query_port(), hermon_cmd_query_qp(), hermon_cmd_read_mcg(), hermon_cmd_rst2init_qp(), hermon_cmd_rtr2rts_qp(), hermon_cmd_rts2rts_qp(), hermon_cmd_run_fw(), hermon_cmd_sense_port(), hermon_cmd_set_icm_size(), hermon_cmd_set_port(), hermon_cmd_sw2hw_cq(), hermon_cmd_sw2hw_eq(), hermon_cmd_sw2hw_mpt(), hermon_cmd_unmap_fa(), hermon_cmd_unmap_icm(), hermon_cmd_unmap_icm_aux(), hermon_cmd_write_mcg(), and hermon_cmd_write_mtt().

◆ hermon_cmd_query_dev_cap()

static int hermon_cmd_query_dev_cap ( struct hermon hermon,
struct hermonprm_query_dev_cap *  dev_cap 
)
inlinestatic

Definition at line 269 of file hermon.c.

270  {
271  return hermon_cmd ( hermon,
273  1, sizeof ( *dev_cap ) ),
274  0, NULL, 0, dev_cap );
275 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_QUERY_DEV_CAP
Definition: hermon.h:47
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_DEV_CAP, and NULL.

Referenced by hermon_get_cap().

◆ hermon_cmd_query_fw()

static int hermon_cmd_query_fw ( struct hermon hermon,
struct hermonprm_query_fw *  fw 
)
inlinestatic

Definition at line 278 of file hermon.c.

278  {
279  return hermon_cmd ( hermon,
281  1, sizeof ( *fw ) ),
282  0, NULL, 0, fw );
283 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
#define HERMON_HCR_QUERY_FW
Definition: hermon.h:48
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_FW, and NULL.

Referenced by hermon_start_firmware().

◆ hermon_cmd_init_hca()

static int hermon_cmd_init_hca ( struct hermon hermon,
const struct hermonprm_init_hca *  init_hca 
)
inlinestatic

Definition at line 286 of file hermon.c.

287  {
288  return hermon_cmd ( hermon,
290  1, sizeof ( *init_hca ) ),
291  0, init_hca, 0, NULL );
292 }
#define HERMON_HCR_INIT_HCA
Definition: hermon.h:49
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_INIT_HCA, and NULL.

Referenced by hermon_start().

◆ hermon_cmd_close_hca()

static int hermon_cmd_close_hca ( struct hermon hermon)
inlinestatic

Definition at line 295 of file hermon.c.

295  {
296  return hermon_cmd ( hermon,
298  0, NULL, 0, NULL );
299 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
#define HERMON_HCR_CLOSE_HCA
Definition: hermon.h:50
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_CLOSE_HCA, HERMON_HCR_VOID_CMD, and NULL.

Referenced by hermon_start(), and hermon_stop().

◆ hermon_cmd_init_port()

static int hermon_cmd_init_port ( struct hermon hermon,
unsigned int  port 
)
inlinestatic

Definition at line 302 of file hermon.c.

302  {
303  return hermon_cmd ( hermon,
305  0, NULL, port, NULL );
306 }
#define HERMON_HCR_INIT_PORT
Definition: hermon.h:51
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_INIT_PORT, HERMON_HCR_VOID_CMD, NULL, and port.

Referenced by hermon_eth_open(), and hermon_ib_open().

◆ hermon_cmd_close_port()

static int hermon_cmd_close_port ( struct hermon hermon,
unsigned int  port 
)
inlinestatic

Definition at line 309 of file hermon.c.

309  {
310  return hermon_cmd ( hermon,
312  0, NULL, port, NULL );
313 }
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_CLOSE_PORT
Definition: hermon.h:52
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_CLOSE_PORT, HERMON_HCR_VOID_CMD, NULL, and port.

Referenced by hermon_eth_close(), and hermon_ib_close().

◆ hermon_cmd_set_port()

static int hermon_cmd_set_port ( struct hermon hermon,
int  is_ethernet,
unsigned int  port_selector,
const union hermonprm_set_port set_port 
)
inlinestatic

Definition at line 316 of file hermon.c.

318  {
319  return hermon_cmd ( hermon,
321  1, sizeof ( *set_port ) ),
322  is_ethernet, set_port, port_selector, NULL );
323 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
#define HERMON_HCR_SET_PORT
Definition: hermon.h:53
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_SET_PORT, and NULL.

Referenced by hermon_eth_open(), and hermon_ib_open().

◆ hermon_cmd_sw2hw_mpt()

static int hermon_cmd_sw2hw_mpt ( struct hermon hermon,
unsigned int  index,
const struct hermonprm_mpt *  mpt 
)
inlinestatic

Definition at line 326 of file hermon.c.

327  {
328  return hermon_cmd ( hermon,
330  1, sizeof ( *mpt ) ),
331  0, mpt, index, NULL );
332 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
#define HERMON_HCR_SW2HW_MPT
Definition: hermon.h:54
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_SW2HW_MPT, index, and NULL.

Referenced by hermon_setup_mpt().

◆ hermon_cmd_hw2sw_mpt()

static int hermon_cmd_hw2sw_mpt ( struct hermon hermon,
unsigned int  index 
)
inlinestatic

Definition at line 335 of file hermon.c.

335  {
336  return hermon_cmd ( hermon,
338  0, NULL, index, NULL );
339 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
#define HERMON_HCR_HW2SW_MPT
Definition: hermon.h:55
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_HW2SW_MPT, HERMON_HCR_VOID_CMD, index, and NULL.

Referenced by hermon_unmap_mpt().

◆ hermon_cmd_write_mtt()

static int hermon_cmd_write_mtt ( struct hermon hermon,
const struct hermonprm_write_mtt write_mtt 
)
inlinestatic

Definition at line 342 of file hermon.c.

343  {
344  return hermon_cmd ( hermon,
346  1, sizeof ( *write_mtt ) ),
347  0, write_mtt, 1, NULL );
348 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define HERMON_HCR_WRITE_MTT
Definition: hermon.h:56

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_WRITE_MTT, and NULL.

Referenced by hermon_alloc_mtt().

◆ hermon_cmd_map_eq()

static int hermon_cmd_map_eq ( struct hermon hermon,
unsigned long  index_map,
const struct hermonprm_event_mask *  mask 
)
inlinestatic

Definition at line 351 of file hermon.c.

352  {
353  return hermon_cmd ( hermon,
355  0, sizeof ( *mask ) ),
356  0, mask, index_map, NULL );
357 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define HERMON_HCR_MAP_EQ
Definition: hermon.h:57

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_EQ, and NULL.

Referenced by hermon_create_eq(), and hermon_destroy_eq().

◆ hermon_cmd_sw2hw_eq()

static int hermon_cmd_sw2hw_eq ( struct hermon hermon,
unsigned int  index,
const struct hermonprm_eqc *  eqctx 
)
inlinestatic

Definition at line 360 of file hermon.c.

361  {
362  return hermon_cmd ( hermon,
364  1, sizeof ( *eqctx ) ),
365  0, eqctx, index, NULL );
366 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
#define HERMON_HCR_SW2HW_EQ
Definition: hermon.h:58
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_SW2HW_EQ, index, and NULL.

Referenced by hermon_create_eq().

◆ hermon_cmd_hw2sw_eq()

static int hermon_cmd_hw2sw_eq ( struct hermon hermon,
unsigned int  index,
struct hermonprm_eqc *  eqctx 
)
inlinestatic

Definition at line 369 of file hermon.c.

370  {
371  return hermon_cmd ( hermon,
373  1, sizeof ( *eqctx ) ),
374  1, NULL, index, eqctx );
375 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define HERMON_HCR_HW2SW_EQ
Definition: hermon.h:59

References hermon_cmd(), HERMON_HCR_HW2SW_EQ, HERMON_HCR_OUT_CMD, index, and NULL.

Referenced by hermon_create_eq(), and hermon_destroy_eq().

◆ hermon_cmd_query_eq()

static int hermon_cmd_query_eq ( struct hermon hermon,
unsigned int  index,
struct hermonprm_eqc *  eqctx 
)
inlinestatic

Definition at line 378 of file hermon.c.

379  {
380  return hermon_cmd ( hermon,
382  1, sizeof ( *eqctx ) ),
383  0, NULL, index, eqctx );
384 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_QUERY_EQ
Definition: hermon.h:60
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_EQ, index, and NULL.

Referenced by hermon_dump_eqctx(), and hermon_dump_eqes().

◆ hermon_cmd_sw2hw_cq()

static int hermon_cmd_sw2hw_cq ( struct hermon hermon,
unsigned long  cqn,
const struct hermonprm_completion_queue_context *  cqctx 
)
inlinestatic

Definition at line 387 of file hermon.c.

388  {
389  return hermon_cmd ( hermon,
391  1, sizeof ( *cqctx ) ),
392  0, cqctx, cqn, NULL );
393 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
#define HERMON_HCR_SW2HW_CQ
Definition: hermon.h:61
A Hermon device.
Definition: hermon.h:864
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References cqn, hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_SW2HW_CQ, and NULL.

Referenced by hermon_create_cq().

◆ hermon_cmd_hw2sw_cq()

static int hermon_cmd_hw2sw_cq ( struct hermon hermon,
unsigned long  cqn,
struct hermonprm_completion_queue_context *  cqctx 
)
inlinestatic

Definition at line 396 of file hermon.c.

397  {
398  return hermon_cmd ( hermon,
400  1, sizeof ( *cqctx ) ),
401  0, NULL, cqn, cqctx );
402 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
#define HERMON_HCR_HW2SW_CQ
Definition: hermon.h:62
A Hermon device.
Definition: hermon.h:864
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References cqn, hermon_cmd(), HERMON_HCR_HW2SW_CQ, HERMON_HCR_OUT_CMD, and NULL.

Referenced by hermon_destroy_cq().

◆ hermon_cmd_query_cq()

static int hermon_cmd_query_cq ( struct hermon hermon,
unsigned long  cqn,
struct hermonprm_completion_queue_context *  cqctx 
)
inlinestatic

Definition at line 405 of file hermon.c.

406  {
407  return hermon_cmd ( hermon,
409  1, sizeof ( *cqctx ) ),
410  0, NULL, cqn, cqctx );
411 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_QUERY_CQ
Definition: hermon.h:63
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References cqn, hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_CQ, and NULL.

Referenced by hermon_dump_cqctx().

◆ hermon_cmd_rst2init_qp()

static int hermon_cmd_rst2init_qp ( struct hermon hermon,
unsigned long  qpn,
const struct hermonprm_qp_ee_state_transitions *  ctx 
)
inlinestatic

Definition at line 414 of file hermon.c.

415  {
416  return hermon_cmd ( hermon,
418  1, sizeof ( *ctx ) ),
419  0, ctx, qpn, NULL );
420 }
__be32 qpn
Definition: CIB_PRM.h:29
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
#define HERMON_HCR_RST2INIT_QP
Definition: hermon.h:64
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ctx, hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_RST2INIT_QP, NULL, and qpn.

Referenced by hermon_create_qp().

◆ hermon_cmd_init2rtr_qp()

static int hermon_cmd_init2rtr_qp ( struct hermon hermon,
unsigned long  qpn,
const struct hermonprm_qp_ee_state_transitions *  ctx 
)
inlinestatic

Definition at line 423 of file hermon.c.

424  {
425  return hermon_cmd ( hermon,
427  1, sizeof ( *ctx ) ),
428  0, ctx, qpn, NULL );
429 }
__be32 qpn
Definition: CIB_PRM.h:29
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_INIT2RTR_QP
Definition: hermon.h:65
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ctx, hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_INIT2RTR_QP, NULL, and qpn.

Referenced by hermon_modify_qp().

◆ hermon_cmd_rtr2rts_qp()

static int hermon_cmd_rtr2rts_qp ( struct hermon hermon,
unsigned long  qpn,
const struct hermonprm_qp_ee_state_transitions *  ctx 
)
inlinestatic

Definition at line 432 of file hermon.c.

433  {
434  return hermon_cmd ( hermon,
436  1, sizeof ( *ctx ) ),
437  0, ctx, qpn, NULL );
438 }
#define HERMON_HCR_RTR2RTS_QP
Definition: hermon.h:66
__be32 qpn
Definition: CIB_PRM.h:29
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ctx, hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_RTR2RTS_QP, NULL, and qpn.

Referenced by hermon_modify_qp().

◆ hermon_cmd_rts2rts_qp()

static int hermon_cmd_rts2rts_qp ( struct hermon hermon,
unsigned long  qpn,
const struct hermonprm_qp_ee_state_transitions *  ctx 
)
inlinestatic

Definition at line 441 of file hermon.c.

442  {
443  return hermon_cmd ( hermon,
445  1, sizeof ( *ctx ) ),
446  0, ctx, qpn, NULL );
447 }
__be32 qpn
Definition: CIB_PRM.h:29
#define HERMON_HCR_RTS2RTS_QP
Definition: hermon.h:67
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ctx, hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_RTS2RTS_QP, NULL, and qpn.

Referenced by hermon_modify_qp().

◆ hermon_cmd_2rst_qp()

static int hermon_cmd_2rst_qp ( struct hermon hermon,
unsigned long  qpn 
)
inlinestatic

Definition at line 450 of file hermon.c.

450  {
451  return hermon_cmd ( hermon,
453  0x03, NULL, qpn, NULL );
454 }
__be32 qpn
Definition: CIB_PRM.h:29
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
A Hermon device.
Definition: hermon.h:864
#define HERMON_HCR_2RST_QP
Definition: hermon.h:68
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_2RST_QP, HERMON_HCR_VOID_CMD, NULL, and qpn.

Referenced by hermon_create_qp(), and hermon_destroy_qp().

◆ hermon_cmd_query_qp()

static int hermon_cmd_query_qp ( struct hermon hermon,
unsigned long  qpn,
struct hermonprm_qp_ee_state_transitions *  ctx 
)
inlinestatic

Definition at line 457 of file hermon.c.

458  {
459  return hermon_cmd ( hermon,
461  1, sizeof ( *ctx ) ),
462  0, NULL, qpn, ctx );
463 }
__be32 qpn
Definition: CIB_PRM.h:29
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
#define HERMON_HCR_QUERY_QP
Definition: hermon.h:69
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ctx, hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_QP, NULL, and qpn.

Referenced by hermon_dump_qpctx().

◆ hermon_cmd_conf_special_qp()

static int hermon_cmd_conf_special_qp ( struct hermon hermon,
unsigned int  internal_qps,
unsigned long  base_qpn 
)
inlinestatic

Definition at line 466 of file hermon.c.

467  {
468  return hermon_cmd ( hermon,
470  internal_qps, NULL, base_qpn, NULL );
471 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
A Hermon device.
Definition: hermon.h:864
#define HERMON_HCR_CONF_SPECIAL_QP
Definition: hermon.h:70
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_CONF_SPECIAL_QP, HERMON_HCR_VOID_CMD, and NULL.

Referenced by hermon_configure_special_qps().

◆ hermon_cmd_mad_ifc()

static int hermon_cmd_mad_ifc ( struct hermon hermon,
unsigned int  port,
union hermonprm_mad mad 
)
inlinestatic

Definition at line 474 of file hermon.c.

475  {
476  return hermon_cmd ( hermon,
478  1, sizeof ( *mad ),
479  1, sizeof ( *mad ) ),
480  0x03, mad, port, mad );
481 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:981
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_MAD_IFC
Definition: hermon.h:71
A Hermon device.
Definition: hermon.h:864
union ib_mad mad
Definition: arbel.h:12

References hermon_cmd(), HERMON_HCR_INOUT_CMD, HERMON_HCR_MAD_IFC, mad, and port.

Referenced by hermon_mad().

◆ hermon_cmd_read_mcg()

static int hermon_cmd_read_mcg ( struct hermon hermon,
unsigned int  index,
struct hermonprm_mcg_entry *  mcg 
)
inlinestatic

Definition at line 484 of file hermon.c.

485  {
486  return hermon_cmd ( hermon,
488  1, sizeof ( *mcg ) ),
489  0, NULL, index, mcg );
490 }
#define HERMON_HCR_READ_MCG
Definition: hermon.h:72
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_READ_MCG, index, and NULL.

Referenced by hermon_mcast_attach().

◆ hermon_cmd_write_mcg()

static int hermon_cmd_write_mcg ( struct hermon hermon,
unsigned int  index,
const struct hermonprm_mcg_entry *  mcg 
)
inlinestatic

Definition at line 493 of file hermon.c.

494  {
495  return hermon_cmd ( hermon,
497  1, sizeof ( *mcg ) ),
498  0, mcg, index, NULL );
499 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define HERMON_HCR_WRITE_MCG
Definition: hermon.h:73

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_WRITE_MCG, index, and NULL.

Referenced by hermon_mcast_attach(), and hermon_mcast_detach().

◆ hermon_cmd_mgid_hash()

static int hermon_cmd_mgid_hash ( struct hermon hermon,
const union ib_gid gid,
struct hermonprm_mgm_hash *  hash 
)
inlinestatic

Definition at line 502 of file hermon.c.

503  {
504  return hermon_cmd ( hermon,
506  1, sizeof ( *gid ),
507  0, sizeof ( *hash ) ),
508  0, gid, 0, hash );
509 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:981
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
pseudo_bit_t hash[0x00010]
Hash algorithm.
Definition: arbel.h:13
#define HERMON_HCR_MGID_HASH
Definition: hermon.h:74
A Hermon device.
Definition: hermon.h:864
u8 gid[16]
Definition: CIB_PRM.h:31

References gid, hash, hermon_cmd(), HERMON_HCR_INOUT_CMD, and HERMON_HCR_MGID_HASH.

Referenced by hermon_mcast_attach(), and hermon_mcast_detach().

◆ hermon_cmd_mod_stat_cfg()

static int hermon_cmd_mod_stat_cfg ( struct hermon hermon,
unsigned int  mode,
unsigned int  input_mod,
struct hermonprm_scalar_parameter *  portion 
)
inlinestatic

Definition at line 512 of file hermon.c.

514  {
515  return hermon_cmd ( hermon,
517  0, sizeof ( *portion ),
518  0, sizeof ( *portion ) ),
519  mode, portion, input_mod, portion );
520 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:981
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_MOD_STAT_CFG
Definition: hermon.h:75
A Hermon device.
Definition: hermon.h:864

References hermon_cmd(), HERMON_HCR_INOUT_CMD, and HERMON_HCR_MOD_STAT_CFG.

Referenced by hermon_mod_stat_cfg().

◆ hermon_cmd_query_port()

static int hermon_cmd_query_port ( struct hermon hermon,
unsigned int  port,
struct hermonprm_query_port_cap *  query_port 
)
inlinestatic

Definition at line 523 of file hermon.c.

524  {
525  return hermon_cmd ( hermon,
527  1, sizeof ( *query_port ) ),
528  0, NULL, port, query_port );
529 }
#define HERMON_HCR_QUERY_PORT
Definition: hermon.h:76
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_QUERY_PORT, NULL, and port.

Referenced by hermon_set_port_type().

◆ hermon_cmd_sense_port()

static int hermon_cmd_sense_port ( struct hermon hermon,
unsigned int  port,
struct hermonprm_sense_port *  port_type 
)
inlinestatic

Definition at line 532 of file hermon.c.

533  {
534  return hermon_cmd ( hermon,
536  0, sizeof ( *port_type ) ),
537  0, NULL, port, port_type );
538 }
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:992
#define HERMON_HCR_SENSE_PORT
Definition: hermon.h:77
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_OUT_CMD, HERMON_HCR_SENSE_PORT, NULL, and port.

Referenced by hermon_sense_port_type().

◆ hermon_cmd_run_fw()

static int hermon_cmd_run_fw ( struct hermon hermon)
inlinestatic

Definition at line 541 of file hermon.c.

541  {
542  return hermon_cmd ( hermon,
544  0, NULL, 0, NULL );
545 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
#define HERMON_HCR_RUN_FW
Definition: hermon.h:78
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_RUN_FW, HERMON_HCR_VOID_CMD, and NULL.

Referenced by hermon_start_firmware().

◆ hermon_cmd_unmap_icm()

static int hermon_cmd_unmap_icm ( struct hermon hermon,
unsigned int  page_count,
const struct hermonprm_scalar_parameter *  offset 
)
inlinestatic

Definition at line 548 of file hermon.c.

549  {
550  return hermon_cmd ( hermon,
552  0, sizeof ( *offset ) ),
553  0, offset, page_count, NULL );
554 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define HERMON_HCR_UNMAP_ICM
Definition: hermon.h:81
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_UNMAP_ICM, NULL, and offset.

Referenced by hermon_unmap_icm().

◆ hermon_cmd_map_icm()

static int hermon_cmd_map_icm ( struct hermon hermon,
const struct hermonprm_virtual_physical_mapping *  map 
)
inlinestatic

Definition at line 557 of file hermon.c.

558  {
559  return hermon_cmd ( hermon,
561  1, sizeof ( *map ) ),
562  0, map, 1, NULL );
563 }
#define HERMON_HCR_MAP_ICM
Definition: hermon.h:82
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_ICM, map, and NULL.

Referenced by hermon_map_icm().

◆ hermon_cmd_unmap_icm_aux()

static int hermon_cmd_unmap_icm_aux ( struct hermon hermon)
inlinestatic

Definition at line 566 of file hermon.c.

566  {
567  return hermon_cmd ( hermon,
569  0, NULL, 0, NULL );
570 }
#define HERMON_HCR_UNMAP_ICM_AUX
Definition: hermon.h:83
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_UNMAP_ICM_AUX, HERMON_HCR_VOID_CMD, and NULL.

Referenced by hermon_map_icm(), and hermon_unmap_icm().

◆ hermon_cmd_map_icm_aux()

static int hermon_cmd_map_icm_aux ( struct hermon hermon,
const struct hermonprm_virtual_physical_mapping *  map 
)
inlinestatic

Definition at line 573 of file hermon.c.

574  {
575  return hermon_cmd ( hermon,
577  1, sizeof ( *map ) ),
578  0, map, 1, NULL );
579 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
#define HERMON_HCR_MAP_ICM_AUX
Definition: hermon.h:84
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_ICM_AUX, map, and NULL.

Referenced by hermon_map_icm().

◆ hermon_cmd_set_icm_size()

static int hermon_cmd_set_icm_size ( struct hermon hermon,
const struct hermonprm_scalar_parameter *  icm_size,
struct hermonprm_scalar_parameter *  icm_aux_size 
)
inlinestatic

Definition at line 582 of file hermon.c.

584  {
585  return hermon_cmd ( hermon,
587  0, sizeof ( *icm_size ),
588  0, sizeof (*icm_aux_size) ),
589  0, icm_size, 0, icm_aux_size );
590 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:981
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_SET_ICM_SIZE
Definition: hermon.h:85
A Hermon device.
Definition: hermon.h:864

References hermon_cmd(), HERMON_HCR_INOUT_CMD, and HERMON_HCR_SET_ICM_SIZE.

Referenced by hermon_map_icm().

◆ hermon_cmd_unmap_fa()

static int hermon_cmd_unmap_fa ( struct hermon hermon)
inlinestatic

Definition at line 593 of file hermon.c.

593  {
594  return hermon_cmd ( hermon,
596  0, NULL, 0, NULL );
597 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_VOID_CMD(_opcode)
Definition: hermon.h:995
#define HERMON_HCR_UNMAP_FA
Definition: hermon.h:86
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_UNMAP_FA, HERMON_HCR_VOID_CMD, and NULL.

Referenced by hermon_start_firmware(), and hermon_stop_firmware().

◆ hermon_cmd_map_fa()

static int hermon_cmd_map_fa ( struct hermon hermon,
const struct hermonprm_virtual_physical_mapping *  map 
)
inlinestatic

Definition at line 600 of file hermon.c.

601  {
602  return hermon_cmd ( hermon,
604  1, sizeof ( *map ) ),
605  0, map, 1, NULL );
606 }
static int hermon_cmd(struct hermon *hermon, unsigned long command, unsigned int op_mod, const void *in, unsigned int in_mod, void *out)
Issue HCA command.
Definition: hermon.c:162
#define HERMON_HCR_MAP_FA
Definition: hermon.h:87
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:989
static __always_inline int struct dma_mapping * map
Definition: dma.h:181
A Hermon device.
Definition: hermon.h:864
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_FA, map, and NULL.

Referenced by hermon_start_firmware().

◆ hermon_alloc_mtt()

static int hermon_alloc_mtt ( struct hermon hermon,
const void *  memory,
size_t  len,
struct hermon_mtt mtt 
)
static

Allocate MTT entries.

Parameters
hermonHermon device
memoryMemory to map into MTT
lenLength of memory to map
mttMTT descriptor to fill in
Return values
rcReturn status code

Definition at line 624 of file hermon.c.

626  {
627  struct hermonprm_write_mtt write_mtt;
630  unsigned int page_offset;
631  unsigned int num_pages;
632  int mtt_offset;
633  unsigned int mtt_base_addr;
634  unsigned int i;
635  int rc;
636 
637  /* Find available MTT entries */
638  start = virt_to_phys ( memory );
639  page_offset = ( start & ( HERMON_PAGE_SIZE - 1 ) );
640  start -= page_offset;
641  len += page_offset;
644  num_pages );
645  if ( mtt_offset < 0 ) {
646  rc = mtt_offset;
647  DBGC ( hermon, "Hermon %p could not allocate %d MTT entries: "
648  "%s\n", hermon, num_pages, strerror ( rc ) );
649  goto err_mtt_offset;
650  }
651  mtt_base_addr = ( ( hermon->cap.reserved_mtts + mtt_offset ) *
653  addr = start;
654 
655  /* Fill in MTT structure */
656  mtt->mtt_offset = mtt_offset;
657  mtt->num_pages = num_pages;
658  mtt->mtt_base_addr = mtt_base_addr;
659  mtt->page_offset = page_offset;
660 
661  /* Construct and issue WRITE_MTT commands */
662  for ( i = 0 ; i < num_pages ; i++ ) {
663  memset ( &write_mtt, 0, sizeof ( write_mtt ) );
664  MLX_FILL_1 ( &write_mtt.mtt_base_addr, 1,
665  value, mtt_base_addr );
666  MLX_FILL_H ( &write_mtt.mtt, 0, ptag_h, addr );
667  MLX_FILL_2 ( &write_mtt.mtt, 1,
668  p, 1,
669  ptag_l, ( addr >> 3 ) );
670  if ( ( rc = hermon_cmd_write_mtt ( hermon,
671  &write_mtt ) ) != 0 ) {
672  DBGC ( hermon, "Hermon %p could not write MTT at %x: "
673  "%s\n", hermon, mtt_base_addr,
674  strerror ( rc ) );
675  goto err_write_mtt;
676  }
679  }
680 
681  DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] for "
682  "[%08lx,%08lx,%08lx,%08lx)\n", hermon, mtt->mtt_offset,
683  ( mtt->mtt_offset + mtt->num_pages - 1 ), start,
684  ( start + page_offset ), ( start + len ), addr );
685 
686  return 0;
687 
688  err_write_mtt:
689  hermon_bitmask_free ( hermon->mtt_inuse, mtt_offset, num_pages );
690  err_mtt_offset:
691  return rc;
692 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
static int hermon_cmd_write_mtt(struct hermon *hermon, const struct hermonprm_write_mtt *write_mtt)
Definition: hermon.c:342
size_t mtt_entry_size
MTT entry size.
Definition: hermon.h:596
#define DBGC(...)
Definition: compiler.h:505
#define HERMON_PAGE_SIZE
Definition: hermon.h:105
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
uint32_t start
Starting offset.
Definition: netvsc.h:12
__be32 num_pages
Definition: CIB_PRM.h:31
struct hermonprm_scalar_parameter mtt_base_addr
Definition: hermon.h:499
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
unsigned int reserved_mtts
Number of reserved MTTs.
Definition: hermon.h:594
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
u32 addr
Definition: sky2.h:8
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
struct hermonprm_mtt mtt
Definition: hermon.h:501
static void hermon_bitmask_free(hermon_bitmask_t *bits, int bit, unsigned int num_bits)
Free offsets within usage bitmask.
Definition: hermon.c:112
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t len
Length.
Definition: ena.h:14
#define HERMON_MAX_MTTS
Maximum number of allocatable MTT entries.
Definition: hermon.h:641
hermon_bitmask_t mtt_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_MTTS)]
MTT entry in-use bitmask.
Definition: hermon.h:920
static int hermon_bitmask_alloc(hermon_bitmask_t *bits, unsigned int bits_len, unsigned int num_bits)
Allocate offsets within usage bitmask.
Definition: hermon.c:71
A Hermon device.
Definition: hermon.h:864
__be16 page_offset
Definition: CIB_PRM.h:33
void * memset(void *dest, int character, size_t len) __nonnull

References addr, hermon::cap, DBGC, hermon_bitmask_alloc(), hermon_bitmask_free(), hermon_cmd_write_mtt(), HERMON_MAX_MTTS, HERMON_PAGE_SIZE, len, memset(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, hermonprm_write_mtt::mtt, hermonprm_write_mtt::mtt_base_addr, hermon_dev_cap::mtt_entry_size, hermon::mtt_inuse, num_pages, page_offset, rc, hermon_dev_cap::reserved_mtts, start, strerror(), value, and virt_to_phys().

Referenced by hermon_create_cq(), hermon_create_eq(), and hermon_create_qp().

◆ hermon_free_mtt()

static void hermon_free_mtt ( struct hermon hermon,
struct hermon_mtt mtt 
)
static

Free MTT entries.

Parameters
hermonHermon device
mttMTT descriptor

Definition at line 700 of file hermon.c.

701  {
702 
703  DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] freed\n",
704  hermon, mtt->mtt_offset,
705  ( mtt->mtt_offset + mtt->num_pages - 1 ) );
706  hermon_bitmask_free ( hermon->mtt_inuse, mtt->mtt_offset,
707  mtt->num_pages );
708 }
#define DBGC(...)
Definition: compiler.h:505
struct hermonprm_mtt mtt
Definition: hermon.h:501
static void hermon_bitmask_free(hermon_bitmask_t *bits, int bit, unsigned int num_bits)
Free offsets within usage bitmask.
Definition: hermon.c:112
hermon_bitmask_t mtt_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_MTTS)]
MTT entry in-use bitmask.
Definition: hermon.h:920
A Hermon device.
Definition: hermon.h:864

References DBGC, hermon_bitmask_free(), hermonprm_write_mtt::mtt, and hermon::mtt_inuse.

Referenced by hermon_create_cq(), hermon_create_eq(), hermon_create_qp(), hermon_destroy_cq(), hermon_destroy_eq(), and hermon_destroy_qp().

◆ hermon_mod_stat_cfg()

static int hermon_mod_stat_cfg ( struct hermon hermon,
unsigned int  port,
unsigned int  mode,
unsigned int  offset,
struct hermonprm_mod_stat_cfg *  stat_cfg 
)
static

Query or modify static configuration.

Parameters
hermonHermon device
portPort
modeCommand mode
offsetOffset within static configuration
stat_cfgStatic configuration
Return values
rcReturn status code

Definition at line 737 of file hermon.c.

739  {
740  struct hermonprm_scalar_parameter *portion =
741  ( ( void * ) &stat_cfg->u.bytes[offset] );
742  struct hermonprm_mod_stat_cfg_input_mod mod;
743  int rc;
744 
745  /* Sanity check */
746  assert ( ( offset % sizeof ( *portion ) ) == 0 );
747 
748  /* Construct input modifier */
749  memset ( &mod, 0, sizeof ( mod ) );
750  MLX_FILL_2 ( &mod, 0,
751  portnum, port,
752  offset, offset );
753 
754  /* Issue command */
755  if ( ( rc = hermon_cmd_mod_stat_cfg ( hermon, mode,
756  be32_to_cpu ( mod.u.dwords[0] ),
757  portion ) ) != 0 )
758  return rc;
759 
760  return 0;
761 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
static int hermon_cmd_mod_stat_cfg(struct hermon *hermon, unsigned int mode, unsigned int input_mod, struct hermonprm_scalar_parameter *portion)
Definition: hermon.c:512
u8 port
Port number.
Definition: CIB_PRM.h:31
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
A Hermon device.
Definition: hermon.h:864
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), be32_to_cpu, hermon_cmd_mod_stat_cfg(), memset(), MLX_FILL_2, offset, port, and rc.

Referenced by hermon_bofm_harvest(), and hermon_bofm_update().

◆ hermon_mad()

static int hermon_mad ( struct ib_device ibdev,
union ib_mad mad 
)
static

Issue management datagram.

Parameters
ibdevInfiniband device
madManagement datagram
Return values
rcReturn status code

Definition at line 777 of file hermon.c.

777  {
778  struct hermon *hermon = ib_get_drvdata ( ibdev );
779  union hermonprm_mad mad_ifc;
780  int rc;
781 
782  /* Sanity check */
783  static_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ) );
784 
785  /* Copy in request packet */
786  memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
787 
788  /* Issue MAD */
789  if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
790  &mad_ifc ) ) != 0 ) {
791  DBGC ( hermon, "Hermon %p port %d could not issue MAD IFC: "
792  "%s\n", hermon, ibdev->port, strerror ( rc ) );
793  return rc;
794  }
795 
796  /* Copy out reply packet */
797  memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
798 
799  if ( mad->hdr.status != 0 ) {
800  DBGC ( hermon, "Hermon %p port %d MAD IFC status %04x\n",
801  hermon, ibdev->port, ntohs ( mad->hdr.status ) );
802  return -EIO;
803  }
804  return 0;
805 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
#define static_assert(x)
Assert a condition at build time.
Definition: assert.h:65
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
#define EIO
Input/output error.
Definition: errno.h:433
A Hermon device.
Definition: hermon.h:864
static int hermon_cmd_mad_ifc(struct hermon *hermon, unsigned int port, union hermonprm_mad *mad)
Definition: hermon.c:474
union ib_mad mad
Definition: arbel.h:12
uint16_t status
Definition: ib_mad.h:543

References DBGC, EIO, ib_mad::hdr, hermon_cmd_mad_ifc(), ib_get_drvdata(), mad, hermonprm_mad::mad, memcpy(), ntohs, ib_device::port, rc, static_assert, ib_mad_hdr::status, and strerror().

Referenced by hermon_event_port_mgmnt_change(), hermon_ib_open(), hermon_inform_sma(), hermon_poll_eq(), hermon_register_ibdev(), and hermon_state_change_ibdev().

◆ hermon_dump_cqctx()

static int hermon_dump_cqctx ( struct hermon hermon,
struct ib_completion_queue cq 
)
static

Dump completion queue context (for debugging only)

Parameters
hermonHermon device
cqCompletion queue
Return values
rcReturn status code

Definition at line 822 of file hermon.c.

822  {
823  struct hermonprm_completion_queue_context cqctx;
824  int rc;
825 
826  /* Do nothing unless debugging is enabled */
827  if ( ! DBG_LOG )
828  return 0;
829 
830  /* Dump completion queue context */
831  memset ( &cqctx, 0, sizeof ( cqctx ) );
832  if ( ( rc = hermon_cmd_query_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
833  DBGC ( hermon, "Hermon %p CQN %#lx QUERY_CQ failed: %s\n",
834  hermon, cq->cqn, strerror ( rc ) );
835  return rc;
836  }
837  DBGC ( hermon, "Hermon %p CQN %#lx context:\n", hermon, cq->cqn );
838  DBGC_HDA ( hermon, 0, &cqctx, sizeof ( cqctx ) );
839 
840  return 0;
841 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
A Hermon device.
Definition: hermon.h:864
static int hermon_cmd_query_cq(struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
Definition: hermon.c:405
#define DBG_LOG
Definition: compiler.h:317
void * memset(void *dest, int character, size_t len) __nonnull

References ib_completion_queue::cqn, DBG_LOG, DBGC, DBGC_HDA, hermon_cmd_query_cq(), memset(), rc, and strerror().

◆ hermon_create_cq()

static int hermon_create_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Create completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue
Return values
rcReturn status code

Definition at line 850 of file hermon.c.

851  {
852  struct hermon *hermon = ib_get_drvdata ( ibdev );
853  struct hermon_completion_queue *hermon_cq;
854  struct hermonprm_completion_queue_context cqctx;
855  int cqn_offset;
856  unsigned int i;
857  int rc;
858 
859  /* Find a free completion queue number */
860  cqn_offset = hermon_bitmask_alloc ( hermon->cq_inuse,
861  HERMON_MAX_CQS, 1 );
862  if ( cqn_offset < 0 ) {
863  DBGC ( hermon, "Hermon %p out of completion queues\n",
864  hermon );
865  rc = cqn_offset;
866  goto err_cqn_offset;
867  }
868  cq->cqn = ( hermon->cap.reserved_cqs + cqn_offset );
869 
870  /* Allocate control structures */
871  hermon_cq = zalloc ( sizeof ( *hermon_cq ) );
872  if ( ! hermon_cq ) {
873  DBGC ( hermon, "Hermon %p CQN %#lx could not allocate CQ\n",
874  hermon, cq->cqn );
875  rc = -ENOMEM;
876  goto err_hermon_cq;
877  }
878 
879  /* Allocate doorbell */
880  hermon_cq->doorbell = malloc_phys ( sizeof ( hermon_cq->doorbell[0] ),
881  sizeof ( hermon_cq->doorbell[0] ) );
882  if ( ! hermon_cq->doorbell ) {
883  DBGC ( hermon, "Hermon %p CQN %#lx could not allocate "
884  "doorbell\n", hermon, cq->cqn );
885  rc = -ENOMEM;
886  goto err_doorbell;
887  }
888  memset ( hermon_cq->doorbell, 0, sizeof ( hermon_cq->doorbell[0] ) );
889 
890  /* Allocate completion queue itself */
891  hermon_cq->cqe_size = ( cq->num_cqes * sizeof ( hermon_cq->cqe[0] ) );
892  hermon_cq->cqe = malloc_phys ( hermon_cq->cqe_size,
893  sizeof ( hermon_cq->cqe[0] ) );
894  if ( ! hermon_cq->cqe ) {
895  DBGC ( hermon, "Hermon %p CQN %#lx could not allocate CQEs\n",
896  hermon, cq->cqn );
897  rc = -ENOMEM;
898  goto err_cqe;
899  }
900  memset ( hermon_cq->cqe, 0, hermon_cq->cqe_size );
901  for ( i = 0 ; i < cq->num_cqes ; i++ ) {
902  MLX_FILL_1 ( &hermon_cq->cqe[i].normal, 7, owner, 1 );
903  }
904  barrier();
905 
906  /* Allocate MTT entries */
907  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_cq->cqe,
908  hermon_cq->cqe_size,
909  &hermon_cq->mtt ) ) != 0 ) {
910  DBGC ( hermon, "Hermon %p CQN %#lx could not allocate MTTs: "
911  "%s\n", hermon, cq->cqn, strerror ( rc ) );
912  goto err_alloc_mtt;
913  }
914 
915  /* Hand queue over to hardware */
916  memset ( &cqctx, 0, sizeof ( cqctx ) );
917  MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
918  MLX_FILL_1 ( &cqctx, 2,
919  page_offset, ( hermon_cq->mtt.page_offset >> 5 ) );
920  MLX_FILL_2 ( &cqctx, 3,
921  usr_page, HERMON_UAR_NON_EQ_PAGE,
922  log_cq_size, fls ( cq->num_cqes - 1 ) );
923  MLX_FILL_1 ( &cqctx, 5, c_eqn, hermon->eq.eqn );
924  MLX_FILL_H ( &cqctx, 6, mtt_base_addr_h,
925  hermon_cq->mtt.mtt_base_addr );
926  MLX_FILL_1 ( &cqctx, 7, mtt_base_addr_l,
927  ( hermon_cq->mtt.mtt_base_addr >> 3 ) );
928  MLX_FILL_H ( &cqctx, 14, db_record_addr_h,
929  virt_to_phys ( hermon_cq->doorbell ) );
930  MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
931  ( virt_to_phys ( hermon_cq->doorbell ) >> 3 ) );
932  if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
933  DBGC ( hermon, "Hermon %p CQN %#lx SW2HW_CQ failed: %s\n",
934  hermon, cq->cqn, strerror ( rc ) );
935  goto err_sw2hw_cq;
936  }
937 
938  DBGC ( hermon, "Hermon %p CQN %#lx ring [%08lx,%08lx), doorbell "
939  "%08lx\n", hermon, cq->cqn, virt_to_phys ( hermon_cq->cqe ),
940  ( virt_to_phys ( hermon_cq->cqe ) + hermon_cq->cqe_size ),
941  virt_to_phys ( hermon_cq->doorbell ) );
942  ib_cq_set_drvdata ( cq, hermon_cq );
943  return 0;
944 
945  err_sw2hw_cq:
946  hermon_free_mtt ( hermon, &hermon_cq->mtt );
947  err_alloc_mtt:
948  free_phys ( hermon_cq->cqe, hermon_cq->cqe_size );
949  err_cqe:
950  free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
951  err_doorbell:
952  free ( hermon_cq );
953  err_hermon_cq:
954  hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
955  err_cqn_offset:
956  return rc;
957 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
static int hermon_cmd_sw2hw_cq(struct hermon *hermon, unsigned long cqn, const struct hermonprm_completion_queue_context *cqctx)
Definition: hermon.c:387
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:764
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:624
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
A Hermon completion queue.
Definition: hermon.h:758
unsigned int reserved_cqs
Number of reserved CQs.
Definition: hermon.h:586
size_t cqe_size
Size of completion queue.
Definition: hermon.h:762
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
struct sockaddr_tcpip st
Definition: syslog.c:56
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:650
hermon_bitmask_t cq_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_CQS)]
Completion queue in-use bitmask.
Definition: hermon.h:916
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline void ib_cq_set_drvdata(struct ib_completion_queue *cq, void *priv)
Set Infiniband completion queue driver-private data.
Definition: infiniband.h:675
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:906
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
#define HERMON_UAR_NON_EQ_PAGE
UAR page for doorbell accesses.
Definition: hermon.h:635
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
static void hermon_bitmask_free(hermon_bitmask_t *bits, int bit, unsigned int num_bits)
Free offsets within usage bitmask.
Definition: hermon.c:112
__be16 c_eqn
Definition: CIB_PRM.h:38
#define HERMON_MAX_CQS
Maximum number of allocatable completion queues.
Definition: hermon.h:755
struct hermonprm_cq_db_record * doorbell
Doorbell record.
Definition: hermon.h:766
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:760
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
unsigned int page_offset
Offset within page.
Definition: hermon.h:652
static int hermon_bitmask_alloc(hermon_bitmask_t *bits, unsigned int bits_len, unsigned int num_bits)
Allocate offsets within usage bitmask.
Definition: hermon.c:71
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:535
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
__be16 page_offset
Definition: CIB_PRM.h:33
#define fls(x)
Find last (i.e.
Definition: strings.h:166
unsigned long eqn
Event queue number.
Definition: hermon.h:784
void * memset(void *dest, int character, size_t len) __nonnull

References barrier, c_eqn, hermon::cap, hermon::cq_inuse, hermon_completion_queue::cqe, hermon_completion_queue::cqe_size, ib_completion_queue::cqn, DBGC, hermon_completion_queue::doorbell, ENOMEM, hermon::eq, hermon_event_queue::eqn, fls, free, free_phys(), hermon_alloc_mtt(), hermon_bitmask_alloc(), hermon_bitmask_free(), hermon_cmd_sw2hw_cq(), hermon_free_mtt(), HERMON_MAX_CQS, HERMON_UAR_NON_EQ_PAGE, ib_cq_set_drvdata(), ib_get_drvdata(), malloc_phys(), memset(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, hermon_completion_queue::mtt, hermon_mtt::mtt_base_addr, hermonprm_completion_entry::normal, ib_completion_queue::num_cqes, owner, page_offset, hermon_mtt::page_offset, rc, hermon_dev_cap::reserved_cqs, st, strerror(), virt_to_phys(), and zalloc().

◆ hermon_destroy_cq()

static void hermon_destroy_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 965 of file hermon.c.

966  {
967  struct hermon *hermon = ib_get_drvdata ( ibdev );
968  struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
969  struct hermonprm_completion_queue_context cqctx;
970  int cqn_offset;
971  int rc;
972 
973  /* Take ownership back from hardware */
974  if ( ( rc = hermon_cmd_hw2sw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
975  DBGC ( hermon, "Hermon %p CQN %#lx FATAL HW2SW_CQ failed: "
976  "%s\n", hermon, cq->cqn, strerror ( rc ) );
977  /* Leak memory and return; at least we avoid corruption */
978  return;
979  }
980 
981  /* Free MTT entries */
982  hermon_free_mtt ( hermon, &hermon_cq->mtt );
983 
984  /* Free memory */
985  free_phys ( hermon_cq->cqe, hermon_cq->cqe_size );
986  free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
987  free ( hermon_cq );
988 
989  /* Mark queue number as free */
990  cqn_offset = ( cq->cqn - hermon->cap.reserved_cqs );
991  hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
992 
993  ib_cq_set_drvdata ( cq, NULL );
994 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:764
#define DBGC(...)
Definition: compiler.h:505
A Hermon completion queue.
Definition: hermon.h:758
unsigned int reserved_cqs
Number of reserved CQs.
Definition: hermon.h:586
size_t cqe_size
Size of completion queue.
Definition: hermon.h:762
hermon_bitmask_t cq_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_CQS)]
Completion queue in-use bitmask.
Definition: hermon.h:916
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static int hermon_cmd_hw2sw_cq(struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
Definition: hermon.c:396
static __always_inline void ib_cq_set_drvdata(struct ib_completion_queue *cq, void *priv)
Set Infiniband completion queue driver-private data.
Definition: infiniband.h:675
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
static void hermon_bitmask_free(hermon_bitmask_t *bits, int bit, unsigned int num_bits)
Free offsets within usage bitmask.
Definition: hermon.c:112
struct hermonprm_cq_db_record * doorbell
Doorbell record.
Definition: hermon.h:766
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:760
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:686
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References hermon::cap, hermon::cq_inuse, hermon_completion_queue::cqe, hermon_completion_queue::cqe_size, ib_completion_queue::cqn, DBGC, hermon_completion_queue::doorbell, free, free_phys(), hermon_bitmask_free(), hermon_cmd_hw2sw_cq(), hermon_free_mtt(), ib_cq_get_drvdata(), ib_cq_set_drvdata(), ib_get_drvdata(), hermon_completion_queue::mtt, NULL, rc, hermon_dev_cap::reserved_cqs, and strerror().

◆ hermon_alloc_qpn()

static int hermon_alloc_qpn ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Assign queue pair number.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 1010 of file hermon.c.

1011  {
1012  struct hermon *hermon = ib_get_drvdata ( ibdev );
1013  unsigned int port_offset;
1014  int qpn_offset;
1015 
1016  /* Calculate queue pair number */
1017  port_offset = ( ibdev->port - HERMON_PORT_BASE );
1018 
1019  switch ( qp->type ) {
1020  case IB_QPT_SMI:
1021  qp->qpn = ( hermon->special_qpn_base + port_offset );
1022  return 0;
1023  case IB_QPT_GSI:
1024  qp->qpn = ( hermon->special_qpn_base + 2 + port_offset );
1025  return 0;
1026  case IB_QPT_UD:
1027  case IB_QPT_RC:
1028  case IB_QPT_ETH:
1029  /* Find a free queue pair number */
1030  qpn_offset = hermon_bitmask_alloc ( hermon->qp_inuse,
1031  HERMON_MAX_QPS, 1 );
1032  if ( qpn_offset < 0 ) {
1033  DBGC ( hermon, "Hermon %p out of queue pairs\n",
1034  hermon );
1035  return qpn_offset;
1036  }
1037  qp->qpn = ( ( random() & HERMON_QPN_RANDOM_MASK ) |
1038  ( hermon->qpn_base + qpn_offset ) );
1039  return 0;
1040  default:
1041  DBGC ( hermon, "Hermon %p unsupported QP type %d\n",
1042  hermon, qp->type );
1043  return -ENOTSUP;
1044  }
1045 }
#define HERMON_PORT_BASE
Definition: hermon.h:28
#define DBGC(...)
Definition: compiler.h:505
unsigned long special_qpn_base
Special QPN base.
Definition: hermon.h:925
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define HERMON_QPN_RANDOM_MASK
Queue pair number randomisation mask.
Definition: hermon.h:725
unsigned int port
Port number.
Definition: infiniband.h:418
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:31
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
unsigned long qpn_base
QPN base.
Definition: hermon.h:927
static int hermon_bitmask_alloc(hermon_bitmask_t *bits, unsigned int bits_len, unsigned int num_bits)
Allocate offsets within usage bitmask.
Definition: hermon.c:71
hermon_bitmask_t qp_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_QPS)]
Queue pair in-use bitmask.
Definition: hermon.h:918
A Hermon device.
Definition: hermon.h:864
#define HERMON_MAX_QPS
Maximum number of allocatable queue pairs.
Definition: hermon.h:722

References DBGC, ENOTSUP, hermon_bitmask_alloc(), HERMON_MAX_QPS, HERMON_PORT_BASE, HERMON_QPN_RANDOM_MASK, ib_get_drvdata(), IB_QPT_ETH, IB_QPT_GSI, IB_QPT_RC, IB_QPT_SMI, IB_QPT_UD, ib_device::port, qp, hermon::qp_inuse, hermon::qpn_base, random(), and hermon::special_qpn_base.

Referenced by hermon_create_qp().

◆ hermon_free_qpn()

static void hermon_free_qpn ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Free queue pair number.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1053 of file hermon.c.

1054  {
1055  struct hermon *hermon = ib_get_drvdata ( ibdev );
1056  int qpn_offset;
1057 
1058  qpn_offset = ( ( qp->qpn & ~HERMON_QPN_RANDOM_MASK )
1059  - hermon->qpn_base );
1060  if ( qpn_offset >= 0 )
1061  hermon_bitmask_free ( hermon->qp_inuse, qpn_offset, 1 );
1062 }
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define HERMON_QPN_RANDOM_MASK
Queue pair number randomisation mask.
Definition: hermon.h:725
static void hermon_bitmask_free(hermon_bitmask_t *bits, int bit, unsigned int num_bits)
Free offsets within usage bitmask.
Definition: hermon.c:112
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
unsigned long qpn_base
QPN base.
Definition: hermon.h:927
hermon_bitmask_t qp_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_QPS)]
Queue pair in-use bitmask.
Definition: hermon.h:918
A Hermon device.
Definition: hermon.h:864

References hermon_bitmask_free(), HERMON_QPN_RANDOM_MASK, ib_get_drvdata(), qp, hermon::qp_inuse, and hermon::qpn_base.

Referenced by hermon_create_qp(), and hermon_destroy_qp().

◆ hermon_rate()

static unsigned int hermon_rate ( struct ib_address_vector av)
static

Calculate transmission rate.

Parameters
avAddress vector
Return values
hermon_rateHermon rate

Definition at line 1070 of file hermon.c.

1070  {
1071  return ( ( ( av->rate >= IB_RATE_2_5 ) && ( av->rate <= IB_RATE_120 ) )
1072  ? ( av->rate + 5 ) : 0 );
1073 }
enum ib_rate rate
Rate.
Definition: infiniband.h:86

References IB_RATE_120, IB_RATE_2_5, and ib_address_vector::rate.

Referenced by hermon_fill_mlx_send_wqe(), hermon_fill_ud_send_wqe(), and hermon_modify_qp().

◆ hermon_sched_queue()

static unsigned int hermon_sched_queue ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Calculate schedule queue.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
sched_queueSchedule queue

Definition at line 1082 of file hermon.c.

1083  {
1084  return ( ( ( qp->type == IB_QPT_SMI ) ?
1086  ( ( ibdev->port - 1 ) << 6 ) );
1087 }
#define HERMON_SCHED_DEFAULT
Definition: hermon.h:129
#define HERMON_SCHED_QP0
Definition: hermon.h:128
unsigned int port
Port number.
Definition: infiniband.h:418
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

References HERMON_SCHED_DEFAULT, HERMON_SCHED_QP0, IB_QPT_SMI, ib_device::port, and qp.

Referenced by hermon_modify_qp().

◆ hermon_dump_qpctx()

static int hermon_dump_qpctx ( struct hermon hermon,
struct ib_queue_pair qp 
)
static

Dump queue pair context (for debugging only)

Parameters
hermonHermon device
qpQueue pair
Return values
rcReturn status code

Definition at line 1106 of file hermon.c.

1106  {
1107  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1108  struct hermonprm_qp_ee_state_transitions qpctx;
1109  unsigned int state;
1110  int rc;
1111 
1112  /* Do nothing unless debugging is enabled */
1113  if ( ! DBG_LOG )
1114  return 0;
1115 
1116  /* Dump queue pair context */
1117  memset ( &qpctx, 0, sizeof ( qpctx ) );
1118  if ( ( rc = hermon_cmd_query_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ) {
1119  DBGC ( hermon, "Hermon %p QPN %#lx QUERY_QP failed: %s\n",
1120  hermon, qp->qpn, strerror ( rc ) );
1121  return rc;
1122  }
1123  state = MLX_GET ( &qpctx, qpc_eec_data.state );
1124  if ( state != hermon_qp->state ) {
1125  DBGC ( hermon, "Hermon %p QPN %#lx state %d unexpected "
1126  "(should be %d)\n",
1127  hermon, qp->qpn, state, hermon_qp->state );
1128  }
1129  DBGC ( hermon, "Hermon %p QPN %#lx state %d context:\n",
1130  hermon, qp->qpn, state );
1131  DBGC_HDA ( hermon, 0, &qpctx.u.dwords[2], ( sizeof ( qpctx ) - 8 ) );
1132 
1133  return 0;
1134 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t state
State.
Definition: eth_slow.h:47
static int hermon_cmd_query_qp(struct hermon *hermon, unsigned long qpn, struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:457
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
enum hermon_queue_pair_state state
Queue state.
Definition: hermon.h:748
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
A Hermon device.
Definition: hermon.h:864
A Hermon queue pair.
Definition: hermon.h:736
#define DBG_LOG
Definition: compiler.h:317
void * memset(void *dest, int character, size_t len) __nonnull

References DBG_LOG, DBGC, DBGC_HDA, hermon_cmd_query_qp(), ib_qp_get_drvdata(), memset(), MLX_GET, qp, rc, state, hermon_queue_pair::state, and strerror().

Referenced by hermon_complete().

◆ hermon_create_qp()

static int hermon_create_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Create queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 1143 of file hermon.c.

1144  {
1145  struct hermon *hermon = ib_get_drvdata ( ibdev );
1146  struct hermon_queue_pair *hermon_qp;
1147  struct hermonprm_qp_ee_state_transitions qpctx;
1148  struct hermonprm_wqe_segment_data_ptr *data;
1149  unsigned int i;
1150  int rc;
1151 
1152  /* Calculate queue pair number */
1153  if ( ( rc = hermon_alloc_qpn ( ibdev, qp ) ) != 0 )
1154  goto err_alloc_qpn;
1155 
1156  /* Allocate control structures */
1157  hermon_qp = zalloc ( sizeof ( *hermon_qp ) );
1158  if ( ! hermon_qp ) {
1159  DBGC ( hermon, "Hermon %p QPN %#lx could not allocate QP\n",
1160  hermon, qp->qpn );
1161  rc = -ENOMEM;
1162  goto err_hermon_qp;
1163  }
1164 
1165  /* Allocate doorbells */
1166  hermon_qp->recv.doorbell =
1167  malloc_phys ( sizeof ( hermon_qp->recv.doorbell[0] ),
1168  sizeof ( hermon_qp->recv.doorbell[0] ) );
1169  if ( ! hermon_qp->recv.doorbell ) {
1170  DBGC ( hermon, "Hermon %p QPN %#lx could not allocate "
1171  "doorbell\n", hermon, qp->qpn );
1172  rc = -ENOMEM;
1173  goto err_recv_doorbell;
1174  }
1175  memset ( hermon_qp->recv.doorbell, 0,
1176  sizeof ( hermon_qp->recv.doorbell[0] ) );
1177  hermon_qp->send.doorbell =
1180 
1181  /* Allocate work queue buffer */
1182  hermon_qp->send.num_wqes = ( qp->send.num_wqes /* headroom */ + 1 +
1183  ( 2048 / sizeof ( hermon_qp->send.wqe[0] ) ) );
1184  hermon_qp->send.num_wqes =
1185  ( 1 << fls ( hermon_qp->send.num_wqes - 1 ) ); /* round up */
1186  hermon_qp->send.wqe_size = ( hermon_qp->send.num_wqes *
1187  sizeof ( hermon_qp->send.wqe[0] ) );
1188  hermon_qp->recv.wqe_size = ( qp->recv.num_wqes *
1189  sizeof ( hermon_qp->recv.wqe[0] ) );
1190  if ( ( qp->type == IB_QPT_SMI ) || ( qp->type == IB_QPT_GSI ) ||
1191  ( qp->type == IB_QPT_UD ) ) {
1192  hermon_qp->recv.grh_size = ( qp->recv.num_wqes *
1193  sizeof ( hermon_qp->recv.grh[0] ));
1194  }
1195  hermon_qp->wqe_size = ( hermon_qp->send.wqe_size +
1196  hermon_qp->recv.wqe_size +
1197  hermon_qp->recv.grh_size );
1198  hermon_qp->wqe = malloc_phys ( hermon_qp->wqe_size,
1199  sizeof ( hermon_qp->send.wqe[0] ) );
1200  if ( ! hermon_qp->wqe ) {
1201  DBGC ( hermon, "Hermon %p QPN %#lx could not allocate WQEs\n",
1202  hermon, qp->qpn );
1203  rc = -ENOMEM;
1204  goto err_alloc_wqe;
1205  }
1206  hermon_qp->send.wqe = hermon_qp->wqe;
1207  hermon_qp->recv.wqe = ( hermon_qp->wqe + hermon_qp->send.wqe_size );
1208  if ( hermon_qp->recv.grh_size ) {
1209  hermon_qp->recv.grh = ( hermon_qp->wqe +
1210  hermon_qp->send.wqe_size +
1211  hermon_qp->recv.wqe_size );
1212  }
1213 
1214  /* Initialise work queue entries */
1215  memset ( hermon_qp->send.wqe, 0xff, hermon_qp->send.wqe_size );
1216  memset ( hermon_qp->recv.wqe, 0, hermon_qp->recv.wqe_size );
1217  data = &hermon_qp->recv.wqe[0].recv.data[0];
1218  for ( i = 0 ; i < ( hermon_qp->recv.wqe_size / sizeof ( *data ) ); i++){
1219  MLX_FILL_1 ( data, 1, l_key, HERMON_INVALID_LKEY );
1220  data++;
1221  }
1222 
1223  /* Allocate MTT entries */
1224  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_qp->wqe,
1225  hermon_qp->wqe_size,
1226  &hermon_qp->mtt ) ) != 0 ) {
1227  DBGC ( hermon, "Hermon %p QPN %#lx could not allocate MTTs: "
1228  "%s\n", hermon, qp->qpn, strerror ( rc ) );
1229  goto err_alloc_mtt;
1230  }
1231 
1232  /* Transition queue to INIT state */
1233  memset ( &qpctx, 0, sizeof ( qpctx ) );
1234  MLX_FILL_2 ( &qpctx, 2,
1235  qpc_eec_data.pm_state, HERMON_PM_STATE_MIGRATED,
1236  qpc_eec_data.st, hermon_qp_st[qp->type] );
1237  MLX_FILL_1 ( &qpctx, 3, qpc_eec_data.pd, HERMON_GLOBAL_PD );
1238  MLX_FILL_4 ( &qpctx, 4,
1239  qpc_eec_data.log_rq_size, fls ( qp->recv.num_wqes - 1 ),
1240  qpc_eec_data.log_rq_stride,
1241  ( fls ( sizeof ( hermon_qp->recv.wqe[0] ) - 1 ) - 4 ),
1242  qpc_eec_data.log_sq_size,
1243  fls ( hermon_qp->send.num_wqes - 1 ),
1244  qpc_eec_data.log_sq_stride,
1245  ( fls ( sizeof ( hermon_qp->send.wqe[0] ) - 1 ) - 4 ) );
1246  MLX_FILL_1 ( &qpctx, 5,
1247  qpc_eec_data.usr_page, HERMON_UAR_NON_EQ_PAGE );
1248  MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
1249  MLX_FILL_4 ( &qpctx, 38,
1250  qpc_eec_data.rre, 1,
1251  qpc_eec_data.rwe, 1,
1252  qpc_eec_data.rae, 1,
1253  qpc_eec_data.page_offset,
1254  ( hermon_qp->mtt.page_offset >> 6 ) );
1255  MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1256  MLX_FILL_H ( &qpctx, 42, qpc_eec_data.db_record_addr_h,
1257  virt_to_phys ( hermon_qp->recv.doorbell ) );
1258  MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.db_record_addr_l,
1259  ( virt_to_phys ( hermon_qp->recv.doorbell ) >> 2 ) );
1260  MLX_FILL_H ( &qpctx, 52, qpc_eec_data.mtt_base_addr_h,
1261  hermon_qp->mtt.mtt_base_addr );
1262  MLX_FILL_1 ( &qpctx, 53, qpc_eec_data.mtt_base_addr_l,
1263  ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1264  if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1265  &qpctx ) ) != 0 ) {
1266  DBGC ( hermon, "Hermon %p QPN %#lx RST2INIT_QP failed: %s\n",
1267  hermon, qp->qpn, strerror ( rc ) );
1268  goto err_rst2init_qp;
1269  }
1270  hermon_qp->state = HERMON_QP_ST_INIT;
1271 
1272  DBGC ( hermon, "Hermon %p QPN %#lx send ring [%08lx,%08lx), doorbell "
1273  "%08lx\n", hermon, qp->qpn,
1274  virt_to_phys ( hermon_qp->send.wqe ),
1275  ( virt_to_phys ( hermon_qp->send.wqe ) +
1276  hermon_qp->send.wqe_size ),
1277  virt_to_phys ( hermon_qp->send.doorbell ) );
1278  DBGC ( hermon, "Hermon %p QPN %#lx receive ring [%08lx,%08lx), "
1279  "doorbell %08lx\n", hermon, qp->qpn,
1280  virt_to_phys ( hermon_qp->recv.wqe ),
1281  ( virt_to_phys ( hermon_qp->recv.wqe ) +
1282  hermon_qp->recv.wqe_size ),
1283  virt_to_phys ( hermon_qp->recv.doorbell ) );
1284  DBGC ( hermon, "Hermon %p QPN %#lx send CQN %#lx receive CQN %#lx\n",
1285  hermon, qp->qpn, qp->send.cq->cqn, qp->recv.cq->cqn );
1286  ib_qp_set_drvdata ( qp, hermon_qp );
1287  return 0;
1288 
1289  hermon_cmd_2rst_qp ( hermon, qp->qpn );
1290  err_rst2init_qp:
1291  hermon_free_mtt ( hermon, &hermon_qp->mtt );
1292  err_alloc_mtt:
1293  free_phys ( hermon_qp->wqe, hermon_qp->wqe_size );
1294  err_alloc_wqe:
1295  free_phys ( hermon_qp->recv.doorbell,
1296  sizeof ( hermon_qp->recv.doorbell[0] ) );
1297  err_recv_doorbell:
1298  free ( hermon_qp );
1299  err_hermon_qp:
1300  hermon_free_qpn ( ibdev, qp );
1301  err_alloc_qpn:
1302  return rc;
1303 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
struct hermon_send_work_queue send
Send work queue.
Definition: hermon.h:744
#define MLX_FILL_4(_ptr, _index,...)
Definition: mlx_bitops.h:179
static int hermon_cmd_rst2init_qp(struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:414
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:746
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:624
void * doorbell
Doorbell register.
Definition: hermon.h:682
struct hermonprm_recv_wqe recv
Definition: hermon.h:690
#define DBGC(...)
Definition: compiler.h:505
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define HERMON_PAGE_SIZE
Definition: hermon.h:105
#define HERMON_DB_POST_SND_OFFSET
Definition: hermon.h:107
static void hermon_free_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Free queue pair number.
Definition: hermon.c:1053
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
struct hermonprm_qp_db_record * doorbell
Doorbell record.
Definition: hermon.h:705
enum hermon_queue_pair_state state
Queue state.
Definition: hermon.h:748
#define HERMON_INVALID_LKEY
Definition: hermon.h:103
union hermon_recv_wqe * wqe
Work queue entries.
Definition: hermon.h:697
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:650
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
size_t wqe_size
Size of work queue buffer.
Definition: hermon.h:740
size_t wqe_size
Size of work queue.
Definition: hermon.h:699
void * wqe
Work queue buffer.
Definition: hermon.h:738
#define HERMON_PM_STATE_MIGRATED
Definition: hermon.h:135
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
union hermon_send_wqe * wqe
Work queue entries.
Definition: hermon.h:678
#define HERMON_UAR_NON_EQ_PAGE
UAR page for doorbell accesses.
Definition: hermon.h:635
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
void * uar
PCI user Access Region.
Definition: hermon.h:870
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER]
Definition: hermon.h:531
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
size_t wqe_size
Size of work queue.
Definition: hermon.h:680
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
unsigned int page_offset
Offset within page.
Definition: hermon.h:652
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:742
static int hermon_alloc_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Assign queue pair number.
Definition: hermon.c:1010
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
A Hermon queue pair.
Definition: hermon.h:736
static uint8_t hermon_qp_st[]
Queue pair transport service type map.
Definition: hermon.c:1090
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static int hermon_cmd_2rst_qp(struct hermon *hermon, unsigned long qpn)
Definition: hermon.c:450
static __always_inline void ib_qp_set_drvdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair driver-private data.
Definition: infiniband.h:631
unsigned int num_wqes
Number of work queue entries, including headroom.
Definition: hermon.h:676
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:701
size_t grh_size
Size of GRH buffers.
Definition: hermon.h:703
void * memset(void *dest, int character, size_t len) __nonnull
#define HERMON_GLOBAL_PD
Global protection domain.
Definition: hermon.h:940

References data, hermonprm_recv_wqe::data, DBGC, hermon_send_work_queue::doorbell, hermon_recv_work_queue::doorbell, ENOMEM, fls, free, free_phys(), hermon_recv_work_queue::grh, hermon_recv_work_queue::grh_size, hermon_alloc_mtt(), hermon_alloc_qpn(), hermon_cmd_2rst_qp(), hermon_cmd_rst2init_qp(), HERMON_DB_POST_SND_OFFSET, hermon_free_mtt(), hermon_free_qpn(), HERMON_GLOBAL_PD, HERMON_INVALID_LKEY, HERMON_PAGE_SIZE, HERMON_PM_STATE_MIGRATED, hermon_qp_st, HERMON_QP_ST_INIT, HERMON_UAR_NON_EQ_PAGE, ib_get_drvdata(), ib_qp_set_drvdata(), IB_QPT_GSI, IB_QPT_SMI, IB_QPT_UD, malloc_phys(), memset(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_4, MLX_FILL_H, hermon_queue_pair::mtt, hermon_mtt::mtt_base_addr, hermon_send_work_queue::num_wqes, hermon_mtt::page_offset, qp, rc, hermon_recv_wqe::recv, hermon_queue_pair::recv, hermon_queue_pair::send, hermon_queue_pair::state, strerror(), hermon::uar, virt_to_phys(), hermon_send_work_queue::wqe, hermon_recv_work_queue::wqe, hermon_queue_pair::wqe, hermon_send_work_queue::wqe_size, hermon_recv_work_queue::wqe_size, hermon_queue_pair::wqe_size, and zalloc().

◆ hermon_modify_qp()

static int hermon_modify_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Modify queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 1312 of file hermon.c.

1313  {
1314  struct hermon *hermon = ib_get_drvdata ( ibdev );
1315  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1316  struct hermonprm_qp_ee_state_transitions qpctx;
1317  int rc;
1318 
1319  /* Transition queue to RTR state, if applicable */
1320  if ( hermon_qp->state < HERMON_QP_ST_RTR ) {
1321  memset ( &qpctx, 0, sizeof ( qpctx ) );
1322  MLX_FILL_2 ( &qpctx, 4,
1323  qpc_eec_data.mtu,
1324  ( ( qp->type == IB_QPT_ETH ) ?
1326  qpc_eec_data.msg_max, 31 );
1327  MLX_FILL_1 ( &qpctx, 7,
1328  qpc_eec_data.remote_qpn_een, qp->av.qpn );
1329  MLX_FILL_1 ( &qpctx, 9,
1330  qpc_eec_data.primary_address_path.rlid,
1331  qp->av.lid );
1332  MLX_FILL_1 ( &qpctx, 10,
1333  qpc_eec_data.primary_address_path.max_stat_rate,
1334  hermon_rate ( &qp->av ) );
1335  memcpy ( &qpctx.u.dwords[12], &qp->av.gid,
1336  sizeof ( qp->av.gid ) );
1337  MLX_FILL_1 ( &qpctx, 16,
1338  qpc_eec_data.primary_address_path.sched_queue,
1339  hermon_sched_queue ( ibdev, qp ) );
1340  MLX_FILL_1 ( &qpctx, 39,
1341  qpc_eec_data.next_rcv_psn, qp->recv.psn );
1342  if ( ( rc = hermon_cmd_init2rtr_qp ( hermon, qp->qpn,
1343  &qpctx ) ) != 0 ) {
1344  DBGC ( hermon, "Hermon %p QPN %#lx INIT2RTR_QP failed:"
1345  " %s\n", hermon, qp->qpn, strerror ( rc ) );
1346  return rc;
1347  }
1348  hermon_qp->state = HERMON_QP_ST_RTR;
1349  }
1350 
1351  /* Transition queue to RTS state */
1352  if ( hermon_qp->state < HERMON_QP_ST_RTS ) {
1353  memset ( &qpctx, 0, sizeof ( qpctx ) );
1354  MLX_FILL_1 ( &qpctx, 10,
1355  qpc_eec_data.primary_address_path.ack_timeout,
1356  14 /* 4.096us * 2^(14) = 67ms */ );
1357  MLX_FILL_2 ( &qpctx, 30,
1358  qpc_eec_data.retry_count, HERMON_RETRY_MAX,
1359  qpc_eec_data.rnr_retry, HERMON_RETRY_MAX );
1360  MLX_FILL_1 ( &qpctx, 32,
1361  qpc_eec_data.next_send_psn, qp->send.psn );
1362  if ( ( rc = hermon_cmd_rtr2rts_qp ( hermon, qp->qpn,
1363  &qpctx ) ) != 0 ) {
1364  DBGC ( hermon, "Hermon %p QPN %#lx RTR2RTS_QP failed: "
1365  "%s\n", hermon, qp->qpn, strerror ( rc ) );
1366  return rc;
1367  }
1368  hermon_qp->state = HERMON_QP_ST_RTS;
1369  }
1370 
1371  /* Update parameters in RTS state */
1372  memset ( &qpctx, 0, sizeof ( qpctx ) );
1374  MLX_FILL_1 ( &qpctx, 44, qpc_eec_data.q_key, qp->qkey );
1375  if ( ( rc = hermon_cmd_rts2rts_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ){
1376  DBGC ( hermon, "Hermon %p QPN %#lx RTS2RTS_QP failed: %s\n",
1377  hermon, qp->qpn, strerror ( rc ) );
1378  return rc;
1379  }
1380 
1381  return 0;
1382 }
#define HERMON_MTU_ETH
Definition: hermon.h:101
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
#define HERMON_RETRY_MAX
Definition: hermon.h:137
enum hermon_queue_pair_state state
Queue state.
Definition: hermon.h:748
static int hermon_cmd_rts2rts_qp(struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:441
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int hermon_cmd_rtr2rts_qp(struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:432
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define HERMON_MTU_2048
Definition: hermon.h:100
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
static int hermon_cmd_init2rtr_qp(struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:423
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static unsigned int hermon_sched_queue(struct ib_device *ibdev, struct ib_queue_pair *qp)
Calculate schedule queue.
Definition: hermon.c:1082
A Hermon device.
Definition: hermon.h:864
__be32 opt_param_mask
Definition: CIB_PRM.h:28
A Hermon queue pair.
Definition: hermon.h:736
#define HERMON_QP_OPT_PARAM_QKEY
Definition: hermon.h:112
static unsigned int hermon_rate(struct ib_address_vector *av)
Calculate transmission rate.
Definition: hermon.c:1070
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, hermon_cmd_init2rtr_qp(), hermon_cmd_rtr2rts_qp(), hermon_cmd_rts2rts_qp(), HERMON_MTU_2048, HERMON_MTU_ETH, HERMON_QP_OPT_PARAM_QKEY, HERMON_QP_ST_RTR, HERMON_QP_ST_RTS, hermon_rate(), HERMON_RETRY_MAX, hermon_sched_queue(), ib_get_drvdata(), ib_qp_get_drvdata(), IB_QPT_ETH, memcpy(), memset(), MLX_FILL_1, MLX_FILL_2, opt_param_mask, qp, rc, hermon_queue_pair::state, and strerror().

◆ hermon_destroy_qp()

static void hermon_destroy_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1390 of file hermon.c.

1391  {
1392  struct hermon *hermon = ib_get_drvdata ( ibdev );
1393  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1394  int rc;
1395 
1396  /* Take ownership back from hardware */
1397  if ( ( rc = hermon_cmd_2rst_qp ( hermon, qp->qpn ) ) != 0 ) {
1398  DBGC ( hermon, "Hermon %p QPN %#lx FATAL 2RST_QP failed: %s\n",
1399  hermon, qp->qpn, strerror ( rc ) );
1400  /* Leak memory and return; at least we avoid corruption */
1401  return;
1402  }
1403 
1404  /* Free MTT entries */
1405  hermon_free_mtt ( hermon, &hermon_qp->mtt );
1406 
1407  /* Free memory */
1408  free_phys ( hermon_qp->wqe, hermon_qp->wqe_size );
1409  free_phys ( hermon_qp->recv.doorbell,
1410  sizeof ( hermon_qp->recv.doorbell[0] ) );
1411  free ( hermon_qp );
1412 
1413  /* Mark queue number as free */
1414  hermon_free_qpn ( ibdev, qp );
1415 
1416  ib_qp_set_drvdata ( qp, NULL );
1417 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:746
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
static void hermon_free_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Free queue pair number.
Definition: hermon.c:1053
struct hermonprm_qp_db_record * doorbell
Doorbell record.
Definition: hermon.h:705
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
size_t wqe_size
Size of work queue buffer.
Definition: hermon.h:740
void * wqe
Work queue buffer.
Definition: hermon.h:738
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:742
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
A Hermon queue pair.
Definition: hermon.h:736
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int hermon_cmd_2rst_qp(struct hermon *hermon, unsigned long qpn)
Definition: hermon.c:450
static __always_inline void ib_qp_set_drvdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair driver-private data.
Definition: infiniband.h:631

References DBGC, hermon_recv_work_queue::doorbell, free, free_phys(), hermon_cmd_2rst_qp(), hermon_free_mtt(), hermon_free_qpn(), ib_get_drvdata(), ib_qp_get_drvdata(), ib_qp_set_drvdata(), hermon_queue_pair::mtt, NULL, qp, rc, hermon_queue_pair::recv, strerror(), hermon_queue_pair::wqe, and hermon_queue_pair::wqe_size.

◆ hermon_fill_nop_send_wqe()

static unsigned int hermon_fill_nop_send_wqe ( struct ib_device *ibdev  __unused,
struct ib_queue_pair *qp  __unused,
struct ib_address_vector *dest  __unused,
struct io_buffer *iobuf  __unused,
union hermon_send_wqe wqe 
)
static

Construct UD send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
wqeSend work queue entry
Return values
opcodeControl opcode

Definition at line 1437 of file hermon.c.

1441  {
1442 
1443  MLX_FILL_1 ( &wqe->ctrl, 1, ds, ( sizeof ( wqe->ctrl ) / 16 ) );
1444  MLX_FILL_1 ( &wqe->ctrl, 2, c, 0x03 /* generate completion */ );
1445  return HERMON_OPCODE_NOP;
1446 }
uint32_t c
Definition: md4.c:30
#define HERMON_OPCODE_NOP
Definition: hermon.h:41
void * wqe
Work queue buffer.
Definition: hermon.h:738
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
uint32_t ds
Definition: librm.h:254

References c, ds, HERMON_OPCODE_NOP, MLX_FILL_1, and hermon_queue_pair::wqe.

◆ hermon_fill_ud_send_wqe()

static unsigned int hermon_fill_ud_send_wqe ( struct ib_device ibdev,
struct ib_queue_pair *qp  __unused,
struct ib_address_vector dest,
struct io_buffer iobuf,
union hermon_send_wqe wqe 
)
static

Construct UD send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
wqeSend work queue entry
Return values
opcodeControl opcode

Definition at line 1459 of file hermon.c.

1463  {
1464  struct hermon *hermon = ib_get_drvdata ( ibdev );
1465 
1466  MLX_FILL_1 ( &wqe->ud.ctrl, 1, ds,
1467  ( ( offsetof ( typeof ( wqe->ud ), data[1] ) / 16 ) ) );
1468  MLX_FILL_1 ( &wqe->ud.ctrl, 2, c, 0x03 /* generate completion */ );
1469  MLX_FILL_2 ( &wqe->ud.ud, 0,
1470  ud_address_vector.pd, HERMON_GLOBAL_PD,
1471  ud_address_vector.port_number, ibdev->port );
1472  MLX_FILL_2 ( &wqe->ud.ud, 1,
1473  ud_address_vector.rlid, dest->lid,
1474  ud_address_vector.g, dest->gid_present );
1475  MLX_FILL_1 ( &wqe->ud.ud, 2,
1476  ud_address_vector.max_stat_rate, hermon_rate ( dest ) );
1477  MLX_FILL_1 ( &wqe->ud.ud, 3, ud_address_vector.sl, dest->sl );
1478  memcpy ( &wqe->ud.ud.u.dwords[4], &dest->gid, sizeof ( dest->gid ) );
1479  MLX_FILL_1 ( &wqe->ud.ud, 8, destination_qp, dest->qpn );
1480  MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, dest->qkey );
1481  MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1482  MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, hermon->lkey );
1483  MLX_FILL_H ( &wqe->ud.data[0], 2,
1484  local_address_h, virt_to_bus ( iobuf->data ) );
1485  MLX_FILL_1 ( &wqe->ud.data[0], 3,
1486  local_address_l, virt_to_bus ( iobuf->data ) );
1487  return HERMON_OPCODE_SEND;
1488 }
uint32_t c
Definition: md4.c:30
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
#define HERMON_OPCODE_SEND
Definition: hermon.h:42
__be32 byte_count
Definition: CIB_PRM.h:28
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
struct hermonprm_wqe_segment_ctrl_send ctrl
Definition: hermon.h:507
static void * dest
Definition: strings.h:176
unsigned int port
Port number.
Definition: infiniband.h:418
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
struct hermonprm_wqe_segment_ud ud
Definition: hermon.h:508
uint32_t ds
Definition: librm.h:254
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:509
void * data
Start of data.
Definition: iobuf.h:48
struct hermonprm_ud_send_wqe ud
Definition: hermon.h:661
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:913
static unsigned int hermon_rate(struct ib_address_vector *av)
Calculate transmission rate.
Definition: hermon.c:1070
#define HERMON_GLOBAL_PD
Global protection domain.
Definition: hermon.h:940

References byte_count, c, hermonprm_ud_send_wqe::ctrl, data, io_buffer::data, hermonprm_ud_send_wqe::data, dest, ds, HERMON_GLOBAL_PD, HERMON_OPCODE_SEND, hermon_rate(), ib_get_drvdata(), iob_len(), hermon::lkey, memcpy(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, offsetof, ib_device::port, typeof(), hermonprm_ud_send_wqe::ud, hermon_send_wqe::ud, and virt_to_bus().

◆ hermon_fill_mlx_send_wqe()

static unsigned int hermon_fill_mlx_send_wqe ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector dest,
struct io_buffer iobuf,
union hermon_send_wqe wqe 
)
static

Construct MLX send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
wqeSend work queue entry
Return values
opcodeControl opcode

Definition at line 1501 of file hermon.c.

1505  {
1506  struct hermon *hermon = ib_get_drvdata ( ibdev );
1507  struct io_buffer headers;
1508 
1509  /* Construct IB headers */
1510  iob_populate ( &headers, &wqe->mlx.headers, 0,
1511  sizeof ( wqe->mlx.headers ) );
1512  iob_reserve ( &headers, sizeof ( wqe->mlx.headers ) );
1513  ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
1514 
1515  /* Fill work queue entry */
1516  MLX_FILL_1 ( &wqe->mlx.ctrl, 1, ds,
1517  ( ( offsetof ( typeof ( wqe->mlx ), data[2] ) / 16 ) ) );
1518  MLX_FILL_5 ( &wqe->mlx.ctrl, 2,
1519  c, 0x03 /* generate completion */,
1520  icrc, 0 /* generate ICRC */,
1521  max_statrate, hermon_rate ( dest ),
1522  slr, 0,
1523  v15, ( ( qp->ext_qpn == IB_QPN_SMI ) ? 1 : 0 ) );
1524  MLX_FILL_1 ( &wqe->mlx.ctrl, 3, rlid, dest->lid );
1525  MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1526  byte_count, iob_len ( &headers ) );
1527  MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, hermon->lkey );
1528  MLX_FILL_H ( &wqe->mlx.data[0], 2,
1529  local_address_h, virt_to_bus ( headers.data ) );
1530  MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1531  local_address_l, virt_to_bus ( headers.data ) );
1532  MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1533  byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1534  MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, hermon->lkey );
1535  MLX_FILL_H ( &wqe->mlx.data[1], 2,
1536  local_address_h, virt_to_bus ( iobuf->data ) );
1537  MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1538  local_address_l, virt_to_bus ( iobuf->data ) );
1539  return HERMON_OPCODE_SEND;
1540 }
uint32_t c
Definition: md4.c:30
#define IB_QPN_SMI
Subnet management interface QPN.
Definition: infiniband.h:21
#define HERMON_OPCODE_SEND
Definition: hermon.h:42
__be32 byte_count
Definition: CIB_PRM.h:28
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
static void iob_populate(struct io_buffer *iobuf, void *data, size_t len, size_t max_len)
Create a temporary I/O buffer.
Definition: iobuf.h:190
struct hermonprm_wqe_segment_ctrl_mlx ctrl
Definition: hermon.h:513
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:514
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static void * dest
Definition: strings.h:176
__be16 rlid
Definition: CIB_PRM.h:38
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition: arbel.h:14
uint32_t ds
Definition: librm.h:254
struct hermonprm_mlx_send_wqe mlx
Definition: hermon.h:662
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define iob_reserve(iobuf, len)
Definition: iobuf.h:67
void * data
Start of data.
Definition: iobuf.h:48
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
#define MLX_FILL_5(_ptr, _index,...)
Definition: mlx_bitops.h:183
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:913
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition: hermon.h:515
int ib_push(struct ib_device *ibdev, struct io_buffer *iobuf, struct ib_queue_pair *qp, size_t payload_len, const struct ib_address_vector *dest)
Add IB headers.
Definition: ib_packet.c:52
static unsigned int hermon_rate(struct ib_address_vector *av)
Calculate transmission rate.
Definition: hermon.c:1070
A persistent I/O buffer.
Definition: iobuf.h:33

References byte_count, c, hermonprm_mlx_send_wqe::ctrl, data, io_buffer::data, hermonprm_mlx_send_wqe::data, dest, ds, headers, hermonprm_mlx_send_wqe::headers, HERMON_OPCODE_SEND, hermon_rate(), ib_get_drvdata(), ib_push(), IB_QPN_SMI, iob_len(), iob_populate(), iob_reserve, hermon::lkey, hermon_send_wqe::mlx, MLX_FILL_1, MLX_FILL_5, MLX_FILL_H, offsetof, qp, rlid, typeof(), and virt_to_bus().

◆ hermon_fill_rc_send_wqe()

static unsigned int hermon_fill_rc_send_wqe ( struct ib_device ibdev,
struct ib_queue_pair *qp  __unused,
struct ib_address_vector *dest  __unused,
struct io_buffer iobuf,
union hermon_send_wqe wqe 
)
static

Construct RC send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
wqeSend work queue entry
Return values
opcodeControl opcode

Definition at line 1553 of file hermon.c.

1557  {
1558  struct hermon *hermon = ib_get_drvdata ( ibdev );
1559 
1560  MLX_FILL_1 ( &wqe->rc.ctrl, 1, ds,
1561  ( ( offsetof ( typeof ( wqe->rc ), data[1] ) / 16 ) ) );
1562  MLX_FILL_1 ( &wqe->rc.ctrl, 2, c, 0x03 /* generate completion */ );
1563  MLX_FILL_1 ( &wqe->rc.data[0], 0, byte_count, iob_len ( iobuf ) );
1564  MLX_FILL_1 ( &wqe->rc.data[0], 1, l_key, hermon->lkey );
1565  MLX_FILL_H ( &wqe->rc.data[0], 2,
1566  local_address_h, virt_to_bus ( iobuf->data ) );
1567  MLX_FILL_1 ( &wqe->rc.data[0], 3,
1568  local_address_l, virt_to_bus ( iobuf->data ) );
1569  return HERMON_OPCODE_SEND;
1570 }
uint32_t c
Definition: md4.c:30
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:520
#define HERMON_OPCODE_SEND
Definition: hermon.h:42
__be32 byte_count
Definition: CIB_PRM.h:28
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
struct hermonprm_rc_send_wqe rc
Definition: hermon.h:663
struct hermonprm_wqe_segment_ctrl_send ctrl
Definition: hermon.h:519
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
uint32_t ds
Definition: librm.h:254
void * data
Start of data.
Definition: iobuf.h:48
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:913

References byte_count, c, hermonprm_rc_send_wqe::ctrl, data, io_buffer::data, hermonprm_rc_send_wqe::data, ds, HERMON_OPCODE_SEND, ib_get_drvdata(), iob_len(), hermon::lkey, MLX_FILL_1, MLX_FILL_H, offsetof, hermon_send_wqe::rc, typeof(), and virt_to_bus().

◆ hermon_fill_eth_send_wqe()

static unsigned int hermon_fill_eth_send_wqe ( struct ib_device ibdev,
struct ib_queue_pair *qp  __unused,
struct ib_address_vector *dest  __unused,
struct io_buffer iobuf,
union hermon_send_wqe wqe 
)
static

Construct Ethernet send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
wqeSend work queue entry
Return values
opcodeControl opcode

Definition at line 1583 of file hermon.c.

1587  {
1588  struct hermon *hermon = ib_get_drvdata ( ibdev );
1589 
1590  /* Fill work queue entry */
1591  MLX_FILL_1 ( &wqe->eth.ctrl, 1, ds,
1592  ( ( offsetof ( typeof ( wqe->mlx ), data[1] ) / 16 ) ) );
1593  MLX_FILL_2 ( &wqe->eth.ctrl, 2,
1594  c, 0x03 /* generate completion */,
1595  s, 1 /* inhibit ICRC */ );
1596  MLX_FILL_1 ( &wqe->eth.data[0], 0,
1597  byte_count, iob_len ( iobuf ) );
1598  MLX_FILL_1 ( &wqe->eth.data[0], 1, l_key, hermon->lkey );
1599  MLX_FILL_H ( &wqe->eth.data[0], 2,
1600  local_address_h, virt_to_bus ( iobuf->data ) );
1601  MLX_FILL_1 ( &wqe->eth.data[0], 3,
1602  local_address_l, virt_to_bus ( iobuf->data ) );
1603  return HERMON_OPCODE_SEND;
1604 }
uint32_t c
Definition: md4.c:30
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
#define HERMON_OPCODE_SEND
Definition: hermon.h:42
__be32 byte_count
Definition: CIB_PRM.h:28
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:525
struct hermonprm_wqe_segment_ctrl_send ctrl
Definition: hermon.h:524
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
struct hermonprm_eth_send_wqe eth
Definition: hermon.h:664
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
uint32_t ds
Definition: librm.h:254
struct hermonprm_mlx_send_wqe mlx
Definition: hermon.h:662
void * data
Start of data.
Definition: iobuf.h:48
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:913

References byte_count, c, hermonprm_eth_send_wqe::ctrl, data, io_buffer::data, hermonprm_eth_send_wqe::data, ds, hermon_send_wqe::eth, HERMON_OPCODE_SEND, ib_get_drvdata(), iob_len(), hermon::lkey, hermon_send_wqe::mlx, MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, offsetof, typeof(), and virt_to_bus().

◆ hermon_post_send()

static int hermon_post_send ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector dest,
struct io_buffer iobuf 
)
static

Post send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
destDestination address vector
iobufI/O buffer
Return values
rcReturn status code

Definition at line 1629 of file hermon.c.

1632  {
1633  struct hermon *hermon = ib_get_drvdata ( ibdev );
1634  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1635  struct ib_work_queue *wq = &qp->send;
1636  struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
1637  union hermon_send_wqe *wqe;
1638  union hermonprm_doorbell_register db_reg;
1639  unsigned long wqe_idx_mask;
1640  unsigned long wqe_idx;
1641  unsigned int owner;
1642  unsigned int opcode;
1643 
1644  /* Allocate work queue entry */
1645  wqe_idx = ( wq->next_idx & ( hermon_send_wq->num_wqes - 1 ) );
1646  owner = ( ( wq->next_idx & hermon_send_wq->num_wqes ) ? 1 : 0 );
1647  wqe_idx_mask = ( wq->num_wqes - 1 );
1648  if ( wq->iobufs[ wqe_idx & wqe_idx_mask ] ) {
1649  DBGC ( hermon, "Hermon %p QPN %#lx send queue full",
1650  hermon, qp->qpn );
1651  return -ENOBUFS;
1652  }
1653  wq->iobufs[ wqe_idx & wqe_idx_mask ] = iobuf;
1654  wqe = &hermon_send_wq->wqe[wqe_idx];
1655 
1656  /* Construct work queue entry */
1657  memset ( ( ( ( void * ) wqe ) + 4 /* avoid ctrl.owner */ ), 0,
1658  ( sizeof ( *wqe ) - 4 ) );
1659  assert ( qp->type < ( sizeof ( hermon_fill_send_wqe ) /
1660  sizeof ( hermon_fill_send_wqe[0] ) ) );
1661  assert ( hermon_fill_send_wqe[qp->type] != NULL );
1662  opcode = hermon_fill_send_wqe[qp->type] ( ibdev, qp, dest, iobuf, wqe );
1663  barrier();
1664  MLX_FILL_2 ( &wqe->ctrl, 0,
1665  opcode, opcode,
1666  owner, owner );
1667  DBGCP ( hermon, "Hermon %p QPN %#lx posting send WQE %#lx:\n",
1668  hermon, qp->qpn, wqe_idx );
1669  DBGCP_HDA ( hermon, virt_to_phys ( wqe ), wqe, sizeof ( *wqe ) );
1670 
1671  /* Ring doorbell register */
1672  MLX_FILL_1 ( &db_reg.send, 0, qn, qp->qpn );
1673  barrier();
1674  writel ( db_reg.dword[0], hermon_send_wq->doorbell );
1675 
1676  /* Update work queue's index */
1677  wq->next_idx++;
1678 
1679  return 0;
1680 }
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
struct hermon_send_work_queue send
Send work queue.
Definition: hermon.h:744
void * doorbell
Doorbell register.
Definition: hermon.h:682
uint8_t opcode
Opcode.
Definition: ena.h:16
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
A Hermon send work queue entry.
Definition: hermon.h:659
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
#define DBGCP_HDA(...)
Definition: compiler.h:540
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static void * dest
Definition: strings.h:176
union hermon_send_wqe * wqe
Work queue entries.
Definition: hermon.h:678
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
unsigned long next_idx
Next work queue entry index.
Definition: infiniband.h:122
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
#define DBGCP(...)
Definition: compiler.h:539
A Hermon device.
Definition: hermon.h:864
A Hermon send work queue.
Definition: hermon.h:669
A Hermon queue pair.
Definition: hermon.h:736
static unsigned int(* hermon_fill_send_wqe[])(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf, union hermon_send_wqe *wqe)
Work queue entry constructors.
Definition: hermon.c:1608
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
unsigned int num_wqes
Number of work queue entries, including headroom.
Definition: hermon.h:676
void * memset(void *dest, int character, size_t len) __nonnull
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), barrier, DBGC, DBGCP, DBGCP_HDA, dest, hermon_send_work_queue::doorbell, hermonprm_doorbell_register::dword, ENOBUFS, hermon_fill_send_wqe, ib_get_drvdata(), ib_qp_get_drvdata(), ib_work_queue::iobufs, memset(), MLX_FILL_1, MLX_FILL_2, ib_work_queue::next_idx, NULL, ib_work_queue::num_wqes, hermon_send_work_queue::num_wqes, opcode, owner, qp, hermonprm_doorbell_register::send, hermon_queue_pair::send, virt_to_phys(), hermon_send_work_queue::wqe, and writel().

◆ hermon_post_recv()

static int hermon_post_recv ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct io_buffer iobuf 
)
static

Post receive work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
iobufI/O buffer
Return values
rcReturn status code

Definition at line 1690 of file hermon.c.

1692  {
1693  struct hermon *hermon = ib_get_drvdata ( ibdev );
1694  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1695  struct ib_work_queue *wq = &qp->recv;
1696  struct hermon_recv_work_queue *hermon_recv_wq = &hermon_qp->recv;
1697  struct hermonprm_recv_wqe *wqe;
1698  struct hermonprm_wqe_segment_data_ptr *data;
1699  struct ib_global_route_header *grh;
1700  unsigned int wqe_idx_mask;
1701 
1702  /* Allocate work queue entry */
1703  wqe_idx_mask = ( wq->num_wqes - 1 );
1704  if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
1705  DBGC ( hermon, "Hermon %p QPN %#lx receive queue full",
1706  hermon, qp->qpn );
1707  return -ENOBUFS;
1708  }
1709  wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1710  wqe = &hermon_recv_wq->wqe[wq->next_idx & wqe_idx_mask].recv;
1711 
1712  /* Construct work queue entry */
1713  data = &wqe->data[0];
1714  if ( hermon_qp->recv.grh ) {
1715  grh = &hermon_qp->recv.grh[wq->next_idx & wqe_idx_mask];
1716  MLX_FILL_1 ( data, 0, byte_count, sizeof ( *grh ) );
1717  MLX_FILL_1 ( data, 1, l_key, hermon->lkey );
1718  MLX_FILL_H ( data, 2, local_address_h, virt_to_bus ( grh ) );
1719  MLX_FILL_1 ( data, 3, local_address_l, virt_to_bus ( grh ) );
1720  data++;
1721  }
1722  MLX_FILL_1 ( data, 0, byte_count, iob_tailroom ( iobuf ) );
1723  MLX_FILL_1 ( data, 1, l_key, hermon->lkey );
1724  MLX_FILL_H ( data, 2, local_address_h, virt_to_bus ( iobuf->data ) );
1725  MLX_FILL_1 ( data, 3, local_address_l, virt_to_bus ( iobuf->data ) );
1726 
1727  /* Update work queue's index */
1728  wq->next_idx++;
1729 
1730  /* Update doorbell record */
1731  barrier();
1732  MLX_FILL_1 ( hermon_recv_wq->doorbell, 0, receive_wqe_counter,
1733  ( wq->next_idx & 0xffff ) );
1734 
1735  return 0;
1736 }
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:746
struct hermonprm_recv_wqe recv
Definition: hermon.h:690
#define DBGC(...)
Definition: compiler.h:505
__be32 byte_count
Definition: CIB_PRM.h:28
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
struct ib_global_route_header grh
Definition: ib_packet.h:16
struct hermonprm_qp_db_record * doorbell
Doorbell record.
Definition: hermon.h:705
union hermon_recv_wqe * wqe
Work queue entries.
Definition: hermon.h:697
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
An Infiniband Work Queue.
Definition: infiniband.h:100
An Infiniband Global Route Header.
Definition: ib_packet.h:89
A Hermon receive work queue.
Definition: hermon.h:695
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:175
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER]
Definition: hermon.h:531
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
unsigned long next_idx
Next work queue entry index.
Definition: infiniband.h:122
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
void * data
Start of data.
Definition: iobuf.h:48
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864
A Hermon queue pair.
Definition: hermon.h:736
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:913
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:701
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References barrier, byte_count, data, io_buffer::data, hermonprm_recv_wqe::data, DBGC, hermon_recv_work_queue::doorbell, ENOBUFS, grh, hermon_recv_work_queue::grh, ib_get_drvdata(), ib_qp_get_drvdata(), iob_tailroom(), ib_work_queue::iobufs, hermon::lkey, MLX_FILL_1, MLX_FILL_H, ib_work_queue::next_idx, ib_work_queue::num_wqes, qp, hermon_recv_wqe::recv, hermon_queue_pair::recv, virt_to_bus(), and hermon_recv_work_queue::wqe.

◆ hermon_complete()

static int hermon_complete ( struct ib_device ibdev,
struct ib_completion_queue cq,
union hermonprm_completion_entry cqe 
)
static

Handle completion.

Parameters
ibdevInfiniband device
cqCompletion queue
cqeHardware completion queue entry
Return values
rcReturn status code

Definition at line 1746 of file hermon.c.

1748  {
1749  struct hermon *hermon = ib_get_drvdata ( ibdev );
1750  struct hermon_queue_pair *hermon_qp;
1751  struct ib_work_queue *wq;
1752  struct ib_queue_pair *qp;
1753  struct io_buffer *iobuf;
1754  struct ib_address_vector recv_dest;
1755  struct ib_address_vector recv_source;
1756  struct ib_global_route_header *grh;
1757  struct ib_address_vector *source;
1758  unsigned int opcode;
1759  unsigned long qpn;
1760  int is_send;
1761  unsigned long wqe_idx;
1762  unsigned long wqe_idx_mask;
1763  size_t len;
1764  int rc = 0;
1765 
1766  /* Parse completion */
1767  qpn = MLX_GET ( &cqe->normal, qpn );
1768  is_send = MLX_GET ( &cqe->normal, s_r );
1769  opcode = MLX_GET ( &cqe->normal, opcode );
1770  if ( opcode >= HERMON_OPCODE_RECV_ERROR ) {
1771  /* "s" field is not valid for error opcodes */
1772  is_send = ( opcode == HERMON_OPCODE_SEND_ERROR );
1773  DBGC ( hermon, "Hermon %p CQN %#lx syndrome %x vendor %x\n",
1774  hermon, cq->cqn, MLX_GET ( &cqe->error, syndrome ),
1775  MLX_GET ( &cqe->error, vendor_error_syndrome ) );
1776  rc = -EIO;
1777  /* Don't return immediately; propagate error to completer */
1778  }
1779 
1780  /* Identify work queue */
1781  wq = ib_find_wq ( cq, qpn, is_send );
1782  if ( ! wq ) {
1783  DBGC ( hermon, "Hermon %p CQN %#lx unknown %s QPN %#lx\n",
1784  hermon, cq->cqn, ( is_send ? "send" : "recv" ), qpn );
1785  return -EIO;
1786  }
1787  qp = wq->qp;
1788  hermon_qp = ib_qp_get_drvdata ( qp );
1789 
1790  /* Identify work queue entry */
1791  wqe_idx = MLX_GET ( &cqe->normal, wqe_counter );
1792  wqe_idx_mask = ( wq->num_wqes - 1 );
1793  DBGCP ( hermon, "Hermon %p CQN %#lx QPN %#lx %s WQE %#lx completed:\n",
1794  hermon, cq->cqn, qp->qpn, ( is_send ? "send" : "recv" ),
1795  wqe_idx );
1796  DBGCP_HDA ( hermon, virt_to_phys ( cqe ), cqe, sizeof ( *cqe ) );
1797 
1798  /* Identify I/O buffer */
1799  iobuf = wq->iobufs[ wqe_idx & wqe_idx_mask ];
1800  if ( ! iobuf ) {
1801  DBGC ( hermon, "Hermon %p CQN %#lx QPN %#lx empty %s WQE "
1802  "%#lx\n", hermon, cq->cqn, qp->qpn,
1803  ( is_send ? "send" : "recv" ), wqe_idx );
1804  return -EIO;
1805  }
1806  wq->iobufs[ wqe_idx & wqe_idx_mask ] = NULL;
1807 
1808  if ( is_send ) {
1809  /* Hand off to completion handler */
1810  ib_complete_send ( ibdev, qp, iobuf, rc );
1811  } else if ( rc != 0 ) {
1812  /* Dump queue state (for debugging) */
1814  /* Hand off to completion handler */
1815  ib_complete_recv ( ibdev, qp, NULL, NULL, iobuf, rc );
1816  } else {
1817  /* Set received length */
1818  len = MLX_GET ( &cqe->normal, byte_cnt );
1819  memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1820  recv_dest.qpn = qpn;
1821  memset ( &recv_source, 0, sizeof ( recv_source ) );
1822  switch ( qp->type ) {
1823  case IB_QPT_SMI:
1824  case IB_QPT_GSI:
1825  case IB_QPT_UD:
1826  /* Locate corresponding GRH */
1827  assert ( hermon_qp->recv.grh != NULL );
1828  grh = &hermon_qp->recv.grh[ wqe_idx & wqe_idx_mask ];
1829  len -= sizeof ( *grh );
1830  /* Construct address vector */
1831  source = &recv_source;
1832  source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
1833  source->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
1834  source->sl = MLX_GET ( &cqe->normal, sl );
1835  recv_dest.gid_present = source->gid_present =
1836  MLX_GET ( &cqe->normal, g );
1837  memcpy ( &recv_dest.gid, &grh->dgid,
1838  sizeof ( recv_dest.gid ) );
1839  memcpy ( &source->gid, &grh->sgid,
1840  sizeof ( source->gid ) );
1841  break;
1842  case IB_QPT_RC:
1843  source = &qp->av;
1844  break;
1845  case IB_QPT_ETH:
1846  /* Construct address vector */
1847  source = &recv_source;
1848  source->vlan_present = MLX_GET ( &cqe->normal, vlan );
1849  source->vlan = MLX_GET ( &cqe->normal, vid );
1850  break;
1851  default:
1852  assert ( 0 );
1853  return -EINVAL;
1854  }
1855  assert ( len <= iob_tailroom ( iobuf ) );
1856  iob_put ( iobuf, len );
1857  /* Hand off to completion handler */
1858  ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, 0 );
1859  }
1860 
1861  return rc;
1862 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:746
uint8_t opcode
Opcode.
Definition: ena.h:16
uint32_t g
Definition: sha256.c:34
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:642
struct ib_global_route_header grh
Definition: ib_packet.h:16
#define HERMON_OPCODE_RECV_ERROR
Definition: hermon.h:43
unsigned int gid_present
GID is present.
Definition: infiniband.h:90
unsigned int vlan
VLAN, if present.
Definition: infiniband.h:96
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
__be32 qpn
Definition: CIB_PRM.h:29
union ib_gid dgid
Destiniation GID.
Definition: ib_packet.h:106
#define DBGCP_HDA(...)
Definition: compiler.h:540
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
void ib_complete_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Complete send work queue entry.
Definition: infiniband.c:515
__be16 wqe_counter
Definition: CIB_PRM.h:36
An Infiniband Global Route Header.
Definition: ib_packet.h:89
struct ib_work_queue * ib_find_wq(struct ib_completion_queue *cq, unsigned long qpn, int is_send)
Find work queue belonging to completion queue.
Definition: infiniband.c:396
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
struct hermonprm_completion_with_error error
Definition: hermon.h:536
union ib_gid sgid
Source GID.
Definition: ib_packet.h:104
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
u8 sl
Definition: CIB_PRM.h:42
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:175
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
#define HERMON_OPCODE_SEND_ERROR
Definition: hermon.h:44
uint16_t syndrome
ID of event.
Definition: ena.h:14
An Infiniband Queue Pair.
Definition: infiniband.h:157
unsigned int sl
Service level.
Definition: infiniband.h:88
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14
#define EIO
Input/output error.
Definition: errno.h:433
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
static int hermon_dump_qpctx(struct hermon *hermon, struct ib_queue_pair *qp)
Dump queue pair context (for debugging only)
Definition: hermon.c:1106
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:535
#define DBGCP(...)
Definition: compiler.h:539
void ib_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Complete receive work queue entry.
Definition: infiniband.c:536
A Hermon device.
Definition: hermon.h:864
An Infiniband Address Vector.
Definition: infiniband.h:72
A Hermon queue pair.
Definition: hermon.h:736
unsigned int lid
Local ID.
Definition: infiniband.h:81
unsigned int vlan_present
VLAN is present.
Definition: infiniband.h:94
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
__be32 byte_cnt
Definition: CIB_PRM.h:37
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:701
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:33
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), byte_cnt, ib_completion_queue::cqn, DBGC, DBGCP, DBGCP_HDA, ib_global_route_header::dgid, EINVAL, EIO, hermonprm_completion_entry::error, g, ib_address_vector::gid, ib_address_vector::gid_present, grh, hermon_recv_work_queue::grh, hermon_dump_qpctx(), HERMON_OPCODE_RECV_ERROR, HERMON_OPCODE_SEND_ERROR, ib_complete_recv(), ib_complete_send(), ib_find_wq(), ib_get_drvdata(), ib_qp_get_drvdata(), IB_QPT_ETH, IB_QPT_GSI, IB_QPT_RC, IB_QPT_SMI, IB_QPT_UD, iob_put, iob_tailroom(), ib_work_queue::iobufs, len, ib_address_vector::lid, memcpy(), memset(), MLX_GET, hermonprm_completion_entry::normal, NULL, ib_work_queue::num_wqes, opcode, qp, ib_work_queue::qp, qpn, ib_address_vector::qpn, rc, hermon_queue_pair::recv, ib_global_route_header::sgid, sl, ib_address_vector::sl, syndrome, virt_to_phys(), ib_address_vector::vlan, ib_address_vector::vlan_present, and wqe_counter.

Referenced by hermon_poll_cq().

◆ hermon_poll_cq()

static void hermon_poll_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Poll completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 1870 of file hermon.c.

1871  {
1872  struct hermon *hermon = ib_get_drvdata ( ibdev );
1873  struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
1874  union hermonprm_completion_entry *cqe;
1875  unsigned int cqe_idx_mask;
1876  int rc;
1877 
1878  while ( 1 ) {
1879  /* Look for completion entry */
1880  cqe_idx_mask = ( cq->num_cqes - 1 );
1881  cqe = &hermon_cq->cqe[cq->next_idx & cqe_idx_mask];
1882  if ( MLX_GET ( &cqe->normal, owner ) ^
1883  ( ( cq->next_idx & cq->num_cqes ) ? 1 : 0 ) ) {
1884  /* Entry still owned by hardware; end of poll */
1885  break;
1886  }
1887 
1888  /* Handle completion */
1889  if ( ( rc = hermon_complete ( ibdev, cq, cqe ) ) != 0 ) {
1890  DBGC ( hermon, "Hermon %p CQN %#lx failed to complete:"
1891  " %s\n", hermon, cq->cqn, strerror ( rc ) );
1892  DBGC_HDA ( hermon, virt_to_phys ( cqe ),
1893  cqe, sizeof ( *cqe ) );
1894  }
1895 
1896  /* Update completion queue's index */
1897  cq->next_idx++;
1898 
1899  /* Update doorbell record */
1900  MLX_FILL_1 ( hermon_cq->doorbell, 0, update_ci,
1901  ( cq->next_idx & 0x00ffffffUL ) );
1902  }
1903 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
A Hermon completion queue.
Definition: hermon.h:758
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
Definition: hermon.h:534
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
unsigned long next_idx
Next completion queue entry index.
Definition: infiniband.h:240
struct hermonprm_cq_db_record * doorbell
Doorbell record.
Definition: hermon.h:766
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:760
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:535
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
A Hermon device.
Definition: hermon.h:864
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:686
static int hermon_complete(struct ib_device *ibdev, struct ib_completion_queue *cq, union hermonprm_completion_entry *cqe)
Handle completion.
Definition: hermon.c:1746

References hermon_completion_queue::cqe, ib_completion_queue::cqn, DBGC, DBGC_HDA, hermon_completion_queue::doorbell, hermon_complete(), ib_cq_get_drvdata(), ib_get_drvdata(), MLX_FILL_1, MLX_GET, ib_completion_queue::next_idx, hermonprm_completion_entry::normal, ib_completion_queue::num_cqes, owner, rc, strerror(), and virt_to_phys().

◆ hermon_dump_eqctx()

static int hermon_dump_eqctx ( struct hermon hermon,
struct hermon_event_queue hermon_eq 
)
static

Dump event queue context (for debugging only)

Parameters
hermonHermon device
hermon_eqEvent queue
Return values
rcReturn status code

Definition at line 1920 of file hermon.c.

1921  {
1922  struct hermonprm_eqc eqctx;
1923  int rc;
1924 
1925  /* Do nothing unless debugging is enabled */
1926  if ( ! DBG_LOG )
1927  return 0;
1928 
1929  /* Dump event queue context */
1930  memset ( &eqctx, 0, sizeof ( eqctx ) );
1931  if ( ( rc = hermon_cmd_query_eq ( hermon, hermon_eq->eqn,
1932  &eqctx ) ) != 0 ) {
1933  DBGC ( hermon, "Hermon %p EQN %#lx QUERY_EQ failed: %s\n",
1934  hermon, hermon_eq->eqn, strerror ( rc ) );
1935  return rc;
1936  }
1937  DBGC ( hermon, "Hermon %p EQN %#lx context:\n",
1938  hermon, hermon_eq->eqn );
1939  DBGC_HDA ( hermon, 0, &eqctx, sizeof ( eqctx ) );
1940 
1941  return 0;
1942 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static int hermon_cmd_query_eq(struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
Definition: hermon.c:378
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A Hermon device.
Definition: hermon.h:864
unsigned long eqn
Event queue number.
Definition: hermon.h:784
#define DBG_LOG
Definition: compiler.h:317
void * memset(void *dest, int character, size_t len) __nonnull

References DBG_LOG, DBGC, DBGC_HDA, hermon_event_queue::eqn, hermon_cmd_query_eq(), memset(), rc, and strerror().

◆ hermon_dump_eqes()

static int hermon_dump_eqes ( struct hermon hermon,
struct hermon_event_queue hermon_eq 
)
static

Dump unconsumed event queue entries (for debugging only)

Parameters
hermonHermon device
hermon_eqEvent queue
Return values
rcReturn status code

Definition at line 1952 of file hermon.c.

1953  {
1954  struct hermonprm_eqc eqctx;
1955  union hermonprm_event_entry *eqe;
1956  unsigned int mask;
1957  unsigned int prod;
1958  unsigned int cons;
1959  unsigned int idx;
1960  int rc;
1961 
1962  /* Do nothing unless debugging is enabled */
1963  if ( ! DBG_LOG )
1964  return 0;
1965 
1966  /* Dump event queue entries */
1967  memset ( &eqctx, 0, sizeof ( eqctx ) );
1968  if ( ( rc = hermon_cmd_query_eq ( hermon, hermon_eq->eqn,
1969  &eqctx ) ) != 0 ) {
1970  DBGC ( hermon, "Hermon %p EQN %#lx QUERY_EQ failed: %s\n",
1971  hermon, hermon_eq->eqn, strerror ( rc ) );
1972  return rc;
1973  }
1974  mask = ( HERMON_NUM_EQES - 1 );
1975  prod = MLX_GET ( &eqctx, producer_counter ) & mask;
1976  cons = MLX_GET ( &eqctx, consumer_counter ) & mask;
1977  idx = hermon_eq->next_idx;
1978  if ( ( idx & mask ) != ( cons & mask ) ) {
1979  DBGC ( hermon, "Hermon %p EQN %#lx mismatch: SW %#x != HW "
1980  "%#x\n", hermon, hermon_eq->eqn, idx, cons );
1981  }
1982  for ( ; ( idx & mask ) != ( prod & mask ) ; idx++ ) {
1983  eqe = &hermon_eq->eqe[idx & mask];
1984  DBGC ( hermon, "Hermon %p EQN %#lx event %#x owner %d type "
1985  "%#02x:%#02x\n", hermon, hermon_eq->eqn, idx,
1986  MLX_GET ( &eqe->generic, owner ),
1987  MLX_GET ( &eqe->generic, event_type ),
1988  MLX_GET ( &eqe->generic, event_sub_type ) );
1989  DBGC_HDA ( hermon, 0, eqe, sizeof ( *eqe ) );
1990  }
1991 
1992  return 0;
1993 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
static int hermon_cmd_query_eq(struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
Definition: hermon.c:378
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:778
__be32 producer_counter
Definition: CIB_PRM.h:44
struct hermonprm_event_queue_entry generic
Definition: hermon.h:540
#define DBGC_HDA(...)
Definition: compiler.h:506
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint16_t cons
Consumer index.
Definition: ena.h:22
Definition: hermon.h:539
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
__be32 consumer_counter
Definition: CIB_PRM.h:38
A Hermon device.
Definition: hermon.h:864
unsigned long next_idx
Next event queue entry index.
Definition: hermon.h:786
unsigned long eqn
Event queue number.
Definition: hermon.h:784
#define DBG_LOG
Definition: compiler.h:317
#define HERMON_NUM_EQES
Number of event queue entries.
Definition: hermon.h:795
void * memset(void *dest, int character, size_t len) __nonnull

References cons, consumer_counter, DBG_LOG, DBGC, DBGC_HDA, hermon_event_queue::eqe, hermon_event_queue::eqn, hermonprm_event_entry::generic, hermon_cmd_query_eq(), HERMON_NUM_EQES, memset(), MLX_GET, hermon_event_queue::next_idx, owner, producer_counter, rc, and strerror().

◆ hermon_create_eq()

static int hermon_create_eq ( struct hermon hermon)
static

Create event queue.

Parameters
hermonHermon device
Return values
rcReturn status code

Definition at line 2001 of file hermon.c.

2001  {
2002  struct hermon_event_queue *hermon_eq = &hermon->eq;
2003  struct hermonprm_eqc eqctx;
2004  struct hermonprm_event_mask mask;
2005  unsigned int i;
2006  int rc;
2007 
2008  /* Select event queue number */
2009  hermon_eq->eqn = ( 4 * hermon->cap.reserved_uars );
2010  if ( hermon_eq->eqn < hermon->cap.reserved_eqs )
2011  hermon_eq->eqn = hermon->cap.reserved_eqs;
2012 
2013  /* Calculate doorbell address */
2014  hermon_eq->doorbell =
2015  ( hermon->uar + HERMON_DB_EQ_OFFSET ( hermon_eq->eqn ) );
2016 
2017  /* Allocate event queue itself */
2018  hermon_eq->eqe_size =
2019  ( HERMON_NUM_EQES * sizeof ( hermon_eq->eqe[0] ) );
2020  hermon_eq->eqe = malloc_phys ( hermon_eq->eqe_size,
2021  sizeof ( hermon_eq->eqe[0] ) );
2022  if ( ! hermon_eq->eqe ) {
2023  DBGC ( hermon, "Hermon %p EQN %#lx could not allocate EQEs\n",
2024  hermon, hermon_eq->eqn );
2025  rc = -ENOMEM;
2026  goto err_eqe;
2027  }
2028  memset ( hermon_eq->eqe, 0, hermon_eq->eqe_size );
2029  for ( i = 0 ; i < HERMON_NUM_EQES ; i++ ) {
2030  MLX_FILL_1 ( &hermon_eq->eqe[i].generic, 7, owner, 1 );
2031  }
2032  barrier();
2033 
2034  /* Allocate MTT entries */
2035  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_eq->eqe,
2036  hermon_eq->eqe_size,
2037  &hermon_eq->mtt ) ) != 0 ) {
2038  DBGC ( hermon, "Hermon %p EQN %#lx could not allocate MTTs: "
2039  "%s\n", hermon, hermon_eq->eqn, strerror ( rc ) );
2040  goto err_alloc_mtt;
2041  }
2042 
2043  /* Hand queue over to hardware */
2044  memset ( &eqctx, 0, sizeof ( eqctx ) );
2045  MLX_FILL_2 ( &eqctx, 0,
2046  st, 0xa /* "Fired" */,
2047  oi, 1 );
2048  MLX_FILL_1 ( &eqctx, 2,
2049  page_offset, ( hermon_eq->mtt.page_offset >> 5 ) );
2050  MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( HERMON_NUM_EQES - 1 ) );
2051  MLX_FILL_H ( &eqctx, 6, mtt_base_addr_h,
2052  hermon_eq->mtt.mtt_base_addr );
2053  MLX_FILL_1 ( &eqctx, 7, mtt_base_addr_l,
2054  ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
2055  if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
2056  &eqctx ) ) != 0 ) {
2057  DBGC ( hermon, "Hermon %p EQN %#lx SW2HW_EQ failed: %s\n",
2058  hermon, hermon_eq->eqn, strerror ( rc ) );
2059  goto err_sw2hw_eq;
2060  }
2061 
2062  /* Map all events to this event queue */
2063  memset ( &mask, 0xff, sizeof ( mask ) );
2064  if ( ( rc = hermon_cmd_map_eq ( hermon,
2065  ( HERMON_MAP_EQ | hermon_eq->eqn ),
2066  &mask ) ) != 0 ) {
2067  DBGC ( hermon, "Hermon %p EQN %#lx MAP_EQ failed: %s\n",
2068  hermon, hermon_eq->eqn, strerror ( rc ) );
2069  goto err_map_eq;
2070  }
2071 
2072  DBGC ( hermon, "Hermon %p EQN %#lx ring [%08lx,%08lx), doorbell "
2073  "%08lx\n", hermon, hermon_eq->eqn,
2074  virt_to_phys ( hermon_eq->eqe ),
2075  ( virt_to_phys ( hermon_eq->eqe ) + hermon_eq->eqe_size ),
2076  virt_to_phys ( hermon_eq->doorbell ) );
2077  return 0;
2078 
2079  err_map_eq:
2080  hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn, &eqctx );
2081  err_sw2hw_eq:
2082  hermon_free_mtt ( hermon, &hermon_eq->mtt );
2083  err_alloc_mtt:
2084  free_phys ( hermon_eq->eqe, hermon_eq->eqe_size );
2085  err_eqe:
2086  memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
2087  return rc;
2088 }
size_t eqe_size
Size of event queue.
Definition: hermon.h:780
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
static int hermon_cmd_sw2hw_eq(struct hermon *hermon, unsigned int index, const struct hermonprm_eqc *eqctx)
Definition: hermon.c:360
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:624
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
static int hermon_cmd_hw2sw_eq(struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
Definition: hermon.c:369
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:778
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
struct sockaddr_tcpip st
Definition: syslog.c:56
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:782
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:650
#define HERMON_MAP_EQ
Definition: hermon.h:115
struct hermonprm_event_queue_entry generic
Definition: hermon.h:540
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:906
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
void * uar
PCI user Access Region.
Definition: hermon.h:870
#define MLX_FILL_H(_structure_st, _index, _field, _address)
Definition: mlx_bitops.h:240
unsigned int reserved_eqs
Number of reserved EQs.
Definition: hermon.h:590
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
void * doorbell
Doorbell register.
Definition: hermon.h:788
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
unsigned int page_offset
Offset within page.
Definition: hermon.h:652
#define HERMON_DB_EQ_OFFSET(_eqn)
Definition: hermon.h:108
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
__be16 page_offset
Definition: CIB_PRM.h:33
unsigned int reserved_uars
Number of reserved UARs.
Definition: hermon.h:602
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static int hermon_cmd_map_eq(struct hermon *hermon, unsigned long index_map, const struct hermonprm_event_mask *mask)
Definition: hermon.c:351
unsigned long eqn
Event queue number.
Definition: hermon.h:784
#define HERMON_NUM_EQES
Number of event queue entries.
Definition: hermon.h:795
void * memset(void *dest, int character, size_t len) __nonnull
A Hermon event queue.
Definition: hermon.h:776

References barrier, hermon::cap, DBGC, hermon_event_queue::doorbell, ENOMEM, hermon::eq, hermon_event_queue::eqe, hermon_event_queue::eqe_size, hermon_event_queue::eqn, fls, free_phys(), hermonprm_event_entry::generic, hermon_alloc_mtt(), hermon_cmd_hw2sw_eq(), hermon_cmd_map_eq(), hermon_cmd_sw2hw_eq(), HERMON_DB_EQ_OFFSET, hermon_free_mtt(), HERMON_MAP_EQ, HERMON_NUM_EQES, malloc_phys(), memset(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, hermon_event_queue::mtt, hermon_mtt::mtt_base_addr, owner, page_offset, hermon_mtt::page_offset, rc, hermon_dev_cap::reserved_eqs, hermon_dev_cap::reserved_uars, st, strerror(), hermon::uar, and virt_to_phys().

Referenced by hermon_start().

◆ hermon_destroy_eq()

static void hermon_destroy_eq ( struct hermon hermon)
static

Destroy event queue.

Parameters
hermonHermon device

Definition at line 2095 of file hermon.c.

2095  {
2096  struct hermon_event_queue *hermon_eq = &hermon->eq;
2097  struct hermonprm_eqc eqctx;
2098  struct hermonprm_event_mask mask;
2099  int rc;
2100 
2101  /* Unmap events from event queue */
2102  memset ( &mask, 0xff, sizeof ( mask ) );
2103  if ( ( rc = hermon_cmd_map_eq ( hermon,
2104  ( HERMON_UNMAP_EQ | hermon_eq->eqn ),
2105  &mask ) ) != 0 ) {
2106  DBGC ( hermon, "Hermon %p EQN %#lx FATAL MAP_EQ failed to "
2107  "unmap: %s\n", hermon, hermon_eq->eqn, strerror ( rc ) );
2108  /* Continue; HCA may die but system should survive */
2109  }
2110 
2111  /* Take ownership back from hardware */
2112  if ( ( rc = hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn,
2113  &eqctx ) ) != 0 ) {
2114  DBGC ( hermon, "Hermon %p EQN %#lx FATAL HW2SW_EQ failed: %s\n",
2115  hermon, hermon_eq->eqn, strerror ( rc ) );
2116  /* Leak memory and return; at least we avoid corruption */
2117  return;
2118  }
2119 
2120  /* Free MTT entries */
2121  hermon_free_mtt ( hermon, &hermon_eq->mtt );
2122 
2123  /* Free memory */
2124  free_phys ( hermon_eq->eqe, hermon_eq->eqe_size );
2125  memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
2126 }
size_t eqe_size
Size of event queue.
Definition: hermon.h:780
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static int hermon_cmd_hw2sw_eq(struct hermon *hermon, unsigned int index, struct hermonprm_eqc *eqctx)
Definition: hermon.c:369
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:778
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:782
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:906
#define HERMON_UNMAP_EQ
Definition: hermon.h:116
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:700
A Hermon device.
Definition: hermon.h:864
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
static int hermon_cmd_map_eq(struct hermon *hermon, unsigned long index_map, const struct hermonprm_event_mask *mask)
Definition: hermon.c:351
unsigned long eqn
Event queue number.
Definition: hermon.h:784
void * memset(void *dest, int character, size_t len) __nonnull
A Hermon event queue.
Definition: hermon.h:776

References DBGC, hermon::eq, hermon_event_queue::eqe, hermon_event_queue::eqe_size, hermon_event_queue::eqn, free_phys(), hermon_cmd_hw2sw_eq(), hermon_cmd_map_eq(), hermon_free_mtt(), HERMON_UNMAP_EQ, memset(), hermon_event_queue::mtt, rc, and strerror().

Referenced by hermon_start(), and hermon_stop().

◆ hermon_event_port_state_change()

static void hermon_event_port_state_change ( struct hermon hermon,
union hermonprm_event_entry eqe 
)
static

Handle port state event.

Parameters
hermonHermon device
eqePort state change event queue entry

Definition at line 2134 of file hermon.c.

2135  {
2136  unsigned int port;
2137  int link_up;
2138 
2139  /* Get port and link status */
2140  port = ( MLX_GET ( &eqe->port_state_change, data.p ) - 1 );
2141  link_up = ( MLX_GET ( &eqe->generic, event_sub_type ) & 0x04 );
2142  DBGC ( hermon, "Hermon %p port %d link %s\n", hermon, ( port + 1 ),
2143  ( link_up ? "up" : "down" ) );
2144 
2145  /* Sanity check */
2146  if ( port >= hermon->cap.num_ports ) {
2147  DBGC ( hermon, "Hermon %p port %d does not exist!\n",
2148  hermon, ( port + 1 ) );
2149  return;
2150  }
2151 
2152  /* Notify device of port state change */
2154  link_up );
2155 }
#define DBGC(...)
Definition: compiler.h:505
unsigned int num_ports
Number of ports.
Definition: hermon.h:604
u8 port
Port number.
Definition: CIB_PRM.h:31
struct hermonprm_event_queue_entry generic
Definition: hermon.h:540
struct hermon_port_type * type
Port type.
Definition: hermon.h:858
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
struct hermonprm_port_state_change_event port_state_change
Definition: hermon.h:541
struct hermon_port port[HERMON_MAX_PORTS]
Ports.
Definition: hermon.h:933
void(* state_change)(struct hermon *hermon, struct hermon_port *port, int link_up)
Port state changed.
Definition: hermon.h:824
uint8_t data[48]
Additional event data.
Definition: ena.h:22
A Hermon device.
Definition: hermon.h:864

References hermon::cap, data, DBGC, hermonprm_event_entry::generic, MLX_GET, hermon_dev_cap::num_ports, port, hermon::port, hermonprm_event_entry::port_state_change, hermon_port_type::state_change, and hermon_port::type.

Referenced by hermon_poll_eq().

◆ hermon_event_port_mgmnt_change()

static void hermon_event_port_mgmnt_change ( struct hermon hermon,
union hermonprm_event_entry eqe 
)
static

Handle port management event.

Parameters
hermonHermon device
eqePort management change event queue entry

Definition at line 2163 of file hermon.c.

2164  {
2165  unsigned int port;
2166 
2167  /* Get port */
2168  port = ( MLX_GET ( &eqe->port_mgmnt_change, port ) - 1 );
2169  DBGC ( hermon, "Hermon %p port %d management change\n",
2170  hermon, ( port + 1 ) );
2171 
2172  /* Sanity check */
2173  if ( port >= hermon->cap.num_ports ) {
2174  DBGC ( hermon, "Hermon %p port %d does not exist!\n",
2175  hermon, ( port + 1 ) );
2176  return;
2177  }
2178 
2179  /* Update MAD parameters */
2181 }
struct hermonprm_port_mgmnt_change_event port_mgmnt_change
Definition: hermon.h:542
struct ib_device * ibdev
Infiniband device.
Definition: hermon.h:848
#define DBGC(...)
Definition: compiler.h:505
unsigned int num_ports
Number of ports.
Definition: hermon.h:604
u8 port
Port number.
Definition: CIB_PRM.h:31
static int hermon_mad(struct ib_device *ibdev, union ib_mad *mad)
Issue management datagram.
Definition: hermon.c:777
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
int ib_smc_update(struct ib_device *ibdev, ib_local_mad_t local_mad)
Update Infiniband parameters using SMC.
Definition: ib_smc.c:249
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:923
struct hermon_port port[HERMON_MAX_PORTS]
Ports.
Definition: hermon.h:933
A Hermon device.
Definition: hermon.h:864

References hermon::cap, DBGC, hermon_mad(), ib_smc_update(), hermon_port::ibdev, MLX_GET, hermon_dev_cap::num_ports, port, hermon::port, and hermonprm_event_entry::port_mgmnt_change.

Referenced by hermon_poll_eq().

◆ hermon_poll_eq()

static void hermon_poll_eq ( struct ib_device ibdev)
static

Poll event queue.

Parameters
ibdevInfiniband device

Definition at line 2188 of file hermon.c.

2188  {
2189  struct hermon *hermon = ib_get_drvdata ( ibdev );
2190  struct hermon_event_queue *hermon_eq = &hermon->eq;
2191  union hermonprm_event_entry *eqe;
2192  union hermonprm_doorbell_register db_reg;
2193  unsigned long now;
2194  unsigned long elapsed;
2195  unsigned int eqe_idx_mask;
2196  unsigned int event_type;
2197 
2198  /* No event is generated upon reaching INIT, so we must poll
2199  * separately for link state changes while we remain DOWN.
2200  */
2201  if ( ib_is_open ( ibdev ) &&
2202  ( ibdev->port_state == IB_PORT_STATE_DOWN ) ) {
2203  now = currticks();
2204  elapsed = ( now - hermon->last_poll );
2205  if ( elapsed >= HERMON_LINK_POLL_INTERVAL ) {
2206  hermon->last_poll = now;
2207  ib_smc_update ( ibdev, hermon_mad );
2208  }
2209  }
2210 
2211  /* Poll event queue */
2212  while ( 1 ) {
2213  /* Look for event entry */
2214  eqe_idx_mask = ( HERMON_NUM_EQES - 1 );
2215  eqe = &hermon_eq->eqe[hermon_eq->next_idx & eqe_idx_mask];
2216  if ( MLX_GET ( &eqe->generic, owner ) ^
2217  ( ( hermon_eq->next_idx & HERMON_NUM_EQES ) ? 1 : 0 ) ) {
2218  /* Entry still owned by hardware; end of poll */
2219  break;
2220  }
2221  DBGCP ( hermon, "Hermon %p EQN %#lx event:\n",
2222  hermon, hermon_eq->eqn );
2223  DBGCP_HDA ( hermon, virt_to_phys ( eqe ),
2224  eqe, sizeof ( *eqe ) );
2225 
2226  /* Handle event */
2227  event_type = MLX_GET ( &eqe->generic, event_type );
2228  switch ( event_type ) {
2231  break;
2234  break;
2235  default:
2236  DBGC ( hermon, "Hermon %p EQN %#lx unrecognised event "
2237  "type %#02x:%#02x\n",
2238  hermon, hermon_eq->eqn, event_type,
2239  MLX_GET ( &eqe->generic, event_sub_type ) );
2240  DBGC_HDA ( hermon, virt_to_phys ( eqe ),
2241  eqe, sizeof ( *eqe ) );
2242  break;
2243  }
2244 
2245  /* Update event queue's index */
2246  hermon_eq->next_idx++;
2247 
2248  /* Ring doorbell */
2249  MLX_FILL_1 ( &db_reg.event, 0,
2250  ci, ( hermon_eq->next_idx & 0x00ffffffUL ) );
2251  writel ( db_reg.dword[0], hermon_eq->doorbell );
2252  }
2253 }
static void hermon_event_port_state_change(struct hermon *hermon, union hermonprm_event_entry *eqe)
Handle port state event.
Definition: hermon.c:2134
static int ib_is_open(struct ib_device *ibdev)
Check whether or not Infiniband device is open.
Definition: infiniband.h:576
u8 owner
Definition: CIB_PRM.h:36
static void hermon_event_port_mgmnt_change(struct hermon *hermon, union hermonprm_event_entry *eqe)
Handle port management event.
Definition: hermon.c:2163
#define DBGC(...)
Definition: compiler.h:505
unsigned long last_poll
Last unsolicited link state poll.
Definition: hermon.h:908
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:778
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
pseudo_bit_t ci[0x00020]
Definition: arbel.h:11
#define DBGCP_HDA(...)
Definition: compiler.h:540
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
struct hermonprm_event_queue_entry generic
Definition: hermon.h:540
#define DBGC_HDA(...)
Definition: compiler.h:506
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static int hermon_mad(struct ib_device *ibdev, union ib_mad *mad)
Issue management datagram.
Definition: hermon.c:777
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:906
Definition: hermon.h:539
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
int ib_smc_update(struct ib_device *ibdev, ib_local_mad_t local_mad)
Update Infiniband parameters using SMC.
Definition: ib_smc.c:249
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
#define HERMON_LINK_POLL_INTERVAL
Link poll interval.
Definition: hermon.h:950
#define IB_PORT_STATE_DOWN
Definition: ib_mad.h:151