david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[infiniband] Record multicast GID attachment as part of group membership

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2016-03-05 15:33:28 +00:00
parent 114a2f19a6
commit c335f8eae4
3 changed files with 16 additions and 18 deletions

View File

@ -89,14 +89,8 @@ struct ipoib_device {
struct ipoib_mac mac;
/** Broadcast MAC */
struct ipoib_mac broadcast;
/** Joined to IPv4 broadcast multicast group
*
* This flag indicates whether or not we have initiated the
* join to the IPv4 broadcast multicast group.
*/
int broadcast_joined;
/** IPv4 broadcast multicast group membership */
struct ib_mc_membership broadcast_membership;
struct ib_mc_membership membership;
/** REMAC cache */
struct list_head peers;
};
@ -742,8 +736,8 @@ void ipoib_join_complete ( struct ib_device *ibdev __unused,
struct ib_queue_pair *qp __unused,
struct ib_mc_membership *membership, int rc,
union ib_mad *mad __unused ) {
struct ipoib_device *ipoib = container_of ( membership,
struct ipoib_device, broadcast_membership );
struct ipoib_device *ipoib =
container_of ( membership, struct ipoib_device, membership );
/* Record join status as link status */
netdev_link_err ( ipoib->netdev, rc );
@ -759,14 +753,12 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
int rc;
if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qp,
&ipoib->broadcast_membership,
&ipoib->broadcast.gid,
&ipoib->membership, &ipoib->broadcast.gid,
ipoib_join_complete ) ) != 0 ) {
DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
ipoib, strerror ( rc ) );
return rc;
}
ipoib->broadcast_joined = 1;
return 0;
}
@ -778,11 +770,7 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
*/
static void ipoib_leave_broadcast_group ( struct ipoib_device *ipoib ) {
if ( ipoib->broadcast_joined ) {
ib_mcast_leave ( ipoib->ibdev, ipoib->qp,
&ipoib->broadcast_membership );
ipoib->broadcast_joined = 0;
}
ib_mcast_leave ( ipoib->ibdev, ipoib->qp, &ipoib->membership );
}
/**

View File

@ -19,6 +19,8 @@ struct ib_mc_membership {
struct ib_queue_pair *qp;
/** Multicast GID */
union ib_gid gid;
/** Attached to multicast GID */
int attached;
/** Multicast group join transaction */
struct ib_mad_transaction *madx;
/** Handle join success/failure

View File

@ -150,8 +150,9 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
DBGC ( ibdev, "IBDEV %s QPN %#lx joining " IB_GID_FMT "\n",
ibdev->name, qp->qpn, IB_GID_ARGS ( gid ) );
/* Sanity check */
/* Sanity checks */
assert ( qp != NULL );
assert ( ! membership->attached );
/* Initialise structure */
membership->qp = qp;
@ -164,6 +165,7 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
ibdev->name, qp->qpn, strerror ( rc ) );
goto err_mcast_attach;
}
membership->attached = 1;
/* Initiate multicast membership join */
ib_mcast_mad ( ibdev, gid, 1, &mad );
@ -182,6 +184,7 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
ib_destroy_madx ( ibdev, ibdev->gsi, membership->madx );
err_create_madx:
ib_mcast_detach ( ibdev, qp, gid );
membership->attached = 0;
err_mcast_attach:
return rc;
}
@ -199,6 +202,10 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
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 ( gid ) );
@ -207,6 +214,7 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
/* Detach from multicast GID */
ib_mcast_detach ( ibdev, qp, &membership->gid );
membership->attached = 0;
/* Cancel multicast membership join, if applicable */
if ( membership->madx ) {