Skip to content

Commit 1ad04b7

Browse files
committed
Merge branch 'smc-sysctl'
Guangguan Wang says: =================== add two sysctl for SMC-R v2.1 This patch set add two sysctl for SMC-R v2.1: net.smc.smcr_max_links_per_lgr is used to control the max links per lgr. net.smc.smcr_max_conns_per_lgr is used to control the max connections per lgr. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a8d4879 + 1f2c9dd commit 1ad04b7

File tree

7 files changed

+55
-7
lines changed

7 files changed

+55
-7
lines changed

Documentation/networking/smc-sysctl.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ 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
68+
69+
smcr_max_conns_per_lgr - INTEGER
70+
Controls the max number of connections can be added to a SMC-R link group. The
71+
acceptable value ranges from 16 to 255. Only for SMC-R v2.1 and later.
72+
73+
Default: 255

include/net/netns/smc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ struct netns_smc {
2222
int sysctl_smcr_testlink_time;
2323
int sysctl_wmem;
2424
int sysctl_rmem;
25+
int sysctl_max_links_per_lgr;
26+
int sysctl_max_conns_per_lgr;
2527
};
2628
#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: 10 additions & 5 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;
@@ -943,8 +944,8 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
943944
}
944945
if (smcr_indicated(ini->smc_type_v2)) {
945946
memcpy(v2_ext->roce, ini->smcrv2.ib_gid_v2, SMC_GID_SIZE);
946-
v2_ext->max_conns = SMC_CONN_PER_LGR_PREFER;
947-
v2_ext->max_links = SMC_LINKS_PER_LGR_MAX_PREFER;
947+
v2_ext->max_conns = net->smc.sysctl_max_conns_per_lgr;
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;
@@ -1188,11 +1191,13 @@ int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
11881191
return SMC_CLC_DECL_NOV2EXT;
11891192

11901193
if (ini->smcr_version & SMC_V2) {
1191-
ini->max_conns = min_t(u8, pclc_v2_ext->max_conns, SMC_CONN_PER_LGR_PREFER);
1194+
ini->max_conns = min_t(u8, pclc_v2_ext->max_conns,
1195+
net->smc.sysctl_max_conns_per_lgr);
11921196
if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
11931197
return SMC_CLC_DECL_MAXCONNERR;
11941198

1195-
ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
1199+
ini->max_links = min_t(u8, pclc_v2_ext->max_links,
1200+
net->smc.sysctl_max_links_per_lgr);
11961201
if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
11971202
return SMC_CLC_DECL_MAXLINKERR;
11981203
}

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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ 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;
30+
static int conns_per_lgr_min = SMC_CONN_PER_LGR_MIN;
31+
static int conns_per_lgr_max = SMC_CONN_PER_LGR_MAX;
2832

2933
static struct ctl_table smc_table[] = {
3034
{
@@ -68,6 +72,24 @@ static struct ctl_table smc_table[] = {
6872
.extra1 = &min_rcvbuf,
6973
.extra2 = &max_rcvbuf,
7074
},
75+
{
76+
.procname = "smcr_max_links_per_lgr",
77+
.data = &init_net.smc.sysctl_max_links_per_lgr,
78+
.maxlen = sizeof(int),
79+
.mode = 0644,
80+
.proc_handler = proc_dointvec_minmax,
81+
.extra1 = &links_per_lgr_min,
82+
.extra2 = &links_per_lgr_max,
83+
},
84+
{
85+
.procname = "smcr_max_conns_per_lgr",
86+
.data = &init_net.smc.sysctl_max_conns_per_lgr,
87+
.maxlen = sizeof(int),
88+
.mode = 0644,
89+
.proc_handler = proc_dointvec_minmax,
90+
.extra1 = &conns_per_lgr_min,
91+
.extra2 = &conns_per_lgr_max,
92+
},
7193
{ }
7294
};
7395

@@ -97,6 +119,8 @@ int __net_init smc_sysctl_net_init(struct net *net)
97119
net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
98120
WRITE_ONCE(net->smc.sysctl_wmem, net_smc_wmem_init);
99121
WRITE_ONCE(net->smc.sysctl_rmem, net_smc_rmem_init);
122+
net->smc.sysctl_max_links_per_lgr = SMC_LINKS_PER_LGR_MAX_PREFER;
123+
net->smc.sysctl_max_conns_per_lgr = SMC_CONN_PER_LGR_PREFER;
100124

101125
return 0;
102126

net/smc/smc_sysctl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ 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;
27+
net->smc.sysctl_max_conns_per_lgr = SMC_CONN_PER_LGR_PREFER;
2628
return 0;
2729
}
2830

0 commit comments

Comments
 (0)