Skip to content

Commit 69b888e

Browse files
GuangguanWangdavem330
authored andcommitted
net/smc: support max links per lgr negotiation in clc handshake
Support max links per lgr negotiation in clc handshake for SMCR v2.1, which is one of smc v2.1 features. Server makes decision for the final value of max links based on the client preferred max links and self-preferred max links. Here use the minimum value of the client preferred max links and server preferred max links. Client Server Proposal(max links(client preferred)) --------------------------------------> Accept(max links(accepted value)) accepted value=min(client preferred, server preferred) <------------------------------------- Confirm(max links(accepted value)) -------------------------------------> Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com> Reviewed-by: Tony Lu <tonylu@linux.alibaba.com> Reviewed-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7f0620b commit 69b888e

File tree

6 files changed

+82
-24
lines changed

6 files changed

+82
-24
lines changed

net/smc/af_smc.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -641,20 +641,22 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
641641
smc_llc_link_active(link);
642642
smcr_lgr_set_type(link->lgr, SMC_LGR_SINGLE);
643643

644-
/* optional 2nd link, receive ADD LINK request from server */
645-
qentry = smc_llc_wait(link->lgr, NULL, SMC_LLC_WAIT_TIME,
646-
SMC_LLC_ADD_LINK);
647-
if (!qentry) {
648-
struct smc_clc_msg_decline dclc;
649-
650-
rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc),
651-
SMC_CLC_DECLINE, CLC_WAIT_TIME_SHORT);
652-
if (rc == -EAGAIN)
653-
rc = 0; /* no DECLINE received, go with one link */
654-
return rc;
644+
if (link->lgr->max_links > 1) {
645+
/* optional 2nd link, receive ADD LINK request from server */
646+
qentry = smc_llc_wait(link->lgr, NULL, SMC_LLC_WAIT_TIME,
647+
SMC_LLC_ADD_LINK);
648+
if (!qentry) {
649+
struct smc_clc_msg_decline dclc;
650+
651+
rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc),
652+
SMC_CLC_DECLINE, CLC_WAIT_TIME_SHORT);
653+
if (rc == -EAGAIN)
654+
rc = 0; /* no DECLINE received, go with one link */
655+
return rc;
656+
}
657+
smc_llc_flow_qentry_clr(&link->lgr->llc_flow_lcl);
658+
smc_llc_cli_add_link(link, qentry);
655659
}
656-
smc_llc_flow_qentry_clr(&link->lgr->llc_flow_lcl);
657-
smc_llc_cli_add_link(link, qentry);
658660
return 0;
659661
}
660662

@@ -1243,6 +1245,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
12431245
memcpy(ini->peer_gid, aclc->r0.lcl.gid, SMC_GID_SIZE);
12441246
memcpy(ini->peer_mac, aclc->r0.lcl.mac, ETH_ALEN);
12451247
ini->max_conns = SMC_CONN_PER_LGR_MAX;
1248+
ini->max_links = SMC_LINKS_ADD_LNK_MAX;
12461249

12471250
reason_code = smc_connect_rdma_v2_prepare(smc, aclc, ini);
12481251
if (reason_code)
@@ -1887,10 +1890,12 @@ static int smcr_serv_conf_first_link(struct smc_sock *smc)
18871890
smc_llc_link_active(link);
18881891
smcr_lgr_set_type(link->lgr, SMC_LGR_SINGLE);
18891892

1890-
down_write(&link->lgr->llc_conf_mutex);
1891-
/* initial contact - try to establish second link */
1892-
smc_llc_srv_add_link(link, NULL);
1893-
up_write(&link->lgr->llc_conf_mutex);
1893+
if (link->lgr->max_links > 1) {
1894+
down_write(&link->lgr->llc_conf_mutex);
1895+
/* initial contact - try to establish second link */
1896+
smc_llc_srv_add_link(link, NULL);
1897+
up_write(&link->lgr->llc_conf_mutex);
1898+
}
18941899
return 0;
18951900
}
18961901

@@ -2494,6 +2499,11 @@ static void smc_listen_work(struct work_struct *work)
24942499
goto out_decl;
24952500
}
24962501

2502+
/* fce smc release version is needed in smc_listen_rdma_finish,
2503+
* so save fce info here.
2504+
*/
2505+
smc_conn_save_peer_info_fce(new_smc, cclc);
2506+
24972507
/* finish worker */
24982508
if (!ini->is_smcd) {
24992509
rc = smc_listen_rdma_finish(new_smc, cclc,

net/smc/smc_clc.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,10 @@ static int smc_clc_fill_fce(struct smc_clc_first_contact_ext_v2x *fce,
433433
}
434434

435435
if (ini->release_nr >= SMC_RELEASE_1) {
436-
if (!ini->is_smcd)
436+
if (!ini->is_smcd) {
437437
fce->max_conns = ini->max_conns;
438+
fce->max_links = ini->max_links;
439+
}
438440
}
439441

440442
out:
@@ -942,6 +944,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
942944
if (smcr_indicated(ini->smc_type_v2)) {
943945
memcpy(v2_ext->roce, ini->smcrv2.ib_gid_v2, SMC_GID_SIZE);
944946
v2_ext->max_conns = SMC_CONN_PER_LGR_PREFER;
947+
v2_ext->max_links = SMC_LINKS_PER_LGR_MAX_PREFER;
945948
}
946949

947950
pclc_base->hdr.length = htons(plen);
@@ -1174,6 +1177,7 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11741177
struct smc_clc_v2_extension *pclc_v2_ext;
11751178

11761179
ini->max_conns = SMC_CONN_PER_LGR_MAX;
1180+
ini->max_links = SMC_LINKS_ADD_LNK_MAX;
11771181

11781182
if ((!(ini->smcd_version & SMC_V2) && !(ini->smcr_version & SMC_V2)) ||
11791183
ini->release_nr < SMC_RELEASE_1)
@@ -1187,6 +1191,10 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11871191
ini->max_conns = min_t(u8, pclc_v2_ext->max_conns, SMC_CONN_PER_LGR_PREFER);
11881192
if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
11891193
return SMC_CLC_DECL_MAXCONNERR;
1194+
1195+
ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
1196+
if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
1197+
return SMC_CLC_DECL_MAXLINKERR;
11901198
}
11911199

11921200
return 0;
@@ -1205,6 +1213,11 @@ int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
12051213
if (fce_v2x->max_conns < SMC_CONN_PER_LGR_MIN)
12061214
return SMC_CLC_DECL_MAXCONNERR;
12071215
ini->max_conns = fce_v2x->max_conns;
1216+
1217+
if (fce_v2x->max_links > SMC_LINKS_ADD_LNK_MAX ||
1218+
fce_v2x->max_links < SMC_LINKS_ADD_LNK_MIN)
1219+
return SMC_CLC_DECL_MAXLINKERR;
1220+
ini->max_links = fce_v2x->max_links;
12081221
}
12091222

12101223
return 0;
@@ -1233,6 +1246,8 @@ int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc,
12331246
if (!ini->is_smcd) {
12341247
if (fce_v2x->max_conns != ini->max_conns)
12351248
return SMC_CLC_DECL_MAXCONNERR;
1249+
if (fce_v2x->max_links != ini->max_links)
1250+
return SMC_CLC_DECL_MAXLINKERR;
12361251
}
12371252

12381253
return 0;

net/smc/smc_clc.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define SMC_CLC_DECL_NOUEID 0x03030008 /* peer sent no UEID */
4848
#define SMC_CLC_DECL_RELEASEERR 0x03030009 /* release version negotiate failed */
4949
#define SMC_CLC_DECL_MAXCONNERR 0x0303000a /* max connections negotiate failed */
50+
#define SMC_CLC_DECL_MAXLINKERR 0x0303000b /* max links negotiate failed */
5051
#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/
5152
#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */
5253
#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */
@@ -136,7 +137,8 @@ struct smc_clc_v2_extension {
136137
struct smc_clnt_opts_area_hdr hdr;
137138
u8 roce[16]; /* RoCEv2 GID */
138139
u8 max_conns;
139-
u8 reserved[15];
140+
u8 max_links;
141+
u8 reserved[14];
140142
u8 user_eids[][SMC_MAX_EID_LEN];
141143
};
142144

@@ -239,7 +241,8 @@ struct smc_clc_first_contact_ext {
239241
struct smc_clc_first_contact_ext_v2x {
240242
struct smc_clc_first_contact_ext fce_v2_base;
241243
u8 max_conns; /* for SMC-R only */
242-
u8 reserved3[3];
244+
u8 max_links; /* for SMC-R only */
245+
u8 reserved3[2];
243246
__be32 vendor_exp_options;
244247
u8 reserved4[8];
245248
} __packed; /* format defined in

net/smc/smc_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,12 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
896896
memcpy(lgr->nexthop_mac, ini->smcrv2.nexthop_mac,
897897
ETH_ALEN);
898898
lgr->max_conns = ini->max_conns;
899+
lgr->max_links = ini->max_links;
899900
} else {
900901
ibdev = ini->ib_dev;
901902
ibport = ini->ib_port;
902903
lgr->max_conns = SMC_CONN_PER_LGR_MAX;
904+
lgr->max_links = SMC_LINKS_ADD_LNK_MAX;
903905
}
904906
memcpy(lgr->pnet_id, ibdev->pnetid[ibport - 1],
905907
SMC_MAX_PNETID_LEN);
@@ -1666,6 +1668,9 @@ void smcr_port_add(struct smc_ib_device *smcibdev, u8 ibport)
16661668
!rdma_dev_access_netns(smcibdev->ibdev, lgr->net))
16671669
continue;
16681670

1671+
if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1)
1672+
continue;
1673+
16691674
/* trigger local add link processing */
16701675
link = smc_llc_usable_link(lgr);
16711676
if (link)

net/smc/smc_core.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ struct smc_link {
173173
*/
174174
#define SMC_LINKS_PER_LGR_MAX 3
175175
#define SMC_SINGLE_LINK 0
176+
#define SMC_LINKS_ADD_LNK_MIN 1 /* min. # of links per link group */
177+
#define SMC_LINKS_ADD_LNK_MAX 2 /* max. # of links per link group, also is the
178+
* default value for smc-r v1.0 and v2.0
179+
*/
180+
#define SMC_LINKS_PER_LGR_MAX_PREFER 2 /* Preferred max links per link group used for
181+
* SMC-R v2.1 and later negotiation, vendors or
182+
* distrubutions may modify it to a value between
183+
* 1-2 as needed.
184+
*/
176185

177186
/* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */
178187
struct smc_buf_desc {
@@ -342,6 +351,8 @@ struct smc_link_group {
342351
struct net *net;
343352
u8 max_conns;
344353
/* max conn can be assigned to lgr */
354+
u8 max_links;
355+
/* max links can be added in lgr */
345356
};
346357
struct { /* SMC-D */
347358
u64 peer_gid;
@@ -387,6 +398,7 @@ struct smc_init_info {
387398
u8 smc_type_v2;
388399
u8 release_nr;
389400
u8 max_conns;
401+
u8 max_links;
390402
u8 first_contact_peer;
391403
u8 first_contact_local;
392404
unsigned short vlan_id;

net/smc/smc_llc.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ struct smc_llc_msg_confirm_link { /* type 0x01 */
5959
#define SMC_LLC_FLAG_ADD_LNK_REJ 0x40
6060
#define SMC_LLC_REJ_RSN_NO_ALT_PATH 1
6161

62-
#define SMC_LLC_ADD_LNK_MAX_LINKS 2
63-
6462
struct smc_llc_msg_add_link { /* type 0x02 */
6563
struct smc_llc_hdr hd;
6664
u8 sender_mac[ETH_ALEN];
@@ -472,10 +470,12 @@ int smc_llc_send_confirm_link(struct smc_link *link,
472470
hton24(confllc->sender_qp_num, link->roce_qp->qp_num);
473471
confllc->link_num = link->link_id;
474472
memcpy(confllc->link_uid, link->link_uid, SMC_LGR_ID_SIZE);
475-
confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS;
473+
confllc->max_links = SMC_LINKS_ADD_LNK_MAX;
476474
if (link->lgr->smc_version == SMC_V2 &&
477-
link->lgr->peer_smc_release >= SMC_RELEASE_1)
475+
link->lgr->peer_smc_release >= SMC_RELEASE_1) {
478476
confllc->max_conns = link->lgr->max_conns;
477+
confllc->max_links = link->lgr->max_links;
478+
}
479479
/* send llc message */
480480
rc = smc_wr_tx_send(link, pend);
481481
put_out:
@@ -1045,6 +1045,11 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
10451045
goto out_reject;
10461046
}
10471047

1048+
if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1) {
1049+
rc = 0;
1050+
goto out_reject;
1051+
}
1052+
10481053
ini->vlan_id = lgr->vlan_id;
10491054
if (lgr->smc_version == SMC_V2) {
10501055
ini->check_smcrv2 = true;
@@ -1169,6 +1174,9 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link,
11691174
lgr->type == SMC_LGR_ASYMMETRIC_PEER)
11701175
goto out;
11711176

1177+
if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1)
1178+
goto out;
1179+
11721180
ini = kzalloc(sizeof(*ini), GFP_KERNEL);
11731181
if (!ini)
11741182
goto out;
@@ -1414,6 +1422,11 @@ int smc_llc_srv_add_link(struct smc_link *link,
14141422
goto out;
14151423
}
14161424

1425+
if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1) {
1426+
rc = 0;
1427+
goto out;
1428+
}
1429+
14171430
/* ignore client add link recommendation, start new flow */
14181431
ini->vlan_id = lgr->vlan_id;
14191432
if (lgr->smc_version == SMC_V2) {

0 commit comments

Comments
 (0)