@@ -382,22 +382,24 @@ static int smcr_lgr_reg_rmbs(struct smc_link_group *lgr,
382382static int smcr_clnt_conf_first_link (struct smc_sock * smc )
383383{
384384 struct smc_link * link = smc -> conn .lnk ;
385- int rest ;
385+ struct smc_llc_qentry * qentry ;
386386 int rc ;
387387
388+ link -> lgr -> type = SMC_LGR_SINGLE ;
389+
388390 /* 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 ) {
393394 struct smc_clc_msg_decline dclc ;
394395
395396 rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
396397 SMC_CLC_DECLINE , CLC_WAIT_TIME_SHORT );
397398 return rc == - EAGAIN ? SMC_CLC_DECL_TIMEOUT_CL : rc ;
398399 }
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 )
401403 return SMC_CLC_DECL_RMBE_EC ;
402404
403405 rc = smc_ib_modify_qp_rts (link );
@@ -409,31 +411,30 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
409411 if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc , false))
410412 return SMC_CLC_DECL_ERR_REGRMB ;
411413
414+ /* confirm_rkey is implicit on 1st contact */
415+ smc -> conn .rmb_desc -> is_conf_rkey = true;
416+
412417 /* send CONFIRM LINK response over RoCE fabric */
413418 rc = smc_llc_send_confirm_link (link , SMC_LLC_RESP );
414419 if (rc < 0 )
415420 return SMC_CLC_DECL_TIMEOUT_CL ;
416421
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 ) {
421428 struct smc_clc_msg_decline dclc ;
422429
423430 rc = smc_clc_wait_msg (smc , & dclc , sizeof (dclc ),
424431 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 ;
426435 }
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); */
437438 return 0 ;
438439}
439440
@@ -613,8 +614,8 @@ static int smc_connect_rdma(struct smc_sock *smc,
613614 struct smc_clc_msg_accept_confirm * aclc ,
614615 struct smc_init_info * ini )
615616{
617+ int i , reason_code = 0 ;
616618 struct smc_link * link ;
617- int reason_code = 0 ;
618619
619620 ini -> is_smcd = false;
620621 ini -> ib_lcl = & aclc -> lcl ;
@@ -627,10 +628,28 @@ static int smc_connect_rdma(struct smc_sock *smc,
627628 mutex_unlock (& smc_client_lgr_pending );
628629 return reason_code ;
629630 }
630- link = smc -> conn .lnk ;
631631
632632 smc_conn_save_peer_info (smc , aclc );
633633
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+
634653 /* create send buffer and rmb */
635654 if (smc_buf_create (smc , false))
636655 return smc_connect_abort (smc , SMC_CLC_DECL_MEM ,
@@ -666,7 +685,9 @@ static int smc_connect_rdma(struct smc_sock *smc,
666685
667686 if (ini -> cln_first_contact == SMC_FIRST_CONTACT ) {
668687 /* QP confirmation over RoCE fabric */
688+ smc_llc_flow_initiate (link -> lgr , SMC_LLC_FLOW_ADD_LINK );
669689 reason_code = smcr_clnt_conf_first_link (smc );
690+ smc_llc_flow_stop (link -> lgr , & link -> lgr -> llc_flow_lcl );
670691 if (reason_code )
671692 return smc_connect_abort (smc , reason_code ,
672693 ini -> cln_first_contact );
0 commit comments