]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[infiniband] Record multicast GID attachment as part of group membership
authorMichael Brown <mcb30@ipxe.org>
Sat, 5 Mar 2016 15:33:28 +0000 (15:33 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 Mar 2016 12:23:30 +0000 (12:23 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/ipoib.c
src/include/ipxe/ib_mcast.h
src/net/infiniband/ib_mcast.c

index e54f8df401570fe21429281254791fd1fa1aaf7e..8165f96e0c7c9439c60b31ebd4e36350d08dafb1 100644 (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 );
 }
 
 /**
index 56406697590645d2b8681c28a9910e9afce58899..202f8e297271322915e578b4f6cd00aa9a810c10 100644 (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
index b7a6e8ce820cbfcd1c71723050d6cc1d3c50c4c8..3a055908119d7a3505387a78ca4ba0aee5e11a1a 100644 (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 ) {