iPXE
Functions | Variables
ib_mcast.c File Reference

Infiniband multicast groups. More...

#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/list.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_mi.h>
#include <ipxe/ib_mcast.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void ib_mcast_mad (struct ib_device *ibdev, struct ib_address_vector *av, unsigned int method, unsigned int mask, union ib_mad *mad)
 Generate multicast membership MAD.
static void ib_mcast_complete (struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *src __unused)
 Handle multicast membership record join response.
int ib_mcast_join (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_mc_membership *membership, struct ib_address_vector *av, unsigned int mask, void(*complete)(struct ib_mc_membership *membership, int rc))
 Join multicast group.
void ib_mcast_leave (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_mc_membership *membership)
 Leave multicast group.

Variables

static struct
ib_mad_transaction_operations 
ib_mcast_op
 Multicast membership management transaction completion operations.

Detailed Description

Infiniband multicast groups.

Definition in file ib_mcast.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void ib_mcast_mad ( struct ib_device ibdev,
struct ib_address_vector av,
unsigned int  method,
unsigned int  mask,
union ib_mad mad 
) [static]

Generate multicast membership MAD.

Parameters:
ibdevInfiniband device
avAddress vector
methodMethod (IB_MGMT_METHOD_SET or IB_MGMT_METHOD_DELETE)
maskAdditional component mask
madMAD to fill in

Definition at line 50 of file ib_mcast.c.

References ib_mad_hdr::attr_id, ib_mad_hdr::class_version, ib_sa_hdr::comp_mask, ib_address_vector::gid, ib_device::gid, htonl, htons, IB_MGMT_CLASS_SUBN_ADM, IB_PKEY_FULL, IB_SA_ATTR_MC_MEMBER_REC, IB_SA_CLASS_VERSION, IB_SA_MCMEMBER_REC_JOIN_STATE, IB_SA_MCMEMBER_REC_MGID, IB_SA_MCMEMBER_REC_PORT_GID, ib_mad_sa::mad_hdr, ib_sa_data::mc_member_record, memcpy(), memset(), ib_mad_hdr::method, method, ib_mc_member_record::mgid, ib_mad_hdr::mgmt_class, ib_mc_member_record::pkey, ib_device::pkey, ib_mc_member_record::port_gid, ib_address_vector::qkey, ib_mc_member_record::qkey, ib_address_vector::rate, ib_mc_member_record::rate_selector__rate, sa, ib_mad::sa, ib_mad_sa::sa_data, ib_mad_sa::sa_hdr, ib_mc_member_record::scope__join_state, ib_address_vector::sl, and ib_mc_member_record::sl__flow_label__hop_limit.

Referenced by ib_mcast_join(), and ib_mcast_leave().

static void ib_mcast_complete ( struct ib_device ibdev,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx,
int  rc,
union ib_mad mad,
struct ib_address_vector *src  __unused 
) [static]

Handle multicast membership record join response.

Parameters:
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
srcSource address vector (or NULL on error)

Definition at line 88 of file ib_mcast.c.

References ib_mc_membership::av, ib_mc_membership::complete, DBGC, ENOTCONN, ib_address_vector::gid, ib_mad::hdr, htons, ib_destroy_madx(), IB_GID_ARGS, IB_GID_FMT, ib_madx_get_ownerdata(), IB_MGMT_METHOD_GET_RESP, IB_MGMT_STATUS_OK, ib_modify_qp(), ib_address_vector::lid, ib_mc_membership::madx, ib_sa_data::mc_member_record, mc_member_record, ib_mad_hdr::method, ib_mc_member_record::mlid, ib_device::name, ntohl, ntohs, NULL, out, ib_address_vector::qkey, ib_queue_pair::qkey, ib_mc_member_record::qkey, ib_mc_membership::qp, qp, ib_queue_pair::qpn, ib_address_vector::rate, ib_mc_member_record::rate_selector__rate, ib_mad::sa, ib_mad_sa::sa_data, ib_address_vector::sl, ib_mc_member_record::sl__flow_label__hop_limit, ib_mad_hdr::status, and strerror().

                                                                         {
        struct ib_mc_membership *membership = ib_madx_get_ownerdata ( madx );
        struct ib_queue_pair *qp = membership->qp;
        struct ib_address_vector *av = membership->av;
        struct ib_mc_member_record *mc_member_record =
                &mad->sa.sa_data.mc_member_record;
        int joined;

        /* Report failures */
        if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ))
                rc = -ENOTCONN;
        if ( rc != 0 ) {
                DBGC ( ibdev, "IBDEV %s QPN %#lx join failed: %s\n",
                       ibdev->name, qp->qpn, strerror ( rc ) );
                goto out;
        }

        /* Extract values from MAD */
        joined = ( mad->hdr.method == IB_MGMT_METHOD_GET_RESP );
        av->qkey = ntohl ( mc_member_record->qkey );
        av->lid = ntohs ( mc_member_record->mlid );
        av->rate = ( mc_member_record->rate_selector__rate & 0x3f );
        av->sl = ( ( ntohl ( mc_member_record->sl__flow_label__hop_limit )
                     >> 28 ) & 0x0f );
        DBGC ( ibdev, "IBDEV %s QPN %#lx %s " IB_GID_FMT " qkey %#lx\n",
               ibdev->name, qp->qpn, ( joined ? "joined" : "left" ),
               IB_GID_ARGS ( &av->gid ), av->qkey );

        /* Set queue key */
        qp->qkey = av->qkey;
        if ( ( rc = ib_modify_qp ( ibdev, qp ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s QPN %#lx could not modify qkey: %s\n",
                       ibdev->name, qp->qpn, strerror ( rc ) );
                goto out;
        }

 out:
        /* Destroy the completed transaction */
        ib_destroy_madx ( ibdev, mi, madx );
        membership->madx = NULL;

        /* Hand off to upper completion handler */
        membership->complete ( membership, rc );
}
int ib_mcast_join ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_mc_membership membership,
struct ib_address_vector av,
unsigned int  mask,
void(*)(struct ib_mc_membership *membership, int rc complete 
)

Join multicast group.

Parameters:
ibdevInfiniband device
qpQueue pair
membershipMulticast group membership
avAddress vector to fill in
joinedJoin completion handler
Return values:
rcReturn status code

Definition at line 152 of file ib_mcast.c.

References assert, ib_mc_membership::attached, ib_mc_membership::av, ib_mc_membership::complete, DBGC, ENOMEM, ib_address_vector::gid, ib_device::gsi, ib_create_madx(), ib_destroy_madx(), IB_GID_ARGS, IB_GID_FMT, ib_madx_set_ownerdata(), ib_mcast_attach(), ib_mcast_detach(), ib_mcast_mad(), IB_MGMT_METHOD_SET, ib_mc_membership::madx, ib_device::name, NULL, ib_mc_membership::qp, qp, ib_queue_pair::qpn, rc, and strerror().

Referenced by eoib_join_broadcast_group(), and ipoib_join_broadcast_group().

                                                     {
        union ib_mad mad;
        int rc;

        DBGC ( ibdev, "IBDEV %s QPN %#lx joining " IB_GID_FMT "\n",
               ibdev->name, qp->qpn, IB_GID_ARGS ( &av->gid ) );

        /* Sanity checks */
        assert ( qp != NULL );
        assert ( ! membership->attached );

        /* Initialise structure */
        membership->qp = qp;
        membership->av = av;
        membership->complete = complete;

        /* Attach queue pair to multicast GID */
        if ( ( rc = ib_mcast_attach ( ibdev, qp, &av->gid ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s QPN %#lx could not attach: %s\n",
                       ibdev->name, qp->qpn, strerror ( rc ) );
                goto err_mcast_attach;
        }
        membership->attached = 1;

        /* Initiate multicast membership join */
        ib_mcast_mad ( ibdev, av, IB_MGMT_METHOD_SET, mask, &mad );
        membership->madx = ib_create_madx ( ibdev, ibdev->gsi, &mad, NULL,
                                            &ib_mcast_op );
        if ( ! membership->madx ) {
                DBGC ( ibdev, "IBDEV %s QPN %#lx could not create join "
                       "transaction\n", ibdev->name, qp->qpn );
                rc = -ENOMEM;
                goto err_create_madx;
        }
        ib_madx_set_ownerdata ( membership->madx, membership );

        return 0;

        ib_destroy_madx ( ibdev, ibdev->gsi, membership->madx );
 err_create_madx:
        ib_mcast_detach ( ibdev, qp, &av->gid );
        membership->attached = 0;
 err_mcast_attach:
        return rc;
}
void ib_mcast_leave ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_mc_membership membership 
)

Leave multicast group.

Parameters:
ibdevInfiniband device
qpQueue pair
membershipMulticast group membership

Definition at line 209 of file ib_mcast.c.

References assert, ib_mc_membership::attached, ib_mc_membership::av, DBGC, ib_address_vector::gid, ib_device::gsi, ib_destroy_madx(), IB_GID_ARGS, IB_GID_FMT, ib_mcast_detach(), ib_mcast_mad(), IB_MGMT_METHOD_DELETE, ib_mi_send(), ib_mc_membership::madx, ib_device::name, NULL, ib_queue_pair::qpn, rc, and strerror().

Referenced by eoib_leave_broadcast_group(), and ipoib_leave_broadcast_group().

                                                            {
        struct ib_address_vector *av = membership->av;
        union ib_mad mad;
        int rc;

        /* Do nothing if we are already detached from the multicast GID */
        if ( ! membership->attached )
                return;

        DBGC ( ibdev, "IBDEV %s QPN %#lx leaving " IB_GID_FMT "\n",
               ibdev->name, qp->qpn, IB_GID_ARGS ( &av->gid ) );

        /* Sanity check */
        assert ( qp != NULL );

        /* Detach from multicast GID */
        ib_mcast_detach ( ibdev, qp, &av->gid );
        membership->attached = 0;

        /* Cancel multicast membership join, if applicable */
        if ( membership->madx ) {
                ib_destroy_madx ( ibdev, ibdev->gsi, membership->madx );
                membership->madx = NULL;
        }

        /* Send a single group leave MAD */
        ib_mcast_mad ( ibdev, av, IB_MGMT_METHOD_DELETE, 0, &mad );
        if ( ( rc = ib_mi_send ( ibdev, ibdev->gsi, &mad, NULL ) ) != 0 ) {
                DBGC ( ibdev, "IBDEV %s QPN %#lx could not send leave request: "
                       "%s\n", ibdev->name, qp->qpn, strerror ( rc ) );
        }
}

Variable Documentation

Initial value:
 {
        .complete = ib_mcast_complete,
}

Multicast membership management transaction completion operations.

Definition at line 138 of file ib_mcast.c.