net/smc: add sysctl for max conns per lgr for SMC-R v2.1
authorGuangguan Wang <guangguan.wang@linux.alibaba.com>
Wed, 22 Nov 2023 13:52:58 +0000 (21:52 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Nov 2023 12:13:14 +0000 (12:13 +0000)
Add a new sysctl: net.smc.smcr_max_conns_per_lgr, which is
used to control the preferred max connections per lgr for
SMC-R v2.1. The default value of this sysctl is 255, and
the acceptable value ranges from 16 to 255.

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>
Documentation/networking/smc-sysctl.rst
include/net/netns/smc.h
net/smc/smc_clc.c
net/smc/smc_sysctl.c
net/smc/smc_sysctl.h

index c6ef86ef4c4f5d386465dfddebe332e66a5aee95..a874d007f2db55160924686bf8885847a5ab1dcd 100644 (file)
@@ -65,3 +65,9 @@ smcr_max_links_per_lgr - INTEGER
        for SMC-R v2.1 and later.
 
        Default: 2
+
+smcr_max_conns_per_lgr - INTEGER
+       Controls the max number of connections can be added to a SMC-R link group. The
+       acceptable value ranges from 16 to 255. Only for SMC-R v2.1 and later.
+
+       Default: 255
index da70235878249d136d63f83fd0cf18519ffe2d3f..fc752a50f91b45e9b38ab1a74273858a0af29410 100644 (file)
@@ -23,5 +23,6 @@ struct netns_smc {
        int                             sysctl_wmem;
        int                             sysctl_rmem;
        int                             sysctl_max_links_per_lgr;
+       int                             sysctl_max_conns_per_lgr;
 };
 #endif
index 1f87c8895a276574d78546ab1414889899bb6d41..0fda5156eef031ae4afc391fa873e7ea2012a831 100644 (file)
@@ -944,7 +944,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
        }
        if (smcr_indicated(ini->smc_type_v2)) {
                memcpy(v2_ext->roce, ini->smcrv2.ib_gid_v2, SMC_GID_SIZE);
-               v2_ext->max_conns = SMC_CONN_PER_LGR_PREFER;
+               v2_ext->max_conns = net->smc.sysctl_max_conns_per_lgr;
                v2_ext->max_links = net->smc.sysctl_max_links_per_lgr;
        }
 
@@ -1191,7 +1191,8 @@ int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
                return SMC_CLC_DECL_NOV2EXT;
 
        if (ini->smcr_version & SMC_V2) {
-               ini->max_conns = min_t(u8, pclc_v2_ext->max_conns, SMC_CONN_PER_LGR_PREFER);
+               ini->max_conns = min_t(u8, pclc_v2_ext->max_conns,
+                                      net->smc.sysctl_max_conns_per_lgr);
                if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
                        return SMC_CLC_DECL_MAXCONNERR;
 
index 3e9bb921e40a7a7b04ce185e60480df336b14436..a5946d1b9d60c85e472a8ebd93af67ea80c22217 100644 (file)
@@ -27,6 +27,8 @@ static const int net_smc_wmem_init = (64 * 1024);
 static const int net_smc_rmem_init = (64 * 1024);
 static int links_per_lgr_min = SMC_LINKS_ADD_LNK_MIN;
 static int links_per_lgr_max = SMC_LINKS_ADD_LNK_MAX;
+static int conns_per_lgr_min = SMC_CONN_PER_LGR_MIN;
+static int conns_per_lgr_max = SMC_CONN_PER_LGR_MAX;
 
 static struct ctl_table smc_table[] = {
        {
@@ -79,6 +81,15 @@ static struct ctl_table smc_table[] = {
                .extra1         = &links_per_lgr_min,
                .extra2         = &links_per_lgr_max,
        },
+       {
+               .procname       = "smcr_max_conns_per_lgr",
+               .data           = &init_net.smc.sysctl_max_conns_per_lgr,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &conns_per_lgr_min,
+               .extra2         = &conns_per_lgr_max,
+       },
        {  }
 };
 
@@ -109,6 +120,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
        WRITE_ONCE(net->smc.sysctl_wmem, net_smc_wmem_init);
        WRITE_ONCE(net->smc.sysctl_rmem, net_smc_rmem_init);
        net->smc.sysctl_max_links_per_lgr = SMC_LINKS_PER_LGR_MAX_PREFER;
+       net->smc.sysctl_max_conns_per_lgr = SMC_CONN_PER_LGR_PREFER;
 
        return 0;
 
index 5783dd7575dd4a65ccfd38d3e8c8b9a3dc93f81b..eb2465ae1e15e73465077a18a98e7ab6cc6982c1 100644 (file)
@@ -24,6 +24,7 @@ static inline int smc_sysctl_net_init(struct net *net)
 {
        net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
        net->smc.sysctl_max_links_per_lgr = SMC_LINKS_PER_LGR_MAX_PREFER;
+       net->smc.sysctl_max_conns_per_lgr = SMC_CONN_PER_LGR_PREFER;
        return 0;
 }