Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[infiniband] Split subnet management agent client out into ib_smc.c
Not all Infiniband cards have embedded subnet management agents.
Split out the code that communicates with such an embedded SMA into a
separate ib_smc.c file, and have drivers call ib_smc_update()
explicitly when they suspect that the answers given by the embedded
SMA may have changed.
  • Loading branch information
Michael Brown committed Nov 11, 2008
1 parent 830e19e commit 663904a
Show file tree
Hide file tree
Showing 9 changed files with 805 additions and 520 deletions.
97 changes: 51 additions & 46 deletions src/drivers/infiniband/arbel.c
Expand Up @@ -33,6 +33,7 @@
#include <gpxe/iobuf.h>
#include <gpxe/netdevice.h>
#include <gpxe/infiniband.h>
#include <gpxe/ib_smc.h>
#include "arbel.h"

/**
Expand Down Expand Up @@ -482,6 +483,50 @@ arbel_cmd_map_fa ( struct arbel *arbel,
0, map, 1, NULL );
}

/***************************************************************************
*
* MAD operations
*
***************************************************************************
*/

/**
* Issue management datagram
*
* @v ibdev Infiniband device
* @v mad Management datagram
* @ret rc Return status code
*/
static int arbel_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
struct arbel *arbel = ib_get_drvdata ( ibdev );
union arbelprm_mad mad_ifc;
int rc;

linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
mad_size_mismatch );

/* Copy in request packet */
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );

/* Issue MAD */
if ( ( rc = arbel_cmd_mad_ifc ( arbel, ibdev->port,
&mad_ifc ) ) != 0 ) {
DBGC ( arbel, "Arbel %p could not issue MAD IFC: %s\n",
arbel, strerror ( rc ) );
return rc;
}

/* Copy out reply packet */
memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );

if ( mad->hdr.status != 0 ) {
DBGC ( arbel, "Arbel %p MAD IFC status %04x\n",
arbel, ntohs ( mad->hdr.status ) );
return -EIO;
}
return 0;
}

/***************************************************************************
*
* Completion queue operations
Expand Down Expand Up @@ -1394,6 +1439,9 @@ static void arbel_event_port_state_change ( struct arbel *arbel,
return;
}

/* Update MAD parameters */
ib_smc_update ( arbel->ibdev[port], arbel_mad );

/* Notify Infiniband core of link state change */
ib_link_state_changed ( arbel->ibdev[port] );
}
Expand Down Expand Up @@ -1483,6 +1531,9 @@ static int arbel_open ( struct ib_device *ibdev ) {
return rc;
}

/* Update MAD parameters */
ib_smc_update ( ibdev, arbel_mad );

return 0;
}

Expand Down Expand Up @@ -1598,51 +1649,6 @@ static void arbel_mcast_detach ( struct ib_device *ibdev,
}
}

/***************************************************************************
*
* MAD operations
*
***************************************************************************
*/

/**
* Issue management datagram
*
* @v ibdev Infiniband device
* @v mad Management datagram
* @v len Length of management datagram
* @ret rc Return status code
*/
static int arbel_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
size_t len ) {
struct arbel *arbel = ib_get_drvdata ( ibdev );
union arbelprm_mad mad_ifc;
int rc;

/* Copy in request packet */
memset ( &mad_ifc, 0, sizeof ( mad_ifc ) );
assert ( len <= sizeof ( mad_ifc.mad ) );
memcpy ( &mad_ifc.mad, mad, len );

/* Issue MAD */
if ( ( rc = arbel_cmd_mad_ifc ( arbel, ibdev->port,
&mad_ifc ) ) != 0 ) {
DBGC ( arbel, "Arbel %p could not issue MAD IFC: %s\n",
arbel, strerror ( rc ) );
return rc;
}

/* Copy out reply packet */
memcpy ( mad, &mad_ifc.mad, len );

if ( mad->status != 0 ) {
DBGC ( arbel, "Arbel %p MAD IFC status %04x\n",
arbel, ntohs ( mad->status ) );
return -EIO;
}
return 0;
}

/** Arbel Infiniband operations */
static struct ib_device_operations arbel_ib_operations = {
.create_cq = arbel_create_cq,
Expand All @@ -1658,7 +1664,6 @@ static struct ib_device_operations arbel_ib_operations = {
.close = arbel_close,
.mcast_attach = arbel_mcast_attach,
.mcast_detach = arbel_mcast_detach,
.mad = arbel_mad,
};

/***************************************************************************
Expand Down
97 changes: 51 additions & 46 deletions src/drivers/infiniband/hermon.c
Expand Up @@ -31,6 +31,7 @@
#include <gpxe/iobuf.h>
#include <gpxe/netdevice.h>
#include <gpxe/infiniband.h>
#include <gpxe/ib_smc.h>
#include "hermon.h"

/**
Expand Down Expand Up @@ -608,6 +609,50 @@ static void hermon_free_mtt ( struct hermon *hermon,
mtt->num_pages );
}

/***************************************************************************
*
* MAD operations
*
***************************************************************************
*/

/**
* Issue management datagram
*
* @v ibdev Infiniband device
* @v mad Management datagram
* @ret rc Return status code
*/
static int hermon_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
struct hermon *hermon = ib_get_drvdata ( ibdev );
union hermonprm_mad mad_ifc;
int rc;

linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
mad_size_mismatch );

/* Copy in request packet */
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );

/* Issue MAD */
if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
&mad_ifc ) ) != 0 ) {
DBGC ( hermon, "Hermon %p could not issue MAD IFC: %s\n",
hermon, strerror ( rc ) );
return rc;
}

/* Copy out reply packet */
memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );

if ( mad->hdr.status != 0 ) {
DBGC ( hermon, "Hermon %p MAD IFC status %04x\n",
hermon, ntohs ( mad->hdr.status ) );
return -EIO;
}
return 0;
}

/***************************************************************************
*
* Completion queue operations
Expand Down Expand Up @@ -1377,6 +1422,9 @@ static void hermon_event_port_state_change ( struct hermon *hermon,
return;
}

/* Update MAD parameters */
ib_smc_update ( hermon->ibdev[port], hermon_mad );

/* Notify Infiniband core of link state change */
ib_link_state_changed ( hermon->ibdev[port] );
}
Expand Down Expand Up @@ -1465,6 +1513,9 @@ static int hermon_open ( struct ib_device *ibdev ) {
return rc;
}

/* Update MAD parameters */
ib_smc_update ( ibdev, hermon_mad );

return 0;
}

Expand Down Expand Up @@ -1579,51 +1630,6 @@ static void hermon_mcast_detach ( struct ib_device *ibdev,
}
}

/***************************************************************************
*
* MAD operations
*
***************************************************************************
*/

/**
* Issue management datagram
*
* @v ibdev Infiniband device
* @v mad Management datagram
* @v len Length of management datagram
* @ret rc Return status code
*/
static int hermon_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
size_t len ) {
struct hermon *hermon = ib_get_drvdata ( ibdev );
union hermonprm_mad mad_ifc;
int rc;

/* Copy in request packet */
memset ( &mad_ifc, 0, sizeof ( mad_ifc ) );
assert ( len <= sizeof ( mad_ifc.mad ) );
memcpy ( &mad_ifc.mad, mad, len );

/* Issue MAD */
if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
&mad_ifc ) ) != 0 ) {
DBGC ( hermon, "Hermon %p could not issue MAD IFC: %s\n",
hermon, strerror ( rc ) );
return rc;
}

/* Copy out reply packet */
memcpy ( mad, &mad_ifc.mad, len );

if ( mad->status != 0 ) {
DBGC ( hermon, "Hermon %p MAD IFC status %04x\n",
hermon, ntohs ( mad->status ) );
return -EIO;
}
return 0;
}

/** Hermon Infiniband operations */
static struct ib_device_operations hermon_ib_operations = {
.create_cq = hermon_create_cq,
Expand All @@ -1639,7 +1645,6 @@ static struct ib_device_operations hermon_ib_operations = {
.close = hermon_close,
.mcast_attach = hermon_mcast_attach,
.mcast_detach = hermon_mcast_detach,
.mad = hermon_mad,
};

/***************************************************************************
Expand Down

0 comments on commit 663904a

Please sign in to comment.