Skip to content

Commit

Permalink
[infiniband] Implement SMA as an instance of a GMA
Browse files Browse the repository at this point in the history
The GMA code was based upon the SMA code.  We can save space by making
the SMA simply an instance of the GMA.
  • Loading branch information
Michael Brown committed Jul 17, 2009
1 parent 8a85228 commit 165074c
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 363 deletions.
11 changes: 3 additions & 8 deletions src/drivers/infiniband/linda.c
Expand Up @@ -272,11 +272,6 @@ static int linda_set_port_info ( struct ib_device *ibdev,
return 0;
}

/** Linda subnet management operations */
static struct ib_sma_operations linda_sma_operations = {
.set_port_info = linda_set_port_info,
};

/***************************************************************************
*
* Context allocation
Expand Down Expand Up @@ -1464,6 +1459,7 @@ static struct ib_device_operations linda_ib_operations = {
.close = linda_close,
.mcast_attach = linda_mcast_attach,
.mcast_detach = linda_mcast_detach,
.set_port_info = linda_set_port_info,
};

/***************************************************************************
Expand Down Expand Up @@ -2340,11 +2336,10 @@ static int linda_probe ( struct pci_device *pci,
goto err_init_ib_serdes;

/* Create the SMA */
if ( ( rc = ib_create_sma ( &linda->sma, ibdev,
&linda_sma_operations ) ) != 0 )
if ( ( rc = ib_create_sma ( &linda->sma, ibdev ) ) != 0 )
goto err_create_sma;
/* If the SMA doesn't get context 0, we're screwed */
assert ( linda_qpn_to_ctx ( linda->sma.qp->qpn ) == 0 );
assert ( linda_qpn_to_ctx ( linda->sma.gma.qp->qpn ) == 0 );

/* Register Infiniband device */
if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
Expand Down
2 changes: 2 additions & 0 deletions src/include/gpxe/ib_gma.h
Expand Up @@ -23,6 +23,8 @@ struct ib_gma;
struct ib_gma_handler {
/** Management class */
uint8_t mgmt_class;
/** Management class don't-care bits */
uint8_t mgmt_class_ignore;
/** Class version */
uint8_t class_version;
/** Method */
Expand Down
3 changes: 3 additions & 0 deletions src/include/gpxe/ib_mad.h
Expand Up @@ -30,6 +30,9 @@ struct ib_smp_hdr {
uint8_t reserved[28];
} __attribute__ (( packed ));

/** Bits to ignore in the management class for subnet management MADs */
#define IB_SMP_CLASS_IGNORE 0x80

/** Subnet management class version */
#define IB_SMP_CLASS_VERSION 1

Expand Down
43 changes: 4 additions & 39 deletions src/include/gpxe/ib_sma.h
Expand Up @@ -10,50 +10,15 @@
FILE_LICENCE ( GPL2_OR_LATER );

#include <gpxe/infiniband.h>

/** Infiniband Subnet Management Agent operations */
struct ib_sma_operations {
/** Set port information
*
* @v ibdev Infiniband device
* @v port_info New port information
*/
int ( * set_port_info ) ( struct ib_device *ibdev,
const struct ib_port_info *port_info );
};
#include <gpxe/ib_gma.h>

/** An Infiniband Subnet Management Agent */
struct ib_sma {
/** Infiniband device */
struct ib_device *ibdev;
/** SMA operations */
struct ib_sma_operations *op;
/** SMA completion queue */
struct ib_completion_queue *cq;
/** SMA queue pair */
struct ib_queue_pair *qp;
/** General management agent */
struct ib_gma gma;
};

/** SMA number of send WQEs
*
* This is a policy decision.
*/
#define IB_SMA_NUM_SEND_WQES 4

/** SMA number of receive WQEs
*
* This is a policy decision.
*/
#define IB_SMA_NUM_RECV_WQES 2

/** SMA number of completion queue entries
*
* This is a policy decision
*/
#define IB_SMA_NUM_CQES 8

extern int ib_create_sma ( struct ib_sma *sma, struct ib_device *ibdev,
struct ib_sma_operations *op );
extern int ib_create_sma ( struct ib_sma *sma, struct ib_device *ibdev );
extern void ib_destroy_sma ( struct ib_sma *sma );

#endif /* _GPXE_IB_SMA_H */
12 changes: 12 additions & 0 deletions src/include/gpxe/infiniband.h
Expand Up @@ -327,6 +327,16 @@ struct ib_device_operations {
void ( * mcast_detach ) ( struct ib_device *ibdev,
struct ib_queue_pair *qp,
struct ib_gid *gid );
/** Set port information
*
* @v ibdev Infiniband device
* @v port_info New port information
*
* This method is required only by adapters that do not have
* an embedded SMA.
*/
int ( * set_port_info ) ( struct ib_device *ibdev,
const struct ib_port_info *port_info );
};

/** An Infiniband device */
Expand Down Expand Up @@ -420,6 +430,8 @@ extern void ib_mcast_detach ( struct ib_device *ibdev,
struct ib_queue_pair *qp, struct ib_gid *gid );
extern int ib_get_hca_info ( struct ib_device *ibdev,
struct ib_gid_half *hca_guid );
extern int ib_set_port_info ( struct ib_device *ibdev,
const struct ib_port_info *port_info );
extern struct ib_device * alloc_ibdev ( size_t priv_size );
extern int register_ibdev ( struct ib_device *ibdev );
extern void unregister_ibdev ( struct ib_device *ibdev );
Expand Down
25 changes: 25 additions & 0 deletions src/net/infiniband.c
Expand Up @@ -644,6 +644,31 @@ int ib_get_hca_info ( struct ib_device *ibdev,
return num_ports;
}

/** Set port information
*
* @v ibdev Infiniband device
* @v port_info New port information
*/
int ib_set_port_info ( struct ib_device *ibdev,
const struct ib_port_info *port_info ) {
int rc;

/* Adapters with embedded SMAs do not need to support this method */
if ( ! ibdev->op->set_port_info ) {
DBGC ( ibdev, "IBDEV %p does not support setting port "
"information\n", ibdev );
return -ENOTSUP;
}

if ( ( rc = ibdev->op->set_port_info ( ibdev, port_info ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not set port information: %s\n",
ibdev, strerror ( rc ) );
return rc;
}

return 0;
};

/***************************************************************************
*
* Event queues
Expand Down
3 changes: 2 additions & 1 deletion src/net/infiniband/ib_gma.c
Expand Up @@ -86,7 +86,8 @@ static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
struct ib_gma_handler *handler;

for_each_table_entry ( handler, IB_GMA_HANDLERS ) {
if ( ( handler->mgmt_class == hdr->mgmt_class ) &&
if ( ( ( handler->mgmt_class & ~handler->mgmt_class_ignore ) ==
( hdr->mgmt_class & ~handler->mgmt_class_ignore ) ) &&
( handler->class_version == hdr->class_version ) &&
( handler->method == hdr->method ) &&
( handler->attr_id == hdr->attr_id ) ) {
Expand Down

0 comments on commit 165074c

Please sign in to comment.