@@ -382,22 +382,24 @@ static int smcr_lgr_reg_rmbs(struct smc_link_group *lgr,
382
382
static int smcr_clnt_conf_first_link (struct smc_sock * smc )
383
383
{
384
384
struct smc_link * link = smc -> conn .lnk ;
385
- int rest ;
385
+ struct smc_llc_qentry * qentry ;
386
386
int rc ;
387
387
388
+ link -> lgr -> type = SMC_LGR_SINGLE ;
389
+
388
390
/* receive CONFIRM LINK request from server over RoCE fabric */
389
- rest = wait_for_completion_interruptible_timeout (
390
- & link -> llc_confirm ,
391
- SMC_LLC_WAIT_FIRST_TIME );
392
- if (rest <= 0 ) {
391
+ qentry = smc_llc_wait (link -> lgr , NULL , SMC_LLC_WAIT_TIME ,
392
+ SMC_LLC_CONFIRM_LINK );
393
+ if (!qentry ) {
393
394
struct smc_clc_msg_decline dclc ;
394
395
395
396
rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
396
397
SMC_CLC_DECLINE , CLC_WAIT_TIME_SHORT );
397
398
return rc == - EAGAIN ? SMC_CLC_DECL_TIMEOUT_CL : rc ;
398
399
}
399
-
400
- if (link -> llc_confirm_rc )
400
+ rc = smc_llc_eval_conf_link (qentry , SMC_LLC_REQ );
401
+ smc_llc_flow_qentry_del (& link -> lgr -> llc_flow_lcl );
402
+ if (rc )
401
403
return SMC_CLC_DECL_RMBE_EC ;
402
404
403
405
rc = smc_ib_modify_qp_rts (link );
@@ -409,31 +411,30 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
409
411
if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc , false))
410
412
return SMC_CLC_DECL_ERR_REGRMB ;
411
413
414
+ /* confirm_rkey is implicit on 1st contact */
415
+ smc -> conn .rmb_desc -> is_conf_rkey = true;
416
+
412
417
/* send CONFIRM LINK response over RoCE fabric */
413
418
rc = smc_llc_send_confirm_link (link , SMC_LLC_RESP );
414
419
if (rc < 0 )
415
420
return SMC_CLC_DECL_TIMEOUT_CL ;
416
421
417
- /* receive ADD LINK request from server over RoCE fabric */
418
- rest = wait_for_completion_interruptible_timeout (& link -> llc_add ,
419
- SMC_LLC_WAIT_TIME );
420
- if (rest <= 0 ) {
422
+ smc_llc_link_active (link );
423
+
424
+ /* optional 2nd link, receive ADD LINK request from server */
425
+ qentry = smc_llc_wait (link -> lgr , NULL , SMC_LLC_WAIT_TIME ,
426
+ SMC_LLC_ADD_LINK );
427
+ if (!qentry ) {
421
428
struct smc_clc_msg_decline dclc ;
422
429
423
430
rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
424
431
SMC_CLC_DECLINE , CLC_WAIT_TIME_SHORT );
425
- return rc == - EAGAIN ? SMC_CLC_DECL_TIMEOUT_AL : rc ;
432
+ if (rc == - EAGAIN )
433
+ rc = 0 ; /* no DECLINE received, go with one link */
434
+ return rc ;
426
435
}
427
-
428
- /* send add link reject message, only one link supported for now */
429
- rc = smc_llc_send_add_link (link ,
430
- link -> smcibdev -> mac [link -> ibport - 1 ],
431
- link -> gid , SMC_LLC_RESP );
432
- if (rc < 0 )
433
- return SMC_CLC_DECL_TIMEOUT_AL ;
434
-
435
- smc_llc_link_active (link );
436
-
436
+ smc_llc_flow_qentry_clr (& link -> lgr -> llc_flow_lcl );
437
+ /* tbd: call smc_llc_cli_add_link(link, qentry); */
437
438
return 0 ;
438
439
}
439
440
@@ -613,8 +614,8 @@ static int smc_connect_rdma(struct smc_sock *smc,
613
614
struct smc_clc_msg_accept_confirm * aclc ,
614
615
struct smc_init_info * ini )
615
616
{
617
+ int i , reason_code = 0 ;
616
618
struct smc_link * link ;
617
- int reason_code = 0 ;
618
619
619
620
ini -> is_smcd = false;
620
621
ini -> ib_lcl = & aclc -> lcl ;
@@ -627,10 +628,28 @@ static int smc_connect_rdma(struct smc_sock *smc,
627
628
mutex_unlock (& smc_client_lgr_pending );
628
629
return reason_code ;
629
630
}
630
- link = smc -> conn .lnk ;
631
631
632
632
smc_conn_save_peer_info (smc , aclc );
633
633
634
+ if (ini -> cln_first_contact == SMC_FIRST_CONTACT ) {
635
+ link = smc -> conn .lnk ;
636
+ } else {
637
+ /* set link that was assigned by server */
638
+ link = NULL ;
639
+ for (i = 0 ; i < SMC_LINKS_PER_LGR_MAX ; i ++ ) {
640
+ struct smc_link * l = & smc -> conn .lgr -> lnk [i ];
641
+
642
+ if (l -> peer_qpn == ntoh24 (aclc -> qpn )) {
643
+ link = l ;
644
+ break ;
645
+ }
646
+ }
647
+ if (!link )
648
+ return smc_connect_abort (smc , SMC_CLC_DECL_NOSRVLINK ,
649
+ ini -> cln_first_contact );
650
+ smc -> conn .lnk = link ;
651
+ }
652
+
634
653
/* create send buffer and rmb */
635
654
if (smc_buf_create (smc , false))
636
655
return smc_connect_abort (smc , SMC_CLC_DECL_MEM ,
@@ -666,7 +685,9 @@ static int smc_connect_rdma(struct smc_sock *smc,
666
685
667
686
if (ini -> cln_first_contact == SMC_FIRST_CONTACT ) {
668
687
/* QP confirmation over RoCE fabric */
688
+ smc_llc_flow_initiate (link -> lgr , SMC_LLC_FLOW_ADD_LINK );
669
689
reason_code = smcr_clnt_conf_first_link (smc );
690
+ smc_llc_flow_stop (link -> lgr , & link -> lgr -> llc_flow_lcl );
670
691
if (reason_code )
671
692
return smc_connect_abort (smc , reason_code ,
672
693
ini -> cln_first_contact );
@@ -1019,9 +1040,11 @@ void smc_close_non_accepted(struct sock *sk)
1019
1040
static int smcr_serv_conf_first_link (struct smc_sock * smc )
1020
1041
{
1021
1042
struct smc_link * link = smc -> conn .lnk ;
1022
- int rest ;
1043
+ struct smc_llc_qentry * qentry ;
1023
1044
int rc ;
1024
1045
1046
+ link -> lgr -> type = SMC_LGR_SINGLE ;
1047
+
1025
1048
if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc , false))
1026
1049
return SMC_CLC_DECL_ERR_REGRMB ;
1027
1050
@@ -1031,40 +1054,27 @@ static int smcr_serv_conf_first_link(struct smc_sock *smc)
1031
1054
return SMC_CLC_DECL_TIMEOUT_CL ;
1032
1055
1033
1056
/* receive CONFIRM LINK response from client over the RoCE fabric */
1034
- rest = wait_for_completion_interruptible_timeout (
1035
- & link -> llc_confirm_resp ,
1036
- SMC_LLC_WAIT_FIRST_TIME );
1037
- if (rest <= 0 ) {
1057
+ qentry = smc_llc_wait (link -> lgr , link , SMC_LLC_WAIT_TIME ,
1058
+ SMC_LLC_CONFIRM_LINK );
1059
+ if (!qentry ) {
1038
1060
struct smc_clc_msg_decline dclc ;
1039
1061
1040
1062
rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
1041
1063
SMC_CLC_DECLINE , CLC_WAIT_TIME_SHORT );
1042
1064
return rc == - EAGAIN ? SMC_CLC_DECL_TIMEOUT_CL : rc ;
1043
1065
}
1044
-
1045
- if (link -> llc_confirm_resp_rc )
1066
+ rc = smc_llc_eval_conf_link (qentry , SMC_LLC_RESP );
1067
+ smc_llc_flow_qentry_del (& link -> lgr -> llc_flow_lcl );
1068
+ if (rc )
1046
1069
return SMC_CLC_DECL_RMBE_EC ;
1047
1070
1048
- /* send ADD LINK request to client over the RoCE fabric */
1049
- rc = smc_llc_send_add_link (link ,
1050
- link -> smcibdev -> mac [link -> ibport - 1 ],
1051
- link -> gid , SMC_LLC_REQ );
1052
- if (rc < 0 )
1053
- return SMC_CLC_DECL_TIMEOUT_AL ;
1054
-
1055
- /* receive ADD LINK response from client over the RoCE fabric */
1056
- rest = wait_for_completion_interruptible_timeout (& link -> llc_add_resp ,
1057
- SMC_LLC_WAIT_TIME );
1058
- if (rest <= 0 ) {
1059
- struct smc_clc_msg_decline dclc ;
1060
-
1061
- rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
1062
- SMC_CLC_DECLINE , CLC_WAIT_TIME_SHORT );
1063
- return rc == - EAGAIN ? SMC_CLC_DECL_TIMEOUT_AL : rc ;
1064
- }
1071
+ /* confirm_rkey is implicit on 1st contact */
1072
+ smc -> conn .rmb_desc -> is_conf_rkey = true;
1065
1073
1066
1074
smc_llc_link_active (link );
1067
1075
1076
+ /* initial contact - try to establish second link */
1077
+ /* tbd: call smc_llc_srv_add_link(link); */
1068
1078
return 0 ;
1069
1079
}
1070
1080
@@ -1240,7 +1250,9 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,
1240
1250
goto decline ;
1241
1251
}
1242
1252
/* QP confirmation over RoCE fabric */
1253
+ smc_llc_flow_initiate (link -> lgr , SMC_LLC_FLOW_ADD_LINK );
1243
1254
reason_code = smcr_serv_conf_first_link (new_smc );
1255
+ smc_llc_flow_stop (link -> lgr , & link -> lgr -> llc_flow_lcl );
1244
1256
if (reason_code )
1245
1257
goto decline ;
1246
1258
}
0 commit comments