1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
|
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* This file contains code imported from the OFED rds source file ib_cm.c
* Oracle elects to have and use the contents of ib_cm.c under and governed
* by the OpenIB.org BSD license (see below for full license text). However,
* the following notice accompanied the original version of this file:
*/
/*
* Copyright (c) 2006 Oracle. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include <sys/rds.h>
#include <sys/ib/clients/of/ofed_kernel.h>
#include <sys/ib/clients/of/rdma/ib_addr.h>
#include <sys/ib/clients/of/rdma/rdma_cm.h>
#include <sys/ib/clients/rdsv3/rdsv3.h>
#include <sys/ib/clients/rdsv3/ib.h>
#include <sys/ib/clients/rdsv3/rdsv3_debug.h>
extern int rdsv3_enable_snd_cq;
/*
* Set the selected protocol version
*/
static void
rdsv3_ib_set_protocol(struct rdsv3_connection *conn, unsigned int version)
{
RDSV3_DPRINTF4("rdsv3_ib_set_protocol", "conn: %p version: %d",
conn, version);
conn->c_version = version;
}
/*
* Set up flow control
*/
static void
rdsv3_ib_set_flow_control(struct rdsv3_connection *conn, uint32_t credits)
{
struct rdsv3_ib_connection *ic = conn->c_transport_data;
RDSV3_DPRINTF2("rdsv3_ib_set_flow_control",
"Enter: conn: %p credits: %d", conn, credits);
if (rdsv3_ib_sysctl_flow_control && credits != 0) {
/* We're doing flow control */
ic->i_flowctl = 1;
rdsv3_ib_send_add_credits(conn, credits);
} else {
ic->i_flowctl = 0;
}
RDSV3_DPRINTF2("rdsv3_ib_set_flow_control",
"Return: conn: %p credits: %d",
conn, credits);
}
/*
* Tune RNR behavior. Without flow control, we use a rather
* low timeout, but not the absolute minimum - this should
* be tunable.
*
* We already set the RNR retry count to 7 (which is the
* smallest infinite number :-) above.
* If flow control is off, we want to change this back to 0
* so that we learn quickly when our credit accounting is
* buggy.
*
* Caller passes in a qp_attr pointer - don't waste stack spacv
* by allocation this twice.
*/
static void
rdsv3_ib_tune_rnr(struct rdsv3_ib_connection *ic, struct ib_qp_attr *attr)
{
int ret;
RDSV3_DPRINTF2("rdsv3_ib_tune_rnr", "Enter ic: %p attr: %p",
ic, attr);
attr->min_rnr_timer = IB_RNR_TIMER_000_32;
ret = ib_modify_qp(ic->i_cm_id->qp, attr, IB_QP_MIN_RNR_TIMER);
if (ret)
RDSV3_DPRINTF2("rdsv3_ib_tune_rnr",
"ib_modify_qp(IB_QP_MIN_RNR_TIMER): err=%d", -ret);
}
/*
* Connection established.
* We get here for both outgoing and incoming connection.
*/
void
rdsv3_ib_cm_connect_complete(struct rdsv3_connection *conn,
struct rdma_cm_event *event)
{
const struct rdsv3_ib_connect_private *dp = NULL;
struct rdsv3_ib_connection *ic = conn->c_transport_data;
struct rdsv3_ib_device *rds_ibdev =
ib_get_client_data(ic->i_cm_id->device, &rdsv3_ib_client);
struct ib_qp_attr qp_attr;
int err;
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"Enter conn: %p event: %p", conn, event);
if (event->param.conn.private_data_len >= sizeof (*dp)) {
dp = event->param.conn.private_data;
/* make sure it isn't empty data */
if (dp->dp_protocol_major) {
rdsv3_ib_set_protocol(conn,
RDS_PROTOCOL(dp->dp_protocol_major,
dp->dp_protocol_minor));
rdsv3_ib_set_flow_control(conn,
ntohl(dp->dp_credit));
}
}
if (conn->c_version < RDS_PROTOCOL(3, 1)) {
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"RDS/IB: Connection to %u.%u.%u.%u version %u.%u failed",
NIPQUAD(conn->c_faddr),
RDS_PROTOCOL_MAJOR(conn->c_version),
RDS_PROTOCOL_MINOR(conn->c_version));
rdsv3_conn_destroy(conn);
return;
} else {
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"RDS/IB: connected to %u.%u.%u.%u version %u.%u%s",
NIPQUAD(conn->c_faddr),
RDS_PROTOCOL_MAJOR(conn->c_version),
RDS_PROTOCOL_MINOR(conn->c_version),
ic->i_flowctl ? ", flow control" : "");
}
ASSERT(ic->i_soft_cq == NULL);
ic->i_soft_cq = rdsv3_af_intr_thr_create(rdsv3_ib_tasklet_fn,
(void *)ic, SCQ_INTR_BIND_CPU, rds_ibdev->aft_hcagp,
ic->i_cq->ibt_cq);
if (rdsv3_enable_snd_cq) {
ic->i_snd_soft_cq = rdsv3_af_intr_thr_create(
rdsv3_ib_snd_tasklet_fn,
(void *)ic, SCQ_INTR_BIND_CPU, rds_ibdev->aft_hcagp,
ic->i_snd_cq->ibt_cq);
}
/* rdsv3_ib_refill_fn is expecting i_max_recv_alloc set */
ic->i_max_recv_alloc = rdsv3_ib_sysctl_max_recv_allocation;
ic->i_refill_rq = rdsv3_af_thr_create(rdsv3_ib_refill_fn, (void *)conn,
SCQ_WRK_BIND_CPU, rds_ibdev->aft_hcagp);
rdsv3_af_grp_draw(rds_ibdev->aft_hcagp);
(void) ib_req_notify_cq(ic->i_cq, IB_CQ_SOLICITED);
if (rdsv3_enable_snd_cq) {
(void) ib_req_notify_cq(ic->i_snd_cq, IB_CQ_NEXT_COMP);
}
/*
* Init rings and fill recv. this needs to wait until protocol
* negotiation
* is complete, since ring layout is different from 3.0 to 3.1.
*/
rdsv3_ib_send_init_ring(ic);
rdsv3_ib_recv_init_ring(ic);
/*
* Post receive buffers - as a side effect, this will update
* the posted credit count.
*/
(void) rdsv3_ib_recv_refill(conn, 1);
/* Tune RNR behavior */
rdsv3_ib_tune_rnr(ic, &qp_attr);
qp_attr.qp_state = IB_QPS_RTS;
err = ib_modify_qp(ic->i_cm_id->qp, &qp_attr, IB_QP_STATE);
if (err)
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"ib_modify_qp(IB_QP_STATE, RTS): err=%d", err);
/* update ib_device with this local ipaddr & conn */
err = rdsv3_ib_update_ipaddr(rds_ibdev, conn->c_laddr);
if (err)
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"rdsv3_ib_update_ipaddr failed (%d)", err);
rdsv3_ib_add_conn(rds_ibdev, conn);
/*
* If the peer gave us the last packet it saw, process this as if
* we had received a regular ACK.
*/
if (dp && dp->dp_ack_seq)
rdsv3_send_drop_acked(conn, ntohll(dp->dp_ack_seq), NULL);
rdsv3_connect_complete(conn);
RDSV3_DPRINTF2("rdsv3_ib_cm_connect_complete",
"Return conn: %p event: %p",
conn, event);
}
static void
rdsv3_ib_cm_fill_conn_param(struct rdsv3_connection *conn,
struct rdma_conn_param *conn_param,
struct rdsv3_ib_connect_private *dp,
uint32_t protocol_version,
uint32_t max_responder_resources,
uint32_t max_initiator_depth)
{
struct rdsv3_ib_connection *ic = conn->c_transport_data;
struct rdsv3_ib_device *rds_ibdev;
RDSV3_DPRINTF2("rdsv3_ib_cm_fill_conn_param",
"Enter conn: %p conn_param: %p private: %p version: %d",
conn, conn_param, dp, protocol_version);
(void) memset(conn_param, 0, sizeof (struct rdma_conn_param));
rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rdsv3_ib_client);
conn_param->responder_resources =
MIN(rds_ibdev->max_responder_resources, max_responder_resources);
conn_param->initiator_depth =
MIN(rds_ibdev->max_initiator_depth, max_initiator_depth);
conn_param->retry_count = min(rdsv3_ib_retry_count, 7);
conn_param->rnr_retry_count = 7;
if (dp) {
(void) memset(dp, 0, sizeof (*dp));
dp->dp_saddr = conn->c_laddr;
dp->dp_daddr = conn->c_faddr;
dp->dp_protocol_major = RDS_PROTOCOL_MAJOR(protocol_version);
dp->dp_protocol_minor = RDS_PROTOCOL_MINOR(protocol_version);
dp->dp_protocol_minor_mask =
htons(RDSV3_IB_SUPPORTED_PROTOCOLS);
dp->dp_ack_seq = rdsv3_ib_piggyb_ack(ic);
/* Advertise flow control */
if (ic->i_flowctl) {
unsigned int credits;
credits = IB_GET_POST_CREDITS(
atomic_get(&ic->i_credits));
dp->dp_credit = htonl(credits);
atomic_add_32(&ic->i_credits,
-IB_SET_POST_CREDITS(credits));
}
conn_param->private_data = dp;
conn_param->private_data_len = sizeof (*dp);
}
RDSV3_DPRINTF2("rdsv3_ib_cm_fill_conn_param",
"Return conn: %p conn_param: %p private: %p version: %d",
conn, conn_param, dp, protocol_version);
}
static void
rdsv3_ib_cq_event_handler(struct ib_event *event, void *data)
{
RDSV3_DPRINTF3("rdsv3_ib_cq_event_handler", "event %u data %p",
event->event, data);
}
static void
rdsv3_ib_snd_cq_comp_handler(struct ib_cq *cq, void *context)
{
struct rdsv3_connection *conn = context;
struct rdsv3_ib_connection *ic = conn->c_transport_data;
RDSV3_DPRINTF4("rdsv3_ib_snd_cq_comp_handler",
"Enter(conn: %p ic: %p cq: %p)", conn, ic, cq);
rdsv3_af_thr_fire(ic->i_snd_soft_cq);
}
void
rdsv3_ib_snd_tasklet_fn(void *data)
{
struct rdsv3_ib_connection *ic = (struct rdsv3_ib_connection *)data;
struct rdsv3_connection *conn = ic->conn;
struct rdsv3_ib_ack_state ack_state = { 0, };
ibt_wc_t wc;
uint_t polled;
RDSV3_DPRINTF4("rdsv3_ib_snd_tasklet_fn",
"Enter(conn: %p ic: %p)", conn, ic);
/*
* Poll in a loop before and after enabling the next event
*/
while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_snd_cq), &wc, 1, &polled) ==
IBT_SUCCESS) {
RDSV3_DPRINTF4("rdsv3_ib_snd_tasklet_fn",
"wc_id 0x%llx type %d status %u byte_len %u imm_data %u\n",
(unsigned long long)wc.wc_id, wc.wc_type, wc.wc_status,
wc.wc_bytes_xfer, ntohl(wc.wc_immed_data));
ASSERT(wc.wc_id & RDSV3_IB_SEND_OP);
rdsv3_ib_send_cqe_handler(ic, &wc);
}
(void) ibt_enable_cq_notify(RDSV3_CQ2CQHDL(ic->i_snd_cq),
IBT_NEXT_COMPLETION);
while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_snd_cq), &wc, 1, &polled) ==
IBT_SUCCESS) {
RDSV3_DPRINTF4("rdsv3_ib_snd_tasklet_fn",
"wc_id 0x%llx type %d status %u byte_len %u imm_data %u\n",
(unsigned long long)wc.wc_id, wc.wc_type, wc.wc_status,
wc.wc_bytes_xfer, ntohl(wc.wc_immed_data));
ASSERT(wc.wc_id & RDSV3_IB_SEND_OP);
rdsv3_ib_send_cqe_handler(ic, &wc);
}
}
static void
rdsv3_ib_cq_comp_handler(struct ib_cq *cq, void *context)
{
struct rdsv3_connection *conn = context;
struct rdsv3_ib_connection *ic = conn->c_transport_data;
RDSV3_DPRINTF4("rdsv3_ib_cq_comp_handler",
"Enter(conn: %p cq: %p)", conn, cq);
rdsv3_ib_stats_inc(s_ib_evt_handler_call);
rdsv3_af_thr_fire(ic->i_soft_cq);
}
void
rdsv3_ib_refill_fn(void *data)
{
struct rdsv3_connection *conn = (struct rdsv3_connection *)data;
(void) rdsv3_ib_recv_refill(conn, 0);
}
void
rdsv3_ib_tasklet_fn(void *data)
{
struct rdsv3_ib_connection *ic = (struct rdsv3_ib_connection *)data;
struct rdsv3_connection *conn = ic->conn;
struct rdsv3_ib_ack_state ack_state = { 0, };
ibt_wc_t wc[RDSV3_IB_WC_POLL_SIZE];
uint_t polled;
int i;
RDSV3_DPRINTF4("rdsv3_ib_tasklet_fn",
"Enter(conn: %p ic: %p)", conn, ic);
rdsv3_ib_stats_inc(s_ib_tasklet_call);
/*
* Poll in a loop before and after enabling the next event
*/
while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_cq), &wc[0],
RDSV3_IB_WC_POLL_SIZE, &polled) == IBT_SUCCESS) {
for (i = 0; i < polled; i++) {
RDSV3_DPRINTF4("rdsv3_ib_tasklet_fn",
"wc_id 0x%llx type %d status %u byte_len %u \
imm_data %u\n",
(unsigned long long)wc[i].wc_id, wc[i].wc_type,
wc[i].wc_status, wc[i].wc_bytes_xfer,
ntohl(wc[i].wc_immed_data));
if (wc[i].wc_id & RDSV3_IB_SEND_OP) {
rdsv3_ib_send_cqe_handler(ic, &wc[i]);
} else {
rdsv3_ib_recv_cqe_handler(ic, &wc[i],
&ack_state);
}
}
}
(void) ibt_enable_cq_notify(RDSV3_CQ2CQHDL(ic->i_cq),
IBT_NEXT_SOLICITED);
while (ibt_poll_cq(RDSV3_CQ2CQHDL(ic->i_cq), &wc[0],
RDSV3_IB_WC_POLL_SIZE, &polled) == IBT_SUCCESS) {
for (i = 0; i < polled; i++) {
RDSV3_DPRINTF4("rdsv3_ib_tasklet_fn",
"wc_id 0x%llx type %d status %u byte_len %u \
imm_data %u\n",
(unsigned long long)wc[i].wc_id, wc[i].wc_type,
wc[i].wc_status, wc[i].wc_bytes_xfer,
ntohl(wc[i].wc_immed_data));
if (wc[i].wc_id & RDSV3_IB_SEND_OP) {
rdsv3_ib_send_cqe_handler(ic, &wc[i]);
} else {
rdsv3_ib_recv_cqe_handler(ic, &wc[i],
&ack_state);
}
}
}
if (ack_state.ack_next_valid) {
rdsv3_ib_set_ack(ic, ack_state.ack_next,
ack_state.ack_required);
}
if (ack_state.ack_recv_valid && ack_state.ack_recv > ic->i_ack_recv) {
rdsv3_send_drop_acked(conn, ack_state.ack_recv, NULL);
ic->i_ack_recv = ack_state.ack_recv;
}
if (rdsv3_conn_up(conn)) {
if (!test_bit(RDSV3_LL_SEND_FULL, &conn->c_flags))
(void) rdsv3_send_xmit(ic->conn);
rdsv3_ib_attempt_ack(ic);
}
}
static void
rdsv3_ib_qp_event_handler(struct ib_event *event, void *data)
{
struct rdsv3_connection *conn = data;
struct rdsv3_ib_connection *ic = conn->c_transport_data;
RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler", "conn %p ic %p event %u",
conn, ic, event->event);
switch (event->event) {
case IB_EVENT_COMM_EST:
(void) rdma_notify(ic->i_cm_id, IB_EVENT_COMM_EST);
break;
default:
if (conn) {
RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler",
"RDS/IB: Fatal QP Event %u - "
"connection %u.%u.%u.%u ->%u.%u.%u.%u "
"...reconnecting",
event->event, NIPQUAD(conn->c_laddr),
NIPQUAD(conn->c_faddr));
rdsv3_conn_drop(conn);
} else {
RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler",
"RDS/IB: Fatal QP Event %u - connection"
"...reconnecting", event->event);
}
break;
}
RDSV3_DPRINTF2("rdsv3_ib_qp_event_handler", "Return conn: %p event: %p",
conn, event);
}
extern int rdsv3_ib_alloc_hdrs(ib_device_t *dev,
struct rdsv3_ib_connection *ic);
extern void rdsv3_ib_free_hdrs(ib_device_t *dev,
struct rdsv3_ib_connection *ic);
/*
* This needs to be very careful to not leave IS_ERR pointers around for
* cleanup to trip over.
*/
static int
rdsv3_ib_setup_qp(struct rdsv3_connection *conn)
{
struct rdsv3_ib_connection *ic = conn->c_transport_data;
struct ib_device *dev = ic->i_cm_id->device;
struct ib_qp_init_attr attr;
struct rdsv3_ib_device *rds_ibdev;
ibt_send_wr_t *wrp;
ibt_wr_ds_t *sgl;
int ret, i;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp", "Enter conn: %p", conn);
/*
* rdsv3_ib_add_one creates a rdsv3_ib_device object per IB device,
* and allocates a protection domain, memory range and FMR pool
* for each. If that fails for any reason, it will not register
* the rds_ibdev at all.
*/
rds_ibdev = ib_get_client_data(dev, &rdsv3_ib_client);
if (!rds_ibdev) {
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"RDS/IB: No client_data for device %s", dev->name);
return (-EOPNOTSUPP);
}
ic->rds_ibdev = rds_ibdev;
if (rds_ibdev->max_wrs < ic->i_send_ring.w_nr + 1)
rdsv3_ib_ring_resize(&ic->i_send_ring, rds_ibdev->max_wrs - 1);
if (rds_ibdev->max_wrs < ic->i_recv_ring.w_nr + 1)
rdsv3_ib_ring_resize(&ic->i_recv_ring, rds_ibdev->max_wrs - 1);
/* Protection domain and memory range */
ic->i_pd = rds_ibdev->pd;
/*
* IB_CQ_VECTOR_LEAST_ATTACHED and/or the corresponding feature is
* not implmeneted in Hermon yet, but we can pass it to ib_create_cq()
* anyway.
*/
ic->i_cq = ib_create_cq(dev, rdsv3_ib_cq_comp_handler,
rdsv3_ib_cq_event_handler, conn,
ic->i_recv_ring.w_nr + ic->i_send_ring.w_nr + 1,
rdsv3_af_grp_get_sched(ic->rds_ibdev->aft_hcagp));
if (IS_ERR(ic->i_cq)) {
ret = PTR_ERR(ic->i_cq);
ic->i_cq = NULL;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"ib_create_cq failed: %d", ret);
goto out;
}
if (rdsv3_enable_snd_cq) {
ic->i_snd_cq = ib_create_cq(dev, rdsv3_ib_snd_cq_comp_handler,
rdsv3_ib_cq_event_handler, conn, ic->i_send_ring.w_nr + 1,
rdsv3_af_grp_get_sched(ic->rds_ibdev->aft_hcagp));
if (IS_ERR(ic->i_snd_cq)) {
ret = PTR_ERR(ic->i_snd_cq);
(void) ib_destroy_cq(ic->i_cq);
ic->i_cq = NULL;
ic->i_snd_cq = NULL;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"ib_create_cq send cq failed: %d", ret);
goto out;
}
}
/* XXX negotiate max send/recv with remote? */
(void) memset(&attr, 0, sizeof (attr));
attr.event_handler = rdsv3_ib_qp_event_handler;
attr.qp_context = conn;
/* + 1 to allow for the single ack message */
attr.cap.max_send_wr = ic->i_send_ring.w_nr + 1;
attr.cap.max_recv_wr = ic->i_recv_ring.w_nr + 1;
attr.cap.max_send_sge = rds_ibdev->max_sge;
attr.cap.max_recv_sge = RDSV3_IB_RECV_SGE;
attr.sq_sig_type = IB_SIGNAL_REQ_WR;
attr.qp_type = IB_QPT_RC;
if (rdsv3_enable_snd_cq) {
attr.send_cq = ic->i_snd_cq;
} else {
attr.send_cq = ic->i_cq;
}
attr.recv_cq = ic->i_cq;
/*
* XXX this can fail if max_*_wr is too large? Are we supposed
* to back off until we get a value that the hardware can support?
*/
ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr);
if (ret) {
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"rdma_create_qp failed: %d", ret);
goto out;
}
ret = rdsv3_ib_alloc_hdrs(dev, ic);
if (ret != 0) {
ret = -ENOMEM;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"rdsv3_ib_alloc_hdrs failed: %d", ret);
goto out;
}
ic->i_sends = kmem_alloc(ic->i_send_ring.w_nr *
sizeof (struct rdsv3_ib_send_work), KM_NOSLEEP);
if (ic->i_sends == NULL) {
ret = -ENOMEM;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"send allocation failed: %d", ret);
goto out;
}
(void) memset(ic->i_sends, 0, ic->i_send_ring.w_nr *
sizeof (struct rdsv3_ib_send_work));
ic->i_send_wrs =
kmem_alloc(ic->i_send_ring.w_nr * (sizeof (ibt_send_wr_t) +
RDSV3_IB_MAX_SGE * sizeof (ibt_wr_ds_t)), KM_NOSLEEP);
if (ic->i_send_wrs == NULL) {
ret = -ENOMEM;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"Send WR allocation failed: %d", ret);
goto out;
}
sgl = (ibt_wr_ds_t *)((uint8_t *)ic->i_send_wrs +
(ic->i_send_ring.w_nr * sizeof (ibt_send_wr_t)));
for (i = 0; i < ic->i_send_ring.w_nr; i++) {
wrp = &ic->i_send_wrs[i];
wrp->wr_sgl = &sgl[i * RDSV3_IB_MAX_SGE];
}
ic->i_recvs = kmem_alloc(ic->i_recv_ring.w_nr *
sizeof (struct rdsv3_ib_recv_work), KM_NOSLEEP);
if (ic->i_recvs == NULL) {
ret = -ENOMEM;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"recv allocation failed: %d", ret);
goto out;
}
(void) memset(ic->i_recvs, 0, ic->i_recv_ring.w_nr *
sizeof (struct rdsv3_ib_recv_work));
ic->i_recv_wrs =
kmem_alloc(ic->i_recv_ring.w_nr * sizeof (ibt_recv_wr_t),
KM_NOSLEEP);
if (ic->i_recv_wrs == NULL) {
ret = -ENOMEM;
RDSV3_DPRINTF2("rdsv3_ib_setup_qp",
"Recv WR allocation failed: %d", ret);
goto out;
}
rdsv3_ib_recv_init_ack(ic);
RDSV3_DPRINTF2("rdsv3_ib_setup_qp", "conn %p pd %p mr %p cq %p",
conn, ic->i_pd, ic->i_mr, ic->i_cq);
out:
return (ret);
}
static uint32_t
rdsv3_ib_protocol_compatible(struct rdma_cm_event *event)
{
const struct rdsv3_ib_connect_private *dp =
event->param.conn.private_data;
uint16_t common;
uint32_t version = 0;
RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible", "Enter event: %p",
event);
/*
* rdma_cm private data is odd - when there is any private data in the
* request, we will be given a pretty large buffer without telling us
* the
* original size. The only way to tell the difference is by looking at
* the contents, which are initialized to zero.
* If the protocol version fields aren't set,
* this is a connection attempt
* from an older version. This could could be 3.0 or 2.0 -
* we can't tell.
* We really should have changed this for OFED 1.3 :-(
*/
/* Be paranoid. RDS always has privdata */
if (!event->param.conn.private_data_len) {
RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible",
"RDS incoming connection has no private data, rejecting");
return (0);
}
/* Even if len is crap *now* I still want to check it. -ASG */
if (event->param.conn.private_data_len < sizeof (*dp) ||
dp->dp_protocol_major == 0)
return (RDS_PROTOCOL_3_0);
common = ntohs(dp->dp_protocol_minor_mask) &
RDSV3_IB_SUPPORTED_PROTOCOLS;
if (dp->dp_protocol_major == 3 && common) {
version = RDS_PROTOCOL_3_0;
while ((common >>= 1) != 0)
version++;
} else {
RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible",
"RDS: Connection from %u.%u.%u.%u using "
"incompatible protocol version %u.%u\n",
NIPQUAD(dp->dp_saddr),
dp->dp_protocol_major,
dp->dp_protocol_minor);
}
RDSV3_DPRINTF2("rdsv3_ib_protocol_compatible", "Return event: %p",
event);
return (version);
}
int
rdsv3_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
struct rdma_cm_event *event)
{
uint64_be_t lguid = cm_id->route.path_rec->sgid.global.interface_id;
uint64_be_t fguid = cm_id->route.path_rec->dgid.global.interface_id;
const struct rdsv3_ib_connect_private *dp =
event->param.conn.private_data;
struct rdsv3_ib_connect_private dp_rep;
struct rdsv3_connection *conn = NULL;
struct rdsv3_ib_connection *ic = NULL;
struct rdma_conn_param conn_param;
uint32_t version;
int err, destroy = 1;
boolean_t conn_created = B_FALSE;
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"Enter cm_id: %p event: %p", cm_id, event);
/* Check whether the remote protocol version matches ours. */
version = rdsv3_ib_protocol_compatible(event);
if (!version) {
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"version mismatch");
goto out;
}
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"saddr %u.%u.%u.%u daddr %u.%u.%u.%u RDSv%d.%d lguid 0x%llx fguid "
"0x%llx", NIPQUAD(dp->dp_saddr), NIPQUAD(dp->dp_daddr),
RDS_PROTOCOL_MAJOR(version), RDS_PROTOCOL_MINOR(version),
(unsigned long long)ntohll(lguid),
(unsigned long long)ntohll(fguid));
conn = rdsv3_conn_create(dp->dp_daddr, dp->dp_saddr,
&rdsv3_ib_transport, KM_NOSLEEP);
if (IS_ERR(conn)) {
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"rdsv3_conn_create failed (%ld)", PTR_ERR(conn));
conn = NULL;
goto out;
}
/*
* The connection request may occur while the
* previous connection exist, e.g. in case of failover.
* But as connections may be initiated simultaneously
* by both hosts, we have a random backoff mechanism -
* see the comment above rdsv3_queue_reconnect()
*/
mutex_enter(&conn->c_cm_lock);
if (!rdsv3_conn_transition(conn, RDSV3_CONN_DOWN,
RDSV3_CONN_CONNECTING)) {
if (rdsv3_conn_state(conn) == RDSV3_CONN_UP) {
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"incoming connect when connected: %p",
conn);
rdsv3_conn_drop(conn);
rdsv3_ib_stats_inc(s_ib_listen_closed_stale);
mutex_exit(&conn->c_cm_lock);
goto out;
} else if (rdsv3_conn_state(conn) == RDSV3_CONN_CONNECTING) {
/* Wait and see - our connect may still be succeeding */
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"peer-to-peer connection request: %p, "
"lguid: 0x%llx fguid: 0x%llx",
conn, lguid, fguid);
rdsv3_ib_stats_inc(s_ib_connect_raced);
}
mutex_exit(&conn->c_cm_lock);
goto out;
}
ic = conn->c_transport_data;
rdsv3_ib_set_protocol(conn, version);
rdsv3_ib_set_flow_control(conn, ntohl(dp->dp_credit));
/*
* If the peer gave us the last packet it saw, process this as if
* we had received a regular ACK.
*/
if (dp->dp_ack_seq)
rdsv3_send_drop_acked(conn, ntohll(dp->dp_ack_seq), NULL);
ASSERT(!cm_id->context);
ASSERT(!ic->i_cm_id);
if (ic->i_cm_id != NULL)
RDSV3_PANIC();
ic->i_cm_id = cm_id;
cm_id->context = conn;
/*
* We got halfway through setting up the ib_connection, if we
* fail now, we have to take the long route out of this mess.
*/
destroy = 0;
err = rdsv3_ib_setup_qp(conn);
if (err) {
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"rdsv3_ib_setup_qp failed (%d)", err);
mutex_exit(&conn->c_cm_lock);
rdsv3_conn_drop(conn);
goto out;
}
rdsv3_ib_cm_fill_conn_param(conn, &conn_param, &dp_rep, version,
event->param.conn.responder_resources,
event->param.conn.initiator_depth);
/* rdma_accept() calls rdma_reject() internally if it fails */
err = rdma_accept(cm_id, &conn_param);
mutex_exit(&conn->c_cm_lock);
if (err) {
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"rdma_accept failed (%d)", err);
rdsv3_conn_drop(conn);
goto out;
}
RDSV3_DPRINTF2("rdsv3_ib_cm_handle_connect",
"Return cm_id: %p event: %p", cm_id, event);
return (0);
out:
(void) rdma_reject(cm_id, NULL, 0);
return (destroy);
}
int
rdsv3_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
{
struct rdsv3_connection *conn = cm_id->context;
struct rdsv3_ib_connection *ic = conn->c_transport_data;
struct rdma_conn_param conn_param;
struct rdsv3_ib_connect_private dp;
int ret;
RDSV3_DPRINTF2("rdsv3_ib_cm_initiate_connect", "Enter: cm_id: %p",
cm_id);
/*
* If the peer doesn't do protocol negotiation, we must
* default to RDSv3.0
*/
rdsv3_ib_set_protocol(conn, RDS_PROTOCOL_3_0);
ic->i_flowctl =
rdsv3_ib_sysctl_flow_control; /* advertise flow control */
ret = rdsv3_ib_setup_qp(conn);
if (ret) {
RDSV3_DPRINTF2("rdsv3_ib_cm_initiate_connect",
"rdsv3_ib_setup_qp failed (%d)", ret);
rdsv3_conn_drop(conn);
goto out;
}
rdsv3_ib_cm_fill_conn_param(conn, &conn_param, &dp,
RDS_PROTOCOL_VERSION, UINT_MAX, UINT_MAX);
ret = rdma_connect(cm_id, &conn_param);
if (ret) {
RDSV3_DPRINTF2("rdsv3_ib_cm_initiate_connect",
"rdma_connect failed (%d)", ret);
rdsv3_conn_drop(conn);
}
RDSV3_DPRINTF2("rdsv3_ib_cm_initiate_connect",
"Return: cm_id: %p", cm_id);
out:
/*
* Beware - returning non-zero tells the rdma_cm to destroy
* the cm_id. We should certainly not do it as long as we still
* "own" the cm_id.
*/
if (ret) {
if (ic->i_cm_id == cm_id)
ret = 0;
}
return (ret);
}
int
rdsv3_ib_conn_connect(struct rdsv3_connection *conn)
{
struct rdsv3_ib_connection *ic = conn->c_transport_data;
struct sockaddr_in src, dest;
ipaddr_t laddr, faddr;
int ret;
RDSV3_DPRINTF2("rdsv3_ib_conn_connect", "Enter: conn: %p", conn);
/*
* XXX I wonder what affect the port space has
*/
/* delegate cm event handler to rdma_transport */
ic->i_cm_id = rdma_create_id(rdsv3_rdma_cm_event_handler, conn,
RDMA_PS_TCP);
if (IS_ERR(ic->i_cm_id)) {
ret = PTR_ERR(ic->i_cm_id);
ic->i_cm_id = NULL;
RDSV3_DPRINTF2("rdsv3_ib_conn_connect",
"rdma_create_id() failed: %d", ret);
goto out;
}
RDSV3_DPRINTF3("rdsv3_ib_conn_connect",
"created cm id %p for conn %p", ic->i_cm_id, conn);
/* The ipaddr should be in the network order */
laddr = conn->c_laddr;
faddr = conn->c_faddr;
ret = rdsv3_sc_path_lookup(&laddr, &faddr);
if (ret == 0) {
RDSV3_DPRINTF2(LABEL, "Path not found (0x%x 0x%x)",
ntohl(laddr), ntohl(faddr));
}
src.sin_family = AF_INET;
src.sin_addr.s_addr = (uint32_t)laddr;
src.sin_port = (uint16_t)htons(0);
dest.sin_family = AF_INET;
dest.sin_addr.s_addr = (uint32_t)faddr;
dest.sin_port = (uint16_t)htons(RDSV3_PORT);
ret = rdma_resolve_addr(ic->i_cm_id, (struct sockaddr *)&src,
(struct sockaddr *)&dest,
RDSV3_RDMA_RESOLVE_TIMEOUT_MS);
if (ret) {
RDSV3_DPRINTF2("rdsv3_ib_conn_connect",
"addr resolve failed for cm id %p: %d", ic->i_cm_id, ret);
rdma_destroy_id(ic->i_cm_id);
ic->i_cm_id = NULL;
}
RDSV3_DPRINTF2("rdsv3_ib_conn_connect", "Return: conn: %p", conn);
out:
return (ret);
}
/*
* This is so careful about only cleaning up resources that were built up
* so that it can be called at any point during startup. In fact it
* can be called multiple times for a given connection.
*/
void
rdsv3_ib_conn_shutdown(struct rdsv3_connection *conn)
{
struct rdsv3_ib_connection *ic = conn->c_transport_data;
int err = 0;
RDSV3_DPRINTF2("rdsv3_ib_conn_shutdown",
"cm %p pd %p cq %p qp %p", ic->i_cm_id,
ic->i_pd, ic->i_cq, ic->i_cm_id ? ic->i_cm_id->qp : NULL);
if (ic->i_cm_id) {
struct ib_device *dev = ic->i_cm_id->device;
RDSV3_DPRINTF2("rdsv3_ib_conn_shutdown",
"disconnecting cm %p", ic->i_cm_id);
err = rdma_disconnect(ic->i_cm_id);
if (err) {
/*
* Actually this may happen quite frequently, when
* an outgoing connect raced with an incoming connect.
*/
RDSV3_DPRINTF2("rdsv3_ib_conn_shutdown",
"failed to disconnect, cm: %p err %d",
ic->i_cm_id, err);
}
if (ic->i_cm_id->qp) {
(void) ibt_flush_qp(
ib_get_ibt_channel_hdl(ic->i_cm_id));
/*
* Don't wait for the send ring to be empty -- there
* may be completed non-signaled entries sitting on
* there. We unmap these below.
*/
rdsv3_wait_event(&ic->i_recv_ring.w_empty_wait,
rdsv3_ib_ring_empty(&ic->i_recv_ring));
/*
* Note that Linux original code calls
* rdma_destroy_qp() after rdsv3_ib_recv_clear_ring(ic).
*/
rdma_destroy_qp(ic->i_cm_id);
}
if (rdsv3_enable_snd_cq) {
if (ic->i_snd_soft_cq) {
rdsv3_af_thr_destroy(ic->i_snd_soft_cq);
ic->i_snd_soft_cq = NULL;
}
if (ic->i_snd_cq)
(void) ib_destroy_cq(ic->i_snd_cq);
}
if (ic->i_soft_cq) {
rdsv3_af_thr_destroy(ic->i_soft_cq);
ic->i_soft_cq = NULL;
}
if (ic->i_refill_rq) {
rdsv3_af_thr_destroy(ic->i_refill_rq);
ic->i_refill_rq = NULL;
}
if (ic->i_cq)
(void) ib_destroy_cq(ic->i_cq);
if (ic->i_mr)
rdsv3_ib_free_hdrs(dev, ic);
if (ic->i_sends)
rdsv3_ib_send_clear_ring(ic);
if (ic->i_recvs)
rdsv3_ib_recv_clear_ring(ic);
rdma_destroy_id(ic->i_cm_id);
/*
* Move connection back to the nodev list.
*/
if (ic->i_on_dev_list)
rdsv3_ib_remove_conn(ic->rds_ibdev, conn);
ic->i_cm_id = NULL;
ic->i_pd = NULL;
ic->i_mr = NULL;
ic->i_cq = NULL;
ic->i_snd_cq = NULL;
ic->i_send_hdrs = NULL;
ic->i_recv_hdrs = NULL;
ic->i_ack = NULL;
}
ASSERT(!ic->i_on_dev_list);
/* Clear pending transmit */
if (ic->i_rm) {
rdsv3_message_put(ic->i_rm);
ic->i_rm = NULL;
}
/* Clear the ACK state */
clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
ic->i_ack_next = 0;
ic->i_ack_recv = 0;
/* Clear flow control state */
ic->i_flowctl = 0;
ic->i_credits = 0;
rdsv3_ib_ring_init(&ic->i_send_ring, rdsv3_ib_sysctl_max_send_wr);
rdsv3_ib_ring_init(&ic->i_recv_ring, rdsv3_ib_sysctl_max_recv_wr);
if (ic->i_ibinc) {
rdsv3_inc_put(&ic->i_ibinc->ii_inc);
ic->i_ibinc = NULL;
}
if (ic->i_sends) {
kmem_free(ic->i_sends,
ic->i_send_ring.w_nr * sizeof (struct rdsv3_ib_send_work));
ic->i_sends = NULL;
}
if (ic->i_send_wrs) {
kmem_free(ic->i_send_wrs, ic->i_send_ring.w_nr *
(sizeof (ibt_send_wr_t) +
RDSV3_IB_MAX_SGE * sizeof (ibt_wr_ds_t)));
ic->i_send_wrs = NULL;
}
if (ic->i_recvs) {
kmem_free(ic->i_recvs,
ic->i_recv_ring.w_nr * sizeof (struct rdsv3_ib_recv_work));
ic->i_recvs = NULL;
}
if (ic->i_recv_wrs) {
kmem_free(ic->i_recv_wrs, ic->i_recv_ring.w_nr *
(sizeof (ibt_recv_wr_t)));
ic->i_recv_wrs = NULL;
}
RDSV3_DPRINTF2("rdsv3_ib_conn_shutdown", "Return conn: %p", conn);
}
/* ARGSUSED */
int
rdsv3_ib_conn_alloc(struct rdsv3_connection *conn, int gfp)
{
struct rdsv3_ib_connection *ic;
RDSV3_DPRINTF2("rdsv3_ib_conn_alloc", "conn: %p", conn);
/* XXX too lazy? */
ic = kmem_zalloc(sizeof (struct rdsv3_ib_connection), gfp);
if (!ic)
return (-ENOMEM);
list_link_init(&ic->ib_node);
mutex_init(&ic->i_recv_mutex, NULL, MUTEX_DRIVER, NULL);
mutex_init(&ic->i_ack_lock, NULL, MUTEX_DRIVER, NULL);
/*
* rdsv3_ib_conn_shutdown() waits for these to be emptied so they
* must be initialized before it can be called.
*/
rdsv3_ib_ring_init(&ic->i_send_ring, rdsv3_ib_sysctl_max_send_wr);
rdsv3_ib_ring_init(&ic->i_recv_ring, rdsv3_ib_sysctl_max_recv_wr);
ic->conn = conn;
conn->c_transport_data = ic;
mutex_enter(&ib_nodev_conns_lock);
list_insert_tail(&ib_nodev_conns, ic);
mutex_exit(&ib_nodev_conns_lock);
RDSV3_DPRINTF2("rdsv3_ib_conn_alloc", "conn %p conn ic %p",
conn, conn->c_transport_data);
return (0);
}
/*
* Free a connection. Connection must be shut down and not set for reconnect.
*/
void
rdsv3_ib_conn_free(void *arg)
{
struct rdsv3_ib_connection *ic = arg;
kmutex_t *lock_ptr;
RDSV3_DPRINTF2("rdsv3_ib_conn_free", "ic %p\n", ic);
#ifndef __lock_lint
/*
* Conn is either on a dev's list or on the nodev list.
* A race with shutdown() or connect() would cause problems
* (since rds_ibdev would change) but that should never happen.
*/
lock_ptr = ic->i_on_dev_list ?
&ic->rds_ibdev->spinlock : &ib_nodev_conns_lock;
mutex_enter(lock_ptr);
list_remove_node(&ic->ib_node);
mutex_exit(lock_ptr);
#endif
kmem_free(ic, sizeof (*ic));
}
/*
* An error occurred on the connection
*/
void
__rdsv3_ib_conn_error(struct rdsv3_connection *conn)
{
rdsv3_conn_drop(conn);
}
|