ib_cmrc.h File Reference

Infiniband Communication-managed Reliable Connections. More...

#include <gpxe/infiniband.h>
#include <gpxe/xfer.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (BSD2)
int ib_cmrc_open (struct xfer_interface *xfer, struct ib_device *ibdev, struct ib_gid *dgid, struct ib_gid_half *service_id)
 Open CMRC connection.


Detailed Description

Infiniband Communication-managed Reliable Connections.

Definition in file ib_cmrc.h.


Function Documentation

FILE_LICENCE ( BSD2   ) 

int ib_cmrc_open ( struct xfer_interface xfer,
struct ib_device ibdev,
struct ib_gid dgid,
struct ib_gid_half service_id 
)

Open CMRC connection.

Parameters:
xfer Data transfer interface
ibdev Infiniband device
dgid Destination GID
service_id Service ID
Return values:
rc Returns status code

Definition at line 375 of file ib_cmrc.c.

References ib_cmrc_connection::cq, DBGC, ib_cmrc_connection::dgid, ENOMEM, ib_close(), IB_CMRC_NUM_CQES, IB_CMRC_NUM_RECV_WQES, IB_CMRC_NUM_SEND_WQES, ib_cmrc_shutdown(), ib_create_cq(), ib_create_qp(), ib_destroy_cq(), ib_destroy_qp(), ib_open(), ib_qp_set_ownerdata(), IB_QPT_RC, ib_cmrc_connection::ibdev, memcpy, process_init_stopped(), ib_cmrc_connection::qp, ib_queue_pair::qpn, ref_put(), ib_cmrc_connection::refcnt, ib_cmrc_connection::service_id, ib_cmrc_connection::shutdown, strerror(), ib_cmrc_connection::xfer, xfer_init(), and zalloc().

Referenced by ib_srp_connect().

00376                                                                          {
00377         struct ib_cmrc_connection *cmrc;
00378         int rc;
00379 
00380         /* Allocate and initialise structure */
00381         cmrc = zalloc ( sizeof ( *cmrc ) );
00382         if ( ! cmrc ) {
00383                 rc = -ENOMEM;
00384                 goto err_alloc;
00385         }
00386         xfer_init ( &cmrc->xfer, &ib_cmrc_xfer_operations, &cmrc->refcnt );
00387         cmrc->ibdev = ibdev;
00388         memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
00389         memcpy ( &cmrc->service_id, service_id, sizeof ( cmrc->service_id ) );
00390         process_init_stopped ( &cmrc->shutdown, ib_cmrc_shutdown,
00391                                &cmrc->refcnt );
00392 
00393         /* Open Infiniband device */
00394         if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
00395                 DBGC ( cmrc, "CMRC %p could not open device: %s\n",
00396                        cmrc, strerror ( rc ) );
00397                 goto err_open;
00398         }
00399 
00400         /* Create completion queue */
00401         cmrc->cq = ib_create_cq ( ibdev, IB_CMRC_NUM_CQES,
00402                                   &ib_cmrc_completion_ops );
00403         if ( ! cmrc->cq ) {
00404                 DBGC ( cmrc, "CMRC %p could not create completion queue\n",
00405                        cmrc );
00406                 rc = -ENOMEM;
00407                 goto err_create_cq;
00408         }
00409 
00410         /* Create queue pair */
00411         cmrc->qp = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES,
00412                                   cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq );
00413         if ( ! cmrc->qp ) {
00414                 DBGC ( cmrc, "CMRC %p could not create queue pair\n", cmrc );
00415                 rc = -ENOMEM;
00416                 goto err_create_qp;
00417         }
00418         ib_qp_set_ownerdata ( cmrc->qp, cmrc );
00419         DBGC ( cmrc, "CMRC %p using QPN %lx\n", cmrc, cmrc->qp->qpn );
00420 
00421         /* Attach to parent interface, transfer reference (implicitly)
00422          * to our shutdown process, and return.
00423          */
00424         xfer_plug_plug ( &cmrc->xfer, xfer );
00425         return 0;
00426 
00427         ib_destroy_qp ( ibdev, cmrc->qp );
00428  err_create_qp:
00429         ib_destroy_cq ( ibdev, cmrc->cq );
00430  err_create_cq:
00431         ib_close ( ibdev );
00432  err_open:
00433         ref_put ( &cmrc->refcnt );
00434  err_alloc:
00435         return rc;
00436 }


Generated on Tue Apr 6 20:01:50 2010 for gPXE by  doxygen 1.5.7.1