[infiniband] Create a general management agent

Generalise the subnet management agent into a general management agent
capable of sending and responding to MADs, including support for
retransmissions as necessary.
This commit is contained in:
Michael Brown
2009-07-06 23:09:26 +01:00
parent 365b8db5cf
commit 1d8c85d112
6 changed files with 534 additions and 7 deletions

View File

@@ -485,16 +485,36 @@ void ib_refill_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
int ib_open ( struct ib_device *ibdev ) {
int rc;
/* Open device if this is the first requested opening */
if ( ibdev->open_count == 0 ) {
if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 )
return rc;
/* Increment device open request counter */
if ( ibdev->open_count++ > 0 ) {
/* Device was already open; do nothing */
return 0;
}
/* Increment device open request counter */
ibdev->open_count++;
/* Open device */
if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not open: %s\n",
ibdev, strerror ( rc ) );
goto err_open;
}
/* Create general management agent */
if ( ( rc = ib_create_gma ( &ibdev->gma, ibdev, IB_QKEY_GMA ) ) != 0 ){
DBGC ( ibdev, "IBDEV %p could not create GMA: %s\n",
ibdev, strerror ( rc ) );
goto err_create_gma;
}
assert ( ibdev->open_count == 1 );
return 0;
ib_destroy_gma ( &ibdev->gma );
err_create_gma:
ibdev->op->close ( ibdev );
err_open:
assert ( ibdev->open_count == 1 );
ibdev->open_count = 0;
return rc;
}
/**
@@ -508,8 +528,10 @@ void ib_close ( struct ib_device *ibdev ) {
ibdev->open_count--;
/* Close device if this was the last remaining requested opening */
if ( ibdev->open_count == 0 )
if ( ibdev->open_count == 0 ) {
ib_destroy_gma ( &ibdev->gma );
ibdev->op->close ( ibdev );
}
}
/***************************************************************************