ibv_attach_mcast

Attaches and detaches a queue pair (QPs) to or from a multicast group

Syntax

#include <rdma/verbs.h>
int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
                     uint16_t lid);
int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
                     uint16_t lid);

Description

The ibv_attach_mcast function attaches the queue pair (QP) to the multicast group that has the MGID gid and MLID lid. The ibv_detach_mcast function detaches the QP to the multicast group that has the MGID gid and MLID lid.
Note:
  • QPs of Transport Service Type IBV_QPT_UD or IBV_QPT_RAW_PACKET can be attached to multicast groups.
  • If a QP is attached to the same multicast group multiple times, the QP receives a single copy of a multicast message.
  • To receive multicast messages, a join request for the multicast group must be sent to the subnet administrator (SA). The fabric's multicast routing is configured on receiving the join request to deliver messages to the local port.

Return Values

0
The ibv_attach_mcast and ibv_detach_mcast functions returns 0 on success.
errno
The ibv_attach_mcast and ibv_detach_mcast functions returns 0 on failure. errno also specifies the reason for failure.

Examples

To use ibv_attach_mcast function with RAW ETH QP, use the following program:
union ibv_gid mgid;

        memset(&mgid, 0, sizeof(union ibv_gid));
        memcpy(&mgid.raw[10], mmac, 6);         
        if (ibv_attach_mcast(qp, &mgid, 0)) {       
            printf ("Failed to attach qp to mcast. Errno: %d\n",errno);
            return 1;
         }