Skip to content

Commit b1570a8

Browse files
karstengrdavem330
authored andcommitted
net/smc: final part of add link processing as SMC client
This patch finalizes the ADD_LINK processing of new links. Receive the CONFIRM_LINK request from peer, complete the link initialization, register all used buffers with the IB device and finally send the CONFIRM_LINK response, which completes the ADD_LINK processing. And activate smc_llc_cli_add_link() in af_smc.c. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 87f88cd commit b1570a8

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

net/smc/af_smc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
427427
return rc;
428428
}
429429
smc_llc_flow_qentry_clr(&link->lgr->llc_flow_lcl);
430-
/* tbd: call smc_llc_cli_add_link(link, qentry); */
430+
smc_llc_cli_add_link(link, qentry);
431431
return 0;
432432
}
433433

net/smc/smc_llc.c

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int smc_llc_send_confirm_link(struct smc_link *link,
381381
hton24(confllc->sender_qp_num, link->roce_qp->qp_num);
382382
confllc->link_num = link->link_id;
383383
memcpy(confllc->link_uid, lgr->id, SMC_LGR_ID_SIZE);
384-
confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS; /* enforce peer resp. */
384+
confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS;
385385
/* send llc message */
386386
rc = smc_wr_tx_send(link, pend);
387387
return rc;
@@ -724,6 +724,61 @@ static int smc_llc_cli_add_link_reject(struct smc_llc_qentry *qentry)
724724
return smc_llc_send_message(qentry->link, &qentry->msg);
725725
}
726726

727+
static int smc_llc_cli_conf_link(struct smc_link *link,
728+
struct smc_init_info *ini,
729+
struct smc_link *link_new,
730+
enum smc_lgr_type lgr_new_t)
731+
{
732+
struct smc_link_group *lgr = link->lgr;
733+
struct smc_llc_msg_del_link *del_llc;
734+
struct smc_llc_qentry *qentry = NULL;
735+
int rc = 0;
736+
737+
/* receive CONFIRM LINK request over RoCE fabric */
738+
qentry = smc_llc_wait(lgr, NULL, SMC_LLC_WAIT_FIRST_TIME, 0);
739+
if (!qentry) {
740+
rc = smc_llc_send_delete_link(link, link_new->link_id,
741+
SMC_LLC_REQ, false,
742+
SMC_LLC_DEL_LOST_PATH);
743+
return -ENOLINK;
744+
}
745+
if (qentry->msg.raw.hdr.common.type != SMC_LLC_CONFIRM_LINK) {
746+
/* received DELETE_LINK instead */
747+
del_llc = &qentry->msg.delete_link;
748+
qentry->msg.raw.hdr.flags |= SMC_LLC_FLAG_RESP;
749+
smc_llc_send_message(link, &qentry->msg);
750+
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
751+
return -ENOLINK;
752+
}
753+
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
754+
755+
rc = smc_ib_modify_qp_rts(link_new);
756+
if (rc) {
757+
smc_llc_send_delete_link(link, link_new->link_id, SMC_LLC_REQ,
758+
false, SMC_LLC_DEL_LOST_PATH);
759+
return -ENOLINK;
760+
}
761+
smc_wr_remember_qp_attr(link_new);
762+
763+
rc = smcr_buf_reg_lgr(link_new);
764+
if (rc) {
765+
smc_llc_send_delete_link(link, link_new->link_id, SMC_LLC_REQ,
766+
false, SMC_LLC_DEL_LOST_PATH);
767+
return -ENOLINK;
768+
}
769+
770+
/* send CONFIRM LINK response over RoCE fabric */
771+
rc = smc_llc_send_confirm_link(link_new, SMC_LLC_RESP);
772+
if (rc) {
773+
smc_llc_send_delete_link(link, link_new->link_id, SMC_LLC_REQ,
774+
false, SMC_LLC_DEL_LOST_PATH);
775+
return -ENOLINK;
776+
}
777+
smc_llc_link_active(link_new);
778+
lgr->type = lgr_new_t;
779+
return 0;
780+
}
781+
727782
static void smc_llc_save_add_link_info(struct smc_link *link,
728783
struct smc_llc_msg_add_link *add_llc)
729784
{
@@ -785,7 +840,7 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
785840
rc = 0;
786841
goto out_clear_lnk;
787842
}
788-
/* tbd: rc = smc_llc_cli_conf_link(link, &ini, lnk_new, lgr_new_t); */
843+
rc = smc_llc_cli_conf_link(link, &ini, lnk_new, lgr_new_t);
789844
if (!rc)
790845
goto out;
791846
out_clear_lnk:
@@ -797,6 +852,17 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
797852
return rc;
798853
}
799854

855+
static void smc_llc_process_cli_add_link(struct smc_link_group *lgr)
856+
{
857+
struct smc_llc_qentry *qentry;
858+
859+
qentry = smc_llc_flow_qentry_clr(&lgr->llc_flow_lcl);
860+
861+
mutex_lock(&lgr->llc_conf_mutex);
862+
smc_llc_cli_add_link(qentry->link, qentry);
863+
mutex_unlock(&lgr->llc_conf_mutex);
864+
}
865+
800866
/* worker to process an add link message */
801867
static void smc_llc_add_link_work(struct work_struct *work)
802868
{
@@ -809,7 +875,8 @@ static void smc_llc_add_link_work(struct work_struct *work)
809875
goto out;
810876
}
811877

812-
/* tbd: call smc_llc_process_cli_add_link(lgr); */
878+
if (lgr->role == SMC_CLNT)
879+
smc_llc_process_cli_add_link(lgr);
813880
/* tbd: call smc_llc_process_srv_add_link(lgr); */
814881
out:
815882
smc_llc_flow_stop(lgr, &lgr->llc_flow_lcl);

net/smc/smc_llc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
8888
int time_out, u8 exp_msg);
8989
struct smc_llc_qentry *smc_llc_flow_qentry_clr(struct smc_llc_flow *flow);
9090
void smc_llc_flow_qentry_del(struct smc_llc_flow *flow);
91+
int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry);
9192
int smc_llc_init(void) __init;
9293

9394
#endif /* SMC_LLC_H */

0 commit comments

Comments
 (0)