|
@@ -54,6 +54,9 @@ struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
|
54
|
54
|
/** List of open Infiniband devices, in reverse order of opening */
|
55
|
55
|
static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
|
56
|
56
|
|
|
57
|
+/** Infiniband device index */
|
|
58
|
+static unsigned int ibdev_index = 0;
|
|
59
|
+
|
57
|
60
|
/** Post send work queue entry profiler */
|
58
|
61
|
static struct profiler ib_post_send_profiler __profiler =
|
59
|
62
|
{ .name = "ib.post_send" };
|
|
@@ -97,7 +100,7 @@ ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes,
|
97
|
100
|
struct ib_completion_queue *cq;
|
98
|
101
|
int rc;
|
99
|
102
|
|
100
|
|
- DBGC ( ibdev, "IBDEV %p creating completion queue\n", ibdev );
|
|
103
|
+ DBGC ( ibdev, "IBDEV %s creating completion queue\n", ibdev->name );
|
101
|
104
|
|
102
|
105
|
/* Allocate and initialise data structure */
|
103
|
106
|
cq = zalloc ( sizeof ( *cq ) );
|
|
@@ -111,13 +114,13 @@ ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes,
|
111
|
114
|
|
112
|
115
|
/* Perform device-specific initialisation and get CQN */
|
113
|
116
|
if ( ( rc = ibdev->op->create_cq ( ibdev, cq ) ) != 0 ) {
|
114
|
|
- DBGC ( ibdev, "IBDEV %p could not initialise completion "
|
115
|
|
- "queue: %s\n", ibdev, strerror ( rc ) );
|
|
117
|
+ DBGC ( ibdev, "IBDEV %s could not initialise completion "
|
|
118
|
+ "queue: %s\n", ibdev->name, strerror ( rc ) );
|
116
|
119
|
goto err_dev_create_cq;
|
117
|
120
|
}
|
118
|
121
|
|
119
|
|
- DBGC ( ibdev, "IBDEV %p created %d-entry completion queue %p (%p) "
|
120
|
|
- "with CQN %#lx\n", ibdev, num_cqes, cq,
|
|
122
|
+ DBGC ( ibdev, "IBDEV %s created %d-entry completion queue %p (%p) "
|
|
123
|
+ "with CQN %#lx\n", ibdev->name, num_cqes, cq,
|
121
|
124
|
ib_cq_get_drvdata ( cq ), cq->cqn );
|
122
|
125
|
return cq;
|
123
|
126
|
|
|
@@ -137,8 +140,8 @@ ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes,
|
137
|
140
|
*/
|
138
|
141
|
void ib_destroy_cq ( struct ib_device *ibdev,
|
139
|
142
|
struct ib_completion_queue *cq ) {
|
140
|
|
- DBGC ( ibdev, "IBDEV %p destroying completion queue %#lx\n",
|
141
|
|
- ibdev, cq->cqn );
|
|
143
|
+ DBGC ( ibdev, "IBDEV %s destroying completion queue %#lx\n",
|
|
144
|
+ ibdev->name, cq->cqn );
|
142
|
145
|
assert ( list_empty ( &cq->work_queues ) );
|
143
|
146
|
ibdev->op->destroy_cq ( ibdev, cq );
|
144
|
147
|
list_del ( &cq->list );
|
|
@@ -198,7 +201,7 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
|
198
|
201
|
size_t total_size;
|
199
|
202
|
int rc;
|
200
|
203
|
|
201
|
|
- DBGC ( ibdev, "IBDEV %p creating queue pair\n", ibdev );
|
|
204
|
+ DBGC ( ibdev, "IBDEV %s creating queue pair\n", ibdev->name );
|
202
|
205
|
|
203
|
206
|
/* Allocate and initialise data structure */
|
204
|
207
|
total_size = ( sizeof ( *qp ) +
|
|
@@ -229,17 +232,17 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
|
229
|
232
|
|
230
|
233
|
/* Perform device-specific initialisation and get QPN */
|
231
|
234
|
if ( ( rc = ibdev->op->create_qp ( ibdev, qp ) ) != 0 ) {
|
232
|
|
- DBGC ( ibdev, "IBDEV %p could not initialise queue pair: "
|
233
|
|
- "%s\n", ibdev, strerror ( rc ) );
|
|
235
|
+ DBGC ( ibdev, "IBDEV %s could not initialise queue pair: "
|
|
236
|
+ "%s\n", ibdev->name, strerror ( rc ) );
|
234
|
237
|
goto err_dev_create_qp;
|
235
|
238
|
}
|
236
|
|
- DBGC ( ibdev, "IBDEV %p created queue pair %p (%p) with QPN %#lx\n",
|
237
|
|
- ibdev, qp, ib_qp_get_drvdata ( qp ), qp->qpn );
|
238
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx has %d send entries at [%p,%p)\n",
|
239
|
|
- ibdev, qp->qpn, num_send_wqes, qp->send.iobufs,
|
|
239
|
+ DBGC ( ibdev, "IBDEV %s created queue pair %p (%p) with QPN %#lx\n",
|
|
240
|
+ ibdev->name, qp, ib_qp_get_drvdata ( qp ), qp->qpn );
|
|
241
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx has %d send entries at [%p,%p)\n",
|
|
242
|
+ ibdev->name, qp->qpn, num_send_wqes, qp->send.iobufs,
|
240
|
243
|
qp->recv.iobufs );
|
241
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx has %d receive entries at [%p,%p)\n",
|
242
|
|
- ibdev, qp->qpn, num_recv_wqes, qp->recv.iobufs,
|
|
244
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx has %d receive entries at [%p,%p)\n",
|
|
245
|
+ ibdev->name, qp->qpn, num_recv_wqes, qp->recv.iobufs,
|
243
|
246
|
( ( ( void * ) qp ) + total_size ) );
|
244
|
247
|
|
245
|
248
|
/* Calculate externally-visible QPN */
|
|
@@ -255,8 +258,8 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
|
255
|
258
|
break;
|
256
|
259
|
}
|
257
|
260
|
if ( qp->ext_qpn != qp->qpn ) {
|
258
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx has external QPN %#lx\n",
|
259
|
|
- ibdev, qp->qpn, qp->ext_qpn );
|
|
261
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx has external QPN %#lx\n",
|
|
262
|
+ ibdev->name, qp->qpn, qp->ext_qpn );
|
260
|
263
|
}
|
261
|
264
|
|
262
|
265
|
return qp;
|
|
@@ -281,11 +284,11 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
|
281
|
284
|
int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
|
282
|
285
|
int rc;
|
283
|
286
|
|
284
|
|
- DBGC ( ibdev, "IBDEV %p modifying QPN %#lx\n", ibdev, qp->qpn );
|
|
287
|
+ DBGC ( ibdev, "IBDEV %s modifying QPN %#lx\n", ibdev->name, qp->qpn );
|
285
|
288
|
|
286
|
289
|
if ( ( rc = ibdev->op->modify_qp ( ibdev, qp ) ) != 0 ) {
|
287
|
|
- DBGC ( ibdev, "IBDEV %p could not modify QPN %#lx: %s\n",
|
288
|
|
- ibdev, qp->qpn, strerror ( rc ) );
|
|
290
|
+ DBGC ( ibdev, "IBDEV %s could not modify QPN %#lx: %s\n",
|
|
291
|
+ ibdev->name, qp->qpn, strerror ( rc ) );
|
289
|
292
|
return rc;
|
290
|
293
|
}
|
291
|
294
|
|
|
@@ -302,8 +305,8 @@ void ib_destroy_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
|
302
|
305
|
struct io_buffer *iobuf;
|
303
|
306
|
unsigned int i;
|
304
|
307
|
|
305
|
|
- DBGC ( ibdev, "IBDEV %p destroying QPN %#lx\n",
|
306
|
|
- ibdev, qp->qpn );
|
|
308
|
+ DBGC ( ibdev, "IBDEV %s destroying QPN %#lx\n",
|
|
309
|
+ ibdev->name, qp->qpn );
|
307
|
310
|
|
308
|
311
|
assert ( list_empty ( &qp->mgids ) );
|
309
|
312
|
|
|
@@ -411,8 +414,8 @@ int ib_post_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
|
411
|
414
|
|
412
|
415
|
/* Check queue fill level */
|
413
|
416
|
if ( qp->send.fill >= qp->send.num_wqes ) {
|
414
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx send queue full\n",
|
415
|
|
- ibdev, qp->qpn );
|
|
417
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx send queue full\n",
|
|
418
|
+ ibdev->name, qp->qpn );
|
416
|
419
|
return -ENOBUFS;
|
417
|
420
|
}
|
418
|
421
|
|
|
@@ -432,8 +435,8 @@ int ib_post_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
|
432
|
435
|
|
433
|
436
|
/* Post to hardware */
|
434
|
437
|
if ( ( rc = ibdev->op->post_send ( ibdev, qp, dest, iobuf ) ) != 0 ) {
|
435
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx could not post send WQE: "
|
436
|
|
- "%s\n", ibdev, qp->qpn, strerror ( rc ) );
|
|
438
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx could not post send WQE: "
|
|
439
|
+ "%s\n", ibdev->name, qp->qpn, strerror ( rc ) );
|
437
|
440
|
return rc;
|
438
|
441
|
}
|
439
|
442
|
|
|
@@ -463,22 +466,22 @@ int ib_post_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
|
463
|
466
|
|
464
|
467
|
/* Check packet length */
|
465
|
468
|
if ( iob_tailroom ( iobuf ) < IB_MAX_PAYLOAD_SIZE ) {
|
466
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx wrong RX buffer size (%zd)\n",
|
467
|
|
- ibdev, qp->qpn, iob_tailroom ( iobuf ) );
|
|
469
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx wrong RX buffer size (%zd)\n",
|
|
470
|
+ ibdev->name, qp->qpn, iob_tailroom ( iobuf ) );
|
468
|
471
|
return -EINVAL;
|
469
|
472
|
}
|
470
|
473
|
|
471
|
474
|
/* Check queue fill level */
|
472
|
475
|
if ( qp->recv.fill >= qp->recv.num_wqes ) {
|
473
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx receive queue full\n",
|
474
|
|
- ibdev, qp->qpn );
|
|
476
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx receive queue full\n",
|
|
477
|
+ ibdev->name, qp->qpn );
|
475
|
478
|
return -ENOBUFS;
|
476
|
479
|
}
|
477
|
480
|
|
478
|
481
|
/* Post to hardware */
|
479
|
482
|
if ( ( rc = ibdev->op->post_recv ( ibdev, qp, iobuf ) ) != 0 ) {
|
480
|
|
- DBGC ( ibdev, "IBDEV %p QPN %#lx could not post receive WQE: "
|
481
|
|
- "%s\n", ibdev, qp->qpn, strerror ( rc ) );
|
|
483
|
+ DBGC ( ibdev, "IBDEV %s QPN %#lx could not post receive WQE: "
|
|
484
|
+ "%s\n", ibdev->name, qp->qpn, strerror ( rc ) );
|
482
|
485
|
return rc;
|
483
|
486
|
}
|
484
|
487
|
|
|
@@ -556,8 +559,8 @@ void ib_refill_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
|
556
|
559
|
|
557
|
560
|
/* Post I/O buffer */
|
558
|
561
|
if ( ( rc = ib_post_recv ( ibdev, qp, iobuf ) ) != 0 ) {
|
559
|
|
- DBGC ( ibdev, "IBDEV %p could not refill: %s\n",
|
560
|
|
- ibdev, strerror ( rc ) );
|
|
562
|
+ DBGC ( ibdev, "IBDEV %s could not refill: %s\n",
|
|
563
|
+ ibdev->name, strerror ( rc ) );
|
561
|
564
|
free_iob ( iobuf );
|
562
|
565
|
/* Give up */
|
563
|
566
|
return;
|
|
@@ -623,8 +626,8 @@ static void ib_notify ( struct ib_device *ibdev ) {
|
623
|
626
|
*/
|
624
|
627
|
void ib_link_state_changed ( struct ib_device *ibdev ) {
|
625
|
628
|
|
626
|
|
- DBGC ( ibdev, "IBDEV %p link state is %s\n",
|
627
|
|
- ibdev, ib_link_state_text ( ibdev ) );
|
|
629
|
+ DBGC ( ibdev, "IBDEV %s link state is %s\n",
|
|
630
|
+ ibdev->name, ib_link_state_text ( ibdev ) );
|
628
|
631
|
|
629
|
632
|
/* Notify drivers of link state change */
|
630
|
633
|
ib_notify ( ibdev );
|
|
@@ -647,30 +650,30 @@ int ib_open ( struct ib_device *ibdev ) {
|
647
|
650
|
|
648
|
651
|
/* Open device */
|
649
|
652
|
if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) {
|
650
|
|
- DBGC ( ibdev, "IBDEV %p could not open: %s\n",
|
651
|
|
- ibdev, strerror ( rc ) );
|
|
653
|
+ DBGC ( ibdev, "IBDEV %s could not open: %s\n",
|
|
654
|
+ ibdev->name, strerror ( rc ) );
|
652
|
655
|
goto err_open;
|
653
|
656
|
}
|
654
|
657
|
|
655
|
658
|
/* Create subnet management interface */
|
656
|
659
|
ibdev->smi = ib_create_mi ( ibdev, IB_QPT_SMI );
|
657
|
660
|
if ( ! ibdev->smi ) {
|
658
|
|
- DBGC ( ibdev, "IBDEV %p could not create SMI\n", ibdev );
|
|
661
|
+ DBGC ( ibdev, "IBDEV %s could not create SMI\n", ibdev->name );
|
659
|
662
|
rc = -ENOMEM;
|
660
|
663
|
goto err_create_smi;
|
661
|
664
|
}
|
662
|
665
|
|
663
|
666
|
/* Create subnet management agent */
|
664
|
667
|
if ( ( rc = ib_create_sma ( ibdev, ibdev->smi ) ) != 0 ) {
|
665
|
|
- DBGC ( ibdev, "IBDEV %p could not create SMA: %s\n",
|
666
|
|
- ibdev, strerror ( rc ) );
|
|
668
|
+ DBGC ( ibdev, "IBDEV %s could not create SMA: %s\n",
|
|
669
|
+ ibdev->name, strerror ( rc ) );
|
667
|
670
|
goto err_create_sma;
|
668
|
671
|
}
|
669
|
672
|
|
670
|
673
|
/* Create general services interface */
|
671
|
674
|
ibdev->gsi = ib_create_mi ( ibdev, IB_QPT_GSI );
|
672
|
675
|
if ( ! ibdev->gsi ) {
|
673
|
|
- DBGC ( ibdev, "IBDEV %p could not create GSI\n", ibdev );
|
|
676
|
+ DBGC ( ibdev, "IBDEV %s could not create GSI\n", ibdev->name );
|
674
|
677
|
rc = -ENOMEM;
|
675
|
678
|
goto err_create_gsi;
|
676
|
679
|
}
|
|
@@ -833,14 +836,14 @@ int ib_set_port_info ( struct ib_device *ibdev, union ib_mad *mad ) {
|
833
|
836
|
|
834
|
837
|
/* Adapters with embedded SMAs do not need to support this method */
|
835
|
838
|
if ( ! ibdev->op->set_port_info ) {
|
836
|
|
- DBGC ( ibdev, "IBDEV %p does not support setting port "
|
837
|
|
- "information\n", ibdev );
|
|
839
|
+ DBGC ( ibdev, "IBDEV %s does not support setting port "
|
|
840
|
+ "information\n", ibdev->name );
|
838
|
841
|
return -ENOTSUP;
|
839
|
842
|
}
|
840
|
843
|
|
841
|
844
|
if ( ( rc = ibdev->op->set_port_info ( ibdev, mad ) ) != 0 ) {
|
842
|
|
- DBGC ( ibdev, "IBDEV %p could not set port information: %s\n",
|
843
|
|
- ibdev, strerror ( rc ) );
|
|
845
|
+ DBGC ( ibdev, "IBDEV %s could not set port information: %s\n",
|
|
846
|
+ ibdev->name, strerror ( rc ) );
|
844
|
847
|
return rc;
|
845
|
848
|
}
|
846
|
849
|
|
|
@@ -858,14 +861,14 @@ int ib_set_pkey_table ( struct ib_device *ibdev, union ib_mad *mad ) {
|
858
|
861
|
|
859
|
862
|
/* Adapters with embedded SMAs do not need to support this method */
|
860
|
863
|
if ( ! ibdev->op->set_pkey_table ) {
|
861
|
|
- DBGC ( ibdev, "IBDEV %p does not support setting partition "
|
862
|
|
- "key table\n", ibdev );
|
|
864
|
+ DBGC ( ibdev, "IBDEV %s does not support setting partition "
|
|
865
|
+ "key table\n", ibdev->name );
|
863
|
866
|
return -ENOTSUP;
|
864
|
867
|
}
|
865
|
868
|
|
866
|
869
|
if ( ( rc = ibdev->op->set_pkey_table ( ibdev, mad ) ) != 0 ) {
|
867
|
|
- DBGC ( ibdev, "IBDEV %p could not set partition key table: "
|
868
|
|
- "%s\n", ibdev, strerror ( rc ) );
|
|
870
|
+ DBGC ( ibdev, "IBDEV %s could not set partition key table: "
|
|
871
|
+ "%s\n", ibdev->name, strerror ( rc ) );
|
869
|
872
|
return rc;
|
870
|
873
|
}
|
871
|
874
|
|
|
@@ -954,17 +957,24 @@ int register_ibdev ( struct ib_device *ibdev ) {
|
954
|
957
|
struct ib_driver *driver;
|
955
|
958
|
int rc;
|
956
|
959
|
|
|
960
|
+ /* Record device index and create device name */
|
|
961
|
+ if ( ibdev->name[0] == '\0' ) {
|
|
962
|
+ snprintf ( ibdev->name, sizeof ( ibdev->name ), "inf%d",
|
|
963
|
+ ibdev_index );
|
|
964
|
+ }
|
|
965
|
+ ibdev->index = ++ibdev_index;
|
|
966
|
+
|
957
|
967
|
/* Add to device list */
|
958
|
968
|
ibdev_get ( ibdev );
|
959
|
969
|
list_add_tail ( &ibdev->list, &ib_devices );
|
960
|
|
- DBGC ( ibdev, "IBDEV %p registered (phys %s)\n", ibdev,
|
|
970
|
+ DBGC ( ibdev, "IBDEV %s registered (phys %s)\n", ibdev->name,
|
961
|
971
|
ibdev->dev->name );
|
962
|
972
|
|
963
|
973
|
/* Probe device */
|
964
|
974
|
for_each_table_entry ( driver, IB_DRIVERS ) {
|
965
|
975
|
if ( ( rc = driver->probe ( ibdev ) ) != 0 ) {
|
966
|
|
- DBGC ( ibdev, "IBDEV %p could not add %s device: %s\n",
|
967
|
|
- ibdev, driver->name, strerror ( rc ) );
|
|
976
|
+ DBGC ( ibdev, "IBDEV %s could not add %s device: %s\n",
|
|
977
|
+ ibdev->name, driver->name, strerror ( rc ) );
|
968
|
978
|
goto err_probe;
|
969
|
979
|
}
|
970
|
980
|
}
|
|
@@ -994,7 +1004,11 @@ void unregister_ibdev ( struct ib_device *ibdev ) {
|
994
|
1004
|
/* Remove from device list */
|
995
|
1005
|
list_del ( &ibdev->list );
|
996
|
1006
|
ibdev_put ( ibdev );
|
997
|
|
- DBGC ( ibdev, "IBDEV %p unregistered\n", ibdev );
|
|
1007
|
+ DBGC ( ibdev, "IBDEV %s unregistered\n", ibdev->name );
|
|
1008
|
+
|
|
1009
|
+ /* Reset device index if no devices remain */
|
|
1010
|
+ if ( list_empty ( &ib_devices ) )
|
|
1011
|
+ ibdev_index = 0;
|
998
|
1012
|
}
|
999
|
1013
|
|
1000
|
1014
|
/**
|