summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2009-07-07 19:09:21 +0200
committerMichael Brown2009-07-18 00:06:34 +0200
commit8a852280eb84ff6a43f8c08aeb52c3e21a5da31b (patch)
tree54b116ac0980f2fb999f2c4e8d7768eadef3c554
parent[ipoib] Remove the queue set abstraction (diff)
downloadipxe-8a852280eb84ff6a43f8c08aeb52c3e21a5da31b.tar.gz
ipxe-8a852280eb84ff6a43f8c08aeb52c3e21a5da31b.tar.xz
ipxe-8a852280eb84ff6a43f8c08aeb52c3e21a5da31b.zip
[infiniband] Pass GMA as a parameter to GMA MAD handlers
-rw-r--r--src/include/gpxe/ib_gma.h17
-rw-r--r--src/net/infiniband/ib_gma.c21
-rw-r--r--src/net/infiniband/ib_mcast.c70
-rw-r--r--src/net/infiniband/ib_pathrec.c36
4 files changed, 72 insertions, 72 deletions
diff --git a/src/include/gpxe/ib_gma.h b/src/include/gpxe/ib_gma.h
index c921e251..04955e5c 100644
--- a/src/include/gpxe/ib_gma.h
+++ b/src/include/gpxe/ib_gma.h
@@ -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 {
diff --git a/src/net/infiniband/ib_gma.c b/src/net/infiniband/ib_gma.c
index 56c0fe95..89f0eeb1 100644
--- a/src/net/infiniband/ib_gma.c
+++ b/src/net/infiniband/ib_gma.c
@@ -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 ) );
diff --git a/src/net/infiniband/ib_mcast.c b/src/net/infiniband/ib_mcast.c
index 358ee0d1..a9546771 100644
--- a/src/net/infiniband/ib_mcast.c
+++ b/src/net/infiniband/ib_mcast.c
@@ -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,
diff --git a/src/net/infiniband/ib_pathrec.c b/src/net/infiniband/ib_pathrec.c
index 06101670..316ccd47 100644
--- a/src/net/infiniband/ib_pathrec.c
+++ b/src/net/infiniband/ib_pathrec.c
@@ -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,