iPXE
Data Structures | Enumerations | Functions | Variables
xsigo.c File Reference

Xsigo virtual Ethernet devices. More...

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/version.h>
#include <ipxe/timer.h>
#include <ipxe/malloc.h>
#include <ipxe/iobuf.h>
#include <ipxe/retry.h>
#include <ipxe/process.h>
#include <ipxe/settings.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_service.h>
#include <ipxe/ib_cmrc.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/eoib.h>
#include <ipxe/xsigo.h>

Go to the source code of this file.

Data Structures

struct  xsigo_device
 A Xsigo device. More...
struct  xsigo_manager
 A Xsigo configuration manager. More...
struct  xsigo_nic
 A Xsigo virtual Ethernet device. More...
struct  xsigo_discovery
 A stage of discovery. More...

Enumerations

enum  xsigo_manager_pending { XCM_TX_CONNECT = 0x0001, XCM_TX_REGISTER = 0x0002 }
 Configuration manager pending transmissions. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static LIST_HEAD (xsigo_devices)
 List of all Xsigo devices.
static void xsigo_free (struct refcnt *refcnt)
 Free Xsigo device.
static void xcm_free (struct refcnt *refcnt)
 Free configuration manager.
static int xve_create (struct xsigo_manager *xcm, union ib_guid *resource, const uint8_t *mac, unsigned long network, unsigned long qkey, const char *name)
 Create virtual Ethernet device.
static struct xsigo_nicxve_find (struct xsigo_manager *xcm, union ib_guid *resource)
 Find virtual Ethernet device.
static void xve_destroy (struct xsigo_nic *xve)
 Destroy virtual Ethernet device.
static int xve_update_mtu (struct xsigo_nic *xve, struct eoib_device *eoib, size_t mtu)
 Update virtual Ethernet device MTU.
static int xve_open (struct xsigo_nic *xve, struct eoib_device *eoib)
 Open virtual Ethernet device.
static void xve_close (struct xsigo_nic *xve, struct eoib_device *eoib)
 Close virtual Ethernet device.
static int xve_update_state (struct xsigo_nic *xve, struct eoib_device *eoib, int open)
 Update virtual Ethernet device administrative state.
static int xve_update_tca (struct xsigo_nic *xve, struct eoib_device *eoib, struct ib_address_vector *av)
 Update gateway (TCA)
static const char * xsmp_session_type (unsigned int type)
 Get session message name (for debugging)
static const char * xsmp_chassis_name (struct xsmp_session_message *msg)
 Extract chassis name (for debugging)
static const char * xsmp_session_name (struct xsmp_session_message *msg)
 Extract session name (for debugging)
static int xsmp_tx_session (struct xsigo_manager *xcm, unsigned int type)
 Send session message.
static int xsmp_tx_session_register (struct xsigo_manager *xcm)
 Send registration message.
static int xsmp_tx_session_hello (struct xsigo_manager *xcm)
 Send keepalive message.
static int xsmp_rx_session_hello (struct xsigo_manager *xcm, struct xsmp_session_message *msg __unused)
 Handle received keepalive message.
static int xsmp_rx_session_confirm (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received registration confirmation message.
static int xsmp_rx_session_reject (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received registration rejection message.
static int xsmp_rx_session_shutdown (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received shutdown message.
static int xsmp_rx_session (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received session message.
static const char * xsmp_xve_type (unsigned int type)
 Get virtual Ethernet message name (for debugging)
static int xsmp_tx_xve (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Send virtual Ethernet message.
static int xsmp_tx_xve_params (struct xsigo_manager *xcm, struct xsmp_xve_message *msg, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet message including current device parameters.
static int xsmp_tx_xve_nack (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Send virtual Ethernet error response.
static int xsmp_tx_xve_notify (struct xsigo_manager *xcm, unsigned int type, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet notification.
static int xsmp_tx_xve_oper (struct xsigo_manager *xcm, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet current operational state.
static int xsmp_rx_xve_modify (struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
 Handle received virtual Ethernet modification message.
static int xsmp_rx_xve_install (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet installation message.
static int xsmp_rx_xve_delete (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet deletion message.
static int xsmp_rx_xve_update (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet update message.
static int xsmp_rx_xve_oper_req (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet operational request message.
static int xsmp_rx_xve_ready (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet readiness message.
static int xsmp_rx_xve (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet message.
static void xcm_close (struct xsigo_manager *xcm, int rc)
 Close configuration manager connection.
static void xcm_step (struct xsigo_manager *xcm)
 Send data to configuration manager.
static int xcm_deliver (struct xsigo_manager *xcm, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
 Receive data from configuration manager.
static void xcm_reopen (struct retry_timer *timer, int fail __unused)
 Handle configuration manager connection timer expiry.
static void xcm_keepalive (struct retry_timer *timer, int fail __unused)
 Handle configuration manager keepalive timer expiry.
static int xcm_create (struct xsigo_device *xdev, struct xsigo_manager_id *id)
 Create configuration manager.
static struct xsigo_managerxcm_find (struct xsigo_device *xdev, struct xsigo_manager_id *id)
 Find configuration manager.
static void xcm_destroy (struct xsigo_manager *xcm)
 Destroy configuration manager.
static int xcm_list (struct xsigo_device *xdev, struct xsigo_manager_id *ids, unsigned int count)
 Synchronise list of configuration managers.
static void xsigo_xcm_complete (struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
 Handle configuration manager lookup completion.
static void xsigo_xds_complete (struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
 Handle directory service lookup completion.
static void xsigo_discover (struct retry_timer *timer, int over __unused)
 Discover configuration managers.
static void xsigo_ib_open (struct retry_timer *opener, int over __unused)
 Open link and start discovery.
static int xsigo_ib_probe (struct ib_device *ibdev)
 Probe Xsigo device.
static void xsigo_ib_notify (struct ib_device *ibdev)
 Handle device or link status change.
static void xsigo_ib_remove (struct ib_device *ibdev)
 Remove Xsigo device.
static void xsigo_net_notify (struct net_device *netdev)
 Handle device or link status change.

Variables

static union ib_guid xcm_service_id
 Configuration manager service ID.
static struct interface_operation xcm_xfer_op []
 Configuration manager data transfer interface operations.
static struct interface_descriptor xcm_xfer_desc
 Configuration manager data transfer interface descriptor.
static struct process_descriptor xcm_process_desc
 Configuration manager process descriptor.
static struct xsigo_discovery xsigo_xcm_discovery
 Configuration manager lookup discovery stage.
static struct xsigo_discovery xsigo_xds_discovery
 Directory service lookup discovery stage.
struct ib_driver xsigo_ib_driver __ib_driver
 Xsigo Infiniband driver.
struct net_driver xsigo_net_driver __net_driver
 Xsigo network driver.

Detailed Description

Xsigo virtual Ethernet devices.

Definition in file xsigo.c.


Enumeration Type Documentation

Configuration manager pending transmissions.

Enumerator:
XCM_TX_CONNECT 

Send connection request.

XCM_TX_REGISTER 

Send registration message.

Definition at line 105 of file xsigo.c.

                           {
        /** Send connection request */
        XCM_TX_CONNECT = 0x0001,
        /** Send registration message */
        XCM_TX_REGISTER = 0x0002,
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static LIST_HEAD ( xsigo_devices  ) [static]

List of all Xsigo devices.

static void xsigo_free ( struct refcnt refcnt) [static]

Free Xsigo device.

Parameters:
refcntReference count

Definition at line 142 of file xsigo.c.

References assert, container_of, xsigo_device::discovery, free, xsigo_device::ibdev, ibdev_put(), list_empty, xsigo_device::madx, xsigo_device::managers, NULL, and xsigo_device::opener.

Referenced by xsigo_ib_probe().

                                                 {
        struct xsigo_device *xdev =
                container_of ( refcnt, struct xsigo_device, refcnt );

        /* Sanity checks */
        assert ( ! timer_running ( &xdev->opener ) );
        assert ( ! timer_running ( &xdev->discovery ) );
        assert ( xdev->madx == NULL );
        assert ( list_empty ( &xdev->managers ) );

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

        /* Free device */
        free ( xdev );
}
static void xcm_free ( struct refcnt refcnt) [static]

Free configuration manager.

Parameters:
refcntReference count

Definition at line 164 of file xsigo.c.

References assert, container_of, free, xsigo_manager::keepalive, list_empty, xsigo_manager::nics, xsigo_manager::process, process_running(), ref_put, xsigo_device::refcnt, xsigo_manager::reopen, and xsigo_manager::xdev.

Referenced by xcm_create().

                                               {
        struct xsigo_manager *xcm =
                container_of ( refcnt, struct xsigo_manager, refcnt );

        /* Sanity checks */
        assert ( ! timer_running ( &xcm->reopen ) );
        assert ( ! timer_running ( &xcm->keepalive ) );
        assert ( ! process_running ( &xcm->process ) );
        assert ( list_empty ( &xcm->nics ) );

        /* Drop reference to Xsigo device */
        ref_put ( &xcm->xdev->refcnt );

        /* Free manager */
        free ( xcm );
}
static int xve_create ( struct xsigo_manager xcm,
union ib_guid resource,
const uint8_t mac,
unsigned long  network,
unsigned long  qkey,
const char *  name 
) [static]

Create virtual Ethernet device.

Parameters:
xcmConfiguration manager
resourceResource identifier
macEthernet MAC
networkNetwork identifier
nameDevice name
Return values:
rcReturn status code

Definition at line 198 of file xsigo.c.

References DBGC, ib_gid::dwords, ENOMEM, eoib_create(), ETH_ALEN, eth_ntoa(), free, ib_address_vector::gid, ib_address_vector::gid_present, htonl, htons, IB_GUID_ARGS, IB_GUID_FMT, IB_QPN_BROADCAST, xsigo_device::ibdev, xsigo_nic::list, list_add, list_del, xsigo_nic::mac, memcpy(), memset(), xsigo_manager::name, xsigo_nic::name, xsigo_nic::network, xsigo_manager::nics, ib_device::pkey, ib_address_vector::qkey, qkey, ib_address_vector::qpn, rc, xsigo_nic::resource, snprintf(), strerror(), ib_gid::words, xsigo_nic::xcm, xsigo_manager::xdev, XVE_PREFIX, and zalloc().

Referenced by xsmp_rx_xve_install().

                                                               {
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        struct xsigo_nic *xve;
        struct ib_address_vector broadcast;
        int rc;

        /* Allocate and initialise structure */
        xve = zalloc ( sizeof ( *xve ) );
        if ( ! xve ) {
                rc = -ENOMEM;
                goto err_alloc;
        }
        xve->xcm = xcm;
        snprintf ( xve->name, sizeof ( xve->name ), "%s", name );
        memcpy ( &xve->resource, resource, sizeof ( xve->resource ) );
        memcpy ( xve->mac, mac, ETH_ALEN );
        xve->network = network;
        DBGC ( xve, "XVE %s created for %s " IB_GUID_FMT "\n",
               xve->name, xcm->name, IB_GUID_ARGS ( resource ) );
        DBGC ( xve, "XVE %s is MAC %s on network %ld\n",
               xve->name, eth_ntoa ( mac ), network );

        /* Construct broadcast address vector */
        memset ( &broadcast, 0, sizeof ( broadcast ) );
        broadcast.qpn = IB_QPN_BROADCAST;
        broadcast.qkey = qkey;
        broadcast.gid_present = 1;
        broadcast.gid.dwords[0] = htonl ( XVE_PREFIX );
        broadcast.gid.words[2] = htons ( ibdev->pkey );
        broadcast.gid.dwords[3] = htonl ( network );

        /* Create EoIB device */
        if ( ( rc = eoib_create ( ibdev, xve->mac, &broadcast,
                                  xve->name ) ) != 0 ) {
                DBGC ( xve, "XVE %s could not create EoIB device: %s\n",
                       xve->name, strerror ( rc ) );
                goto err_create;
        }

        /* Add to list of virtual Ethernet devices.  Do this only
         * after creating the EoIB device, so that our net device
         * notifier won't attempt to send an operational state update
         * before we have acknowledged the installation.
         */
        list_add ( &xve->list, &xcm->nics );

        return 0;

        list_del ( &xve->list );
 err_create:
        free ( xve );
 err_alloc:
        return rc;
}
static struct xsigo_nic* xve_find ( struct xsigo_manager xcm,
union ib_guid resource 
) [static, read]

Find virtual Ethernet device.

Parameters:
xcmConfiguration manager
resourceResource identifier
Return values:
xveVirtual Ethernet device, or NULL

Definition at line 263 of file xsigo.c.

References xsigo_nic::list, list_for_each_entry, memcmp(), xsigo_manager::nics, NULL, and xsigo_nic::resource.

Referenced by xsmp_rx_xve_delete(), xsmp_rx_xve_install(), and xsmp_rx_xve_modify().

                                                               {
        struct xsigo_nic *xve;

        list_for_each_entry ( xve, &xcm->nics, list ) {
                if ( memcmp ( resource, &xve->resource,
                              sizeof ( *resource ) ) == 0 )
                        return xve;
        }
        return NULL;
}
static void xve_destroy ( struct xsigo_nic xve) [static]

Destroy virtual Ethernet device.

Parameters:
xveVirtual Ethernet device

Definition at line 280 of file xsigo.c.

References DBGC, eoib_destroy(), eoib_find(), free, xsigo_device::ibdev, xsigo_nic::list, list_del, xsigo_nic::mac, xsigo_nic::name, xsigo_nic::xcm, and xsigo_manager::xdev.

Referenced by xcm_destroy(), and xsmp_rx_xve_delete().

                                                  {
        struct xsigo_manager *xcm = xve->xcm;
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        struct eoib_device *eoib;

        /* Destroy corresponding EoIB device, if any */
        if ( ( eoib = eoib_find ( ibdev, xve->mac ) ) )
                eoib_destroy ( eoib );

        /* Remove from list of virtual Ethernet devices */
        list_del ( &xve->list );

        /* Free virtual Ethernet device */
        DBGC ( xve, "XVE %s destroyed\n", xve->name );
        free ( xve );
}
static int xve_update_mtu ( struct xsigo_nic xve,
struct eoib_device eoib,
size_t  mtu 
) [static]

Update virtual Ethernet device MTU.

Parameters:
xveVirtual Ethernet device
eoibEoIB device
mtuNew MTU (excluding Ethernet and EoIB headers)
Return values:
rcReturn status code

Definition at line 306 of file xsigo.c.

References DBGC, ERANGE, IB_MAX_PAYLOAD_SIZE, max, net_device::max_pkt_len, mtu, net_device::mtu, xsigo_nic::name, eoib_device::netdev, and netdev.

Referenced by xsmp_rx_xve_modify().

                                         {
        struct net_device *netdev = eoib->netdev;
        size_t max;

        /* Check that we can support this MTU */
        max = ( IB_MAX_PAYLOAD_SIZE - ( sizeof ( struct ethhdr ) +
                                        sizeof ( struct eoib_header ) ) );
        if ( mtu > max ) {
                DBGC ( xve, "XVE %s cannot support MTU %zd (max %zd)\n",
                       xve->name, mtu, max );
                return -ERANGE;
        }

        /* Update MTU.  No need to close/reopen the network device,
         * since our Infiniband stack uses a fixed MTU anyway.  Note
         * that the network device sees the Ethernet frame header but
         * not the EoIB header.
         */
        netdev->max_pkt_len = ( mtu + sizeof ( struct ethhdr ) );
        netdev->mtu = mtu;
        DBGC ( xve, "XVE %s has MTU %zd\n", xve->name, mtu );

        return 0;
}
static int xve_open ( struct xsigo_nic xve,
struct eoib_device eoib 
) [static]

Open virtual Ethernet device.

Parameters:
xveVirtual Ethernet device
eoibEoIB device
openNew administrative state
Return values:
rcReturn status code

Definition at line 340 of file xsigo.c.

References DBGC, xsigo_nic::name, eoib_device::netdev, netdev, netdev_is_open(), netdev_open(), rc, and strerror().

Referenced by xve_update_state().

                                                                        {
        struct net_device *netdev = eoib->netdev;
        int rc;

        /* Do nothing if network device is already open */
        if ( netdev_is_open ( netdev ) )
                return 0;
        DBGC ( xve, "XVE %s opening network device\n", xve->name );

        /* Open network device */
        if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
                DBGC ( xve, "XVE %s could not open: %s\n",
                       xve->name, strerror ( rc ) );
                return rc;
        }

        return 0;
}
static void xve_close ( struct xsigo_nic xve,
struct eoib_device eoib 
) [static]

Close virtual Ethernet device.

Parameters:
xveVirtual Ethernet device
eoibEoIB device

Definition at line 365 of file xsigo.c.

References DBGC, xsigo_nic::name, eoib_device::netdev, netdev, netdev_close(), and netdev_is_open().

Referenced by xve_update_state().

                                                                          {
        struct net_device *netdev = eoib->netdev;

        /* Do nothing if network device is already closed */
        if ( ! netdev_is_open ( netdev ) )
                return;

        /* Close network device */
        netdev_close ( netdev );
        DBGC ( xve, "XVE %s closed network device\n", xve->name );
}
static int xve_update_state ( struct xsigo_nic xve,
struct eoib_device eoib,
int  open 
) [static]

Update virtual Ethernet device administrative state.

Parameters:
xveVirtual Ethernet device
eoibEoIB device
openNew administrative state
Return values:
rcReturn status code

Definition at line 385 of file xsigo.c.

References xve_close(), and xve_open().

Referenced by xsmp_rx_xve_modify().

                                         {

        /* Open or close device, as applicable */
        if ( open ) {
                return xve_open ( xve, eoib );
        } else {
                xve_close ( xve, eoib );
                return 0;
        }
}
static int xve_update_tca ( struct xsigo_nic xve,
struct eoib_device eoib,
struct ib_address_vector av 
) [static]

Update gateway (TCA)

Parameters:
xveVirtual Ethernet device
eoibEoIB device
avAddress vector, or NULL if no gateway
Return values:
rcReturn status code

Definition at line 405 of file xsigo.c.

References DBGC, eoib_set_gateway(), ib_address_vector::gid, IB_GID_ARGS, IB_GID_FMT, xsigo_nic::name, ib_address_vector::qkey, and ib_address_vector::qpn.

Referenced by xsmp_rx_xve_modify().

                                                           {

        /* Update gateway address */
        eoib_set_gateway ( eoib, av );
        if ( av ) {
                DBGC ( xve, "XVE %s has TCA " IB_GID_FMT " data %#lx qkey "
                       "%#lx\n", xve->name, IB_GID_ARGS ( &av->gid ), av->qpn,
                       av->qkey );
        } else {
                DBGC ( xve, "XVE %s has no TCA\n", xve->name );
        }

        /* The Linux driver will modify the local device's link state
         * to reflect the EoIB-to-Ethernet gateway's link state, but
         * this seems philosophically incorrect since communication
         * within the EoIB broadcast domain still works regardless of
         * the state of the gateway.
         */

        return 0;
}
static const char* xsmp_session_type ( unsigned int  type) [static]

Get session message name (for debugging)

Parameters:
typeMessage type
Return values:
nameMessage name

Definition at line 441 of file xsigo.c.

References snprintf(), XSMP_SESSION_TYPE_CONFIRM, XSMP_SESSION_TYPE_HELLO, XSMP_SESSION_TYPE_REGISTER, XSMP_SESSION_TYPE_REJECT, and XSMP_SESSION_TYPE_SHUTDOWN.

                                                            {
        static char buf[16];

        switch ( type ) {
        case XSMP_SESSION_TYPE_HELLO:           return "HELLO";
        case XSMP_SESSION_TYPE_REGISTER:        return "REGISTER";
        case XSMP_SESSION_TYPE_CONFIRM:         return "CONFIRM";
        case XSMP_SESSION_TYPE_REJECT:          return "REJECT";
        case XSMP_SESSION_TYPE_SHUTDOWN:        return "SHUTDOWN";
        default:
                snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", type );
                return buf;
        }
}
static const char* xsmp_chassis_name ( struct xsmp_session_message msg) [static]

Extract chassis name (for debugging)

Parameters:
msgSession message
Return values:
chassisChassis name

Definition at line 462 of file xsigo.c.

References xsmp_session_message::chassis, and memcpy().

Referenced by xsmp_rx_session_confirm(), xsmp_rx_session_reject(), and xsmp_rx_session_shutdown().

                                                                           {
        static char chassis[ sizeof ( msg->chassis ) + 1 /* NUL */ ];

        memcpy ( chassis, msg->chassis, sizeof ( msg->chassis ) );
        return chassis;
}
static const char* xsmp_session_name ( struct xsmp_session_message msg) [static]

Extract session name (for debugging)

Parameters:
msgSession message
Return values:
sessionSession name

Definition at line 475 of file xsigo.c.

References memcpy(), session, and xsmp_session_message::session.

Referenced by xsmp_rx_session_confirm().

                                                                           {
        static char session[ sizeof ( msg->session ) + 1 /* NUL */ ];

        memcpy ( session, msg->session, sizeof ( msg->session ) );
        return session;
}
static int xsmp_tx_session ( struct xsigo_manager xcm,
unsigned int  type 
) [static]

Send session message.

Parameters:
xcmConfiguration manager
typeMessage type
Return values:
rcReturn status code

Definition at line 489 of file xsigo.c.

References xsmp_session_message::boot, DBGC, DBGCP, DBGCP_HDA, xsmp_message_header::dst, ib_device::gid, ib_gid::guid, xsigo_manager_id::guid, xsmp_node_id::guid, xsmp_session_message::hdr, htonl, htons, xsigo_device::ibdev, xsigo_manager::id, xsmp_message_header::len, xsmp_session_message::len, memcpy(), memset(), xsigo_manager::name, ntohl, xsmp_session_message::os_type, rc, xsmp_session_message::resources, ib_gid::s, xsigo_manager::seq, xsmp_message_header::seq, xsmp_message_header::src, strerror(), xsmp_message_header::type, xsmp_session_message::type, type, xsigo_manager::xdev, xsigo_manager::xfer, xfer_deliver_raw(), XSIGO_OS_TYPE_GENERIC, XSIGO_RESOURCE_NO_HA, XSIGO_RESOURCE_XVE, XSMP_BOOT_PXE, and XSMP_TYPE_SESSION.

Referenced by xsmp_tx_session_hello(), and xsmp_tx_session_register().

                                                                            {
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        struct xsmp_session_message msg;
        int rc;

        /* Construct session message */
        memset ( &msg, 0, sizeof ( msg ) );
        msg.hdr.type = XSMP_TYPE_SESSION;
        msg.hdr.len = htons ( sizeof ( msg ) );
        msg.hdr.seq = htonl ( ++xcm->seq );
        memcpy ( &msg.hdr.src.guid, &ibdev->gid.s.guid,
                 sizeof ( msg.hdr.src.guid ) );
        memcpy ( &msg.hdr.dst.guid, &xcm->id.guid,
                 sizeof ( msg.hdr.dst.guid ) );
        msg.type = type;
        msg.len = htons ( sizeof ( msg ) - sizeof ( msg.hdr ) );
        msg.os_type = XSIGO_OS_TYPE_GENERIC;
        msg.resources = htons ( XSIGO_RESOURCE_XVE |
                                XSIGO_RESOURCE_NO_HA );
        msg.boot = htonl ( XSMP_BOOT_PXE );
        DBGCP ( xcm, "XCM %s TX[%d] session %s\n", xcm->name,
                ntohl ( msg.hdr.seq ), xsmp_session_type ( msg.type ) );
        DBGCP_HDA ( xcm, 0, &msg, sizeof ( msg ) );

        /* Send session message */
        if ( ( rc = xfer_deliver_raw ( &xcm->xfer, &msg,
                                       sizeof ( msg ) ) ) != 0 ) {
                DBGC ( xcm, "XCM %s TX session %s failed: %s\n", xcm->name,
                       xsmp_session_type ( msg.type ), strerror ( rc ) );
                return rc;
        }

        return 0;
}
static int xsmp_tx_session_register ( struct xsigo_manager xcm) [inline, static]

Send registration message.

Parameters:
xcmConfiguration manager
Return values:
rcReturn status code

Definition at line 531 of file xsigo.c.

References DBGC, xsigo_manager_id::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::id, xsigo_manager::name, XSMP_SESSION_TYPE_REGISTER, and xsmp_tx_session().

Referenced by xcm_step().

                                                                         {

        DBGC ( xcm, "XCM %s registering with " IB_GUID_FMT "\n",
               xcm->name, IB_GUID_ARGS ( &xcm->id.guid ) );

        /* Send registration message */
        return xsmp_tx_session ( xcm, XSMP_SESSION_TYPE_REGISTER );
}
static int xsmp_tx_session_hello ( struct xsigo_manager xcm) [static]

Send keepalive message.

Parameters:
xcmConfiguration manager
Return values:
rcReturn status code

Definition at line 546 of file xsigo.c.

References XSMP_SESSION_TYPE_HELLO, and xsmp_tx_session().

Referenced by xcm_keepalive(), and xsmp_rx_session_hello().

                                                               {

        /* Send keepalive message */
        return xsmp_tx_session ( xcm, XSMP_SESSION_TYPE_HELLO );
}
static int xsmp_rx_session_hello ( struct xsigo_manager xcm,
struct xsmp_session_message *msg  __unused 
) [static]

Handle received keepalive message.

Parameters:
xcmConfiguration manager
msgKeepalive message
Return values:
rcReturn status code

Definition at line 559 of file xsigo.c.

References xsmp_tx_session_hello().

Referenced by xsmp_rx_session().

                                                                               {

        /* Respond to keepalive message.  Note that the XCM doesn't
         * seem to actually ever send these.
         */
        return xsmp_tx_session_hello ( xcm );
}
static int xsmp_rx_session_confirm ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
) [static]

Handle received registration confirmation message.

Parameters:
xcmConfiguration manager
msgRegistration confirmation message
Return values:
rcReturn status code

Definition at line 575 of file xsigo.c.

References DBGC, xsigo_manager::name, xsmp_chassis_name(), and xsmp_session_name().

Referenced by xsmp_rx_session().

                                                                        {

        DBGC ( xcm, "XCM %s registered with \"%s\" as \"%s\"\n", xcm->name,
               xsmp_chassis_name ( msg ), xsmp_session_name ( msg ) );

        return 0;
}
static int xsmp_rx_session_reject ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
) [static]

Handle received registration rejection message.

Parameters:
xcmConfiguration manager
msgRegistration confirmation message
Return values:
rcReturn status code

Definition at line 591 of file xsigo.c.

References DBGC, DBGC_HDA, EPERM, xsigo_manager::name, and xsmp_chassis_name().

Referenced by xsmp_rx_session().

                                                                       {

        DBGC ( xcm, "XCM %s rejected by \"%s\":\n",
               xcm->name, xsmp_chassis_name ( msg ) );
        DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );

        return -EPERM;
}
static int xsmp_rx_session_shutdown ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
) [static]

Handle received shutdown message.

Parameters:
xcmConfiguration manager
msgRegistration confirmation message
Return values:
rcReturn status code

Definition at line 608 of file xsigo.c.

References DBGC, DBGC_HDA, ENOTCONN, xsigo_manager::name, and xsmp_chassis_name().

Referenced by xsmp_rx_session().

                                                                         {

        DBGC ( xcm, "XCM %s shut down by \"%s\":\n",
               xcm->name, xsmp_chassis_name ( msg ) );
        DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );

        return -ENOTCONN;
}
static int xsmp_rx_session ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
) [static]

Handle received session message.

Parameters:
xcmConfiguration manager
msgSession message
Return values:
rcReturn status code

Definition at line 625 of file xsigo.c.

References DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, EPROTO, xsmp_session_message::hdr, xsigo_manager::name, ntohl, xsmp_message_header::seq, xsmp_session_message::type, xsmp_rx_session_confirm(), xsmp_rx_session_hello(), xsmp_rx_session_reject(), xsmp_rx_session_shutdown(), XSMP_SESSION_TYPE_CONFIRM, XSMP_SESSION_TYPE_HELLO, XSMP_SESSION_TYPE_REJECT, and XSMP_SESSION_TYPE_SHUTDOWN.

Referenced by xcm_deliver().

                                                                {

        DBGCP ( xcm, "XCM %s RX[%d] session %s\n", xcm->name,
                ntohl ( msg->hdr.seq ), xsmp_session_type ( msg->type ) );
        DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );

        /* Handle message according to type */
        switch ( msg->type ) {
        case XSMP_SESSION_TYPE_HELLO:
                return xsmp_rx_session_hello ( xcm, msg );
        case XSMP_SESSION_TYPE_CONFIRM:
                return xsmp_rx_session_confirm ( xcm, msg );
        case XSMP_SESSION_TYPE_REJECT:
                return xsmp_rx_session_reject ( xcm, msg );
        case XSMP_SESSION_TYPE_SHUTDOWN:
                return xsmp_rx_session_shutdown ( xcm, msg );
        default:
                DBGC ( xcm, "XCM %s RX[%d] session unexpected %s:\n", xcm->name,
                       ntohl ( msg->hdr.seq ), xsmp_session_type ( msg->type ));
                DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
                return -EPROTO;
        }
}
static const char* xsmp_xve_type ( unsigned int  type) [static]

Get virtual Ethernet message name (for debugging)

Parameters:
typeMessage type
Return values:
nameMessage name

Definition at line 663 of file xsigo.c.

References snprintf(), XSMP_XVE_TYPE_DELETE, XSMP_XVE_TYPE_INSTALL, XSMP_XVE_TYPE_OPER_DOWN, XSMP_XVE_TYPE_OPER_REQ, XSMP_XVE_TYPE_OPER_UP, XSMP_XVE_TYPE_READY, and XSMP_XVE_TYPE_UPDATE.

                                                        {
        static char buf[16];

        switch ( type ) {
        case XSMP_XVE_TYPE_INSTALL:             return "INSTALL";
        case XSMP_XVE_TYPE_DELETE:              return "DELETE";
        case XSMP_XVE_TYPE_UPDATE:              return "UPDATE";
        case XSMP_XVE_TYPE_OPER_UP:             return "OPER_UP";
        case XSMP_XVE_TYPE_OPER_DOWN:           return "OPER_DOWN";
        case XSMP_XVE_TYPE_OPER_REQ:            return "OPER_REQ";
        case XSMP_XVE_TYPE_READY:               return "READY";
        default:
                snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", type );
                return buf;
        }
}
static int xsmp_tx_xve ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Send virtual Ethernet message.

Parameters:
xcmConfiguration manager
msgPartial message
Return values:
rcReturn status code

Definition at line 687 of file xsigo.c.

References xsmp_xve_message::code, DBGC, DBGCP, DBGCP_HDA, xsmp_message_header::dst, ib_device::gid, ib_gid::guid, xsigo_manager_id::guid, xsmp_node_id::guid, xsmp_xve_message::hdr, htonl, htons, xsigo_device::ibdev, xsigo_manager::id, xsmp_message_header::len, xsmp_xve_message::len, memcpy(), xsigo_manager::name, ntohl, rc, ib_gid::s, xsigo_manager::seq, xsmp_message_header::seq, xsmp_message_header::src, strerror(), xsmp_message_header::type, xsmp_xve_message::type, xsigo_manager::xdev, xsigo_manager::xfer, xfer_deliver_raw(), and XSMP_TYPE_XVE.

Referenced by xsmp_rx_xve_delete(), xsmp_tx_xve_nack(), and xsmp_tx_xve_params().

                                                        {
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        int rc;

        /* Fill in common header fields */
        msg->hdr.type = XSMP_TYPE_XVE;
        msg->hdr.len = htons ( sizeof ( *msg ) );
        msg->hdr.seq = htonl ( ++xcm->seq );
        memcpy ( &msg->hdr.src.guid, &ibdev->gid.s.guid,
                 sizeof ( msg->hdr.src.guid ) );
        memcpy ( &msg->hdr.dst.guid, &xcm->id.guid,
                 sizeof ( msg->hdr.dst.guid ) );
        msg->len = htons ( sizeof ( *msg ) - sizeof ( msg->hdr ) );
        DBGCP ( xcm, "XCM %s TX[%d] xve %s code %#02x\n", xcm->name,
                ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ),
                msg->code );
        DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );

        /* Send virtual Ethernet message */
        if ( ( rc = xfer_deliver_raw ( &xcm->xfer, msg,
                                       sizeof ( *msg ) ) ) != 0 ) {
                DBGC ( xcm, "XCM %s TX xve %s failed: %s\n", xcm->name,
                       xsmp_xve_type ( msg->type ), strerror ( rc ) );
                return rc;
        }

        return 0;
}
static int xsmp_tx_xve_params ( struct xsigo_manager xcm,
struct xsmp_xve_message msg,
struct xsigo_nic xve,
struct eoib_device eoib 
) [static]

Send virtual Ethernet message including current device parameters.

Parameters:
xcmConfiguration manager
msgPartial virtual Ethernet message
xveVirtual Ethernet device
eoibEoIB device
Return values:
rcReturn status code

Definition at line 727 of file xsigo.c.

References bswap_64, xsmp_xve_message::code, xsmp_xve_ca::ctrl, xsmp_xve_ca::data, DBGC, ib_queue_pair::ext_qpn, ib_device::gid, xsmp_xve_message::hca, htonl, htons, xsigo_device::ibdev, net_device::max_pkt_len, xsmp_xve_message::mtu, xsigo_nic::name, eoib_device::netdev, netdev, netdev_is_open(), xsigo_nic::network, xsmp_xve_message::network, ntohl, ntohs, xsmp_xve_ca::pkey, ib_device::pkey, ib_gid::prefix, xsmp_xve_ca::prefix_le, ib_queue_pair::qkey, xsmp_xve_ca::qkey, eoib_device::qp, ib_guid::qword, ib_gid::s, xsmp_xve_message::tca, xsmp_xve_message::type, xsigo_manager::xdev, xsmp_tx_xve(), XSMP_XVE_TYPE_OPER_DOWN, XSMP_XVE_TYPE_OPER_REQ, and XSMP_XVE_TYPE_OPER_UP.

Referenced by xsmp_rx_xve_modify(), and xsmp_tx_xve_notify().

                                                           {
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        struct net_device *netdev = eoib->netdev;

        /* Set successful response code */
        msg->code = 0;

        /* Include network identifier, MTU, and current HCA parameters */
        msg->network = htonl ( xve->network );
        msg->mtu = htons ( netdev->max_pkt_len - sizeof ( struct ethhdr ) );
        msg->hca.prefix_le.qword = bswap_64 ( ibdev->gid.s.prefix.qword );
        msg->hca.pkey = htons ( ibdev->pkey );
        msg->hca.qkey = msg->tca.qkey;
        if ( eoib->qp ) {
                msg->hca.data = htonl ( eoib->qp->ext_qpn );
                msg->hca.qkey = htons ( eoib->qp->qkey );
        }

        /* The message type field is (ab)used to return the current
         * operational status.
         */
        if ( msg->type == XSMP_XVE_TYPE_OPER_REQ ) {
                msg->type = ( netdev_is_open ( netdev ) ?
                              XSMP_XVE_TYPE_OPER_UP : XSMP_XVE_TYPE_OPER_DOWN );
        }

        /* Send message */
        DBGC ( xve, "XVE %s network %d MTU %d ctrl %#x data %#x qkey %#04x "
               "%s\n", xve->name, ntohl ( msg->network ), ntohs ( msg->mtu ),
               ntohl ( msg->hca.ctrl ), ntohl ( msg->hca.data ),
               ntohs ( msg->hca.qkey ), xsmp_xve_type ( msg->type ) );

        return xsmp_tx_xve ( xcm, msg );
}
static int xsmp_tx_xve_nack ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [inline, static]

Send virtual Ethernet error response.

Parameters:
xcmConfiguration manager
msgPartial virtual Ethernet message
Return values:
rcReturn status code

Definition at line 773 of file xsigo.c.

References xsmp_xve_message::code, xsmp_tx_xve(), and XSMP_XVE_CODE_ERROR.

Referenced by xsmp_rx_xve_install(), and xsmp_rx_xve_modify().

                                                                    {

        /* Set error response code.  (There aren't any meaningful
         * detailed response codes defined by the wire protocol.)
         */
        msg->code = XSMP_XVE_CODE_ERROR;

        /* Send message */
        return xsmp_tx_xve ( xcm, msg );
}
static int xsmp_tx_xve_notify ( struct xsigo_manager xcm,
unsigned int  type,
struct xsigo_nic xve,
struct eoib_device eoib 
) [static]

Send virtual Ethernet notification.

Parameters:
xcmConfiguration manager
typeMessage type
xveVirtual Ethernet device
eoibEoIB device
Return values:
rcReturn status code

Definition at line 794 of file xsigo.c.

References memcpy(), memset(), xsigo_nic::resource, xsmp_xve_message::resource, xsmp_xve_message::type, type, and xsmp_tx_xve_params().

Referenced by xsmp_tx_xve_oper().

                                                           {
        struct xsmp_xve_message msg;

        /* Construct message */
        memset ( &msg, 0, sizeof ( msg ) );
        msg.type = type;
        memcpy ( &msg.resource, &xve->resource, sizeof ( msg.resource ) );

        /* Send message */
        return xsmp_tx_xve_params ( xcm, &msg, xve, eoib );
}
static int xsmp_tx_xve_oper ( struct xsigo_manager xcm,
struct xsigo_nic xve,
struct eoib_device eoib 
) [inline, static]

Send virtual Ethernet current operational state.

Parameters:
xcmConfiguration manager
xveVirtual Ethernet device
eoibEoIB device
Return values:
rcReturn status code

Definition at line 817 of file xsigo.c.

References xsmp_tx_xve_notify(), and XSMP_XVE_TYPE_OPER_REQ.

Referenced by xsigo_net_notify().

                                                                {

        /* Send notification */
        return xsmp_tx_xve_notify ( xcm, XSMP_XVE_TYPE_OPER_REQ, xve, eoib );
}
static int xsmp_rx_xve_modify ( struct xsigo_manager xcm,
struct xsmp_xve_message msg,
unsigned int  update 
) [static]

Handle received virtual Ethernet modification message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
updateUpdate bitmask
Return values:
rcReturn status code

Definition at line 833 of file xsigo.c.

References bswap_64, xsmp_xve_ca::data, DBGC, ENOENT, eoib_find(), eoib_force_group_creation(), EPIPE, ib_address_vector::gid, ib_address_vector::gid_present, ib_gid::guid, xsmp_xve_message::guid_le, xsmp_xve_message::hca, IB_GUID_ARGS, IB_GUID_FMT, xsigo_device::ibdev, xsigo_nic::mac, memset(), mtu, xsmp_xve_message::mtu, xsigo_manager::name, xsigo_nic::name, ntohl, ntohs, NULL, ib_gid::prefix, xsmp_xve_ca::prefix_le, ib_address_vector::qkey, xsmp_xve_ca::qkey, ib_address_vector::qpn, ib_guid::qword, rc, xsmp_xve_message::resource, ib_gid::s, xsmp_xve_message::state, xsmp_xve_message::tca, xsigo_manager::xdev, xsmp_tx_xve_nack(), xsmp_tx_xve_params(), XSMP_XVE_UPDATE_GW_CHANGE, XSMP_XVE_UPDATE_GW_DOWN, XSMP_XVE_UPDATE_MTU, XSMP_XVE_UPDATE_STATE, xve_find(), xve_update_mtu(), xve_update_state(), and xve_update_tca().

Referenced by xsmp_rx_xve_install(), xsmp_rx_xve_oper_req(), xsmp_rx_xve_ready(), and xsmp_rx_xve_update().

                                                      {
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        struct xsigo_nic *xve;
        struct eoib_device *eoib;
        struct ib_address_vector tca;
        size_t mtu;
        int rc;

        /* Avoid returning uninitialised HCA parameters in response */
        memset ( &msg->hca, 0, sizeof ( msg->hca ) );

        /* Find virtual Ethernet device */
        xve = xve_find ( xcm, &msg->resource );
        if ( ! xve ) {
                DBGC ( xcm, "XCM %s unrecognised resource " IB_GUID_FMT "\n",
                       xcm->name, IB_GUID_ARGS ( &msg->resource ) );
                rc = -ENOENT;
                goto err_no_xve;
        }

        /* Find corresponding EoIB device */
        eoib = eoib_find ( ibdev, xve->mac );
        if ( ! eoib ) {
                DBGC ( xve, "XVE %s has no EoIB device\n", xve->name );
                rc = -EPIPE;
                goto err_no_eoib;
        }

        /* The Xsigo management software fails to create the EoIB
         * multicast group.  This is a fundamental design flaw.
         */
        eoib_force_group_creation ( eoib );

        /* Extract modifiable parameters.  Note that the TCA GID is
         * erroneously transmitted as little-endian.
         */
        mtu = ntohs ( msg->mtu );
        tca.qpn = ntohl ( msg->tca.data );
        tca.qkey = ntohs ( msg->tca.qkey );
        tca.gid_present = 1;
        tca.gid.s.prefix.qword = bswap_64 ( msg->tca.prefix_le.qword );
        tca.gid.s.guid.qword = bswap_64 ( msg->guid_le.qword );

        /* Update MTU, if applicable */
        if ( ( update & XSMP_XVE_UPDATE_MTU ) &&
             ( ( rc = xve_update_mtu ( xve, eoib, mtu ) ) != 0 ) )
                goto err_mtu;
        update &= ~XSMP_XVE_UPDATE_MTU;

        /* Update admin state, if applicable */
        if ( ( update & XSMP_XVE_UPDATE_STATE ) &&
             ( ( rc = xve_update_state ( xve, eoib, msg->state ) ) != 0 ) )
                goto err_state;
        update &= ~XSMP_XVE_UPDATE_STATE;

        /* Remove gateway, if applicable */
        if ( ( update & XSMP_XVE_UPDATE_GW_DOWN ) &&
             ( ( rc = xve_update_tca ( xve, eoib, NULL ) ) != 0 ) )
                goto err_gw_down;
        update &= ~XSMP_XVE_UPDATE_GW_DOWN;

        /* Update gateway, if applicable */
        if ( ( update & XSMP_XVE_UPDATE_GW_CHANGE ) &&
             ( ( rc = xve_update_tca ( xve, eoib, &tca ) ) != 0 ) )
                goto err_gw_change;
        update &= ~XSMP_XVE_UPDATE_GW_CHANGE;

        /* Warn about unexpected updates */
        if ( update ) {
                DBGC ( xve, "XVE %s unrecognised update(s) %#08x\n",
                       xve->name, update );
        }

        xsmp_tx_xve_params ( xcm, msg, xve, eoib );
        return 0;

 err_gw_change:
 err_gw_down:
 err_state:
 err_mtu:
 err_no_eoib:
 err_no_xve:
        /* Send NACK */
        xsmp_tx_xve_nack ( xcm, msg );
        return rc;
}
static int xsmp_rx_xve_install ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet installation message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 930 of file xsigo.c.

References bswap_16, bswap_32, DBGC2, ETH_ALEN, eth_ntoa(), xsmp_xve_mac::high, IB_GUID_ARGS, IB_GUID_FMT, xsmp_xve_mac::low, mac, xsmp_xve_message::mac_le, memcpy(), xsigo_manager::name, xsmp_xve_message::name, name, xsmp_xve_message::network, ntohl, ntohs, NULL, xsmp_xve_ca::qkey, qkey, raw, rc, xsmp_xve_message::resource, xsmp_xve_message::tca, xsmp_xve_message::uplink, xsmp_rx_xve_modify(), xsmp_tx_xve_nack(), XSMP_XVE_UPDATE_GW_CHANGE, XSMP_XVE_UPDATE_MTU, XSMP_XVE_UPLINK, xve_create(), and xve_find().

Referenced by xsmp_rx_xve().

                                                                {
        union {
                struct xsmp_xve_mac msg;
                uint8_t raw[ETH_ALEN];
        } mac;
        char name[ sizeof ( msg->name ) + 1 /* NUL */ ];
        unsigned long network;
        unsigned long qkey;
        unsigned int update;
        int rc;

        /* Demangle MAC address (which is erroneously transmitted as
         * little-endian).
         */
        mac.msg.high = bswap_16 ( msg->mac_le.high );
        mac.msg.low = bswap_32 ( msg->mac_le.low );

        /* Extract interface name (which may not be NUL-terminated) */
        memcpy ( name, msg->name, ( sizeof ( name ) - 1 /* NUL */ ) );
        name[ sizeof ( name ) - 1 /* NUL */ ] = '\0';

        /* Extract remaining message parameters */
        network = ntohl ( msg->network );
        qkey = ntohs ( msg->tca.qkey );
        DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " install \"%s\" %s net %ld qkey "
                "%#lx\n", xcm->name, IB_GUID_ARGS ( &msg->resource ), name,
                eth_ntoa ( mac.raw ), network, qkey );

        /* Create virtual Ethernet device, if applicable */
        if ( ( xve_find ( xcm, &msg->resource ) == NULL ) &&
             ( ( rc = xve_create ( xcm, &msg->resource, mac.raw, network,
                                   qkey, name ) ) != 0 ) )
                goto err_create;

        /* Handle remaining parameters as for a modification message */
        update = XSMP_XVE_UPDATE_MTU;
        if ( msg->uplink == XSMP_XVE_UPLINK )
                update |= XSMP_XVE_UPDATE_GW_CHANGE;
        return xsmp_rx_xve_modify ( xcm, msg, update );

 err_create:
        /* Send NACK */
        xsmp_tx_xve_nack ( xcm, msg );
        return rc;
}
static int xsmp_rx_xve_delete ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet deletion message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 984 of file xsigo.c.

References xsmp_xve_message::code, DBGC2, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::name, xsmp_xve_message::resource, xsmp_tx_xve(), xve_destroy(), and xve_find().

Referenced by xsmp_rx_xve().

                                                               {
        struct xsigo_nic *xve;

        DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " delete\n",
                xcm->name, IB_GUID_ARGS ( &msg->resource ) );

        /* Destroy virtual Ethernet device (if any) */
        if ( ( xve = xve_find ( xcm, &msg->resource ) ) )
                xve_destroy ( xve );

        /* Send ACK */
        msg->code = 0;
        xsmp_tx_xve ( xcm, msg );

        return 0;
}
static int xsmp_rx_xve_update ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet update message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 1009 of file xsigo.c.

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::name, ntohl, xsmp_xve_message::resource, xsmp_xve_message::update, and xsmp_rx_xve_modify().

Referenced by xsmp_rx_xve().

                                                               {
        unsigned int update = ntohl ( msg->update );

        DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " update (%08x)\n",
                xcm->name, IB_GUID_ARGS ( &msg->resource ), update );

        /* Handle as a modification message */
        return xsmp_rx_xve_modify ( xcm, msg, update );
}
static int xsmp_rx_xve_oper_req ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet operational request message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 1027 of file xsigo.c.

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::name, xsmp_xve_message::resource, and xsmp_rx_xve_modify().

Referenced by xsmp_rx_xve().

                                                                 {

        DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " operational request\n",
                xcm->name, IB_GUID_ARGS ( &msg->resource ) );

        /* Handle as a nullipotent modification message */
        return xsmp_rx_xve_modify ( xcm, msg, 0 );
}
static int xsmp_rx_xve_ready ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet readiness message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 1044 of file xsigo.c.

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::name, rc, xsmp_xve_message::resource, xsmp_xve_message::type, xsmp_rx_xve_modify(), and XSMP_XVE_TYPE_OPER_REQ.

Referenced by xsmp_rx_xve().

                                                              {
        int rc;

        DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " ready\n",
                xcm->name, IB_GUID_ARGS ( &msg->resource ) );

        /* Handle as a nullipotent modification message */
        if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
                return rc;

        /* Send an unsolicited operational state update, since there
         * is no other way to convey the current operational state.
         */
        msg->type = XSMP_XVE_TYPE_OPER_REQ;
        if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
                return rc;

        return 0;
}
static int xsmp_rx_xve ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
) [static]

Handle received virtual Ethernet message.

Parameters:
xcmConfiguration manager
msgVirtual Ethernet message
Return values:
rcReturn status code

Definition at line 1072 of file xsigo.c.

References DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, EPROTO, xsmp_xve_message::hdr, xsigo_manager::name, ntohl, xsmp_message_header::seq, xsmp_xve_message::type, xsmp_rx_xve_delete(), xsmp_rx_xve_install(), xsmp_rx_xve_oper_req(), xsmp_rx_xve_ready(), xsmp_rx_xve_update(), XSMP_XVE_TYPE_DELETE, XSMP_XVE_TYPE_INSTALL, XSMP_XVE_TYPE_OPER_REQ, XSMP_XVE_TYPE_READY, and XSMP_XVE_TYPE_UPDATE.

Referenced by xcm_deliver().

                                                        {

        DBGCP ( xcm, "XCM %s RX[%d] xve %s\n", xcm->name,
                ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
        DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );

        /* Handle message according to type */
        switch ( msg->type ) {
        case XSMP_XVE_TYPE_INSTALL:
                return xsmp_rx_xve_install ( xcm, msg );
        case XSMP_XVE_TYPE_DELETE:
                return xsmp_rx_xve_delete ( xcm, msg );
        case XSMP_XVE_TYPE_UPDATE:
                return xsmp_rx_xve_update ( xcm, msg );
        case XSMP_XVE_TYPE_OPER_REQ:
                return xsmp_rx_xve_oper_req ( xcm, msg );
        case XSMP_XVE_TYPE_READY:
                return xsmp_rx_xve_ready ( xcm, msg );
        default:
                DBGC ( xcm, "XCM %s RX[%d] xve unexpected %s:\n", xcm->name,
                       ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
                DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
                return -EPROTO;
        }
}
static void xcm_close ( struct xsigo_manager xcm,
int  rc 
) [static]

Close configuration manager connection.

Parameters:
xcmConfiguration manager
rcReason for close

Definition at line 1112 of file xsigo.c.

References DBGC, intf_restart(), xsigo_manager::keepalive, xsigo_manager::name, xsigo_manager::process, process_del(), xsigo_manager::reopen, start_timer(), stop_timer(), strerror(), and xsigo_manager::xfer.

Referenced by xcm_deliver(), xcm_keepalive(), and xcm_step().

                                                            {

        DBGC ( xcm, "XCM %s closed: %s\n", xcm->name, strerror ( rc ) );

        /* Stop transmission process */
        process_del ( &xcm->process );

        /* Stop keepalive timer */
        stop_timer ( &xcm->keepalive );

        /* Restart data transfer interface */
        intf_restart ( &xcm->xfer, rc );

        /* Schedule reconnection attempt */
        start_timer ( &xcm->reopen );
}
static void xcm_step ( struct xsigo_manager xcm) [static]

Send data to configuration manager.

Parameters:
xcmConfiguration manager

Definition at line 1134 of file xsigo.c.

References DBGC, xsigo_manager::name, NULL, xsigo_manager::pending, rc, strerror(), xcm_close(), XCM_TX_CONNECT, XCM_TX_REGISTER, xsigo_manager::xfer, xfer_deliver_raw(), xfer_window(), and xsmp_tx_session_register().

                                                   {
        int rc;

        /* Do nothing unless we have something to send */
        if ( ! xcm->pending )
                return;

        /* Send (empty) connection request, if applicable */
        if ( xcm->pending & XCM_TX_CONNECT ) {
                if ( ( rc = xfer_deliver_raw ( &xcm->xfer, NULL, 0 ) ) != 0 ) {
                        DBGC ( xcm, "XCM %s could not send connection request: "
                               "%s\n", xcm->name, strerror ( rc ) );
                        goto err;
                }
                xcm->pending &= ~XCM_TX_CONNECT;
                return;
        }

        /* Wait until data transfer interface is connected */
        if ( ! xfer_window ( &xcm->xfer ) )
                return;

        /* Send registration message, if applicable */
        if ( xcm->pending & XCM_TX_REGISTER ) {
                if ( ( rc = xsmp_tx_session_register ( xcm ) ) != 0 )
                        goto err;
                xcm->pending &= ~XCM_TX_REGISTER;
                return;
        }

        return;

 err:
        xcm_close ( xcm, rc );
}
static int xcm_deliver ( struct xsigo_manager xcm,
struct io_buffer iobuf,
struct xfer_metadata *meta  __unused 
) [static]

Receive data from configuration manager.

Parameters:
xcmConfiguration manager
iobufI/O buffer
metaData transfer metadata
Return values:
rcReturn status code

Definition at line 1178 of file xsigo.c.

References io_buffer::data, DBGC, DBGC_HDA, EPROTO, free_iob(), xsmp_message::hdr, iob_len(), len, msg(), xsigo_manager::name, out, rc, xsmp_message::sess, xsmp_message_header::type, xcm_close(), xsmp_rx_session(), xsmp_rx_xve(), XSMP_TYPE_SESSION, XSMP_TYPE_XVE, and xsmp_message::xve.

                                                               {
        union xsmp_message *msg;
        size_t len = iob_len ( iobuf );
        int rc;

        /* Sanity check */
        if ( len < sizeof ( msg->hdr ) ) {
                DBGC ( xcm, "XCM %s underlength message:\n", xcm->name );
                DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
                rc = -EPROTO;
                goto out;
        }
        msg = iobuf->data;

        /* Handle message according to type */
        if ( ! msg->hdr.type ) {

                /* Ignore unused communication manager private data blocks */
                rc = 0;

        } else if ( ( msg->hdr.type == XSMP_TYPE_SESSION ) &&
                    ( len >= sizeof ( msg->sess ) ) ) {

                /* Session message */
                rc = xsmp_rx_session ( xcm, &msg->sess );

        } else if ( ( msg->hdr.type == XSMP_TYPE_XVE ) &&
                    ( len >= sizeof ( msg->xve ) ) ) {

                /* Virtual Ethernet message */
                xsmp_rx_xve ( xcm, &msg->xve );

                /* Virtual Ethernet message errors are non-fatal */
                rc = 0;

        } else {

                /* Unknown message */
                DBGC ( xcm, "XCM %s unexpected message type %d:\n",
                       xcm->name, msg->hdr.type );
                DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
                rc = -EPROTO;
        }

 out:
        free_iob ( iobuf );
        if ( rc != 0 )
                xcm_close ( xcm, rc );
        return rc;
}
static void xcm_reopen ( struct retry_timer timer,
int fail  __unused 
) [static]

Handle configuration manager connection timer expiry.

Parameters:
timerConnection timer
failFailure indicator

Definition at line 1251 of file xsigo.c.

References container_of, DBGC, ECANCELED, ib_device::gid, ib_gid::guid, xsigo_manager_id::guid, ib_cmrc_open(), IB_GID_ARGS, IB_GID_FMT, xsigo_device::ibdev, xsigo_manager::id, intf_restart(), xsigo_manager::keepalive, memcpy(), xsigo_manager::name, xsigo_manager::pending, ib_gid::prefix, xsigo_manager::process, process_add(), process_del(), rc, xsigo_manager::reopen, ib_gid::s, xsigo_manager::seq, start_timer(), start_timer_fixed(), stop_timer(), strerror(), XCM_TX_CONNECT, XCM_TX_REGISTER, xsigo_manager::xdev, xsigo_manager::xfer, and XSIGO_KEEPALIVE_INTERVAL.

Referenced by xcm_create().

                                                                        {
        struct xsigo_manager *xcm =
                container_of ( timer, struct xsigo_manager, reopen );
        struct xsigo_device *xdev = xcm->xdev;
        struct ib_device *ibdev = xdev->ibdev;
        union ib_gid gid;
        int rc;

        /* Stop transmission process */
        process_del ( &xcm->process );

        /* Stop keepalive timer */
        stop_timer ( &xcm->keepalive );

        /* Restart data transfer interface */
        intf_restart ( &xcm->xfer, -ECANCELED );

        /* Reset sequence number */
        xcm->seq = 0;

        /* Construct GID */
        memcpy ( &gid.s.prefix, &ibdev->gid.s.prefix, sizeof ( gid.s.prefix ) );
        memcpy ( &gid.s.guid, &xcm->id.guid, sizeof ( gid.s.guid ) );
        DBGC ( xcm, "XCM %s connecting to " IB_GID_FMT "\n",
               xcm->name, IB_GID_ARGS ( &gid ) );

        /* Open CMRC connection */
        if ( ( rc = ib_cmrc_open ( &xcm->xfer, ibdev, &gid,
                                   &xcm_service_id, xcm->name ) ) != 0 ) {
                DBGC ( xcm, "XCM %s could not open CMRC connection: %s\n",
                       xcm->name, strerror ( rc ) );
                start_timer ( &xcm->reopen );
                return;
        }

        /* Schedule transmissions */
        xcm->pending |= ( XCM_TX_CONNECT | XCM_TX_REGISTER );
        process_add ( &xcm->process );

        /* Start keepalive timer */
        start_timer_fixed ( &xcm->keepalive, XSIGO_KEEPALIVE_INTERVAL );

        return;
}
static void xcm_keepalive ( struct retry_timer timer,
int fail  __unused 
) [static]

Handle configuration manager keepalive timer expiry.

Parameters:
timerConnection timer
failFailure indicator

Definition at line 1302 of file xsigo.c.

References container_of, xsigo_manager::keepalive, rc, start_timer_fixed(), xcm_close(), XSIGO_KEEPALIVE_INTERVAL, and xsmp_tx_session_hello().

Referenced by xcm_create().

                                                                           {
        struct xsigo_manager *xcm =
                container_of ( timer, struct xsigo_manager, keepalive );
        int rc;

        /* Send keepalive message.  The server won't actually respond
         * to these, but it gives the RC queue pair a chance to
         * complain if it doesn't ever at least get an ACK.
         */
        if ( ( rc = xsmp_tx_session_hello ( xcm ) ) != 0 ) {
                xcm_close ( xcm, rc );
                return;
        }

        /* Restart keepalive timer */
        start_timer_fixed ( &xcm->keepalive, XSIGO_KEEPALIVE_INTERVAL );
}
static int xcm_create ( struct xsigo_device xdev,
struct xsigo_manager_id id 
) [static]

Create configuration manager.

Parameters:
xsigoXsigo device
idConfiguration manager ID
Return values:
rcReturn status code

Definition at line 1327 of file xsigo.c.

References DBGC, ENOMEM, xsigo_manager_id::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::id, INIT_LIST_HEAD, intf_init(), xsigo_manager::keepalive, xsigo_manager_id::lid, xsigo_manager::list, list_add, xsigo_device::managers, memcpy(), xsigo_device::name, xsigo_manager::name, xsigo_manager::nics, ntohs, xsigo_manager::process, process_init_stopped(), ref_get, ref_init, xsigo_device::refcnt, xsigo_manager::refcnt, xsigo_manager::reopen, snprintf(), start_timer_nodelay(), xcm_free(), xcm_keepalive(), xcm_reopen(), xsigo_manager::xdev, xsigo_manager::xfer, and zalloc().

Referenced by xcm_list().

                                                      {
        struct xsigo_manager *xcm;

        /* Allocate and initialise structure */
        xcm = zalloc ( sizeof ( *xcm ) );
        if ( ! xcm )
                return -ENOMEM;
        ref_init ( &xcm->refcnt, xcm_free );
        xcm->xdev = xdev;
        ref_get ( &xcm->xdev->refcnt );
        snprintf ( xcm->name, sizeof ( xcm->name ), "%s:xcm-%d",
                   xdev->name, ntohs ( id->lid ) );
        memcpy ( &xcm->id, id, sizeof ( xcm->id ) );
        intf_init ( &xcm->xfer, &xcm_xfer_desc, &xcm->refcnt );
        timer_init ( &xcm->keepalive, xcm_keepalive, &xcm->refcnt );
        timer_init ( &xcm->reopen, xcm_reopen, &xcm->refcnt );
        process_init_stopped ( &xcm->process, &xcm_process_desc, &xcm->refcnt );
        INIT_LIST_HEAD ( &xcm->nics );

        /* Start timer to open connection */
        start_timer_nodelay ( &xcm->reopen );

        /* Add to list of managers and transfer reference to list */
        list_add ( &xcm->list, &xdev->managers );
        DBGC ( xcm, "XCM %s created for " IB_GUID_FMT " (LID %d)\n", xcm->name,
               IB_GUID_ARGS ( &xcm->id.guid ), ntohs ( id->lid ) );
        return 0;
}
static struct xsigo_manager* xcm_find ( struct xsigo_device xdev,
struct xsigo_manager_id id 
) [static, read]

Find configuration manager.

Parameters:
xsigoXsigo device
idConfiguration manager ID
Return values:
xcmConfiguration manager, or NULL

Definition at line 1364 of file xsigo.c.

References xsigo_manager_id::guid, guid, xsigo_manager::id, list_for_each_entry, xsigo_device::managers, memcmp(), and NULL.

Referenced by xcm_list().

                                                                       {
        struct xsigo_manager *xcm;
        union ib_guid *guid = &id->guid;

        /* Find configuration manager */
        list_for_each_entry ( xcm, &xdev->managers, list ) {
                if ( memcmp ( guid, &xcm->id.guid, sizeof ( *guid ) ) == 0 )
                        return xcm;
        }
        return NULL;
}
static void xcm_destroy ( struct xsigo_manager xcm) [static]

Destroy configuration manager.

Parameters:
xcmConfiguration manager

Definition at line 1382 of file xsigo.c.

References DBGC, intf_shutdown(), xsigo_manager::keepalive, xsigo_manager::list, xsigo_nic::list, list_del, list_first_entry, xsigo_manager::name, xsigo_manager::nics, xsigo_manager::process, process_del(), ref_put, xsigo_manager::refcnt, xsigo_manager::reopen, stop_timer(), xsigo_manager::xfer, and xve_destroy().

Referenced by xcm_list().

                                                      {
        struct xsigo_nic *xve;

        /* Remove all EoIB NICs */
        while ( ( xve = list_first_entry ( &xcm->nics, struct xsigo_nic,
                                           list ) ) ) {
                xve_destroy ( xve );
        }

        /* Stop transmission process */
        process_del ( &xcm->process );

        /* Stop timers */
        stop_timer ( &xcm->keepalive );
        stop_timer ( &xcm->reopen );

        /* Shut down data transfer interface */
        intf_shutdown ( &xcm->xfer, 0 );

        /* Remove from list of managers and drop list's reference */
        DBGC ( xcm, "XCM %s destroyed\n", xcm->name );
        list_del ( &xcm->list );
        ref_put ( &xcm->refcnt );
}
static int xcm_list ( struct xsigo_device xdev,
struct xsigo_manager_id ids,
unsigned int  count 
) [static]

Synchronise list of configuration managers.

Parameters:
xdevXsigo device
idsList of manager IDs
countNumber of manager IDs
Return values:
rcReturn status code

Definition at line 1415 of file xsigo.c.

References count, DBGC, id, xsigo_manager::id, INIT_LIST_HEAD, xsigo_manager_id::lid, xsigo_manager::list, list_add_tail, list_del, list_for_each_entry_safe, list_splice, xsigo_device::managers, xsigo_device::name, rc, xsigo_manager::reopen, start_timer_nodelay(), strerror(), xcm_create(), xcm_destroy(), and xcm_find().

Referenced by xsigo_ib_remove(), and xsigo_xcm_complete().

                                           {
        struct xsigo_manager_id *id;
        struct xsigo_manager *xcm;
        struct xsigo_manager *tmp;
        struct list_head list;
        unsigned int i;
        int rc;

        /* Create list of managers to be retained */
        INIT_LIST_HEAD ( &list );
        for ( i = 0, id = ids ; i < count ; i++, id++ ) {
                if ( ( xcm = xcm_find ( xdev, id ) ) ) {
                        list_del ( &xcm->list );
                        list_add_tail ( &xcm->list, &list );
                }
        }

        /* Destroy any managers not in the list */
        list_for_each_entry_safe ( xcm, tmp, &xdev->managers, list )
                xcm_destroy ( xcm );
        list_splice ( &list, &xdev->managers );

        /* Create any new managers in the list, and force reconnection
         * for any changed LIDs.
         */
        for ( i = 0, id = ids ; i < count ; i++, id++ ) {
                if ( ( xcm = xcm_find ( xdev, id ) ) ) {
                        if ( xcm->id.lid != id->lid )
                                start_timer_nodelay ( &xcm->reopen );
                        continue;
                }
                if ( ( rc = xcm_create ( xdev, id ) ) != 0 ) {
                        DBGC ( xdev, "XDEV %s could not create manager: %s\n",
                               xdev->name, strerror ( rc ) );
                        return rc;
                }
        }

        return 0;
}
static void xsigo_xcm_complete ( struct ib_device ibdev,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx,
int  rc,
union ib_mad mad,
struct ib_address_vector *av  __unused 
) [static]

Handle configuration manager lookup completion.

Parameters:
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
avSource address vector (or NULL on error)

Definition at line 1482 of file xsigo.c.

References container_of, xsigo_managers_reply::count, DBGC, xsigo_device::discovery, ENODEV, ib_device::gsi, ib_mad::hdr, htons, ib_destroy_madx(), ib_madx_get_ownerdata(), IB_MGMT_STATUS_OK, xsigo_device::madx, xsigo_managers_reply::manager, xsigo_device::name, NULL, out, xsigo_mad::reply, start_timer_fixed(), ib_mad_hdr::status, strerror(), xcm_list(), and XSIGO_DISCOVERY_SUCCESS_DELAY.

                                                                         {
        struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
        union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
        struct xsigo_managers_reply *reply = &xsmad->reply;

        /* Check for failures */
        if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
                rc = -ENODEV;
        if ( rc != 0 ) {
                DBGC ( xdev, "XDEV %s manager lookup failed: %s\n",
                       xdev->name, strerror ( rc ) );
                goto out;
        }

        /* Sanity checks */
        if ( reply->count > ( sizeof ( reply->manager ) /
                              sizeof ( reply->manager[0] ) ) ) {
                DBGC ( xdev, "XDEV %s has too many managers (%d)\n",
                       xdev->name, reply->count );
                goto out;
        }

        /* Synchronise list of managers */
        if ( ( rc = xcm_list ( xdev, reply->manager, reply->count ) ) != 0 )
                goto out;

        /* Report an empty list of managers */
        if ( reply->count == 0 )
                DBGC ( xdev, "XDEV %s has no managers\n", xdev->name );

        /* Delay next discovery attempt */
        start_timer_fixed ( &xdev->discovery, XSIGO_DISCOVERY_SUCCESS_DELAY );

out:
        /* Destroy the completed transaction */
        ib_destroy_madx ( ibdev, ibdev->gsi, madx );
        xdev->madx = NULL;
}
static void xsigo_xds_complete ( struct ib_device ibdev,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx,
int  rc,
union ib_mad mad,
struct ib_address_vector *av  __unused 
) [static]

Handle directory service lookup completion.

Parameters:
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
avSource address vector (or NULL on error)

Definition at line 1543 of file xsigo.c.

References _S2, xsigo_managers_request::arch, ib_mad_hdr::attr_id, xsigo_managers_request::build, build_id, ib_mad_hdr::class_version, container_of, ib_service_record::data16, ib_service_record::data64, DBGC, DBGC2, xsigo_managers_request::driver_version, ENODEV, fetch_string_setting(), ib_device::gid, ib_device::gsi, ib_gid::guid, xsigo_server_id::guid, guid, ib_mad::hdr, xsigo_managers_request::hostname, htonl, htons, ib_create_madx(), ib_destroy_madx(), IB_GUID_ARGS, IB_GUID_FMT, ib_madx_get_ownerdata(), ib_madx_set_ownerdata(), IB_MGMT_METHOD_GET, IB_MGMT_STATUS_OK, IB_QKEY_GSI, IB_QPN_GSI, ib_address_vector::lid, xsigo_managers_request::mad_hdr, xsigo_device::madx, memcpy(), memset(), ib_mad_hdr::method, ib_mad_hdr::mgmt_class, xsigo_device::name, ntohs, NULL, xsigo_discovery::op, xsigo_managers_request::os_type, xsigo_managers_request::os_version, out, product_short_name, product_version, ib_address_vector::qkey, ib_address_vector::qpn, xsigo_mad::request, request, xsigo_managers_request::resources, ib_gid::s, ib_mad::sa, ib_mad_sa::sa_data, xsigo_managers_request::server, ib_sa_data::service_record, ib_address_vector::sl, ib_device::sm_sl, snprintf(), ib_mad_hdr::status, strerror(), XSIGO_ATTR_XCM_REQUEST, XSIGO_MGMT_CLASS, XSIGO_MGMT_CLASS_VERSION, XSIGO_OS_TYPE_GENERIC, XSIGO_RESOURCE_NO_HA, XSIGO_RESOURCE_XVE, and XSIGO_RESOURCES_PRESENT.

                                                                         {
        struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
        union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
        struct xsigo_managers_request *request = &xsmad->request;
        struct ib_service_record *svc;
        struct ib_address_vector dest;
        union ib_guid *guid;

        /* Allow for reuse of transaction pointer */
        xdev->madx = NULL;

        /* Check for failures */
        if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
                rc = -ENODEV;
        if ( rc != 0 ) {
                DBGC ( xdev, "XDEV %s directory lookup failed: %s\n",
                       xdev->name, strerror ( rc ) );
                goto out;
        }

        /* Construct address vector */
        memset ( &dest, 0, sizeof ( dest ) );
        svc = &mad->sa.sa_data.service_record;
        dest.lid = ntohs ( svc->data16[0] );
        dest.sl = ibdev->sm_sl;
        dest.qpn = IB_QPN_GSI;
        dest.qkey = IB_QKEY_GSI;
        guid = ( ( union ib_guid * ) &svc->data64[0] );
        DBGC2 ( xdev, "XDEV %s found directory at LID %d GUID " IB_GUID_FMT
                "\n", xdev->name, dest.lid, IB_GUID_ARGS ( guid ) );

        /* Construct request (reusing MAD buffer) */
        memset ( request, 0, sizeof ( *request ) );
        request->mad_hdr.mgmt_class = XSIGO_MGMT_CLASS;
        request->mad_hdr.class_version = XSIGO_MGMT_CLASS_VERSION;
        request->mad_hdr.method = IB_MGMT_METHOD_GET;
        request->mad_hdr.attr_id = htons ( XSIGO_ATTR_XCM_REQUEST );
        memcpy ( &request->server.guid, &ibdev->gid.s.guid,
                 sizeof ( request->server.guid ) );
        snprintf ( request->os_version, sizeof ( request->os_version ),
                   "%s %s", product_short_name, product_version );
        snprintf ( request->arch, sizeof ( request->arch ), _S2 ( ARCH ) );
        request->os_type = XSIGO_OS_TYPE_GENERIC;
        request->resources = htons ( XSIGO_RESOURCES_PRESENT |
                                     XSIGO_RESOURCE_XVE |
                                     XSIGO_RESOURCE_NO_HA );

        /* The handling of this request on the server side is a
         * textbook example of how not to design a wire protocol.  The
         * server uses the _driver_ version number to determine which
         * fields are present.
         */
        request->driver_version = htonl ( 0x2a2a2a );

        /* The build version field is ignored unless it happens to
         * contain the substring "xg-".
         */
        snprintf ( request->build, sizeof ( request->build ),
                   "not-xg-%08lx", build_id );

        /* The server side user interface occasionally has no way to
         * refer to an entry with an empty hostname.
         */
        fetch_string_setting ( NULL, &hostname_setting, request->hostname,
                               sizeof ( request->hostname ) );
        if ( ! request->hostname[0] ) {
                snprintf ( request->hostname, sizeof ( request->hostname ),
                           "%s-" IB_GUID_FMT, product_short_name,
                           IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
        }

        /* Start configuration manager lookup */
        xdev->madx = ib_create_madx ( ibdev, ibdev->gsi, mad, &dest,
                                      &xsigo_xcm_discovery.op );
        if ( ! xdev->madx ) {
                DBGC ( xdev, "XDEV %s could not start manager lookup\n",
                       xdev->name );
                goto out;
        }
        ib_madx_set_ownerdata ( xdev->madx, xdev );

out:
        /* Destroy the completed transaction */
        ib_destroy_madx ( ibdev, ibdev->gsi, madx );
}
static void xsigo_discover ( struct retry_timer timer,
int over  __unused 
) [static]

Discover configuration managers.

Parameters:
timerRetry timer
overFailure indicator

Definition at line 1647 of file xsigo.c.

References container_of, DBGC, xsigo_device::discovery, ib_device::gsi, ib_create_service_madx(), ib_destroy_madx(), ib_madx_set_ownerdata(), xsigo_device::ibdev, xsigo_device::madx, xsigo_device::name, xsigo_discovery::name, NULL, ib_mad_transaction::op, op, xsigo_discovery::op, start_timer_fixed(), XDS_SERVICE_NAME, and XSIGO_DISCOVERY_FAILURE_DELAY.

Referenced by xsigo_ib_probe().

                                                                            {
        struct xsigo_device *xdev =
                container_of ( timer, struct xsigo_device, discovery );
        struct ib_device *ibdev = xdev->ibdev;
        struct xsigo_discovery *discovery;

        /* Restart timer */
        start_timer_fixed ( &xdev->discovery, XSIGO_DISCOVERY_FAILURE_DELAY );

        /* Cancel any pending discovery transaction */
        if ( xdev->madx ) {
                discovery = container_of ( xdev->madx->op,
                                           struct xsigo_discovery, op );
                DBGC ( xdev, "XDEV %s timed out waiting for %s lookup\n",
                       xdev->name, discovery->name );
                ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
                xdev->madx = NULL;
        }

        /* Start directory service lookup */
        xdev->madx = ib_create_service_madx ( ibdev, ibdev->gsi,
                                              XDS_SERVICE_NAME,
                                              &xsigo_xds_discovery.op );
        if ( ! xdev->madx ) {
                DBGC ( xdev, "XDEV %s could not start directory lookup\n",
                       xdev->name );
                return;
        }
        ib_madx_set_ownerdata ( xdev->madx, xdev );
}
static void xsigo_ib_open ( struct retry_timer opener,
int over  __unused 
) [static]

Open link and start discovery.

Parameters:
openerLink opener
overFailure indicator

Definition at line 1691 of file xsigo.c.

References container_of, DBGC, xsigo_device::discovery, ib_link_ok(), ib_open(), xsigo_device::ibdev, xsigo_device::name, xsigo_device::opener, rc, start_timer_fixed(), start_timer_nodelay(), strerror(), and XSIGO_OPEN_RETRY_DELAY.

Referenced by xsigo_ib_probe().

                                                                            {
        struct xsigo_device *xdev =
                container_of ( opener, struct xsigo_device, opener );
        struct ib_device *ibdev = xdev->ibdev;
        int rc;

        /* Open Infiniband device */
        if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
                DBGC ( xdev, "XDEV %s could not open: %s\n",
                       xdev->name, strerror ( rc ) );
                /* Delay and try again */
                start_timer_fixed ( &xdev->opener, XSIGO_OPEN_RETRY_DELAY );
                return;
        }

        /* If link is already up, then start discovery */
        if ( ib_link_ok ( ibdev ) )
                start_timer_nodelay ( &xdev->discovery );
}
static int xsigo_ib_probe ( struct ib_device ibdev) [static]

Probe Xsigo device.

Parameters:
ibdevInfiniband device
Return values:
rcReturn status code

Definition at line 1717 of file xsigo.c.

References DBGC, xsigo_device::discovery, ENOMEM, ib_device::gid, ib_gid::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_device::ibdev, ibdev_get(), INIT_LIST_HEAD, xsigo_device::list, list_add_tail, xsigo_device::managers, xsigo_device::name, ib_device::name, xsigo_device::opener, ref_init, xsigo_device::refcnt, ib_gid::s, start_timer_nodelay(), xsigo_discover(), xsigo_free(), xsigo_ib_open(), and zalloc().

                                                      {
        struct xsigo_device *xdev;

        /* Allocate and initialise structure */
        xdev = zalloc ( sizeof ( *xdev ) );
        if ( ! xdev )
                return -ENOMEM;
        ref_init ( &xdev->refcnt, xsigo_free );
        xdev->ibdev = ibdev_get ( ibdev );
        xdev->name = ibdev->name;
        timer_init ( &xdev->opener, xsigo_ib_open, &xdev->refcnt );
        timer_init ( &xdev->discovery, xsigo_discover, &xdev->refcnt );
        INIT_LIST_HEAD ( &xdev->managers );

        /* Start timer to open Infiniband device.  (We are currently
         * within the Infiniband device probe callback list; opening
         * the device here would have interesting side-effects.)
         */
        start_timer_nodelay ( &xdev->opener );

        /* Add to list of devices and transfer reference to list */
        list_add_tail ( &xdev->list, &xsigo_devices );
        DBGC ( xdev, "XDEV %s created for " IB_GUID_FMT "\n",
               xdev->name, IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
        return 0;
}
static void xsigo_ib_notify ( struct ib_device ibdev) [static]

Handle device or link status change.

Parameters:
ibdevInfiniband device

Definition at line 1749 of file xsigo.c.

References xsigo_device::discovery, ib_device::gsi, ib_destroy_madx(), ib_link_ok(), xsigo_device::ibdev, xsigo_device::list, list_for_each_entry, xsigo_device::madx, NULL, start_timer_nodelay(), and stop_timer().

                                                        {
        struct xsigo_device *xdev;

        /* Stop/restart discovery on any attached devices */
        list_for_each_entry ( xdev, &xsigo_devices, list ) {

                /* Skip non-attached devices */
                if ( xdev->ibdev != ibdev )
                        continue;

                /* Stop any ongoing discovery */
                if ( xdev->madx ) {
                        ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
                        xdev->madx = NULL;
                }
                stop_timer ( &xdev->discovery );

                /* If link is up, then start discovery */
                if ( ib_link_ok ( ibdev ) )
                        start_timer_nodelay ( &xdev->discovery );
        }
}
static void xsigo_ib_remove ( struct ib_device ibdev) [static]

Remove Xsigo device.

Parameters:
ibdevInfiniband device

Definition at line 1777 of file xsigo.c.

References DBGC, xsigo_device::discovery, ib_device::gsi, ib_close(), ib_destroy_madx(), xsigo_device::ibdev, xsigo_device::list, list_del, list_for_each_entry_safe, xsigo_device::madx, xsigo_device::name, NULL, xsigo_device::opener, ref_put, xsigo_device::refcnt, stop_timer(), and xcm_list().

                                                        {
        struct xsigo_device *xdev;
        struct xsigo_device *tmp;

        /* Remove any attached Xsigo devices */
        list_for_each_entry_safe ( xdev, tmp, &xsigo_devices, list ) {

                /* Skip non-attached devices */
                if ( xdev->ibdev != ibdev )
                        continue;

                /* Stop any ongoing discovery */
                if ( xdev->madx ) {
                        ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
                        xdev->madx = NULL;
                }
                stop_timer ( &xdev->discovery );

                /* Destroy all configuration managers */
                xcm_list ( xdev, NULL, 0 );

                /* Close Infiniband device, if applicable */
                if ( ! timer_running ( &xdev->opener ) )
                        ib_close ( xdev->ibdev );

                /* Stop link opener */
                stop_timer ( &xdev->opener );

                /* Remove from list of devices and drop list's reference */
                DBGC ( xdev, "XDEV %s destroyed\n", xdev->name );
                list_del ( &xdev->list );
                ref_put ( &xdev->refcnt );
        }
}
static void xsigo_net_notify ( struct net_device netdev) [static]

Handle device or link status change.

Parameters:
netdevNetwork device

Definition at line 1832 of file xsigo.c.

References eoib_find(), xsigo_device::ibdev, eoib_device::list, list_for_each_entry, xsigo_nic::mac, xsigo_device::managers, eoib_device::netdev, xsigo_manager::nics, and xsmp_tx_xve_oper().

                                                           {
        struct xsigo_device *xdev;
        struct ib_device *ibdev;
        struct xsigo_manager *xcm;
        struct xsigo_nic *xve;
        struct eoib_device *eoib;

        /* Send current operational state to XCM, if applicable */
        list_for_each_entry ( xdev, &xsigo_devices, list ) {
                ibdev = xdev->ibdev;
                list_for_each_entry ( xcm, &xdev->managers, list ) {
                        list_for_each_entry ( xve, &xcm->nics, list ) {
                                eoib = eoib_find ( ibdev, xve->mac );
                                if ( ! eoib )
                                        continue;
                                if ( eoib->netdev != netdev )
                                        continue;
                                xsmp_tx_xve_oper ( xcm, xve, eoib );
                        }
                }
        }
}

Variable Documentation

union ib_guid xcm_service_id [static]
Initial value:
 {
        .bytes = XCM_SERVICE_ID,
}

Configuration manager service ID.

Definition at line 130 of file xsigo.c.

struct interface_operation xcm_xfer_op[] [static]
Initial value:

Configuration manager data transfer interface operations.

Definition at line 1231 of file xsigo.c.

Initial value:
        INTF_DESC ( struct xsigo_manager, xfer, xcm_xfer_op )

Configuration manager data transfer interface descriptor.

Definition at line 1238 of file xsigo.c.

Initial value:

Configuration manager process descriptor.

Definition at line 1242 of file xsigo.c.

Initial value:
 {
        .name = "manager",
        .op = {
                .complete = xsigo_xcm_complete,
        },
}

Configuration manager lookup discovery stage.

Definition at line 1526 of file xsigo.c.

Initial value:
 {
        .name = "directory",
        .op = {
                .complete = xsigo_xds_complete,
        },
}

Directory service lookup discovery stage.

Definition at line 1634 of file xsigo.c.

struct ib_driver xsigo_ib_driver __ib_driver
Initial value:
 {
        .name = "Xsigo",
        .probe = xsigo_ib_probe,
        .notify = xsigo_ib_notify,
        .remove = xsigo_ib_remove,
}

Xsigo Infiniband driver.

Definition at line 1813 of file xsigo.c.

struct net_driver xsigo_net_driver __net_driver
Initial value:
 {
        .name = "Xsigo",
        .notify = xsigo_net_notify,
}

Xsigo network driver.

Definition at line 1856 of file xsigo.c.