|
@@ -81,14 +81,48 @@ static unsigned int next_request_tid;
|
81
|
81
|
*****************************************************************************
|
82
|
82
|
*/
|
83
|
83
|
|
|
84
|
+/**
|
|
85
|
+ * Construct directed route response, if necessary
|
|
86
|
+ *
|
|
87
|
+ * @v gma General management agent
|
|
88
|
+ * @v mad MAD response without DR fields filled in
|
|
89
|
+ * @ret mad MAD response with DR fields filled in
|
|
90
|
+ */
|
|
91
|
+static union ib_mad * ib_sma_dr_response ( struct ib_gma *gma,
|
|
92
|
+ union ib_mad *mad ) {
|
|
93
|
+ struct ib_mad_hdr *hdr = &mad->hdr;
|
|
94
|
+ struct ib_mad_smp *smp = &mad->smp;
|
|
95
|
+ unsigned int hop_pointer;
|
|
96
|
+ unsigned int hop_count;
|
|
97
|
+
|
|
98
|
+ /* Set response fields for directed route SMPs */
|
|
99
|
+ if ( hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) {
|
|
100
|
+ hdr->status |= htons ( IB_SMP_STATUS_D_INBOUND );
|
|
101
|
+ hop_pointer = smp->mad_hdr.class_specific.smp.hop_pointer;
|
|
102
|
+ hop_count = smp->mad_hdr.class_specific.smp.hop_count;
|
|
103
|
+ assert ( hop_count == hop_pointer );
|
|
104
|
+ if ( hop_pointer < ( sizeof ( smp->return_path.hops ) /
|
|
105
|
+ sizeof ( smp->return_path.hops[0] ) ) ) {
|
|
106
|
+ smp->return_path.hops[hop_pointer] = gma->ibdev->port;
|
|
107
|
+ } else {
|
|
108
|
+ DBGC ( gma, "GMA %p invalid hop pointer %d\n",
|
|
109
|
+ gma, hop_pointer );
|
|
110
|
+ return NULL;
|
|
111
|
+ }
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ return mad;
|
|
115
|
+}
|
|
116
|
+
|
84
|
117
|
/**
|
85
|
118
|
* Get node information
|
86
|
119
|
*
|
87
|
120
|
* @v gma General management agent
|
88
|
121
|
* @v mad MAD
|
|
122
|
+ * @ret response MAD response
|
89
|
123
|
*/
|
90
|
|
-static void ib_sma_get_node_info ( struct ib_gma *gma,
|
91
|
|
- union ib_mad *mad ) {
|
|
124
|
+static union ib_mad * ib_sma_get_node_info ( struct ib_gma *gma,
|
|
125
|
+ union ib_mad *mad ) {
|
92
|
126
|
struct ib_device *ibdev = gma->ibdev;
|
93
|
127
|
struct ib_node_info *node_info = &mad->smp.smp_data.node_info;
|
94
|
128
|
|
|
@@ -103,6 +137,9 @@ static void ib_sma_get_node_info ( struct ib_gma *gma,
|
103
|
137
|
sizeof ( node_info->port_guid ) );
|
104
|
138
|
node_info->partition_cap = htons ( 1 );
|
105
|
139
|
node_info->local_port_num = ibdev->port;
|
|
140
|
+
|
|
141
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
|
142
|
+ return ib_sma_dr_response ( gma, mad );
|
106
|
143
|
}
|
107
|
144
|
|
108
|
145
|
/**
|
|
@@ -110,9 +147,10 @@ static void ib_sma_get_node_info ( struct ib_gma *gma,
|
110
|
147
|
*
|
111
|
148
|
* @v gma General management agent
|
112
|
149
|
* @v mad MAD
|
|
150
|
+ * @ret response MAD response
|
113
|
151
|
*/
|
114
|
|
-static void ib_sma_get_node_desc ( struct ib_gma *gma,
|
115
|
|
- union ib_mad *mad ) {
|
|
152
|
+static union ib_mad * ib_sma_get_node_desc ( struct ib_gma *gma,
|
|
153
|
+ union ib_mad *mad ) {
|
116
|
154
|
struct ib_device *ibdev = gma->ibdev;
|
117
|
155
|
struct ib_node_desc *node_desc = &mad->smp.smp_data.node_desc;
|
118
|
156
|
struct ib_gid_half *guid = &ibdev->gid.u.half[1];
|
|
@@ -123,6 +161,9 @@ static void ib_sma_get_node_desc ( struct ib_gma *gma,
|
123
|
161
|
guid->bytes[0], guid->bytes[1], guid->bytes[2],
|
124
|
162
|
guid->bytes[3], guid->bytes[4], guid->bytes[5],
|
125
|
163
|
guid->bytes[6], guid->bytes[7], ibdev->dev->name );
|
|
164
|
+
|
|
165
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
|
166
|
+ return ib_sma_dr_response ( gma, mad );
|
126
|
167
|
}
|
127
|
168
|
|
128
|
169
|
/**
|
|
@@ -130,15 +171,19 @@ static void ib_sma_get_node_desc ( struct ib_gma *gma,
|
130
|
171
|
*
|
131
|
172
|
* @v gma General management agent
|
132
|
173
|
* @v mad MAD
|
|
174
|
+ * @ret response MAD response
|
133
|
175
|
*/
|
134
|
|
-static void ib_sma_get_guid_info ( struct ib_gma *gma,
|
135
|
|
- union ib_mad *mad ) {
|
|
176
|
+static union ib_mad * ib_sma_get_guid_info ( struct ib_gma *gma,
|
|
177
|
+ union ib_mad *mad ) {
|
136
|
178
|
struct ib_device *ibdev = gma->ibdev;
|
137
|
179
|
struct ib_guid_info *guid_info = &mad->smp.smp_data.guid_info;
|
138
|
180
|
|
139
|
181
|
memset ( guid_info, 0, sizeof ( *guid_info ) );
|
140
|
182
|
memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1],
|
141
|
183
|
sizeof ( guid_info->guid[0] ) );
|
|
184
|
+
|
|
185
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
|
186
|
+ return ib_sma_dr_response ( gma, mad );
|
142
|
187
|
}
|
143
|
188
|
|
144
|
189
|
/**
|
|
@@ -146,9 +191,10 @@ static void ib_sma_get_guid_info ( struct ib_gma *gma,
|
146
|
191
|
*
|
147
|
192
|
* @v gma General management agent
|
148
|
193
|
* @v mad MAD
|
|
194
|
+ * @ret response MAD response
|
149
|
195
|
*/
|
150
|
|
-static void ib_sma_get_port_info ( struct ib_gma *gma,
|
151
|
|
- union ib_mad *mad ) {
|
|
196
|
+static union ib_mad * ib_sma_get_port_info ( struct ib_gma *gma,
|
|
197
|
+ union ib_mad *mad ) {
|
152
|
198
|
struct ib_device *ibdev = gma->ibdev;
|
153
|
199
|
struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
|
154
|
200
|
|
|
@@ -174,6 +220,9 @@ static void ib_sma_get_port_info ( struct ib_gma *gma,
|
174
|
220
|
port_info->init_type_reply__mtu_cap = IB_MTU_2048;
|
175
|
221
|
port_info->operational_vls__enforcement = ( IB_VL_0 << 4 );
|
176
|
222
|
port_info->guid_cap = 1;
|
|
223
|
+
|
|
224
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
|
225
|
+ return ib_sma_dr_response ( gma, mad );
|
177
|
226
|
}
|
178
|
227
|
|
179
|
228
|
/**
|
|
@@ -181,9 +230,10 @@ static void ib_sma_get_port_info ( struct ib_gma *gma,
|
181
|
230
|
*
|
182
|
231
|
* @v gma General management agent
|
183
|
232
|
* @v mad MAD
|
|
233
|
+ * @ret response MAD response
|
184
|
234
|
*/
|
185
|
|
-static void ib_sma_set_port_info ( struct ib_gma *gma,
|
186
|
|
- union ib_mad *mad ) {
|
|
235
|
+static union ib_mad * ib_sma_set_port_info ( struct ib_gma *gma,
|
|
236
|
+ union ib_mad *mad ) {
|
187
|
237
|
struct ib_device *ibdev = gma->ibdev;
|
188
|
238
|
const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
|
189
|
239
|
int rc;
|
|
@@ -201,7 +251,7 @@ static void ib_sma_set_port_info ( struct ib_gma *gma,
|
201
|
251
|
htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
|
202
|
252
|
}
|
203
|
253
|
|
204
|
|
- ib_sma_get_port_info ( gma, mad );
|
|
254
|
+ return ib_sma_get_port_info ( gma, mad );
|
205
|
255
|
}
|
206
|
256
|
|
207
|
257
|
/**
|
|
@@ -209,14 +259,19 @@ static void ib_sma_set_port_info ( struct ib_gma *gma,
|
209
|
259
|
*
|
210
|
260
|
* @v gma General management agent
|
211
|
261
|
* @v mad MAD
|
|
262
|
+ * @ret response MAD response
|
212
|
263
|
*/
|
213
|
|
-static void ib_sma_get_pkey_table ( struct ib_gma *gma,
|
214
|
|
- union ib_mad *mad ) {
|
|
264
|
+static union ib_mad * ib_sma_get_pkey_table ( struct ib_gma *gma,
|
|
265
|
+ union ib_mad *mad ) {
|
215
|
266
|
struct ib_device *ibdev = gma->ibdev;
|
216
|
267
|
struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
|
217
|
268
|
|
|
269
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
218
|
270
|
memset ( pkey_table, 0, sizeof ( *pkey_table ) );
|
219
|
271
|
pkey_table->pkey[0] = htons ( ibdev->pkey );
|
|
272
|
+
|
|
273
|
+ mad->hdr.method = IB_MGMT_METHOD_GET_RESP;
|
|
274
|
+ return ib_sma_dr_response ( gma, mad );
|
220
|
275
|
}
|
221
|
276
|
|
222
|
277
|
/**
|
|
@@ -224,15 +279,16 @@ static void ib_sma_get_pkey_table ( struct ib_gma *gma,
|
224
|
279
|
*
|
225
|
280
|
* @v gma General management agent
|
226
|
281
|
* @v mad MAD
|
|
282
|
+ * @ret response MAD response
|
227
|
283
|
*/
|
228
|
|
-static void ib_sma_set_pkey_table ( struct ib_gma *gma,
|
229
|
|
- union ib_mad *mad ) {
|
|
284
|
+static union ib_mad * ib_sma_set_pkey_table ( struct ib_gma *gma,
|
|
285
|
+ union ib_mad *mad ) {
|
230
|
286
|
struct ib_device *ibdev = gma->ibdev;
|
231
|
287
|
struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
|
232
|
288
|
|
233
|
289
|
ibdev->pkey = ntohs ( pkey_table->pkey[0] );
|
234
|
290
|
|
235
|
|
- ib_sma_get_pkey_table ( gma, mad );
|
|
291
|
+ return ib_sma_get_pkey_table ( gma, mad );
|
236
|
292
|
}
|
237
|
293
|
|
238
|
294
|
/** List of attribute handlers */
|
|
@@ -242,7 +298,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
242
|
298
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
243
|
299
|
.class_version = IB_SMP_CLASS_VERSION,
|
244
|
300
|
.method = IB_MGMT_METHOD_GET,
|
245
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
246
|
301
|
.attr_id = htons ( IB_SMP_ATTR_NODE_INFO ),
|
247
|
302
|
.handle = ib_sma_get_node_info,
|
248
|
303
|
},
|
|
@@ -251,7 +306,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
251
|
306
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
252
|
307
|
.class_version = IB_SMP_CLASS_VERSION,
|
253
|
308
|
.method = IB_MGMT_METHOD_GET,
|
254
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
255
|
309
|
.attr_id = htons ( IB_SMP_ATTR_NODE_DESC ),
|
256
|
310
|
.handle = ib_sma_get_node_desc,
|
257
|
311
|
},
|
|
@@ -260,7 +314,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
260
|
314
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
261
|
315
|
.class_version = IB_SMP_CLASS_VERSION,
|
262
|
316
|
.method = IB_MGMT_METHOD_GET,
|
263
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
264
|
317
|
.attr_id = htons ( IB_SMP_ATTR_GUID_INFO ),
|
265
|
318
|
.handle = ib_sma_get_guid_info,
|
266
|
319
|
},
|
|
@@ -269,7 +322,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
269
|
322
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
270
|
323
|
.class_version = IB_SMP_CLASS_VERSION,
|
271
|
324
|
.method = IB_MGMT_METHOD_GET,
|
272
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
273
|
325
|
.attr_id = htons ( IB_SMP_ATTR_PORT_INFO ),
|
274
|
326
|
.handle = ib_sma_get_port_info,
|
275
|
327
|
},
|
|
@@ -278,7 +330,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
278
|
330
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
279
|
331
|
.class_version = IB_SMP_CLASS_VERSION,
|
280
|
332
|
.method = IB_MGMT_METHOD_SET,
|
281
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
282
|
333
|
.attr_id = htons ( IB_SMP_ATTR_PORT_INFO ),
|
283
|
334
|
.handle = ib_sma_set_port_info,
|
284
|
335
|
},
|
|
@@ -287,7 +338,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
287
|
338
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
288
|
339
|
.class_version = IB_SMP_CLASS_VERSION,
|
289
|
340
|
.method = IB_MGMT_METHOD_GET,
|
290
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
291
|
341
|
.attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE ),
|
292
|
342
|
.handle = ib_sma_get_pkey_table,
|
293
|
343
|
},
|
|
@@ -296,7 +346,6 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
296
|
346
|
.mgmt_class_ignore = IB_SMP_CLASS_IGNORE,
|
297
|
347
|
.class_version = IB_SMP_CLASS_VERSION,
|
298
|
348
|
.method = IB_MGMT_METHOD_SET,
|
299
|
|
- .resp_method = IB_MGMT_METHOD_GET_RESP,
|
300
|
349
|
.attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE ),
|
301
|
350
|
.handle = ib_sma_set_pkey_table,
|
302
|
351
|
},
|
|
@@ -314,8 +363,9 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
|
314
|
363
|
*
|
315
|
364
|
* @v gma General management agent
|
316
|
365
|
* @v mad MAD
|
|
366
|
+ * @ret mad MAD response
|
317
|
367
|
*/
|
318
|
|
-static void ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
|
|
368
|
+static union ib_mad * ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
|
319
|
369
|
struct ib_mad_hdr *hdr = &mad->hdr;
|
320
|
370
|
struct ib_gma_handler *handler;
|
321
|
371
|
|
|
@@ -325,14 +375,13 @@ static void ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
|
325
|
375
|
( handler->class_version == hdr->class_version ) &&
|
326
|
376
|
( handler->method == hdr->method ) &&
|
327
|
377
|
( handler->attr_id == hdr->attr_id ) ) {
|
328
|
|
- hdr->method = handler->resp_method;
|
329
|
|
- handler->handle ( gma, mad );
|
330
|
|
- return;
|
|
378
|
+ return handler->handle ( gma, mad );
|
331
|
379
|
}
|
332
|
380
|
}
|
333
|
381
|
|
334
|
382
|
hdr->method = IB_MGMT_METHOD_TRAP;
|
335
|
383
|
hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
|
|
384
|
+ return mad;
|
336
|
385
|
}
|
337
|
386
|
|
338
|
387
|
/**
|
|
@@ -353,8 +402,7 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
|
353
|
402
|
struct ib_mad_request *request;
|
354
|
403
|
union ib_mad *mad;
|
355
|
404
|
struct ib_mad_hdr *hdr;
|
356
|
|
- unsigned int hop_pointer;
|
357
|
|
- unsigned int hop_count;
|
|
405
|
+ union ib_mad *response;
|
358
|
406
|
|
359
|
407
|
/* Ignore errors */
|
360
|
408
|
if ( rc != 0 ) {
|
|
@@ -395,36 +443,17 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
|
395
|
443
|
}
|
396
|
444
|
|
397
|
445
|
/* Handle MAD */
|
398
|
|
- ib_handle_mad ( gma, mad );
|
399
|
|
-
|
400
|
|
- /* Finish processing if we have no response to send */
|
401
|
|
- if ( ! hdr->method )
|
|
446
|
+ if ( ( response = ib_handle_mad ( gma, mad ) ) == NULL )
|
402
|
447
|
goto out;
|
403
|
448
|
|
|
449
|
+ /* Re-use I/O buffer for response */
|
|
450
|
+ memcpy ( mad, response, sizeof ( *mad ) );
|
404
|
451
|
DBGC ( gma, "GMA %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
|
405
|
452
|
"%04x\n", gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
|
406
|
453
|
hdr->mgmt_class, hdr->class_version, hdr->method,
|
407
|
454
|
ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
|
408
|
455
|
DBGC2_HDA ( gma, 0, mad, sizeof ( *mad ) );
|
409
|
456
|
|
410
|
|
- /* Set response fields for directed route SMPs */
|
411
|
|
- if ( hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) {
|
412
|
|
- struct ib_mad_smp *smp = &mad->smp;
|
413
|
|
-
|
414
|
|
- hdr->status |= htons ( IB_SMP_STATUS_D_INBOUND );
|
415
|
|
- hop_pointer = smp->mad_hdr.class_specific.smp.hop_pointer;
|
416
|
|
- hop_count = smp->mad_hdr.class_specific.smp.hop_count;
|
417
|
|
- assert ( hop_count == hop_pointer );
|
418
|
|
- if ( hop_pointer < ( sizeof ( smp->return_path.hops ) /
|
419
|
|
- sizeof ( smp->return_path.hops[0] ) ) ) {
|
420
|
|
- smp->return_path.hops[hop_pointer] = ibdev->port;
|
421
|
|
- } else {
|
422
|
|
- DBGC ( gma, "GMA %p invalid hop pointer %d\n",
|
423
|
|
- gma, hop_pointer );
|
424
|
|
- goto out;
|
425
|
|
- }
|
426
|
|
- }
|
427
|
|
-
|
428
|
457
|
/* Send MAD response, if applicable */
|
429
|
458
|
if ( ( rc = ib_post_send ( ibdev, qp, av,
|
430
|
459
|
iob_disown ( iobuf ) ) ) != 0 ) {
|