iPXE
Data Structures | Macros | Functions | Variables
eoib.c File Reference

Ethernet over Infiniband. More...

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ipxe/errortab.h>
#include <ipxe/malloc.h>
#include <ipxe/iobuf.h>
#include <ipxe/if_ether.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_mcast.h>
#include <ipxe/ib_pathrec.h>
#include <ipxe/eoib.h>

Go to the source code of this file.

Data Structures

struct  eoib_peer
 An EoIB peer cache entry. More...
 

Macros

#define EOIB_NUM_SEND_WQES   8
 Number of EoIB send work queue entries. More...
 
#define EOIB_NUM_RECV_WQES   4
 Number of EoIB receive work queue entries. More...
 
#define EOIB_NUM_CQES   16
 Number of EoIB completion queue entries. More...
 
#define EINPROGRESS_JOINING   __einfo_error ( EINFO_EINPROGRESS_JOINING )
 Link status for "broadcast join in progress". More...
 
#define EINFO_EINPROGRESS_JOINING
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static LIST_HEAD (eoib_devices)
 List of EoIB devices. More...
 
static struct eoib_peereoib_find_peer (struct eoib_device *eoib, const uint8_t *mac)
 Find EoIB peer cache entry. More...
 
static struct eoib_peereoib_create_peer (struct eoib_device *eoib, const uint8_t *mac)
 Create EoIB peer cache entry. More...
 
static void eoib_flush_peers (struct eoib_device *eoib)
 Flush EoIB peer cache. More...
 
static unsigned int eoib_discard (void)
 Discard some entries from the peer cache. More...
 
struct cache_discarder eoib_discarder __cache_discarder (CACHE_EXPENSIVE)
 EoIB cache discarder. More...
 
static struct ib_address_vectoreoib_tx_av (struct eoib_device *eoib, const uint8_t *mac)
 Find destination address vector. More...
 
static void eoib_rx_av (struct eoib_device *eoib, const uint8_t *mac, const struct ib_address_vector *av)
 Record source address vector. More...
 
static int eoib_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet via EoIB network device. More...
 
static void eoib_complete_send (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
 Handle EoIB send completion. More...
 
static void eoib_complete_recv (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct ib_address_vector *dest __unused, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Handle EoIB receive completion. More...
 
static void eoib_poll (struct net_device *netdev)
 Poll EoIB network device. More...
 
static void eoib_join_complete (struct ib_mc_membership *membership, int rc)
 Handle EoIB broadcast multicast group join completion. More...
 
static int eoib_join_broadcast_group (struct eoib_device *eoib)
 Join EoIB broadcast multicast group. More...
 
static void eoib_leave_broadcast_group (struct eoib_device *eoib)
 Leave EoIB broadcast multicast group. More...
 
static void eoib_link_state_changed (struct eoib_device *eoib)
 Handle link status change. More...
 
static int eoib_open (struct net_device *netdev)
 Open EoIB network device. More...
 
static void eoib_close (struct net_device *netdev)
 Close EoIB network device. More...
 
int eoib_create (struct ib_device *ibdev, const uint8_t *hw_addr, struct ib_address_vector *broadcast, const char *name)
 Create EoIB device. More...
 
struct eoib_deviceeoib_find (struct ib_device *ibdev, const uint8_t *hw_addr)
 Find EoIB device. More...
 
void eoib_destroy (struct eoib_device *eoib)
 Remove EoIB device. More...
 
static int eoib_probe (struct ib_device *ibdev __unused)
 Probe EoIB device. More...
 
static void eoib_notify (struct ib_device *ibdev)
 Handle device or link status change. More...
 
static void eoib_remove (struct ib_device *ibdev)
 Remove EoIB device. More...
 
static int eoib_heartbeat_rx (struct io_buffer *iobuf, struct net_device *netdev __unused, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
 Silently ignore incoming EoIB heartbeat packets. More...
 
static const char * eoib_heartbeat_ntoa (const void *net_addr __unused)
 Transcribe EoIB heartbeat address. More...
 
static void eoib_duplicate (struct eoib_device *eoib, struct io_buffer *original)
 Transmit duplicate packet to the EoIB gateway. More...
 
void eoib_set_gateway (struct eoib_device *eoib, struct ib_address_vector *av)
 Set EoIB gateway. More...
 

Variables

struct errortab eoib_errors [] __errortab
 Human-readable message for the link status. More...
 
static struct net_device_operations eoib_operations
 EoIB network device operations. More...
 
static struct ib_completion_queue_operations eoib_cq_op
 EoIB completion operations. More...
 
static struct ib_queue_pair_operations eoib_qp_op
 EoIB queue pair operations. More...
 
struct ib_driver eoib_driver __ib_driver
 EoIB driver. More...
 
struct net_protocol eoib_heartbeat_protocol __net_protocol
 EoIB heartbeat network protocol. More...
 

Detailed Description

Ethernet over Infiniband.

Definition in file eoib.c.

Macro Definition Documentation

◆ EOIB_NUM_SEND_WQES

#define EOIB_NUM_SEND_WQES   8

Number of EoIB send work queue entries.

Definition at line 47 of file eoib.c.

◆ EOIB_NUM_RECV_WQES

#define EOIB_NUM_RECV_WQES   4

Number of EoIB receive work queue entries.

Definition at line 50 of file eoib.c.

◆ EOIB_NUM_CQES

#define EOIB_NUM_CQES   16

Number of EoIB completion queue entries.

Definition at line 53 of file eoib.c.

◆ EINPROGRESS_JOINING

#define EINPROGRESS_JOINING   __einfo_error ( EINFO_EINPROGRESS_JOINING )

Link status for "broadcast join in progress".

Definition at line 56 of file eoib.c.

◆ EINFO_EINPROGRESS_JOINING

#define EINFO_EINPROGRESS_JOINING
Value:
( EINFO_EINPROGRESS, 0x01, "Joining" )
#define EINFO_EINPROGRESS
Definition: errno.h:419
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 57 of file eoib.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ LIST_HEAD()

static LIST_HEAD ( eoib_devices  )
static

List of EoIB devices.

◆ eoib_find_peer()

static struct eoib_peer* eoib_find_peer ( struct eoib_device eoib,
const uint8_t mac 
)
static

Find EoIB peer cache entry.

Parameters
eoibEoIB device
macEthernet MAC
Return values
peerEoIB peer, or NULL if not found

Definition at line 94 of file eoib.c.

95  {
96  struct eoib_peer *peer;
97 
98  /* Find peer cache entry */
99  list_for_each_entry ( peer, &eoib->peers, list ) {
100  if ( memcmp ( mac, peer->mac, sizeof ( peer->mac ) ) == 0 ) {
101  /* Move peer to start of list */
102  list_del ( &peer->list );
103  list_add ( &peer->list, &eoib->peers );
104  return peer;
105  }
106  }
107 
108  return NULL;
109 }
struct list_head peers
Peer cache.
Definition: eoib.h:50
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct list_head list
List of EoIB peer cache entries.
Definition: eoib.c:80
An EoIB peer cache entry.
Definition: eoib.c:78
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References eoib_peer::list, list_add, list_del, list_for_each_entry, mac, memcmp(), NULL, peer, and eoib_device::peers.

Referenced by eoib_rx_av(), and eoib_tx_av().

◆ eoib_create_peer()

static struct eoib_peer* eoib_create_peer ( struct eoib_device eoib,
const uint8_t mac 
)
static

Create EoIB peer cache entry.

Parameters
eoibEoIB device
macEthernet MAC
Return values
peerEoIB peer, or NULL on error

Definition at line 118 of file eoib.c.

119  {
120  struct eoib_peer *peer;
121 
122  /* Allocate and initialise peer cache entry */
123  peer = zalloc ( sizeof ( *peer ) );
124  if ( peer ) {
125  memcpy ( peer->mac, mac, sizeof ( peer->mac ) );
126  list_add ( &peer->list, &eoib->peers );
127  }
128  return peer;
129 }
struct list_head peers
Peer cache.
Definition: eoib.h:50
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
An EoIB peer cache entry.
Definition: eoib.c:78
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12

References list_add, mac, memcpy(), peer, eoib_device::peers, and zalloc().

Referenced by eoib_tx_av().

◆ eoib_flush_peers()

static void eoib_flush_peers ( struct eoib_device eoib)
static

Flush EoIB peer cache.

Parameters
eoibEoIB device

Definition at line 136 of file eoib.c.

136  {
137  struct eoib_peer *peer;
138  struct eoib_peer *tmp;
139 
140  list_for_each_entry_safe ( peer, tmp, &eoib->peers, list ) {
141  list_del ( &peer->list );
142  free ( peer );
143  }
144 }
struct list_head peers
Peer cache.
Definition: eoib.h:50
unsigned long tmp
Definition: linux_pci.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
List of EoIB peer cache entries.
Definition: eoib.c:80
An EoIB peer cache entry.
Definition: eoib.c:78
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12

References free, eoib_peer::list, list_del, list_for_each_entry_safe, peer, eoib_device::peers, and tmp.

Referenced by eoib_close().

◆ eoib_discard()

static unsigned int eoib_discard ( void  )
static

Discard some entries from the peer cache.

Return values
discardedNumber of cached items discarded

Definition at line 151 of file eoib.c.

151  {
152  struct net_device *netdev;
153  struct eoib_device *eoib;
154  struct eoib_peer *peer;
155  unsigned int discarded = 0;
156 
157  /* Try to discard one cache entry for each EoIB device */
158  for_each_netdev ( netdev ) {
159 
160  /* Skip non-EoIB devices */
161  if ( netdev->op != &eoib_operations )
162  continue;
163  eoib = netdev->priv;
164 
165  /* Discard least recently used cache entry (if any) */
167  list_del ( &peer->list );
168  free ( peer );
169  discarded++;
170  break;
171  }
172  }
173 
174  return discarded;
175 }
struct list_head peers
Peer cache.
Definition: eoib.h:50
An EoIB device.
Definition: eoib.h:30
struct net_device_operations * op
Network device operations.
Definition: netdevice.h:369
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
void * priv
Driver private data.
Definition: netdevice.h:431
#define list_for_each_entry_reverse(pos, head, member)
Iterate over entries in a list in reverse order.
Definition: list.h:444
static struct net_device * netdev
Definition: gdbudp.c:52
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition: netdevice.h:543
A network device.
Definition: netdevice.h:352
struct list_head list
List of EoIB peer cache entries.
Definition: eoib.c:80
An EoIB peer cache entry.
Definition: eoib.c:78
static struct net_device_operations eoib_operations
EoIB network device operations.
Definition: eoib.c:68
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12

References eoib_operations, for_each_netdev, free, eoib_peer::list, list_del, list_for_each_entry_reverse, netdev, net_device::op, peer, eoib_device::peers, and net_device::priv.

◆ __cache_discarder()

struct cache_discarder eoib_discarder __cache_discarder ( CACHE_EXPENSIVE  )

EoIB cache discarder.

◆ eoib_tx_av()

static struct ib_address_vector* eoib_tx_av ( struct eoib_device eoib,
const uint8_t mac 
)
static

Find destination address vector.

Parameters
eoibEoIB device
macEthernet MAC
Return values
avAddress vector, or NULL to send as broadcast

Definition at line 189 of file eoib.c.

190  {
191  struct ib_device *ibdev = eoib->ibdev;
192  struct eoib_peer *peer;
193  int rc;
194 
195  /* If this is a broadcast or multicast MAC address, then send
196  * this packet as a broadcast.
197  */
198  if ( is_multicast_ether_addr ( mac ) ) {
199  DBGCP ( eoib, "EoIB %s %s TX multicast\n",
200  eoib->name, eth_ntoa ( mac ) );
201  return NULL;
202  }
203 
204  /* If we have no peer cache entry, then create one and send
205  * this packet as a broadcast.
206  */
207  peer = eoib_find_peer ( eoib, mac );
208  if ( ! peer ) {
209  DBGC ( eoib, "EoIB %s %s TX unknown\n",
210  eoib->name, eth_ntoa ( mac ) );
211  eoib_create_peer ( eoib, mac );
212  return NULL;
213  }
214 
215  /* If we have not yet recorded a received GID and QPN for this
216  * peer cache entry, then send this packet as a broadcast.
217  */
218  if ( ! peer->av.gid_present ) {
219  DBGCP ( eoib, "EoIB %s %s TX not yet recorded\n",
220  eoib->name, eth_ntoa ( mac ) );
221  return NULL;
222  }
223 
224  /* If we have not yet resolved a path to this peer, then send
225  * this packet as a broadcast.
226  */
227  if ( ( rc = ib_resolve_path ( ibdev, &peer->av ) ) != 0 ) {
228  DBGCP ( eoib, "EoIB %s %s TX not yet resolved\n",
229  eoib->name, eth_ntoa ( mac ) );
230  return NULL;
231  }
232 
233  /* Force use of GRH even for local destinations */
234  peer->av.gid_present = 1;
235 
236  /* We have a fully resolved peer: send this packet as a
237  * unicast.
238  */
239  DBGCP ( eoib, "EoIB %s %s TX " IB_GID_FMT " QPN %#lx\n", eoib->name,
240  eth_ntoa ( mac ), IB_GID_ARGS ( &peer->av.gid ), peer->av.qpn );
241  return &peer->av;
242 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
const char * name
Name.
Definition: eoib.h:32
An Infiniband device.
Definition: infiniband.h:398
static int is_multicast_ether_addr(const void *addr)
Check if Ethernet address is a multicast address.
Definition: ethernet.h:37
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
An EoIB peer cache entry.
Definition: eoib.c:78
int ib_resolve_path(struct ib_device *ibdev, struct ib_address_vector *av)
Resolve path.
Definition: ib_pathrec.c:249
static struct eoib_peer * eoib_find_peer(struct eoib_device *eoib, const uint8_t *mac)
Find EoIB peer cache entry.
Definition: eoib.c:94
static struct eoib_peer * eoib_create_peer(struct eoib_device *eoib, const uint8_t *mac)
Create EoIB peer cache entry.
Definition: eoib.c:118
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
#define DBGCP(...)
Definition: compiler.h:539
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGC, DBGCP, eoib_create_peer(), eoib_find_peer(), eth_ntoa(), IB_GID_ARGS, IB_GID_FMT, ib_resolve_path(), eoib_device::ibdev, is_multicast_ether_addr(), mac, eoib_device::name, NULL, peer, and rc.

Referenced by eoib_transmit().

◆ eoib_rx_av()

static void eoib_rx_av ( struct eoib_device eoib,
const uint8_t mac,
const struct ib_address_vector av 
)
static

Record source address vector.

Parameters
eoibEoIB device
macEthernet MAC
lidInfiniband LID

Definition at line 251 of file eoib.c.

252  {
253  const union ib_gid *gid = &av->gid;
254  unsigned long qpn = av->qpn;
255  struct eoib_peer *peer;
256 
257  /* Sanity checks */
258  if ( ! av->gid_present ) {
259  DBGC ( eoib, "EoIB %s %s RX with no GID\n",
260  eoib->name, eth_ntoa ( mac ) );
261  return;
262  }
263 
264  /* Find peer cache entry (if any) */
265  peer = eoib_find_peer ( eoib, mac );
266  if ( ! peer ) {
267  DBGCP ( eoib, "EoIB %s %s RX " IB_GID_FMT " (ignored)\n",
268  eoib->name, eth_ntoa ( mac ), IB_GID_ARGS ( gid ) );
269  return;
270  }
271 
272  /* Some dubious EoIB implementations utilise an Ethernet-to-
273  * EoIB gateway that will send packets from the wrong QPN.
274  */
275  if ( eoib_has_gateway ( eoib ) &&
276  ( memcmp ( gid, &eoib->gateway.gid, sizeof ( *gid ) ) == 0 ) ) {
277  qpn = eoib->gateway.qpn;
278  }
279 
280  /* Do nothing if peer cache entry is complete and correct */
281  if ( ( peer->av.lid == av->lid ) && ( peer->av.qpn == qpn ) ) {
282  DBGCP ( eoib, "EoIB %s %s RX unchanged\n",
283  eoib->name, eth_ntoa ( mac ) );
284  return;
285  }
286 
287  /* Update peer cache entry */
288  peer->av.qpn = qpn;
289  peer->av.qkey = eoib->broadcast.qkey;
290  peer->av.gid_present = 1;
291  memcpy ( &peer->av.gid, gid, sizeof ( peer->av.gid ) );
292  DBGC ( eoib, "EoIB %s %s RX " IB_GID_FMT " QPN %#lx\n", eoib->name,
293  eth_ntoa ( mac ), IB_GID_ARGS ( &peer->av.gid ), peer->av.qpn );
294 }
struct ib_address_vector broadcast
Broadcast address.
Definition: eoib.h:40
#define DBGC(...)
Definition: compiler.h:505
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
unsigned int gid_present
GID is present.
Definition: infiniband.h:90
An Infiniband Global Identifier.
Definition: ib_packet.h:33
__be32 qpn
Definition: CIB_PRM.h:29
const char * name
Name.
Definition: eoib.h:32
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned long qkey
Queue key.
Definition: infiniband.h:79
static int eoib_has_gateway(struct eoib_device *eoib)
Check if EoIB device uses a gateway.
Definition: eoib.h:71
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
An EoIB peer cache entry.
Definition: eoib.c:78
static struct eoib_peer * eoib_find_peer(struct eoib_device *eoib, const uint8_t *mac)
Find EoIB peer cache entry.
Definition: eoib.c:94
struct ib_address_vector gateway
Gateway (if any)
Definition: eoib.h:60
struct ib_address_vector av
Infiniband address vector.
Definition: eoib.c:84
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
#define DBGCP(...)
Definition: compiler.h:539
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
unsigned int lid
Local ID.
Definition: infiniband.h:81
u8 gid[16]
Definition: CIB_PRM.h:31
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

References eoib_peer::av, eoib_device::broadcast, DBGC, DBGCP, eoib_find_peer(), eoib_has_gateway(), eth_ntoa(), eoib_device::gateway, gid, ib_address_vector::gid, ib_address_vector::gid_present, IB_GID_ARGS, IB_GID_FMT, ib_address_vector::lid, mac, memcmp(), memcpy(), eoib_device::name, peer, ib_address_vector::qkey, qpn, and ib_address_vector::qpn.

Referenced by eoib_complete_recv().

◆ eoib_transmit()

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

Transmit packet via EoIB network device.

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

Definition at line 310 of file eoib.c.

311  {
312  struct eoib_device *eoib = netdev->priv;
313  struct eoib_header *eoib_hdr;
314  struct ethhdr *ethhdr;
315  struct ib_address_vector *av;
316  size_t zlen;
317 
318  /* Sanity checks */
319  assert ( iob_len ( iobuf ) >= sizeof ( *ethhdr ) );
320  assert ( iob_headroom ( iobuf ) >= sizeof ( *eoib_hdr ) );
321 
322  /* Look up destination address vector */
323  ethhdr = iobuf->data;
324  av = eoib_tx_av ( eoib, ethhdr->h_dest );
325 
326  /* Prepend EoIB header */
327  eoib_hdr = iob_push ( iobuf, sizeof ( *eoib_hdr ) );
328  eoib_hdr->magic = htons ( EOIB_MAGIC );
329  eoib_hdr->reserved = 0;
330 
331  /* Pad buffer to minimum Ethernet frame size */
332  zlen = ( sizeof ( *eoib_hdr ) + ETH_ZLEN );
333  assert ( zlen <= IOB_ZLEN );
334  if ( iob_len ( iobuf ) < zlen )
335  iob_pad ( iobuf, zlen );
336 
337  /* If we have no unicast address then send as a broadcast,
338  * with a duplicate sent to the gateway if applicable.
339  */
340  if ( ! av ) {
341  av = &eoib->broadcast;
342  if ( eoib_has_gateway ( eoib ) )
343  eoib->duplicate ( eoib, iobuf );
344  }
345 
346  /* Post send work queue entry */
347  return ib_post_send ( eoib->ibdev, eoib->qp, av, iobuf );
348 }
struct ib_address_vector broadcast
Broadcast address.
Definition: eoib.h:40
An EoIB device.
Definition: eoib.h:30
#define iob_push(iobuf, len)
Definition: iobuf.h:84
#define EOIB_MAGIC
EoIB magic signature.
Definition: eoib.h:27
uint8_t h_dest[ETH_ALEN]
Destination MAC address.
Definition: if_ether.h:33
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int eoib_has_gateway(struct eoib_device *eoib)
Check if EoIB device uses a gateway.
Definition: eoib.h:71
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
An EoIB header.
Definition: eoib.h:19
void(* duplicate)(struct eoib_device *eoib, struct io_buffer *original)
Send duplicate packet to gateway (or NULL)
Definition: eoib.h:57
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define ETH_ZLEN
Definition: if_ether.h:10
uint16_t magic
Signature.
Definition: eoib.h:21
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
static size_t iob_headroom(struct io_buffer *iobuf)
Calculate available space at start of an I/O buffer.
Definition: iobuf.h:165
#define IOB_ZLEN
Minimum I/O buffer length.
Definition: iobuf.h:24
void * data
Start of data.
Definition: iobuf.h:48
uint16_t reserved
Reserved.
Definition: eoib.h:23
An Infiniband Address Vector.
Definition: infiniband.h:72
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
static struct ib_address_vector * eoib_tx_av(struct eoib_device *eoib, const uint8_t *mac)
Find destination address vector.
Definition: eoib.c:189
An Ethernet link-layer header.
Definition: if_ether.h:31
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition: iobpad.c:49
#define htons(value)
Definition: byteswap.h:135

References assert(), eoib_device::broadcast, io_buffer::data, eoib_device::duplicate, eoib_has_gateway(), EOIB_MAGIC, eoib_tx_av(), ETH_ZLEN, ethhdr::h_dest, htons, ib_post_send(), eoib_device::ibdev, iob_headroom(), iob_len(), iob_pad(), iob_push, IOB_ZLEN, eoib_header::magic, netdev, net_device::priv, eoib_device::qp, and eoib_header::reserved.

◆ eoib_complete_send()

static void eoib_complete_send ( struct ib_device *ibdev  __unused,
struct ib_queue_pair qp,
struct io_buffer iobuf,
int  rc 
)
static

Handle EoIB send completion.

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

Definition at line 358 of file eoib.c.

360  {
361  struct eoib_device *eoib = ib_qp_get_ownerdata ( qp );
362 
363  netdev_tx_complete_err ( eoib->netdev, iobuf, rc );
364 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An EoIB device.
Definition: eoib.h:30
struct net_device * netdev
Network device.
Definition: eoib.h:34
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:664
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:470

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

◆ eoib_complete_recv()

static void eoib_complete_recv ( struct ib_device *ibdev  __unused,
struct ib_queue_pair qp,
struct ib_address_vector *dest  __unused,
struct ib_address_vector source,
struct io_buffer iobuf,
int  rc 
)
static

Handle EoIB receive completion.

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

Definition at line 376 of file eoib.c.

380  {
381  struct eoib_device *eoib = ib_qp_get_ownerdata ( qp );
382  struct net_device *netdev = eoib->netdev;
383  struct eoib_header *eoib_hdr;
384  struct ethhdr *ethhdr;
385 
386  /* Record errors */
387  if ( rc != 0 ) {
388  netdev_rx_err ( netdev, iobuf, rc );
389  return;
390  }
391 
392  /* Sanity check */
393  if ( iob_len ( iobuf ) < ( sizeof ( *eoib_hdr ) + sizeof ( *ethhdr ) )){
394  DBGC ( eoib, "EoIB %s received packet too short to "
395  "contain EoIB and Ethernet headers\n", eoib->name );
396  DBGC_HD ( eoib, iobuf->data, iob_len ( iobuf ) );
397  netdev_rx_err ( netdev, iobuf, -EIO );
398  return;
399  }
400  if ( ! source ) {
401  DBGC ( eoib, "EoIB %s received packet without address "
402  "vector\n", eoib->name );
403  netdev_rx_err ( netdev, iobuf, -ENOTTY );
404  return;
405  }
406 
407  /* Strip EoIB header */
408  iob_pull ( iobuf, sizeof ( *eoib_hdr ) );
409 
410  /* Update neighbour cache entry, if any */
411  ethhdr = iobuf->data;
412  eoib_rx_av ( eoib, ethhdr->h_source, source );
413 
414  /* Hand off to network layer */
415  netdev_rx ( netdev, iobuf );
416 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
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:586
An EoIB device.
Definition: eoib.h:30
#define DBGC(...)
Definition: compiler.h:505
const char * name
Name.
Definition: eoib.h:32
static void eoib_rx_av(struct eoib_device *eoib, const uint8_t *mac, const struct ib_address_vector *av)
Record source address vector.
Definition: eoib.c:251
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
An EoIB header.
Definition: eoib.h:19
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:664
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define DBGC_HD(...)
Definition: compiler.h:507
A network device.
Definition: netdevice.h:352
uint8_t h_source[ETH_ALEN]
Source MAC address.
Definition: if_ether.h:35
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
An Ethernet link-layer header.
Definition: if_ether.h:31

References io_buffer::data, DBGC, DBGC_HD, EIO, ENOTTY, eoib_rx_av(), ethhdr::h_source, ib_qp_get_ownerdata(), iob_len(), iob_pull, eoib_device::name, eoib_device::netdev, netdev, netdev_rx(), netdev_rx_err(), qp, and rc.

◆ eoib_poll()

static void eoib_poll ( struct net_device netdev)
static

Poll EoIB network device.

Parameters
netdevNetwork device

Definition at line 434 of file eoib.c.

434  {
435  struct eoib_device *eoib = netdev->priv;
436  struct ib_device *ibdev = eoib->ibdev;
437 
438  /* Poll Infiniband device */
439  ib_poll_eq ( ibdev );
440 
441  /* Poll the retry timers (required for EoIB multicast join) */
442  retry_poll();
443 }
void ib_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: infiniband.c:878
An EoIB device.
Definition: eoib.h:30
An Infiniband device.
Definition: infiniband.h:398
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
void retry_poll(void)
Poll the retry timer list.
Definition: retry.c:197

References ib_poll_eq(), eoib_device::ibdev, netdev, net_device::priv, and retry_poll().

◆ eoib_join_complete()

static void eoib_join_complete ( struct ib_mc_membership membership,
int  rc 
)
static

Handle EoIB broadcast multicast group join completion.

Parameters
membershipMulticast group membership
rcStatus code

Definition at line 451 of file eoib.c.

451  {
452  struct eoib_device *eoib =
454 
455  /* Record join status as link status */
456  netdev_link_err ( eoib->netdev, rc );
457 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An EoIB device.
Definition: eoib.h:30
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_mc_membership membership
Broadcast group membership.
Definition: eoib.h:47
struct net_device * netdev
Network device.
Definition: eoib.h:34
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
Definition: netdevice.c:207

References container_of, eoib_device::membership, eoib_device::netdev, netdev_link_err(), and rc.

Referenced by eoib_join_broadcast_group().

◆ eoib_join_broadcast_group()

static int eoib_join_broadcast_group ( struct eoib_device eoib)
static

Join EoIB broadcast multicast group.

Parameters
eoibEoIB device
Return values
rcReturn status code

Definition at line 465 of file eoib.c.

465  {
466  int rc;
467 
468  /* Join multicast group */
469  if ( ( rc = ib_mcast_join ( eoib->ibdev, eoib->qp,
470  &eoib->membership, &eoib->broadcast,
471  eoib->mask, eoib_join_complete ) ) != 0 ) {
472  DBGC ( eoib, "EoIB %s could not join broadcast group: %s\n",
473  eoib->name, strerror ( rc ) );
474  return rc;
475  }
476 
477  return 0;
478 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct ib_address_vector broadcast
Broadcast address.
Definition: eoib.h:40
int ib_mcast_join(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_mc_membership *membership, struct ib_address_vector *av, unsigned int mask, void(*complete)(struct ib_mc_membership *membership, int rc))
Join multicast group.
Definition: ib_mcast.c:152
#define DBGC(...)
Definition: compiler.h:505
const char * name
Name.
Definition: eoib.h:32
struct ib_mc_membership membership
Broadcast group membership.
Definition: eoib.h:47
unsigned int mask
Multicast group additional component mask.
Definition: eoib.h:62
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
static void eoib_join_complete(struct ib_mc_membership *membership, int rc)
Handle EoIB broadcast multicast group join completion.
Definition: eoib.c:451

References eoib_device::broadcast, DBGC, eoib_join_complete(), ib_mcast_join(), eoib_device::ibdev, eoib_device::mask, eoib_device::membership, eoib_device::name, eoib_device::qp, rc, and strerror().

Referenced by eoib_link_state_changed().

◆ eoib_leave_broadcast_group()

static void eoib_leave_broadcast_group ( struct eoib_device eoib)
static

Leave EoIB broadcast multicast group.

Parameters
eoibEoIB device

Definition at line 485 of file eoib.c.

485  {
486 
487  /* Leave multicast group */
488  ib_mcast_leave ( eoib->ibdev, eoib->qp, &eoib->membership );
489 }
struct ib_mc_membership membership
Broadcast group membership.
Definition: eoib.h:47
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
void ib_mcast_leave(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_mc_membership *membership)
Leave multicast group.
Definition: ib_mcast.c:209

References ib_mcast_leave(), eoib_device::ibdev, eoib_device::membership, and eoib_device::qp.

Referenced by eoib_close(), and eoib_link_state_changed().

◆ eoib_link_state_changed()

static void eoib_link_state_changed ( struct eoib_device eoib)
static

Handle link status change.

Parameters
eoibEoIB device

Definition at line 496 of file eoib.c.

496  {
497  struct net_device *netdev = eoib->netdev;
498  struct ib_device *ibdev = eoib->ibdev;
499  int rc;
500 
501  /* Leave existing broadcast group */
502  if ( eoib->qp )
504 
505  /* Update broadcast GID based on potentially-new partition key */
506  eoib->broadcast.gid.words[2] = htons ( ibdev->pkey | IB_PKEY_FULL );
507 
508  /* Set net device link state to reflect Infiniband link state */
509  rc = ib_link_rc ( ibdev );
511 
512  /* Join new broadcast group */
513  if ( ib_is_open ( ibdev ) && ib_link_ok ( ibdev ) && eoib->qp &&
514  ( ( rc = eoib_join_broadcast_group ( eoib ) ) != 0 ) ) {
515  DBGC ( eoib, "EoIB %s could not rejoin broadcast group: "
516  "%s\n", eoib->name, strerror ( rc ) );
518  return;
519  }
520 }
int ib_link_rc(struct ib_device *ibdev)
Get link state.
Definition: infiniband.c:594
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static __always_inline int ib_link_ok(struct ib_device *ibdev)
Check link state of Infiniband device.
Definition: infiniband.h:565
static int ib_is_open(struct ib_device *ibdev)
Check whether or not Infiniband device is open.
Definition: infiniband.h:576
struct ib_address_vector broadcast
Broadcast address.
Definition: eoib.h:40
#define IB_PKEY_FULL
Infiniband partition key full membership flag.
Definition: infiniband.h:42
#define DBGC(...)
Definition: compiler.h:505
static int eoib_join_broadcast_group(struct eoib_device *eoib)
Join EoIB broadcast multicast group.
Definition: eoib.c:465
const char * name
Name.
Definition: eoib.h:32
An Infiniband device.
Definition: infiniband.h:398
#define EINPROGRESS_JOINING
Link status for "broadcast join in progress".
Definition: eoib.c:56
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint16_t words[8]
Definition: ib_packet.h:35
A network device.
Definition: netdevice.h:352
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
Definition: netdevice.c:207
static void eoib_leave_broadcast_group(struct eoib_device *eoib)
Leave EoIB broadcast multicast group.
Definition: eoib.c:485
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
uint16_t pkey
Partition key.
Definition: infiniband.h:449
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
#define htons(value)
Definition: byteswap.h:135

References eoib_device::broadcast, DBGC, EINPROGRESS_JOINING, eoib_join_broadcast_group(), eoib_leave_broadcast_group(), ib_address_vector::gid, htons, ib_is_open(), ib_link_ok(), ib_link_rc(), IB_PKEY_FULL, eoib_device::ibdev, eoib_device::name, eoib_device::netdev, netdev, netdev_link_err(), ib_device::pkey, eoib_device::qp, rc, strerror(), and ib_gid::words.

Referenced by eoib_notify(), and eoib_open().

◆ eoib_open()

static int eoib_open ( struct net_device netdev)
static

Open EoIB network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 528 of file eoib.c.

528  {
529  struct eoib_device *eoib = netdev->priv;
530  struct ib_device *ibdev = eoib->ibdev;
531  int rc;
532 
533  /* Open IB device */
534  if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
535  DBGC ( eoib, "EoIB %s could not open %s: %s\n",
536  eoib->name, ibdev->name, strerror ( rc ) );
537  goto err_ib_open;
538  }
539 
540  /* Allocate completion queue */
541  if ( ( rc = ib_create_cq ( ibdev, EOIB_NUM_CQES, &eoib_cq_op,
542  &eoib->cq ) ) != 0 ) {
543  DBGC ( eoib, "EoIB %s could not create completion queue: %s\n",
544  eoib->name, strerror ( rc ) );
545  goto err_create_cq;
546  }
547 
548  /* Allocate queue pair */
549  if ( ( rc = ib_create_qp ( ibdev, IB_QPT_UD, EOIB_NUM_SEND_WQES,
550  eoib->cq, EOIB_NUM_RECV_WQES, eoib->cq,
551  &eoib_qp_op, netdev->name, &eoib->qp ) )!=0){
552  DBGC ( eoib, "EoIB %s could not create queue pair: %s\n",
553  eoib->name, strerror ( rc ) );
554  goto err_create_qp;
555  }
556  ib_qp_set_ownerdata ( eoib->qp, eoib );
557 
558  /* Fill receive rings */
559  ib_refill_recv ( ibdev, eoib->qp );
560 
561  /* Fake a link status change to join the broadcast group */
562  eoib_link_state_changed ( eoib );
563 
564  return 0;
565 
566  ib_destroy_qp ( ibdev, eoib->qp );
567  eoib->qp = NULL;
568  err_create_qp:
569  ib_destroy_cq ( ibdev, eoib->cq );
570  eoib->cq = NULL;
571  err_create_cq:
572  ib_close ( ibdev );
573  err_ib_open:
574  return rc;
575 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EOIB_NUM_SEND_WQES
Number of EoIB send work queue entries.
Definition: eoib.c:47
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
An EoIB device.
Definition: eoib.h:30
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
int ib_open(struct ib_device *ibdev)
Open port.
Definition: infiniband.c:652
void ib_close(struct ib_device *ibdev)
Close port.
Definition: infiniband.c:716
#define EOIB_NUM_RECV_WQES
Number of EoIB receive work queue entries.
Definition: eoib.c:50
const char * name
Name.
Definition: eoib.h:32
struct ib_completion_queue * cq
Completion queue.
Definition: eoib.h:43
#define EOIB_NUM_CQES
Number of EoIB completion queue entries.
Definition: eoib.c:53
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
static struct ib_queue_pair_operations eoib_qp_op
EoIB queue pair operations.
Definition: eoib.c:425
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void eoib_link_state_changed(struct eoib_device *eoib)
Handle link status change.
Definition: eoib.c:496
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
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
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
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
static struct ib_completion_queue_operations eoib_cq_op
EoIB completion operations.
Definition: eoib.c:419
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
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:653

References eoib_device::cq, DBGC, eoib_cq_op, eoib_link_state_changed(), EOIB_NUM_CQES, EOIB_NUM_RECV_WQES, EOIB_NUM_SEND_WQES, eoib_qp_op, ib_close(), ib_create_cq(), ib_create_qp(), ib_destroy_cq(), ib_destroy_qp(), ib_open(), ib_qp_set_ownerdata(), IB_QPT_UD, ib_refill_recv(), eoib_device::ibdev, eoib_device::name, net_device::name, ib_device::name, netdev, NULL, net_device::priv, eoib_device::qp, rc, and strerror().

◆ eoib_close()

static void eoib_close ( struct net_device netdev)
static

Close EoIB network device.

Parameters
netdevNetwork device

Definition at line 582 of file eoib.c.

582  {
583  struct eoib_device *eoib = netdev->priv;
584  struct ib_device *ibdev = eoib->ibdev;
585 
586  /* Flush peer cache */
587  eoib_flush_peers ( eoib );
588 
589  /* Leave broadcast group */
591 
592  /* Tear down the queues */
593  ib_destroy_qp ( ibdev, eoib->qp );
594  eoib->qp = NULL;
595  ib_destroy_cq ( ibdev, eoib->cq );
596  eoib->cq = NULL;
597 
598  /* Close IB device */
599  ib_close ( ibdev );
600 }
An EoIB device.
Definition: eoib.h:30
void ib_close(struct ib_device *ibdev)
Close port.
Definition: infiniband.c:716
struct ib_completion_queue * cq
Completion queue.
Definition: eoib.h:43
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
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
static void eoib_flush_peers(struct eoib_device *eoib)
Flush EoIB peer cache.
Definition: eoib.c:136
static void eoib_leave_broadcast_group(struct eoib_device *eoib)
Leave EoIB broadcast multicast group.
Definition: eoib.c:485
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References eoib_device::cq, eoib_flush_peers(), eoib_leave_broadcast_group(), ib_close(), ib_destroy_cq(), ib_destroy_qp(), eoib_device::ibdev, netdev, NULL, net_device::priv, and eoib_device::qp.

◆ eoib_create()

int eoib_create ( struct ib_device ibdev,
const uint8_t hw_addr,
struct ib_address_vector broadcast,
const char *  name 
)

Create EoIB device.

Parameters
ibdevInfiniband device
hw_addrEthernet MAC
broadcastBroadcast address vector
nameInterface name (or NULL to use default)
Return values
rcReturn status code

Definition at line 619 of file eoib.c.

620  {
621  struct net_device *netdev;
622  struct eoib_device *eoib;
623  int rc;
624 
625  /* Allocate network device */
626  netdev = alloc_etherdev ( sizeof ( *eoib ) );
627  if ( ! netdev ) {
628  rc = -ENOMEM;
629  goto err_alloc;
630  }
632  eoib = netdev->priv;
633  netdev->dev = ibdev->dev;
634  eoib->netdev = netdev;
635  eoib->ibdev = ibdev_get ( ibdev );
636  memcpy ( &eoib->broadcast, broadcast, sizeof ( eoib->broadcast ) );
637  INIT_LIST_HEAD ( &eoib->peers );
638 
639  /* Set MAC address */
640  memcpy ( netdev->hw_addr, hw_addr, ETH_ALEN );
641 
642  /* Set interface name, if applicable */
643  if ( name )
644  snprintf ( netdev->name, sizeof ( netdev->name ), "%s", name );
645  eoib->name = netdev->name;
646 
647  /* Add to list of EoIB devices */
648  list_add_tail ( &eoib->list, &eoib_devices );
649 
650  /* Register network device */
651  if ( ( rc = register_netdev ( netdev ) ) != 0 )
652  goto err_register;
653 
654  DBGC ( eoib, "EoIB %s created for %s MAC %s\n",
655  eoib->name, ibdev->name, eth_ntoa ( hw_addr ) );
656  DBGC ( eoib, "EoIB %s broadcast GID " IB_GID_FMT "\n",
657  eoib->name, IB_GID_ARGS ( &broadcast->gid ) );
658  return 0;
659 
661  err_register:
662  list_del ( &eoib->list );
663  ibdev_put ( ibdev );
665  netdev_put ( netdev );
666  err_alloc:
667  return rc;
668 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
struct list_head peers
Peer cache.
Definition: eoib.h:50
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
struct ib_address_vector broadcast
Broadcast address.
Definition: eoib.h:40
An EoIB device.
Definition: eoib.h:30
#define DBGC(...)
Definition: compiler.h:505
struct device * dev
Underlying device.
Definition: infiniband.h:410
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition: infiniband.h:587
const char * name
Name.
Definition: eoib.h:32
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:598
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
#define ETH_ALEN
Definition: if_ether.h:8
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static struct net_device_operations eoib_operations
EoIB network device operations.
Definition: eoib.c:68
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381

References alloc_etherdev(), eoib_device::broadcast, DBGC, net_device::dev, ib_device::dev, ENOMEM, eoib_operations, ETH_ALEN, eth_ntoa(), ib_address_vector::gid, net_device::hw_addr, IB_GID_ARGS, IB_GID_FMT, eoib_device::ibdev, ibdev_get(), ibdev_put(), INIT_LIST_HEAD, eoib_device::list, list_add_tail, list_del, memcpy(), eoib_device::name, net_device::name, ib_device::name, name, eoib_device::netdev, netdev, netdev_init(), netdev_nullify(), netdev_put(), eoib_device::peers, net_device::priv, rc, register_netdev(), snprintf(), and unregister_netdev().

Referenced by xve_create().

◆ eoib_find()

struct eoib_device* eoib_find ( struct ib_device ibdev,
const uint8_t hw_addr 
)

Find EoIB device.

Parameters
ibdevInfiniband device
hw_addrOriginal Ethernet MAC
Return values
eoibEoIB device

Definition at line 677 of file eoib.c.

678  {
679  struct eoib_device *eoib;
680 
681  list_for_each_entry ( eoib, &eoib_devices, list ) {
682  if ( ( eoib->ibdev == ibdev ) &&
683  ( memcmp ( eoib->netdev->hw_addr, hw_addr,
684  ETH_ALEN ) == 0 ) )
685  return eoib;
686  }
687  return NULL;
688 }
An EoIB device.
Definition: eoib.h:30
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
struct net_device * netdev
Network device.
Definition: eoib.h:34
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
#define ETH_ALEN
Definition: if_ether.h:8
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ETH_ALEN, net_device::hw_addr, eoib_device::ibdev, eoib_device::list, list_for_each_entry, memcmp(), eoib_device::netdev, and NULL.

Referenced by xsigo_net_notify(), xsmp_rx_xve_modify(), and xve_destroy().

◆ eoib_destroy()

void eoib_destroy ( struct eoib_device eoib)

Remove EoIB device.

Parameters
eoibEoIB device

Definition at line 695 of file eoib.c.

695  {
696  struct net_device *netdev = eoib->netdev;
697 
698  /* Unregister network device */
700 
701  /* Remove from list of network devices */
702  list_del ( &eoib->list );
703 
704  /* Drop reference to Infiniband device */
705  ibdev_put ( eoib->ibdev );
706 
707  /* Free network device */
708  DBGC ( eoib, "EoIB %s destroyed\n", eoib->name );
710  netdev_put ( netdev );
711 }
#define DBGC(...)
Definition: compiler.h:505
const char * name
Name.
Definition: eoib.h:32
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:598
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528

References DBGC, eoib_device::ibdev, ibdev_put(), eoib_device::list, list_del, eoib_device::name, eoib_device::netdev, netdev, netdev_nullify(), netdev_put(), and unregister_netdev().

Referenced by eoib_remove(), and xve_destroy().

◆ eoib_probe()

static int eoib_probe ( struct ib_device *ibdev  __unused)
static

Probe EoIB device.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 719 of file eoib.c.

719  {
720 
721  /* EoIB devices are not created automatically */
722  return 0;
723 }

◆ eoib_notify()

static void eoib_notify ( struct ib_device ibdev)
static

Handle device or link status change.

Parameters
ibdevInfiniband device

Definition at line 730 of file eoib.c.

730  {
731  struct eoib_device *eoib;
732 
733  /* Handle link status change for any attached EoIB devices */
734  list_for_each_entry ( eoib, &eoib_devices, list ) {
735  if ( eoib->ibdev != ibdev )
736  continue;
737  eoib_link_state_changed ( eoib );
738  }
739 }
An EoIB device.
Definition: eoib.h:30
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
static void eoib_link_state_changed(struct eoib_device *eoib)
Handle link status change.
Definition: eoib.c:496
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36

References eoib_link_state_changed(), eoib_device::ibdev, eoib_device::list, and list_for_each_entry.

◆ eoib_remove()

static void eoib_remove ( struct ib_device ibdev)
static

Remove EoIB device.

Parameters
ibdevInfiniband device

Definition at line 746 of file eoib.c.

746  {
747  struct eoib_device *eoib;
748  struct eoib_device *tmp;
749 
750  /* Remove any attached EoIB devices */
751  list_for_each_entry_safe ( eoib, tmp, &eoib_devices, list ) {
752  if ( eoib->ibdev != ibdev )
753  continue;
754  eoib_destroy ( eoib );
755  }
756 }
void eoib_destroy(struct eoib_device *eoib)
Remove EoIB device.
Definition: eoib.c:695
An EoIB device.
Definition: eoib.h:30
unsigned long tmp
Definition: linux_pci.h:53
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458

References eoib_destroy(), eoib_device::ibdev, eoib_device::list, list_for_each_entry_safe, and tmp.

◆ eoib_heartbeat_rx()

static int eoib_heartbeat_rx ( struct io_buffer iobuf,
struct net_device *netdev  __unused,
const void *ll_dest  __unused,
const void *ll_source  __unused,
unsigned int flags  __unused 
)
static

Silently ignore incoming EoIB heartbeat packets.

Parameters
iobufI/O buffer
netdevNetwork device
ll_sourceLink-layer source address
flagsPacket flags
Return values
rcReturn status code

Definition at line 782 of file eoib.c.

786  {
787  free_iob ( iobuf );
788  return 0;
789 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146

References free_iob().

◆ eoib_heartbeat_ntoa()

static const char* eoib_heartbeat_ntoa ( const void *net_addr  __unused)
static

Transcribe EoIB heartbeat address.

Parameters
net_addrEoIB heartbeat address
Return values
string"<EoIB>"

This operation is meaningless for the EoIB heartbeat protocol.

Definition at line 799 of file eoib.c.

799  {
800  return "<EoIB>";
801 }

◆ eoib_duplicate()

static void eoib_duplicate ( struct eoib_device eoib,
struct io_buffer original 
)
static

Transmit duplicate packet to the EoIB gateway.

Parameters
eoibEoIB device
originalOriginal I/O buffer

Definition at line 832 of file eoib.c.

833  {
834  struct net_device *netdev = eoib->netdev;
835  struct ib_device *ibdev = eoib->ibdev;
836  struct ib_address_vector *av = &eoib->gateway;
837  size_t len = iob_len ( original );
838  struct io_buffer *copy;
839  int rc;
840 
841  /* Create copy of I/O buffer */
842  copy = alloc_iob ( len );
843  if ( ! copy ) {
844  rc = -ENOMEM;
845  goto err_alloc;
846  }
847  memcpy ( iob_put ( copy, len ), original->data, len );
848 
849  /* Append to network device's transmit queue */
850  list_add_tail ( &copy->list, &original->list );
851 
852  /* Resolve path to gateway */
853  if ( ( rc = ib_resolve_path ( ibdev, av ) ) != 0 ) {
854  DBGC ( eoib, "EoIB %s no path to gateway: %s\n",
855  eoib->name, strerror ( rc ) );
856  goto err_path;
857  }
858 
859  /* Force use of GRH even for local destinations */
860  av->gid_present = 1;
861 
862  /* Post send work queue entry */
863  if ( ( rc = ib_post_send ( eoib->ibdev, eoib->qp, av, copy ) ) != 0 )
864  goto err_post_send;
865 
866  return;
867 
868  err_post_send:
869  err_path:
870  list_del ( &copy->list );
871  err_alloc:
872  netdev_tx_err ( netdev, copy, rc );
873 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
Definition: netdevice.c:440
#define DBGC(...)
Definition: compiler.h:505
unsigned int gid_present
GID is present.
Definition: infiniband.h:90
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
const char * name
Name.
Definition: eoib.h:32
An Infiniband device.
Definition: infiniband.h:398
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
A network device.
Definition: netdevice.h:352
int ib_resolve_path(struct ib_device *ibdev, struct ib_address_vector *av)
Resolve path.
Definition: ib_pathrec.c:249
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
struct ib_address_vector gateway
Gateway (if any)
Definition: eoib.h:60
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:40
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:48
An Infiniband Address Vector.
Definition: infiniband.h:72
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
A persistent I/O buffer.
Definition: iobuf.h:33

References alloc_iob(), io_buffer::data, DBGC, ENOMEM, eoib_device::gateway, ib_address_vector::gid_present, ib_post_send(), ib_resolve_path(), eoib_device::ibdev, iob_len(), iob_put, len, io_buffer::list, list_add_tail, list_del, memcpy(), eoib_device::name, eoib_device::netdev, netdev, netdev_tx_err(), eoib_device::qp, rc, and strerror().

Referenced by eoib_set_gateway().

◆ eoib_set_gateway()

void eoib_set_gateway ( struct eoib_device eoib,
struct ib_address_vector av 
)

Set EoIB gateway.

Parameters
eoibEoIB device
avAddress vector, or NULL to clear gateway

Definition at line 881 of file eoib.c.

882  {
883 
884  if ( av ) {
885  DBGC ( eoib, "EoIB %s using gateway " IB_GID_FMT "\n",
886  eoib->name, IB_GID_ARGS ( &av->gid ) );
887  memcpy ( &eoib->gateway, av, sizeof ( eoib->gateway ) );
888  eoib->duplicate = eoib_duplicate;
889  } else {
890  DBGC ( eoib, "EoIB %s not using gateway\n", eoib->name );
891  eoib->duplicate = NULL;
892  }
893 }
#define DBGC(...)
Definition: compiler.h:505
const char * name
Name.
Definition: eoib.h:32
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
void(* duplicate)(struct eoib_device *eoib, struct io_buffer *original)
Send duplicate packet to gateway (or NULL)
Definition: eoib.h:57
static void eoib_duplicate(struct eoib_device *eoib, struct io_buffer *original)
Transmit duplicate packet to the EoIB gateway.
Definition: eoib.c:832
struct ib_address_vector gateway
Gateway (if any)
Definition: eoib.h:60
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGC, eoib_device::duplicate, eoib_duplicate(), eoib_device::gateway, ib_address_vector::gid, IB_GID_ARGS, IB_GID_FMT, memcpy(), eoib_device::name, and NULL.

Referenced by xve_update_tca().

Variable Documentation

◆ __errortab

struct errortab eoib_errors [] __errortab
Initial value:
= {
}
#define EINFO_EINPROGRESS_JOINING
Definition: eoib.c:57
#define __einfo_errortab(einfo)
Definition: errortab.h:23

Human-readable message for the link status.

Definition at line 61 of file eoib.c.

◆ eoib_operations

static struct net_device_operations eoib_operations
static
Initial value:
= {
.open = eoib_open,
.close = eoib_close,
.transmit = eoib_transmit,
.poll = eoib_poll,
}
static void eoib_poll(struct net_device *netdev)
Poll EoIB network device.
Definition: eoib.c:434
static int eoib_open(struct net_device *netdev)
Open EoIB network device.
Definition: eoib.c:528
static int eoib_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet via EoIB network device.
Definition: eoib.c:310
static void eoib_close(struct net_device *netdev)
Close EoIB network device.
Definition: eoib.c:582

EoIB network device operations.

Definition at line 68 of file eoib.c.

Referenced by eoib_create(), and eoib_discard().

◆ eoib_cq_op

struct ib_completion_queue_operations eoib_cq_op
static
Initial value:
= {
.complete_send = eoib_complete_send,
.complete_recv = eoib_complete_recv,
}
static void eoib_complete_recv(struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct ib_address_vector *dest __unused, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Handle EoIB receive completion.
Definition: eoib.c:376
static void eoib_complete_send(struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Handle EoIB send completion.
Definition: eoib.c:358

EoIB completion operations.

Definition at line 419 of file eoib.c.

Referenced by eoib_open().

◆ eoib_qp_op

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

EoIB queue pair operations.

Definition at line 425 of file eoib.c.

Referenced by eoib_open().

◆ __ib_driver

struct ib_driver eoib_driver __ib_driver
Initial value:
= {
.name = "EoIB",
.probe = eoib_probe,
.notify = eoib_notify,
.remove = eoib_remove,
}
static void eoib_notify(struct ib_device *ibdev)
Handle device or link status change.
Definition: eoib.c:730
static void eoib_remove(struct ib_device *ibdev)
Remove EoIB device.
Definition: eoib.c:746
static int eoib_probe(struct ib_device *ibdev __unused)
Probe EoIB device.
Definition: eoib.c:719

EoIB driver.

Definition at line 759 of file eoib.c.

◆ __net_protocol

struct net_protocol eoib_heartbeat_protocol __net_protocol
Initial value:
= {
.name = "EoIB",
.net_proto = htons ( EOIB_MAGIC ),
}
#define EOIB_MAGIC
EoIB magic signature.
Definition: eoib.h:27
static int eoib_heartbeat_rx(struct io_buffer *iobuf, struct net_device *netdev __unused, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
Silently ignore incoming EoIB heartbeat packets.
Definition: eoib.c:782
static const char * eoib_heartbeat_ntoa(const void *net_addr __unused)
Transcribe EoIB heartbeat address.
Definition: eoib.c:799
#define htons(value)
Definition: byteswap.h:135

EoIB heartbeat network protocol.

AoE protocol.

Definition at line 804 of file eoib.c.