Skip to content

Commit 0fb0b02

Browse files
karstengrdavem330
authored andcommitted
net/smc: adapt SMC client code to use the LLC flow
Change the code that processes the SMC client part of connection establishment to use the LLC flow framework (CONFIRM_LINK request messages). Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Reviewed-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4667bb4 commit 0fb0b02

File tree

4 files changed

+71
-74
lines changed

4 files changed

+71
-74
lines changed

net/smc/af_smc.c

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,24 @@ static int smcr_lgr_reg_rmbs(struct smc_link_group *lgr,
382382
static 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);

net/smc/smc_clc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define SMC_CLC_DECL_GETVLANERR 0x03080000 /* err to get vlan id of ip device*/
4646
#define SMC_CLC_DECL_ISMVLANERR 0x03090000 /* err to reg vlan id on ism dev */
4747
#define SMC_CLC_DECL_NOACTLINK 0x030a0000 /* no active smc-r link in lgr */
48+
#define SMC_CLC_DECL_NOSRVLINK 0x030b0000 /* SMC-R link from srv not found */
4849
#define SMC_CLC_DECL_SYNCERR 0x04000000 /* synchronization error */
4950
#define SMC_CLC_DECL_PEERDECL 0x05000000 /* peer declined during handshake */
5051
#define SMC_CLC_DECL_INTERR 0x09990000 /* internal error */

net/smc/smc_core.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ struct smc_link {
120120
struct smc_link_group *lgr; /* parent link group */
121121

122122
enum smc_link_state state; /* state of link */
123-
struct completion llc_confirm; /* wait for rx of conf link */
124-
int llc_confirm_rc; /* rc from confirm link msg */
125-
struct completion llc_add; /* wait for rx of add link */
126123
struct delayed_work llc_testlink_wrk; /* testlink worker */
127124
struct completion llc_testlink_resp; /* wait for rx of testlink */
128125
int llc_testlink_time; /* testlink interval */

net/smc/smc_llc.c

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -528,47 +528,6 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf)
528528

529529
/********************************* receive ***********************************/
530530

531-
static void smc_llc_rx_confirm_link(struct smc_link *link,
532-
struct smc_llc_msg_confirm_link *llc)
533-
{
534-
struct smc_link_group *lgr = smc_get_lgr(link);
535-
int conf_rc = 0;
536-
537-
/* RMBE eyecatchers are not supported */
538-
if (!(llc->hd.flags & SMC_LLC_FLAG_NO_RMBE_EYEC))
539-
conf_rc = ENOTSUPP;
540-
541-
if (lgr->role == SMC_CLNT &&
542-
link->state == SMC_LNK_ACTIVATING) {
543-
link->llc_confirm_rc = conf_rc;
544-
link->link_id = llc->link_num;
545-
complete(&link->llc_confirm);
546-
}
547-
}
548-
549-
static void smc_llc_rx_add_link(struct smc_link *link,
550-
struct smc_llc_msg_add_link *llc)
551-
{
552-
struct smc_link_group *lgr = smc_get_lgr(link);
553-
554-
if (link->state == SMC_LNK_ACTIVATING) {
555-
complete(&link->llc_add);
556-
return;
557-
}
558-
559-
if (lgr->role == SMC_SERV) {
560-
smc_llc_prep_add_link(llc, link,
561-
link->smcibdev->mac[link->ibport - 1],
562-
link->gid, SMC_LLC_REQ);
563-
564-
} else {
565-
smc_llc_prep_add_link(llc, link,
566-
link->smcibdev->mac[link->ibport - 1],
567-
link->gid, SMC_LLC_RESP);
568-
}
569-
smc_llc_send_message(link, llc);
570-
}
571-
572531
static void smc_llc_rx_delete_link(struct smc_link *link,
573532
struct smc_llc_msg_del_link *llc)
574533
{
@@ -657,6 +616,7 @@ static void smc_llc_event_handler(struct smc_llc_qentry *qentry)
657616
{
658617
union smc_llc_msg *llc = &qentry->msg;
659618
struct smc_link *link = qentry->link;
619+
struct smc_link_group *lgr = link->lgr;
660620

661621
if (!smc_link_usable(link))
662622
goto out;
@@ -665,11 +625,31 @@ static void smc_llc_event_handler(struct smc_llc_qentry *qentry)
665625
case SMC_LLC_TEST_LINK:
666626
smc_llc_rx_test_link(link, &llc->test_link);
667627
break;
668-
case SMC_LLC_CONFIRM_LINK:
669-
smc_llc_rx_confirm_link(link, &llc->confirm_link);
670-
break;
671628
case SMC_LLC_ADD_LINK:
672-
smc_llc_rx_add_link(link, &llc->add_link);
629+
if (list_empty(&lgr->list))
630+
goto out; /* lgr is terminating */
631+
if (lgr->role == SMC_CLNT) {
632+
if (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_ADD_LINK) {
633+
/* a flow is waiting for this message */
634+
smc_llc_flow_qentry_set(&lgr->llc_flow_lcl,
635+
qentry);
636+
wake_up_interruptible(&lgr->llc_waiter);
637+
} else if (smc_llc_flow_start(&lgr->llc_flow_lcl,
638+
qentry)) {
639+
/* tbd: schedule_work(&lgr->llc_add_link_work); */
640+
}
641+
} else if (smc_llc_flow_start(&lgr->llc_flow_lcl, qentry)) {
642+
/* as smc server, handle client suggestion */
643+
/* tbd: schedule_work(&lgr->llc_add_link_work); */
644+
}
645+
return;
646+
case SMC_LLC_CONFIRM_LINK:
647+
if (lgr->llc_flow_lcl.type != SMC_LLC_FLOW_NONE) {
648+
/* a flow is waiting for this message */
649+
smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, qentry);
650+
wake_up_interruptible(&lgr->llc_waiter);
651+
return;
652+
}
673653
break;
674654
case SMC_LLC_DELETE_LINK:
675655
smc_llc_rx_delete_link(link, &llc->delete_link);
@@ -857,8 +837,6 @@ void smc_llc_lgr_clear(struct smc_link_group *lgr)
857837

858838
int smc_llc_link_init(struct smc_link *link)
859839
{
860-
init_completion(&link->llc_confirm);
861-
init_completion(&link->llc_add);
862840
init_completion(&link->llc_confirm_rkey_resp);
863841
init_completion(&link->llc_delete_rkey_resp);
864842
mutex_init(&link->llc_delete_rkey_mutex);

0 commit comments

Comments
 (0)