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   2
 Number of Hermon Ethernet send work queue entries. More...
 
#define HERMON_ETH_NUM_RECV_WQES   4
 Number of Hermon Ethernet receive work queue entries. More...
 
#define HERMON_ETH_NUM_CQES   8
 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_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_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_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 void 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_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 717 of file hermon.c.

◆ HERMON_ETH_NUM_SEND_WQES

#define HERMON_ETH_NUM_SEND_WQES   2

Number of Hermon Ethernet send work queue entries.

Definition at line 3140 of file hermon.c.

◆ HERMON_ETH_NUM_RECV_WQES

#define HERMON_ETH_NUM_RECV_WQES   4

Number of Hermon Ethernet receive work queue entries.

Definition at line 3143 of file hermon.c.

◆ HERMON_ETH_NUM_CQES

#define HERMON_ETH_NUM_CQES   8

Number of Hermon Ethernet completion entries.

Definition at line 3146 of file hermon.c.

◆ HERMON_SENSE_PORT_TIMEOUT

#define HERMON_SENSE_PORT_TIMEOUT   ( TICKS_PER_SEC / 2 )

Timeout for port sensing.

Definition at line 3492 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:205
uint32_t hermon_bitmask_t
A Hermon resource bitmask.
Definition: hermon.h:787
#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:205
uint32_t hermon_bitmask_t
A Hermon resource bitmask.
Definition: hermon.h:787
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 = 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  mdelay ( 1 );
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.
#define HERMON_HCR_REG(x)
Definition: hermon.h:927
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
void * config
PCI configuration registers.
Definition: hermon.h:846
unsigned int toggle
Command toggle.
Definition: hermon.h:851
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
A Hermon device.
Definition: hermon.h:842
#define HERMON_HCR_MAX_WAIT_MS
Definition: hermon.h:928

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

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 %02x 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 );
217  DBGC ( hermon, "Hermon %p issuing command %04x\n",
218  hermon, opcode );
220  &hcr, sizeof ( hcr ) );
221  if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
222  DBGC2 ( hermon, "Input mailbox:\n" );
223  DBGC2_HDA ( hermon, virt_to_phys ( in_buffer ), in_buffer,
224  ( ( in_len < 512 ) ? in_len : 512 ) );
225  }
226 
227  /* Issue command */
228  for ( i = 0 ; i < ( sizeof ( hcr ) / sizeof ( hcr.u.dwords[0] ) ) ;
229  i++ ) {
230  writel ( hcr.u.dwords[i],
231  hermon->config + HERMON_HCR_REG ( i ) );
232  barrier();
233  }
234 
235  /* Wait for command completion */
236  if ( ( rc = hermon_cmd_wait ( hermon, &hcr ) ) != 0 ) {
237  DBGC ( hermon, "Hermon %p timed out waiting for command:\n",
238  hermon );
239  DBGC_HDA ( hermon,
241  &hcr, sizeof ( hcr ) );
242  return rc;
243  }
244 
245  /* Check command status */
246  status = MLX_GET ( &hcr, status );
247  if ( status != 0 ) {
248  DBGC ( hermon, "Hermon %p command failed with status %02x:\n",
249  hermon, status );
250  DBGC_HDA ( hermon,
252  &hcr, sizeof ( hcr ) );
253  return -EIO;
254  }
255 
256  /* Read output parameters, if any */
257  hcr.u.dwords[3] = readl ( hermon->config + HERMON_HCR_REG ( 3 ) );
258  hcr.u.dwords[4] = readl ( hermon->config + HERMON_HCR_REG ( 4 ) );
259  memcpy ( out, out_buffer, out_len );
260  if ( out_len ) {
261  DBGC2 ( hermon, "Output%s:\n",
262  ( command & HERMON_HCR_OUT_MBOX ) ? " mailbox" : "" );
263  DBGC2_HDA ( hermon, virt_to_phys ( out_buffer ), out_buffer,
264  ( ( out_len < 512 ) ? out_len : 512 ) );
265  }
266 
267  return 0;
268 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define HERMON_HCR_OUT_LEN(_command)
Definition: hermon.h:947
#define MLX_FILL_4(_ptr, _index,...)
Definition: mlx_bitops.h:179
#define HERMON_HCR_BASE
Definition: hermon.h:926
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:853
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:946
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
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:943
void * mailbox_out
Command output mailbox.
Definition: hermon.h:855
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.
__be32 out[4]
Definition: CIB_PRM.h:36
#define DBGC2_HDA(...)
Definition: compiler.h:523
#define HERMON_HCR_REG(x)
Definition: hermon.h:927
#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:944
void * config
PCI configuration registers.
Definition: hermon.h:846
unsigned int toggle
Command toggle.
Definition: hermon.h:851
#define DBGC2(...)
Definition: compiler.h:522
#define HERMON_HCR_OPCODE(_command)
Definition: hermon.h:945
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
#define EIO
Input/output error.
Definition: errno.h:433
A Hermon device.
Definition: hermon.h:842
void * memset(void *dest, int character, size_t len) __nonnull
#define HERMON_MBOX_SIZE
Definition: hermon.h:930

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_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 271 of file hermon.c.

272  {
273  return hermon_cmd ( hermon,
275  1, sizeof ( *dev_cap ) ),
276  0, NULL, 0, dev_cap );
277 }
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:961
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 280 of file hermon.c.

280  {
281  return hermon_cmd ( hermon,
283  1, sizeof ( *fw ) ),
284  0, NULL, 0, fw );
285 }
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:961
#define HERMON_HCR_QUERY_FW
Definition: hermon.h:48
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 288 of file hermon.c.

289  {
290  return hermon_cmd ( hermon,
292  1, sizeof ( *init_hca ) ),
293  0, init_hca, 0, NULL );
294 }
#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:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 297 of file hermon.c.

297  {
298  return hermon_cmd ( hermon,
300  0, NULL, 0, NULL );
301 }
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:964
#define HERMON_HCR_CLOSE_HCA
Definition: hermon.h:50
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 304 of file hermon.c.

304  {
305  return hermon_cmd ( hermon,
307  0, NULL, port, NULL );
308 }
#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:964
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 311 of file hermon.c.

311  {
312  return hermon_cmd ( hermon,
314  0, NULL, port, NULL );
315 }
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:964
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 318 of file hermon.c.

320  {
321  return hermon_cmd ( hermon,
323  1, sizeof ( *set_port ) ),
324  is_ethernet, set_port, port_selector, NULL );
325 }
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:958
#define HERMON_HCR_SET_PORT
Definition: hermon.h:53
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 328 of file hermon.c.

329  {
330  return hermon_cmd ( hermon,
332  1, sizeof ( *mpt ) ),
333  0, mpt, index, NULL );
334 }
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:958
#define HERMON_HCR_SW2HW_MPT
Definition: hermon.h:54
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

Referenced by hermon_setup_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 337 of file hermon.c.

338  {
339  return hermon_cmd ( hermon,
341  1, sizeof ( *write_mtt ) ),
342  0, write_mtt, 1, NULL );
343 }
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:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define HERMON_HCR_WRITE_MTT
Definition: hermon.h:55

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 346 of file hermon.c.

347  {
348  return hermon_cmd ( hermon,
350  0, sizeof ( *mask ) ),
351  0, mask, index_map, NULL );
352 }
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:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define HERMON_HCR_MAP_EQ
Definition: hermon.h:56

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 355 of file hermon.c.

356  {
357  return hermon_cmd ( hermon,
359  1, sizeof ( *eqctx ) ),
360  0, eqctx, index, NULL );
361 }
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:958
#define HERMON_HCR_SW2HW_EQ
Definition: hermon.h:57
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 364 of file hermon.c.

365  {
366  return hermon_cmd ( hermon,
368  1, sizeof ( *eqctx ) ),
369  1, NULL, index, eqctx );
370 }
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:961
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define HERMON_HCR_HW2SW_EQ
Definition: hermon.h:58

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 373 of file hermon.c.

374  {
375  return hermon_cmd ( hermon,
377  1, sizeof ( *eqctx ) ),
378  0, NULL, index, eqctx );
379 }
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:59
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:961
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

◆ 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 382 of file hermon.c.

383  {
384  return hermon_cmd ( hermon,
386  1, sizeof ( *cqctx ) ),
387  0, cqctx, cqn, NULL );
388 }
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:958
#define HERMON_HCR_SW2HW_CQ
Definition: hermon.h:60
A Hermon device.
Definition: hermon.h:842
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 391 of file hermon.c.

392  {
393  return hermon_cmd ( hermon,
395  1, sizeof ( *cqctx ) ),
396  0, NULL, cqn, cqctx );
397 }
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:961
#define HERMON_HCR_HW2SW_CQ
Definition: hermon.h:61
A Hermon device.
Definition: hermon.h:842
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 400 of file hermon.c.

401  {
402  return hermon_cmd ( hermon,
404  1, sizeof ( *cqctx ) ),
405  0, NULL, cqn, cqctx );
406 }
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:62
#define HERMON_HCR_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:961
A Hermon device.
Definition: hermon.h:842
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 409 of file hermon.c.

410  {
411  return hermon_cmd ( hermon,
413  1, sizeof ( *ctx ) ),
414  0, ctx, qpn, NULL );
415 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
__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_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:958
#define HERMON_HCR_RST2INIT_QP
Definition: hermon.h:63
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 418 of file hermon.c.

419  {
420  return hermon_cmd ( hermon,
422  1, sizeof ( *ctx ) ),
423  0, ctx, qpn, NULL );
424 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
__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:64
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 427 of file hermon.c.

428  {
429  return hermon_cmd ( hermon,
431  1, sizeof ( *ctx ) ),
432  0, ctx, qpn, NULL );
433 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define HERMON_HCR_RTR2RTS_QP
Definition: hermon.h:65
__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_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 436 of file hermon.c.

437  {
438  return hermon_cmd ( hermon,
440  1, sizeof ( *ctx ) ),
441  0, ctx, qpn, NULL );
442 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
__be32 qpn
Definition: CIB_PRM.h:29
#define HERMON_HCR_RTS2RTS_QP
Definition: hermon.h:66
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:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 445 of file hermon.c.

445  {
446  return hermon_cmd ( hermon,
448  0x03, NULL, qpn, NULL );
449 }
__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:964
A Hermon device.
Definition: hermon.h:842
#define HERMON_HCR_2RST_QP
Definition: hermon.h:67
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 452 of file hermon.c.

453  {
454  return hermon_cmd ( hermon,
456  1, sizeof ( *ctx ) ),
457  0, NULL, qpn, ctx );
458 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
__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_OUT_CMD(_opcode, _out_mbox, _out_len)
Definition: hermon.h:961
A Hermon device.
Definition: hermon.h:842
#define HERMON_HCR_QUERY_QP
Definition: hermon.h:68
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 461 of file hermon.c.

462  {
463  return hermon_cmd ( hermon,
465  internal_qps, NULL, base_qpn, NULL );
466 }
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:964
A Hermon device.
Definition: hermon.h:842
#define HERMON_HCR_CONF_SPECIAL_QP
Definition: hermon.h:69
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 469 of file hermon.c.

470  {
471  return hermon_cmd ( hermon,
473  1, sizeof ( *mad ),
474  1, sizeof ( *mad ) ),
475  0x03, mad, port, mad );
476 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:950
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:70
A Hermon device.
Definition: hermon.h:842
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 479 of file hermon.c.

480  {
481  return hermon_cmd ( hermon,
483  1, sizeof ( *mcg ) ),
484  0, NULL, index, mcg );
485 }
#define HERMON_HCR_READ_MCG
Definition: hermon.h:71
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:961
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 488 of file hermon.c.

489  {
490  return hermon_cmd ( hermon,
492  1, sizeof ( *mcg ) ),
493  0, mcg, index, NULL );
494 }
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:958
A Hermon device.
Definition: hermon.h:842
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define HERMON_HCR_WRITE_MCG
Definition: hermon.h:72

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 497 of file hermon.c.

498  {
499  return hermon_cmd ( hermon,
501  1, sizeof ( *gid ),
502  0, sizeof ( *hash ) ),
503  0, gid, 0, hash );
504 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:950
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:73
A Hermon device.
Definition: hermon.h:842
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 507 of file hermon.c.

509  {
510  return hermon_cmd ( hermon,
512  0, sizeof ( *portion ),
513  0, sizeof ( *portion ) ),
514  mode, portion, input_mod, portion );
515 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:950
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:74
A Hermon device.
Definition: hermon.h:842

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 518 of file hermon.c.

519  {
520  return hermon_cmd ( hermon,
522  1, sizeof ( *query_port ) ),
523  0, NULL, port, query_port );
524 }
#define HERMON_HCR_QUERY_PORT
Definition: hermon.h:75
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:961
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

Referenced by hermon_register_netdev(), and 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 527 of file hermon.c.

528  {
529  return hermon_cmd ( hermon,
531  0, sizeof ( *port_type ) ),
532  0, NULL, port, port_type );
533 }
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:961
#define HERMON_HCR_SENSE_PORT
Definition: hermon.h:76
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 536 of file hermon.c.

536  {
537  return hermon_cmd ( hermon,
539  0, NULL, 0, NULL );
540 }
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:964
#define HERMON_HCR_RUN_FW
Definition: hermon.h:77
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 543 of file hermon.c.

544  {
545  return hermon_cmd ( hermon,
547  0, sizeof ( *offset ) ),
548  0, offset, page_count, NULL );
549 }
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:80
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 552 of file hermon.c.

553  {
554  return hermon_cmd ( hermon,
556  1, sizeof ( *map ) ),
557  0, map, 1, NULL );
558 }
#define HERMON_HCR_MAP_ICM
Definition: hermon.h:81
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:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_ICM, 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 561 of file hermon.c.

561  {
562  return hermon_cmd ( hermon,
564  0, NULL, 0, NULL );
565 }
#define HERMON_HCR_UNMAP_ICM_AUX
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_VOID_CMD(_opcode)
Definition: hermon.h:964
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 568 of file hermon.c.

569  {
570  return hermon_cmd ( hermon,
572  1, sizeof ( *map ) ),
573  0, map, 1, NULL );
574 }
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:958
#define HERMON_HCR_MAP_ICM_AUX
Definition: hermon.h:83
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_ICM_AUX, 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 577 of file hermon.c.

579  {
580  return hermon_cmd ( hermon,
582  0, sizeof ( *icm_size ),
583  0, sizeof (*icm_aux_size) ),
584  0, icm_size, 0, icm_aux_size );
585 }
#define HERMON_HCR_INOUT_CMD(_opcode, _in_mbox, _in_len, _out_mbox, _out_len)
Build HCR command from component parts.
Definition: hermon.h:950
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:84
A Hermon device.
Definition: hermon.h:842

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 588 of file hermon.c.

588  {
589  return hermon_cmd ( hermon,
591  0, NULL, 0, NULL );
592 }
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:964
#define HERMON_HCR_UNMAP_FA
Definition: hermon.h:85
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 595 of file hermon.c.

596  {
597  return hermon_cmd ( hermon,
599  1, sizeof ( *map ) ),
600  0, map, 1, NULL );
601 }
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:86
#define HERMON_HCR_IN_CMD(_opcode, _in_mbox, _in_len)
Definition: hermon.h:958
A Hermon device.
Definition: hermon.h:842
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References hermon_cmd(), HERMON_HCR_IN_CMD, HERMON_HCR_MAP_FA, 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 619 of file hermon.c.

621  {
622  struct hermonprm_write_mtt write_mtt;
625  unsigned int page_offset;
626  unsigned int num_pages;
627  int mtt_offset;
628  unsigned int mtt_base_addr;
629  unsigned int i;
630  int rc;
631 
632  /* Find available MTT entries */
633  start = virt_to_phys ( memory );
634  page_offset = ( start & ( HERMON_PAGE_SIZE - 1 ) );
635  start -= page_offset;
636  len += page_offset;
639  num_pages );
640  if ( mtt_offset < 0 ) {
641  DBGC ( hermon, "Hermon %p could not allocate %d MTT entries\n",
642  hermon, num_pages );
643  rc = mtt_offset;
644  goto err_mtt_offset;
645  }
646  mtt_base_addr = ( ( hermon->cap.reserved_mtts + mtt_offset ) *
648  addr = start;
649 
650  /* Fill in MTT structure */
651  mtt->mtt_offset = mtt_offset;
652  mtt->num_pages = num_pages;
653  mtt->mtt_base_addr = mtt_base_addr;
654  mtt->page_offset = page_offset;
655 
656  /* Construct and issue WRITE_MTT commands */
657  for ( i = 0 ; i < num_pages ; i++ ) {
658  memset ( &write_mtt, 0, sizeof ( write_mtt ) );
659  MLX_FILL_1 ( &write_mtt.mtt_base_addr, 1,
660  value, mtt_base_addr );
661  MLX_FILL_H ( &write_mtt.mtt, 0, ptag_h, addr );
662  MLX_FILL_2 ( &write_mtt.mtt, 1,
663  p, 1,
664  ptag_l, ( addr >> 3 ) );
665  if ( ( rc = hermon_cmd_write_mtt ( hermon,
666  &write_mtt ) ) != 0 ) {
667  DBGC ( hermon, "Hermon %p could not write MTT at %x\n",
669  goto err_write_mtt;
670  }
673  }
674 
675  DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] for "
676  "[%08lx,%08lx,%08lx,%08lx)\n", hermon, mtt->mtt_offset,
677  ( mtt->mtt_offset + mtt->num_pages - 1 ), start,
678  ( start + page_offset ), ( start + len ), addr );
679 
680  return 0;
681 
682  err_write_mtt:
683  hermon_bitmask_free ( hermon->mtt_inuse, mtt_offset, num_pages );
684  err_mtt_offset:
685  return rc;
686 }
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:337
size_t mtt_entry_size
MTT entry size.
Definition: hermon.h:585
#define DBGC(...)
Definition: compiler.h:505
#define HERMON_PAGE_SIZE
Definition: hermon.h:104
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:489
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
unsigned int reserved_mtts
Number of reserved MTTs.
Definition: hermon.h:583
#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:899
struct hermonprm_mtt mtt
Definition: hermon.h:491
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:630
hermon_bitmask_t mtt_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_MTTS)]
MTT entry in-use bitmask.
Definition: hermon.h:896
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:842
__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, 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 694 of file hermon.c.

695  {
696 
697  DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] freed\n",
698  hermon, mtt->mtt_offset,
699  ( mtt->mtt_offset + mtt->num_pages - 1 ) );
700  hermon_bitmask_free ( hermon->mtt_inuse, mtt->mtt_offset,
701  mtt->num_pages );
702 }
#define DBGC(...)
Definition: compiler.h:505
struct hermonprm_mtt mtt
Definition: hermon.h:491
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:896
A Hermon device.
Definition: hermon.h:842

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 731 of file hermon.c.

733  {
734  struct hermonprm_scalar_parameter *portion =
735  ( ( void * ) &stat_cfg->u.bytes[offset] );
736  struct hermonprm_mod_stat_cfg_input_mod mod;
737  int rc;
738 
739  /* Sanity check */
740  assert ( ( offset % sizeof ( *portion ) ) == 0 );
741 
742  /* Construct input modifier */
743  memset ( &mod, 0, sizeof ( mod ) );
744  MLX_FILL_2 ( &mod, 0,
745  portnum, port,
746  offset, offset );
747 
748  /* Issue command */
749  if ( ( rc = hermon_cmd_mod_stat_cfg ( hermon, mode,
750  be32_to_cpu ( mod.u.dwords[0] ),
751  portion ) ) != 0 )
752  return rc;
753 
754  return 0;
755 }
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:507
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:842
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 771 of file hermon.c.

771  {
772  struct hermon *hermon = ib_get_drvdata ( ibdev );
773  union hermonprm_mad mad_ifc;
774  int rc;
775 
776  linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
777  mad_size_mismatch );
778 
779  /* Copy in request packet */
780  memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
781 
782  /* Issue MAD */
783  if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
784  &mad_ifc ) ) != 0 ) {
785  DBGC ( hermon, "Hermon %p port %d could not issue MAD IFC: "
786  "%s\n", hermon, ibdev->port, strerror ( rc ) );
787  return rc;
788  }
789 
790  /* Copy out reply packet */
791  memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
792 
793  if ( mad->hdr.status != 0 ) {
794  DBGC ( hermon, "Hermon %p port %d MAD IFC status %04x\n",
795  hermon, ibdev->port, ntohs ( mad->hdr.status ) );
796  return -EIO;
797  }
798  return 0;
799 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
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:707
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:842
static int hermon_cmd_mad_ifc(struct hermon *hermon, unsigned int port, union hermonprm_mad *mad)
Definition: hermon.c:469
#define linker_assert(condition, error_symbol)
Assert a condition at link-time.
Definition: assert.h:68
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(), linker_assert, mad, hermonprm_mad::mad, memcpy(), ntohs, ib_device::port, rc, ib_mad_hdr::status, and strerror().

Referenced by 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 816 of file hermon.c.

816  {
817  struct hermonprm_completion_queue_context cqctx;
818  int rc;
819 
820  memset ( &cqctx, 0, sizeof ( cqctx ) );
821  if ( ( rc = hermon_cmd_query_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
822  DBGC ( hermon, "Hermon %p CQN %#lx QUERY_CQ failed: %s\n",
823  hermon, cq->cqn, strerror ( rc ) );
824  return rc;
825  }
826  DBGC ( hermon, "Hermon %p CQN %#lx context:\n", hermon, cq->cqn );
827  DBGC_HDA ( hermon, 0, &cqctx, sizeof ( cqctx ) );
828 
829  return 0;
830 }
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:842
static int hermon_cmd_query_cq(struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
Definition: hermon.c:400
void * memset(void *dest, int character, size_t len) __nonnull

References ib_completion_queue::cqn, 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 839 of file hermon.c.

840  {
841  struct hermon *hermon = ib_get_drvdata ( ibdev );
842  struct hermon_completion_queue *hermon_cq;
843  struct hermonprm_completion_queue_context cqctx;
844  int cqn_offset;
845  unsigned int i;
846  int rc;
847 
848  /* Find a free completion queue number */
849  cqn_offset = hermon_bitmask_alloc ( hermon->cq_inuse,
850  HERMON_MAX_CQS, 1 );
851  if ( cqn_offset < 0 ) {
852  DBGC ( hermon, "Hermon %p out of completion queues\n",
853  hermon );
854  rc = cqn_offset;
855  goto err_cqn_offset;
856  }
857  cq->cqn = ( hermon->cap.reserved_cqs + cqn_offset );
858 
859  /* Allocate control structures */
860  hermon_cq = zalloc ( sizeof ( *hermon_cq ) );
861  if ( ! hermon_cq ) {
862  rc = -ENOMEM;
863  goto err_hermon_cq;
864  }
865 
866  /* Allocate doorbell */
867  hermon_cq->doorbell = malloc_dma ( sizeof ( hermon_cq->doorbell[0] ),
868  sizeof ( hermon_cq->doorbell[0] ) );
869  if ( ! hermon_cq->doorbell ) {
870  rc = -ENOMEM;
871  goto err_doorbell;
872  }
873  memset ( hermon_cq->doorbell, 0, sizeof ( hermon_cq->doorbell[0] ) );
874 
875  /* Allocate completion queue itself */
876  hermon_cq->cqe_size = ( cq->num_cqes * sizeof ( hermon_cq->cqe[0] ) );
877  hermon_cq->cqe = malloc_dma ( hermon_cq->cqe_size,
878  sizeof ( hermon_cq->cqe[0] ) );
879  if ( ! hermon_cq->cqe ) {
880  rc = -ENOMEM;
881  goto err_cqe;
882  }
883  memset ( hermon_cq->cqe, 0, hermon_cq->cqe_size );
884  for ( i = 0 ; i < cq->num_cqes ; i++ ) {
885  MLX_FILL_1 ( &hermon_cq->cqe[i].normal, 7, owner, 1 );
886  }
887  barrier();
888 
889  /* Allocate MTT entries */
890  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_cq->cqe,
891  hermon_cq->cqe_size,
892  &hermon_cq->mtt ) ) != 0 )
893  goto err_alloc_mtt;
894 
895  /* Hand queue over to hardware */
896  memset ( &cqctx, 0, sizeof ( cqctx ) );
897  MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
898  MLX_FILL_1 ( &cqctx, 2,
899  page_offset, ( hermon_cq->mtt.page_offset >> 5 ) );
900  MLX_FILL_2 ( &cqctx, 3,
901  usr_page, HERMON_UAR_NON_EQ_PAGE,
902  log_cq_size, fls ( cq->num_cqes - 1 ) );
903  MLX_FILL_1 ( &cqctx, 5, c_eqn, hermon->eq.eqn );
904  MLX_FILL_H ( &cqctx, 6, mtt_base_addr_h,
905  hermon_cq->mtt.mtt_base_addr );
906  MLX_FILL_1 ( &cqctx, 7, mtt_base_addr_l,
907  ( hermon_cq->mtt.mtt_base_addr >> 3 ) );
908  MLX_FILL_H ( &cqctx, 14, db_record_addr_h,
909  virt_to_phys ( hermon_cq->doorbell ) );
910  MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
911  ( virt_to_phys ( hermon_cq->doorbell ) >> 3 ) );
912  if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
913  DBGC ( hermon, "Hermon %p CQN %#lx SW2HW_CQ failed: %s\n",
914  hermon, cq->cqn, strerror ( rc ) );
915  goto err_sw2hw_cq;
916  }
917 
918  DBGC ( hermon, "Hermon %p CQN %#lx ring [%08lx,%08lx), doorbell "
919  "%08lx\n", hermon, cq->cqn, virt_to_phys ( hermon_cq->cqe ),
920  ( virt_to_phys ( hermon_cq->cqe ) + hermon_cq->cqe_size ),
921  virt_to_phys ( hermon_cq->doorbell ) );
922  ib_cq_set_drvdata ( cq, hermon_cq );
923  return 0;
924 
925  err_sw2hw_cq:
926  hermon_free_mtt ( hermon, &hermon_cq->mtt );
927  err_alloc_mtt:
928  free_dma ( hermon_cq->cqe, hermon_cq->cqe_size );
929  err_cqe:
930  free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
931  err_doorbell:
932  free ( hermon_cq );
933  err_hermon_cq:
934  hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
935  err_cqn_offset:
936  return rc;
937 }
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:382
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:753
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:619
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
A Hermon completion queue.
Definition: hermon.h:747
unsigned int reserved_cqs
Number of reserved CQs.
Definition: hermon.h:575
size_t cqe_size
Size of completion queue.
Definition: hermon.h:751
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:639
hermon_bitmask_t cq_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_CQS)]
Completion queue in-use bitmask.
Definition: hermon.h:892
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
struct sockaddr_tcpip st
Definition: dns.c:69
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:674
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:884
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:694
#define HERMON_UAR_NON_EQ_PAGE
UAR page for doorbell accesses.
Definition: hermon.h:624
#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:899
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:744
struct hermonprm_cq_db_record * doorbell
Doorbell record.
Definition: hermon.h:755
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:749
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
unsigned int page_offset
Offset within page.
Definition: hermon.h:641
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
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:525
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
A Hermon device.
Definition: hermon.h:842
__be16 page_offset
Definition: CIB_PRM.h:33
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
unsigned long eqn
Event queue number.
Definition: hermon.h:773
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_dma(), 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_dma(), 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 945 of file hermon.c.

946  {
947  struct hermon *hermon = ib_get_drvdata ( ibdev );
948  struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
949  struct hermonprm_completion_queue_context cqctx;
950  int cqn_offset;
951  int rc;
952 
953  /* Take ownership back from hardware */
954  if ( ( rc = hermon_cmd_hw2sw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
955  DBGC ( hermon, "Hermon %p CQN %#lx FATAL HW2SW_CQ failed: "
956  "%s\n", hermon, cq->cqn, strerror ( rc ) );
957  /* Leak memory and return; at least we avoid corruption */
958  return;
959  }
960 
961  /* Free MTT entries */
962  hermon_free_mtt ( hermon, &hermon_cq->mtt );
963 
964  /* Free memory */
965  free_dma ( hermon_cq->cqe, hermon_cq->cqe_size );
966  free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
967  free ( hermon_cq );
968 
969  /* Mark queue number as free */
970  cqn_offset = ( cq->cqn - hermon->cap.reserved_cqs );
971  hermon_bitmask_free ( hermon->cq_inuse, cqn_offset, 1 );
972 
973  ib_cq_set_drvdata ( cq, NULL );
974 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:753
#define DBGC(...)
Definition: compiler.h:505
A Hermon completion queue.
Definition: hermon.h:747
unsigned int reserved_cqs
Number of reserved CQs.
Definition: hermon.h:575
size_t cqe_size
Size of completion queue.
Definition: hermon.h:751
hermon_bitmask_t cq_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_CQS)]
Completion queue in-use bitmask.
Definition: hermon.h:892
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
static int hermon_cmd_hw2sw_cq(struct hermon *hermon, unsigned long cqn, struct hermonprm_completion_queue_context *cqctx)
Definition: hermon.c:391
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:674
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:694
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:899
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:755
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:749
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
A Hermon device.
Definition: hermon.h:842
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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_dma(), 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 990 of file hermon.c.

991  {
992  struct hermon *hermon = ib_get_drvdata ( ibdev );
993  unsigned int port_offset;
994  int qpn_offset;
995 
996  /* Calculate queue pair number */
997  port_offset = ( ibdev->port - HERMON_PORT_BASE );
998 
999  switch ( qp->type ) {
1000  case IB_QPT_SMI:
1001  qp->qpn = ( hermon->special_qpn_base + port_offset );
1002  return 0;
1003  case IB_QPT_GSI:
1004  qp->qpn = ( hermon->special_qpn_base + 2 + port_offset );
1005  return 0;
1006  case IB_QPT_UD:
1007  case IB_QPT_RC:
1008  case IB_QPT_ETH:
1009  /* Find a free queue pair number */
1010  qpn_offset = hermon_bitmask_alloc ( hermon->qp_inuse,
1011  HERMON_MAX_QPS, 1 );
1012  if ( qpn_offset < 0 ) {
1013  DBGC ( hermon, "Hermon %p out of queue pairs\n",
1014  hermon );
1015  return qpn_offset;
1016  }
1017  qp->qpn = ( ( random() & HERMON_QPN_RANDOM_MASK ) |
1018  ( hermon->qpn_base + qpn_offset ) );
1019  return 0;
1020  default:
1021  DBGC ( hermon, "Hermon %p unsupported QP type %d\n",
1022  hermon, qp->type );
1023  return -ENOTSUP;
1024  }
1025 }
#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:901
#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:707
#define HERMON_QPN_RANDOM_MASK
Queue pair number randomisation mask.
Definition: hermon.h:714
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:30
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
unsigned long qpn_base
QPN base.
Definition: hermon.h:903
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:894
A Hermon device.
Definition: hermon.h:842
#define HERMON_MAX_QPS
Maximum number of allocatable queue pairs.
Definition: hermon.h:711

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 1033 of file hermon.c.

1034  {
1035  struct hermon *hermon = ib_get_drvdata ( ibdev );
1036  int qpn_offset;
1037 
1038  qpn_offset = ( ( qp->qpn & ~HERMON_QPN_RANDOM_MASK )
1039  - hermon->qpn_base );
1040  if ( qpn_offset >= 0 )
1041  hermon_bitmask_free ( hermon->qp_inuse, qpn_offset, 1 );
1042 }
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
#define HERMON_QPN_RANDOM_MASK
Queue pair number randomisation mask.
Definition: hermon.h:714
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:903
hermon_bitmask_t qp_inuse[HERMON_BITMASK_SIZE(HERMON_MAX_QPS)]
Queue pair in-use bitmask.
Definition: hermon.h:894
A Hermon device.
Definition: hermon.h:842

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 1050 of file hermon.c.

1050  {
1051  return ( ( ( av->rate >= IB_RATE_2_5 ) && ( av->rate <= IB_RATE_120 ) )
1052  ? ( av->rate + 5 ) : 0 );
1053 }
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 1062 of file hermon.c.

1063  {
1064  return ( ( ( qp->type == IB_QPT_SMI ) ?
1066  ( ( ibdev->port - 1 ) << 6 ) );
1067 }
#define HERMON_SCHED_DEFAULT
Definition: hermon.h:127
#define HERMON_SCHED_QP0
Definition: hermon.h:126
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 1086 of file hermon.c.

1086  {
1087  struct hermonprm_qp_ee_state_transitions qpctx;
1088  int rc;
1089 
1090  memset ( &qpctx, 0, sizeof ( qpctx ) );
1091  if ( ( rc = hermon_cmd_query_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ) {
1092  DBGC ( hermon, "Hermon %p QPN %#lx QUERY_QP failed: %s\n",
1093  hermon, qp->qpn, strerror ( rc ) );
1094  return rc;
1095  }
1096  DBGC ( hermon, "Hermon %p QPN %#lx context:\n", hermon, qp->qpn );
1097  DBGC_HDA ( hermon, 0, &qpctx.u.dwords[2], ( sizeof ( qpctx ) - 8 ) );
1098 
1099  return 0;
1100 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int hermon_cmd_query_qp(struct hermon *hermon, unsigned long qpn, struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:452
#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
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
A Hermon device.
Definition: hermon.h:842
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, DBGC_HDA, hermon_cmd_query_qp(), memset(), qp, rc, and strerror().

◆ 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 1109 of file hermon.c.

1110  {
1111  struct hermon *hermon = ib_get_drvdata ( ibdev );
1112  struct hermon_queue_pair *hermon_qp;
1113  struct hermonprm_qp_ee_state_transitions qpctx;
1114  struct hermonprm_wqe_segment_data_ptr *data;
1115  unsigned int i;
1116  int rc;
1117 
1118  /* Calculate queue pair number */
1119  if ( ( rc = hermon_alloc_qpn ( ibdev, qp ) ) != 0 )
1120  goto err_alloc_qpn;
1121 
1122  /* Allocate control structures */
1123  hermon_qp = zalloc ( sizeof ( *hermon_qp ) );
1124  if ( ! hermon_qp ) {
1125  rc = -ENOMEM;
1126  goto err_hermon_qp;
1127  }
1128 
1129  /* Allocate doorbells */
1130  hermon_qp->recv.doorbell =
1131  malloc_dma ( sizeof ( hermon_qp->recv.doorbell[0] ),
1132  sizeof ( hermon_qp->recv.doorbell[0] ) );
1133  if ( ! hermon_qp->recv.doorbell ) {
1134  rc = -ENOMEM;
1135  goto err_recv_doorbell;
1136  }
1137  memset ( hermon_qp->recv.doorbell, 0,
1138  sizeof ( hermon_qp->recv.doorbell[0] ) );
1139  hermon_qp->send.doorbell =
1142 
1143  /* Allocate work queue buffer */
1144  hermon_qp->send.num_wqes = ( qp->send.num_wqes /* headroom */ + 1 +
1145  ( 2048 / sizeof ( hermon_qp->send.wqe[0] ) ) );
1146  hermon_qp->send.num_wqes =
1147  ( 1 << fls ( hermon_qp->send.num_wqes - 1 ) ); /* round up */
1148  hermon_qp->send.wqe_size = ( hermon_qp->send.num_wqes *
1149  sizeof ( hermon_qp->send.wqe[0] ) );
1150  hermon_qp->recv.wqe_size = ( qp->recv.num_wqes *
1151  sizeof ( hermon_qp->recv.wqe[0] ) );
1152  if ( ( qp->type == IB_QPT_SMI ) || ( qp->type == IB_QPT_GSI ) ||
1153  ( qp->type == IB_QPT_UD ) ) {
1154  hermon_qp->recv.grh_size = ( qp->recv.num_wqes *
1155  sizeof ( hermon_qp->recv.grh[0] ));
1156  }
1157  hermon_qp->wqe_size = ( hermon_qp->send.wqe_size +
1158  hermon_qp->recv.wqe_size +
1159  hermon_qp->recv.grh_size );
1160  hermon_qp->wqe = malloc_dma ( hermon_qp->wqe_size,
1161  sizeof ( hermon_qp->send.wqe[0] ) );
1162  if ( ! hermon_qp->wqe ) {
1163  rc = -ENOMEM;
1164  goto err_alloc_wqe;
1165  }
1166  hermon_qp->send.wqe = hermon_qp->wqe;
1167  hermon_qp->recv.wqe = ( hermon_qp->wqe + hermon_qp->send.wqe_size );
1168  if ( hermon_qp->recv.grh_size ) {
1169  hermon_qp->recv.grh = ( hermon_qp->wqe +
1170  hermon_qp->send.wqe_size +
1171  hermon_qp->recv.wqe_size );
1172  }
1173 
1174  /* Initialise work queue entries */
1175  memset ( hermon_qp->send.wqe, 0xff, hermon_qp->send.wqe_size );
1176  memset ( hermon_qp->recv.wqe, 0, hermon_qp->recv.wqe_size );
1177  data = &hermon_qp->recv.wqe[0].recv.data[0];
1178  for ( i = 0 ; i < ( hermon_qp->recv.wqe_size / sizeof ( *data ) ); i++){
1179  MLX_FILL_1 ( data, 1, l_key, HERMON_INVALID_LKEY );
1180  data++;
1181  }
1182 
1183  /* Allocate MTT entries */
1184  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_qp->wqe,
1185  hermon_qp->wqe_size,
1186  &hermon_qp->mtt ) ) != 0 ) {
1187  goto err_alloc_mtt;
1188  }
1189 
1190  /* Transition queue to INIT state */
1191  memset ( &qpctx, 0, sizeof ( qpctx ) );
1192  MLX_FILL_2 ( &qpctx, 2,
1193  qpc_eec_data.pm_state, HERMON_PM_STATE_MIGRATED,
1194  qpc_eec_data.st, hermon_qp_st[qp->type] );
1195  MLX_FILL_1 ( &qpctx, 3, qpc_eec_data.pd, HERMON_GLOBAL_PD );
1196  MLX_FILL_4 ( &qpctx, 4,
1197  qpc_eec_data.log_rq_size, fls ( qp->recv.num_wqes - 1 ),
1198  qpc_eec_data.log_rq_stride,
1199  ( fls ( sizeof ( hermon_qp->recv.wqe[0] ) - 1 ) - 4 ),
1200  qpc_eec_data.log_sq_size,
1201  fls ( hermon_qp->send.num_wqes - 1 ),
1202  qpc_eec_data.log_sq_stride,
1203  ( fls ( sizeof ( hermon_qp->send.wqe[0] ) - 1 ) - 4 ) );
1204  MLX_FILL_1 ( &qpctx, 5,
1205  qpc_eec_data.usr_page, HERMON_UAR_NON_EQ_PAGE );
1206  MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
1207  MLX_FILL_4 ( &qpctx, 38,
1208  qpc_eec_data.rre, 1,
1209  qpc_eec_data.rwe, 1,
1210  qpc_eec_data.rae, 1,
1211  qpc_eec_data.page_offset,
1212  ( hermon_qp->mtt.page_offset >> 6 ) );
1213  MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1214  MLX_FILL_H ( &qpctx, 42, qpc_eec_data.db_record_addr_h,
1215  virt_to_phys ( hermon_qp->recv.doorbell ) );
1216  MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.db_record_addr_l,
1217  ( virt_to_phys ( hermon_qp->recv.doorbell ) >> 2 ) );
1218  MLX_FILL_H ( &qpctx, 52, qpc_eec_data.mtt_base_addr_h,
1219  hermon_qp->mtt.mtt_base_addr );
1220  MLX_FILL_1 ( &qpctx, 53, qpc_eec_data.mtt_base_addr_l,
1221  ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1222  if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1223  &qpctx ) ) != 0 ) {
1224  DBGC ( hermon, "Hermon %p QPN %#lx RST2INIT_QP failed: %s\n",
1225  hermon, qp->qpn, strerror ( rc ) );
1226  goto err_rst2init_qp;
1227  }
1228  hermon_qp->state = HERMON_QP_ST_INIT;
1229 
1230  DBGC ( hermon, "Hermon %p QPN %#lx send ring [%08lx,%08lx), doorbell "
1231  "%08lx\n", hermon, qp->qpn,
1232  virt_to_phys ( hermon_qp->send.wqe ),
1233  ( virt_to_phys ( hermon_qp->send.wqe ) +
1234  hermon_qp->send.wqe_size ),
1235  virt_to_phys ( hermon_qp->send.doorbell ) );
1236  DBGC ( hermon, "Hermon %p QPN %#lx receive ring [%08lx,%08lx), "
1237  "doorbell %08lx\n", hermon, qp->qpn,
1238  virt_to_phys ( hermon_qp->recv.wqe ),
1239  ( virt_to_phys ( hermon_qp->recv.wqe ) +
1240  hermon_qp->recv.wqe_size ),
1241  virt_to_phys ( hermon_qp->recv.doorbell ) );
1242  DBGC ( hermon, "Hermon %p QPN %#lx send CQN %#lx receive CQN %#lx\n",
1243  hermon, qp->qpn, qp->send.cq->cqn, qp->recv.cq->cqn );
1244  ib_qp_set_drvdata ( qp, hermon_qp );
1245  return 0;
1246 
1247  hermon_cmd_2rst_qp ( hermon, qp->qpn );
1248  err_rst2init_qp:
1249  hermon_free_mtt ( hermon, &hermon_qp->mtt );
1250  err_alloc_mtt:
1251  free_dma ( hermon_qp->wqe, hermon_qp->wqe_size );
1252  err_alloc_wqe:
1253  free_dma ( hermon_qp->recv.doorbell,
1254  sizeof ( hermon_qp->recv.doorbell[0] ) );
1255  err_recv_doorbell:
1256  free ( hermon_qp );
1257  err_hermon_qp:
1258  hermon_free_qpn ( ibdev, qp );
1259  err_alloc_qpn:
1260  return rc;
1261 }
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:733
#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:409
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:735
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:619
void * doorbell
Doorbell register.
Definition: hermon.h:671
struct hermonprm_recv_wqe recv
Definition: hermon.h:679
#define DBGC(...)
Definition: compiler.h:505
#define HERMON_PAGE_SIZE
Definition: hermon.h:104
#define HERMON_DB_POST_SND_OFFSET
Definition: hermon.h:106
static void hermon_free_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Free queue pair number.
Definition: hermon.c:1033
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:694
enum hermon_queue_pair_state state
Queue state.
Definition: hermon.h:737
#define HERMON_INVALID_LKEY
Definition: hermon.h:102
union hermon_recv_wqe * wqe
Work queue entries.
Definition: hermon.h:686
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:639
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
size_t wqe_size
Size of work queue buffer.
Definition: hermon.h:729
size_t wqe_size
Size of work queue.
Definition: hermon.h:688
void * wqe
Work queue buffer.
Definition: hermon.h:727
#define HERMON_PM_STATE_MIGRATED
Definition: hermon.h:133
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:694
union hermon_send_wqe * wqe
Work queue entries.
Definition: hermon.h:667
#define HERMON_UAR_NON_EQ_PAGE
UAR page for doorbell accesses.
Definition: hermon.h:624
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
void * uar
PCI user Access Region.
Definition: hermon.h:848
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER]
Definition: hermon.h:521
#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:669
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
unsigned int page_offset
Offset within page.
Definition: hermon.h:641
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:731
static int hermon_alloc_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Assign queue pair number.
Definition: hermon.c:990
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
A Hermon device.
Definition: hermon.h:842
A Hermon queue pair.
Definition: hermon.h:725
static uint8_t hermon_qp_st[]
Queue pair transport service type map.
Definition: hermon.c:1070
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
static int hermon_cmd_2rst_qp(struct hermon *hermon, unsigned long qpn)
Definition: hermon.c:445
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:630
unsigned int num_wqes
Number of work queue entries, including headroom.
Definition: hermon.h:665
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:690
size_t grh_size
Size of GRH buffers.
Definition: hermon.h:692
void * memset(void *dest, int character, size_t len) __nonnull
#define HERMON_GLOBAL_PD
Global protection domain.
Definition: hermon.h:916

References data, hermonprm_recv_wqe::data, DBGC, hermon_send_work_queue::doorbell, hermon_recv_work_queue::doorbell, ENOMEM, fls, free, free_dma(), 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_dma(), 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 1270 of file hermon.c.

1271  {
1272  struct hermon *hermon = ib_get_drvdata ( ibdev );
1273  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1274  struct hermonprm_qp_ee_state_transitions qpctx;
1275  int rc;
1276 
1277  /* Transition queue to RTR state, if applicable */
1278  if ( hermon_qp->state < HERMON_QP_ST_RTR ) {
1279  memset ( &qpctx, 0, sizeof ( qpctx ) );
1280  MLX_FILL_2 ( &qpctx, 4,
1281  qpc_eec_data.mtu,
1282  ( ( qp->type == IB_QPT_ETH ) ?
1284  qpc_eec_data.msg_max, 31 );
1285  MLX_FILL_1 ( &qpctx, 7,
1286  qpc_eec_data.remote_qpn_een, qp->av.qpn );
1287  MLX_FILL_1 ( &qpctx, 9,
1288  qpc_eec_data.primary_address_path.rlid,
1289  qp->av.lid );
1290  MLX_FILL_1 ( &qpctx, 10,
1291  qpc_eec_data.primary_address_path.max_stat_rate,
1292  hermon_rate ( &qp->av ) );
1293  memcpy ( &qpctx.u.dwords[12], &qp->av.gid,
1294  sizeof ( qp->av.gid ) );
1295  MLX_FILL_1 ( &qpctx, 16,
1296  qpc_eec_data.primary_address_path.sched_queue,
1297  hermon_sched_queue ( ibdev, qp ) );
1298  MLX_FILL_1 ( &qpctx, 39,
1299  qpc_eec_data.next_rcv_psn, qp->recv.psn );
1300  if ( ( rc = hermon_cmd_init2rtr_qp ( hermon, qp->qpn,
1301  &qpctx ) ) != 0 ) {
1302  DBGC ( hermon, "Hermon %p QPN %#lx INIT2RTR_QP failed:"
1303  " %s\n", hermon, qp->qpn, strerror ( rc ) );
1304  return rc;
1305  }
1306  hermon_qp->state = HERMON_QP_ST_RTR;
1307  }
1308 
1309  /* Transition queue to RTS state */
1310  if ( hermon_qp->state < HERMON_QP_ST_RTS ) {
1311  memset ( &qpctx, 0, sizeof ( qpctx ) );
1312  MLX_FILL_1 ( &qpctx, 10,
1313  qpc_eec_data.primary_address_path.ack_timeout,
1314  14 /* 4.096us * 2^(14) = 67ms */ );
1315  MLX_FILL_2 ( &qpctx, 30,
1316  qpc_eec_data.retry_count, HERMON_RETRY_MAX,
1317  qpc_eec_data.rnr_retry, HERMON_RETRY_MAX );
1318  MLX_FILL_1 ( &qpctx, 32,
1319  qpc_eec_data.next_send_psn, qp->send.psn );
1320  if ( ( rc = hermon_cmd_rtr2rts_qp ( hermon, qp->qpn,
1321  &qpctx ) ) != 0 ) {
1322  DBGC ( hermon, "Hermon %p QPN %#lx RTR2RTS_QP failed: "
1323  "%s\n", hermon, qp->qpn, strerror ( rc ) );
1324  return rc;
1325  }
1326  hermon_qp->state = HERMON_QP_ST_RTS;
1327  }
1328 
1329  /* Update parameters in RTS state */
1330  memset ( &qpctx, 0, sizeof ( qpctx ) );
1332  MLX_FILL_1 ( &qpctx, 44, qpc_eec_data.q_key, qp->qkey );
1333  if ( ( rc = hermon_cmd_rts2rts_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ){
1334  DBGC ( hermon, "Hermon %p QPN %#lx RTS2RTS_QP failed: %s\n",
1335  hermon, qp->qpn, strerror ( rc ) );
1336  return rc;
1337  }
1338 
1339  return 0;
1340 }
#define HERMON_MTU_ETH
Definition: hermon.h:100
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:641
#define HERMON_RETRY_MAX
Definition: hermon.h:135
enum hermon_queue_pair_state state
Queue state.
Definition: hermon.h:737
static int hermon_cmd_rts2rts_qp(struct hermon *hermon, unsigned long qpn, const struct hermonprm_qp_ee_state_transitions *ctx)
Definition: hermon.c:436
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:427
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define HERMON_MTU_2048
Definition: hermon.h:99
#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:418
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:1062
A Hermon device.
Definition: hermon.h:842
__be32 opt_param_mask
Definition: CIB_PRM.h:28
A Hermon queue pair.
Definition: hermon.h:725
#define HERMON_QP_OPT_PARAM_QKEY
Definition: hermon.h:111
static unsigned int hermon_rate(struct ib_address_vector *av)
Calculate transmission rate.
Definition: hermon.c:1050
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 1348 of file hermon.c.

1349  {
1350  struct hermon *hermon = ib_get_drvdata ( ibdev );
1351  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1352  int rc;
1353 
1354  /* Take ownership back from hardware */
1355  if ( ( rc = hermon_cmd_2rst_qp ( hermon, qp->qpn ) ) != 0 ) {
1356  DBGC ( hermon, "Hermon %p QPN %#lx FATAL 2RST_QP failed: %s\n",
1357  hermon, qp->qpn, strerror ( rc ) );
1358  /* Leak memory and return; at least we avoid corruption */
1359  return;
1360  }
1361 
1362  /* Free MTT entries */
1363  hermon_free_mtt ( hermon, &hermon_qp->mtt );
1364 
1365  /* Free memory */
1366  free_dma ( hermon_qp->wqe, hermon_qp->wqe_size );
1367  free_dma ( hermon_qp->recv.doorbell,
1368  sizeof ( hermon_qp->recv.doorbell[0] ) );
1369  free ( hermon_qp );
1370 
1371  /* Mark queue number as free */
1372  hermon_free_qpn ( ibdev, qp );
1373 
1374  ib_qp_set_drvdata ( qp, NULL );
1375 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:735
#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:641
static void hermon_free_qpn(struct ib_device *ibdev, struct ib_queue_pair *qp)
Free queue pair number.
Definition: hermon.c:1033
struct hermonprm_qp_db_record * doorbell
Doorbell record.
Definition: hermon.h:694
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
size_t wqe_size
Size of work queue buffer.
Definition: hermon.h:729
void * wqe
Work queue buffer.
Definition: hermon.h:727
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:694
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:731
A Hermon device.
Definition: hermon.h:842
A Hermon queue pair.
Definition: hermon.h:725
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static int hermon_cmd_2rst_qp(struct hermon *hermon, unsigned long qpn)
Definition: hermon.c:445
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:630

References DBGC, hermon_recv_work_queue::doorbell, free, free_dma(), 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 1395 of file hermon.c.

1399  {
1400 
1401  MLX_FILL_1 ( &wqe->ctrl, 1, ds, ( sizeof ( wqe->ctrl ) / 16 ) );
1402  MLX_FILL_1 ( &wqe->ctrl, 2, c, 0x03 /* generate completion */ );
1403  return HERMON_OPCODE_NOP;
1404 }
#define HERMON_OPCODE_NOP
Definition: hermon.h:41
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
void * wqe
Work queue buffer.
Definition: hermon.h:727
#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 1417 of file hermon.c.

1421  {
1422  struct hermon *hermon = ib_get_drvdata ( ibdev );
1423 
1424  MLX_FILL_1 ( &wqe->ud.ctrl, 1, ds,
1425  ( ( offsetof ( typeof ( wqe->ud ), data[1] ) / 16 ) ) );
1426  MLX_FILL_1 ( &wqe->ud.ctrl, 2, c, 0x03 /* generate completion */ );
1427  MLX_FILL_2 ( &wqe->ud.ud, 0,
1428  ud_address_vector.pd, HERMON_GLOBAL_PD,
1429  ud_address_vector.port_number, ibdev->port );
1430  MLX_FILL_2 ( &wqe->ud.ud, 1,
1431  ud_address_vector.rlid, dest->lid,
1432  ud_address_vector.g, dest->gid_present );
1433  MLX_FILL_1 ( &wqe->ud.ud, 2,
1434  ud_address_vector.max_stat_rate, hermon_rate ( dest ) );
1435  MLX_FILL_1 ( &wqe->ud.ud, 3, ud_address_vector.sl, dest->sl );
1436  memcpy ( &wqe->ud.ud.u.dwords[4], &dest->gid, sizeof ( dest->gid ) );
1437  MLX_FILL_1 ( &wqe->ud.ud, 8, destination_qp, dest->qpn );
1438  MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, dest->qkey );
1439  MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1440  MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, hermon->lkey );
1441  MLX_FILL_H ( &wqe->ud.data[0], 2,
1442  local_address_h, virt_to_bus ( iobuf->data ) );
1443  MLX_FILL_1 ( &wqe->ud.data[0], 3,
1444  local_address_l, virt_to_bus ( iobuf->data ) );
1445  return HERMON_OPCODE_SEND;
1446 }
#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
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
#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:707
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:497
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:151
#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:498
uint32_t ds
Definition: librm.h:254
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:499
void * data
Start of data.
Definition: iobuf.h:44
struct hermonprm_ud_send_wqe ud
Definition: hermon.h:650
A Hermon device.
Definition: hermon.h:842
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:889
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
static unsigned int hermon_rate(struct ib_address_vector *av)
Calculate transmission rate.
Definition: hermon.c:1050
#define HERMON_GLOBAL_PD
Global protection domain.
Definition: hermon.h:916

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, 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 1459 of file hermon.c.

1463  {
1464  struct hermon *hermon = ib_get_drvdata ( ibdev );
1465  struct io_buffer headers;
1466 
1467  /* Construct IB headers */
1468  iob_populate ( &headers, &wqe->mlx.headers, 0,
1469  sizeof ( wqe->mlx.headers ) );
1470  iob_reserve ( &headers, sizeof ( wqe->mlx.headers ) );
1471  ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
1472 
1473  /* Fill work queue entry */
1474  MLX_FILL_1 ( &wqe->mlx.ctrl, 1, ds,
1475  ( ( offsetof ( typeof ( wqe->mlx ), data[2] ) / 16 ) ) );
1476  MLX_FILL_5 ( &wqe->mlx.ctrl, 2,
1477  c, 0x03 /* generate completion */,
1478  icrc, 0 /* generate ICRC */,
1479  max_statrate, hermon_rate ( dest ),
1480  slr, 0,
1481  v15, ( ( qp->ext_qpn == IB_QPN_SMI ) ? 1 : 0 ) );
1482  MLX_FILL_1 ( &wqe->mlx.ctrl, 3, rlid, dest->lid );
1483  MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1484  byte_count, iob_len ( &headers ) );
1485  MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, hermon->lkey );
1486  MLX_FILL_H ( &wqe->mlx.data[0], 2,
1487  local_address_h, virt_to_bus ( headers.data ) );
1488  MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1489  local_address_l, virt_to_bus ( headers.data ) );
1490  MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1491  byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1492  MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, hermon->lkey );
1493  MLX_FILL_H ( &wqe->mlx.data[1], 2,
1494  local_address_h, virt_to_bus ( iobuf->data ) );
1495  MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1496  local_address_l, virt_to_bus ( iobuf->data ) );
1497  return HERMON_OPCODE_SEND;
1498 }
#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
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
#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:186
struct hermonprm_wqe_segment_ctrl_mlx ctrl
Definition: hermon.h:503
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:504
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
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:151
#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:651
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
void * data
Start of data.
Definition: iobuf.h:44
A Hermon device.
Definition: hermon.h:842
#define MLX_FILL_5(_ptr, _index,...)
Definition: mlx_bitops.h:183
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:889
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition: hermon.h:505
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:1050
A persistent I/O buffer.
Definition: iobuf.h:32

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, 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 1511 of file hermon.c.

1515  {
1516  struct hermon *hermon = ib_get_drvdata ( ibdev );
1517 
1518  MLX_FILL_1 ( &wqe->rc.ctrl, 1, ds,
1519  ( ( offsetof ( typeof ( wqe->rc ), data[1] ) / 16 ) ) );
1520  MLX_FILL_1 ( &wqe->rc.ctrl, 2, c, 0x03 /* generate completion */ );
1521  MLX_FILL_1 ( &wqe->rc.data[0], 0, byte_count, iob_len ( iobuf ) );
1522  MLX_FILL_1 ( &wqe->rc.data[0], 1, l_key, hermon->lkey );
1523  MLX_FILL_H ( &wqe->rc.data[0], 2,
1524  local_address_h, virt_to_bus ( iobuf->data ) );
1525  MLX_FILL_1 ( &wqe->rc.data[0], 3,
1526  local_address_l, virt_to_bus ( iobuf->data ) );
1527  return HERMON_OPCODE_SEND;
1528 }
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER]
Definition: hermon.h:510
#define HERMON_OPCODE_SEND
Definition: hermon.h:42
__be32 byte_count
Definition: CIB_PRM.h:28
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
#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:707
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:652
struct hermonprm_wqe_segment_ctrl_send ctrl
Definition: hermon.h:509
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#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:44
A Hermon device.
Definition: hermon.h:842
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:889
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

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, 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 1541 of file hermon.c.

1545  {
1546  struct hermon *hermon = ib_get_drvdata ( ibdev );
1547 
1548  /* Fill work queue entry */
1549  MLX_FILL_1 ( &wqe->eth.ctrl, 1, ds,
1550  ( ( offsetof ( typeof ( wqe->mlx ), data[1] ) / 16 ) ) );
1551  MLX_FILL_2 ( &wqe->eth.ctrl, 2,
1552  c, 0x03 /* generate completion */,
1553  s, 1 /* inhibit ICRC */ );
1554  MLX_FILL_1 ( &wqe->eth.data[0], 0,
1555  byte_count, iob_len ( iobuf ) );
1556  MLX_FILL_1 ( &wqe->eth.data[0], 1, l_key, hermon->lkey );
1557  MLX_FILL_H ( &wqe->eth.data[0], 2,
1558  local_address_h, virt_to_bus ( iobuf->data ) );
1559  MLX_FILL_1 ( &wqe->eth.data[0], 3,
1560  local_address_l, virt_to_bus ( iobuf->data ) );
1561  return HERMON_OPCODE_SEND;
1562 }
#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
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
#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:515
struct hermonprm_wqe_segment_ctrl_send ctrl
Definition: hermon.h:514
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
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:653
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#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:651
void * data
Start of data.
Definition: iobuf.h:44
A Hermon device.
Definition: hermon.h:842
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:889
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

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, 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 1587 of file hermon.c.

1590  {
1591  struct hermon *hermon = ib_get_drvdata ( ibdev );
1592  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1593  struct ib_work_queue *wq = &qp->send;
1594  struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
1595  union hermon_send_wqe *wqe;
1596  union hermonprm_doorbell_register db_reg;
1597  unsigned long wqe_idx_mask;
1598  unsigned long wqe_idx;
1599  unsigned int owner;
1600  unsigned int opcode;
1601 
1602  /* Allocate work queue entry */
1603  wqe_idx = ( wq->next_idx & ( hermon_send_wq->num_wqes - 1 ) );
1604  owner = ( ( wq->next_idx & hermon_send_wq->num_wqes ) ? 1 : 0 );
1605  wqe_idx_mask = ( wq->num_wqes - 1 );
1606  if ( wq->iobufs[ wqe_idx & wqe_idx_mask ] ) {
1607  DBGC ( hermon, "Hermon %p QPN %#lx send queue full",
1608  hermon, qp->qpn );
1609  return -ENOBUFS;
1610  }
1611  wq->iobufs[ wqe_idx & wqe_idx_mask ] = iobuf;
1612  wqe = &hermon_send_wq->wqe[wqe_idx];
1613 
1614  /* Construct work queue entry */
1615  memset ( ( ( ( void * ) wqe ) + 4 /* avoid ctrl.owner */ ), 0,
1616  ( sizeof ( *wqe ) - 4 ) );
1617  assert ( qp->type < ( sizeof ( hermon_fill_send_wqe ) /
1618  sizeof ( hermon_fill_send_wqe[0] ) ) );
1619  assert ( hermon_fill_send_wqe[qp->type] != NULL );
1620  opcode = hermon_fill_send_wqe[qp->type] ( ibdev, qp, dest, iobuf, wqe );
1621  barrier();
1622  MLX_FILL_2 ( &wqe->ctrl, 0,
1623  opcode, opcode,
1624  owner, owner );
1625  DBGCP ( hermon, "Hermon %p QPN %#lx posting send WQE %#lx:\n",
1626  hermon, qp->qpn, wqe_idx );
1627  DBGCP_HDA ( hermon, virt_to_phys ( wqe ), wqe, sizeof ( *wqe ) );
1628 
1629  /* Ring doorbell register */
1630  MLX_FILL_1 ( &db_reg.send, 0, qn, qp->qpn );
1631  barrier();
1632  writel ( db_reg.dword[0], hermon_send_wq->doorbell );
1633 
1634  /* Update work queue's index */
1635  wq->next_idx++;
1636 
1637  return 0;
1638 }
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
struct hermon_send_work_queue send
Send work queue.
Definition: hermon.h:733
void * doorbell
Doorbell register.
Definition: hermon.h:671
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:641
A Hermon send work queue entry.
Definition: hermon.h:648
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:707
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:667
#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:842
A Hermon send work queue.
Definition: hermon.h:658
A Hermon queue pair.
Definition: hermon.h:725
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:1566
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int num_wqes
Number of work queue entries, including headroom.
Definition: hermon.h:665
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 1648 of file hermon.c.

1650  {
1651  struct hermon *hermon = ib_get_drvdata ( ibdev );
1652  struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1653  struct ib_work_queue *wq = &qp->recv;
1654  struct hermon_recv_work_queue *hermon_recv_wq = &hermon_qp->recv;
1655  struct hermonprm_recv_wqe *wqe;
1656  struct hermonprm_wqe_segment_data_ptr *data;
1657  struct ib_global_route_header *grh;
1658  unsigned int wqe_idx_mask;
1659 
1660  /* Allocate work queue entry */
1661  wqe_idx_mask = ( wq->num_wqes - 1 );
1662  if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
1663  DBGC ( hermon, "Hermon %p QPN %#lx receive queue full",
1664  hermon, qp->qpn );
1665  return -ENOBUFS;
1666  }
1667  wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1668  wqe = &hermon_recv_wq->wqe[wq->next_idx & wqe_idx_mask].recv;
1669 
1670  /* Construct work queue entry */
1671  data = &wqe->data[0];
1672  if ( hermon_qp->recv.grh ) {
1673  grh = &hermon_qp->recv.grh[wq->next_idx & wqe_idx_mask];
1674  MLX_FILL_1 ( data, 0, byte_count, sizeof ( *grh ) );
1675  MLX_FILL_1 ( data, 1, l_key, hermon->lkey );
1676  MLX_FILL_H ( data, 2, local_address_h, virt_to_bus ( grh ) );
1677  MLX_FILL_1 ( data, 3, local_address_l, virt_to_bus ( grh ) );
1678  data++;
1679  }
1680  MLX_FILL_1 ( data, 0, byte_count, iob_tailroom ( iobuf ) );
1681  MLX_FILL_1 ( data, 1, l_key, hermon->lkey );
1682  MLX_FILL_H ( data, 2, local_address_h, virt_to_bus ( iobuf->data ) );
1683  MLX_FILL_1 ( data, 3, local_address_l, virt_to_bus ( iobuf->data ) );
1684 
1685  /* Update work queue's index */
1686  wq->next_idx++;
1687 
1688  /* Update doorbell record */
1689  barrier();
1690  MLX_FILL_1 ( hermon_recv_wq->doorbell, 0, receive_wqe_counter,
1691  ( wq->next_idx & 0xffff ) );
1692 
1693  return 0;
1694 }
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:735
struct hermonprm_recv_wqe recv
Definition: hermon.h:679
#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:641
struct ib_global_route_header grh
Definition: ib_packet.h:16
struct hermonprm_qp_db_record * doorbell
Doorbell record.
Definition: hermon.h:694
union hermon_recv_wqe * wqe
Work queue entries.
Definition: hermon.h:686
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
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:684
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:171
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER]
Definition: hermon.h:521
#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:44
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
A Hermon device.
Definition: hermon.h:842
A Hermon queue pair.
Definition: hermon.h:725
unsigned long lkey
Unrestricted LKey.
Definition: hermon.h:889
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:690
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 1704 of file hermon.c.

1706  {
1707  struct hermon *hermon = ib_get_drvdata ( ibdev );
1708  struct hermon_queue_pair *hermon_qp;
1709  struct ib_work_queue *wq;
1710  struct ib_queue_pair *qp;
1711  struct io_buffer *iobuf;
1712  struct ib_address_vector recv_dest;
1713  struct ib_address_vector recv_source;
1714  struct ib_global_route_header *grh;
1715  struct ib_address_vector *source;
1716  unsigned int opcode;
1717  unsigned long qpn;
1718  int is_send;
1719  unsigned long wqe_idx;
1720  unsigned long wqe_idx_mask;
1721  size_t len;
1722  int rc = 0;
1723 
1724  /* Parse completion */
1725  qpn = MLX_GET ( &cqe->normal, qpn );
1726  is_send = MLX_GET ( &cqe->normal, s_r );
1727  opcode = MLX_GET ( &cqe->normal, opcode );
1728  if ( opcode >= HERMON_OPCODE_RECV_ERROR ) {
1729  /* "s" field is not valid for error opcodes */
1730  is_send = ( opcode == HERMON_OPCODE_SEND_ERROR );
1731  DBGC ( hermon, "Hermon %p CQN %#lx syndrome %x vendor %x\n",
1732  hermon, cq->cqn, MLX_GET ( &cqe->error, syndrome ),
1733  MLX_GET ( &cqe->error, vendor_error_syndrome ) );
1734  rc = -EIO;
1735  /* Don't return immediately; propagate error to completer */
1736  }
1737 
1738  /* Identify work queue */
1739  wq = ib_find_wq ( cq, qpn, is_send );
1740  if ( ! wq ) {
1741  DBGC ( hermon, "Hermon %p CQN %#lx unknown %s QPN %#lx\n",
1742  hermon, cq->cqn, ( is_send ? "send" : "recv" ), qpn );
1743  return -EIO;
1744  }
1745  qp = wq->qp;
1746  hermon_qp = ib_qp_get_drvdata ( qp );
1747 
1748  /* Identify work queue entry */
1749  wqe_idx = MLX_GET ( &cqe->normal, wqe_counter );
1750  wqe_idx_mask = ( wq->num_wqes - 1 );
1751  DBGCP ( hermon, "Hermon %p CQN %#lx QPN %#lx %s WQE %#lx completed:\n",
1752  hermon, cq->cqn, qp->qpn, ( is_send ? "send" : "recv" ),
1753  wqe_idx );
1754  DBGCP_HDA ( hermon, virt_to_phys ( cqe ), cqe, sizeof ( *cqe ) );
1755 
1756  /* Identify I/O buffer */
1757  iobuf = wq->iobufs[ wqe_idx & wqe_idx_mask ];
1758  if ( ! iobuf ) {
1759  DBGC ( hermon, "Hermon %p CQN %#lx QPN %#lx empty %s WQE "
1760  "%#lx\n", hermon, cq->cqn, qp->qpn,
1761  ( is_send ? "send" : "recv" ), wqe_idx );
1762  return -EIO;
1763  }
1764  wq->iobufs[ wqe_idx & wqe_idx_mask ] = NULL;
1765 
1766  if ( is_send ) {
1767  /* Hand off to completion handler */
1768  ib_complete_send ( ibdev, qp, iobuf, rc );
1769  } else {
1770  /* Set received length */
1771  len = MLX_GET ( &cqe->normal, byte_cnt );
1772  memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1773  recv_dest.qpn = qpn;
1774  memset ( &recv_source, 0, sizeof ( recv_source ) );
1775  switch ( qp->type ) {
1776  case IB_QPT_SMI:
1777  case IB_QPT_GSI:
1778  case IB_QPT_UD:
1779  /* Locate corresponding GRH */
1780  assert ( hermon_qp->recv.grh != NULL );
1781  grh = &hermon_qp->recv.grh[ wqe_idx & wqe_idx_mask ];
1782  len -= sizeof ( *grh );
1783  /* Construct address vector */
1784  source = &recv_source;
1785  source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
1786  source->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
1787  source->sl = MLX_GET ( &cqe->normal, sl );
1788  recv_dest.gid_present = source->gid_present =
1789  MLX_GET ( &cqe->normal, g );
1790  memcpy ( &recv_dest.gid, &grh->dgid,
1791  sizeof ( recv_dest.gid ) );
1792  memcpy ( &source->gid, &grh->sgid,
1793  sizeof ( source->gid ) );
1794  break;
1795  case IB_QPT_RC:
1796  source = &qp->av;
1797  break;
1798  case IB_QPT_ETH:
1799  /* Construct address vector */
1800  source = &recv_source;
1801  source->vlan_present = MLX_GET ( &cqe->normal, vlan );
1802  source->vlan = MLX_GET ( &cqe->normal, vid );
1803  break;
1804  default:
1805  assert ( 0 );
1806  return -EINVAL;
1807  }
1808  assert ( len <= iob_tailroom ( iobuf ) );
1809  iob_put ( iobuf, len );
1810  /* Hand off to completion handler */
1811  ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
1812  }
1813 
1814  return rc;
1815 }
#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:116
struct hermon_recv_work_queue recv
Receive work queue.
Definition: hermon.h:735
uint8_t opcode
Opcode.
Definition: ena.h:16
#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:641
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:707
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:526
union ib_gid sgid
Source GID.
Definition: ib_packet.h:104
__be32 syndrome
Definition: CIB_PRM.h:30
#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:171
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
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
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:525
#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:842
An Infiniband Address Vector.
Definition: infiniband.h:72
A Hermon queue pair.
Definition: hermon.h:725
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:362
__be32 byte_cnt
Definition: CIB_PRM.h:37
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: hermon.h:690
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32
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, ib_address_vector::gid, ib_address_vector::gid_present, grh, hermon_recv_work_queue::grh, 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 1823 of file hermon.c.

1824  {
1825  struct hermon *hermon = ib_get_drvdata ( ibdev );
1826  struct hermon_completion_queue *hermon_cq = ib_cq_get_drvdata ( cq );
1827  union hermonprm_completion_entry *cqe;
1828  unsigned int cqe_idx_mask;
1829  int rc;
1830 
1831  while ( 1 ) {
1832  /* Look for completion entry */
1833  cqe_idx_mask = ( cq->num_cqes - 1 );
1834  cqe = &hermon_cq->cqe[cq->next_idx & cqe_idx_mask];
1835  if ( MLX_GET ( &cqe->normal, owner ) ^
1836  ( ( cq->next_idx & cq->num_cqes ) ? 1 : 0 ) ) {
1837  /* Entry still owned by hardware; end of poll */
1838  break;
1839  }
1840 
1841  /* Handle completion */
1842  if ( ( rc = hermon_complete ( ibdev, cq, cqe ) ) != 0 ) {
1843  DBGC ( hermon, "Hermon %p CQN %#lx failed to complete:"
1844  " %s\n", hermon, cq->cqn, strerror ( rc ) );
1845  DBGC_HDA ( hermon, virt_to_phys ( cqe ),
1846  cqe, sizeof ( *cqe ) );
1847  }
1848 
1849  /* Update completion queue's index */
1850  cq->next_idx++;
1851 
1852  /* Update doorbell record */
1853  MLX_FILL_1 ( hermon_cq->doorbell, 0, update_ci,
1854  ( cq->next_idx & 0x00ffffffUL ) );
1855  }
1856 }
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:747
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:524
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
#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:755
union hermonprm_completion_entry * cqe
Completion queue entries.
Definition: hermon.h:749
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
struct hermonprm_completion_queue_entry normal
Definition: hermon.h:525
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
A Hermon device.
Definition: hermon.h:842
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685
static int hermon_complete(struct ib_device *ibdev, struct ib_completion_queue *cq, union hermonprm_completion_entry *cqe)
Handle completion.
Definition: hermon.c:1704

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_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 1871 of file hermon.c.

1871  {
1872  struct hermon_event_queue *hermon_eq = &hermon->eq;
1873  struct hermonprm_eqc eqctx;
1874  struct hermonprm_event_mask mask;
1875  unsigned int i;
1876  int rc;
1877 
1878  /* Select event queue number */
1879  hermon_eq->eqn = ( 4 * hermon->cap.reserved_uars );
1880  if ( hermon_eq->eqn < hermon->cap.reserved_eqs )
1881  hermon_eq->eqn = hermon->cap.reserved_eqs;
1882 
1883  /* Calculate doorbell address */
1884  hermon_eq->doorbell =
1885  ( hermon->uar + HERMON_DB_EQ_OFFSET ( hermon_eq->eqn ) );
1886 
1887  /* Allocate event queue itself */
1888  hermon_eq->eqe_size =
1889  ( HERMON_NUM_EQES * sizeof ( hermon_eq->eqe[0] ) );
1890  hermon_eq->eqe = malloc_dma ( hermon_eq->eqe_size,
1891  sizeof ( hermon_eq->eqe[0] ) );
1892  if ( ! hermon_eq->eqe ) {
1893  rc = -ENOMEM;
1894  goto err_eqe;
1895  }
1896  memset ( hermon_eq->eqe, 0, hermon_eq->eqe_size );
1897  for ( i = 0 ; i < HERMON_NUM_EQES ; i++ ) {
1898  MLX_FILL_1 ( &hermon_eq->eqe[i].generic, 7, owner, 1 );
1899  }
1900  barrier();
1901 
1902  /* Allocate MTT entries */
1903  if ( ( rc = hermon_alloc_mtt ( hermon, hermon_eq->eqe,
1904  hermon_eq->eqe_size,
1905  &hermon_eq->mtt ) ) != 0 )
1906  goto err_alloc_mtt;
1907 
1908  /* Hand queue over to hardware */
1909  memset ( &eqctx, 0, sizeof ( eqctx ) );
1910  MLX_FILL_2 ( &eqctx, 0,
1911  st, 0xa /* "Fired" */,
1912  oi, 1 );
1913  MLX_FILL_1 ( &eqctx, 2,
1914  page_offset, ( hermon_eq->mtt.page_offset >> 5 ) );
1915  MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( HERMON_NUM_EQES - 1 ) );
1916  MLX_FILL_H ( &eqctx, 6, mtt_base_addr_h,
1917  hermon_eq->mtt.mtt_base_addr );
1918  MLX_FILL_1 ( &eqctx, 7, mtt_base_addr_l,
1919  ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1920  if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
1921  &eqctx ) ) != 0 ) {
1922  DBGC ( hermon, "Hermon %p EQN %#lx SW2HW_EQ failed: %s\n",
1923  hermon, hermon_eq->eqn, strerror ( rc ) );
1924  goto err_sw2hw_eq;
1925  }
1926 
1927  /* Map all events to this event queue */
1928  memset ( &mask, 0xff, sizeof ( mask ) );
1929  if ( ( rc = hermon_cmd_map_eq ( hermon,
1930  ( HERMON_MAP_EQ | hermon_eq->eqn ),
1931  &mask ) ) != 0 ) {
1932  DBGC ( hermon, "Hermon %p EQN %#lx MAP_EQ failed: %s\n",
1933  hermon, hermon_eq->eqn, strerror ( rc ) );
1934  goto err_map_eq;
1935  }
1936 
1937  DBGC ( hermon, "Hermon %p EQN %#lx ring [%08lx,%08lx), doorbell "
1938  "%08lx\n", hermon, hermon_eq->eqn,
1939  virt_to_phys ( hermon_eq->eqe ),
1940  ( virt_to_phys ( hermon_eq->eqe ) + hermon_eq->eqe_size ),
1941  virt_to_phys ( hermon_eq->doorbell ) );
1942  return 0;
1943 
1944  err_map_eq:
1945  hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn, &eqctx );
1946  err_sw2hw_eq:
1947  hermon_free_mtt ( hermon, &hermon_eq->mtt );
1948  err_alloc_mtt:
1949  free_dma ( hermon_eq->eqe, hermon_eq->eqe_size );
1950  err_eqe:
1951  memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
1952  return rc;
1953 }
size_t eqe_size
Size of event queue.
Definition: hermon.h:769
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:355
static int hermon_alloc_mtt(struct hermon *hermon, const void *memory, size_t len, struct hermon_mtt *mtt)
Allocate MTT entries.
Definition: hermon.c:619
u8 owner
Definition: CIB_PRM.h:36
#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:364
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:767
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:771
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int mtt_base_addr
MTT base address.
Definition: hermon.h:639
#define HERMON_MAP_EQ
Definition: hermon.h:114
struct hermonprm_event_queue_entry generic
Definition: hermon.h:530
struct sockaddr_tcpip st
Definition: dns.c:69
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:884
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:694
#define MLX_FILL_1(_ptr, _index,...)
Definition: mlx_bitops.h:167
void * uar
PCI user Access Region.
Definition: hermon.h:848
#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:579
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:899
void * doorbell
Doorbell register.
Definition: hermon.h:777
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
unsigned int page_offset
Offset within page.
Definition: hermon.h:641
#define HERMON_DB_EQ_OFFSET(_eqn)
Definition: hermon.h:107
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
A Hermon device.
Definition: hermon.h:842
__be16 page_offset
Definition: CIB_PRM.h:33
unsigned int reserved_uars
Number of reserved UARs.
Definition: hermon.h:591
#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:346
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
unsigned long eqn
Event queue number.
Definition: hermon.h:773
#define HERMON_NUM_EQES
Number of event queue entries.
Definition: hermon.h:784
void * memset(void *dest, int character, size_t len) __nonnull
A Hermon event queue.
Definition: hermon.h:765

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_dma(), 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_dma(), 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 1960 of file hermon.c.

1960  {
1961  struct hermon_event_queue *hermon_eq = &hermon->eq;
1962  struct hermonprm_eqc eqctx;
1963  struct hermonprm_event_mask mask;
1964  int rc;
1965 
1966  /* Unmap events from event queue */
1967  memset ( &mask, 0xff, sizeof ( mask ) );
1968  if ( ( rc = hermon_cmd_map_eq ( hermon,
1969  ( HERMON_UNMAP_EQ | hermon_eq->eqn ),
1970  &mask ) ) != 0 ) {
1971  DBGC ( hermon, "Hermon %p EQN %#lx FATAL MAP_EQ failed to "
1972  "unmap: %s\n", hermon, hermon_eq->eqn, strerror ( rc ) );
1973  /* Continue; HCA may die but system should survive */
1974  }
1975 
1976  /* Take ownership back from hardware */
1977  if ( ( rc = hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn,
1978  &eqctx ) ) != 0 ) {
1979  DBGC ( hermon, "Hermon %p EQN %#lx FATAL HW2SW_EQ failed: %s\n",
1980  hermon, hermon_eq->eqn, strerror ( rc ) );
1981  /* Leak memory and return; at least we avoid corruption */
1982  return;
1983  }
1984 
1985  /* Free MTT entries */
1986  hermon_free_mtt ( hermon, &hermon_eq->mtt );
1987 
1988  /* Free memory */
1989  free_dma ( hermon_eq->eqe, hermon_eq->eqe_size );
1990  memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
1991 }
size_t eqe_size
Size of event queue.
Definition: hermon.h:769
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:364
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:767
struct hermon_mtt mtt
MTT descriptor.
Definition: hermon.h:771
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:884
#define HERMON_UNMAP_EQ
Definition: hermon.h:115
static void hermon_free_mtt(struct hermon *hermon, struct hermon_mtt *mtt)
Free MTT entries.
Definition: hermon.c:694
A Hermon device.
Definition: hermon.h:842
static int hermon_cmd_map_eq(struct hermon *hermon, unsigned long index_map, const struct hermonprm_event_mask *mask)
Definition: hermon.c:346
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
unsigned long eqn
Event queue number.
Definition: hermon.h:773
void * memset(void *dest, int character, size_t len) __nonnull
A Hermon event queue.
Definition: hermon.h:765

References DBGC, hermon::eq, hermon_event_queue::eqe, hermon_event_queue::eqe_size, hermon_event_queue::eqn, free_dma(), 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 1999 of file hermon.c.

2000  {
2001  unsigned int port;
2002  int link_up;
2003 
2004  /* Get port and link status */
2005  port = ( MLX_GET ( &eqe->port_state_change, data.p ) - 1 );
2006  link_up = ( MLX_GET ( &eqe->generic, event_sub_type ) & 0x04 );
2007  DBGC ( hermon, "Hermon %p port %d link %s\n", hermon, ( port + 1 ),
2008  ( link_up ? "up" : "down" ) );
2009 
2010  /* Sanity check */
2011  if ( port >= hermon->cap.num_ports ) {
2012  DBGC ( hermon, "Hermon %p port %d does not exist!\n",
2013  hermon, ( port + 1 ) );
2014  return;
2015  }
2016 
2017  /* Notify device of port state change */
2019  link_up );
2020 }
#define DBGC(...)
Definition: compiler.h:505
unsigned int num_ports
Number of ports.
Definition: hermon.h:593
u8 port
Port number.
Definition: CIB_PRM.h:31
pseudo_bit_t p[0x00002]
Definition: MT25218_PRM.h:3017
struct hermonprm_event_queue_entry generic
Definition: hermon.h:530
struct hermon_port_type * type
Port type.
Definition: hermon.h:836
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
struct hermon_dev_cap cap
Device capabilities.
Definition: hermon.h:899
struct hermonprm_port_state_change_event port_state_change
Definition: hermon.h:531
struct hermon_port port[HERMON_MAX_PORTS]
Ports.
Definition: hermon.h:909
void(* state_change)(struct hermon *hermon, struct hermon_port *port, int link_up)
Port state changed.
Definition: hermon.h:813
A Hermon device.
Definition: hermon.h:842
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

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

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 2027 of file hermon.c.

2027  {
2028  struct hermon *hermon = ib_get_drvdata ( ibdev );
2029  struct hermon_event_queue *hermon_eq = &hermon->eq;
2030  union hermonprm_event_entry *eqe;
2031  union hermonprm_doorbell_register db_reg;
2032  unsigned int eqe_idx_mask;
2033  unsigned int event_type;
2034 
2035  /* No event is generated upon reaching INIT, so we must poll
2036  * separately for link state changes while we remain DOWN.
2037  */
2038  if ( ib_is_open ( ibdev ) &&
2039  ( ibdev->port_state == IB_PORT_STATE_DOWN ) ) {
2040  ib_smc_update ( ibdev, hermon_mad );
2041  }
2042 
2043  /* Poll event queue */
2044  while ( 1 ) {
2045  /* Look for event entry */
2046  eqe_idx_mask = ( HERMON_NUM_EQES - 1 );
2047  eqe = &hermon_eq->eqe[hermon_eq->next_idx & eqe_idx_mask];
2048  if ( MLX_GET ( &eqe->generic, owner ) ^
2049  ( ( hermon_eq->next_idx & HERMON_NUM_EQES ) ? 1 : 0 ) ) {
2050  /* Entry still owned by hardware; end of poll */
2051  break;
2052  }
2053  DBGCP ( hermon, "Hermon %p EQN %#lx event:\n",
2054  hermon, hermon_eq->eqn );
2055  DBGCP_HDA ( hermon, virt_to_phys ( eqe ),
2056  eqe, sizeof ( *eqe ) );
2057 
2058  /* Handle event */
2059  event_type = MLX_GET ( &eqe->generic, event_type );
2060  switch ( event_type ) {
2063  break;
2064  default:
2065  DBGC ( hermon, "Hermon %p EQN %#lx unrecognised event "
2066  "type %#x:\n",
2067  hermon, hermon_eq->eqn, event_type );
2068  DBGC_HDA ( hermon, virt_to_phys ( eqe ),
2069  eqe, sizeof ( *eqe ) );
2070  break;
2071  }
2072 
2073  /* Update event queue's index */
2074  hermon_eq->next_idx++;
2075 
2076  /* Ring doorbell */
2077  MLX_FILL_1 ( &db_reg.event, 0,
2078  ci, ( hermon_eq->next_idx & 0x00ffffffUL ) );
2079  writel ( db_reg.dword[0], hermon_eq->doorbell );
2080  }
2081 }
static void hermon_event_port_state_change(struct hermon *hermon, union hermonprm_event_entry *eqe)
Handle port state event.
Definition: hermon.c:1999
static int ib_is_open(struct ib_device *ibdev)
Check whether or not Infiniband device is open.
Definition: infiniband.h:575
u8 owner
Definition: CIB_PRM.h:36
#define DBGC(...)
Definition: compiler.h:505
union hermonprm_event_entry * eqe
Event queue entries.
Definition: hermon.h:767
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:707
struct hermonprm_event_queue_entry generic
Definition: hermon.h:530
#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:771
struct hermon_event_queue eq
Event queue.
Definition: hermon.h:884
Definition: hermon.h:529
#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 IB_PORT_STATE_DOWN
Definition: ib_mad.h:151
#define HERMON_EV_PORT_STATE_CHANGE
Definition: hermon.h:124
void * doorbell
Doorbell register.
Definition: hermon.h:777
uint8_t port_state
Port state.
Definition: infiniband.h:423
#define DBGCP(...)
Definition: compiler.h:539
A Hermon device.
Definition: hermon.h:842
unsigned long next_idx
Next event queue entry index.
Definition: hermon.h:775
unsigned long eqn
Event queue number.
Definition: hermon.h:773
#define HERMON_NUM_EQES
Number of event queue entries.
Definition: hermon.h:784
A Hermon event queue.
Definition: hermon.h:765

References ci, DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, hermon_event_queue::doorbell, hermonprm_doorbell_register::dword, hermon::eq, hermon_event_queue::eqe, hermon_event_queue::eqn, hermonprm_doorbell_register::event, hermonprm_event_entry::generic, HERMON_EV_PORT_STATE_CHANGE, hermon_event_port_state_change(), hermon_mad(), HERMON_NUM_EQES, ib_get_drvdata(), ib_is_open(), IB_PORT_STATE_DOWN, ib_smc_update(), MLX_FILL_1, MLX_GET, hermon_event_queue::next_idx, owner, ib_device::port_state, virt_to_phys(), and writel().

◆ hermon_map_vpm()

static int hermon_map_vpm ( struct hermon hermon,
int(*)(struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *)  map,
uint64_t  va,
physaddr_t  pa,
size_t  len 
)
static

Map virtual to physical address for firmware usage.

Parameters
hermonHermon device
mapMapping function
vaVirtual address
paPhysical address
lenLength of region
Return values
rcReturn status code

Definition at line 2100 of file hermon.c.

2103  {
2104  struct hermonprm_virtual_physical_mapping mapping;
2105  physaddr_t start;
2106  physaddr_t low;
2107  physaddr_t high;
2108  physaddr_t end;
2109  size_t size;
2110  int rc;
2111 
2112  /* Sanity checks */
2113  assert ( ( va & ( HERMON_PAGE_SIZE - 1 ) ) == 0 );
2114  assert ( ( pa & ( HERMON_PAGE_SIZE - 1 ) ) == 0 );
2115  assert ( ( len & ( HERMON_PAGE_SIZE - 1 ) ) == 0 );
2116  assert ( len != 0 );
2117 
2118  /* Calculate starting points */
2119  start = pa;
2120  end = ( start + len );
2121  size = ( 1UL << ( fls ( start ^ end ) - 1 ) );
2122  low = high = ( end & ~( size - 1 ) );
2123  assert ( start < low );
2124  assert ( high <= end );
2125 
2126  /* These mappings tend to generate huge volumes of
2127  * uninteresting debug data, which basically makes it
2128  * impossible to use debugging otherwise.
2129  */
2131 
2132  /* Map blocks in descending order of size */
2133  while ( size >= HERMON_PAGE_SIZE ) {
2134 
2135  /* Find the next candidate block */
2136  if ( ( low - size ) >= start ) {
2137  low -= size;
2138  pa = low;
2139  } else if ( high <= ( end - size ) ) {
2140  pa = high;
2141  high += size;
2142  } else {
2143  size >>= 1;
2144  continue;
2145  }
2146  assert ( ( va & ( size - 1 ) ) == 0 );
2147  assert ( ( pa & ( size - 1 ) ) == 0 );
2148 
2149  /* Map this block */
2150  memset ( &mapping, 0, sizeof ( mapping ) );
2151  MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2152  MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2153  MLX_FILL_H ( &mapping, 2, pa_h, pa );
2154  MLX_FILL_2 ( &mapping, 3,
2155  log2size, ( ( fls ( size ) - 1 ) - 12 ),
2156  pa_l, ( pa >> 12 ) );
2157  if ( ( rc = map ( hermon, &mapping ) ) != 0 ) {
2159  DBGC ( hermon, "Hermon %p could not map %08llx+%zx to "
2160  "%08lx: %s\n",
2161  hermon, va, size, pa, strerror ( rc ) );
2162  return rc;
2163  }
2164  va += size;
2165  }
2166  assert ( low == start );
2167  assert ( high == end );
2168 
2170  return 0;
2171 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MLX_FILL_2(_ptr, _index,...)
Definition: mlx_bitops.h:171
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define DBGC(...)
Definition: compiler.h:505
#define DBG_DISABLE(level)
Definition: compiler.h:312
#define HERMON_PAGE_SIZE
Definition: hermon.h:104
uint32_t start
Starting offset.
Definition: netvsc.h:12
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define DBGLVL_LOG
Definition: compiler.h:316
uint32_t low
Low 16 bits of address.
Definition: intel.h:21
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#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
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t len
Length.
Definition: ena.h:14
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
A Hermon device.
Definition: hermon.h:842
uint32_t high
High 32 bits of address.
Definition: intel.h:22
#define fls(x)
Find last (i.e.
Definition: strings.h:166
#define DBGLVL_EXTRA
Definition: compiler.h:318
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), DBG_DISABLE, DBG_ENABLE, DBGC, DBGLVL_EXTRA, DBGLVL_LOG, end, fls, HERMON_PAGE_SIZE, high, len, low, memset(), MLX_FILL_1, MLX_FILL_2, MLX_FILL_H, rc, size, start, and strerror().

Referenced by hermon_map_icm(), and hermon_start_firmware().

◆ hermon_start_firmware()

static int hermon_start_firmware ( struct hermon hermon)
static

Start firmware running.

Parameters
hermonHermon device
Return values
rcReturn status code

Definition at line 2179 of file hermon.c.

2179  {
2180  struct hermonprm_query_fw fw;
2181  unsigned int fw_pages;
2182  size_t fw_len;
2183  physaddr_t fw_base;
2184  int rc;
2185 
2186  /* Get firmware parameters */
2187  if ( ( rc = hermon_cmd_query_fw ( hermon, &fw ) ) != 0 ) {
2188  DBGC ( hermon, "Hermon %p could not query firmware: %s\n",
2189  hermon, strerror ( rc ) );
2190  goto err_query_fw;
2191  }
2192  DBGC ( hermon, "Hermon %p firmware version %d.%d.%d\n", hermon,
2193  MLX_GET ( &fw, fw_rev_major ), MLX_GET ( &fw, fw_rev_minor ),
2194  MLX_GET ( &fw, fw_rev_subminor ) );
2195  fw_pages = MLX_GET ( &fw, fw_pages );
2196  DBGC ( hermon, "Hermon %p requires %d pages (%d kB) for firmware\n",
2197  hermon, fw_pages, ( fw_pages * 4 ) );
2198 
2199  /* Allocate firmware pages and map firmware area */
2200  fw_len = ( fw_pages * HERMON_PAGE_SIZE );
2201  if ( ! hermon->firmware_area ) {
2202  hermon->firmware_len = fw_len;
2204  if ( ! hermon->firmware_area ) {
2205  rc = -ENOMEM;
2206  goto err_alloc_fa;
2207  }
2208  } else {
2209  assert ( hermon->firmware_len == fw_len );
2210  }
2211  fw_base = user_to_phys ( hermon->firmware_area, 0 );
2212  DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n",
2213  hermon, fw_base, ( fw_base + fw_len ) );
2215  0, fw_base, fw_len ) ) != 0 ) {
2216  DBGC ( hermon, "Hermon %p could not map firmware: %s\n",
2217  hermon, strerror ( rc ) );
2218  goto err_map_fa;
2219  }
2220 
2221  /* Start firmware */
2222  if ( ( rc = hermon_cmd_run_fw ( hermon ) ) != 0 ) {
2223  DBGC ( hermon, "Hermon %p could not run firmware: %s\n",
2224  hermon, strerror ( rc ) );
2225  goto err_run_fw;
2226  }
2227 
2228  DBGC ( hermon, "Hermon %p firmware started\n", hermon );
2229  return 0;
2230 
2231  err_run_fw:
2232  err_map_fa:
2234  err_alloc_fa:
2235  err_query_fw:
2236  return rc;
2237 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int hermon_cmd_query_fw(struct hermon *hermon, struct hermonprm_query_fw *fw)
Definition: hermon.c:280
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define HERMON_PAGE_SIZE
Definition: hermon.h:104
userptr_t firmware_area
Firmware area in external memory.
Definition: hermon.h:868
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static int hermon_cmd_unmap_fa(struct hermon *hermon)
Definition: hermon.c:588
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
size_t firmware_len
Firmware size.
Definition: hermon.h:861
#define MLX_GET(_ptr, _field)
Definition: mlx_bitops.h:222
static int hermon_cmd_map_fa(struct hermon *hermon, const struct hermonprm_virtual_physical_mapping *map)
Definition: hermon.c:595
unsigned long physaddr_t
Definition: stdint.h:20
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
A Hermon device.
Definition: hermon.h:842
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.
Definition: hermon.c:2100
static int hermon_cmd_run_fw(struct hermon *hermon)
Definition: hermon.c:536

References assert(), DBGC, ENOMEM, hermon::firmware_area, hermon::firmware_len, hermon_cmd_map_fa(), hermon_cmd_query_fw(), hermon_cmd_run_fw(), hermon_cmd_unmap_fa(), hermon_map_vpm(), HERMON_PAGE_SIZE, MLX_GET, rc, strerror(), umalloc(), and user_to_phys().

Referenced by hermon_probe(), and hermon_start().

◆ hermon_stop_firmware()

static void hermon_stop_firmware ( struct hermon hermon)
static

Stop firmware running.

Parameters
hermonHermon device

Definition at line 2244 of file hermon.c.

2244  {
2245  int rc;
2246 
2247  if ( ( rc = hermon_cmd_unmap_fa ( hermon ) ) != 0 ) {
2248  DBGC ( hermon, "Hermon %p FATAL could not stop firmware: %s\n",
2249  hermon, strerror ( rc ) );
2250  /* Leak memory and return; at least we avoid corruption */
2252  return;
2253  }
2254 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
userptr_t firmware_area
Firmware area in external memory.
Definition: hermon.h:868
static int hermon_cmd_unmap_fa(struct hermon *hermon)
Definition: hermon.c:588
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
A Hermon device.
Definition: hermon.h:842

References DBGC, hermon::firmware_area, hermon_cmd_unmap_fa(), rc, strerror(), and UNULL.

Referenced by hermon_probe(), hermon_start(), and hermon_stop().

◆ hermon_get_cap()

static int hermon_get_cap ( struct hermon hermon)
static

Get device limits.

Parameters
hermonHermon device
Return values
rcReturn status code

Definition at line 2269 of file hermon.c.

2269  {
2270  struct hermonprm_query_dev_cap dev_cap;
2271  int rc;
2272 
2273  if ( ( rc = hermon_cmd_query_dev_cap ( hermon, &dev_cap ) ) != 0 ) {
2274  DBGC ( hermon, "Hermon %p could not get device limits: %s\n",
2275  hermon, strerror ( rc ) );
2276  return rc;
2277  }
2278 
2279  hermon->cap.cmpt_entry_size = MLX_GET ( &dev_cap, c_mpt_entry_sz );
2281  ( 1 << MLX_GET ( &dev_cap, log2_rsvd_qps ) );
2282  hermon->cap.qpc_entry_size = MLX_GET ( &dev_cap, qpc_entry_sz );
2283  hermon->cap.altc_entry_size = MLX_GET ( &dev_cap, altc_entry_sz );
2284  hermon->cap.auxc_entry_size = MLX_GET ( &dev_cap, aux_entry_sz );
2286  ( 1 << MLX_GET ( &dev_cap, log2_rsvd_srqs ) );
2287  hermon->cap.srqc_entry_size = MLX_GET ( &dev_cap, srq_entry_sz );
2289  ( 1 << MLX_GET ( &dev_cap, log2_rsvd_cqs ) );
2290  hermon->cap.cqc_entry_size = MLX_GET ( &dev_cap, cqc_entry_sz );
2291  hermon->cap.reserved_eqs = MLX_GET ( &dev_cap, num_rsvd_eqs );
2292  if ( hermon->cap.reserved_eqs == 0 ) {
2293  /* Backward compatibility */
2295  ( 1 << MLX_GET ( &dev_cap, log2_rsvd_eqs ) );
2296  }
2297  hermon->cap.eqc_entry_size = MLX_GET ( &dev_cap, eqc_entry_sz );
2298  hermon->cap.