Просмотр исходного кода

[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 лет назад
Родитель
Сommit
c335f8eae4
3 измененных файлов: 16 добавлений и 18 удалений
  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 Просмотреть файл

@@ -89,14 +89,8 @@ struct ipoib_device {
89 89
 	struct ipoib_mac mac;
90 90
 	/** Broadcast MAC */
91 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 92
 	/** IPv4 broadcast multicast group membership */
99
-	struct ib_mc_membership broadcast_membership;
93
+	struct ib_mc_membership membership;
100 94
 	/** REMAC cache */
101 95
 	struct list_head peers;
102 96
 };
@@ -742,8 +736,8 @@ void ipoib_join_complete ( struct ib_device *ibdev __unused,
742 736
 			   struct ib_queue_pair *qp __unused,
743 737
 			   struct ib_mc_membership *membership, int rc,
744 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 742
 	/* Record join status as link status */
749 743
 	netdev_link_err ( ipoib->netdev, rc );
@@ -759,14 +753,12 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
759 753
 	int rc;
760 754
 
761 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 757
 				    ipoib_join_complete ) ) != 0 ) {
765 758
 		DBGC ( ipoib, "IPoIB %p could not join broadcast group: %s\n",
766 759
 		       ipoib, strerror ( rc ) );
767 760
 		return rc;
768 761
 	}
769
-	ipoib->broadcast_joined = 1;
770 762
 
771 763
 	return 0;
772 764
 }
@@ -778,11 +770,7 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
778 770
  */
779 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 Просмотреть файл

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

+ 9
- 1
src/net/infiniband/ib_mcast.c Просмотреть файл

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

Загрузка…
Отмена
Сохранить