david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[infiniband] Remove the return status code from MAD handlers

MAD handlers have to set the status fields within the MAD itself
anyway, in order to provide a meaningful response MAD; the additional
gPXE return status code is just noise.

Note that we probably don't need to ever explicitly set the status to
IB_MGMT_STATUS_OK, since it should already have this value from the
request.  (By not explicitly setting the status in this way, we can
safely have ib_sma_set_xxx() call ib_sma_get_xxx() in order to
generate the GetResponse MAD without worrying that ib_sma_get_xxx()
will clear any error status set by ib_sma_set_xxx().)
This commit is contained in:
Michael Brown 2009-07-10 21:29:25 +01:00
parent f1d92fa886
commit 94876f4bb6
4 changed files with 37 additions and 69 deletions

View File

@ -34,13 +34,12 @@ struct ib_gma_handler {
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
* *
* The handler should modify the MAD as applicable. If the * The handler should modify the MAD as applicable. If the
* handler returns with a non-zero value in the MAD's @c * handler returns with a non-zero value in the MAD's @c
* method field, it will be sent as a response. * method field, it will be sent as a response.
*/ */
int ( * handle ) ( struct ib_gma *gma, union ib_mad *mad ); void ( * handle ) ( struct ib_gma *gma, union ib_mad *mad );
}; };
/** GMA attribute handlers */ /** GMA attribute handlers */

View File

@ -86,10 +86,9 @@ static unsigned int next_request_tid;
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_get_node_info ( struct ib_gma *gma, static void ib_sma_get_node_info ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_node_info *node_info = &mad->smp.smp_data.node_info; struct ib_node_info *node_info = &mad->smp.smp_data.node_info;
@ -104,8 +103,6 @@ static int ib_sma_get_node_info ( struct ib_gma *gma,
sizeof ( node_info->port_guid ) ); sizeof ( node_info->port_guid ) );
node_info->partition_cap = htons ( 1 ); node_info->partition_cap = htons ( 1 );
node_info->local_port_num = ibdev->port; node_info->local_port_num = ibdev->port;
return 0;
} }
/** /**
@ -113,10 +110,9 @@ static int ib_sma_get_node_info ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_get_node_desc ( struct ib_gma *gma, static void ib_sma_get_node_desc ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_node_desc *node_desc = &mad->smp.smp_data.node_desc; struct ib_node_desc *node_desc = &mad->smp.smp_data.node_desc;
struct ib_gid_half *guid = &ibdev->gid.u.half[1]; struct ib_gid_half *guid = &ibdev->gid.u.half[1];
@ -127,8 +123,6 @@ static int ib_sma_get_node_desc ( struct ib_gma *gma,
guid->bytes[0], guid->bytes[1], guid->bytes[2], guid->bytes[0], guid->bytes[1], guid->bytes[2],
guid->bytes[3], guid->bytes[4], guid->bytes[5], guid->bytes[3], guid->bytes[4], guid->bytes[5],
guid->bytes[6], guid->bytes[7], ibdev->dev->name ); guid->bytes[6], guid->bytes[7], ibdev->dev->name );
return 0;
} }
/** /**
@ -136,18 +130,15 @@ static int ib_sma_get_node_desc ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_get_guid_info ( struct ib_gma *gma, static void ib_sma_get_guid_info ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_guid_info *guid_info = &mad->smp.smp_data.guid_info; struct ib_guid_info *guid_info = &mad->smp.smp_data.guid_info;
memset ( guid_info, 0, sizeof ( *guid_info ) ); memset ( guid_info, 0, sizeof ( *guid_info ) );
memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1], memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1],
sizeof ( guid_info->guid[0] ) ); sizeof ( guid_info->guid[0] ) );
return 0;
} }
/** /**
@ -155,10 +146,9 @@ static int ib_sma_get_guid_info ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_get_port_info ( struct ib_gma *gma, static void ib_sma_get_port_info ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_port_info *port_info = &mad->smp.smp_data.port_info; struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
@ -184,8 +174,6 @@ static int ib_sma_get_port_info ( struct ib_gma *gma,
port_info->init_type_reply__mtu_cap = IB_MTU_2048; port_info->init_type_reply__mtu_cap = IB_MTU_2048;
port_info->operational_vls__enforcement = ( IB_VL_0 << 4 ); port_info->operational_vls__enforcement = ( IB_VL_0 << 4 );
port_info->guid_cap = 1; port_info->guid_cap = 1;
return 0;
} }
/** /**
@ -193,10 +181,9 @@ static int ib_sma_get_port_info ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_set_port_info ( struct ib_gma *gma, static void ib_sma_set_port_info ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
const struct ib_port_info *port_info = &mad->smp.smp_data.port_info; const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
int rc; int rc;
@ -214,7 +201,7 @@ static int ib_sma_set_port_info ( struct ib_gma *gma,
htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR ); htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
} }
return ib_sma_get_port_info ( gma, mad ); ib_sma_get_port_info ( gma, mad );
} }
/** /**
@ -222,17 +209,14 @@ static int ib_sma_set_port_info ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_get_pkey_table ( struct ib_gma *gma, static void ib_sma_get_pkey_table ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table; struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
memset ( pkey_table, 0, sizeof ( *pkey_table ) ); memset ( pkey_table, 0, sizeof ( *pkey_table ) );
pkey_table->pkey[0] = htons ( ibdev->pkey ); pkey_table->pkey[0] = htons ( ibdev->pkey );
return 0;
} }
/** /**
@ -240,16 +224,15 @@ static int ib_sma_get_pkey_table ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_sma_set_pkey_table ( struct ib_gma *gma, static void ib_sma_set_pkey_table ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table; struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
ibdev->pkey = ntohs ( pkey_table->pkey[0] ); ibdev->pkey = ntohs ( pkey_table->pkey[0] );
return ib_sma_get_pkey_table ( gma, mad ); ib_sma_get_pkey_table ( gma, mad );
} }
/** List of attribute handlers */ /** List of attribute handlers */
@ -331,9 +314,8 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) { static void ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
struct ib_mad_hdr *hdr = &mad->hdr; struct ib_mad_hdr *hdr = &mad->hdr;
struct ib_gma_handler *handler; struct ib_gma_handler *handler;
@ -344,13 +326,13 @@ static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
( handler->method == hdr->method ) && ( handler->method == hdr->method ) &&
( handler->attr_id == hdr->attr_id ) ) { ( handler->attr_id == hdr->attr_id ) ) {
hdr->method = handler->resp_method; hdr->method = handler->resp_method;
return handler->handle ( gma, mad ); handler->handle ( gma, mad );
return;
} }
} }
hdr->method = IB_MGMT_METHOD_TRAP; hdr->method = IB_MGMT_METHOD_TRAP;
hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR ); hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
return -ENOTSUP;
} }
/** /**
@ -412,21 +394,17 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
} }
} }
/* Handle MAD, if possible */ /* Handle MAD */
if ( ( rc = ib_handle_mad ( gma, mad ) ) != 0 ) { ib_handle_mad ( gma, mad );
DBGC ( gma, "GMA %p could not handle TID %08x%08x: %s\n",
gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
strerror ( rc ) );
/* Do not abort; we may want to send an error response */
}
/* Finish processing if we have no response to send */ /* Finish processing if we have no response to send */
if ( ! hdr->method ) if ( ! hdr->method )
goto out; goto out;
DBGC ( gma, "GMA %p TX TID %08x%08x (%02x,%02x,%02x,%04x)\n", gma, DBGC ( gma, "GMA %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ), hdr->mgmt_class, "%04x\n", gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
hdr->class_version, hdr->method, ntohs ( hdr->attr_id ) ); hdr->mgmt_class, hdr->class_version, hdr->method,
ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
DBGC2_HDA ( gma, 0, mad, sizeof ( *mad ) ); DBGC2_HDA ( gma, 0, mad, sizeof ( *mad ) );
/* Set response fields for directed route SMPs */ /* Set response fields for directed route SMPs */

View File

@ -139,10 +139,9 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_handle_mc_member_join ( struct ib_gma *gma, static void ib_handle_mc_member_join ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_mc_member_record *mc_member_record = struct ib_mc_member_record *mc_member_record =
&mad->sa.sa_data.mc_member_record; &mad->sa.sa_data.mc_member_record;
@ -155,7 +154,7 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) { if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( gma, "GMA %p join failed with status %04x\n", DBGC ( gma, "GMA %p join failed with status %04x\n",
gma, ntohs ( mad->hdr.status ) ); gma, ntohs ( mad->hdr.status ) );
return -EINVAL; return;
} }
/* Extract MAD parameters */ /* Extract MAD parameters */
@ -170,7 +169,7 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[1] ),
ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[2] ),
ntohl ( gid->u.dwords[3] ) ); ntohl ( gid->u.dwords[3] ) );
return -ENOENT; return;
} }
DBGC ( gma, "GMA %p QPN %lx joined %08x:%08x:%08x:%08x qkey %lx\n", DBGC ( gma, "GMA %p QPN %lx joined %08x:%08x:%08x:%08x qkey %lx\n",
gma, qp->qpn, ntohl ( gid->u.dwords[0] ), gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
@ -181,10 +180,8 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
if ( ( rc = ib_modify_qp ( ibdev, qp, IB_MODIFY_QKEY, qkey ) ) != 0 ) { if ( ( rc = ib_modify_qp ( ibdev, qp, IB_MODIFY_QKEY, qkey ) ) != 0 ) {
DBGC ( gma, "GMA %p QPN %lx could not modify qkey: %s\n", DBGC ( gma, "GMA %p QPN %lx could not modify qkey: %s\n",
gma, qp->qpn, strerror ( rc ) ); gma, qp->qpn, strerror ( rc ) );
return rc; return;
} }
return 0;
} }
/** /**
@ -192,10 +189,9 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_handle_mc_member_leave ( struct ib_gma *gma, static void ib_handle_mc_member_leave ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_mc_member_record *mc_member_record = struct ib_mc_member_record *mc_member_record =
&mad->sa.sa_data.mc_member_record; &mad->sa.sa_data.mc_member_record;
struct ib_gid *gid; struct ib_gid *gid;
@ -204,7 +200,7 @@ static int ib_handle_mc_member_leave ( struct ib_gma *gma,
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) { if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( gma, "GMA %p leave failed with status %04x\n", DBGC ( gma, "GMA %p leave failed with status %04x\n",
gma, ntohs ( mad->hdr.status ) ); gma, ntohs ( mad->hdr.status ) );
return -EINVAL; return;
} }
/* Extract MAD parameters */ /* Extract MAD parameters */
@ -212,8 +208,6 @@ static int ib_handle_mc_member_leave ( struct ib_gma *gma,
DBGC ( gma, "GMA %p left %08x:%08x:%08x:%08x\n", gma, DBGC ( gma, "GMA %p left %08x:%08x:%08x:%08x\n", gma,
ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ),
ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ) ); ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ) );
return 0;
} }
/** Multicast membership record response handler */ /** Multicast membership record response handler */

View File

@ -170,10 +170,9 @@ int ib_resolve_path ( struct ib_device *ibdev,
* *
* @v gma General management agent * @v gma General management agent
* @v mad MAD * @v mad MAD
* @ret rc Return status code
*/ */
static int ib_handle_path_record ( struct ib_gma *gma, static void ib_handle_path_record ( struct ib_gma *gma,
union ib_mad *mad ) { union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev; struct ib_device *ibdev = gma->ibdev;
struct ib_path_record *path_record = &mad->sa.sa_data.path_record; struct ib_path_record *path_record = &mad->sa.sa_data.path_record;
struct ib_gid *dgid = &path_record->dgid; struct ib_gid *dgid = &path_record->dgid;
@ -186,7 +185,7 @@ static int ib_handle_path_record ( struct ib_gma *gma,
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) { if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( gma, "GMA %p path record lookup failed with status " DBGC ( gma, "GMA %p path record lookup failed with status "
"%04x\n", gma, ntohs ( mad->hdr.status ) ); "%04x\n", gma, ntohs ( mad->hdr.status ) );
return -EINVAL; return;
} }
/* Extract values from MAD */ /* Extract values from MAD */
@ -209,8 +208,6 @@ static int ib_handle_path_record ( struct ib_gma *gma,
cached->rate = rate; cached->rate = rate;
cached->sl = sl; cached->sl = sl;
} }
return 0;
} }
/** Path record response handler */ /** Path record response handler */