david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[infiniband] Pass GMA as a parameter to GMA MAD handlers

This commit is contained in:
Michael Brown 2009-07-07 18:09:21 +01:00
parent cb9ef4dee2
commit 8a852280eb
4 changed files with 72 additions and 72 deletions

View File

@ -17,9 +17,10 @@ struct ib_device;
struct ib_completion_queue;
struct ib_queue_pair;
union ib_mad;
struct ib_gma;
/** A MAD attribute handler */
struct ib_mad_handler {
/** A GMA attribute handler */
struct ib_gma_handler {
/** Management class */
uint8_t mgmt_class;
/** Class version */
@ -32,7 +33,7 @@ struct ib_mad_handler {
uint16_t attr_id;
/** Handle attribute
*
* @v ibdev Infiniband device
* @v gma General management agent
* @v mad MAD
* @ret rc Return status code
*
@ -40,14 +41,14 @@ struct ib_mad_handler {
* handler returns with a non-zero value in the MAD's @c
* method field, it will be sent as a response.
*/
int ( * handle ) ( struct ib_device *ibdev, union ib_mad *mad );
int ( * handle ) ( struct ib_gma *gma, union ib_mad *mad );
};
/** MAD attribute handlers */
#define IB_MAD_HANDLERS __table ( struct ib_mad_handler, "ib_mad_handlers" )
/** GMA attribute handlers */
#define IB_GMA_HANDLERS __table ( struct ib_gma_handler, "ib_gma_handlers" )
/** Declare a MAD attribute handler */
#define __ib_mad_handler __table_entry ( IB_MAD_HANDLERS, 01 )
/** Declare a GMA attribute handler */
#define __ib_gma_handler __table_entry ( IB_GMA_HANDLERS, 01 )
/** An Infiniband General Management Agent */
struct ib_gma {

View File

@ -75,26 +75,23 @@ struct ib_mad_request {
static unsigned int next_request_tid;
/**
* Identify attribute handler
* Call attribute handler
*
* @v mgmt_class Management class
* @v class_version Class version
* @v method Method
* @v attr_id Attribute ID (in network byte order)
* @ret handler Attribute handler (or NULL)
* @v gma General management agent
* @v mad MAD
* @ret rc Return status code
*/
static int ib_handle_mad ( struct ib_device *ibdev,
union ib_mad *mad ) {
static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
struct ib_mad_hdr *hdr = &mad->hdr;
struct ib_mad_handler *handler;
struct ib_gma_handler *handler;
for_each_table_entry ( handler, IB_MAD_HANDLERS ) {
for_each_table_entry ( handler, IB_GMA_HANDLERS ) {
if ( ( handler->mgmt_class == hdr->mgmt_class ) &&
( handler->class_version == hdr->class_version ) &&
( handler->method == hdr->method ) &&
( handler->attr_id == hdr->attr_id ) ) {
hdr->method = handler->resp_method;
return handler->handle ( ibdev, mad );
return handler->handle ( gma, mad );
}
}
@ -163,7 +160,7 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
}
/* Handle MAD, if possible */
if ( ( rc = ib_handle_mad ( ibdev, mad ) ) != 0 ) {
if ( ( rc = ib_handle_mad ( gma, mad ) ) != 0 ) {
DBGC ( gma, "GMA %p could not handle TID %08x%08x: %s\n",
gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
strerror ( rc ) );

View File

@ -36,12 +36,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
/**
* Transmit multicast group membership request
*
* @v ibdev Infiniband device
* @v gma General management agent
* @v gid Multicast GID
* @v join Join (rather than leave) group
* @ret rc Return status code
*/
static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
static int ib_mc_member_request ( struct ib_gma *gma, struct ib_gid *gid,
int join ) {
union ib_mad mad;
struct ib_mad_sa *sa = &mad.sa;
@ -61,14 +61,13 @@ static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
sa->sa_data.mc_member_record.scope__join_state = 1;
memcpy ( &sa->sa_data.mc_member_record.mgid, gid,
sizeof ( sa->sa_data.mc_member_record.mgid ) );
memcpy ( &sa->sa_data.mc_member_record.port_gid, &ibdev->gid,
memcpy ( &sa->sa_data.mc_member_record.port_gid, &gma->ibdev->gid,
sizeof ( sa->sa_data.mc_member_record.port_gid ) );
/* Issue multicast membership record request */
if ( ( rc = ib_gma_request ( &ibdev->gma, &mad, NULL,
join ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not join group: %s\n",
ibdev, strerror ( rc ) );
if ( ( rc = ib_gma_request ( gma, &mad, NULL, join ) ) != 0 ) {
DBGC ( gma, "GMA %p could not join group: %s\n",
gma, strerror ( rc ) );
return rc;
}
@ -85,22 +84,23 @@ static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
*/
int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
struct ib_gid *gid ) {
struct ib_gma *gma = &ibdev->gma;
int rc;
DBGC ( ibdev, "IBDEV %p QPN %lx joining %08x:%08x:%08x:%08x\n",
ibdev, qp->qpn, ntohl ( gid->u.dwords[0] ),
DBGC ( gma, "GMA %p QPN %lx joining %08x:%08x:%08x:%08x\n",
gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
ntohl ( gid->u.dwords[3] ) );
/* Attach queue pair to multicast GID */
if ( ( rc = ib_mcast_attach ( ibdev, qp, gid ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not attach: %s\n",
ibdev, strerror ( rc ) );
DBGC ( gma, "GMA %p could not attach: %s\n",
gma, strerror ( rc ) );
goto err_mcast_attach;
}
/* Initiate multicast membership join */
if ( ( rc = ib_mc_member_request ( ibdev, gid, 1 ) ) != 0 )
if ( ( rc = ib_mc_member_request ( gma, gid, 1 ) ) != 0 )
goto err_mc_member_record;
return 0;
@ -120,9 +120,10 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
*/
void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
struct ib_gid *gid ) {
struct ib_gma *gma = &ibdev->gma;
DBGC ( ibdev, "IBDEV %p QPN %lx leaving %08x:%08x:%08x:%08x\n",
ibdev, qp->qpn, ntohl ( gid->u.dwords[0] ),
DBGC ( gma, "GMA %p QPN %lx leaving %08x:%08x:%08x:%08x\n",
gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
ntohl ( gid->u.dwords[3] ) );
@ -130,18 +131,19 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
ib_mcast_detach ( ibdev, qp, gid );
/* Initiate multicast membership leave */
ib_mc_member_request ( ibdev, gid, 0 );
ib_mc_member_request ( gma, gid, 0 );
}
/**
* Handle multicast membership record join response
*
* @v ibdev Infiniband device
* @v gma General management agent
* @v mad MAD
* @ret rc Return status code
*/
static int ib_handle_mc_member_join ( struct ib_device *ibdev,
static int ib_handle_mc_member_join ( struct ib_gma *gma,
union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev;
struct ib_mc_member_record *mc_member_record =
&mad->sa.sa_data.mc_member_record;
struct ib_queue_pair *qp;
@ -151,8 +153,8 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
/* Ignore if not a success */
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( ibdev, "IBDEV %p join failed with status %04x\n",
ibdev, ntohs ( mad->hdr.status ) );
DBGC ( gma, "GMA %p join failed with status %04x\n",
gma, ntohs ( mad->hdr.status ) );
return -EINVAL;
}
@ -163,24 +165,22 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
/* Locate matching queue pair */
qp = ib_find_qp_mgid ( ibdev, gid );
if ( ! qp ) {
DBGC ( ibdev, "IBDEV %p has no QP to join "
"%08x:%08x:%08x:%08x\n", ibdev,
ntohl ( gid->u.dwords[0] ),
DBGC ( gma, "GMA %p has no QP to join %08x:%08x:%08x:%08x\n",
gma, ntohl ( gid->u.dwords[0] ),
ntohl ( gid->u.dwords[1] ),
ntohl ( gid->u.dwords[2] ),
ntohl ( gid->u.dwords[3] ) );
return -ENOENT;
}
DBGC ( ibdev, "IBDEV %p QPN %lx joined %08x:%08x:%08x:%08x qkey "
"%lx\n", ibdev, qp->qpn,
ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ),
ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ),
qkey );
DBGC ( gma, "GMA %p QPN %lx joined %08x:%08x:%08x:%08x qkey %lx\n",
gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
ntohl ( gid->u.dwords[3] ), qkey );
/* Set queue key */
if ( ( rc = ib_modify_qp ( ibdev, qp, IB_MODIFY_QKEY, qkey ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p QPN %lx could not modify qkey: %s\n",
ibdev, qp->qpn, strerror ( rc ) );
DBGC ( gma, "GMA %p QPN %lx could not modify qkey: %s\n",
gma, qp->qpn, strerror ( rc ) );
return rc;
}
@ -190,11 +190,11 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
/**
* Handle multicast membership record leave response
*
* @v ibdev Infiniband device
* @v gma General management agent
* @v mad MAD
* @ret rc Return status code
*/
static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
static int ib_handle_mc_member_leave ( struct ib_gma *gma,
union ib_mad *mad ) {
struct ib_mc_member_record *mc_member_record =
&mad->sa.sa_data.mc_member_record;
@ -202,14 +202,14 @@ static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
/* Ignore if not a success */
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( ibdev, "IBDEV %p leave failed with status %04x\n",
ibdev, ntohs ( mad->hdr.status ) );
DBGC ( gma, "GMA %p leave failed with status %04x\n",
gma, ntohs ( mad->hdr.status ) );
return -EINVAL;
}
/* Extract MAD parameters */
gid = &mc_member_record->mgid;
DBGC ( ibdev, "IBDEV %p left %08x:%08x:%08x:%08x\n", ibdev,
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[2] ), ntohl ( gid->u.dwords[3] ) );
@ -217,7 +217,7 @@ static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
}
/** Multicast membership record response handler */
struct ib_mad_handler ib_mc_member_record_handlers[] __ib_mad_handler = {
struct ib_gma_handler ib_mc_member_record_handlers[] __ib_gma_handler = {
{
.mgmt_class = IB_MGMT_CLASS_SUBN_ADM,
.class_version = IB_SA_CLASS_VERSION,

View File

@ -98,6 +98,7 @@ ib_find_path_cache_entry ( struct ib_device *ibdev, struct ib_gid *dgid ) {
*/
int ib_resolve_path ( struct ib_device *ibdev,
struct ib_address_vector *av ) {
struct ib_gma *gma = &ibdev->gma;
struct ib_gid *gid = &av->gid;
struct ib_cached_path_record *cached;
union ib_mad mad;
@ -107,8 +108,8 @@ int ib_resolve_path ( struct ib_device *ibdev,
/* Sanity check */
if ( ! av->gid_present ) {
DBGC ( ibdev, "IBDEV %p attempt to look up path record "
"without GID\n", ibdev );
DBGC ( gma, "GMA %p attempt to look up path record "
"without GID\n", gma );
return -EINVAL;
}
@ -119,13 +120,13 @@ int ib_resolve_path ( struct ib_device *ibdev,
av->lid = cached->dlid;
av->rate = cached->rate;
av->sl = cached->sl;
DBGC2 ( ibdev, "IBDEV %p cache hit for %08x:%08x:%08x:%08x\n",
ibdev, htonl ( gid->u.dwords[0] ),
DBGC2 ( gma, "GMA %p cache hit for %08x:%08x:%08x:%08x\n",
gma, htonl ( gid->u.dwords[0] ),
htonl ( gid->u.dwords[1] ), htonl ( gid->u.dwords[2] ),
htonl ( gid->u.dwords[3] ) );
return 0;
}
DBGC ( ibdev, "IBDEV %p cache miss for %08x:%08x:%08x:%08x%s\n", ibdev,
DBGC ( gma, "GMA %p cache miss for %08x:%08x:%08x:%08x%s\n", gma,
htonl ( gid->u.dwords[0] ), htonl ( gid->u.dwords[1] ),
htonl ( gid->u.dwords[2] ), htonl ( gid->u.dwords[3] ),
( cached ? " (in progress)" : "" ) );
@ -154,9 +155,9 @@ int ib_resolve_path ( struct ib_device *ibdev,
sizeof ( sa->sa_data.path_record.sgid ) );
/* Issue path record request */
if ( ( rc = ib_gma_request ( &ibdev->gma, &mad, NULL, 1 ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not get path record: %s\n",
ibdev, strerror ( rc ) );
if ( ( rc = ib_gma_request ( gma, &mad, NULL, 1 ) ) != 0 ) {
DBGC ( gma, "GMA %p could not get path record: %s\n",
gma, strerror ( rc ) );
return rc;
}
@ -167,12 +168,13 @@ int ib_resolve_path ( struct ib_device *ibdev,
/**
* Handle path record response
*
* @v ibdev Infiniband device
* @v gma General management agent
* @v mad MAD
* @ret rc Return status code
*/
static int ib_handle_path_record ( struct ib_device *ibdev,
static int ib_handle_path_record ( struct ib_gma *gma,
union ib_mad *mad ) {
struct ib_device *ibdev = gma->ibdev;
struct ib_path_record *path_record = &mad->sa.sa_data.path_record;
struct ib_gid *dgid = &path_record->dgid;
struct ib_cached_path_record *cached;
@ -182,8 +184,8 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
/* Ignore if not a success */
if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
DBGC ( ibdev, "IBDEV %p path record lookup failed with status "
"%04x\n", ibdev, ntohs ( mad->hdr.status ) );
DBGC ( gma, "GMA %p path record lookup failed with status "
"%04x\n", gma, ntohs ( mad->hdr.status ) );
return -EINVAL;
}
@ -191,15 +193,15 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
dlid = ntohs ( path_record->dlid );
sl = ( path_record->reserved__sl & 0x0f );
rate = ( path_record->rate_selector__rate & 0x3f );
DBGC ( ibdev, "IBDEV %p path to %08x:%08x:%08x:%08x is %04x sl %d "
"rate %d\n", ibdev, htonl ( dgid->u.dwords[0] ),
DBGC ( gma, "GMA %p path to %08x:%08x:%08x:%08x is %04x sl %d "
"rate %d\n", gma, htonl ( dgid->u.dwords[0] ),
htonl ( dgid->u.dwords[1] ), htonl ( dgid->u.dwords[2] ),
htonl ( dgid->u.dwords[3] ), dlid, sl, rate );
/* Look for a matching cache entry to fill in */
if ( ( cached = ib_find_path_cache_entry ( ibdev, dgid ) ) != NULL ) {
DBGC ( ibdev, "IBDEV %p cache add for %08x:%08x:%08x:%08x\n",
ibdev, htonl ( dgid->u.dwords[0] ),
DBGC ( gma, "GMA %p cache add for %08x:%08x:%08x:%08x\n",
gma, htonl ( dgid->u.dwords[0] ),
htonl ( dgid->u.dwords[1] ),
htonl ( dgid->u.dwords[2] ),
htonl ( dgid->u.dwords[3] ) );
@ -212,7 +214,7 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
}
/** Path record response handler */
struct ib_mad_handler ib_path_record_handler __ib_mad_handler = {
struct ib_gma_handler ib_path_record_handler __ib_gma_handler = {
.mgmt_class = IB_MGMT_CLASS_SUBN_ADM,
.class_version = IB_SA_CLASS_VERSION,
.method = IB_MGMT_METHOD_GET_RESP,