iPXE
Macros | Functions | Variables
flexboot_nodnic.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/pci.h>
#include <ipxe/malloc.h>
#include <ipxe/umalloc.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/vlan.h>
#include <ipxe/io.h>
#include "flexboot_nodnic.h"
#include "mlx_utils/include/public/mlx_types.h"
#include "mlx_utils/include/public/mlx_utils.h"
#include "mlx_utils/include/public/mlx_bail.h"
#include "mlx_nodnic/include/mlx_cmd.h"
#include "mlx_utils/include/public/mlx_memory.h"
#include "mlx_utils/include/public/mlx_pci.h"
#include "mlx_nodnic/include/mlx_device.h"
#include "mlx_nodnic/include/mlx_port.h"
#include <byteswap.h>
#include <usr/ifmgmt.h>
#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h"
#include "mlx_utils/include/public/mlx_pci_gw.h"
#include "mlx_utils/mlx_lib/mlx_vmac/mlx_vmac.h"
#include "mlx_utils/mlx_lib/mlx_mtu/mlx_mtu.h"

Go to the source code of this file.

Macros

#define ARM_CQ_UAR_CQ_CI_MASK   0xffffff
 
#define ARM_CQ_UAR_CMDSN_MASK   3
 
#define ARM_CQ_UAR_CMDSN_OFFSET   28
 
#define ARM_CQ_UAR_CQ_CI_OFFSET   0x20
 
#define FLEX_NODNIC_TX_POLL_TOUT   500000
 
#define FLEX_NODNIC_TX_POLL_USLEEP   10
 
#define FLEXBOOT_NODNIC_ETH_NUM_SEND_WQES   64
 Number of flexboot_nodnic Ethernet send work queue entries. More...
 
#define FLEXBOOT_NODNIC_ETH_NUM_RECV_WQES   64
 Number of flexboot_nodnic Ethernet receive work queue entries. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static int flexboot_nodnic_arm_cq (struct flexboot_nodnic_port *port)
 
static int flexboot_nodnic_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Create completion queue. More...
 
static void flexboot_nodnic_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue. More...
 
static struct ib_work_queueflexboot_nodnic_find_wq (struct ib_device *ibdev, struct ib_completion_queue *cq, unsigned long qpn, int is_send)
 
static int flexboot_nodnic_complete (struct ib_device *ibdev, struct ib_completion_queue *cq, struct cqe_data *cqe_data)
 Handle completion. More...
 
static void flexboot_nodnic_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Poll completion queue. More...
 
static int flexboot_nodnic_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create queue pair. More...
 
static int flexboot_nodnic_modify_qp (struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp __attribute__((unused)))
 Modify queue pair. More...
 
static void flexboot_nodnic_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair. More...
 
static int flexboot_nodnic_post_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *av, struct io_buffer *iobuf)
 Post send work queue entry. More...
 
static int flexboot_nodnic_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry. More...
 
static void flexboot_nodnic_poll_eq (struct ib_device *ibdev)
 
static int flexboot_nodnic_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 
static void flexboot_nodnic_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 
static int flexboot_nodnic_ib_open (struct ib_device *ibdev __attribute__((unused)))
 Initialise Infiniband link. More...
 
static void flexboot_nodnic_ib_close (struct ib_device *ibdev __attribute__((unused)))
 Close Infiniband link. More...
 
static int flexboot_nodnic_inform_sma (struct ib_device *ibdev __attribute__((unused)), union ib_mad *mad __attribute__((unused)))
 Inform embedded subnet management agent of a received MAD. More...
 
static void flexboot_nodnic_complete_all_tx (struct flexboot_nodnic_port *port)
 
static void flexboot_nodnic_port_disable_dma (struct flexboot_nodnic_port *port)
 
static int flexboot_nodnic_eth_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet via flexboot_nodnic Ethernet device. More...
 
static void flexboot_nodnic_eth_complete_send (struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
 Handle flexboot_nodnic Ethernet device send completion. More...
 
static void flexboot_nodnic_eth_complete_recv (struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp, struct ib_address_vector *dest __attribute__((unused)), struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Handle flexboot_nodnic Ethernet device receive completion. More...
 
static void flexboot_nodnic_eth_poll (struct net_device *netdev)
 Poll flexboot_nodnic Ethernet device. More...
 
static int flexboot_nodnic_eth_open (struct net_device *netdev)
 Open flexboot_nodnic Ethernet device. More...
 
static void flexboot_nodnic_eth_close (struct net_device *netdev)
 Close flexboot_nodnic Ethernet device. More...
 
void flexboot_nodnic_eth_irq (struct net_device *netdev, int enable)
 
static int flexboot_nodnic_register_netdev (struct flexboot_nodnic *flexboot_nodnic, struct flexboot_nodnic_port *port)
 Register flexboot_nodnic Ethernet device. More...
 
static void flexboot_nodnic_state_change_netdev (struct flexboot_nodnic *flexboot_nodnic __attribute__((unused)), struct flexboot_nodnic_port *port, int link_up)
 Handle flexboot_nodnic Ethernet device port state change. More...
 
static void flexboot_nodnic_unregister_netdev (struct flexboot_nodnic *flexboot_nodnic __attribute__((unused)), struct flexboot_nodnic_port *port)
 Unregister flexboot_nodnic Ethernet device. More...
 
static mlx_status flexboot_nodnic_allocate_infiniband_devices (struct flexboot_nodnic *flexboot_nodnic_priv)
 
static mlx_status flexboot_nodnic_thin_init_ports (struct flexboot_nodnic *flexboot_nodnic_priv)
 
static mlx_status flexboot_nodnic_set_ports_type (struct flexboot_nodnic *flexboot_nodnic_priv)
 
static mlx_status flexboot_nodnic_ports_register_dev (struct flexboot_nodnic *flexboot_nodnic_priv)
 
static mlx_status flexboot_nodnic_ports_unregister_dev (struct flexboot_nodnic *flexboot_nodnic_priv)
 
 __attribute__ ((unused))
 
int flexboot_nodnic_is_supported (struct pci_device *pci)
 
void flexboot_nodnic_copy_mac (uint8_t mac_addr[], uint32_t low_byte, uint16_t high_byte)
 
static mlx_status flexboot_nodnic_get_factory_mac (struct flexboot_nodnic *flexboot_nodnic_priv, uint8_t port __attribute__((unused)))
 
static int flexboot_nodnic_set_port_masking (struct flexboot_nodnic *flexboot_nodnic)
 Set port masking. More...
 
int init_mlx_utils (mlx_utils **utils, struct pci_device *pci)
 
void free_mlx_utils (mlx_utils **utils)
 
static int flexboot_nodnic_alloc_uar (struct flexboot_nodnic *flexboot_nodnic)
 Initialise Nodnic PCI parameters. More...
 
static int flexboot_nodnic_dealloc_uar (struct flexboot_nodnic *flexboot_nodnic)
 
int flexboot_nodnic_probe (struct pci_device *pci, struct flexboot_nodnic_callbacks *callbacks, void *drv_priv __attribute__((unused)))
 
void flexboot_nodnic_remove (struct pci_device *pci)
 

Variables

static struct ib_device_operations flexboot_nodnic_ib_operations
 flexboot_nodnic Infiniband operations More...
 
static struct ib_queue_pair_operations flexboot_nodnic_eth_qp_op
 flexboot nodnic Ethernet queue pair operations More...
 
static struct ib_completion_queue_operations flexboot_nodnic_eth_cq_op
 flexboot_nodnic Ethernet device completion operations More...
 
static struct net_device_operations flexboot_nodnic_eth_operations
 flexboot_nodnic Ethernet network device operations More...
 
static struct flexboot_nodnic_port_type flexboot_nodnic_port_type_eth
 flexboot_nodnic Ethernet port type More...
 

Macro Definition Documentation

◆ ARM_CQ_UAR_CQ_CI_MASK

#define ARM_CQ_UAR_CQ_CI_MASK   0xffffff

◆ ARM_CQ_UAR_CMDSN_MASK

#define ARM_CQ_UAR_CMDSN_MASK   3

◆ ARM_CQ_UAR_CMDSN_OFFSET

#define ARM_CQ_UAR_CMDSN_OFFSET   28

◆ ARM_CQ_UAR_CQ_CI_OFFSET

#define ARM_CQ_UAR_CQ_CI_OFFSET   0x20

◆ FLEX_NODNIC_TX_POLL_TOUT

#define FLEX_NODNIC_TX_POLL_TOUT   500000

Definition at line 701 of file flexboot_nodnic.c.

◆ FLEX_NODNIC_TX_POLL_USLEEP

#define FLEX_NODNIC_TX_POLL_USLEEP   10

Definition at line 702 of file flexboot_nodnic.c.

◆ FLEXBOOT_NODNIC_ETH_NUM_SEND_WQES

#define FLEXBOOT_NODNIC_ETH_NUM_SEND_WQES   64

Number of flexboot_nodnic Ethernet send work queue entries.

Definition at line 748 of file flexboot_nodnic.c.

◆ FLEXBOOT_NODNIC_ETH_NUM_RECV_WQES

#define FLEXBOOT_NODNIC_ETH_NUM_RECV_WQES   64

Number of flexboot_nodnic Ethernet receive work queue entries.

Definition at line 751 of file flexboot_nodnic.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ flexboot_nodnic_arm_cq()

static int flexboot_nodnic_arm_cq ( struct flexboot_nodnic_port port)
static

Definition at line 55 of file flexboot_nodnic.c.

55  {
56 #ifndef DEVICE_CX3
57  mlx_uint32 val32 = 0;
58  union arm_cq_uar cq_uar;
59 
60 #define ARM_CQ_UAR_CQ_CI_MASK 0xffffff
61 #define ARM_CQ_UAR_CMDSN_MASK 3
62 #define ARM_CQ_UAR_CMDSN_OFFSET 28
63 #define ARM_CQ_UAR_CQ_CI_OFFSET 0x20
64  if ( port->port_priv.device->device_cap.support_bar_cq_ctrl ) {
65  cq_uar.dword[0] = cpu_to_be32((port->eth_cq->next_idx & ARM_CQ_UAR_CQ_CI_MASK) |
67  cq_uar.dword[1] = cpu_to_be32(port->eth_cq->cqn);
68  wmb();
69  writeq(cq_uar.qword, port->port_priv.device->uar.virt + ARM_CQ_UAR_CQ_CI_OFFSET);
70  port->port_priv.arm_cq_doorbell_record->dword[0] = cq_uar.dword[1];
71  port->port_priv.arm_cq_doorbell_record->dword[1] = cq_uar.dword[0];
72  } else {
73  val32 = ( port->eth_cq->next_idx & 0xffffff );
74  if ( nodnic_port_set ( & port->port_priv, nodnic_port_option_arm_cq, val32 ) ) {
75  MLX_DEBUG_ERROR( port->port_priv.device, "Failed to arm the CQ\n" );
76  return MLX_FAILED;
77  }
78  }
79 #else
80  mlx_utils *utils = port->port_priv.device->utils;
81  nodnic_port_data_flow_gw *ptr = port->port_priv.data_flow_gw;
82  mlx_uint32 data = 0;
83  mlx_uint32 val = 0;
84 
85  if ( port->port_priv.device->device_cap.crspace_doorbells == 0 ) {
86  val = ( port->eth_cq->next_idx & 0xffff );
87  if ( nodnic_port_set ( & port->port_priv, nodnic_port_option_arm_cq, val ) ) {
88  MLX_DEBUG_ERROR( port->port_priv.device, "Failed to arm the CQ\n" );
89  return MLX_FAILED;
90  }
91  } else {
92  /* Arming the CQ with CQ CI should be with this format -
93  * 16 bit - CQ CI - same endianness as the FW (don't swap bytes)
94  * 15 bit - reserved
95  * 1 bit - arm CQ - must correct the endianness with the reserved above */
96  data = ( ( ( port->eth_cq->next_idx & 0xffff ) << 16 ) | 0x0080 );
97  /* Write the new index and update FW that new data was submitted */
99  ( mlx_uintn ) & ( ptr->armcq_cq_ci_dword ), 1, &data );
100  }
101 #endif
102  return 0;
103 }
wmb()
mlx_status mlx_pci_mem_write(IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint8 bar_index, IN mlx_uint64 offset, IN mlx_uintn count, IN mlx_void *buffer)
Definition: mlx_pci.c:116
#define ARM_CQ_UAR_CMDSN_MASK
mlx_uint32 dword[2]
uint32_t mlx_uint32
#define ARM_CQ_UAR_CQ_CI_OFFSET
u8 port
Port number.
Definition: CIB_PRM.h:31
#define ARM_CQ_UAR_CQ_CI_MASK
mlx_status nodnic_port_set(IN nodnic_port_priv *port_priv, IN nodnic_port_option option, IN mlx_uint32 in)
Definition: mlx_port.c:155
#define MLX_FAILED
void __asmcall int val
Definition: setjmp.h:28
unsigned long mlx_uintn
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define ARM_CQ_UAR_CMDSN_OFFSET

References ARM_CQ_UAR_CMDSN_MASK, ARM_CQ_UAR_CMDSN_OFFSET, ARM_CQ_UAR_CQ_CI_MASK, ARM_CQ_UAR_CQ_CI_OFFSET, cpu_to_be32, data, arm_cq_uar::dword, MLX_DEBUG_ERROR, MLX_FAILED, mlx_pci_mem_write(), MlxPciWidthUint32, nodnic_port_option_arm_cq, nodnic_port_set(), port, arm_cq_uar::qword, val, wmb(), and writeq().

Referenced by flexboot_nodnic_eth_irq().

◆ flexboot_nodnic_create_cq()

static int flexboot_nodnic_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 112 of file flexboot_nodnic.c.

113  {
114  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
116  struct flexboot_nodnic_completion_queue *flexboot_nodnic_cq;
118  mlx_uint32 cqn;
119 
120  flexboot_nodnic_cq = (struct flexboot_nodnic_completion_queue *)
121  zalloc(sizeof(*flexboot_nodnic_cq));
122  if ( flexboot_nodnic_cq == NULL ) {
124  goto qp_alloc_err;
125  }
126 
127  status = nodnic_port_create_cq(&port->port_priv,
128  cq->num_cqes *
130  &flexboot_nodnic_cq->nodnic_completion_queue
131  );
132  MLX_FATAL_CHECK_STATUS(status, create_err,
133  "nodnic_port_create_cq failed");
135  flexboot_nodnic_cq->nodnic_completion_queue->cq_virt,
136  cq->num_cqes);
138  status = nodnic_port_query(&port->port_priv,
140  (mlx_uint32 *)&cqn );
141  MLX_FATAL_CHECK_STATUS(status, read_cqn_err,
142  "failed to query cqn");
143  cq->cqn = cqn;
144  }
145 
146  ib_cq_set_drvdata ( cq, flexboot_nodnic_cq );
147  return status;
148 read_cqn_err:
149 create_err:
150  free(flexboot_nodnic_cq);
151 qp_alloc_err:
152  return status;
153 }
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
mlx_void * cq_virt
cq entries
mlx_status(* cqe_set_owner)(void *cq, unsigned int num_cqes)
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
mlx_status nodnic_port_create_cq(IN nodnic_port_priv *port_priv, IN mlx_size cq_size, OUT nodnic_cq **cq)
Definition: mlx_port.c:360
nodnic_device_capabilites device_cap
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
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
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
mlx_status nodnic_port_query(IN nodnic_port_priv *port_priv, IN nodnic_port_option option, OUT mlx_uint32 *out)
Definition: mlx_port.c:126
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
#define MLX_OUT_OF_RESOURCES
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
A flexboot nodnic port.
int mlx_status
struct flexboot_nodnic_callbacks * callbacks
nic specific data
__be32 cqn
Definition: CIB_PRM.h:29
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References flexboot_nodnic::callbacks, _nodnic_cq::cq_virt, flexboot_nodnic_callbacks::cqe_set_owner, cqn, ib_completion_queue::cqn, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, free, flexboot_nodnic_callbacks::get_cqe_size, ib_cq_set_drvdata(), ib_get_drvdata(), flexboot_nodnic_port::ibdev, MLX_FATAL_CHECK_STATUS, MLX_OUT_OF_RESOURCES, MLX_SUCCESS, flexboot_nodnic_completion_queue::nodnic_completion_queue, nodnic_port_create_cq(), nodnic_port_option_cq_n_index, nodnic_port_query(), NULL, ib_completion_queue::num_cqes, port, flexboot_nodnic::port, ib_device::port, status, _nodnic_device_capabilites::support_bar_cq_ctrl, and zalloc().

◆ flexboot_nodnic_destroy_cq()

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

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 161 of file flexboot_nodnic.c.

162  {
163  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
165  struct flexboot_nodnic_completion_queue *flexboot_nodnic_cq = ib_cq_get_drvdata ( cq );
166 
167  nodnic_port_destroy_cq(&port->port_priv,
168  flexboot_nodnic_cq->nodnic_completion_queue);
169 
170  free(flexboot_nodnic_cq);
171 }
struct ib_device * ibdev
Infiniband device.
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
mlx_status nodnic_port_destroy_cq(IN nodnic_port_priv *port_priv, IN nodnic_cq *cq)
Definition: mlx_port.c:426
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685

References free, ib_cq_get_drvdata(), ib_get_drvdata(), flexboot_nodnic_port::ibdev, flexboot_nodnic_completion_queue::nodnic_completion_queue, nodnic_port_destroy_cq(), port, flexboot_nodnic::port, and ib_device::port.

◆ flexboot_nodnic_find_wq()

static struct ib_work_queue* flexboot_nodnic_find_wq ( struct ib_device ibdev,
struct ib_completion_queue cq,
unsigned long  qpn,
int  is_send 
)
static

Definition at line 174 of file flexboot_nodnic.c.

176  {
177  struct ib_work_queue *wq;
178  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp;
179  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
181  struct nodnic_ring *ring;
182  mlx_uint32 out_qpn;
183  list_for_each_entry ( wq, &cq->work_queues, list ) {
184  flexboot_nodnic_qp = ib_qp_get_drvdata ( wq->qp );
185  if( wq->is_send == is_send && wq->is_send == TRUE ) {
186  ring = &flexboot_nodnic_qp->nodnic_queue_pair->send.nodnic_ring;
187  } else if( wq->is_send == is_send && wq->is_send == FALSE ) {
188  ring = &flexboot_nodnic_qp->nodnic_queue_pair->receive.nodnic_ring;
189  } else {
190  continue;
191  }
192  nodnic_port_get_qpn(&port->port_priv, ring, &out_qpn);
193  if ( out_qpn == qpn )
194  return wq;
195  }
196  return NULL;
197 }
struct nodnic_ring nodnic_ring
struct nodnic_send_ring send
struct ib_device * ibdev
Infiniband device.
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
__be32 qpn
Definition: CIB_PRM.h:29
uint32_t mlx_uint32
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
An Infiniband Work Queue.
Definition: infiniband.h:100
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
struct nodnic_recv_ring receive
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
#define TRUE
Definition: tlan.h:46
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
#define FALSE
Definition: tlan.h:45
mlx_status nodnic_port_get_qpn(IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, OUT mlx_uint32 *qpn)
Definition: mlx_port.c:796
int is_send
"Is a send queue" flag
Definition: infiniband.h:104
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A flexboot nodnic queue pair.
struct nodnic_ring nodnic_ring

References FALSE, ib_get_drvdata(), ib_qp_get_drvdata(), flexboot_nodnic_port::ibdev, ib_work_queue::is_send, list_for_each_entry, nodnic_port_get_qpn(), flexboot_nodnic_queue_pair::nodnic_queue_pair, nodnic_send_ring::nodnic_ring, nodnic_recv_ring::nodnic_ring, NULL, port, flexboot_nodnic::port, ib_device::port, ib_work_queue::qp, qpn, _nodnic_qp::receive, _nodnic_qp::send, TRUE, and ib_completion_queue::work_queues.

Referenced by flexboot_nodnic_complete().

◆ flexboot_nodnic_complete()

static int flexboot_nodnic_complete ( struct ib_device ibdev,
struct ib_completion_queue cq,
struct cqe_data cqe_data 
)
static

Handle completion.

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

Definition at line 207 of file flexboot_nodnic.c.

209  {
210  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
211  struct ib_work_queue *wq;
212  struct ib_queue_pair *qp;
213  struct io_buffer *iobuf;
214  struct ib_address_vector recv_dest;
215  struct ib_address_vector recv_source;
216  unsigned long qpn;
217  unsigned long wqe_idx;
218  unsigned long wqe_idx_mask;
219  size_t len;
220  int rc = 0;
221 
222  /* Parse completion */
223  qpn = cqe_data->qpn;
224 
225  if ( cqe_data->is_error == TRUE ) {
226  DBGC ( flexboot_nodnic, "flexboot_nodnic %p CQN %#lx syndrome %x vendor %x\n",
229  rc = -EIO;
230  /* Don't return immediately; propagate error to completer */
231  }
232 
233  /* Identify work queue */
234  wq = flexboot_nodnic_find_wq( ibdev, cq, qpn, cqe_data->is_send );
235  if ( wq == NULL ) {
237  "flexboot_nodnic %p CQN %#lx unknown %s QPN %#lx\n",
238  flexboot_nodnic, cq->cqn,
239  ( cqe_data->is_send ? "send" : "recv" ), qpn );
240  return -EIO;
241  }
242  qp = wq->qp;
243 
244  /* Identify work queue entry */
245  wqe_idx = cqe_data->wqe_counter;
246  wqe_idx_mask = ( wq->num_wqes - 1 );
248  "NODNIC %p CQN %#lx QPN %#lx %s WQE %#lx completed:\n",
249  flexboot_nodnic, cq->cqn, qp->qpn,
250  ( cqe_data->is_send ? "send" : "recv" ),
251  wqe_idx );
252 
253  /* Identify I/O buffer */
254  iobuf = wq->iobufs[wqe_idx & wqe_idx_mask];
255  if ( iobuf == NULL ) {
257  "NODNIC %p CQN %#lx QPN %#lx empty %s WQE %#lx\n",
258  flexboot_nodnic, cq->cqn, qp->qpn,
259  ( cqe_data->is_send ? "send" : "recv" ), wqe_idx );
260  return -EIO;
261  }
262  wq->iobufs[wqe_idx & wqe_idx_mask] = NULL;
263 
264  if ( cqe_data->is_send == TRUE ) {
265  /* Hand off to completion handler */
266  ib_complete_send ( ibdev, qp, iobuf, rc );
267  } else if ( rc != 0 ) {
268  /* Propagate error to receive completion handler */
269  ib_complete_recv ( ibdev, qp, NULL, NULL, iobuf, rc );
270  } else {
271  /* Set received length */
272  len = cqe_data->byte_cnt;
273  assert ( len <= iob_tailroom ( iobuf ) );
274  iob_put ( iobuf, len );
275  memset ( &recv_dest, 0, sizeof ( recv_dest ) );
276  recv_dest.qpn = qpn;
277  memset ( &recv_source, 0, sizeof ( recv_source ) );
278  switch ( qp->type ) {
279  case IB_QPT_SMI:
280  case IB_QPT_GSI:
281  case IB_QPT_UD:
282  case IB_QPT_RC:
283  break;
284  case IB_QPT_ETH:
285  break;
286  default:
287  assert ( 0 );
288  return -EINVAL;
289  }
290  /* Hand off to completion handler */
291  ib_complete_recv ( ibdev, qp, &recv_dest,
292  &recv_source, iobuf, rc );
293  }
294 
295  return rc;
296 }
#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
mlx_uint32 is_error
#define DBGC(...)
Definition: compiler.h:505
mlx_uint32 byte_cnt
__be32 qpn
Definition: CIB_PRM.h:29
static struct ib_work_queue * flexboot_nodnic_find_wq(struct ib_device *ibdev, struct ib_completion_queue *cq, unsigned long qpn, int is_send)
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
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
A flexboot_nodnic device.
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
mlx_uint32 vendor_err_syndrome
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
#define TRUE
Definition: tlan.h:46
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
mlx_uint32 syndrome
uint32_t len
Length.
Definition: ena.h:14
#define EIO
Input/output error.
Definition: errno.h:433
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
#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
An Infiniband Address Vector.
Definition: infiniband.h:72
mlx_uint32 qpn
mlx_uint32 wqe_counter
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
mlx_uint32 is_send
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(), cqe_data::byte_cnt, ib_completion_queue::cqn, DBGC, DBGCP, EINVAL, EIO, flexboot_nodnic_find_wq(), ib_complete_recv(), ib_complete_send(), ib_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, cqe_data::is_error, cqe_data::is_send, len, memset(), NULL, ib_work_queue::num_wqes, qp, ib_work_queue::qp, qpn, ib_address_vector::qpn, cqe_data::qpn, rc, cqe_data::syndrome, TRUE, cqe_data::vendor_err_syndrome, and cqe_data::wqe_counter.

Referenced by flexboot_nodnic_poll_cq().

◆ flexboot_nodnic_poll_cq()

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

Poll completion queue.

Parameters
ibdevInfiniband device
cqCompletion queues

Definition at line 303 of file flexboot_nodnic.c.

304  {
305  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
306  struct flexboot_nodnic_completion_queue *flexboot_nodnic_cq = ib_cq_get_drvdata ( cq );
307  void *cqe;
308  mlx_size cqe_size;
309  struct cqe_data cqe_data;
310  unsigned int cqe_idx_mask;
311  int rc;
312 
313  cqe_size = flexboot_nodnic->callbacks->get_cqe_size();
314  while ( TRUE ) {
315  /* Look for completion entry */
316  cqe_idx_mask = ( cq->num_cqes - 1 );
317  cqe = ((uint8_t *)flexboot_nodnic_cq->nodnic_completion_queue->cq_virt) +
318  cqe_size * (cq->next_idx & cqe_idx_mask);
319 
320  /* TODO: check fill_completion */
322  if ( cqe_data.owner ^
323  ( ( cq->next_idx & cq->num_cqes ) ? 1 : 0 ) ) {
324  /* Entry still owned by hardware; end of poll */
325  break;
326  }
327  /* Handle completion */
328  rc = flexboot_nodnic_complete ( ibdev, cq, &cqe_data );
329  if ( rc != 0 ) {
330  DBGC ( flexboot_nodnic, "flexboot_nodnic %p CQN %#lx failed to complete: %s\n",
331  flexboot_nodnic, cq->cqn, strerror ( rc ) );
333  cqe, sizeof ( *cqe ) );
334  }
335 
336  /* Update completion queue's index */
337  cq->next_idx++;
338  }
339 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
mlx_void * cq_virt
cq entries
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
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
mlx_status(* fill_completion)(void *cqe, struct cqe_data *cqe_data)
A flexboot_nodnic device.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
size_t mlx_size
unsigned char uint8_t
Definition: stdint.h:10
#define TRUE
Definition: tlan.h:46
unsigned long next_idx
Next completion queue entry index.
Definition: infiniband.h:240
static int flexboot_nodnic_complete(struct ib_device *ibdev, struct ib_completion_queue *cq, struct cqe_data *cqe_data)
Handle completion.
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
mlx_boolean owner
struct flexboot_nodnic_callbacks * callbacks
nic specific data
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685

References flexboot_nodnic::callbacks, _nodnic_cq::cq_virt, ib_completion_queue::cqn, DBGC, DBGC_HDA, flexboot_nodnic_callbacks::fill_completion, flexboot_nodnic_complete(), flexboot_nodnic_callbacks::get_cqe_size, ib_cq_get_drvdata(), ib_get_drvdata(), ib_completion_queue::next_idx, flexboot_nodnic_completion_queue::nodnic_completion_queue, ib_completion_queue::num_cqes, cqe_data::owner, rc, strerror(), TRUE, and virt_to_phys().

◆ flexboot_nodnic_create_qp()

static int flexboot_nodnic_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 355 of file flexboot_nodnic.c.

356  {
357  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
359  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp;
361 
362  flexboot_nodnic_qp = (struct flexboot_nodnic_queue_pair *)zalloc(sizeof(*flexboot_nodnic_qp));
363  if ( flexboot_nodnic_qp == NULL ) {
365  goto qp_alloc_err;
366  }
367 
368  status = nodnic_port_create_qp(&port->port_priv, qp->type,
369  qp->send.num_wqes * sizeof(struct nodnic_send_wqbb),
370  qp->send.num_wqes,
371  qp->recv.num_wqes * sizeof(struct nodnic_recv_wqe),
372  qp->recv.num_wqes,
373  &flexboot_nodnic_qp->nodnic_queue_pair);
374  MLX_FATAL_CHECK_STATUS(status, create_err,
375  "nodnic_port_create_qp failed");
376  ib_qp_set_drvdata ( qp, flexboot_nodnic_qp );
377  return status;
378 create_err:
379  free(flexboot_nodnic_qp);
380 qp_alloc_err:
381  return status;
382 }
struct ib_device * ibdev
Infiniband device.
mlx_status nodnic_port_create_qp(IN nodnic_port_priv *port_priv, IN nodnic_queue_pair_type type, IN mlx_size send_wq_size, IN mlx_uint32 send_wqe_num, IN mlx_size receive_wq_size, IN mlx_uint32 recv_wqe_num, OUT nodnic_qp **qp)
Definition: mlx_port.c:585
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define MLX_OUT_OF_RESOURCES
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
int mlx_status
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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
A flexboot nodnic queue pair.

References free, ib_get_drvdata(), ib_qp_set_drvdata(), flexboot_nodnic_port::ibdev, MLX_FATAL_CHECK_STATUS, MLX_OUT_OF_RESOURCES, MLX_SUCCESS, nodnic_port_create_qp(), flexboot_nodnic_queue_pair::nodnic_queue_pair, NULL, port, flexboot_nodnic::port, ib_device::port, qp, status, and zalloc().

◆ flexboot_nodnic_modify_qp()

static int flexboot_nodnic_modify_qp ( struct ib_device *ibdev   __attribute__(unused),
struct ib_queue_pair *qp   __attribute__(unused) 
)
static

Modify queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 391 of file flexboot_nodnic.c.

392  {
393  /*not needed*/
394  return 0;
395 }

◆ flexboot_nodnic_destroy_qp()

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

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 403 of file flexboot_nodnic.c.

404  {
405  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
407  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp = ib_qp_get_drvdata ( qp );
408 
409  nodnic_port_destroy_qp(&port->port_priv, qp->type,
410  flexboot_nodnic_qp->nodnic_queue_pair);
411 
412  free(flexboot_nodnic_qp);
413 }
struct ib_device * ibdev
Infiniband device.
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
mlx_status nodnic_port_destroy_qp(IN nodnic_port_priv *port_priv, IN nodnic_queue_pair_type type, IN nodnic_qp *qp)
Definition: mlx_port.c:726
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
A flexboot nodnic queue pair.

References free, ib_get_drvdata(), ib_qp_get_drvdata(), flexboot_nodnic_port::ibdev, nodnic_port_destroy_qp(), flexboot_nodnic_queue_pair::nodnic_queue_pair, port, flexboot_nodnic::port, ib_device::port, and qp.

◆ flexboot_nodnic_post_send()

static int flexboot_nodnic_post_send ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector av,
struct io_buffer iobuf 
)
static

Post send work queue entry.

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

Definition at line 431 of file flexboot_nodnic.c.

434  {
435 
436  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
437  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp = ib_qp_get_drvdata ( qp );
439  struct ib_work_queue *wq = &qp->send;
440  struct nodnic_send_wqbb *wqbb;
441  nodnic_qp *nodnic_qp = flexboot_nodnic_qp->nodnic_queue_pair;
442  struct nodnic_send_ring *send_ring = &nodnic_qp->send;
444  unsigned int wqe_idx_mask;
445  unsigned long wqe_idx;
446 
447  if ( ( port->port_priv.dma_state == FALSE ) ||
448  ( port->port_priv.port_state & NODNIC_PORT_DISABLING_DMA ) ) {
449  DBGC ( flexboot_nodnic, "flexboot_nodnic DMA disabled\n");
450  status = -ENETDOWN;
451  goto post_send_done;
452  }
453 
454  /* Allocate work queue entry */
455  wqe_idx = wq->next_idx;
456  wqe_idx_mask = ( wq->num_wqes - 1 );
457  if ( wq->iobufs[wqe_idx & wqe_idx_mask] ) {
458  DBGC ( flexboot_nodnic, "flexboot_nodnic %p QPN %#lx send queue full\n",
459  flexboot_nodnic, qp->qpn );
460  status = -ENOBUFS;
461  goto post_send_done;
462  }
463  wqbb = &send_ring->wqe_virt[wqe_idx & wqe_idx_mask];
464  wq->iobufs[wqe_idx & wqe_idx_mask] = iobuf;
465 
467  fill_send_wqe[qp->type] != NULL );
469  fill_send_wqe[qp->type] ( ibdev, qp, av, iobuf,
470  wqbb, wqe_idx );
471  if ( status != 0 ) {
472  DBGC ( flexboot_nodnic, "flexboot_nodnic %p QPN %#lx fill send wqe failed\n",
473  flexboot_nodnic, qp->qpn );
474  goto post_send_done;
475  }
476 
477  wq->next_idx++;
478 
479  status = port->port_priv.send_doorbell ( &port->port_priv,
480  &send_ring->nodnic_ring, ( mlx_uint16 ) wq->next_idx );
483  }
484  if ( status != 0 ) {
485  DBGC ( flexboot_nodnic, "flexboot_nodnic %p ring send doorbell failed\n", flexboot_nodnic );
486  }
487 
488 post_send_done:
489  return status;
490 }
struct nodnic_ring nodnic_ring
struct nodnic_send_ring send
#define NODNIC_PORT_DISABLING_DMA
struct ib_device * ibdev
Infiniband device.
#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 nodnic_send_wqbb * wqe_virt
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
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
mlx_status(* tx_uar_send_doorbell_fn)(struct ib_device *ibdev, struct nodnic_send_wqbb *wqbb)
#define MLX_SUCCESS
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
unsigned long next_idx
Next work queue entry index.
Definition: infiniband.h:122
uint16_t mlx_uint16
#define ENETDOWN
Network is down.
Definition: errno.h:478
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
#define FALSE
Definition: tlan.h:45
int mlx_status
struct flexboot_nodnic_callbacks * callbacks
nic specific data
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A flexboot nodnic queue pair.
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), flexboot_nodnic::callbacks, DBGC, ENETDOWN, ENOBUFS, FALSE, ib_get_drvdata(), ib_qp_get_drvdata(), flexboot_nodnic_port::ibdev, ib_work_queue::iobufs, MLX_SUCCESS, ib_work_queue::next_idx, NODNIC_PORT_DISABLING_DMA, flexboot_nodnic_queue_pair::nodnic_queue_pair, nodnic_send_ring::nodnic_ring, NULL, ib_work_queue::num_wqes, port, flexboot_nodnic::port, ib_device::port, qp, _nodnic_qp::send, status, flexboot_nodnic_callbacks::tx_uar_send_doorbell_fn, and nodnic_send_ring::wqe_virt.

◆ flexboot_nodnic_post_recv()

static int flexboot_nodnic_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 500 of file flexboot_nodnic.c.

502  {
503  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
504  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp = ib_qp_get_drvdata ( qp );
506  struct ib_work_queue *wq = &qp->recv;
507  nodnic_qp *nodnic_qp = flexboot_nodnic_qp->nodnic_queue_pair;
508  struct nodnic_recv_ring *recv_ring = &nodnic_qp->receive;
509  struct nodnic_recv_wqe *wqe;
510  unsigned int wqe_idx_mask;
512 
513  /* Allocate work queue entry */
514  wqe_idx_mask = ( wq->num_wqes - 1 );
515  if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
517  "flexboot_nodnic %p QPN %#lx receive queue full\n",
518  flexboot_nodnic, qp->qpn );
519  status = -ENOBUFS;
520  goto post_recv_done;
521  }
522  wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
523  wqe = &((struct nodnic_recv_wqe*)recv_ring->wqe_virt)[wq->next_idx & wqe_idx_mask];
524 
525  MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
526  MLX_FILL_1 ( &wqe->data[0], 1, l_key, flexboot_nodnic->device_priv.lkey );
527  MLX_FILL_H ( &wqe->data[0], 2,
528  local_address_h, virt_to_bus ( iobuf->data ) );
529  MLX_FILL_1 ( &wqe->data[0], 3,
530  local_address_l, virt_to_bus ( iobuf->data ) );
531 
532  wq->next_idx++;
533 
534  status = port->port_priv.recv_doorbell ( &port->port_priv,
535  &recv_ring->nodnic_ring, ( mlx_uint16 ) wq->next_idx );
536  if ( status != 0 ) {
537  DBGC ( flexboot_nodnic, "flexboot_nodnic %p ring receive doorbell failed\n", flexboot_nodnic );
538  }
539 post_recv_done:
540  return status;
541 }
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
#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
uint8_t status
Status.
Definition: ena.h:16
struct nodnic_wqe_segment_data_ptr data[HERMON_MAX_SCATTER]
Definition: nodnic_prm.h:44
u8 port
Port number.
Definition: CIB_PRM.h:31
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
#define MLX_SUCCESS
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
struct nodnic_recv_ring receive
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
#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
uint16_t mlx_uint16
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
void * data
Start of data.
Definition: iobuf.h:44
A flexboot nodnic port.
int mlx_status
A flexboot nodnic queue pair.
struct nodnic_ring nodnic_ring
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References byte_count, nodnic_recv_wqe::data, io_buffer::data, DBGC, flexboot_nodnic::device_priv, ENOBUFS, ib_get_drvdata(), ib_qp_get_drvdata(), flexboot_nodnic_port::ibdev, iob_tailroom(), ib_work_queue::iobufs, _nodnic_device_priv::lkey, MLX_FILL_1, MLX_FILL_H, MLX_SUCCESS, ib_work_queue::next_idx, flexboot_nodnic_queue_pair::nodnic_queue_pair, nodnic_recv_ring::nodnic_ring, ib_work_queue::num_wqes, port, flexboot_nodnic::port, ib_device::port, qp, _nodnic_qp::receive, status, virt_to_bus(), and nodnic_recv_ring::wqe_virt.

◆ flexboot_nodnic_poll_eq()

static void flexboot_nodnic_poll_eq ( struct ib_device ibdev)
static

Definition at line 550 of file flexboot_nodnic.c.

550  {
552  struct flexboot_nodnic_port *port;
553  struct net_device *netdev;
556 
557  if ( ! ibdev ) {
558  DBG ( "%s: ibdev = NULL!!!\n", __FUNCTION__ );
559  return;
560  }
561 
562  flexboot_nodnic = ib_get_drvdata ( ibdev );
563  port = &flexboot_nodnic->port[ibdev->port - 1];
564  netdev = port->netdev;
565 
566  if ( ! netdev_is_open ( netdev ) ) {
567  DBG2( "%s: port %d is closed\n", __FUNCTION__, port->ibdev->port );
568  return;
569  }
570 
571  /* we don't poll EQ. Just poll link status if it's not active */
572  if ( ! netdev_link_ok ( netdev ) ) {
573  status = nodnic_port_get_state ( &port->port_priv, &state );
574  MLX_FATAL_CHECK_STATUS(status, state_err, "nodnic_port_get_state failed");
575 
576  if ( state == nodnic_port_state_active ) {
577  DBG( "%s: port %d physical link is up\n", __FUNCTION__,
578  port->ibdev->port );
579  port->type->state_change ( flexboot_nodnic, port, 1 );
580  }
581  }
582 state_err:
583  return;
584 }
mlx_status nodnic_port_get_state(IN nodnic_port_priv *port_priv, OUT nodnic_port_state *state)
Definition: mlx_port.c:88
uint8_t state
State.
Definition: eth_slow.h:47
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
nodnic_port_state
Definition: mlx_port.h:69
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
A network device.
Definition: netdevice.h:348
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
int mlx_status
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define DBG2(...)
Definition: compiler.h:515

References DBG, DBG2, ib_get_drvdata(), MLX_FATAL_CHECK_STATUS, netdev, netdev_is_open(), netdev_link_ok(), nodnic_port_get_state(), nodnic_port_state_active, port, flexboot_nodnic::port, ib_device::port, state, and status.

◆ flexboot_nodnic_mcast_attach()

static int flexboot_nodnic_mcast_attach ( struct ib_device ibdev,
struct ib_queue_pair qp,
union ib_gid gid 
)
static

Definition at line 592 of file flexboot_nodnic.c.

594  {
595  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
599 
600  switch (qp->type) {
601  case IB_QPT_ETH:
602  memcpy(&mac, gid, sizeof(mac));
603  status = nodnic_port_add_mac_filter(&port->port_priv, mac);
605  "nodnic_port_add_mac_filter failed");
606  break;
607  default:
608  break;
609  }
610 mac_err:
611  return status;
612 }
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
mlx_status nodnic_port_add_mac_filter(IN nodnic_port_priv *port_priv, IN mlx_mac_address mac)
Definition: mlx_port.c:992
uint8_t status
Status.
Definition: ena.h:16
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
int mlx_status
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
u8 gid[16]
Definition: CIB_PRM.h:31

References flexboot_nodnic::device_priv, gid, ib_get_drvdata(), IB_QPT_ETH, flexboot_nodnic_port::ibdev, mac, memcpy(), MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_add_mac_filter(), port, flexboot_nodnic::port, ib_device::port, qp, and status.

◆ flexboot_nodnic_mcast_detach()

static void flexboot_nodnic_mcast_detach ( struct ib_device ibdev,
struct ib_queue_pair qp,
union ib_gid gid 
)
static

Definition at line 613 of file flexboot_nodnic.c.

615  {
616  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
620 
621  switch (qp->type) {
622  case IB_QPT_ETH:
623  memcpy(&mac, gid, sizeof(mac));
626  "nodnic_port_remove_mac_filter failed");
627  break;
628  default:
629  break;
630  }
631 mac_err:
632  return;
633 }
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
uint8_t status
Status.
Definition: ena.h:16
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
int mlx_status
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
u8 gid[16]
Definition: CIB_PRM.h:31
mlx_status nodnic_port_remove_mac_filter(IN nodnic_port_priv *port_priv, IN mlx_mac_address mac)
Definition: mlx_port.c:1073

References flexboot_nodnic::device_priv, gid, ib_get_drvdata(), IB_QPT_ETH, flexboot_nodnic_port::ibdev, mac, memcpy(), MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_remove_mac_filter(), port, flexboot_nodnic::port, ib_device::port, qp, and status.

◆ flexboot_nodnic_ib_open()

static int flexboot_nodnic_ib_open ( struct ib_device *ibdev   __attribute__(unused))
static

Initialise Infiniband link.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 647 of file flexboot_nodnic.c.

647  {
648  int rc = 0;
649 
650  /*TODO: add implementation*/
651  return rc;
652 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14

References rc.

◆ flexboot_nodnic_ib_close()

static void flexboot_nodnic_ib_close ( struct ib_device *ibdev   __attribute__(unused))
static

Close Infiniband link.

Parameters
ibdevInfiniband device

Definition at line 659 of file flexboot_nodnic.c.

659  {
660  /*TODO: add implementation*/
661 }

◆ flexboot_nodnic_inform_sma()

static int flexboot_nodnic_inform_sma ( struct ib_device *ibdev   __attribute__(unused),
union ib_mad *mad   __attribute__(unused) 
)
static

Inform embedded subnet management agent of a received MAD.

Parameters
ibdevInfiniband device
madMAD
Return values
rcReturn status code

Definition at line 670 of file flexboot_nodnic.c.

671  {
672  /*TODO: add implementation*/
673  return 0;
674 }

◆ flexboot_nodnic_complete_all_tx()

static void flexboot_nodnic_complete_all_tx ( struct flexboot_nodnic_port port)
static

Definition at line 704 of file flexboot_nodnic.c.

704  {
705  struct ib_device *ibdev = port->ibdev;
706  struct ib_completion_queue *cq;
707  struct ib_work_queue *wq;
708  int keep_polling = 0;
710 
711  list_for_each_entry ( cq, &ibdev->cqs, list ) {
712  do {
713  ib_poll_cq ( ibdev, cq );
714  keep_polling = 0;
716  if ( wq->is_send )
717  keep_polling += ( wq->fill > 0 );
718  }
720  } while ( keep_polling && ( timeout-- > 0 ) );
721  }
722 }
#define FLEX_NODNIC_TX_POLL_USLEEP
An Infiniband device.
Definition: infiniband.h:398
struct ib_completion_queue * cq
Associated completion queue.
Definition: infiniband.h:106
u8 port
Port number.
Definition: CIB_PRM.h:31
#define FLEX_NODNIC_TX_POLL_TOUT
An Infiniband Work Queue.
Definition: infiniband.h:100
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
unsigned int fill
Number of occupied work queue entries.
Definition: infiniband.h:114
An Infiniband Completion Queue.
Definition: infiniband.h:224
struct list_head list
List of work queues on this completion queue.
Definition: infiniband.h:108
struct list_head cqs
List of completion queues.
Definition: infiniband.h:412
void ib_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: infiniband.c:161
void timeout(int)
int is_send
"Is a send queue" flag
Definition: infiniband.h:104

References ib_work_queue::cq, ib_device::cqs, ib_work_queue::fill, FLEX_NODNIC_TX_POLL_TOUT, FLEX_NODNIC_TX_POLL_USLEEP, ib_poll_cq(), ib_work_queue::is_send, ib_work_queue::list, list_for_each_entry, port, timeout(), udelay(), and ib_completion_queue::work_queues.

Referenced by flexboot_nodnic_port_disable_dma().

◆ flexboot_nodnic_port_disable_dma()

static void flexboot_nodnic_port_disable_dma ( struct flexboot_nodnic_port port)
static

Definition at line 724 of file flexboot_nodnic.c.

724  {
725  nodnic_port_priv *port_priv = & ( port->port_priv );
727 
728  if ( ! ( port_priv->port_state & NODNIC_PORT_OPENED ) )
729  return;
730 
733  if ( ( status = nodnic_port_disable_dma ( port_priv ) ) ) {
734  MLX_DEBUG_WARN ( port, "Failed to disable DMA %d\n", status );
735  }
736 
737  port_priv->port_state &= ~NODNIC_PORT_DISABLING_DMA;
738 }
#define NODNIC_PORT_DISABLING_DMA
#define MLX_DEBUG_WARN(...)
Definition: mlx_logging.h:30
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
mlx_status nodnic_port_disable_dma(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1295
#define NODNIC_PORT_OPENED
int mlx_status
static void flexboot_nodnic_complete_all_tx(struct flexboot_nodnic_port *port)

References flexboot_nodnic_complete_all_tx(), MLX_DEBUG_WARN, nodnic_port_disable_dma(), NODNIC_PORT_DISABLING_DMA, NODNIC_PORT_OPENED, port, _nodnic_port_priv::port_state, and status.

Referenced by flexboot_nodnic_eth_close().

◆ flexboot_nodnic_eth_transmit()

static int flexboot_nodnic_eth_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

Transmit packet via flexboot_nodnic Ethernet device.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 764 of file flexboot_nodnic.c.

765  {
767  struct ib_device *ibdev = port->ibdev;
768  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
769  int rc;
770 
771  rc = ib_post_send ( ibdev, port->eth_qp, NULL, iobuf);
772  /* Transmit packet */
773  if ( rc != 0) {
774  DBGC ( flexboot_nodnic, "NODNIC %p port %d could not transmit: %s\n",
775  flexboot_nodnic, ibdev->port, strerror ( rc ) );
776  return rc;
777  }
778 
779  return 0;
780 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
An Infiniband device.
Definition: infiniband.h:398
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int ib_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.
Definition: infiniband.c:416
A flexboot nodnic port.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, ib_get_drvdata(), ib_post_send(), netdev, NULL, port, ib_device::port, net_device::priv, rc, and strerror().

◆ flexboot_nodnic_eth_complete_send()

static void flexboot_nodnic_eth_complete_send ( struct ib_device *ibdev   __attribute__(unused),
struct ib_queue_pair qp,
struct io_buffer iobuf,
int  rc 
)
static

Handle flexboot_nodnic Ethernet device send completion.

Parameters
ibdevInfiniband device
qpQueue pair
iobufI/O buffer
rcCompletion status code

Definition at line 790 of file flexboot_nodnic.c.

793  {
794  struct net_device *netdev = ib_qp_get_ownerdata ( qp );
795 
796  netdev_tx_complete_err ( netdev, iobuf, rc );
797 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:663
A network device.
Definition: netdevice.h:348
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:395

References ib_qp_get_ownerdata(), netdev, netdev_tx_complete_err(), qp, and rc.

◆ flexboot_nodnic_eth_complete_recv()

static void flexboot_nodnic_eth_complete_recv ( struct ib_device *ibdev   __attribute__(unused),
struct ib_queue_pair qp,
struct ib_address_vector *dest   __attribute__(unused),
struct ib_address_vector source,
struct io_buffer iobuf,
int  rc 
)
static

Handle flexboot_nodnic Ethernet device receive completion.

Parameters
ibdevInfiniband device
qpQueue pair
avAddress vector, or NULL
iobufI/O buffer
rcCompletion status code

Definition at line 808 of file flexboot_nodnic.c.

813  {
814  struct net_device *netdev = ib_qp_get_ownerdata ( qp );
815 
816  if ( rc != 0 ) {
817  DBG ( "Received packet with error\n" );
818  netdev_rx_err ( netdev, iobuf, rc );
819  return;
820  }
821 
822  if ( source == NULL ) {
823  DBG ( "Received packet without address vector\n" );
824  netdev_rx_err ( netdev, iobuf, -ENOTTY );
825  return;
826  }
827 
828  netdev_rx ( netdev, iobuf );
829 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:663
A network device.
Definition: netdevice.h:348
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBG, ENOTTY, ib_qp_get_ownerdata(), netdev, netdev_rx(), netdev_rx_err(), NULL, qp, and rc.

◆ flexboot_nodnic_eth_poll()

static void flexboot_nodnic_eth_poll ( struct net_device netdev)
static

Poll flexboot_nodnic Ethernet device.

Parameters
netdevNetwork device

Definition at line 842 of file flexboot_nodnic.c.

842  {
844  struct ib_device *ibdev = port->ibdev;
845 
846  ib_poll_eq ( ibdev );
847 }
void ib_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: infiniband.c:898
An Infiniband device.
Definition: infiniband.h:398
u8 port
Port number.
Definition: CIB_PRM.h:31
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
A flexboot nodnic port.

References ib_poll_eq(), netdev, port, and net_device::priv.

◆ flexboot_nodnic_eth_open()

static int flexboot_nodnic_eth_open ( struct net_device netdev)
static

Open flexboot_nodnic Ethernet device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 855 of file flexboot_nodnic.c.

855  {
857  struct ib_device *ibdev = port->ibdev;
858  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
860  struct ib_completion_queue *dummy_cq = NULL;
861  struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp = NULL;
862  mlx_uint64 cq_size = 0;
863  mlx_uint32 qpn = 0;
865  int rc;
866 
867  if ( port->port_priv.port_state & NODNIC_PORT_OPENED ) {
868  DBGC ( flexboot_nodnic, "%s: port %d is already opened\n",
869  __FUNCTION__, port->ibdev->port );
870  return 0;
871  }
872 
873  port->port_priv.port_state |= NODNIC_PORT_OPENED;
874 
875  dummy_cq = zalloc ( sizeof ( struct ib_completion_queue ) );
876  if ( dummy_cq == NULL ) {
877  DBGC ( flexboot_nodnic, "%s: Failed to allocate dummy CQ\n", __FUNCTION__ );
879  goto err_create_dummy_cq;
880  }
881  INIT_LIST_HEAD ( &dummy_cq->work_queues );
882 
883  if ( ( rc = ib_create_qp ( ibdev, IB_QPT_ETH,
887  &port->eth_qp ) ) != 0 ) {
888  DBGC ( flexboot_nodnic, "flexboot_nodnic %p port %d could not create queue pair\n",
889  flexboot_nodnic, ibdev->port );
891  goto err_create_qp;
892  }
893 
894  ib_qp_set_ownerdata ( port->eth_qp, netdev );
895 
896  status = nodnic_port_get_cq_size(&port->port_priv, &cq_size);
897  MLX_FATAL_CHECK_STATUS(status, get_cq_size_err,
898  "nodnic_port_get_cq_size failed");
899 
900  if ( ( rc = ib_create_cq ( ibdev, cq_size, &flexboot_nodnic_eth_cq_op,
901  &port->eth_cq ) ) != 0 ) {
903  "flexboot_nodnic %p port %d could not create completion queue\n",
904  flexboot_nodnic, ibdev->port );
906  goto err_create_cq;
907  }
908  port->eth_qp->send.cq = port->eth_cq;
909  list_del(&port->eth_qp->send.list);
910  list_add ( &port->eth_qp->send.list, &port->eth_cq->work_queues );
911  port->eth_qp->recv.cq = port->eth_cq;
912  port->cmdsn = 0;
913  list_del(&port->eth_qp->recv.list);
914  list_add ( &port->eth_qp->recv.list, &port->eth_cq->work_queues );
915 
916  status = nodnic_port_allocate_eq(&port->port_priv,
918  MLX_FATAL_CHECK_STATUS(status, eq_alloc_err,
919  "nodnic_port_allocate_eq failed");
920 
921  status = nodnic_port_init(&port->port_priv);
922  MLX_FATAL_CHECK_STATUS(status, init_err,
923  "nodnic_port_init failed");
924 
925  /* update qp - qpn */
926  flexboot_nodnic_qp = ib_qp_get_drvdata ( port->eth_qp );
927  status = nodnic_port_get_qpn(&port->port_priv,
928  &flexboot_nodnic_qp->nodnic_queue_pair->send.nodnic_ring,
929  &qpn);
931  "nodnic_port_get_qpn failed");
932  port->eth_qp->qpn = qpn;
933 
934  /* Fill receive rings */
935  ib_refill_recv ( ibdev, port->eth_qp );
936 
937  status = nodnic_port_enable_dma(&port->port_priv);
939  "nodnic_port_enable_dma failed");
940 
942  status = nodnic_port_set_promisc(&port->port_priv, TRUE);
943  MLX_FATAL_CHECK_STATUS(status, promisc_err,
944  "nodnic_port_set_promisc failed");
945  }
946 
947  status = nodnic_port_get_state(&port->port_priv, &state);
948  MLX_FATAL_CHECK_STATUS(status, state_err,
949  "nodnic_port_get_state failed");
950 
951  port->type->state_change (
953 
954  DBGC ( flexboot_nodnic, "%s: port %d opened (link is %s)\n",
955  __FUNCTION__, port->ibdev->port,
956  ( ( state == nodnic_port_state_active ) ? "Up" : "Down" ) );
957 
958  free(dummy_cq);
959  return 0;
960 state_err:
961 promisc_err:
962 dma_err:
963 qpn_err:
964  nodnic_port_close(&port->port_priv);
965 init_err:
966  nodnic_port_free_eq(&port->port_priv);
967 eq_alloc_err:
968 err_create_cq:
969 get_cq_size_err:
970  ib_destroy_qp(ibdev, port->eth_qp );
971 err_create_qp:
972  free(dummy_cq);
973 err_create_dummy_cq:
974  port->port_priv.port_state &= ~NODNIC_PORT_OPENED;
975  return status;
976 }
struct nodnic_ring nodnic_ring
mlx_status nodnic_port_allocate_eq(IN nodnic_port_priv *port_priv, IN mlx_uint8 log_eq_size)
Definition: mlx_port.c:915
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
mlx_status nodnic_port_get_state(IN nodnic_port_priv *port_priv, OUT nodnic_port_state *state)
Definition: mlx_port.c:88
struct nodnic_send_ring send
mlx_status nodnic_port_close(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1255
uint8_t state
State.
Definition: eth_slow.h:47
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
nodnic_device_priv device_priv
nodnic device
int ib_create_cq(struct ib_device *ibdev, unsigned int num_cqes, struct ib_completion_queue_operations *op, struct ib_completion_queue **new_cq)
Create completion queue.
Definition: infiniband.c:98
void ib_refill_recv(struct ib_device *ibdev, struct ib_queue_pair *qp)
Refill receive work queue.
Definition: infiniband.c:556
#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 struct ib_queue_pair_operations flexboot_nodnic_eth_qp_op
flexboot nodnic Ethernet queue pair operations
mlx_status nodnic_port_free_eq(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:968
__be32 qpn
Definition: CIB_PRM.h:29
An Infiniband device.
Definition: infiniband.h:398
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
u8 port
Port number.
Definition: CIB_PRM.h:31
nodnic_port_state
Definition: mlx_port.h:69
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
mlx_status nodnic_port_enable_dma(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1275
#define FLEXBOOT_NODNIC_ETH_NUM_RECV_WQES
Number of flexboot_nodnic Ethernet receive work queue entries.
#define FLEXBOOT_NODNIC_ETH_NUM_SEND_WQES
Number of flexboot_nodnic Ethernet send work queue entries.
void * priv
Driver private data.
Definition: netdevice.h:425
nodnic_device_capabilites device_cap
mlx_status nodnic_port_init(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1235
static struct net_device * netdev
Definition: gdbudp.c:52
#define MLX_SUCCESS
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
mlx_status nodnic_port_get_cq_size(IN nodnic_port_priv *port_priv, OUT mlx_uint64 *cq_size)
Definition: mlx_port.c:899
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
An Infiniband Completion Queue.
Definition: infiniband.h:224
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
#define NODNIC_PORT_OPENED
static struct ib_completion_queue_operations flexboot_nodnic_eth_cq_op
flexboot_nodnic Ethernet device completion operations
#define TRUE
Definition: tlan.h:46
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define MLX_OUT_OF_RESOURCES
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
int ib_create_qp(struct ib_device *ibdev, enum ib_queue_pair_type type, unsigned int num_send_wqes, struct ib_completion_queue *send_cq, unsigned int num_recv_wqes, struct ib_completion_queue *recv_cq, struct ib_queue_pair_operations *op, const char *name, struct ib_queue_pair **new_qp)
Create queue pair.
Definition: infiniband.c:199
A flexboot nodnic port.
int mlx_status
mlx_status nodnic_port_get_qpn(IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, OUT mlx_uint32 *qpn)
Definition: mlx_port.c:796
mlx_status nodnic_port_set_promisc(IN nodnic_port_priv *port_priv, IN mlx_boolean value)
Definition: mlx_port.c:1205
uint64_t mlx_uint64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static __always_inline void ib_qp_set_ownerdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair owner-private data.
Definition: infiniband.h:652
A flexboot nodnic queue pair.

References DBGC, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, flexboot_nodnic_eth_cq_op, FLEXBOOT_NODNIC_ETH_NUM_RECV_WQES, FLEXBOOT_NODNIC_ETH_NUM_SEND_WQES, flexboot_nodnic_eth_qp_op, free, ib_create_cq(), ib_create_qp(), ib_destroy_qp(), ib_get_drvdata(), ib_qp_get_drvdata(), ib_qp_set_ownerdata(), IB_QPT_ETH, ib_refill_recv(), INIT_LIST_HEAD, list_add, list_del, _nodnic_device_capabilites::log_working_buffer_size, MLX_FATAL_CHECK_STATUS, MLX_OUT_OF_RESOURCES, MLX_SUCCESS, net_device::name, netdev, nodnic_port_allocate_eq(), nodnic_port_close(), nodnic_port_enable_dma(), nodnic_port_free_eq(), nodnic_port_get_cq_size(), nodnic_port_get_qpn(), nodnic_port_get_state(), nodnic_port_init(), NODNIC_PORT_OPENED, nodnic_port_set_promisc(), nodnic_port_state_active, nodnic_port_state_down, flexboot_nodnic_queue_pair::nodnic_queue_pair, nodnic_send_ring::nodnic_ring, NULL, port, ib_device::port, net_device::priv, qpn, rc, _nodnic_qp::send, state, status, _nodnic_device_capabilites::support_promisc_filter, TRUE, ib_completion_queue::work_queues, and zalloc().

◆ flexboot_nodnic_eth_close()

static void flexboot_nodnic_eth_close ( struct net_device netdev)
static

Close flexboot_nodnic Ethernet device.

Parameters
netdevNetwork device

Definition at line 983 of file flexboot_nodnic.c.

983  {
985  struct ib_device *ibdev = port->ibdev;
986  struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
988 
989  if ( ! ( port->port_priv.port_state & NODNIC_PORT_OPENED ) ) {
990  DBGC ( flexboot_nodnic, "%s: port %d is already closed\n",
991  __FUNCTION__, port->ibdev->port );
992  return;
993  }
994 
996  if ( ( status = nodnic_port_set_promisc( &port->port_priv, FALSE ) ) ) {
998  "nodnic_port_set_promisc failed (status = %d)\n", status );
999  }
1000  }
1001 
1003 
1004  port->port_priv.port_state &= ~NODNIC_PORT_OPENED;
1005 
1006  port->type->state_change ( flexboot_nodnic, port, FALSE );
1007 
1008  /* Close port */
1009  status = nodnic_port_close(&port->port_priv);
1010  if ( status != MLX_SUCCESS ) {
1011  DBGC ( flexboot_nodnic, "flexboot_nodnic %p port %d could not close port: %s\n",
1012  flexboot_nodnic, ibdev->port, strerror ( status ) );
1013  /* Nothing we can do about this */
1014  }
1015 
1016  ib_destroy_qp ( ibdev, port->eth_qp );
1017  port->eth_qp = NULL;
1018  ib_destroy_cq ( ibdev, port->eth_cq );
1019  port->eth_cq = NULL;
1020 
1021  nodnic_port_free_eq(&port->port_priv);
1022 
1023  DBGC ( flexboot_nodnic, "%s: port %d closed\n", __FUNCTION__, port->ibdev->port );
1024 }
mlx_status nodnic_port_close(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1255
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
mlx_status nodnic_port_free_eq(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:968
void ib_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: infiniband.c:145
An Infiniband device.
Definition: infiniband.h:398
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
void * priv
Driver private data.
Definition: netdevice.h:425
nodnic_device_capabilites device_cap
static struct net_device * netdev
Definition: gdbudp.c:52
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
#define NODNIC_PORT_OPENED
A flexboot nodnic port.
#define FALSE
Definition: tlan.h:45
int mlx_status
mlx_status nodnic_port_set_promisc(IN nodnic_port_priv *port_priv, IN mlx_boolean value)
Definition: mlx_port.c:1205
static void flexboot_nodnic_port_disable_dma(struct flexboot_nodnic_port *port)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, FALSE, flexboot_nodnic_port_disable_dma(), ib_destroy_cq(), ib_destroy_qp(), ib_get_drvdata(), MLX_SUCCESS, netdev, nodnic_port_close(), nodnic_port_free_eq(), NODNIC_PORT_OPENED, nodnic_port_set_promisc(), NULL, port, ib_device::port, net_device::priv, status, strerror(), and _nodnic_device_capabilites::support_promisc_filter.

◆ flexboot_nodnic_eth_irq()

void flexboot_nodnic_eth_irq ( struct net_device netdev,
int  enable 
)

Definition at line 1026 of file flexboot_nodnic.c.

1026  {
1027  struct flexboot_nodnic_port *port = netdev->priv;
1028 
1029  if ( enable ) {
1030  if ( ( port->port_priv.port_state & NODNIC_PORT_OPENED ) &&
1031  ! ( port->port_priv.port_state & NODNIC_PORT_DISABLING_DMA ) ) {
1033  } else {
1034  /* do nothing */
1035  }
1036  } else {
1037  nodnic_device_clear_int( port->port_priv.device );
1038  }
1039 }
#define NODNIC_PORT_DISABLING_DMA
mlx_status nodnic_device_clear_int(IN nodnic_device_priv *device_priv)
Definition: mlx_device.c:165
u8 port
Port number.
Definition: CIB_PRM.h:31
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define NODNIC_PORT_OPENED
static int flexboot_nodnic_arm_cq(struct flexboot_nodnic_port *port)
A flexboot nodnic port.

References flexboot_nodnic_arm_cq(), netdev, nodnic_device_clear_int(), NODNIC_PORT_DISABLING_DMA, NODNIC_PORT_OPENED, port, and net_device::priv.

◆ flexboot_nodnic_register_netdev()

static int flexboot_nodnic_register_netdev ( struct flexboot_nodnic flexboot_nodnic,
struct flexboot_nodnic_port port 
)
static

Register flexboot_nodnic Ethernet device.

Definition at line 1052 of file flexboot_nodnic.c.

1053  {
1055  struct net_device *netdev;
1056  struct ib_device *ibdev = port->ibdev;
1057  union {
1058  uint8_t bytes[8];
1059  uint32_t dwords[2];
1060  } mac;
1061 
1062  /* Allocate network devices */
1063  netdev = alloc_etherdev ( 0 );
1064  if ( netdev == NULL ) {
1065  DBGC ( flexboot_nodnic, "flexboot_nodnic %p port %d could not allocate net device\n",
1066  flexboot_nodnic, ibdev->port );
1068  goto alloc_err;
1069  }
1070  port->netdev = netdev;
1072  netdev->dev = ibdev->dev;
1073  netdev->priv = port;
1074 
1075  status = nodnic_port_query(&port->port_priv,
1077  &mac.dwords[0]);
1078  MLX_FATAL_CHECK_STATUS(status, mac_err,
1079  "failed to query mac high");
1080  status = nodnic_port_query(&port->port_priv,
1082  &mac.dwords[1]);
1083  MLX_FATAL_CHECK_STATUS(status, mac_err,
1084  "failed to query mac low");
1085  mac.dwords[0] = htonl(mac.dwords[0]);
1086  mac.dwords[1] = htonl(mac.dwords[1]);
1087  memcpy ( netdev->hw_addr,
1088  &mac.bytes[2], ETH_ALEN);
1089  /* Register network device */
1091  if ( status != MLX_SUCCESS ) {
1093  "flexboot_nodnic %p port %d could not register network device: %s\n",
1094  flexboot_nodnic, ibdev->port, strerror ( status ) );
1095  goto reg_err;
1096  }
1097  return status;
1098 reg_err:
1099 mac_err:
1100  netdev_put ( netdev );
1101 alloc_err:
1102  return status;
1103 }
#define DBGC(...)
Definition: compiler.h:505
struct device * dev
Underlying device.
Definition: infiniband.h:410
static struct net_device_operations flexboot_nodnic_eth_operations
flexboot_nodnic Ethernet network device operations
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define htonl(value)
Definition: byteswap.h:133
An Infiniband device.
Definition: infiniband.h:398
uint8_t status
Status.
Definition: ena.h:16
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define MLX_SUCCESS
A flexboot_nodnic device.
unsigned int port
Port number.
Definition: infiniband.h:418
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
mlx_status nodnic_port_query(IN nodnic_port_priv *port_priv, IN nodnic_port_option option, OUT mlx_uint32 *out)
Definition: mlx_port.c:126
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
unsigned char uint8_t
Definition: stdint.h:10
#define ETH_ALEN
Definition: if_ether.h:8
unsigned int uint32_t
Definition: stdint.h:12
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define MLX_OUT_OF_RESOURCES
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
int mlx_status
uint8_t bytes[64]
Definition: ib_mad.h:16
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References alloc_etherdev(), bytes, DBGC, net_device::dev, ib_device::dev, ETH_ALEN, flexboot_nodnic_eth_operations, htonl, net_device::hw_addr, mac, memcpy(), MLX_FATAL_CHECK_STATUS, MLX_OUT_OF_RESOURCES, MLX_SUCCESS, netdev, netdev_init(), netdev_put(), nodnic_port_option_mac_high, nodnic_port_option_mac_low, nodnic_port_query(), NULL, port, ib_device::port, net_device::priv, register_netdev(), status, and strerror().

◆ flexboot_nodnic_state_change_netdev()

static void flexboot_nodnic_state_change_netdev ( struct flexboot_nodnic *flexboot_nodnic   __attribute__(unused),
struct flexboot_nodnic_port port,
int  link_up 
)
static

Handle flexboot_nodnic Ethernet device port state change.

Definition at line 1108 of file flexboot_nodnic.c.

1110  {
1111  struct net_device *netdev = port->netdev;
1112 
1113  if ( link_up )
1114  netdev_link_up ( netdev );
1115  else
1117 
1118 }
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
u8 port
Port number.
Definition: CIB_PRM.h:31
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:348

References netdev, netdev_link_down(), netdev_link_up(), and port.

◆ flexboot_nodnic_unregister_netdev()

static void flexboot_nodnic_unregister_netdev ( struct flexboot_nodnic *flexboot_nodnic   __attribute__(unused),
struct flexboot_nodnic_port port 
)
static

Unregister flexboot_nodnic Ethernet device.

Definition at line 1123 of file flexboot_nodnic.c.

1124  {
1125  struct net_device *netdev = port->netdev;
1127  netdev_nullify ( netdev );
1128  netdev_put ( netdev );
1129 }
u8 port
Port number.
Definition: CIB_PRM.h:31
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511

References netdev, netdev_nullify(), netdev_put(), port, and unregister_netdev().

◆ flexboot_nodnic_allocate_infiniband_devices()

static mlx_status flexboot_nodnic_allocate_infiniband_devices ( struct flexboot_nodnic flexboot_nodnic_priv)
static

Definition at line 1146 of file flexboot_nodnic.c.

1146  {
1148  nodnic_device_priv *device_priv = &flexboot_nodnic_priv->device_priv;
1149  struct pci_device *pci = flexboot_nodnic_priv->pci;
1150  struct ib_device *ibdev = NULL;
1151  unsigned int i = 0;
1152 
1153  /* Allocate Infiniband devices */
1154  for (; i < device_priv->device_cap.num_ports; i++) {
1155  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1156  continue;
1157  ibdev = alloc_ibdev(0);
1158  if (ibdev == NULL) {
1160  goto err_alloc_ibdev;
1161  }
1162  flexboot_nodnic_priv->port[i].ibdev = ibdev;
1164  ibdev->dev = &pci->dev;
1165  ibdev->port = ( FLEXBOOT_NODNIC_PORT_BASE + i);
1166  ib_set_drvdata(ibdev, flexboot_nodnic_priv);
1167  }
1168  return status;
1169 err_alloc_ibdev:
1170  for ( i-- ; ( signed int ) i >= 0 ; i-- )
1171  ibdev_put ( flexboot_nodnic_priv->port[i].ibdev );
1172  return status;
1173 }
static __always_inline void ib_set_drvdata(struct ib_device *ibdev, void *priv)
Set Infiniband device driver-private data.
Definition: infiniband.h:696
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
struct device * dev
Underlying device.
Definition: infiniband.h:410
struct pci_device * pci
PCI device.
u16 port_mask
Port masking.
struct device dev
Generic device.
Definition: pci.h:189
An Infiniband device.
Definition: infiniband.h:398
uint8_t status
Status.
Definition: ena.h:16
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
nodnic_device_capabilites device_cap
#define MLX_SUCCESS
unsigned int port
Port number.
Definition: infiniband.h:418
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:597
A PCI device.
Definition: pci.h:187
struct ib_device * alloc_ibdev(size_t priv_size)
Allocate Infiniband device.
Definition: infiniband.c:937
#define FLEXBOOT_NODNIC_PORT_BASE
#define MLX_OUT_OF_RESOURCES
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
int mlx_status
static struct ib_device_operations flexboot_nodnic_ib_operations
flexboot_nodnic Infiniband operations
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References alloc_ibdev(), pci_device::dev, ib_device::dev, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, flexboot_nodnic_ib_operations, FLEXBOOT_NODNIC_PORT_BASE, ib_set_drvdata(), flexboot_nodnic_port::ibdev, ibdev_put(), MLX_OUT_OF_RESOURCES, MLX_SUCCESS, NULL, _nodnic_device_capabilites::num_ports, ib_device::op, flexboot_nodnic::pci, flexboot_nodnic::port, ib_device::port, flexboot_nodnic::port_mask, and status.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_thin_init_ports()

static mlx_status flexboot_nodnic_thin_init_ports ( struct flexboot_nodnic flexboot_nodnic_priv)
static

Definition at line 1177 of file flexboot_nodnic.c.

1177  {
1179  nodnic_device_priv *device_priv = &flexboot_nodnic_priv->device_priv;
1180  nodnic_port_priv *port_priv = NULL;
1181  unsigned int i = 0;
1182 
1183  for ( i = 0; i < device_priv->device_cap.num_ports; i++ ) {
1184  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1185  continue;
1186  port_priv = &flexboot_nodnic_priv->port[i].port_priv;
1187  status = nodnic_port_thin_init( device_priv, port_priv, i );
1188  MLX_FATAL_CHECK_STATUS(status, thin_init_err,
1189  "flexboot_nodnic_thin_init_ports failed");
1190  }
1191 thin_init_err:
1192  return status;
1193 }
nodnic_device_priv device_priv
nodnic device
u16 port_mask
Port masking.
uint8_t status
Status.
Definition: ena.h:16
nodnic_device_capabilites device_cap
mlx_status nodnic_port_thin_init(IN nodnic_device_priv *device_priv, IN nodnic_port_priv *port_priv, IN mlx_uint8 port_index)
Definition: mlx_port.c:1315
#define MLX_SUCCESS
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
nodnic_port_priv port_priv
nodic port
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
int mlx_status
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, MLX_FATAL_CHECK_STATUS, MLX_SUCCESS, nodnic_port_thin_init(), NULL, _nodnic_device_capabilites::num_ports, flexboot_nodnic::port, flexboot_nodnic::port_mask, flexboot_nodnic_port::port_priv, and status.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_set_ports_type()

static mlx_status flexboot_nodnic_set_ports_type ( struct flexboot_nodnic flexboot_nodnic_priv)
static

Definition at line 1198 of file flexboot_nodnic.c.

1198  {
1200  nodnic_device_priv *device_priv = &flexboot_nodnic_priv->device_priv;
1201  nodnic_port_priv *port_priv = NULL;
1203  unsigned int i = 0;
1204 
1205  for ( i = 0 ; i < device_priv->device_cap.num_ports ; i++ ) {
1206  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1207  continue;
1208  port_priv = &flexboot_nodnic_priv->port[i].port_priv;
1209  status = nodnic_port_get_type(port_priv, &type);
1210  MLX_FATAL_CHECK_STATUS(status, type_err,
1211  "nodnic_port_get_type failed");
1212  switch ( type ) {
1213  case NODNIC_PORT_TYPE_ETH:
1214  DBGC ( flexboot_nodnic_priv, "Port %d type is Ethernet\n", i );
1215  flexboot_nodnic_priv->port[i].type = &flexboot_nodnic_port_type_eth;
1216  break;
1217  case NODNIC_PORT_TYPE_IB:
1218  DBGC ( flexboot_nodnic_priv, "Port %d type is Infiniband\n", i );
1220  goto type_err;
1221  default:
1222  DBGC ( flexboot_nodnic_priv, "Port %d type is unknown\n", i );
1224  goto type_err;
1225  }
1226  }
1227 type_err:
1228  return status;
1229 }
uint8_t type
Type.
Definition: ena.h:16
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
u16 port_mask
Port masking.
uint8_t status
Status.
Definition: ena.h:16
nodnic_device_capabilites device_cap
mlx_status nodnic_port_get_type(IN nodnic_port_priv *port_priv, OUT nodnic_port_type *type)
Definition: mlx_port.c:105
#define MLX_SUCCESS
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
#define MLX_UNSUPPORTED
nodnic_port_priv port_priv
nodic port
static struct flexboot_nodnic_port_type flexboot_nodnic_port_type_eth
flexboot_nodnic Ethernet port type
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
int mlx_status
struct flexboot_nodnic_port_type * type
Port type.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, flexboot_nodnic_port_type_eth, MLX_FATAL_CHECK_STATUS, MLX_SUCCESS, MLX_UNSUPPORTED, nodnic_port_get_type(), NODNIC_PORT_TYPE_ETH, NODNIC_PORT_TYPE_IB, NODNIC_PORT_TYPE_UNKNOWN, NULL, _nodnic_device_capabilites::num_ports, flexboot_nodnic::port, flexboot_nodnic::port_mask, flexboot_nodnic_port::port_priv, status, type, and flexboot_nodnic_port::type.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_ports_register_dev()

static mlx_status flexboot_nodnic_ports_register_dev ( struct flexboot_nodnic flexboot_nodnic_priv)
static

Definition at line 1233 of file flexboot_nodnic.c.

1233  {
1235  nodnic_device_priv *device_priv = &flexboot_nodnic_priv->device_priv;
1236  struct flexboot_nodnic_port *port = NULL;
1237  unsigned int i = 0;
1238 
1239  for (; i < device_priv->device_cap.num_ports; i++) {
1240  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1241  continue;
1242  port = &flexboot_nodnic_priv->port[i];
1243  status = port->type->register_dev ( flexboot_nodnic_priv, port );
1244  MLX_FATAL_CHECK_STATUS(status, reg_err,
1245  "port register_dev failed");
1246  }
1247 reg_err:
1248  return status;
1249 }
nodnic_device_priv device_priv
nodnic device
u16 port_mask
Port masking.
uint8_t status
Status.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
nodnic_device_capabilites device_cap
#define MLX_SUCCESS
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.
int mlx_status
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, MLX_FATAL_CHECK_STATUS, MLX_SUCCESS, NULL, _nodnic_device_capabilites::num_ports, port, flexboot_nodnic::port, flexboot_nodnic::port_mask, and status.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_ports_unregister_dev()

static mlx_status flexboot_nodnic_ports_unregister_dev ( struct flexboot_nodnic flexboot_nodnic_priv)
static

Definition at line 1253 of file flexboot_nodnic.c.

1253  {
1254  struct flexboot_nodnic_port *port;
1255  nodnic_device_priv *device_priv = &flexboot_nodnic_priv->device_priv;
1256  int i = (device_priv->device_cap.num_ports - 1);
1257 
1258  for (; i >= 0; i--) {
1259  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1260  continue;
1261  port = &flexboot_nodnic_priv->port[i];
1262  port->type->unregister_dev(flexboot_nodnic_priv, port);
1263  ibdev_put(flexboot_nodnic_priv->port[i].ibdev);
1264  }
1265  return MLX_SUCCESS;
1266 }
struct ib_device * ibdev
Infiniband device.
nodnic_device_priv device_priv
nodnic device
u16 port_mask
Port masking.
u8 port
Port number.
Definition: CIB_PRM.h:31
nodnic_device_capabilites device_cap
#define MLX_SUCCESS
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:597
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
A flexboot nodnic port.

References _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, flexboot_nodnic_port::ibdev, ibdev_put(), MLX_SUCCESS, _nodnic_device_capabilites::num_ports, port, flexboot_nodnic::port, and flexboot_nodnic::port_mask.

Referenced by flexboot_nodnic_probe(), and flexboot_nodnic_remove().

◆ __attribute__()

Definition at line 1274 of file flexboot_nodnic.c.

1274  {
1277  int i;
1278 
1279  for ( i = 0; i < nodnic->device_priv.device_cap.num_ports; i++ ) {
1280  if ( ! ( nodnic->port_mask & ( i + 1 ) ) )
1281  continue;
1282  port_priv = & ( nodnic->port[i].port_priv );
1283  if ( ! ( port_priv->port_state & NODNIC_PORT_OPENED ) )
1284  continue;
1285 
1286  if ( ( status = nodnic_port_enable_dma ( port_priv ) ) ) {
1287  MLX_DEBUG_WARN ( nodnic, "Failed to enable DMA %d\n", status );
1288  }
1289  }
1290 }
#define MLX_DEBUG_WARN(...)
Definition: mlx_logging.h:30
uint8_t status
Status.
Definition: ena.h:16
mlx_status nodnic_port_enable_dma(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:1275
#define NODNIC_PORT_OPENED
nodnic_port_priv port_priv
nodic port
int mlx_status

References _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, MLX_DEBUG_WARN, nodnic_port_enable_dma(), NODNIC_PORT_OPENED, _nodnic_device_capabilites::num_ports, flexboot_nodnic::port, flexboot_nodnic::port_mask, flexboot_nodnic_port::port_priv, _nodnic_port_priv::port_state, and status.

◆ flexboot_nodnic_is_supported()

int flexboot_nodnic_is_supported ( struct pci_device pci)

Definition at line 1302 of file flexboot_nodnic.c.

1302  {
1303  mlx_utils utils;
1306  int is_supported = 0;
1307 
1308  DBG ( "%s: start\n", __FUNCTION__ );
1309 
1310  memset ( &utils, 0, sizeof ( utils ) );
1311 
1312  status = mlx_utils_init ( &utils, pci );
1313  MLX_CHECK_STATUS ( pci, status, utils_init_err, "mlx_utils_init failed" );
1314 
1315  status = mlx_pci_gw_init ( &utils );
1316  MLX_CHECK_STATUS ( pci, status, pci_gw_init_err, "mlx_pci_gw_init failed" );
1317 
1320 
1321  if ( status == MLX_SUCCESS ) {
1323  is_supported = ( buffer & 0x1 );
1324  }
1325 
1326  mlx_pci_gw_teardown( &utils );
1327 
1328 pci_gw_init_err:
1329  mlx_utils_teardown(&utils);
1330 utils_init_err:
1331  DBG ( "%s: NODNIC is %s supported (status = %d)\n",
1332  __FUNCTION__, ( is_supported ? "": "not" ), status );
1333  return is_supported;
1334 }
#define NODNIC_NIC_INTERFACE_SUPPORTED_BIT
Definition: mlx_device.h:41
mlx_status mlx_pci_gw_read(IN mlx_utils *utils, IN mlx_pci_gw_space space, IN mlx_uint32 address, OUT mlx_pci_gw_buffer *buffer)
Definition: mlx_pci_gw.c:258
#define NODNIC_NIC_INTERFACE_SUPPORTED_OFFSET
Definition: mlx_device.h:33
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
mlx_status mlx_pci_gw_init(IN mlx_utils *utils)
Definition: mlx_pci_gw.c:218
uint8_t status
Status.
Definition: ena.h:16
#define MLX_SUCCESS
mlx_status mlx_utils_init(IN mlx_utils *utils, IN mlx_pci *pci)
Definition: mlx_utils.c:28
mlx_status mlx_utils_teardown(IN mlx_utils *utils)
Definition: mlx_utils.c:46
int mlx_status
mlx_status mlx_pci_gw_teardown(IN mlx_utils *utils)
Definition: mlx_pci_gw.c:247
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
mlx_uint32 mlx_pci_gw_buffer
Definition: mlx_pci_gw.h:52
void * memset(void *dest, int character, size_t len) __nonnull
#define PCI_GW_SPACE_NODNIC
Definition: mlx_pci_gw.h:47

References buffer, DBG, memset(), MLX_CHECK_STATUS, mlx_pci_gw_init(), mlx_pci_gw_read(), mlx_pci_gw_teardown(), MLX_SUCCESS, mlx_utils_init(), mlx_utils_teardown(), NODNIC_NIC_INTERFACE_SUPPORTED_BIT, NODNIC_NIC_INTERFACE_SUPPORTED_OFFSET, PCI_GW_SPACE_NODNIC, and status.

Referenced by shomron_nodnic_is_supported().

◆ flexboot_nodnic_copy_mac()

void flexboot_nodnic_copy_mac ( uint8_t  mac_addr[],
uint32_t  low_byte,
uint16_t  high_byte 
)

Definition at line 1337 of file flexboot_nodnic.c.

1338  {
1339  union mac_addr {
1340  struct {
1341  uint32_t low_byte;
1342  uint16_t high_byte;
1343  };
1344  uint8_t mac_addr[ETH_ALEN];
1345  } mac_addr_aux;
1346 
1347  mac_addr_aux.high_byte = high_byte;
1348  mac_addr_aux.low_byte = low_byte;
1349 
1350  mac_addr[0] = mac_addr_aux.mac_addr[5];
1351  mac_addr[1] = mac_addr_aux.mac_addr[4];
1352  mac_addr[2] = mac_addr_aux.mac_addr[3];
1353  mac_addr[3] = mac_addr_aux.mac_addr[2];
1354  mac_addr[4] = mac_addr_aux.mac_addr[1];
1355  mac_addr[5] = mac_addr_aux.mac_addr[0];
1356 }
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:10
#define ETH_ALEN
Definition: if_ether.h:8
unsigned int uint32_t
Definition: stdint.h:12

References ETH_ALEN.

◆ flexboot_nodnic_get_factory_mac()

static mlx_status flexboot_nodnic_get_factory_mac ( struct flexboot_nodnic flexboot_nodnic_priv,
uint8_t port   __attribute__(unused) 
)
static

Definition at line 1358 of file flexboot_nodnic.c.

1359  {
1360  struct mlx_vmac_query_virt_mac virt_mac;
1362 
1363  memset ( & virt_mac, 0, sizeof ( virt_mac ) );
1364  status = mlx_vmac_query_virt_mac ( flexboot_nodnic_priv->device_priv.utils,
1365  &virt_mac );
1366  if ( ! status ) {
1367  DBGC ( flexboot_nodnic_priv, "NODNIC %p Failed to set the virtual MAC\n"
1368  ,flexboot_nodnic_priv );
1369  }
1370 
1371  return status;
1372 }
mlx_status mlx_vmac_query_virt_mac(IN mlx_utils *utils, OUT struct mlx_vmac_query_virt_mac *virt_mac)
Definition: mlx_vmac.c:27
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
uint8_t status
Status.
Definition: ena.h:16
int mlx_status
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, flexboot_nodnic::device_priv, memset(), mlx_vmac_query_virt_mac(), status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_set_port_masking()

static int flexboot_nodnic_set_port_masking ( struct flexboot_nodnic flexboot_nodnic)
static

Set port masking.

Parameters
flexboot_nodnicnodnic device
Return values
rcReturn status code

Definition at line 1381 of file flexboot_nodnic.c.

1381  {
1382  unsigned int i;
1384 
1386  for ( i = 0; i < device_priv->device_cap.num_ports; i++ ) {
1387  flexboot_nodnic->port_mask |= (i + 1);
1388  }
1389 
1390  if ( ! flexboot_nodnic->port_mask ) {
1391  /* No port was enabled */
1392  DBGC ( flexboot_nodnic, "NODNIC %p No port was enabled for "
1393  "booting\n", flexboot_nodnic );
1394  return -ENETUNREACH;
1395  }
1396 
1397  return 0;
1398 }
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
u16 port_mask
Port masking.
nodnic_device_capabilites device_cap
A flexboot_nodnic device.
#define ENETUNREACH
Network unreachable.
Definition: errno.h:488

References DBGC, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, ENETUNREACH, _nodnic_device_capabilites::num_ports, and flexboot_nodnic::port_mask.

Referenced by flexboot_nodnic_probe().

◆ init_mlx_utils()

int init_mlx_utils ( mlx_utils **  utils,
struct pci_device pci 
)

Definition at line 1400 of file flexboot_nodnic.c.

1400  {
1401  int rc = 0;
1402 
1403  *utils = ( mlx_utils * ) zalloc ( sizeof ( mlx_utils ) );
1404  if ( *utils == NULL ) {
1405  DBGC ( utils, "%s: Failed to allocate utils\n", __FUNCTION__ );
1406  rc = -1;
1407  goto err_utils_alloc;
1408  }
1409  if ( mlx_utils_init ( *utils, pci ) ) {
1410  DBGC ( utils, "%s: mlx_utils_init failed\n", __FUNCTION__ );
1411  rc = -1;
1412  goto err_utils_init;
1413  }
1414  if ( mlx_pci_gw_init ( *utils ) ){
1415  DBGC ( utils, "%s: mlx_pci_gw_init failed\n", __FUNCTION__ );
1416  rc = -1;
1417  goto err_cmd_init;
1418  }
1419 
1420  return 0;
1421 
1422  mlx_pci_gw_teardown ( *utils );
1423 err_cmd_init:
1424  mlx_utils_teardown ( *utils );
1425 err_utils_init:
1426  free ( *utils );
1427 err_utils_alloc:
1428  *utils = NULL;
1429 
1430  return rc;
1431 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
mlx_status mlx_pci_gw_init(IN mlx_utils *utils)
Definition: mlx_pci_gw.c:218
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
mlx_status mlx_utils_init(IN mlx_utils *utils, IN mlx_pci *pci)
Definition: mlx_utils.c:28
mlx_status mlx_utils_teardown(IN mlx_utils *utils)
Definition: mlx_utils.c:46
mlx_status mlx_pci_gw_teardown(IN mlx_utils *utils)
Definition: mlx_pci_gw.c:247
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, free, mlx_pci_gw_init(), mlx_pci_gw_teardown(), mlx_utils_init(), mlx_utils_teardown(), NULL, rc, and zalloc().

Referenced by flexboot_nodnic_probe(), golan_probe_normal(), and golan_set_link_speed().

◆ free_mlx_utils()

void free_mlx_utils ( mlx_utils **  utils)

Definition at line 1433 of file flexboot_nodnic.c.

1433  {
1434 
1435  mlx_pci_gw_teardown ( *utils );
1436  mlx_utils_teardown ( *utils );
1437  free ( *utils );
1438  *utils = NULL;
1439 }
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
mlx_status mlx_utils_teardown(IN mlx_utils *utils)
Definition: mlx_utils.c:46
mlx_status mlx_pci_gw_teardown(IN mlx_utils *utils)
Definition: mlx_pci_gw.c:247
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References free, mlx_pci_gw_teardown(), mlx_utils_teardown(), and NULL.

Referenced by flexboot_nodnic_probe(), flexboot_nodnic_remove(), golan_probe_normal(), golan_remove_normal(), and golan_set_link_speed().

◆ flexboot_nodnic_alloc_uar()

static int flexboot_nodnic_alloc_uar ( struct flexboot_nodnic flexboot_nodnic)
static

Initialise Nodnic PCI parameters.

Parameters
hermonNodnic device

Definition at line 1446 of file flexboot_nodnic.c.

1446  {
1448  struct pci_device *pci = flexboot_nodnic->pci;
1450 
1452  DBGC ( flexboot_nodnic, "%s: tx db using uar is not supported \n", __FUNCTION__ );
1453  return -ENOTSUP;
1454  }
1455  /* read uar offset then allocate */
1457  DBGC ( flexboot_nodnic, "%s: nodnic_port_set_send_uar_offset failed,"
1458  "status = %d\n", __FUNCTION__, status );
1459  return -EINVAL;
1460  }
1461  uar->phys = ( pci_bar_start ( pci, FLEXBOOT_NODNIC_HCA_BAR ) + (mlx_uint32)uar->offset );
1462  uar->virt = ( void * )( ioremap ( uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) );
1463 
1464  return status;
1465 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define FLEXBOOT_NODNIC_HCA_BAR
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
nodnic_device_priv * device
struct pci_device * pci
PCI device.
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
nodnic_device_capabilites device_cap
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
#define MLX_SUCCESS
A flexboot_nodnic device.
A PCI device.
Definition: pci.h:187
nodnic_port_priv port_priv
nodic port
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
#define FLEXBOOT_NODNIC_PAGE_SIZE
int mlx_status
mlx_status nodnic_port_set_send_uar_offset(IN nodnic_port_priv *port_priv)
Definition: mlx_port.c:197
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.

References DBGC, _nodnic_port_priv::device, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, EINVAL, ENOTSUP, FLEXBOOT_NODNIC_HCA_BAR, FLEXBOOT_NODNIC_PAGE_SIZE, ioremap(), MLX_SUCCESS, nodnic_port_set_send_uar_offset(), _nodnic_uar_priv::offset, flexboot_nodnic::pci, pci_bar_start(), _nodnic_uar_priv::phys, flexboot_nodnic::port, flexboot_nodnic_port::port_priv, status, _nodnic_device_capabilites::support_uar_tx_db, _nodnic_device_priv::uar, and _nodnic_uar_priv::virt.

Referenced by flexboot_nodnic_probe().

◆ flexboot_nodnic_dealloc_uar()

static int flexboot_nodnic_dealloc_uar ( struct flexboot_nodnic flexboot_nodnic)
static

Definition at line 1467 of file flexboot_nodnic.c.

1467  {
1469 
1470  if ( uar->virt ) {
1471  iounmap( uar->virt );
1472  uar->virt = NULL;
1473  }
1474 
1475  return MLX_SUCCESS;
1476 }
nodnic_device_priv * device
#define MLX_SUCCESS
A flexboot_nodnic device.
nodnic_port_priv port_priv
nodic port
struct flexboot_nodnic_port port[FLEXBOOT_NODNIC_MAX_PORTS]
flexboot_nodnic ports
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References _nodnic_port_priv::device, iounmap(), MLX_SUCCESS, NULL, flexboot_nodnic::port, flexboot_nodnic_port::port_priv, _nodnic_device_priv::uar, and _nodnic_uar_priv::virt.

Referenced by flexboot_nodnic_probe(), and flexboot_nodnic_remove().

◆ flexboot_nodnic_probe()

int flexboot_nodnic_probe ( struct pci_device pci,
struct flexboot_nodnic_callbacks callbacks,
void *drv_priv   __attribute__(unused) 
)

Definition at line 1479 of file flexboot_nodnic.c.

1481  {
1483  struct flexboot_nodnic *flexboot_nodnic_priv = NULL;
1485  int i = 0;
1486 
1487  if ( ( pci == NULL ) || ( callbacks == NULL ) ) {
1488  DBGC ( flexboot_nodnic_priv, "%s: Bad Parameter\n", __FUNCTION__ );
1489  return -EINVAL;
1490  }
1491 
1492  flexboot_nodnic_priv = zalloc( sizeof ( *flexboot_nodnic_priv ) );
1493  if ( flexboot_nodnic_priv == NULL ) {
1494  DBGC ( flexboot_nodnic_priv, "%s: Failed to allocate priv data\n", __FUNCTION__ );
1496  goto device_err_alloc;
1497  }
1498 
1499  /* Register settings
1500  * Note that pci->priv will be the device private data */
1501  flexboot_nodnic_priv->pci = pci;
1502  flexboot_nodnic_priv->callbacks = callbacks;
1503  pci_set_drvdata ( pci, flexboot_nodnic_priv );
1504 
1505  device_priv = &flexboot_nodnic_priv->device_priv;
1506  /* init mlx utils */
1508  MLX_FATAL_CHECK_STATUS(status, err_utils_init,
1509  "init_mlx_utils failed");
1510 
1511  /* init device */
1513  MLX_FATAL_CHECK_STATUS(status, device_init_err,
1514  "nodnic_device_init failed");
1515 
1517  MLX_FATAL_CHECK_STATUS(status, get_cap_err,
1518  "nodnic_device_get_cap failed");
1519 
1521  MLX_DEBUG_ERROR( device_priv->utils, "Failed to set admin mtu\n" );
1522  }
1523 
1524  status = flexboot_nodnic_set_port_masking ( flexboot_nodnic_priv );
1525  MLX_FATAL_CHECK_STATUS(status, err_set_masking,
1526  "flexboot_nodnic_set_port_masking failed");
1527 
1528  status = flexboot_nodnic_allocate_infiniband_devices( flexboot_nodnic_priv );
1529  MLX_FATAL_CHECK_STATUS(status, err_alloc_ibdev,
1530  "flexboot_nodnic_allocate_infiniband_devices failed");
1531 
1532  /* port init */
1533  status = flexboot_nodnic_thin_init_ports( flexboot_nodnic_priv );
1534  MLX_FATAL_CHECK_STATUS(status, err_thin_init_ports,
1535  "flexboot_nodnic_thin_init_ports failed");
1536 
1537  if ( ( status = flexboot_nodnic_alloc_uar ( flexboot_nodnic_priv ) ) ) {
1538  DBGC(flexboot_nodnic_priv, "%s: flexboot_nodnic_alloc_uar failed"
1539  " ( status = %d )\n",__FUNCTION__, status );
1540  }
1541 
1542  /* device reg */
1543  status = flexboot_nodnic_set_ports_type( flexboot_nodnic_priv );
1544  MLX_CHECK_STATUS( flexboot_nodnic_priv, status, err_set_ports_types,
1545  "flexboot_nodnic_set_ports_type failed");
1546 
1547  status = flexboot_nodnic_ports_register_dev( flexboot_nodnic_priv );
1548  MLX_FATAL_CHECK_STATUS(status, reg_err,
1549  "flexboot_nodnic_ports_register_dev failed");
1550 
1551  for ( i = 0; i < device_priv->device_cap.num_ports; i++ ) {
1552  if ( ! ( flexboot_nodnic_priv->port_mask & ( i + 1 ) ) )
1553  continue;
1554  flexboot_nodnic_get_factory_mac ( flexboot_nodnic_priv, i );
1555  }
1556 
1557  /* Update ETH operations with IRQ function if supported */
1558  DBGC ( flexboot_nodnic_priv, "%s: %s IRQ function\n",
1559  __FUNCTION__, ( callbacks->irq ? "Valid" : "No" ) );
1561  return 0;
1562 
1563  flexboot_nodnic_ports_unregister_dev ( flexboot_nodnic_priv );
1564 reg_err:
1565 err_set_ports_types:
1566  flexboot_nodnic_dealloc_uar ( flexboot_nodnic_priv );
1567 err_thin_init_ports:
1568 err_alloc_ibdev:
1569 err_set_masking:
1570 get_cap_err:
1572 device_init_err:
1574 err_utils_init:
1575  free ( flexboot_nodnic_priv );
1576 device_err_alloc:
1577  return status;
1578 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
mlx_status nodnic_device_get_cap(IN nodnic_device_priv *device_priv)
Definition: mlx_device.c:230
static mlx_status flexboot_nodnic_thin_init_ports(struct flexboot_nodnic *flexboot_nodnic_priv)
mlx_status nodnic_device_init(IN nodnic_device_priv *device_priv)
Definition: mlx_device.c:195
static mlx_status flexboot_nodnic_set_ports_type(struct flexboot_nodnic *flexboot_nodnic_priv)
static int flexboot_nodnic_set_port_masking(struct flexboot_nodnic *flexboot_nodnic)
Set port masking.
nodnic_device_priv device_priv
nodnic device
#define DBGC(...)
Definition: compiler.h:505
static int flexboot_nodnic_dealloc_uar(struct flexboot_nodnic *flexboot_nodnic)
static int flexboot_nodnic_alloc_uar(struct flexboot_nodnic *flexboot_nodnic)
Initialise Nodnic PCI parameters.
static struct net_device_operations flexboot_nodnic_eth_operations
flexboot_nodnic Ethernet network device operations
struct pci_device * pci
PCI device.
int init_mlx_utils(mlx_utils **utils, struct pci_device *pci)
u16 port_mask
Port masking.
uint8_t status
Status.
Definition: ena.h:16
void(* irq)(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: netdevice.h:272
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:338
mlx_status nodnic_device_teardown(IN nodnic_device_priv *device_priv)
Definition: mlx_device.c:218
static mlx_status flexboot_nodnic_ports_unregister_dev(struct flexboot_nodnic *flexboot_nodnic_priv)
static mlx_status flexboot_nodnic_ports_register_dev(struct flexboot_nodnic *flexboot_nodnic_priv)
nodnic_device_capabilites device_cap
#define MLX_SUCCESS
A flexboot_nodnic device.
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define MLX_FATAL_CHECK_STATUS(status, label, message)
Definition: mlx_bail.h:29
#define EN_DEFAULT_ADMIN_MTU
static mlx_status flexboot_nodnic_get_factory_mac(struct flexboot_nodnic *flexboot_nodnic_priv, uint8_t port __attribute__((unused)))
mlx_status mlx_set_admin_mtu(IN mlx_utils *utils, IN mlx_uint8 port_num, IN mlx_uint32 admin_mtu)
Definition: mlx_mtu.c:63
static mlx_status flexboot_nodnic_allocate_infiniband_devices(struct flexboot_nodnic *flexboot_nodnic_priv)
#define MLX_OUT_OF_RESOURCES
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
void free_mlx_utils(mlx_utils **utils)
int mlx_status
struct flexboot_nodnic_callbacks * callbacks
nic specific data
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void(* irq)(struct net_device *netdev, int enable)

References flexboot_nodnic::callbacks, DBGC, _nodnic_device_priv::device_cap, flexboot_nodnic::device_priv, EINVAL, EN_DEFAULT_ADMIN_MTU, flexboot_nodnic_alloc_uar(), flexboot_nodnic_allocate_infiniband_devices(), flexboot_nodnic_dealloc_uar(), flexboot_nodnic_eth_operations, flexboot_nodnic_get_factory_mac(), flexboot_nodnic_ports_register_dev(), flexboot_nodnic_ports_unregister_dev(), flexboot_nodnic_set_port_masking(), flexboot_nodnic_set_ports_type(), flexboot_nodnic_thin_init_ports(), free, free_mlx_utils(), init_mlx_utils(), flexboot_nodnic_callbacks::irq, net_device_operations::irq, MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FATAL_CHECK_STATUS, MLX_OUT_OF_RESOURCES, mlx_set_admin_mtu(), MLX_SUCCESS, nodnic_device_get_cap(), nodnic_device_init(), nodnic_device_teardown(), NULL, _nodnic_device_capabilites::num_ports, flexboot_nodnic::pci, pci_set_drvdata(), flexboot_nodnic::port_mask, status, _nodnic_device_priv::utils, and zalloc().

Referenced by golan_probe().

◆ flexboot_nodnic_remove()

void flexboot_nodnic_remove ( struct pci_device pci)

Definition at line 1580 of file flexboot_nodnic.c.

1581 {
1582  struct flexboot_nodnic *flexboot_nodnic_priv = pci_get_drvdata ( pci );
1583  nodnic_device_priv *device_priv = & ( flexboot_nodnic_priv->device_priv );
1584 
1585  flexboot_nodnic_dealloc_uar ( flexboot_nodnic_priv );
1586  flexboot_nodnic_ports_unregister_dev ( flexboot_nodnic_priv );
1589  free( flexboot_nodnic_priv );
1590 }
nodnic_device_priv device_priv
nodnic device
static int flexboot_nodnic_dealloc_uar(struct flexboot_nodnic *flexboot_nodnic)
struct pci_device * pci
PCI device.
mlx_status nodnic_device_teardown(IN nodnic_device_priv *device_priv)
Definition: mlx_device.c:218
static mlx_status flexboot_nodnic_ports_unregister_dev(struct flexboot_nodnic *flexboot_nodnic_priv)
A flexboot_nodnic device.
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
void free_mlx_utils(mlx_utils **utils)

References flexboot_nodnic::device_priv, flexboot_nodnic_dealloc_uar(), flexboot_nodnic_ports_unregister_dev(), free, free_mlx_utils(), nodnic_device_teardown(), flexboot_nodnic::pci, pci_get_drvdata(), and _nodnic_device_priv::utils.

Referenced by golan_remove().

Variable Documentation

◆ flexboot_nodnic_ib_operations

struct ib_device_operations flexboot_nodnic_ib_operations
static
Initial value:
= {
.set_port_info = flexboot_nodnic_inform_sma,
.set_pkey_table = flexboot_nodnic_inform_sma,
}
static void flexboot_nodnic_ib_close(struct ib_device *ibdev __attribute__((unused)))
Close Infiniband link.
static int flexboot_nodnic_post_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
static int flexboot_nodnic_modify_qp(struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp __attribute__((unused)))
Modify queue pair.
static int flexboot_nodnic_create_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
static void flexboot_nodnic_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
static void flexboot_nodnic_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
static int flexboot_nodnic_inform_sma(struct ib_device *ibdev __attribute__((unused)), union ib_mad *mad __attribute__((unused)))
Inform embedded subnet management agent of a received MAD.
static void flexboot_nodnic_mcast_detach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
static void flexboot_nodnic_poll_eq(struct ib_device *ibdev)
static void flexboot_nodnic_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
static int flexboot_nodnic_post_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *av, struct io_buffer *iobuf)
Post send work queue entry.
static int flexboot_nodnic_ib_open(struct ib_device *ibdev __attribute__((unused)))
Initialise Infiniband link.
static int flexboot_nodnic_create_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
static int flexboot_nodnic_mcast_attach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)

flexboot_nodnic Infiniband operations

Definition at line 677 of file flexboot_nodnic.c.

Referenced by flexboot_nodnic_allocate_infiniband_devices().

◆ flexboot_nodnic_eth_qp_op

struct ib_queue_pair_operations flexboot_nodnic_eth_qp_op
static
Initial value:
= {
.alloc_iob = alloc_iob,
}
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128

flexboot nodnic Ethernet queue pair operations

Definition at line 753 of file flexboot_nodnic.c.

Referenced by flexboot_nodnic_eth_open().

◆ flexboot_nodnic_eth_cq_op

struct ib_completion_queue_operations flexboot_nodnic_eth_cq_op
static
Initial value:
= {
}
static void flexboot_nodnic_eth_complete_recv(struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp, struct ib_address_vector *dest __attribute__((unused)), struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Handle flexboot_nodnic Ethernet device receive completion.
static void flexboot_nodnic_eth_complete_send(struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Handle flexboot_nodnic Ethernet device send completion.

flexboot_nodnic Ethernet device completion operations

Definition at line 832 of file flexboot_nodnic.c.

Referenced by flexboot_nodnic_eth_open().

◆ flexboot_nodnic_eth_operations

struct net_device_operations flexboot_nodnic_eth_operations
static
Initial value:
= {
}
static int flexboot_nodnic_eth_open(struct net_device *netdev)
Open flexboot_nodnic Ethernet device.
static void flexboot_nodnic_eth_close(struct net_device *netdev)
Close flexboot_nodnic Ethernet device.
static int flexboot_nodnic_eth_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet via flexboot_nodnic Ethernet device.
static void flexboot_nodnic_eth_poll(struct net_device *netdev)
Poll flexboot_nodnic Ethernet device.

flexboot_nodnic Ethernet network device operations

Definition at line 1042 of file flexboot_nodnic.c.

Referenced by flexboot_nodnic_probe(), and flexboot_nodnic_register_netdev().

◆ flexboot_nodnic_port_type_eth

struct flexboot_nodnic_port_type flexboot_nodnic_port_type_eth
static
Initial value:
= {
}
static void flexboot_nodnic_unregister_netdev(struct flexboot_nodnic *flexboot_nodnic __attribute__((unused)), struct flexboot_nodnic_port *port)
Unregister flexboot_nodnic Ethernet device.
static int flexboot_nodnic_register_netdev(struct flexboot_nodnic *flexboot_nodnic, struct flexboot_nodnic_port *port)
Register flexboot_nodnic Ethernet device.
static void flexboot_nodnic_state_change_netdev(struct flexboot_nodnic *flexboot_nodnic __attribute__((unused)), struct flexboot_nodnic_port *port, int link_up)
Handle flexboot_nodnic Ethernet device port state change.

flexboot_nodnic Ethernet port type

Definition at line 1132 of file flexboot_nodnic.c.

Referenced by flexboot_nodnic_set_ports_type().