Skip to content

Commit 2d2209f

Browse files
karstengrdavem330
authored andcommitted
net/smc: first part of add link processing as SMC server
First set of functions to process an ADD_LINK LLC request as an SMC server. Find an alternate IB device, determine the new link group type and get the index for the new link. Then initialize the link and send the ADD_LINK LLC message to the peer. Save the contents of the response, ready the link, map all used buffers and register the buffers with the IB device. If any error occurs, stop the processing and clear the link. And call smc_llc_srv_add_link() in af_smc.c to start second link establishment after the initial link of a link group was created. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b1570a8 commit 2d2209f

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed

net/smc/af_smc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ static int smcr_serv_conf_first_link(struct smc_sock *smc)
10671067
smc_llc_link_active(link);
10681068

10691069
/* initial contact - try to establish second link */
1070-
/* tbd: call smc_llc_srv_add_link(link); */
1070+
smc_llc_srv_add_link(link);
10711071
return 0;
10721072
}
10731073

net/smc/smc_llc.c

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,94 @@ static void smc_llc_process_cli_add_link(struct smc_link_group *lgr)
863863
mutex_unlock(&lgr->llc_conf_mutex);
864864
}
865865

866+
int smc_llc_srv_add_link(struct smc_link *link)
867+
{
868+
enum smc_lgr_type lgr_new_t = SMC_LGR_SYMMETRIC;
869+
struct smc_link_group *lgr = link->lgr;
870+
struct smc_llc_msg_add_link *add_llc;
871+
struct smc_llc_qentry *qentry = NULL;
872+
struct smc_link *link_new;
873+
struct smc_init_info ini;
874+
int lnk_idx, rc = 0;
875+
876+
/* ignore client add link recommendation, start new flow */
877+
ini.vlan_id = lgr->vlan_id;
878+
smc_pnet_find_alt_roce(lgr, &ini, link->smcibdev);
879+
if (!ini.ib_dev) {
880+
lgr_new_t = SMC_LGR_ASYMMETRIC_LOCAL;
881+
ini.ib_dev = link->smcibdev;
882+
ini.ib_port = link->ibport;
883+
}
884+
lnk_idx = smc_llc_alloc_alt_link(lgr, lgr_new_t);
885+
if (lnk_idx < 0)
886+
return 0;
887+
888+
rc = smcr_link_init(lgr, &lgr->lnk[lnk_idx], lnk_idx, &ini);
889+
if (rc)
890+
return rc;
891+
link_new = &lgr->lnk[lnk_idx];
892+
rc = smc_llc_send_add_link(link,
893+
link_new->smcibdev->mac[ini.ib_port - 1],
894+
link_new->gid, link_new, SMC_LLC_REQ);
895+
if (rc)
896+
goto out_err;
897+
/* receive ADD LINK response over the RoCE fabric */
898+
qentry = smc_llc_wait(lgr, link, SMC_LLC_WAIT_TIME, SMC_LLC_ADD_LINK);
899+
if (!qentry) {
900+
rc = -ETIMEDOUT;
901+
goto out_err;
902+
}
903+
add_llc = &qentry->msg.add_link;
904+
if (add_llc->hd.flags & SMC_LLC_FLAG_ADD_LNK_REJ) {
905+
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
906+
rc = -ENOLINK;
907+
goto out_err;
908+
}
909+
if (lgr->type == SMC_LGR_SINGLE &&
910+
(!memcmp(add_llc->sender_gid, link->peer_gid, SMC_GID_SIZE) &&
911+
!memcmp(add_llc->sender_mac, link->peer_mac, ETH_ALEN))) {
912+
lgr_new_t = SMC_LGR_ASYMMETRIC_PEER;
913+
}
914+
smc_llc_save_add_link_info(link_new, add_llc);
915+
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
916+
917+
rc = smc_ib_ready_link(link_new);
918+
if (rc)
919+
goto out_err;
920+
rc = smcr_buf_map_lgr(link_new);
921+
if (rc)
922+
goto out_err;
923+
rc = smcr_buf_reg_lgr(link_new);
924+
if (rc)
925+
goto out_err;
926+
/* tbd: rc = smc_llc_srv_rkey_exchange(link, link_new); */
927+
if (rc)
928+
goto out_err;
929+
/* tbd: rc = smc_llc_srv_conf_link(link, link_new, lgr_new_t); */
930+
if (rc)
931+
goto out_err;
932+
return 0;
933+
out_err:
934+
smcr_link_clear(link_new);
935+
return rc;
936+
}
937+
938+
static void smc_llc_process_srv_add_link(struct smc_link_group *lgr)
939+
{
940+
struct smc_link *link = lgr->llc_flow_lcl.qentry->link;
941+
int rc;
942+
943+
smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
944+
945+
mutex_lock(&lgr->llc_conf_mutex);
946+
rc = smc_llc_srv_add_link(link);
947+
if (!rc && lgr->type == SMC_LGR_SYMMETRIC) {
948+
/* delete any asymmetric link */
949+
/* tbd: smc_llc_delete_asym_link(lgr); */
950+
}
951+
mutex_unlock(&lgr->llc_conf_mutex);
952+
}
953+
866954
/* worker to process an add link message */
867955
static void smc_llc_add_link_work(struct work_struct *work)
868956
{
@@ -877,7 +965,8 @@ static void smc_llc_add_link_work(struct work_struct *work)
877965

878966
if (lgr->role == SMC_CLNT)
879967
smc_llc_process_cli_add_link(lgr);
880-
/* tbd: call smc_llc_process_srv_add_link(lgr); */
968+
else
969+
smc_llc_process_srv_add_link(lgr);
881970
out:
882971
smc_llc_flow_stop(lgr, &lgr->llc_flow_lcl);
883972
}

net/smc/smc_llc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct smc_llc_qentry *smc_llc_wait(struct smc_link_group *lgr,
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);
9191
int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry);
92+
int smc_llc_srv_add_link(struct smc_link *link);
9293
int smc_llc_init(void) __init;
9394

9495
#endif /* SMC_LLC_H */

0 commit comments

Comments
 (0)