iPXE
Functions
ib_cmrc.h File Reference

Infiniband Communication-managed Reliable Connections. More...

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

Go to the source code of this file.

Functions

 FILE_LICENCE (BSD2)
int ib_cmrc_open (struct interface *xfer, struct ib_device *ibdev, union ib_gid *dgid, union ib_guid *service_id, const char *name)
 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 interface xfer,
struct ib_device ibdev,
union ib_gid dgid,
union ib_guid service_id,
const char *  name 
)

Open CMRC connection.

Parameters:
xferData transfer interface
ibdevInfiniband device
dgidDestination GID
service_idService ID
nameConnection name
Return values:
rcReturns status code

Definition at line 397 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_create_cq(), ib_create_qp(), ib_destroy_cq(), ib_destroy_qp(), ib_open(), ib_qp_set_ownerdata(), IB_QPT_RC, ib_cmrc_connection::ibdev, intf_init(), intf_plug_plug(), memcpy(), ib_cmrc_connection::name, ib_device::name, name, NULL, process_init_stopped(), ib_cmrc_connection::qp, ib_queue_pair::qpn, rc, ref_init, ref_put, ib_cmrc_connection::refcnt, ib_cmrc_connection::service_id, ib_cmrc_connection::shutdown, strerror(), ib_cmrc_connection::xfer, and zalloc().

Referenced by ib_srp_open(), and xcm_reopen().

                                      {
        struct ib_cmrc_connection *cmrc;
        int rc;

        /* Allocate and initialise structure */
        cmrc = zalloc ( sizeof ( *cmrc ) );
        if ( ! cmrc ) {
                rc = -ENOMEM;
                goto err_alloc;
        }
        ref_init ( &cmrc->refcnt, NULL );
        cmrc->name = name;
        intf_init ( &cmrc->xfer, &ib_cmrc_xfer_desc, &cmrc->refcnt );
        cmrc->ibdev = ibdev;
        memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
        memcpy ( &cmrc->service_id, service_id, sizeof ( cmrc->service_id ) );
        process_init_stopped ( &cmrc->shutdown, &ib_cmrc_shutdown_desc,
                               &cmrc->refcnt );

        /* Open Infiniband device */
        if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
                DBGC ( cmrc, "CMRC %s %s could not open device: %s\n",
                       ibdev->name, cmrc->name, strerror ( rc ) );
                goto err_open;
        }

        /* Create completion queue */
        if ( ( rc = ib_create_cq ( ibdev, IB_CMRC_NUM_CQES,
                                   &ib_cmrc_completion_ops, &cmrc->cq ) ) != 0){
                DBGC ( cmrc, "CMRC %s %s could not create completion queue: "
                       "%s\n", ibdev->name, cmrc->name, strerror ( rc ) );
                goto err_create_cq;
        }

        /* Create queue pair */
        if ( ( rc = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES,
                                   cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq,
                                   &ib_cmrc_queue_pair_ops, name,
                                   &cmrc->qp ) ) != 0 ) {
                DBGC ( cmrc, "CMRC %s %s could not create queue pair: %s\n",
                       ibdev->name, cmrc->name, strerror ( rc ) );
                goto err_create_qp;
        }
        ib_qp_set_ownerdata ( cmrc->qp, cmrc );
        DBGC ( cmrc, "CMRC %s %s using QPN %#lx\n",
               ibdev->name, cmrc->name, cmrc->qp->qpn );

        /* Attach to parent interface, transfer reference (implicitly)
         * to our shutdown process, and return.
         */
        intf_plug_plug ( &cmrc->xfer, xfer );
        return 0;

        ib_destroy_qp ( ibdev, cmrc->qp );
 err_create_qp:
        ib_destroy_cq ( ibdev, cmrc->cq );
 err_create_cq:
        ib_close ( ibdev );
 err_open:
        ref_put ( &cmrc->refcnt );
 err_alloc:
        return rc;
}