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
 	struct ib_smp_class_specific smp;
525
 	struct ib_smp_class_specific smp;
526
 } __attribute__ (( packed ));
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
 /** A management datagram common header
534
 /** A management datagram common header
529
  *
535
  *
530
  * Defined in section 13.4.2 of the IBA.
536
  * Defined in section 13.4.2 of the IBA.
536
 	uint8_t method;
542
 	uint8_t method;
537
 	uint16_t status;
543
 	uint16_t status;
538
 	union ib_mad_class_specific class_specific;
544
 	union ib_mad_class_specific class_specific;
539
-	uint32_t tid[2];
545
+	struct ib_mad_tid tid;
540
 	uint16_t attr_id;
546
 	uint16_t attr_id;
541
 	uint8_t reserved[2];
547
 	uint8_t reserved[2];
542
 	uint32_t attr_mod;
548
 	uint32_t attr_mod;

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

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

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

106
 
106
 
107
 	/* Otherwise, ignore it */
107
 	/* Otherwise, ignore it */
108
 	DBGC ( mi, "MI %p RX TID %08x%08x ignored\n",
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
 	return -ENOTSUP;
110
 	return -ENOTSUP;
111
 }
111
 }
112
 
112
 
152
 		goto out;
152
 		goto out;
153
 	}
153
 	}
154
 	DBGC ( mi, "MI %p RX TID %08x%08x (%02x,%02x,%02x,%04x) status "
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
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
156
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
157
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
157
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
158
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
158
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
192
 
192
 
193
 	/* Set common fields */
193
 	/* Set common fields */
194
 	hdr->base_version = IB_MGMT_BASE_VERSION;
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
 	DBGC ( mi, "MI %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
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
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
201
 	       hdr->mgmt_class, hdr->class_version, hdr->method,
202
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
202
 	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
203
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
203
 	DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
217
 			smp->return_path.hops[hop_pointer] = ibdev->port;
217
 			smp->return_path.hops[hop_pointer] = ibdev->port;
218
 		} else {
218
 		} else {
219
 			DBGC ( mi, "MI %p TX TID %08x%08x invalid hop pointer "
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
 			return -EINVAL;
222
 			return -EINVAL;
223
 		}
223
 		}
224
 	}
224
 	}
228
 	if ( ! iobuf ) {
228
 	if ( ! iobuf ) {
229
 		DBGC ( mi, "MI %p could not allocate buffer for TID "
229
 		DBGC ( mi, "MI %p could not allocate buffer for TID "
230
 		       "%08x%08x\n",
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
 		return -ENOMEM;
232
 		return -ENOMEM;
233
 	}
233
 	}
234
 	memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
234
 	memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
236
 	/* Send I/O buffer */
236
 	/* Send I/O buffer */
237
 	if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
237
 	if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
238
 		DBGC ( mi, "MI %p TX TID %08x%08x failed: %s\n",
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
 		       strerror ( rc ) );
240
 		       strerror ( rc ) );
241
 		free_iob ( iobuf );
241
 		free_iob ( iobuf );
242
 		return rc;
242
 		return rc;
261
 	/* Abandon transaction if we have tried too many times */
261
 	/* Abandon transaction if we have tried too many times */
262
 	if ( expired ) {
262
 	if ( expired ) {
263
 		DBGC ( mi, "MI %p abandoning TID %08x%08x\n",
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
 		madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
265
 		madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
266
 		return;
266
 		return;
267
 	}
267
 	}
408
 	/* Flush any outstanding requests */
408
 	/* Flush any outstanding requests */
409
 	list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
409
 	list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
410
 		DBGC ( mi, "MI %p destroyed while TID %08x%08x in progress\n",
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
 		madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
413
 		madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
414
 	}
414
 	}
415
 
415
 

Loading…
Cancel
Save