Skip to content

Commit f8e80fc

Browse files
GuangguanWangdavem330
authored andcommitted
net/smc: add sysctl for max links per lgr for SMC-R v2.1
Add a new sysctl: net.smc.smcr_max_links_per_lgr, which is used to control the preferred max links per lgr for SMC-R v2.1. The default value of this sysctl is 2, and the acceptable value ranges from 1 to 2. Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com> Reviewed-by: Dust Li <dust.li@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a8d4879 commit f8e80fc

File tree

7 files changed

+32
-5
lines changed

7 files changed

+32
-5
lines changed

Documentation/networking/smc-sysctl.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ rmem - INTEGER
5757
only allowed 512KiB for SMC-R and 1MiB for SMC-D.
5858

5959
Default: 64KiB
60+
61+
smcr_max_links_per_lgr - INTEGER
62+
Controls the max number of links can be added to a SMC-R link group. Notice that
63+
the actual number of the links added to a SMC-R link group depends on the number
64+
of RDMA devices exist in the system. The acceptable value ranges from 1 to 2. Only
65+
for SMC-R v2.1 and later.
66+
67+
Default: 2

include/net/netns/smc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ struct netns_smc {
2222
int sysctl_smcr_testlink_time;
2323
int sysctl_wmem;
2424
int sysctl_rmem;
25+
int sysctl_max_links_per_lgr;
2526
};
2627
#endif

net/smc/af_smc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@ static void smc_listen_work(struct work_struct *work)
24612461
if (rc)
24622462
goto out_decl;
24632463

2464-
rc = smc_clc_srv_v2x_features_validate(pclc, ini);
2464+
rc = smc_clc_srv_v2x_features_validate(new_smc, pclc, ini);
24652465
if (rc)
24662466
goto out_decl;
24672467

net/smc/smc_clc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
824824
struct smc_clc_smcd_gid_chid *gidchids;
825825
struct smc_clc_msg_proposal_area *pclc;
826826
struct smc_clc_ipv6_prefix *ipv6_prfx;
827+
struct net *net = sock_net(&smc->sk);
827828
struct smc_clc_v2_extension *v2_ext;
828829
struct smc_clc_msg_smcd *pclc_smcd;
829830
struct smc_clc_msg_trail *trl;
@@ -944,7 +945,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
944945
if (smcr_indicated(ini->smc_type_v2)) {
945946
memcpy(v2_ext->roce, ini->smcrv2.ib_gid_v2, SMC_GID_SIZE);
946947
v2_ext->max_conns = SMC_CONN_PER_LGR_PREFER;
947-
v2_ext->max_links = SMC_LINKS_PER_LGR_MAX_PREFER;
948+
v2_ext->max_links = net->smc.sysctl_max_links_per_lgr;
948949
}
949950

950951
pclc_base->hdr.length = htons(plen);
@@ -1171,10 +1172,12 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
11711172
return len > 0 ? 0 : len;
11721173
}
11731174

1174-
int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
1175+
int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
1176+
struct smc_clc_msg_proposal *pclc,
11751177
struct smc_init_info *ini)
11761178
{
11771179
struct smc_clc_v2_extension *pclc_v2_ext;
1180+
struct net *net = sock_net(&smc->sk);
11781181

11791182
ini->max_conns = SMC_CONN_PER_LGR_MAX;
11801183
ini->max_links = SMC_LINKS_ADD_LNK_MAX;
@@ -1192,7 +1195,8 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11921195
if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
11931196
return SMC_CLC_DECL_MAXCONNERR;
11941197

1195-
ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
1198+
ini->max_links = min_t(u8, pclc_v2_ext->max_links,
1199+
net->smc.sysctl_max_links_per_lgr);
11961200
if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
11971201
return SMC_CLC_DECL_MAXLINKERR;
11981202
}

net/smc/smc_clc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
422422
u8 version, u8 *eid, struct smc_init_info *ini);
423423
int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
424424
u8 version, u8 *negotiated_eid, struct smc_init_info *ini);
425-
int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
425+
int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
426+
struct smc_clc_msg_proposal *pclc,
426427
struct smc_init_info *ini);
427428
int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
428429
struct smc_init_info *ini);

net/smc/smc_sysctl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ static int max_sndbuf = INT_MAX / 2;
2525
static int max_rcvbuf = INT_MAX / 2;
2626
static const int net_smc_wmem_init = (64 * 1024);
2727
static const int net_smc_rmem_init = (64 * 1024);
28+
static int links_per_lgr_min = SMC_LINKS_ADD_LNK_MIN;
29+
static int links_per_lgr_max = SMC_LINKS_ADD_LNK_MAX;
2830

2931
static struct ctl_table smc_table[] = {
3032
{
@@ -68,6 +70,15 @@ static struct ctl_table smc_table[] = {
6870
.extra1 = &min_rcvbuf,
6971
.extra2 = &max_rcvbuf,
7072
},
73+
{
74+
.procname = "smcr_max_links_per_lgr",
75+
.data = &init_net.smc.sysctl_max_links_per_lgr,
76+
.maxlen = sizeof(int),
77+
.mode = 0644,
78+
.proc_handler = proc_dointvec_minmax,
79+
.extra1 = &links_per_lgr_min,
80+
.extra2 = &links_per_lgr_max,
81+
},
7182
{ }
7283
};
7384

@@ -97,6 +108,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
97108
net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
98109
WRITE_ONCE(net->smc.sysctl_wmem, net_smc_wmem_init);
99110
WRITE_ONCE(net->smc.sysctl_rmem, net_smc_rmem_init);
111+
net->smc.sysctl_max_links_per_lgr = SMC_LINKS_PER_LGR_MAX_PREFER;
100112

101113
return 0;
102114

net/smc/smc_sysctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void __net_exit smc_sysctl_net_exit(struct net *net);
2323
static inline int smc_sysctl_net_init(struct net *net)
2424
{
2525
net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
26+
net->smc.sysctl_max_links_per_lgr = SMC_LINKS_PER_LGR_MAX_PREFER;
2627
return 0;
2728
}
2829

0 commit comments

Comments
 (0)