Browse Source

[infiniband] Use correct transaction identifier in CM responses

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
bd1687465c
3 changed files with 31 additions and 17 deletions
  1. 7
    1
      src/include/ipxe/ib_mad.h
  2. 11
    3
      src/net/infiniband/ib_cm.c
  3. 13
    13
      src/net/infiniband/ib_mi.c

+ 7
- 1
src/include/ipxe/ib_mad.h View File

@@ -525,6 +525,12 @@ union ib_mad_class_specific {
525 525
 	struct ib_smp_class_specific smp;
526 526
 } __attribute__ (( packed ));
527 527
 
528
+/** A management datagram transaction identifier */
529
+struct ib_mad_tid {
530
+	uint32_t high;
531
+	uint32_t low;
532
+} __attribute__ (( packed ));
533
+
528 534
 /** A management datagram common header
529 535
  *
530 536
  * Defined in section 13.4.2 of the IBA.
@@ -536,7 +542,7 @@ struct ib_mad_hdr {
536 542
 	uint8_t method;
537 543
 	uint16_t status;
538 544
 	union ib_mad_class_specific class_specific;
539
-	uint32_t tid[2];
545
+	struct ib_mad_tid tid;
540 546
 	uint16_t attr_id;
541 547
 	uint8_t reserved[2];
542 548
 	uint32_t attr_mod;

+ 11
- 3
src/net/infiniband/ib_cm.c View File

@@ -65,6 +65,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
65 65
  *
66 66
  * @v ibdev		Infiniband device
67 67
  * @v mi		Management interface
68
+ * @v tid		Transaction identifier
68 69
  * @v av		Address vector
69 70
  * @v local_id		Local communication ID
70 71
  * @v remote_id		Remote communication ID
@@ -72,6 +73,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
72 73
  */
73 74
 static int ib_cm_send_rtu ( struct ib_device *ibdev,
74 75
 			    struct ib_mad_interface *mi,
76
+			    struct ib_mad_tid *tid,
75 77
 			    struct ib_address_vector *av,
76 78
 			    uint32_t local_id, uint32_t remote_id ) {
77 79
 	union ib_mad mad;
@@ -83,6 +85,7 @@ static int ib_cm_send_rtu ( struct ib_device *ibdev,
83 85
 	mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
84 86
 	mad.hdr.class_version = IB_CM_CLASS_VERSION;
85 87
 	mad.hdr.method = IB_MGMT_METHOD_SEND;
88
+	memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
86 89
 	mad.hdr.attr_id = htons ( IB_CM_ATTR_READY_TO_USE );
87 90
 	rtu->local_id = htonl ( local_id );
88 91
 	rtu->remote_id = htonl ( remote_id );
@@ -121,7 +124,8 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
121 124
 	conn = ib_cm_find ( local_id );
122 125
 	if ( conn ) {
123 126
 		/* Try to send "ready to use" reply */
124
-		if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
127
+		if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
128
+					     conn->local_id,
125 129
 					     conn->remote_id ) ) != 0 ) {
126 130
 			/* Ignore errors; the remote end will retry */
127 131
 		}
@@ -135,6 +139,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
135 139
  *
136 140
  * @v ibdev		Infiniband device
137 141
  * @v mi		Management interface
142
+ * @v tid		Transaction identifier
138 143
  * @v av		Address vector
139 144
  * @v local_id		Local communication ID
140 145
  * @v remote_id		Remote communication ID
@@ -142,6 +147,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
142 147
  */
143 148
 static int ib_cm_send_drep ( struct ib_device *ibdev,
144 149
 			     struct ib_mad_interface *mi,
150
+			     struct ib_mad_tid *tid,
145 151
 			     struct ib_address_vector *av,
146 152
 			     uint32_t local_id, uint32_t remote_id ) {
147 153
 	union ib_mad mad;
@@ -153,6 +159,7 @@ static int ib_cm_send_drep ( struct ib_device *ibdev,
153 159
 	mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
154 160
 	mad.hdr.class_version = IB_CM_CLASS_VERSION;
155 161
 	mad.hdr.method = IB_MGMT_METHOD_SEND;
162
+	memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
156 163
 	mad.hdr.attr_id = htons ( IB_CM_ATTR_DISCONNECT_REPLY );
157 164
 	drep->local_id = htonl ( local_id );
158 165
 	drep->remote_id = htonl ( remote_id );
@@ -197,7 +204,7 @@ static void ib_cm_recv_dreq ( struct ib_device *ibdev,
197 204
 	}
198 205
 
199 206
 	/* Send reply */
200
-	if ( ( rc = ib_cm_send_drep ( ibdev, mi, av, local_id,
207
+	if ( ( rc = ib_cm_send_drep ( ibdev, mi, &mad->hdr.tid, av, local_id,
201 208
 				      remote_id ) ) != 0 ) {
202 209
 		/* Ignore errors; the remote end will retry */
203 210
 	}
@@ -294,7 +301,8 @@ static void ib_cm_req_complete ( struct ib_device *ibdev,
294 301
 		}
295 302
 
296 303
 		/* Send "ready to use" reply */
297
-		if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
304
+		if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
305
+					     conn->local_id,
298 306
 					     conn->remote_id ) ) != 0 ) {
299 307
 			/* Treat as non-fatal */
300 308
 			rc = 0;

+ 13
- 13
src/net/infiniband/ib_mi.c View File

@@ -106,7 +106,7 @@ static int ib_mi_handle ( struct ib_device *ibdev,
106 106
 
107 107
 	/* Otherwise, ignore it */
108 108
 	DBGC ( mi, "MI %p RX TID %08x%08x ignored\n",
109
-	       mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
109
+	       mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
110 110
 	return -ENOTSUP;
111 111
 }
112 112
 
@@ -152,7 +152,7 @@ static void ib_mi_complete_recv ( struct ib_device *ibdev,
152 152
 		goto out;
153 153
 	}
154 154
 	DBGC ( mi, "MI %p RX TID %08x%08x (%02x,%02x,%02x,%04x) status "
155
-	       "%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
155
+	       "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
156 156
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
157 157
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
158 158
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@@ -192,12 +192,12 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
192 192
 
193 193
 	/* Set common fields */
194 194
 	hdr->base_version = IB_MGMT_BASE_VERSION;
195
-	if ( ( hdr->tid[0] == 0 ) && ( hdr->tid[1] == 0 ) ) {
196
-		hdr->tid[0] = htonl ( IB_MI_TID_MAGIC );
197
-		hdr->tid[1] = htonl ( ++next_tid );
195
+	if ( ( hdr->tid.high == 0 ) && ( hdr->tid.low == 0 ) ) {
196
+		hdr->tid.high = htonl ( IB_MI_TID_MAGIC );
197
+		hdr->tid.low = htonl ( ++next_tid );
198 198
 	}
199 199
 	DBGC ( mi, "MI %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
200
-	       "%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
200
+	       "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
201 201
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
202 202
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
203 203
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@@ -217,8 +217,8 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
217 217
 			smp->return_path.hops[hop_pointer] = ibdev->port;
218 218
 		} else {
219 219
 			DBGC ( mi, "MI %p TX TID %08x%08x invalid hop pointer "
220
-			       "%d\n", mi, ntohl ( hdr->tid[0] ),
221
-			       ntohl ( hdr->tid[1] ), hop_pointer );
220
+			       "%d\n", mi, ntohl ( hdr->tid.high ),
221
+			       ntohl ( hdr->tid.low ), hop_pointer );
222 222
 			return -EINVAL;
223 223
 		}
224 224
 	}
@@ -228,7 +228,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
228 228
 	if ( ! iobuf ) {
229 229
 		DBGC ( mi, "MI %p could not allocate buffer for TID "
230 230
 		       "%08x%08x\n",
231
-		       mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
231
+		       mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
232 232
 		return -ENOMEM;
233 233
 	}
234 234
 	memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
@@ -236,7 +236,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
236 236
 	/* Send I/O buffer */
237 237
 	if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
238 238
 		DBGC ( mi, "MI %p TX TID %08x%08x failed: %s\n",
239
-		       mi,  ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
239
+		       mi,  ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
240 240
 		       strerror ( rc ) );
241 241
 		free_iob ( iobuf );
242 242
 		return rc;
@@ -261,7 +261,7 @@ static void ib_mi_timer_expired ( struct retry_timer *timer, int expired ) {
261 261
 	/* Abandon transaction if we have tried too many times */
262 262
 	if ( expired ) {
263 263
 		DBGC ( mi, "MI %p abandoning TID %08x%08x\n",
264
-		       mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
264
+		       mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
265 265
 		madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
266 266
 		return;
267 267
 	}
@@ -408,8 +408,8 @@ void ib_destroy_mi ( struct ib_device *ibdev, struct ib_mad_interface *mi ) {
408 408
 	/* Flush any outstanding requests */
409 409
 	list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
410 410
 		DBGC ( mi, "MI %p destroyed while TID %08x%08x in progress\n",
411
-		       mi, ntohl ( madx->mad.hdr.tid[0] ),
412
-		       ntohl ( madx->mad.hdr.tid[1] ) );
411
+		       mi, ntohl ( madx->mad.hdr.tid.high ),
412
+		       ntohl ( madx->mad.hdr.tid.low ) );
413 413
 		madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
414 414
 	}
415 415
 

Loading…
Cancel
Save