Browse Source

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
c335f8eae4
3 changed files with 16 additions and 18 deletions
  1. 5
    17
      src/drivers/net/ipoib.c
  2. 2
    0
      src/include/ipxe/ib_mcast.h
  3. 9
    1
      src/net/infiniband/ib_mcast.c

+ 5
- 17
src/drivers/net/ipoib.c View File

89
 	struct ipoib_mac mac;
89
 	struct ipoib_mac mac;
90
 	/** Broadcast MAC */
90
 	/** Broadcast MAC */
91
 	struct ipoib_mac broadcast;
91
 	struct ipoib_mac broadcast;
92
-	/** Joined to IPv4 broadcast multicast group
93
-	 *
94
-	 * This flag indicates whether or not we have initiated the
95
-	 * join to the IPv4 broadcast multicast group.
96
-	 */
97
-	int broadcast_joined;
98
 	/** IPv4 broadcast multicast group membership */
92
 	/** IPv4 broadcast multicast group membership */
99
-	struct ib_mc_membership broadcast_membership;
93
+	struct ib_mc_membership membership;
100
 	/** REMAC cache */
94
 	/** REMAC cache */
101
 	struct list_head peers;
95
 	struct list_head peers;
102
 };
96
 };
742
 			   struct ib_queue_pair *qp __unused,
736
 			   struct ib_queue_pair *qp __unused,
743
 			   struct ib_mc_membership *membership, int rc,
737
 			   struct ib_mc_membership *membership, int rc,
744
 			   union ib_mad *mad __unused ) {
738
 			   union ib_mad *mad __unused ) {
745
-	struct ipoib_device *ipoib = container_of ( membership,
746
-				   struct ipoib_device, broadcast_membership );
739
+	struct ipoib_device *ipoib =
740
+		container_of ( membership, struct ipoib_device, membership );
747
 
741
 
748
 	/* Record join status as link status */
742
 	/* Record join status as link status */
749
 	netdev_link_err ( ipoib->netdev, rc );
743
 	netdev_link_err ( ipoib->netdev, rc );
759
 	int rc;
753
 	int rc;
760
 
754
 
761
 	if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qp,
755
 	if ( ( rc = ib_mcast_join ( ipoib->ibdev, ipoib->qp,
762
-				    &ipoib->broadcast_membership,
763
-				    &ipoib->broadcast.gid,
756
+				    &ipoib->membership, &ipoib->broadcast.gid,
764
 				    ipoib_join_complete ) ) != 0 ) {
757
 				    ipoib_join_complete ) ) != 0 ) {
765
 		DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
758
 		DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
766
 		       ipoib, strerror ( rc ) );
759
 		       ipoib, strerror ( rc ) );
767
 		return rc;
760
 		return rc;
768
 	}
761
 	}
769
-	ipoib->broadcast_joined = 1;
770
 
762
 
771
 	return 0;
763
 	return 0;
772
 }
764
 }
778
  */
770
  */
779
 static void ipoib_leave_broadcast_group ( struct ipoib_device *ipoib ) {
771
 static void ipoib_leave_broadcast_group ( struct ipoib_device *ipoib ) {
780
 
772
 
781
-	if ( ipoib->broadcast_joined ) {
782
-		ib_mcast_leave ( ipoib->ibdev, ipoib->qp,
783
-				 &ipoib->broadcast_membership );
784
-		ipoib->broadcast_joined = 0;
785
-	}
773
+	ib_mcast_leave ( ipoib->ibdev, ipoib->qp, &ipoib->membership );
786
 }
774
 }
787
 
775
 
788
 /**
776
 /**

+ 2
- 0
src/include/ipxe/ib_mcast.h View File

19
 	struct ib_queue_pair *qp;
19
 	struct ib_queue_pair *qp;
20
 	/** Multicast GID */
20
 	/** Multicast GID */
21
 	union ib_gid gid;
21
 	union ib_gid gid;
22
+	/** Attached to multicast GID */
23
+	int attached;
22
 	/** Multicast group join transaction */
24
 	/** Multicast group join transaction */
23
 	struct ib_mad_transaction *madx;
25
 	struct ib_mad_transaction *madx;
24
 	/** Handle join success/failure
26
 	/** Handle join success/failure

+ 9
- 1
src/net/infiniband/ib_mcast.c View File

150
 	DBGC ( ibdev, "IBDEV %s QPN %#lx joining " IB_GID_FMT "\n",
150
 	DBGC ( ibdev, "IBDEV %s QPN %#lx joining " IB_GID_FMT "\n",
151
 	       ibdev->name, qp->qpn, IB_GID_ARGS ( gid ) );
151
 	       ibdev->name, qp->qpn, IB_GID_ARGS ( gid ) );
152
 
152
 
153
-	/* Sanity check */
153
+	/* Sanity checks */
154
 	assert ( qp != NULL );
154
 	assert ( qp != NULL );
155
+	assert ( ! membership->attached );
155
 
156
 
156
 	/* Initialise structure */
157
 	/* Initialise structure */
157
 	membership->qp = qp;
158
 	membership->qp = qp;
164
 		       ibdev->name, qp->qpn, strerror ( rc ) );
165
 		       ibdev->name, qp->qpn, strerror ( rc ) );
165
 		goto err_mcast_attach;
166
 		goto err_mcast_attach;
166
 	}
167
 	}
168
+	membership->attached = 1;
167
 
169
 
168
 	/* Initiate multicast membership join */
170
 	/* Initiate multicast membership join */
169
 	ib_mcast_mad ( ibdev, gid, 1, &mad );
171
 	ib_mcast_mad ( ibdev, gid, 1, &mad );
182
 	ib_destroy_madx ( ibdev, ibdev->gsi, membership->madx );
184
 	ib_destroy_madx ( ibdev, ibdev->gsi, membership->madx );
183
  err_create_madx:
185
  err_create_madx:
184
 	ib_mcast_detach ( ibdev, qp, gid );
186
 	ib_mcast_detach ( ibdev, qp, gid );
187
+	membership->attached = 0;
185
  err_mcast_attach:
188
  err_mcast_attach:
186
 	return rc;
189
 	return rc;
187
 }
190
 }
199
 	union ib_mad mad;
202
 	union ib_mad mad;
200
 	int rc;
203
 	int rc;
201
 
204
 
205
+	/* Do nothing if we are already detached from the multicast GID */
206
+	if ( ! membership->attached )
207
+		return;
208
+
202
 	DBGC ( ibdev, "IBDEV %s QPN %#lx leaving " IB_GID_FMT "\n",
209
 	DBGC ( ibdev, "IBDEV %s QPN %#lx leaving " IB_GID_FMT "\n",
203
 	       ibdev->name, qp->qpn, IB_GID_ARGS ( gid ) );
210
 	       ibdev->name, qp->qpn, IB_GID_ARGS ( gid ) );
204
 
211
 
207
 
214
 
208
 	/* Detach from multicast GID */
215
 	/* Detach from multicast GID */
209
 	ib_mcast_detach ( ibdev, qp, &membership->gid );
216
 	ib_mcast_detach ( ibdev, qp, &membership->gid );
217
+	membership->attached = 0;
210
 
218
 
211
 	/* Cancel multicast membership join, if applicable */
219
 	/* Cancel multicast membership join, if applicable */
212
 	if ( membership->madx ) {
220
 	if ( membership->madx ) {

Loading…
Cancel
Save