Skip to content

Commit 7f0620b

Browse files
GuangguanWangdavem330
authored andcommitted
net/smc: support max connections per lgr negotiation
Support max connections per lgr negotiation for SMCR v2.1, which is one of smc v2.1 features. Server makes decision for the final value of max conns based on the client preferred max conns and self-preferred max conns. Here use the minimum value of client preferred max conns and server preferred max conns. Client Server Proposal(max conns(client preferred)) ------------------------------------> Accept(max conns(accepted value)) accepted value=min(client preferred, server preferred) <----------------------------------- Confirm(max conns(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 6ac1e65 commit 7f0620b

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

net/smc/af_smc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
12421242
memcpy(ini->peer_systemid, aclc->r0.lcl.id_for_peer, SMC_SYSTEMID_LEN);
12431243
memcpy(ini->peer_gid, aclc->r0.lcl.gid, SMC_GID_SIZE);
12441244
memcpy(ini->peer_mac, aclc->r0.lcl.mac, ETH_ALEN);
1245+
ini->max_conns = SMC_CONN_PER_LGR_MAX;
12451246

12461247
reason_code = smc_connect_rdma_v2_prepare(smc, aclc, ini);
12471248
if (reason_code)

net/smc/smc_clc.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,17 @@ static int smc_clc_fill_fce(struct smc_clc_first_contact_ext_v2x *fce,
427427
fce->fce_v2_base.os_type = SMC_CLC_OS_LINUX;
428428
fce->fce_v2_base.release = ini->release_nr;
429429
memcpy(fce->fce_v2_base.hostname, smc_hostname, sizeof(smc_hostname));
430-
if (ini->is_smcd && ini->release_nr < SMC_RELEASE_1)
430+
if (ini->is_smcd && ini->release_nr < SMC_RELEASE_1) {
431431
ret = sizeof(struct smc_clc_first_contact_ext);
432+
goto out;
433+
}
434+
435+
if (ini->release_nr >= SMC_RELEASE_1) {
436+
if (!ini->is_smcd)
437+
fce->max_conns = ini->max_conns;
438+
}
432439

440+
out:
433441
return ret;
434442
}
435443

@@ -931,8 +939,10 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
931939
sizeof(struct smc_clc_smcd_gid_chid);
932940
}
933941
}
934-
if (smcr_indicated(ini->smc_type_v2))
942+
if (smcr_indicated(ini->smc_type_v2)) {
935943
memcpy(v2_ext->roce, ini->smcrv2.ib_gid_v2, SMC_GID_SIZE);
944+
v2_ext->max_conns = SMC_CONN_PER_LGR_PREFER;
945+
}
936946

937947
pclc_base->hdr.length = htons(plen);
938948
memcpy(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
@@ -1163,6 +1173,8 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11631173
{
11641174
struct smc_clc_v2_extension *pclc_v2_ext;
11651175

1176+
ini->max_conns = SMC_CONN_PER_LGR_MAX;
1177+
11661178
if ((!(ini->smcd_version & SMC_V2) && !(ini->smcr_version & SMC_V2)) ||
11671179
ini->release_nr < SMC_RELEASE_1)
11681180
return 0;
@@ -1171,15 +1183,30 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11711183
if (!pclc_v2_ext)
11721184
return SMC_CLC_DECL_NOV2EXT;
11731185

1186+
if (ini->smcr_version & SMC_V2) {
1187+
ini->max_conns = min_t(u8, pclc_v2_ext->max_conns, SMC_CONN_PER_LGR_PREFER);
1188+
if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
1189+
return SMC_CLC_DECL_MAXCONNERR;
1190+
}
1191+
11741192
return 0;
11751193
}
11761194

11771195
int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
11781196
struct smc_init_info *ini)
11791197
{
1198+
struct smc_clc_first_contact_ext_v2x *fce_v2x =
1199+
(struct smc_clc_first_contact_ext_v2x *)fce;
1200+
11801201
if (ini->release_nr < SMC_RELEASE_1)
11811202
return 0;
11821203

1204+
if (!ini->is_smcd) {
1205+
if (fce_v2x->max_conns < SMC_CONN_PER_LGR_MIN)
1206+
return SMC_CLC_DECL_MAXCONNERR;
1207+
ini->max_conns = fce_v2x->max_conns;
1208+
}
1209+
11831210
return 0;
11841211
}
11851212

@@ -1190,6 +1217,8 @@ int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc,
11901217
(struct smc_clc_msg_accept_confirm_v2 *)cclc;
11911218
struct smc_clc_first_contact_ext *fce =
11921219
smc_get_clc_first_contact_ext(clc_v2, ini->is_smcd);
1220+
struct smc_clc_first_contact_ext_v2x *fce_v2x =
1221+
(struct smc_clc_first_contact_ext_v2x *)fce;
11931222

11941223
if (cclc->hdr.version == SMC_V1 ||
11951224
!(cclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK))
@@ -1201,6 +1230,11 @@ int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc,
12011230
if (fce->release < SMC_RELEASE_1)
12021231
return 0;
12031232

1233+
if (!ini->is_smcd) {
1234+
if (fce_v2x->max_conns != ini->max_conns)
1235+
return SMC_CLC_DECL_MAXCONNERR;
1236+
}
1237+
12041238
return 0;
12051239
}
12061240

net/smc/smc_clc.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#define SMC_CLC_DECL_NOSMCD2DEV 0x03030007 /* no SMC-Dv2 device found */
4747
#define SMC_CLC_DECL_NOUEID 0x03030008 /* peer sent no UEID */
4848
#define SMC_CLC_DECL_RELEASEERR 0x03030009 /* release version negotiate failed */
49+
#define SMC_CLC_DECL_MAXCONNERR 0x0303000a /* max connections negotiate failed */
4950
#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/
5051
#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */
5152
#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */
@@ -134,7 +135,8 @@ struct smc_clc_smcd_gid_chid {
134135
struct smc_clc_v2_extension {
135136
struct smc_clnt_opts_area_hdr hdr;
136137
u8 roce[16]; /* RoCEv2 GID */
137-
u8 reserved[16];
138+
u8 max_conns;
139+
u8 reserved[15];
138140
u8 user_eids[][SMC_MAX_EID_LEN];
139141
};
140142

@@ -236,7 +238,8 @@ struct smc_clc_first_contact_ext {
236238

237239
struct smc_clc_first_contact_ext_v2x {
238240
struct smc_clc_first_contact_ext fce_v2_base;
239-
u8 reserved3[4];
241+
u8 max_conns; /* for SMC-R only */
242+
u8 reserved3[3];
240243
__be32 vendor_exp_options;
241244
u8 reserved4[8];
242245
} __packed; /* format defined in

net/smc/smc_core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,11 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
895895
lgr->uses_gateway = ini->smcrv2.uses_gateway;
896896
memcpy(lgr->nexthop_mac, ini->smcrv2.nexthop_mac,
897897
ETH_ALEN);
898+
lgr->max_conns = ini->max_conns;
898899
} else {
899900
ibdev = ini->ib_dev;
900901
ibport = ini->ib_port;
902+
lgr->max_conns = SMC_CONN_PER_LGR_MAX;
901903
}
902904
memcpy(lgr->pnet_id, ibdev->pnetid[ibport - 1],
903905
SMC_MAX_PNETID_LEN);
@@ -1888,7 +1890,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
18881890
(ini->smcd_version == SMC_V2 ||
18891891
lgr->vlan_id == ini->vlan_id) &&
18901892
(role == SMC_CLNT || ini->is_smcd ||
1891-
(lgr->conns_num < SMC_RMBS_PER_LGR_MAX &&
1893+
(lgr->conns_num < lgr->max_conns &&
18921894
!bitmap_full(lgr->rtokens_used_mask, SMC_RMBS_PER_LGR_MAX)))) {
18931895
/* link group found */
18941896
ini->first_contact_local = 0;

net/smc/smc_core.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
#include "smc_ib.h"
2323

2424
#define SMC_RMBS_PER_LGR_MAX 255 /* max. # of RMBs per link group */
25+
#define SMC_CONN_PER_LGR_MIN 16 /* min. # of connections per link group */
26+
#define SMC_CONN_PER_LGR_MAX 255 /* max. # of connections per link group,
27+
* also is the default value for SMC-R v1 and v2.0
28+
*/
29+
#define SMC_CONN_PER_LGR_PREFER 255 /* Preferred connections per link group used for
30+
* SMC-R v2.1 and later negotiation, vendors or
31+
* distrubutions may modify it to a value between
32+
* 16-255 as needed.
33+
*/
2534

2635
struct smc_lgr_list { /* list of link group definition */
2736
struct list_head list;
@@ -331,6 +340,8 @@ struct smc_link_group {
331340
__be32 saddr;
332341
/* net namespace */
333342
struct net *net;
343+
u8 max_conns;
344+
/* max conn can be assigned to lgr */
334345
};
335346
struct { /* SMC-D */
336347
u64 peer_gid;
@@ -375,6 +386,7 @@ struct smc_init_info {
375386
u8 smc_type_v1;
376387
u8 smc_type_v2;
377388
u8 release_nr;
389+
u8 max_conns;
378390
u8 first_contact_peer;
379391
u8 first_contact_local;
380392
unsigned short vlan_id;

net/smc/smc_llc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ struct smc_llc_msg_confirm_link { /* type 0x01 */
5252
u8 link_num;
5353
u8 link_uid[SMC_LGR_ID_SIZE];
5454
u8 max_links;
55-
u8 reserved[9];
55+
u8 max_conns;
56+
u8 reserved[8];
5657
};
5758

5859
#define SMC_LLC_FLAG_ADD_LNK_REJ 0x40
@@ -472,6 +473,9 @@ int smc_llc_send_confirm_link(struct smc_link *link,
472473
confllc->link_num = link->link_id;
473474
memcpy(confllc->link_uid, link->link_uid, SMC_LGR_ID_SIZE);
474475
confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS;
476+
if (link->lgr->smc_version == SMC_V2 &&
477+
link->lgr->peer_smc_release >= SMC_RELEASE_1)
478+
confllc->max_conns = link->lgr->max_conns;
475479
/* send llc message */
476480
rc = smc_wr_tx_send(link, pend);
477481
put_out:

0 commit comments

Comments
 (0)