ipoib.h File Reference

IP over Infiniband. More...

#include <gpxe/infiniband.h>

Go to the source code of this file.

Data Structures

struct  ipoib_mac
 An IPoIB MAC address. More...
struct  ipoib_hdr
 IPoIB link-layer header. More...

Defines

#define IPOIB_ALEN   20
 IPoIB MAC address length.
#define IPOIB_HLEN   4
 IPoIB link-layer header length.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
const char * ipoib_ntoa (const void *ll_addr)
 Transcribe IPoIB link-layer address.
void ipoib_link_state_changed (struct ib_device *ibdev)
 Handle link status change.
int ipoib_probe (struct ib_device *ibdev)
 Probe IPoIB device.
void ipoib_remove (struct ib_device *ibdev)
 Remove IPoIB device.
struct net_devicealloc_ipoibdev (size_t priv_size)
 Allocate IPoIB device.


Detailed Description

IP over Infiniband.

Definition in file ipoib.h.


Define Documentation

#define IPOIB_ALEN   20

IPoIB MAC address length.

Definition at line 14 of file ipoib.h.

#define IPOIB_HLEN   4

IPoIB link-layer header length.

Definition at line 29 of file ipoib.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

const char* ipoib_ntoa ( const void *  ll_addr  ) 

Transcribe IPoIB link-layer address.

Parameters:
ll_addr Link-layer address
Return values:
string Link-layer address in human-readable format

Definition at line 280 of file ipoib.c.

References ib_gid::dwords, ipoib_mac::flags__qpn, ipoib_mac::gid, htonl, snprintf(), and ib_gid::u.

Referenced by ipoib_cache_peer().

00280                                                 {
00281         static char buf[45];
00282         const struct ipoib_mac *mac = ll_addr;
00283 
00284         snprintf ( buf, sizeof ( buf ), "%08x:%08x:%08x:%08x:%08x",
00285                    htonl ( mac->flags__qpn ), htonl ( mac->gid.u.dwords[0] ),
00286                    htonl ( mac->gid.u.dwords[1] ),
00287                    htonl ( mac->gid.u.dwords[2] ),
00288                    htonl ( mac->gid.u.dwords[3] ) );
00289         return buf;
00290 }

void ipoib_link_state_changed ( struct ib_device ibdev  ) 

Handle link status change.

Parameters:
ibdev Infiniband device

Definition at line 696 of file ipoib.c.

References ipoib_device::broadcast, DBGC, EINPROGRESS_JOINING, ib_device::gid, ipoib_mac::gid, ib_gid::half, htons, ib_get_ownerdata(), ib_link_ok(), ib_link_rc(), IB_PKEY_FULL, ipoib_join_broadcast_group(), ipoib_leave_broadcast_group(), net_device::ll_addr, memcpy, netdev, netdev_link_err(), ib_device::pkey, net_device::priv, strerror(), ib_gid::u, and ib_gid::words.

Referenced by ib_link_state_changed(), and ipoib_open().

00696                                                           {
00697         struct net_device *netdev = ib_get_ownerdata ( ibdev );
00698         struct ipoib_device *ipoib = netdev->priv;
00699         struct ipoib_mac *mac = ( ( struct ipoib_mac * ) netdev->ll_addr );
00700         int rc;
00701 
00702         /* Leave existing broadcast group */
00703         ipoib_leave_broadcast_group ( ipoib );
00704 
00705         /* Update MAC address based on potentially-new GID prefix */
00706         memcpy ( &mac->gid.u.half[0], &ibdev->gid.u.half[0],
00707                  sizeof ( mac->gid.u.half[0] ) );
00708 
00709         /* Update broadcast GID based on potentially-new partition key */
00710         ipoib->broadcast.gid.u.words[2] =
00711                 htons ( ibdev->pkey | IB_PKEY_FULL );
00712 
00713         /* Set net device link state to reflect Infiniband link state */
00714         rc = ib_link_rc ( ibdev );
00715         netdev_link_err ( netdev, ( rc ? rc : -EINPROGRESS_JOINING ) );
00716 
00717         /* Join new broadcast group */
00718         if ( ib_link_ok ( ibdev ) &&
00719              ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
00720                 DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
00721                        "%s\n", ipoib, strerror ( rc ) );
00722                 netdev_link_err ( netdev, rc );
00723                 return;
00724         }
00725 }

int ipoib_probe ( struct ib_device ibdev  ) 

Probe IPoIB device.

Parameters:
ibdev Infiniband device
Return values:
rc Return status code

Definition at line 733 of file ipoib.c.

References alloc_ipoibdev(), ipoib_device::broadcast, ib_device::dev, net_device::dev, ENOMEM, ib_device::gid, ib_gid::half, net_device::hw_addr, ib_set_ownerdata(), ipoib_device::ibdev, net_device::ll_broadcast, memcpy, memset(), ipoib_device::netdev, netdev, netdev_init(), netdev_nullify(), netdev_put(), net_device::priv, register_netdev(), and ib_gid::u.

Referenced by register_ibdev().

00733                                             {
00734         struct net_device *netdev;
00735         struct ipoib_device *ipoib;
00736         int rc;
00737 
00738         /* Allocate network device */
00739         netdev = alloc_ipoibdev ( sizeof ( *ipoib ) );
00740         if ( ! netdev )
00741                 return -ENOMEM;
00742         netdev_init ( netdev, &ipoib_operations );
00743         ipoib = netdev->priv;
00744         ib_set_ownerdata ( ibdev, netdev );
00745         netdev->dev = ibdev->dev;
00746         memset ( ipoib, 0, sizeof ( *ipoib ) );
00747         ipoib->netdev = netdev;
00748         ipoib->ibdev = ibdev;
00749 
00750         /* Extract hardware address */
00751         memcpy ( netdev->hw_addr, &ibdev->gid.u.half[1],
00752                  sizeof ( ibdev->gid.u.half[1] ) );
00753 
00754         /* Set default broadcast address */
00755         memcpy ( &ipoib->broadcast, &ipoib_broadcast,
00756                  sizeof ( ipoib->broadcast ) );
00757         netdev->ll_broadcast = ( ( uint8_t * ) &ipoib->broadcast );
00758 
00759         /* Register network device */
00760         if ( ( rc = register_netdev ( netdev ) ) != 0 )
00761                 goto err_register_netdev;
00762 
00763         return 0;
00764 
00765  err_register_netdev:
00766         netdev_nullify ( netdev );
00767         netdev_put ( netdev );
00768         return rc;
00769 }

void ipoib_remove ( struct ib_device ibdev  ) 

Remove IPoIB device.

Parameters:
ibdev Infiniband device

Definition at line 776 of file ipoib.c.

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

Referenced by unregister_ibdev().

00776                                               {
00777         struct net_device *netdev = ib_get_ownerdata ( ibdev );
00778 
00779         unregister_netdev ( netdev );
00780         netdev_nullify ( netdev );
00781         netdev_put ( netdev );
00782 }

struct net_device* alloc_ipoibdev ( size_t  priv_size  )  [read]

Allocate IPoIB device.

Parameters:
priv_size Size of driver private data
Return values:
netdev Network device, or NULL

Definition at line 384 of file ipoib.c.

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

Referenced by ipoib_probe().

00384                                                         {
00385         struct net_device *netdev;
00386 
00387         netdev = alloc_netdev ( priv_size );
00388         if ( netdev ) {
00389                 netdev->ll_protocol = &ipoib_protocol;
00390                 netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
00391                 netdev->max_pkt_len = IB_MAX_PAYLOAD_SIZE;
00392         }
00393         return netdev;
00394 }


Generated on Tue Apr 6 20:01:51 2010 for gPXE by  doxygen 1.5.7.1