iPXE
Data Structures | Macros | Functions
eoib.h File Reference

Ethernet over Infiniband. More...

#include <stdint.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_mcast.h>

Go to the source code of this file.

Data Structures

struct  eoib_header
 An EoIB header. More...
 
struct  eoib_device
 An EoIB device. More...
 

Macros

#define EOIB_MAGIC   0x8919
 EoIB magic signature. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int eoib_has_gateway (struct eoib_device *eoib)
 Check if EoIB device uses a gateway. More...
 
static void eoib_force_group_creation (struct eoib_device *eoib)
 Force creation of multicast group. 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...
 
void eoib_set_gateway (struct eoib_device *eoib, struct ib_address_vector *av)
 Set EoIB gateway. More...
 

Detailed Description

Ethernet over Infiniband.

Definition in file eoib.h.

Macro Definition Documentation

◆ EOIB_MAGIC

#define EOIB_MAGIC   0x8919

EoIB magic signature.

Definition at line 27 of file eoib.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ eoib_has_gateway()

static int eoib_has_gateway ( struct eoib_device eoib)
inlinestatic

Check if EoIB device uses a gateway.

Parameters
eoibEoIB device
has_gwEoIB device uses a gateway

Definition at line 71 of file eoib.h.

71  {
72 
73  return ( eoib->duplicate != NULL );
74 }
void(* duplicate)(struct eoib_device *eoib, struct io_buffer *original)
Send duplicate packet to gateway (or NULL)
Definition: eoib.h:57
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References eoib_device::duplicate, and NULL.

Referenced by eoib_rx_av(), and eoib_transmit().

◆ eoib_force_group_creation()

static void eoib_force_group_creation ( struct eoib_device eoib)
inlinestatic

Force creation of multicast group.

Parameters
eoibEoIB device

Definition at line 81 of file eoib.h.

81  {
82 
83  /* Some dubious EoIB implementations require each endpoint to
84  * force the creation of the multicast group. Yes, this makes
85  * it impossible for the group parameters (e.g. SL) to ever be
86  * modified without breaking backwards compatiblity with every
87  * existing driver.
88  */
92 }
#define IB_SA_MCMEMBER_REC_SL
Definition: ib_mad.h:290
#define IB_SA_MCMEMBER_REC_PKEY
Definition: ib_mad.h:285
#define IB_SA_MCMEMBER_REC_QKEY
Definition: ib_mad.h:280
unsigned int mask
Multicast group additional component mask.
Definition: eoib.h:62
#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS
Definition: ib_mad.h:284
#define IB_SA_MCMEMBER_REC_FLOW_LABEL
Definition: ib_mad.h:291

References IB_SA_MCMEMBER_REC_FLOW_LABEL, IB_SA_MCMEMBER_REC_PKEY, IB_SA_MCMEMBER_REC_QKEY, IB_SA_MCMEMBER_REC_SL, IB_SA_MCMEMBER_REC_TRAFFIC_CLASS, and eoib_device::mask.

Referenced by xsmp_rx_xve_modify().

◆ 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_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().