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

IP over Infiniband. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/errortab.h>
#include <ipxe/malloc.h>
#include <ipxe/if_arp.h>
#include <ipxe/arp.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/ip.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_pathrec.h>
#include <ipxe/ib_mcast.h>
#include <ipxe/retry.h>
#include <ipxe/ipoib.h>

Go to the source code of this file.

Data Structures

struct  ipoib_broadcast
 An IPoIB broadcast address. More...
 
struct  ipoib_device
 An IPoIB device. More...
 
struct  ipoib_peer
 An IPoIB REMAC cache entry. More...
 

Macros

#define ENXIO_ARP_REPLY   __einfo_error ( EINFO_ENXIO_ARP_REPLY )
 
#define EINFO_ENXIO_ARP_REPLY
 
#define ENXIO_NON_IPV4   __einfo_error ( EINFO_ENXIO_NON_IPV4 )
 
#define EINFO_ENXIO_NON_IPV4
 
#define ENXIO_ARP_SENT   __einfo_error ( EINFO_ENXIO_ARP_SENT )
 
#define EINFO_ENXIO_ARP_SENT
 
#define IPOIB_NUM_SEND_WQES   8
 Number of IPoIB send work queue entries. More...
 
#define IPOIB_NUM_RECV_WQES   4
 Number of IPoIB receive work queue entries. More...
 
#define IPOIB_NUM_CQES   16
 Number of IPoIB completion 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 (ipoib_devices)
 List of all IPoIB devices. More...
 
static struct ipoib_macipoib_find_remac (struct ipoib_device *ipoib, const struct ipoib_remac *remac)
 Find IPoIB MAC from REMAC. More...
 
static int ipoib_map_remac (struct ipoib_device *ipoib, const struct ipoib_remac *remac, const struct ipoib_mac *mac)
 Add IPoIB MAC to REMAC cache. More...
 
static void ipoib_flush_remac (struct ipoib_device *ipoib)
 Flush REMAC cache. More...
 
static unsigned int ipoib_discard_remac (void)
 Discard some entries from the REMAC cache. More...
 
struct cache_discarder ipoib_discarder __cache_discarder (CACHE_EXPENSIVE)
 IPoIB cache discarder. More...
 
static void ipoib_init_addr (const void *hw_addr, void *ll_addr)
 Initialise IPoIB link-layer address. More...
 
struct net_devicealloc_ipoibdev (size_t priv_size)
 Allocate IPoIB device. More...
 
static int ipoib_translate_tx_arp (struct net_device *netdev, struct io_buffer *iobuf)
 Translate transmitted ARP packet. More...
 
static int ipoib_translate_tx (struct net_device *netdev, struct io_buffer *iobuf, uint16_t net_proto)
 Translate transmitted packet. More...
 
static int ipoib_translate_rx_arp (struct net_device *netdev, struct io_buffer *iobuf, struct ipoib_remac *remac)
 Translate received ARP packet. More...
 
static int ipoib_translate_rx (struct net_device *netdev, struct io_buffer *iobuf, struct ipoib_remac *remac, uint16_t net_proto)
 Translate received packet. More...
 
static int ipoib_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet via IPoIB network device. More...
 
static void ipoib_complete_send (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
 Handle IPoIB send completion. More...
 
static void ipoib_complete_recv (struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
 Handle IPoIB receive completion. More...
 
static struct io_bufferipoib_alloc_iob (size_t len)
 Allocate IPoIB receive I/O buffer. More...
 
static void ipoib_poll (struct net_device *netdev)
 Poll IPoIB network device. More...
 
void ipoib_join_complete (struct ib_mc_membership *membership, int rc)
 Handle IPv4 broadcast multicast group join completion. More...
 
static int ipoib_join_broadcast_group (struct ipoib_device *ipoib)
 Join IPv4 broadcast multicast group. More...
 
static void ipoib_leave_broadcast_group (struct ipoib_device *ipoib)
 Leave IPv4 broadcast multicast group. More...
 
static void ipoib_link_state_changed (struct ipoib_device *ipoib)
 Handle link status change. More...
 
static int ipoib_open (struct net_device *netdev)
 Open IPoIB network device. More...
 
static void ipoib_close (struct net_device *netdev)
 Close IPoIB network device. More...
 
static int ipoib_probe (struct ib_device *ibdev)
 Probe IPoIB device. More...
 
static void ipoib_notify (struct ib_device *ibdev)
 Handle device or link status change. More...
 
static void ipoib_remove (struct ib_device *ibdev)
 Remove IPoIB device. More...
 
struct net_deviceipoib_netdev (struct ib_device *ibdev)
 Find IPoIB network device. More...
 

Variables

static struct ipoib_mac ipoib_broadcast
 Broadcast IPoIB address. More...
 
struct errortab ipoib_errors [] __errortab
 Human-readable message for the link status. More...
 
static struct net_device_operations ipoib_operations
 IPoIB network device operations. More...
 
struct ll_protocol ipoib_protocol __ll_protocol
 IPoIB protocol. More...
 
static struct ib_completion_queue_operations ipoib_cq_op
 IPoIB completion operations. More...
 
static struct ib_queue_pair_operations ipoib_qp_op
 IPoIB queue pair operations. More...
 
struct ib_driver ipoib_driver __ib_driver
 IPoIB driver. More...
 

Detailed Description

IP over Infiniband.

Definition in file ipoib.c.

Macro Definition Documentation

◆ ENXIO_ARP_REPLY

#define ENXIO_ARP_REPLY   __einfo_error ( EINFO_ENXIO_ARP_REPLY )

Definition at line 54 of file ipoib.c.

◆ EINFO_ENXIO_ARP_REPLY

#define EINFO_ENXIO_ARP_REPLY
Value:
"Missing REMAC for ARP reply target address" )
#define EINFO_ENXIO
Definition: errno.h:600
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 55 of file ipoib.c.

◆ ENXIO_NON_IPV4

#define ENXIO_NON_IPV4   __einfo_error ( EINFO_ENXIO_NON_IPV4 )

Definition at line 58 of file ipoib.c.

◆ EINFO_ENXIO_NON_IPV4

#define EINFO_ENXIO_NON_IPV4
Value:
"Missing REMAC for non-IPv4 packet" )
#define EINFO_ENXIO
Definition: errno.h:600
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 59 of file ipoib.c.

◆ ENXIO_ARP_SENT

#define ENXIO_ARP_SENT   __einfo_error ( EINFO_ENXIO_ARP_SENT )

Definition at line 62 of file ipoib.c.

◆ EINFO_ENXIO_ARP_SENT

#define EINFO_ENXIO_ARP_SENT
Value:
"Missing REMAC for IPv4 packet (ARP sent)" )
#define EINFO_ENXIO
Definition: errno.h:600
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:180

Definition at line 63 of file ipoib.c.

◆ IPOIB_NUM_SEND_WQES

#define IPOIB_NUM_SEND_WQES   8

Number of IPoIB send work queue entries.

Definition at line 68 of file ipoib.c.

◆ IPOIB_NUM_RECV_WQES

#define IPOIB_NUM_RECV_WQES   4

Number of IPoIB receive work queue entries.

Definition at line 71 of file ipoib.c.

◆ IPOIB_NUM_CQES

#define IPOIB_NUM_CQES   16

Number of IPoIB completion entries.

Definition at line 74 of file ipoib.c.

◆ EINPROGRESS_JOINING

#define EINPROGRESS_JOINING   __einfo_error ( EINFO_EINPROGRESS_JOINING )

Link status for "broadcast join in progress".

Definition at line 114 of file ipoib.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 115 of file ipoib.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ LIST_HEAD()

static LIST_HEAD ( ipoib_devices  )
static

List of all IPoIB devices.

◆ ipoib_find_remac()

static struct ipoib_mac* ipoib_find_remac ( struct ipoib_device ipoib,
const struct ipoib_remac remac 
)
static

Find IPoIB MAC from REMAC.

Parameters
ipoibIPoIB device
remacRemote Ethernet MAC
Return values
macIPoIB MAC (or NULL if not found)

Definition at line 152 of file ipoib.c.

153  {
154  struct ipoib_peer *peer;
155 
156  /* Check for broadcast or multicast REMAC. We transmit
157  * multicasts as broadcasts for simplicity.
158  */
159  if ( is_multicast_ether_addr ( remac ) )
160  return &ipoib->broadcast.mac;
161 
162  /* Try to find via REMAC cache */
163  list_for_each_entry ( peer, &ipoib->peers, list ) {
164  if ( memcmp ( remac, &peer->remac,
165  sizeof ( peer->remac ) ) == 0 ) {
166  /* Move peer to start of list */
167  list_del ( &peer->list );
168  list_add ( &peer->list, &ipoib->peers );
169  return &peer->mac;
170  }
171  }
172 
173  DBGC ( ipoib, "IPoIB %p unknown REMAC %s\n",
174  ipoib, eth_ntoa ( remac ) );
175  return NULL;
176 }
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
#define DBGC(...)
Definition: compiler.h:505
An IPoIB REMAC cache entry.
Definition: ipoib.c:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct list_head peers
REMAC cache.
Definition: ipoib.c:103
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct ipoib_mac mac
MAC address.
Definition: ipoib.c:142
struct list_head list
List of REMAC cache entries.
Definition: ipoib.c:138
static int is_multicast_ether_addr(const void *addr)
Check if Ethernet address is a multicast address.
Definition: ethernet.h:37
struct ipoib_mac mac
MAC address.
Definition: ipoib.c:79
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
struct ipoib_remac remac
Remote Ethermet MAC.
Definition: ipoib.c:140
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References ipoib_device::broadcast, DBGC, eth_ntoa(), is_multicast_ether_addr(), ipoib_peer::list, list_add, list_del, list_for_each_entry, ipoib_peer::mac, ipoib_broadcast::mac, memcmp(), NULL, ipoib_device::peers, and ipoib_peer::remac.

Referenced by ipoib_translate_tx_arp(), and ipoib_transmit().

◆ ipoib_map_remac()

static int ipoib_map_remac ( struct ipoib_device ipoib,
const struct ipoib_remac remac,
const struct ipoib_mac mac 
)
static

Add IPoIB MAC to REMAC cache.

Parameters
ipoibIPoIB device
remacRemote Ethernet MAC
macIPoIB MAC
Return values
rcReturn status code

Definition at line 186 of file ipoib.c.

188  {
189  struct ipoib_peer *peer;
190 
191  /* Check for existing entry in REMAC cache */
192  list_for_each_entry ( peer, &ipoib->peers, list ) {
193  if ( memcmp ( remac, &peer->remac,
194  sizeof ( peer->remac ) ) == 0 ) {
195  /* Move peer to start of list */
196  list_del ( &peer->list );
197  list_add ( &peer->list, &ipoib->peers );
198  /* Update MAC */
199  memcpy ( &peer->mac, mac, sizeof ( peer->mac ) );
200  return 0;
201  }
202  }
203 
204  /* Create new entry */
205  peer = malloc ( sizeof ( *peer ) );
206  if ( ! peer )
207  return -ENOMEM;
208  memcpy ( &peer->remac, remac, sizeof ( peer->remac ) );
209  memcpy ( &peer->mac, mac, sizeof ( peer->mac ) );
210  list_add ( &peer->list, &ipoib->peers );
211 
212  return 0;
213 }
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
An IPoIB REMAC cache entry.
Definition: ipoib.c:136
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 ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct list_head peers
REMAC cache.
Definition: ipoib.c:103
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct ipoib_mac mac
MAC address.
Definition: ipoib.c:142
struct list_head list
List of REMAC cache entries.
Definition: ipoib.c:138
struct ipoib_remac remac
Remote Ethermet MAC.
Definition: ipoib.c:140
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113

References ENOMEM, ipoib_peer::list, list_add, list_del, list_for_each_entry, mac, ipoib_peer::mac, malloc(), memcmp(), memcpy(), ipoib_device::peers, and ipoib_peer::remac.

Referenced by ipoib_translate_rx_arp().

◆ ipoib_flush_remac()

static void ipoib_flush_remac ( struct ipoib_device ipoib)
static

Flush REMAC cache.

Parameters
ipoibIPoIB device

Definition at line 220 of file ipoib.c.

220  {
221  struct ipoib_peer *peer;
222  struct ipoib_peer *tmp;
223 
224  list_for_each_entry_safe ( peer, tmp, &ipoib->peers, list ) {
225  list_del ( &peer->list );
226  free ( peer );
227  }
228 }
An IPoIB REMAC cache entry.
Definition: ipoib.c:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct list_head peers
REMAC cache.
Definition: ipoib.c:103
struct list_head list
List of REMAC cache entries.
Definition: ipoib.c:138
#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:447
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
uint8_t * tmp
Definition: entropy.h:156

References free, ipoib_peer::list, list_del, list_for_each_entry_safe, ipoib_device::peers, and tmp.

Referenced by ipoib_close().

◆ ipoib_discard_remac()

static unsigned int ipoib_discard_remac ( void  )
static

Discard some entries from the REMAC cache.

Return values
discardedNumber of cached items discarded

Definition at line 235 of file ipoib.c.

235  {
236  struct net_device *netdev;
237  struct ipoib_device *ipoib;
238  struct ipoib_peer *peer;
239  unsigned int discarded = 0;
240 
241  /* Try to discard one cache entry for each IPoIB device */
242  for_each_netdev ( netdev ) {
243 
244  /* Skip non-IPoIB devices */
245  if ( netdev->op != &ipoib_operations )
246  continue;
247  ipoib = netdev->priv;
248 
249  /* Discard least recently used cache entry (if any) */
250  list_for_each_entry_reverse ( peer, &ipoib->peers, list ) {
251  list_del ( &peer->list );
252  free ( peer );
253  discarded++;
254  break;
255  }
256  }
257 
258  return discarded;
259 }
An IPoIB REMAC cache entry.
Definition: ipoib.c:136
struct net_device_operations * op
Network device operations.
Definition: netdevice.h:363
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct list_head peers
REMAC cache.
Definition: ipoib.c:103
void * priv
Driver private data.
Definition: netdevice.h:425
#define list_for_each_entry_reverse(pos, head, member)
Iterate over entries in a list in reverse order.
Definition: list.h:433
static struct net_device * netdev
Definition: gdbudp.c:52
struct list_head list
List of REMAC cache entries.
Definition: ipoib.c:138
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition: netdevice.h:526
An IPoIB device.
Definition: ipoib.c:87
A network device.
Definition: netdevice.h:348
static struct net_device_operations ipoib_operations
IPoIB network device operations.
Definition: ipoib.c:126

References for_each_netdev, free, ipoib_operations, ipoib_peer::list, list_del, list_for_each_entry_reverse, netdev, net_device::op, ipoib_device::peers, and net_device::priv.

◆ __cache_discarder()

struct cache_discarder ipoib_discarder __cache_discarder ( CACHE_EXPENSIVE  )

IPoIB cache discarder.

◆ ipoib_init_addr()

static void ipoib_init_addr ( const void *  hw_addr,
void *  ll_addr 
)
static

Initialise IPoIB link-layer address.

Parameters
hw_addrHardware address
ll_addrLink-layer address

Definition at line 279 of file ipoib.c.

279  {
280  const uint8_t *guid = hw_addr;
281  uint8_t *eth_addr = ll_addr;
282  uint8_t guid_mask = IPOIB_GUID_MASK;
283  unsigned int i;
284 
285  /* Extract bytes from GUID according to mask */
286  for ( i = 0 ; i < 8 ; i++, guid++, guid_mask <<= 1 ) {
287  if ( guid_mask & 0x80 )
288  *(eth_addr++) = *guid;
289  }
290 }
unsigned char uint8_t
Definition: stdint.h:10
#define IPOIB_GUID_MASK
GUID mask used for constructing eIPoIB Local Ethernet MAC address (LEMAC)
Definition: ipoib.h:41
uint64_t guid
GUID.
Definition: edd.h:30

References guid, and IPOIB_GUID_MASK.

◆ alloc_ipoibdev()

struct net_device* alloc_ipoibdev ( size_t  priv_size)

Allocate IPoIB device.

Parameters
priv_sizeSize of driver private data
Return values
netdevNetwork device, or NULL

Definition at line 315 of file ipoib.c.

315  {
316  struct net_device *netdev;
317 
318  netdev = alloc_netdev ( priv_size );
319  if ( netdev ) {
320  netdev->ll_protocol = &ipoib_protocol;
323  }
324  return netdev;
325 }
uint8_t eth_broadcast[ETH_ALEN]
Ethernet broadcast MAC address.
Definition: ethernet.c:47
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:383
struct net_device * alloc_netdev(size_t priv_len)
Allocate network device.
Definition: netdevice.c:622
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:348
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:403
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
#define IB_MAX_PAYLOAD_SIZE
Maximum payload size.
Definition: infiniband.h:50

References alloc_netdev(), eth_broadcast, IB_MAX_PAYLOAD_SIZE, net_device::ll_broadcast, net_device::ll_protocol, net_device::max_pkt_len, and netdev.

Referenced by ipoib_probe().

◆ ipoib_translate_tx_arp()

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

Translate transmitted ARP packet.

Parameters
netdevNetwork device
iobufPacket to be transmitted (with no link-layer headers)
Return values
rcReturn status code

Definition at line 341 of file ipoib.c.

342  {
343  struct ipoib_device *ipoib = netdev->priv;
344  struct arphdr *arphdr = iobuf->data;
345  struct ipoib_mac *target_ha = NULL;
346  void *sender_pa;
347  void *target_pa;
348 
349  /* Do nothing unless ARP contains eIPoIB link-layer addresses */
350  if ( arphdr->ar_hln != ETH_ALEN )
351  return 0;
352 
353  /* Fail unless we have room to expand packet */
354  if ( iob_tailroom ( iobuf ) < ( 2 * ( sizeof ( ipoib->mac ) -
355  ETH_ALEN ) ) ) {
356  DBGC ( ipoib, "IPoIB %p insufficient space in TX ARP\n",
357  ipoib );
358  return -ENOBUFS;
359  }
360 
361  /* Look up REMAC, if applicable */
362  if ( arphdr->ar_op == ARPOP_REPLY ) {
363  target_ha = ipoib_find_remac ( ipoib, arp_target_pa ( arphdr ));
364  if ( ! target_ha ) {
365  DBGC ( ipoib, "IPoIB %p no REMAC for %s ARP reply\n",
366  ipoib, eth_ntoa ( arp_target_pa ( arphdr ) ) );
367  return -ENXIO_ARP_REPLY;
368  }
369  }
370 
371  /* Construct new packet */
372  iob_put ( iobuf, ( 2 * ( sizeof ( ipoib->mac ) - ETH_ALEN ) ) );
373  sender_pa = arp_sender_pa ( arphdr );
374  target_pa = arp_target_pa ( arphdr );
376  arphdr->ar_hln = sizeof ( ipoib->mac );
377  memcpy ( arp_target_pa ( arphdr ), target_pa, arphdr->ar_pln );
378  memcpy ( arp_sender_pa ( arphdr ), sender_pa, arphdr->ar_pln );
379  memcpy ( arp_sender_ha ( arphdr ), &ipoib->mac, sizeof ( ipoib->mac ) );
380  memset ( arp_target_ha ( arphdr ), 0, sizeof ( ipoib->mac ) );
381  if ( target_ha ) {
382  memcpy ( arp_target_ha ( arphdr ), target_ha,
383  sizeof ( *target_ha ) );
384  }
385 
386  return 0;
387 }
static void * arp_sender_pa(struct arphdr *arphdr)
ARP packet sender protocol address.
Definition: if_arp.h:80
#define iob_put(iobuf, len)
Definition: iobuf.h:116
static void * arp_target_ha(struct arphdr *arphdr)
ARP packet target hardware address.
Definition: if_arp.h:89
static void * arp_target_pa(struct arphdr *arphdr)
ARP packet target protocol address.
Definition: if_arp.h:98
#define DBGC(...)
Definition: compiler.h:505
uint8_t ar_hln
Link-layer address length.
Definition: if_arp.h:59
uint16_t ar_hrd
Link-layer protocol.
Definition: if_arp.h:52
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define ARPHRD_INFINIBAND
InfiniBand.
Definition: if_arp.h:29
An ARP header.
Definition: if_arp.h:47
#define ENXIO_ARP_REPLY
Definition: ipoib.c:54
uint16_t ar_op
ARP opcode.
Definition: if_arp.h:63
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
An IPoIB device.
Definition: ipoib.c:87
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
#define ARPOP_REPLY
ARP reply.
Definition: if_arp.h:33
#define ETH_ALEN
Definition: if_ether.h:8
static void * arp_sender_ha(struct arphdr *arphdr)
ARP packet sender hardware address.
Definition: if_arp.h:71
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
void * data
Start of data.
Definition: iobuf.h:44
An IPoIB MAC address.
Definition: ipoib.h:18
uint8_t ar_pln
Network-layer address length.
Definition: if_arp.h:61
static struct ipoib_mac * ipoib_find_remac(struct ipoib_device *ipoib, const struct ipoib_remac *remac)
Find IPoIB MAC from REMAC.
Definition: ipoib.c:152
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull

References arphdr::ar_hln, arphdr::ar_hrd, arphdr::ar_op, arphdr::ar_pln, arp_sender_ha(), arp_sender_pa(), arp_target_ha(), arp_target_pa(), ARPHRD_INFINIBAND, ARPOP_REPLY, io_buffer::data, DBGC, ENOBUFS, ENXIO_ARP_REPLY, ETH_ALEN, eth_ntoa(), htons, iob_put, iob_tailroom(), ipoib_find_remac(), ipoib_device::mac, memcpy(), memset(), netdev, NULL, and net_device::priv.

Referenced by ipoib_translate_tx().

◆ ipoib_translate_tx()

static int ipoib_translate_tx ( struct net_device netdev,
struct io_buffer iobuf,
uint16_t  net_proto 
)
static

Translate transmitted packet.

Parameters
netdevNetwork device
iobufPacket to be transmitted (with no link-layer headers)
net_protoNetwork-layer protocol (in network byte order)
Return values
rcReturn status code

Definition at line 397 of file ipoib.c.

398  {
399 
400  switch ( net_proto ) {
401  case htons ( ETH_P_ARP ) :
403  case htons ( ETH_P_IP ) :
404  /* No translation needed */
405  return 0;
406  default:
407  /* Cannot handle other traffic via eIPoIB */
408  return -ENOTSUP;
409  }
410 }
#define ETH_P_IP
Definition: if_ether.h:18
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static struct net_device * netdev
Definition: gdbudp.c:52
static int ipoib_translate_tx_arp(struct net_device *netdev, struct io_buffer *iobuf)
Translate transmitted ARP packet.
Definition: ipoib.c:341
return
Definition: natsemi.h:326
#define ETH_P_ARP
Definition: if_ether.h:19
#define htons(value)
Definition: byteswap.h:135

References ENOTSUP, ETH_P_ARP, ETH_P_IP, htons, ipoib_translate_tx_arp(), and netdev.

Referenced by ipoib_transmit().

◆ ipoib_translate_rx_arp()

static int ipoib_translate_rx_arp ( struct net_device netdev,
struct io_buffer iobuf,
struct ipoib_remac remac 
)
static

Translate received ARP packet.

Parameters
netdevNetwork device
iobufReceived packet (with no link-layer headers)
remacConstructed Remote Ethernet MAC
Return values
rcReturn status code

Definition at line 420 of file ipoib.c.

422  {
423  struct ipoib_device *ipoib = netdev->priv;
424  struct arphdr *arphdr = iobuf->data;
425  void *sender_pa;
426  void *target_pa;
427  int rc;
428 
429  /* Do nothing unless ARP contains IPoIB link-layer addresses */
430  if ( arphdr->ar_hln != sizeof ( ipoib->mac ) )
431  return 0;
432 
433  /* Create REMAC cache entry */
434  if ( ( rc = ipoib_map_remac ( ipoib, remac,
435  arp_sender_ha ( arphdr ) ) ) != 0 ) {
436  DBGC ( ipoib, "IPoIB %p could not map REMAC: %s\n",
437  ipoib, strerror ( rc ) );
438  return rc;
439  }
440 
441  /* Construct new packet */
442  sender_pa = arp_sender_pa ( arphdr );
443  target_pa = arp_target_pa ( arphdr );
446  memcpy ( arp_sender_pa ( arphdr ), sender_pa, arphdr->ar_pln );
447  memcpy ( arp_target_pa ( arphdr ), target_pa, arphdr->ar_pln );
448  memcpy ( arp_sender_ha ( arphdr ), remac, ETH_ALEN );
449  memset ( arp_target_ha ( arphdr ), 0, ETH_ALEN );
450  if ( arphdr->ar_op == ARPOP_REPLY ) {
451  /* Assume received replies were directed to us */
453  }
454  iob_unput ( iobuf, ( 2 * ( sizeof ( ipoib->mac ) - ETH_ALEN ) ) );
455 
456  return 0;
457 }
static void * arp_sender_pa(struct arphdr *arphdr)
ARP packet sender protocol address.
Definition: if_arp.h:80
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void * arp_target_ha(struct arphdr *arphdr)
ARP packet target hardware address.
Definition: if_arp.h:89
static void * arp_target_pa(struct arphdr *arphdr)
ARP packet target protocol address.
Definition: if_arp.h:98
#define DBGC(...)
Definition: compiler.h:505
uint8_t ar_hln
Link-layer address length.
Definition: if_arp.h:59
uint16_t ar_hrd
Link-layer protocol.
Definition: if_arp.h:52
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
An ARP header.
Definition: if_arp.h:47
#define iob_unput(iobuf, len)
Definition: iobuf.h:131
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint16_t ar_op
ARP opcode.
Definition: if_arp.h:63
An IPoIB device.
Definition: ipoib.c:87
#define ARPOP_REPLY
ARP reply.
Definition: if_arp.h:33
#define ETH_ALEN
Definition: if_ether.h:8
static void * arp_sender_ha(struct arphdr *arphdr)
ARP packet sender hardware address.
Definition: if_arp.h:71
void * data
Start of data.
Definition: iobuf.h:44
uint8_t ar_pln
Network-layer address length.
Definition: if_arp.h:61
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define ARPHRD_ETHER
Ethernet 10Mbps.
Definition: if_arp.h:16
static int ipoib_map_remac(struct ipoib_device *ipoib, const struct ipoib_remac *remac, const struct ipoib_mac *mac)
Add IPoIB MAC to REMAC cache.
Definition: ipoib.c:186
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull

References arphdr::ar_hln, arphdr::ar_hrd, arphdr::ar_op, arphdr::ar_pln, arp_sender_ha(), arp_sender_pa(), arp_target_ha(), arp_target_pa(), ARPHRD_ETHER, ARPOP_REPLY, io_buffer::data, DBGC, ETH_ALEN, htons, iob_unput, ipoib_map_remac(), net_device::ll_addr, ipoib_device::mac, memcpy(), memset(), netdev, net_device::priv, rc, and strerror().

Referenced by ipoib_translate_rx().

◆ ipoib_translate_rx()

static int ipoib_translate_rx ( struct net_device netdev,
struct io_buffer iobuf,
struct ipoib_remac remac,
uint16_t  net_proto 
)
static

Translate received packet.

Parameters
netdevNetwork device
iobufReceived packet (with no link-layer headers)
remacConstructed Remote Ethernet MAC
net_protoNetwork-layer protocol (in network byte order)
Return values
rcReturn status code

Definition at line 468 of file ipoib.c.

471  {
472 
473  switch ( net_proto ) {
474  case htons ( ETH_P_ARP ) :
475  return ipoib_translate_rx_arp ( netdev, iobuf, remac );
476  case htons ( ETH_P_IP ) :
477  /* No translation needed */
478  return 0;
479  default:
480  /* Cannot handle other traffic via eIPoIB */
481  return -ENOTSUP;
482  }
483 }
#define ETH_P_IP
Definition: if_ether.h:18
static int ipoib_translate_rx_arp(struct net_device *netdev, struct io_buffer *iobuf, struct ipoib_remac *remac)
Translate received ARP packet.
Definition: ipoib.c:420
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static struct net_device * netdev
Definition: gdbudp.c:52
return
Definition: natsemi.h:326
#define ETH_P_ARP
Definition: if_ether.h:19
#define htons(value)
Definition: byteswap.h:135

References ENOTSUP, ETH_P_ARP, ETH_P_IP, htons, ipoib_translate_rx_arp(), and netdev.

Referenced by ipoib_complete_recv().

◆ ipoib_transmit()

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

Transmit packet via IPoIB network device.

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

Definition at line 499 of file ipoib.c.

500  {
501  struct ipoib_device *ipoib = netdev->priv;
502  struct ib_device *ibdev = ipoib->ibdev;
503  struct ethhdr *ethhdr;
504  struct iphdr *iphdr;
505  struct ipoib_hdr *ipoib_hdr;
506  struct ipoib_remac *remac;
507  struct ipoib_mac *mac;
508  struct ib_address_vector *dest;
509  struct ib_address_vector av;
510  uint16_t net_proto;
511  int rc;
512 
513  /* Sanity check */
514  if ( iob_len ( iobuf ) < sizeof ( *ethhdr ) ) {
515  DBGC ( ipoib, "IPoIB %p buffer too short\n", ipoib );
516  return -EINVAL;
517  }
518 
519  /* Attempting transmission while link is down will put the
520  * queue pair into an error state, so don't try it.
521  */
522  if ( ! ib_link_ok ( ibdev ) )
523  return -ENETUNREACH;
524 
525  /* Strip eIPoIB header */
526  ethhdr = iobuf->data;
527  remac = ( ( struct ipoib_remac * ) ethhdr->h_dest );
528  net_proto = ethhdr->h_protocol;
529  iob_pull ( iobuf, sizeof ( *ethhdr ) );
530 
531  /* Identify destination address */
532  if ( is_multicast_ether_addr ( remac ) ) {
533 
534  /* Transmit multicasts as broadcasts, for simplicity */
535  dest = &ipoib->broadcast.av;
536 
537  } else if ( ( mac = ipoib_find_remac ( ipoib, remac ) ) ) {
538 
539  /* Construct address vector from IPoIB MAC */
540  dest = &av;
541  memset ( dest, 0, sizeof ( *dest ) );
542  dest->qpn = ( ntohl ( mac->flags__qpn ) & IB_QPN_MASK );
543  dest->qkey = ipoib->broadcast.av.qkey;
544  dest->gid_present = 1;
545  memcpy ( &dest->gid, &mac->gid, sizeof ( dest->gid ) );
546  if ( ( rc = ib_resolve_path ( ibdev, dest ) ) != 0 ) {
547  /* Path not resolved yet */
548  return rc;
549  }
550 
551  } else {
552 
553  /* Generate a new ARP request (if possible) to trigger
554  * population of the REMAC cache entry.
555  */
556  if ( ( net_proto != htons ( ETH_P_IP ) ) ||
557  ( iob_len ( iobuf ) < sizeof ( *iphdr ) ) ) {
558  DBGC ( ipoib, "IPoIB %p no REMAC for %s non-IPv4 "
559  "packet type %04x\n", ipoib,
560  eth_ntoa ( ethhdr->h_dest ),
561  ntohs ( net_proto ) );
562  return -ENXIO_NON_IPV4;
563  }
564  iphdr = iobuf->data;
565  if ( ( rc = arp_tx_request ( netdev, &ipv4_protocol,
566  &iphdr->dest, &iphdr->src ) ) !=0){
567  DBGC ( ipoib, "IPoIB %p could not ARP for %s/%s/",
568  ipoib, eth_ntoa ( ethhdr->h_dest ),
569  inet_ntoa ( iphdr->dest ) );
570  DBGC ( ipoib, "%s: %s\n", inet_ntoa ( iphdr->src ),
571  strerror ( rc ) );
572  return rc;
573  }
574  DBGC ( ipoib, "IPoIB %p no REMAC for %s/%s/", ipoib,
575  eth_ntoa ( ethhdr->h_dest ), inet_ntoa ( iphdr->dest ) );
576  DBGC ( ipoib, "%s\n", inet_ntoa ( iphdr->src ) );
577  return -ENXIO_ARP_SENT;
578  }
579 
580  /* Translate packet if applicable */
581  if ( ( rc = ipoib_translate_tx ( netdev, iobuf, net_proto ) ) != 0 )
582  return rc;
583 
584  /* Prepend real IPoIB header */
585  ipoib_hdr = iob_push ( iobuf, sizeof ( *ipoib_hdr ) );
586  ipoib_hdr->proto = net_proto;
587  ipoib_hdr->reserved = 0;
588 
589  /* Transmit packet */
590  return ib_post_send ( ibdev, ipoib->qp, dest, iobuf );
591 }
uint16_t h_protocol
Protocol ID.
Definition: if_ether.h:36
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
static __always_inline int ib_link_ok(struct ib_device *ibdev)
Check link state of Infiniband device.
Definition: infiniband.h:564
struct in_addr src
Definition: ip.h:44
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
#define iob_push(iobuf, len)
Definition: iobuf.h:80
#define ETH_P_IP
Definition: if_ether.h:18
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
#define DBGC(...)
Definition: compiler.h:505
#define ENXIO_NON_IPV4
Definition: ipoib.c:58
#define ntohl(value)
Definition: byteswap.h:134
#define ENXIO_ARP_SENT
Definition: ipoib.c:62
#define ntohs(value)
Definition: byteswap.h:136
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
An IPv4 packet header.
Definition: ip.h:35
An Infiniband device.
Definition: infiniband.h:398
uint8_t h_dest[ETH_ALEN]
Destination MAC address.
Definition: if_ether.h:32
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned long qkey
Queue key.
Definition: infiniband.h:79
uint16_t reserved
Reserved, must be zero.
Definition: ipoib.h:37
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static int is_multicast_ether_addr(const void *addr)
Check if Ethernet address is a multicast address.
Definition: ethernet.h:37
static void * dest
Definition: strings.h:176
int arp_tx_request(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
Transmit ARP request.
Definition: arp.c:59
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:151
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
An IPoIB device.
Definition: ipoib.c:87
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
Definition: ipv4.c:658
struct in_addr dest
Definition: ip.h:45
int ib_resolve_path(struct ib_device *ibdev, struct ib_address_vector *av)
Resolve path.
Definition: ib_pathrec.c:249
uint16_t proto
Network-layer protocol.
Definition: ipoib.h:35
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 ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
void * data
Start of data.
Definition: iobuf.h:44
eIPoIB Remote Ethernet MAC address
Definition: ipoib.h:48
An IPoIB MAC address.
Definition: ipoib.h:18
IPoIB link-layer header.
Definition: ipoib.h:33
An Infiniband Address Vector.
Definition: infiniband.h:72
static struct ipoib_mac * ipoib_find_remac(struct ipoib_device *ipoib, const struct ipoib_remac *remac)
Find IPoIB MAC from REMAC.
Definition: ipoib.c:152
static int ipoib_translate_tx(struct net_device *netdev, struct io_buffer *iobuf, uint16_t net_proto)
Translate transmitted packet.
Definition: ipoib.c:397
#define ENETUNREACH
Network unreachable.
Definition: errno.h:488
An Ethernet link-layer header.
Definition: if_ether.h:30
struct ib_address_vector av
Address vector.
Definition: ipoib.c:81
#define htons(value)
Definition: byteswap.h:135
#define IB_QPN_MASK
QPN mask.
Definition: infiniband.h:36
void * memset(void *dest, int character, size_t len) __nonnull

References arp_tx_request(), ipoib_broadcast::av, ipoib_device::broadcast, io_buffer::data, DBGC, iphdr::dest, dest, EINVAL, ENETUNREACH, ENXIO_ARP_SENT, ENXIO_NON_IPV4, eth_ntoa(), ETH_P_IP, ethhdr::h_dest, ethhdr::h_protocol, htons, ib_link_ok(), ib_post_send(), IB_QPN_MASK, ib_resolve_path(), ipoib_device::ibdev, inet_ntoa(), iob_len(), iob_pull, iob_push, ipoib_find_remac(), ipoib_translate_tx(), is_multicast_ether_addr(), mac, memcpy(), memset(), netdev, ntohl, ntohs, net_device::priv, ipoib_hdr::proto, ib_address_vector::qkey, ipoib_device::qp, rc, ipoib_hdr::reserved, iphdr::src, and strerror().

◆ ipoib_complete_send()

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

Handle IPoIB send completion.

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

Definition at line 601 of file ipoib.c.

603  {
604  struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );
605 
606  netdev_tx_complete_err ( ipoib->netdev, iobuf, rc );
607 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:663
An IPoIB device.
Definition: ipoib.c:87
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
struct net_device * netdev
Network device.
Definition: ipoib.c:89

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

◆ ipoib_complete_recv()

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

Handle IPoIB 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 619 of file ipoib.c.

623  {
624  struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );
625  struct net_device *netdev = ipoib->netdev;
626  struct ipoib_hdr *ipoib_hdr;
627  struct ethhdr *ethhdr;
628  struct ipoib_remac remac;
629  uint16_t net_proto;
630 
631  /* Record errors */
632  if ( rc != 0 ) {
633  netdev_rx_err ( netdev, iobuf, rc );
634  return;
635  }
636 
637  /* Sanity check */
638  if ( iob_len ( iobuf ) < sizeof ( struct ipoib_hdr ) ) {
639  DBGC ( ipoib, "IPoIB %p received packet too short to "
640  "contain IPoIB header\n", ipoib );
641  DBGC_HD ( ipoib, iobuf->data, iob_len ( iobuf ) );
642  netdev_rx_err ( netdev, iobuf, -EIO );
643  return;
644  }
645  if ( ! source ) {
646  DBGC ( ipoib, "IPoIB %p received packet without address "
647  "vector\n", ipoib );
648  netdev_rx_err ( netdev, iobuf, -ENOTTY );
649  return;
650  }
651 
652  /* Strip real IPoIB header */
653  ipoib_hdr = iobuf->data;
654  net_proto = ipoib_hdr->proto;
655  iob_pull ( iobuf, sizeof ( *ipoib_hdr ) );
656 
657  /* Construct source address from remote QPN and LID */
658  remac.qpn = htonl ( source->qpn | EIPOIB_QPN_LA );
659  remac.lid = htons ( source->lid );
660 
661  /* Translate packet if applicable */
662  if ( ( rc = ipoib_translate_rx ( netdev, iobuf, &remac,
663  net_proto ) ) != 0 ) {
664  netdev_rx_err ( netdev, iobuf, rc );
665  return;
666  }
667 
668  /* Prepend eIPoIB header */
669  ethhdr = iob_push ( iobuf, sizeof ( *ethhdr ) );
670  memcpy ( &ethhdr->h_source, &remac, sizeof ( ethhdr->h_source ) );
671  ethhdr->h_protocol = net_proto;
672 
673  /* Construct destination address */
674  if ( dest->gid_present && IB_GID_MULTICAST ( &dest->gid ) ) {
675  /* Multicast GID: use the Ethernet broadcast address */
677  sizeof ( ethhdr->h_dest ) );
678  } else {
679  /* Assume destination address is local Ethernet MAC */
681  sizeof ( ethhdr->h_dest ) );
682  }
683 
684  /* Hand off to network layer */
685  netdev_rx ( netdev, iobuf );
686 }
uint16_t h_protocol
Protocol ID.
Definition: if_ether.h:36
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
#define iob_push(iobuf, len)
Definition: iobuf.h:80
uint8_t eth_broadcast[ETH_ALEN]
Ethernet broadcast MAC address.
Definition: ethernet.c:47
#define DBGC(...)
Definition: compiler.h:505
#define EIPOIB_QPN_LA
eIPoIB REMAC locally-assigned address indicator
Definition: ipoib.h:61
#define htonl(value)
Definition: byteswap.h:133
uint8_t h_dest[ETH_ALEN]
Destination MAC address.
Definition: if_ether.h:32
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
#define IB_GID_MULTICAST(gid)
Test for multicast GID.
Definition: ib_packet.h:52
static void * dest
Definition: strings.h:176
static __always_inline void * ib_qp_get_ownerdata(struct ib_queue_pair *qp)
Get Infiniband queue pair owner-private data.
Definition: infiniband.h:663
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
An IPoIB device.
Definition: ipoib.c:87
#define DBGC_HD(...)
Definition: compiler.h:507
A network device.
Definition: netdevice.h:348
uint8_t h_source[ETH_ALEN]
Source MAC address.
Definition: if_ether.h:34
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
uint16_t proto
Network-layer protocol.
Definition: ipoib.h:35
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:44
eIPoIB Remote Ethernet MAC address
Definition: ipoib.h:48
#define EIO
Input/output error.
Definition: errno.h:433
IPoIB link-layer header.
Definition: ipoib.h:33
unsigned int lid
Local ID.
Definition: infiniband.h:81
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
static int ipoib_translate_rx(struct net_device *netdev, struct io_buffer *iobuf, struct ipoib_remac *remac, uint16_t net_proto)
Translate received packet.
Definition: ipoib.c:468
An Ethernet link-layer header.
Definition: if_ether.h:30
#define htons(value)
Definition: byteswap.h:135
struct net_device * netdev
Network device.
Definition: ipoib.c:89

References io_buffer::data, DBGC, DBGC_HD, dest, EIO, EIPOIB_QPN_LA, ENOTTY, eth_broadcast, ethhdr::h_dest, ethhdr::h_protocol, ethhdr::h_source, htonl, htons, IB_GID_MULTICAST, ib_qp_get_ownerdata(), iob_len(), iob_pull, iob_push, ipoib_translate_rx(), ipoib_remac::lid, ib_address_vector::lid, net_device::ll_addr, memcpy(), netdev, ipoib_device::netdev, netdev_rx(), netdev_rx_err(), ipoib_hdr::proto, qp, ipoib_remac::qpn, ib_address_vector::qpn, and rc.

◆ ipoib_alloc_iob()

static struct io_buffer* ipoib_alloc_iob ( size_t  len)
static

Allocate IPoIB receive I/O buffer.

Parameters
lenLength of buffer
Return values
iobufI/O buffer, or NULL

Some Infiniband hardware requires 2kB alignment of receive buffers and provides no way to disable header separation. The result is that there are only four bytes of link-layer header (the real IPoIB header) before the payload. This is not sufficient space to insert an eIPoIB link-layer pseudo-header.

We therefore allocate I/O buffers offset to start slightly before the natural alignment boundary, in order to allow sufficient space.

Definition at line 709 of file ipoib.c.

709  {
710  struct io_buffer *iobuf;
711  size_t reserve_len;
712 
713  /* Calculate additional length required at start of buffer */
714  reserve_len = ( sizeof ( struct ethhdr ) -
715  sizeof ( struct ipoib_hdr ) );
716 
717  /* Allocate buffer */
718  iobuf = alloc_iob_raw ( ( len + reserve_len ), len, -reserve_len );
719  if ( iobuf ) {
720  iob_reserve ( iobuf, reserve_len );
721  }
722  return iobuf;
723 }
struct io_buffer * alloc_iob_raw(size_t len, size_t align, size_t offset)
Allocate I/O buffer with specified alignment and offset.
Definition: iobuf.c:48
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
uint32_t len
Length.
Definition: ena.h:14
IPoIB link-layer header.
Definition: ipoib.h:33
An Ethernet link-layer header.
Definition: if_ether.h:30
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob_raw(), iob_reserve, and len.

◆ ipoib_poll()

static void ipoib_poll ( struct net_device netdev)
static

Poll IPoIB network device.

Parameters
netdevNetwork device

Definition at line 735 of file ipoib.c.

735  {
736  struct ipoib_device *ipoib = netdev->priv;
737  struct ib_device *ibdev = ipoib->ibdev;
738 
739  /* Poll Infiniband device */
740  ib_poll_eq ( ibdev );
741 
742  /* Poll the retry timers (required for IPoIB multicast join) */
743  retry_poll();
744 }
void ib_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: infiniband.c:898
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
An Infiniband device.
Definition: infiniband.h:398
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
An IPoIB device.
Definition: ipoib.c:87
void retry_poll(void)
Poll the retry timer list.
Definition: retry.c:197

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

◆ ipoib_join_complete()

void ipoib_join_complete ( struct ib_mc_membership membership,
int  rc 
)

Handle IPv4 broadcast multicast group join completion.

Parameters
membershipMulticast group membership
rcStatus code

Definition at line 752 of file ipoib.c.

752  {
753  struct ipoib_device *ipoib = container_of ( membership,
754  struct ipoib_device,
756 
757  /* Record join status as link status */
758  netdev_link_err ( ipoib->netdev, rc );
759 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An IPoIB device.
Definition: ipoib.c:87
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
Definition: netdevice.c:163
struct ib_mc_membership membership
Multicast group membership.
Definition: ipoib.c:83
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
struct net_device * netdev
Network device.
Definition: ipoib.c:89

References ipoib_device::broadcast, container_of, ipoib_broadcast::membership, ipoib_device::netdev, netdev_link_err(), and rc.

Referenced by ipoib_join_broadcast_group().

◆ ipoib_join_broadcast_group()

static int ipoib_join_broadcast_group ( struct ipoib_device ipoib)
static

Join IPv4 broadcast multicast group.

Parameters
ipoibIPoIB device
Return values
rcReturn status code

Definition at line 767 of file ipoib.c.

767  {
768  int rc;
769 
770  /* Join multicast group */
771  if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qp,
772  &ipoib->broadcast.membership,
773  &ipoib->broadcast.av, 0,
774  ipoib_join_complete ) ) != 0 ) {
775  DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
776  ipoib, strerror ( rc ) );
777  return rc;
778  }
779 
780  return 0;
781 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void ipoib_join_complete(struct ib_mc_membership *membership, int rc)
Handle IPv4 broadcast multicast group join completion.
Definition: ipoib.c:752
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
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
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_mc_membership membership
Multicast group membership.
Definition: ipoib.c:83
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
struct ib_address_vector av
Address vector.
Definition: ipoib.c:81

References ipoib_broadcast::av, ipoib_device::broadcast, DBGC, ib_mcast_join(), ipoib_device::ibdev, ipoib_join_complete(), ipoib_broadcast::membership, ipoib_device::qp, rc, and strerror().

Referenced by ipoib_link_state_changed().

◆ ipoib_leave_broadcast_group()

static void ipoib_leave_broadcast_group ( struct ipoib_device ipoib)
static

Leave IPv4 broadcast multicast group.

Parameters
ipoibIPoIB device

Definition at line 788 of file ipoib.c.

788  {
789 
790  /* Leave multicast group */
791  ib_mcast_leave ( ipoib->ibdev, ipoib->qp,
792  &ipoib->broadcast.membership );
793 }
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
struct ib_mc_membership membership
Multicast group membership.
Definition: ipoib.c:83
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
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 ipoib_device::broadcast, ib_mcast_leave(), ipoib_device::ibdev, ipoib_broadcast::membership, and ipoib_device::qp.

Referenced by ipoib_close(), and ipoib_link_state_changed().

◆ ipoib_link_state_changed()

static void ipoib_link_state_changed ( struct ipoib_device ipoib)
static

Handle link status change.

Parameters
ipoibIPoIB device

Definition at line 800 of file ipoib.c.

800  {
801  struct ib_device *ibdev = ipoib->ibdev;
802  struct net_device *netdev = ipoib->netdev;
803  int rc;
804 
805  /* Leave existing broadcast group */
806  if ( ipoib->qp )
807  ipoib_leave_broadcast_group ( ipoib );
808 
809  /* Update MAC address based on potentially-new GID prefix */
810  memcpy ( &ipoib->mac.gid.s.prefix, &ibdev->gid.s.prefix,
811  sizeof ( ipoib->mac.gid.s.prefix ) );
812 
813  /* Update broadcast MAC GID based on potentially-new partition key */
814  ipoib->broadcast.mac.gid.words[2] =
815  htons ( ibdev->pkey | IB_PKEY_FULL );
816 
817  /* Construct broadcast address vector from broadcast MAC address */
818  memset ( &ipoib->broadcast.av, 0, sizeof ( ipoib->broadcast.av ) );
819  ipoib->broadcast.av.qpn = IB_QPN_BROADCAST;
820  ipoib->broadcast.av.gid_present = 1;
821  memcpy ( &ipoib->broadcast.av.gid, &ipoib->broadcast.mac.gid,
822  sizeof ( ipoib->broadcast.av.gid ) );
823 
824  /* Set net device link state to reflect Infiniband link state */
825  rc = ib_link_rc ( ibdev );
827 
828  /* Join new broadcast group */
829  if ( ib_is_open ( ibdev ) && ib_link_ok ( ibdev ) && ipoib->qp &&
830  ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
831  DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
832  "%s\n", ipoib, strerror ( rc ) );
834  return;
835  }
836 }
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:564
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
static int ib_is_open(struct ib_device *ibdev)
Check whether or not Infiniband device is open.
Definition: infiniband.h:575
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
#define IB_PKEY_FULL
Infiniband partition key full membership flag.
Definition: infiniband.h:42
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
#define DBGC(...)
Definition: compiler.h:505
unsigned int gid_present
GID is present.
Definition: infiniband.h:90
An Infiniband device.
Definition: infiniband.h:398
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
struct ipoib_mac mac
MAC address.
Definition: ipoib.c:79
static void ipoib_leave_broadcast_group(struct ipoib_device *ipoib)
Leave IPv4 broadcast multicast group.
Definition: ipoib.c:788
#define IB_QPN_BROADCAST
Broadcast QPN.
Definition: infiniband.h:33
union ib_guid prefix
Definition: ib_packet.h:39
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:348
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
Definition: netdevice.c:163
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
#define EINPROGRESS_JOINING
Link status for "broadcast join in progress".
Definition: ipoib.c:114
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
static int ipoib_join_broadcast_group(struct ipoib_device *ipoib)
Join IPv4 broadcast multicast group.
Definition: ipoib.c:767
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
uint16_t pkey
Partition key.
Definition: infiniband.h:447
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
struct ib_address_vector av
Address vector.
Definition: ipoib.c:81
#define htons(value)
Definition: byteswap.h:135
union ib_gid gid
Port GID.
Definition: ipoib.h:26
void * memset(void *dest, int character, size_t len) __nonnull
struct net_device * netdev
Network device.
Definition: ipoib.c:89
struct ib_gid::@532 s

References ipoib_broadcast::av, ipoib_device::broadcast, DBGC, EINPROGRESS_JOINING, ipoib_mac::gid, ib_address_vector::gid, ib_device::gid, ib_address_vector::gid_present, htons, ib_is_open(), ib_link_ok(), ib_link_rc(), IB_PKEY_FULL, IB_QPN_BROADCAST, ipoib_device::ibdev, ipoib_join_broadcast_group(), ipoib_leave_broadcast_group(), ipoib_device::mac, ipoib_broadcast::mac, memcpy(), memset(), netdev, ipoib_device::netdev, netdev_link_err(), ib_device::pkey, ib_gid::prefix, ipoib_device::qp, ib_address_vector::qpn, rc, ib_gid::s, strerror(), and ib_gid::words.

Referenced by ipoib_notify(), and ipoib_open().

◆ ipoib_open()

static int ipoib_open ( struct net_device netdev)
static

Open IPoIB network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 844 of file ipoib.c.

844  {
845  struct ipoib_device *ipoib = netdev->priv;
846  struct ib_device *ibdev = ipoib->ibdev;
847  int rc;
848 
849  /* Open IB device */
850  if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
851  DBGC ( ipoib, "IPoIB %p could not open device: %s\n",
852  ipoib, strerror ( rc ) );
853  goto err_ib_open;
854  }
855 
856  /* Allocate completion queue */
857  if ( ( rc = ib_create_cq ( ibdev, IPOIB_NUM_CQES, &ipoib_cq_op,
858  &ipoib->cq ) ) != 0 ) {
859  DBGC ( ipoib, "IPoIB %p could not create completion queue: "
860  "%s\n", ipoib, strerror ( rc ) );
861  goto err_create_cq;
862  }
863 
864  /* Allocate queue pair */
865  if ( ( rc = ib_create_qp ( ibdev, IB_QPT_UD, IPOIB_NUM_SEND_WQES,
866  ipoib->cq, IPOIB_NUM_RECV_WQES, ipoib->cq,
868  &ipoib->qp ) ) != 0 ) {
869  DBGC ( ipoib, "IPoIB %p could not create queue pair: %s\n",
870  ipoib, strerror ( rc ) );
871  goto err_create_qp;
872  }
873  ib_qp_set_ownerdata ( ipoib->qp, ipoib );
874 
875  /* Update MAC address with QPN */
876  ipoib->mac.flags__qpn = htonl ( ipoib->qp->qpn );
877 
878  /* Fill receive rings */
879  ib_refill_recv ( ibdev, ipoib->qp );
880 
881  /* Fake a link status change to join the broadcast group */
882  ipoib_link_state_changed ( ipoib );
883 
884  return 0;
885 
886  ib_destroy_qp ( ibdev, ipoib->qp );
887  err_create_qp:
888  ib_destroy_cq ( ibdev, ipoib->cq );
889  err_create_cq:
890  ib_close ( ibdev );
891  err_ib_open:
892  return rc;
893 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
static void ipoib_link_state_changed(struct ipoib_device *ipoib)
Handle link status change.
Definition: ipoib.c:800
#define IPOIB_NUM_RECV_WQES
Number of IPoIB receive work queue entries.
Definition: ipoib.c:71
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
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 htonl(value)
Definition: byteswap.h:133
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:425
unsigned long qpn
Queue pair number.
Definition: infiniband.h:165
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
An IPoIB device.
Definition: ipoib.c:87
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
uint32_t flags__qpn
Queue pair number.
Definition: ipoib.h:24
static struct ib_completion_queue_operations ipoib_cq_op
IPoIB completion operations.
Definition: ipoib.c:689
#define IPOIB_NUM_CQES
Number of IPoIB completion entries.
Definition: ipoib.c:74
#define IPOIB_NUM_SEND_WQES
Number of IPoIB send work queue entries.
Definition: ipoib.c:68
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
static struct ib_queue_pair_operations ipoib_qp_op
IPoIB queue pair operations.
Definition: ipoib.c:726
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
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
struct ib_completion_queue * cq
Completion queue.
Definition: ipoib.c:95

References ipoib_device::cq, DBGC, ipoib_mac::flags__qpn, htonl, 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(), ipoib_device::ibdev, ipoib_cq_op, ipoib_link_state_changed(), IPOIB_NUM_CQES, IPOIB_NUM_RECV_WQES, IPOIB_NUM_SEND_WQES, ipoib_qp_op, ipoib_device::mac, net_device::name, netdev, net_device::priv, ipoib_device::qp, ib_queue_pair::qpn, rc, and strerror().

◆ ipoib_close()

static void ipoib_close ( struct net_device netdev)
static

Close IPoIB network device.

Parameters
netdevNetwork device

Definition at line 900 of file ipoib.c.

900  {
901  struct ipoib_device *ipoib = netdev->priv;
902  struct ib_device *ibdev = ipoib->ibdev;
903 
904  /* Flush REMAC cache */
905  ipoib_flush_remac ( ipoib );
906 
907  /* Leave broadcast group */
908  ipoib_leave_broadcast_group ( ipoib );
909 
910  /* Remove QPN from MAC address */
911  ipoib->mac.flags__qpn = 0;
912 
913  /* Tear down the queues */
914  ib_destroy_qp ( ibdev, ipoib->qp );
915  ipoib->qp = NULL;
916  ib_destroy_cq ( ibdev, ipoib->cq );
917  ipoib->cq = NULL;
918 
919  /* Close IB device */
920  ib_close ( ibdev );
921 }
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
struct ib_queue_pair * qp
Queue pair.
Definition: ipoib.c:97
void ib_close(struct ib_device *ibdev)
Close port.
Definition: infiniband.c:716
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:425
static struct net_device * netdev
Definition: gdbudp.c:52
static void ipoib_leave_broadcast_group(struct ipoib_device *ipoib)
Leave IPv4 broadcast multicast group.
Definition: ipoib.c:788
An IPoIB device.
Definition: ipoib.c:87
void ib_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: infiniband.c:314
uint32_t flags__qpn
Queue pair number.
Definition: ipoib.h:24
static void ipoib_flush_remac(struct ipoib_device *ipoib)
Flush REMAC cache.
Definition: ipoib.c:220
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
struct ib_completion_queue * cq
Completion queue.
Definition: ipoib.c:95

References ipoib_device::cq, ipoib_mac::flags__qpn, ib_close(), ib_destroy_cq(), ib_destroy_qp(), ipoib_device::ibdev, ipoib_flush_remac(), ipoib_leave_broadcast_group(), ipoib_device::mac, netdev, NULL, net_device::priv, and ipoib_device::qp.

◆ ipoib_probe()

static int ipoib_probe ( struct ib_device ibdev)
static

Probe IPoIB device.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 937 of file ipoib.c.

937  {
938  struct net_device *netdev;
939  struct ipoib_device *ipoib;
940  int rc;
941 
942  /* Allocate network device */
943  netdev = alloc_ipoibdev ( sizeof ( *ipoib ) );
944  if ( ! netdev )
945  return -ENOMEM;
947  ipoib = netdev->priv;
948  netdev->dev = ibdev->dev;
949  memset ( ipoib, 0, sizeof ( *ipoib ) );
950  ipoib->netdev = netdev;
951  ipoib->ibdev = ibdev;
952  INIT_LIST_HEAD ( &ipoib->peers );
953 
954  /* Extract hardware address */
956  sizeof ( ibdev->gid.s.guid ) );
958 
959  /* Set local MAC address */
960  memcpy ( &ipoib->mac.gid.s.guid, &ibdev->gid.s.guid,
961  sizeof ( ipoib->mac.gid.s.guid ) );
962 
963  /* Set default broadcast MAC address */
964  memcpy ( &ipoib->broadcast.mac, &ipoib_broadcast,
965  sizeof ( ipoib->broadcast.mac ) );
966 
967  /* Add to list of IPoIB devices */
968  list_add_tail ( &ipoib->list, &ipoib_devices );
969 
970  /* Register network device */
971  if ( ( rc = register_netdev ( netdev ) ) != 0 )
972  goto err_register_netdev;
973 
974  return 0;
975 
977  err_register_netdev:
978  list_del ( &ipoib->list );
980  netdev_put ( netdev );
981  return rc;
982 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
struct device * dev
Underlying device.
Definition: infiniband.h:410
struct net_device * alloc_ipoibdev(size_t priv_size)
Allocate IPoIB device.
Definition: ipoib.c:315
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
#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
struct list_head peers
REMAC cache.
Definition: ipoib.c:103
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
#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 ipoib_mac mac
MAC address.
Definition: ipoib.c:79
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
An IPoIB device.
Definition: ipoib.c:87
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
#define ETH_ALEN
Definition: if_ether.h:8
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct ipoib_broadcast broadcast
Broadcast address.
Definition: ipoib.c:101
struct list_head list
List of IPoIB devices.
Definition: ipoib.c:93
static struct net_device_operations ipoib_operations
IPoIB network device operations.
Definition: ipoib.c:126
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
uint8_t lemac[ETH_ALEN]
IPoIB LEMAC (if non-default)
Definition: infiniband.h:462
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct ipoib_mac mac
Local MAC.
Definition: ipoib.c:99
An IPoIB broadcast address.
Definition: ipoib.c:77
union ib_gid gid
Port GID.
Definition: ipoib.h:26
void * memset(void *dest, int character, size_t len) __nonnull
struct net_device * netdev
Network device.
Definition: ipoib.c:89
struct ib_gid::@532 s

References alloc_ipoibdev(), ipoib_device::broadcast, net_device::dev, ib_device::dev, ENOMEM, ETH_ALEN, ipoib_mac::gid, ib_device::gid, ib_gid::guid, net_device::hw_addr, ipoib_device::ibdev, INIT_LIST_HEAD, ipoib_operations, ib_device::lemac, ipoib_device::list, list_add_tail, list_del, net_device::ll_addr, ipoib_device::mac, ipoib_broadcast::mac, memcpy(), memset(), netdev, ipoib_device::netdev, netdev_init(), netdev_nullify(), netdev_put(), ipoib_device::peers, net_device::priv, rc, register_netdev(), ib_gid::s, and unregister_netdev().

◆ ipoib_notify()

static void ipoib_notify ( struct ib_device ibdev)
static

Handle device or link status change.

Parameters
ibdevInfiniband device

Definition at line 989 of file ipoib.c.

989  {
990  struct ipoib_device *ipoib;
991 
992  /* Handle link status change for any attached IPoIB devices */
993  list_for_each_entry ( ipoib, &ipoib_devices, list ) {
994  if ( ipoib->ibdev != ibdev )
995  continue;
996  ipoib_link_state_changed ( ipoib );
997  }
998 }
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
static void ipoib_link_state_changed(struct ipoib_device *ipoib)
Handle link status change.
Definition: ipoib.c:800
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An IPoIB device.
Definition: ipoib.c:87
struct list_head list
List of IPoIB devices.
Definition: ipoib.c:93

References ipoib_device::ibdev, ipoib_link_state_changed(), ipoib_device::list, and list_for_each_entry.

◆ ipoib_remove()

static void ipoib_remove ( struct ib_device ibdev)
static

Remove IPoIB device.

Parameters
ibdevInfiniband device

Definition at line 1005 of file ipoib.c.

1005  {
1006  struct ipoib_device *ipoib;
1007  struct ipoib_device *tmp;
1008  struct net_device *netdev;
1009 
1010  /* Remove any attached IPoIB devices */
1011  list_for_each_entry_safe ( ipoib, tmp, &ipoib_devices, list ) {
1012  if ( ipoib->ibdev != ibdev )
1013  continue;
1014  netdev = ipoib->netdev;
1016  list_del ( &ipoib->list );
1017  netdev_nullify ( netdev );
1018  netdev_put ( netdev );
1019  }
1020 }
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
struct list_head list
List of network devices.
Definition: netdevice.h:352
#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:555
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
#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:447
An IPoIB device.
Definition: ipoib.c:87
uint8_t * tmp
Definition: entropy.h:156
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
struct list_head list
List of IPoIB devices.
Definition: ipoib.c:93
struct net_device * netdev
Network device.
Definition: ipoib.c:89

References ipoib_device::ibdev, ipoib_device::list, net_device::list, list_del, list_for_each_entry_safe, netdev, ipoib_device::netdev, netdev_nullify(), netdev_put(), tmp, and unregister_netdev().

◆ ipoib_netdev()

struct net_device* ipoib_netdev ( struct ib_device ibdev)

Find IPoIB network device.

Parameters
ibdevInfiniband device
Return values
netdevIPoIB network device, or NULL if not found

Definition at line 1036 of file ipoib.c.

1036  {
1037  struct ipoib_device *ipoib;
1038 
1039  /* Find matching IPoIB device */
1040  list_for_each_entry ( ipoib, &ipoib_devices, list ) {
1041  if ( ipoib->ibdev != ibdev )
1042  continue;
1043  return ipoib->netdev;
1044  }
1045  return NULL;
1046 }
struct ib_device * ibdev
Underlying Infiniband device.
Definition: ipoib.c:91
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An IPoIB device.
Definition: ipoib.c:87
struct list_head list
List of IPoIB devices.
Definition: ipoib.c:93
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct net_device * netdev
Network device.
Definition: ipoib.c:89

References ipoib_device::ibdev, ipoib_device::list, list_for_each_entry, ipoib_device::netdev, and NULL.

Referenced by golan_register_ibdev().

Variable Documentation

◆ ipoib_broadcast

struct ipoib_mac ipoib_broadcast
static
Initial value:
= {
.flags__qpn = htonl ( IB_QPN_BROADCAST ),
.gid.bytes = { 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff },
}
#define htonl(value)
Definition: byteswap.h:133
#define IB_QPN_BROADCAST
Broadcast QPN.
Definition: infiniband.h:33

Broadcast IPoIB address.

Definition at line 107 of file ipoib.c.

◆ __errortab

struct errortab ipoib_errors [] __errortab
Initial value:
= {
}
#define __einfo_errortab(einfo)
Definition: errortab.h:23
#define EINFO_EINPROGRESS_JOINING
Definition: ipoib.c:115

Human-readable message for the link status.

Definition at line 119 of file ipoib.c.

◆ ipoib_operations

static struct net_device_operations ipoib_operations
static
Initial value:
= {
.open = ipoib_open,
.close = ipoib_close,
.transmit = ipoib_transmit,
.poll = ipoib_poll,
}
static void ipoib_poll(struct net_device *netdev)
Poll IPoIB network device.
Definition: ipoib.c:735
static void ipoib_close(struct net_device *netdev)
Close IPoIB network device.
Definition: ipoib.c:900
static int ipoib_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet via IPoIB network device.
Definition: ipoib.c:499
static int ipoib_open(struct net_device *netdev)
Open IPoIB network device.
Definition: ipoib.c:844

IPoIB network device operations.

Definition at line 126 of file ipoib.c.

Referenced by ipoib_discard_remac(), and ipoib_probe().

◆ __ll_protocol

struct ll_protocol ipoib_protocol __ll_protocol
Initial value:
= {
.name = "IPoIB",
.ll_proto = htons ( ARPHRD_ETHER ),
.hw_addr_len = sizeof ( union ib_guid ),
.ll_addr_len = ETH_ALEN,
.ll_header_len = ETH_HLEN,
.push = eth_push,
.pull = eth_pull,
.init_addr = ipoib_init_addr,
.ntoa = eth_ntoa,
.mc_hash = eth_mc_hash,
.eth_addr = eth_eth_addr,
.eui64 = eth_eui64,
.flags = LL_NAME_ONLY,
}
int eth_eth_addr(const void *ll_addr, void *eth_addr)
Generate Ethernet-compatible compressed link-layer address.
Definition: ethernet.c:222
#define LL_NAME_ONLY
Local link-layer address functions only as a name.
Definition: netdevice.h:210
int eth_push(struct net_device *netdev __unused, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto)
Add Ethernet link-layer header.
Definition: ethernet.c:77
int eth_eui64(const void *ll_addr, void *eui64)
Generate EUI-64 address.
Definition: ethernet.c:234
int eth_pull(struct net_device *netdev __unused, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags)
Remove Ethernet link-layer header.
Definition: ethernet.c:101
#define ETH_HLEN
Definition: if_ether.h:9
int eth_mc_hash(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
Definition: ethernet.c:193
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
An Infiniband Globally Unique Identifier.
Definition: ib_packet.h:18
#define ETH_ALEN
Definition: if_ether.h:8
static void ipoib_init_addr(const void *hw_addr, void *ll_addr)
Initialise IPoIB link-layer address.
Definition: ipoib.c:279
#define ARPHRD_ETHER
Ethernet 10Mbps.
Definition: if_arp.h:16
#define htons(value)
Definition: byteswap.h:135

IPoIB protocol.

Ethernet protocol.

Definition at line 293 of file ipoib.c.

◆ ipoib_cq_op

struct ib_completion_queue_operations ipoib_cq_op
static
Initial value:
= {
.complete_send = ipoib_complete_send,
.complete_recv = ipoib_complete_recv,
}
static void ipoib_complete_recv(struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Handle IPoIB receive completion.
Definition: ipoib.c:619
static void ipoib_complete_send(struct ib_device *ibdev __unused, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Handle IPoIB send completion.
Definition: ipoib.c:601

IPoIB completion operations.

Definition at line 689 of file ipoib.c.

Referenced by ipoib_open().

◆ ipoib_qp_op

struct ib_queue_pair_operations ipoib_qp_op
static
Initial value:
= {
.alloc_iob = ipoib_alloc_iob,
}
static struct io_buffer * ipoib_alloc_iob(size_t len)
Allocate IPoIB receive I/O buffer.
Definition: ipoib.c:709

IPoIB queue pair operations.

Definition at line 726 of file ipoib.c.

Referenced by ipoib_open().

◆ __ib_driver

struct ib_driver ipoib_driver __ib_driver
Initial value:
= {
.name = "IPoIB",
.probe = ipoib_probe,
.notify = ipoib_notify,
.remove = ipoib_remove,
}
static int ipoib_probe(struct ib_device *ibdev)
Probe IPoIB device.
Definition: ipoib.c:937
static void ipoib_remove(struct ib_device *ibdev)
Remove IPoIB device.
Definition: ipoib.c:1005
static void ipoib_notify(struct ib_device *ibdev)
Handle device or link status change.
Definition: ipoib.c:989

IPoIB driver.

Definition at line 1023 of file ipoib.c.