iPXE
Data Structures | Defines | 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...

Defines

#define EOIB_MAGIC   0x8919
 EoIB magic signature.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int eoib_has_gateway (struct eoib_device *eoib)
 Check if EoIB device uses a gateway.
static void eoib_force_group_creation (struct eoib_device *eoib)
 Force creation of multicast group.
int eoib_create (struct ib_device *ibdev, const uint8_t *hw_addr, struct ib_address_vector *broadcast, const char *name)
 Create EoIB device.
struct eoib_deviceeoib_find (struct ib_device *ibdev, const uint8_t *hw_addr)
 Find EoIB device.
void eoib_destroy (struct eoib_device *eoib)
 Remove EoIB device.
void eoib_set_gateway (struct eoib_device *eoib, struct ib_address_vector *av)
 Set EoIB gateway.

Detailed Description

Ethernet over Infiniband.

Definition in file eoib.h.


Define Documentation

#define EOIB_MAGIC   0x8919

EoIB magic signature.

Definition at line 27 of file eoib.h.

Referenced by eoib_transmit().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int eoib_has_gateway ( struct eoib_device eoib) [inline, static]

Check if EoIB device uses a gateway.

Parameters:
eoibEoIB device
has_gwEoIB device uses a gateway

Definition at line 71 of file eoib.h.

References eoib_device::duplicate, and NULL.

Referenced by eoib_rx_av(), and eoib_transmit().

                                                                {

        return ( eoib->duplicate != NULL );
}
static void eoib_force_group_creation ( struct eoib_device eoib) [inline, static]

Force creation of multicast group.

Parameters:
eoibEoIB device

Definition at line 81 of file eoib.h.

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

                                                                          {

        /* Some dubious EoIB implementations require each endpoint to
         * force the creation of the multicast group.  Yes, this makes
         * it impossible for the group parameters (e.g. SL) to ever be
         * modified without breaking backwards compatiblity with every
         * existing driver.
         */
        eoib->mask = ( IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_QKEY |
                       IB_SA_MCMEMBER_REC_SL | IB_SA_MCMEMBER_REC_FLOW_LABEL |
                       IB_SA_MCMEMBER_REC_TRAFFIC_CLASS );
}
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.

References alloc_etherdev(), eoib_device::broadcast, DBGC, net_device::dev, ib_device::dev, ENOMEM, 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, 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().

                                                                          {
        struct net_device *netdev;
        struct eoib_device *eoib;
        int rc;

        /* Allocate network device */
        netdev = alloc_etherdev ( sizeof ( *eoib ) );
        if ( ! netdev ) {
                rc = -ENOMEM;
                goto err_alloc;
        }
        netdev_init ( netdev, &eoib_operations );
        eoib = netdev->priv;
        netdev->dev = ibdev->dev;
        eoib->netdev = netdev;
        eoib->ibdev = ibdev_get ( ibdev );
        memcpy ( &eoib->broadcast, broadcast, sizeof ( eoib->broadcast ) );
        INIT_LIST_HEAD ( &eoib->peers );

        /* Set MAC address */
        memcpy ( netdev->hw_addr, hw_addr, ETH_ALEN );

        /* Set interface name, if applicable */
        if ( name )
                snprintf ( netdev->name, sizeof ( netdev->name ), "%s", name );
        eoib->name = netdev->name;

        /* Add to list of EoIB devices */
        list_add_tail ( &eoib->list, &eoib_devices );

        /* Register network device */
        if ( ( rc = register_netdev ( netdev ) ) != 0 )
                goto err_register;

        DBGC ( eoib, "EoIB %s created for %s MAC %s\n",
               eoib->name, ibdev->name, eth_ntoa ( hw_addr ) );
        DBGC ( eoib, "EoIB %s broadcast GID " IB_GID_FMT "\n",
               eoib->name, IB_GID_ARGS ( &broadcast->gid ) );
        return 0;

        unregister_netdev ( netdev );
 err_register:
        list_del ( &eoib->list );
        ibdev_put ( ibdev );
        netdev_nullify ( netdev );
        netdev_put ( netdev );
 err_alloc:
        return rc;
}
struct eoib_device* eoib_find ( struct ib_device ibdev,
const uint8_t hw_addr 
) [read]

Find EoIB device.

Parameters:
ibdevInfiniband device
hw_addrOriginal Ethernet MAC
Return values:
eoibEoIB device

Definition at line 677 of file eoib.c.

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

                                                          {
        struct eoib_device *eoib;

        list_for_each_entry ( eoib, &eoib_devices, list ) {
                if ( ( eoib->ibdev == ibdev ) &&
                     ( memcmp ( eoib->netdev->hw_addr, hw_addr,
                                ETH_ALEN ) == 0 ) )
                        return eoib;
        }
        return NULL;
}
void eoib_destroy ( struct eoib_device eoib)

Remove EoIB device.

Parameters:
eoibEoIB device

Definition at line 695 of file eoib.c.

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

                                               {
        struct net_device *netdev = eoib->netdev;

        /* Unregister network device */
        unregister_netdev ( netdev );

        /* Remove from list of network devices */
        list_del ( &eoib->list );

        /* Drop reference to Infiniband device */
        ibdev_put ( eoib->ibdev );

        /* Free network device */
        DBGC ( eoib, "EoIB %s destroyed\n", eoib->name );
        netdev_nullify ( netdev );
        netdev_put ( netdev );
}
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.

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

                                                       {

        if ( av ) {
                DBGC ( eoib, "EoIB %s using gateway " IB_GID_FMT "\n",
                       eoib->name, IB_GID_ARGS ( &av->gid ) );
                memcpy ( &eoib->gateway, av, sizeof ( eoib->gateway ) );
                eoib->duplicate = eoib_duplicate;
        } else {
                DBGC ( eoib, "EoIB %s not using gateway\n", eoib->name );
                eoib->duplicate = NULL;
        }
}