Przeglądaj źródła

[infiniband] Add a standalone subnet management agent

This generic SMA code can be used for any cards that do not provide
firmware-based embedded SMAs.
tags/v0.9.6
Michael Brown 16 lat temu
rodzic
commit
c0ec00f47f

+ 541
- 0
src/drivers/infiniband/ib_sma.c Wyświetl plik

@@ -0,0 +1,541 @@
1
+/*
2
+ * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <stdint.h>
20
+#include <stdlib.h>
21
+#include <string.h>
22
+#include <errno.h>
23
+#include <stdio.h>
24
+#include <unistd.h>
25
+#include <byteswap.h>
26
+#include <gpxe/infiniband.h>
27
+#include <gpxe/iobuf.h>
28
+#include <gpxe/process.h>
29
+#include <gpxe/ib_sma.h>
30
+
31
+/**
32
+ * @file
33
+ *
34
+ * Infiniband Subnet Management Agent
35
+ *
36
+ */
37
+
38
+/**
39
+ * Get node information
40
+ *
41
+ * @v sma		Subnet management agent
42
+ * @v get		Attribute to get
43
+ */
44
+static void ib_sma_get_node_info ( struct ib_sma *sma,
45
+				   union ib_smp_data *get ) {
46
+	struct ib_device *ibdev = sma->ibdev;
47
+	struct ib_node_info *node_info = &get->node_info;
48
+	struct ib_device *tmp;
49
+
50
+	memset ( node_info, 0, sizeof ( *node_info ) );
51
+	node_info->base_version = IB_MGMT_BASE_VERSION;
52
+	node_info->class_version = IB_SMP_CLASS_VERSION;
53
+	node_info->node_type = IB_NODE_TYPE_HCA;
54
+	/* Search for IB devices with the same physical device to
55
+	 * identify port count and a suitable Node GUID.
56
+	 */
57
+	for_each_ibdev ( tmp ) {
58
+		if ( tmp->dev != ibdev->dev )
59
+			continue;
60
+		if ( node_info->num_ports == 0 ) {
61
+			memcpy ( node_info->sys_guid, &tmp->gid.u.half[1],
62
+				 sizeof ( node_info->sys_guid ) );
63
+			memcpy ( node_info->node_guid, &tmp->gid.u.half[1],
64
+				 sizeof ( node_info->node_guid ) );
65
+		}
66
+		node_info->num_ports++;
67
+	}
68
+	memcpy ( node_info->port_guid, &ibdev->gid.u.half[1],
69
+		 sizeof ( node_info->port_guid ) );
70
+	node_info->partition_cap = htons ( 1 );
71
+	node_info->local_port_num = ibdev->port;
72
+}
73
+
74
+/**
75
+ * Get node description
76
+ *
77
+ * @v sma		Subnet management agent
78
+ * @v get		Attribute to get
79
+ */
80
+static void ib_sma_get_node_desc ( struct ib_sma *sma,
81
+				   union ib_smp_data *get ) {
82
+	struct ib_device *ibdev = sma->ibdev;
83
+	struct ib_node_desc *node_desc = &get->node_desc;
84
+	struct ib_gid_half *guid = &ibdev->gid.u.half[1];
85
+
86
+	memset ( node_desc, 0, sizeof ( *node_desc ) );
87
+	snprintf ( node_desc->node_string, sizeof ( node_desc->node_string ),
88
+		   "gPXE %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x (%s)",
89
+		   guid->bytes[0], guid->bytes[1], guid->bytes[2],
90
+		   guid->bytes[3], guid->bytes[4], guid->bytes[5],
91
+		   guid->bytes[6], guid->bytes[7], ibdev->dev->name );
92
+}
93
+
94
+/**
95
+ * Get GUID information
96
+ *
97
+ * @v sma		Subnet management agent
98
+ * @v get		Attribute to get
99
+ */
100
+static void ib_sma_get_guid_info ( struct ib_sma *sma,
101
+				   union ib_smp_data *get ) {
102
+	struct ib_device *ibdev = sma->ibdev;
103
+	struct ib_guid_info *guid_info = &get->guid_info;
104
+
105
+	memset ( guid_info, 0, sizeof ( *guid_info ) );
106
+	memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1],
107
+		 sizeof ( guid_info->guid[0] ) );
108
+}
109
+
110
+/**
111
+ * Get port information
112
+ *
113
+ * @v sma		Subnet management agent
114
+ * @v get		Attribute to get
115
+ */
116
+static void ib_sma_get_port_info ( struct ib_sma *sma,
117
+				   union ib_smp_data *get ) {
118
+	struct ib_device *ibdev = sma->ibdev;
119
+	struct ib_port_info *port_info = &get->port_info;
120
+
121
+	memset ( port_info, 0, sizeof ( *port_info ) );
122
+	memcpy ( port_info->gid_prefix, &ibdev->gid.u.half[0],
123
+		 sizeof ( port_info->gid_prefix ) );
124
+	port_info->lid = ntohs ( ibdev->lid );
125
+	port_info->mastersm_lid = ntohs ( ibdev->sm_lid );
126
+	port_info->local_port_num = ibdev->port;
127
+	port_info->link_width_enabled = ibdev->link_width;
128
+	port_info->link_width_supported = ibdev->link_width;
129
+	port_info->link_width_active = ibdev->link_width;
130
+	port_info->link_speed_supported__port_state =
131
+		( ( ibdev->link_speed << 4 ) | ibdev->port_state );
132
+	port_info->port_phys_state__link_down_def_state =
133
+		( ( IB_PORT_PHYS_STATE_POLLING << 4 ) |
134
+		  IB_PORT_PHYS_STATE_POLLING );
135
+	port_info->link_speed_active__link_speed_enabled =
136
+		( ( ibdev->link_speed << 4 ) | ibdev->link_speed );
137
+	port_info->neighbour_mtu__mastersm_sl =
138
+		( ( IB_MTU_2048 << 4 ) | ibdev->sm_sl );
139
+	port_info->vl_cap__init_type = ( IB_VL_0 << 4 );
140
+	port_info->init_type_reply__mtu_cap = IB_MTU_2048;
141
+	port_info->operational_vls__enforcement = ( IB_VL_0 << 4 );
142
+	port_info->guid_cap = 1;
143
+}
144
+
145
+/**
146
+ * Set port information
147
+ *
148
+ * @v sma		Subnet management agent
149
+ * @v set		Attribute to set
150
+ * @ret rc		Return status code
151
+ */
152
+static int ib_sma_set_port_info ( struct ib_sma *sma,
153
+				  const union ib_smp_data *set ) {
154
+	struct ib_device *ibdev = sma->ibdev;
155
+	const struct ib_port_info *port_info = &set->port_info;
156
+
157
+	memcpy ( &ibdev->gid.u.half[0], port_info->gid_prefix,
158
+		 sizeof ( ibdev->gid.u.half[0] ) );
159
+	ibdev->lid = ntohs ( port_info->lid );
160
+	ibdev->sm_lid = ntohs ( port_info->mastersm_lid );
161
+	ibdev->sm_sl = ( port_info->neighbour_mtu__mastersm_sl & 0xf );
162
+
163
+	if ( ! sma->op->set_port_info ) {
164
+		/* Not an error; we just ignore all other settings */
165
+		return 0;
166
+	}
167
+
168
+	return sma->op->set_port_info ( ibdev, port_info );
169
+}
170
+
171
+/**
172
+ * Get partition key table
173
+ *
174
+ * @v sma		Subnet management agent
175
+ * @v get		Attribute to get
176
+ */
177
+static void ib_sma_get_pkey_table ( struct ib_sma *sma,
178
+				    union ib_smp_data *get ) {
179
+	struct ib_device *ibdev = sma->ibdev;
180
+	struct ib_pkey_table *pkey_table = &get->pkey_table;
181
+
182
+	memset ( pkey_table, 0, sizeof ( *pkey_table ) );
183
+	pkey_table->pkey[0] = htons ( ibdev->pkey );
184
+}
185
+
186
+/**
187
+ * Set partition key table
188
+ *
189
+ * @v sma		Subnet management agent
190
+ * @v set		Attribute to set
191
+ */
192
+static int ib_sma_set_pkey_table ( struct ib_sma *sma,
193
+				   const union ib_smp_data *get ) {
194
+	struct ib_device *ibdev = sma->ibdev;
195
+	const struct ib_pkey_table *pkey_table = &get->pkey_table;
196
+
197
+	ibdev->pkey = ntohs ( pkey_table->pkey[0] );
198
+	return 0;
199
+}
200
+
201
+/** An attribute handler */
202
+struct ib_sma_handler {
203
+	/** Attribute (in network byte order) */
204
+	uint16_t attr_id;
205
+	/** Get attribute
206
+	 *
207
+	 * @v sma	Subnet management agent
208
+	 * @v get	Attribute to get
209
+	 * @ret rc	Return status code
210
+	 */
211
+	void ( * get ) ( struct ib_sma *sma, union ib_smp_data *get );
212
+	/** Set attribute
213
+	 *
214
+	 * @v sma	Subnet management agent
215
+	 * @v set	Attribute to set
216
+	 * @ret rc	Return status code
217
+	 */
218
+	int ( * set ) ( struct ib_sma *sma, const union ib_smp_data *set );
219
+};
220
+
221
+/** List of attribute handlers */
222
+static struct ib_sma_handler ib_sma_handlers[] = {
223
+	{ htons ( IB_SMP_ATTR_NODE_DESC ),
224
+	  ib_sma_get_node_desc, NULL },
225
+	{ htons ( IB_SMP_ATTR_NODE_INFO ),
226
+	  ib_sma_get_node_info, NULL },
227
+	{ htons ( IB_SMP_ATTR_GUID_INFO ),
228
+	  ib_sma_get_guid_info, NULL },
229
+	{ htons ( IB_SMP_ATTR_PORT_INFO ),
230
+	  ib_sma_get_port_info, ib_sma_set_port_info },
231
+	{ htons ( IB_SMP_ATTR_PKEY_TABLE ),
232
+	  ib_sma_get_pkey_table, ib_sma_set_pkey_table },
233
+};
234
+
235
+/**
236
+ * Identify attribute handler
237
+ *
238
+ * @v attr_id		Attribute ID (in network byte order)
239
+ * @ret handler		Attribute handler (or NULL)
240
+ */
241
+static struct ib_sma_handler * ib_sma_handler ( uint16_t attr_id ) {
242
+	struct ib_sma_handler *handler;
243
+	unsigned int i;
244
+
245
+	for ( i = 0 ; i < ( sizeof ( ib_sma_handlers ) /
246
+			    sizeof ( ib_sma_handlers[0] ) ) ; i++ ) {
247
+		handler = &ib_sma_handlers[i];
248
+		if ( handler->attr_id == attr_id )
249
+			return handler;
250
+	}
251
+
252
+	return NULL;
253
+}
254
+
255
+/**
256
+ * Respond to management datagram
257
+ *
258
+ * @v sma		Subnet management agent
259
+ * @v mad		Management datagram
260
+ * @ret rc		Return status code
261
+ */
262
+static int ib_sma_mad ( struct ib_sma *sma, union ib_mad *mad ) {
263
+	struct ib_device *ibdev = sma->ibdev;
264
+	struct ib_mad_hdr *hdr = &mad->hdr;
265
+	struct ib_mad_smp *smp = &mad->smp;
266
+	struct ib_sma_handler *handler = NULL;
267
+	int rc;
268
+
269
+	DBGC ( sma, "SMA %p received SMP with bv=%02x mc=%02x cv=%02x "
270
+	       "meth=%02x attr=%04x mod=%08lx\n", sma, hdr->base_version,
271
+	       hdr->mgmt_class, hdr->class_version, hdr->method,
272
+	       ntohs ( hdr->attr_id ), ntohl ( hdr->attr_mod ) );
273
+	DBGC2_HDA ( sma, 0, mad, sizeof ( *mad ) );
274
+
275
+	/* Sanity checks */
276
+	if ( hdr->base_version != IB_MGMT_BASE_VERSION ) {
277
+		DBGC ( sma, "SMA %p unsupported base version %x\n",
278
+		       sma, hdr->base_version );
279
+		return -ENOTSUP;
280
+	}
281
+	if ( ( hdr->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) &&
282
+	     ( hdr->mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED ) ) {
283
+		DBGC ( sma, "SMA %p unsupported management class %x\n",
284
+		       sma, hdr->mgmt_class );
285
+		return -ENOTSUP;
286
+	}
287
+	if ( hdr->class_version != IB_SMP_CLASS_VERSION ) {
288
+		DBGC ( sma, "SMA %p unsupported class version %x\n",
289
+		       sma, hdr->class_version );
290
+		return -ENOTSUP;
291
+	}
292
+	if ( ( hdr->method != IB_MGMT_METHOD_GET ) &&
293
+	     ( hdr->method != IB_MGMT_METHOD_SET ) ) {
294
+		DBGC ( sma, "SMA %p unsupported method %x\n",
295
+		       sma, hdr->method );
296
+		return -ENOTSUP;
297
+	}
298
+
299
+	/* Identify handler */
300
+	if ( ! ( handler = ib_sma_handler ( hdr->attr_id ) ) ) {
301
+		DBGC ( sma, "SMA %p unsupported attribute %x\n",
302
+		       sma, ntohs ( hdr->attr_id ) );
303
+		hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
304
+		goto respond_without_data;
305
+	}
306
+
307
+	/* Set attribute (if applicable) */
308
+	if ( hdr->method != IB_MGMT_METHOD_SET ) {
309
+		hdr->status = htons ( IB_MGMT_STATUS_OK );
310
+		goto respond;
311
+	}
312
+	if ( ! handler->set ) {
313
+		DBGC ( sma, "SMA %p attribute %x is unsettable\n",
314
+		       sma, ntohs ( hdr->attr_id ) );
315
+		hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
316
+		goto respond;
317
+	}
318
+	if ( ( rc = handler->set ( sma, &smp->smp_data ) ) != 0 ) {
319
+		DBGC ( sma, "SMA %p could not set attribute %x: %s\n",
320
+		       sma, ntohs ( hdr->attr_id ), strerror ( rc ) );
321
+		hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
322
+		goto respond;
323
+	}
324
+
325
+	hdr->status = htons ( IB_MGMT_STATUS_OK );
326
+
327
+ respond:
328
+	/* Get attribute */
329
+	handler->get ( sma, &smp->smp_data );
330
+
331
+ respond_without_data:
332
+
333
+	/* Set method to "Get Response" */
334
+	hdr->method = IB_MGMT_METHOD_GET_RESP;
335
+
336
+	/* Set response fields for directed route SMPs */
337
+	if ( hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ) {
338
+		hdr->status |= htons ( IB_SMP_STATUS_D_INBOUND );
339
+		smp->return_path.hops[0] = ibdev->port;
340
+	}
341
+
342
+	DBGC ( sma, "SMA %p responding with status=%04x\n",
343
+	       sma, ntohs ( hdr->status ) );
344
+	DBGC2_HDA ( sma, 0, mad, sizeof ( *mad ) );
345
+
346
+	return 0;
347
+}
348
+
349
+/**
350
+ * Refill SMA receive ring
351
+ *
352
+ * @v sma		Subnet management agent
353
+ */
354
+static void ib_sma_refill_recv ( struct ib_sma *sma ) {
355
+	struct ib_device *ibdev = sma->ibdev;
356
+	struct io_buffer *iobuf;
357
+	int rc;
358
+
359
+	while ( sma->qp->recv.fill < IB_SMA_NUM_RECV_WQES ) {
360
+
361
+		/* Allocate I/O buffer */
362
+		iobuf = alloc_iob ( IB_SMA_PAYLOAD_LEN );
363
+		if ( ! iobuf ) {
364
+			/* Non-fatal; we will refill on next attempt */
365
+			return;
366
+		}
367
+
368
+		/* Post I/O buffer */
369
+		if ( ( rc = ib_post_recv ( ibdev, sma->qp, iobuf ) ) != 0 ) {
370
+			DBGC ( sma, "SMA %p could not refill: %s\n",
371
+			       sma, strerror ( rc ) );
372
+			free_iob ( iobuf );
373
+			/* Give up */
374
+			return;
375
+		}
376
+	}
377
+}
378
+
379
+/**
380
+ * Complete SMA send
381
+ *
382
+ *
383
+ * @v ibdev		Infiniband device
384
+ * @v qp		Queue pair
385
+ * @v iobuf		I/O buffer
386
+ * @v rc		Completion status code
387
+ */
388
+static void ib_sma_complete_send ( struct ib_device *ibdev __unused,
389
+				   struct ib_queue_pair *qp,
390
+				   struct io_buffer *iobuf, int rc ) {
391
+	struct ib_sma *sma = ib_qp_get_ownerdata ( qp );
392
+
393
+	if ( rc != 0 ) {
394
+		DBGC ( sma, "SMA %p send completion error: %s\n",
395
+		       sma, strerror ( rc ) );
396
+	}
397
+	free_iob ( iobuf );
398
+}
399
+
400
+/**
401
+ * Complete SMA receive
402
+ *
403
+ *
404
+ * @v ibdev		Infiniband device
405
+ * @v qp		Queue pair
406
+ * @v av		Address vector
407
+ * @v iobuf		I/O buffer
408
+ * @v rc		Completion status code
409
+ */
410
+static void ib_sma_complete_recv ( struct ib_device *ibdev,
411
+				   struct ib_queue_pair *qp,
412
+				   struct ib_address_vector *av,
413
+				   struct io_buffer *iobuf, int rc ) {
414
+	struct ib_sma *sma = ib_qp_get_ownerdata ( qp );
415
+	union ib_mad *mad;
416
+
417
+	/* Ignore errors */
418
+	if ( rc != 0 ) {
419
+		DBGC ( sma, "SMA %p RX error: %s\n", sma, strerror ( rc ) );
420
+		goto err;
421
+	}
422
+
423
+	/* Sanity check */
424
+	if ( iob_len ( iobuf ) != sizeof ( *mad ) ) {
425
+		DBGC ( sma, "SMA %p RX bad size (%zd bytes)\n",
426
+		       sma, iob_len ( iobuf ) );
427
+		goto err;
428
+	}
429
+	mad = iobuf->data;
430
+
431
+	/* Construct MAD response */
432
+	if ( ( rc = ib_sma_mad ( sma, mad ) ) != 0 ) {
433
+		DBGC ( sma, "SMA %p could not construct MAD response: %s\n",
434
+		       sma, strerror ( rc ) );
435
+		goto err;
436
+	}
437
+
438
+	/* Send MAD response */
439
+	if ( ( rc = ib_post_send ( ibdev, qp, av, iobuf ) ) != 0 ) {
440
+		DBGC ( sma, "SMA %p could not send MAD response: %s\n",
441
+		       sma, strerror ( rc ) );
442
+		goto err;
443
+	}
444
+
445
+	return;
446
+
447
+ err:
448
+	free_iob ( iobuf );
449
+}
450
+
451
+/** SMA completion operations */
452
+static struct ib_completion_queue_operations ib_sma_completion_ops = {
453
+	.complete_send = ib_sma_complete_send,
454
+	.complete_recv = ib_sma_complete_recv,
455
+};
456
+
457
+/**
458
+ * Poll SMA
459
+ *
460
+ * @v process		Process
461
+ */
462
+static void ib_sma_step ( struct process *process ) {
463
+	struct ib_sma *sma =
464
+		container_of ( process, struct ib_sma, poll );
465
+	struct ib_device *ibdev = sma->ibdev;
466
+
467
+	/* Poll the kernel completion queue */
468
+	ib_poll_cq ( ibdev, sma->cq );
469
+
470
+	/* Refill the receive ring */
471
+	ib_sma_refill_recv ( sma );
472
+}
473
+
474
+/**
475
+ * Create SMA
476
+ *
477
+ * @v sma		Subnet management agent
478
+ * @v ibdev		Infiniband device
479
+ * @v op		Subnet management operations
480
+ * @ret rc		Return status code
481
+ */
482
+int ib_create_sma ( struct ib_sma *sma, struct ib_device *ibdev,
483
+		    struct ib_sma_operations *op ) {
484
+	int rc;
485
+
486
+	/* Initialise fields */
487
+	memset ( sma, 0, sizeof ( *sma ) );
488
+	sma->ibdev = ibdev;
489
+	sma->op = op;
490
+	process_init ( &sma->poll, ib_sma_step, &ibdev->refcnt );
491
+
492
+	/* Create completion queue */
493
+	sma->cq = ib_create_cq ( ibdev, IB_SMA_NUM_CQES,
494
+				 &ib_sma_completion_ops );
495
+	if ( ! sma->cq ) {
496
+		rc = -ENOMEM;
497
+		goto err_create_cq;
498
+	}
499
+
500
+	/* Create queue pair */
501
+	sma->qp = ib_create_qp ( ibdev, IB_SMA_NUM_SEND_WQES, sma->cq,
502
+				 IB_SMA_NUM_RECV_WQES, sma->cq, 0 );
503
+	if ( ! sma->qp ) {
504
+		rc = -ENOMEM;
505
+		goto err_create_qp;
506
+	}
507
+	ib_qp_set_ownerdata ( sma->qp, sma );
508
+
509
+	/* If we don't get QP0, we can't function */
510
+	if ( sma->qp->qpn != IB_QPN_SMP ) {
511
+		DBGC ( sma, "SMA %p on QPN %lx, needs to be on QPN 0\n",
512
+		       sma, sma->qp->qpn );
513
+		rc = -ENOTSUP;
514
+		goto err_not_qp0;
515
+	}
516
+
517
+	/* Fill receive ring */
518
+	ib_sma_refill_recv ( sma );
519
+	return 0;
520
+
521
+ err_not_qp0:
522
+	ib_destroy_qp ( ibdev, sma->qp );
523
+ err_create_qp:
524
+	ib_destroy_cq ( ibdev, sma->cq );
525
+ err_create_cq:
526
+	process_del ( &sma->poll );
527
+	return rc;
528
+}
529
+
530
+/**
531
+ * Destroy SMA
532
+ *
533
+ * @v sma		Subnet management agent
534
+ */
535
+void ib_destroy_sma ( struct ib_sma *sma ) {
536
+	struct ib_device *ibdev = sma->ibdev;
537
+
538
+	ib_destroy_qp ( ibdev, sma->qp );
539
+	ib_destroy_cq ( ibdev, sma->cq );
540
+	process_del ( &sma->poll );
541
+}

+ 1
- 0
src/include/gpxe/errfile.h Wyświetl plik

@@ -135,6 +135,7 @@
135 135
 #define ERRFILE_netdev_settings		( ERRFILE_NET | 0x00140000 )
136 136
 #define ERRFILE_dhcppkt			( ERRFILE_NET | 0x00150000 )
137 137
 #define ERRFILE_slam			( ERRFILE_NET | 0x00160000 )
138
+#define ERRFILE_ib_sma			( ERRFILE_NET | 0x00170000 )
138 139
 
139 140
 #define ERRFILE_image		      ( ERRFILE_IMAGE | 0x00000000 )
140 141
 #define ERRFILE_elf		      ( ERRFILE_IMAGE | 0x00010000 )

+ 63
- 0
src/include/gpxe/ib_sma.h Wyświetl plik

@@ -0,0 +1,63 @@
1
+#ifndef _GPXE_IB_SMA_H
2
+#define _GPXE_IB_SMA_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband Subnet Management Agent
7
+ *
8
+ */
9
+
10
+#include <gpxe/infiniband.h>
11
+#include <gpxe/process.h>
12
+
13
+/** Infiniband Subnet Management Agent operations */
14
+struct ib_sma_operations {
15
+	/** Set port information
16
+	 *
17
+	 * @v ibdev		Infiniband device
18
+	 * @v port_info		New port information
19
+	 */
20
+	int ( * set_port_info ) ( struct ib_device *ibdev,
21
+				  const struct ib_port_info *port_info );
22
+};
23
+
24
+/** An Infiniband Subnet Management Agent */
25
+struct ib_sma {
26
+	/** Infiniband device */
27
+	struct ib_device *ibdev;
28
+	/** SMA operations */
29
+	struct ib_sma_operations *op;
30
+	/** SMA completion queue */
31
+	struct ib_completion_queue *cq;
32
+	/** SMA queue pair */
33
+	struct ib_queue_pair *qp;
34
+	/** Poll process */
35
+	struct process poll;
36
+};
37
+
38
+/** SMA payload size allocated for received packets */
39
+#define IB_SMA_PAYLOAD_LEN 2048
40
+
41
+/** SMA number of send WQEs
42
+ *
43
+ * This is a policy decision.
44
+ */
45
+#define IB_SMA_NUM_SEND_WQES 4
46
+
47
+/** SMA number of receive WQEs
48
+ *
49
+ * This is a policy decision.
50
+ */
51
+#define IB_SMA_NUM_RECV_WQES 2
52
+
53
+/** SMA number of completion queue entries
54
+ *
55
+ * This is a policy decision
56
+ */
57
+#define IB_SMA_NUM_CQES 8
58
+
59
+extern int ib_create_sma ( struct ib_sma *sma, struct ib_device *ibdev,
60
+			   struct ib_sma_operations *op );
61
+extern void ib_destroy_sma ( struct ib_sma *sma );
62
+
63
+#endif /* _GPXE_IB_SMA_H */

Ładowanie…
Anuluj
Zapisz