linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] add two sysctl for SMC-R v2.1
@ 2023-11-22 13:52 Guangguan Wang
  2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Guangguan Wang @ 2023-11-22 13:52 UTC (permalink / raw)
  To: wenjia, jaka, kgraul, corbet, davem, kuba, pabeni, edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

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.

Guangguan Wang (2):
  net/smc: add sysctl for max links per lgr for SMC-R v2.1
  net/smc: add sysctl for max conns per lgr for SMC-R v2.1

 Documentation/networking/smc-sysctl.rst | 14 ++++++++++++++
 include/net/netns/smc.h                 |  2 ++
 net/smc/af_smc.c                        |  2 +-
 net/smc/smc_clc.c                       | 15 ++++++++++-----
 net/smc/smc_clc.h                       |  3 ++-
 net/smc/smc_sysctl.c                    | 24 ++++++++++++++++++++++++
 net/smc/smc_sysctl.h                    |  2 ++
 7 files changed, 55 insertions(+), 7 deletions(-)

-- 
2.24.3 (Apple Git-128)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr for SMC-R v2.1
  2023-11-22 13:52 [PATCH net-next 0/2] add two sysctl for SMC-R v2.1 Guangguan Wang
@ 2023-11-22 13:52 ` Guangguan Wang
  2023-11-24  5:50   ` Dust Li
  2023-11-24 12:22   ` Jan Karcher
  2023-11-22 13:52 ` [PATCH net-next 2/2] net/smc: add sysctl for max conns " Guangguan Wang
  2023-11-24 12:20 ` [PATCH net-next 0/2] add two sysctl " patchwork-bot+netdevbpf
  2 siblings, 2 replies; 8+ messages in thread
From: Guangguan Wang @ 2023-11-22 13:52 UTC (permalink / raw)
  To: wenjia, jaka, kgraul, corbet, davem, kuba, pabeni, edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

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>
---
 Documentation/networking/smc-sysctl.rst |  8 ++++++++
 include/net/netns/smc.h                 |  1 +
 net/smc/af_smc.c                        |  2 +-
 net/smc/smc_clc.c                       | 10 +++++++---
 net/smc/smc_clc.h                       |  3 ++-
 net/smc/smc_sysctl.c                    | 12 ++++++++++++
 net/smc/smc_sysctl.h                    |  1 +
 7 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
index 769149d98773..c6ef86ef4c4f 100644
--- a/Documentation/networking/smc-sysctl.rst
+++ b/Documentation/networking/smc-sysctl.rst
@@ -57,3 +57,11 @@ rmem - INTEGER
 	only allowed 512KiB for SMC-R and 1MiB for SMC-D.
 
 	Default: 64KiB
+
+smcr_max_links_per_lgr - INTEGER
+	Controls the max number of links can be added to a SMC-R link group. Notice that
+	the actual number of the links added to a SMC-R link group depends on the number
+	of RDMA devices exist in the system. The acceptable value ranges from 1 to 2. Only
+	for SMC-R v2.1 and later.
+
+	Default: 2
diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
index 582212ada3ba..da7023587824 100644
--- a/include/net/netns/smc.h
+++ b/include/net/netns/smc.h
@@ -22,5 +22,6 @@ struct netns_smc {
 	int				sysctl_smcr_testlink_time;
 	int				sysctl_wmem;
 	int				sysctl_rmem;
+	int				sysctl_max_links_per_lgr;
 };
 #endif
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index da97f946b79b..f8da484efe90 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2457,7 +2457,7 @@ static void smc_listen_work(struct work_struct *work)
 	if (rc)
 		goto out_decl;
 
-	rc = smc_clc_srv_v2x_features_validate(pclc, ini);
+	rc = smc_clc_srv_v2x_features_validate(new_smc, pclc, ini);
 	if (rc)
 		goto out_decl;
 
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 8deb46c28f1d..1f87c8895a27 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -824,6 +824,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
 	struct smc_clc_smcd_gid_chid *gidchids;
 	struct smc_clc_msg_proposal_area *pclc;
 	struct smc_clc_ipv6_prefix *ipv6_prfx;
+	struct net *net = sock_net(&smc->sk);
 	struct smc_clc_v2_extension *v2_ext;
 	struct smc_clc_msg_smcd *pclc_smcd;
 	struct smc_clc_msg_trail *trl;
@@ -944,7 +945,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_links = SMC_LINKS_PER_LGR_MAX_PREFER;
+		v2_ext->max_links = net->smc.sysctl_max_links_per_lgr;
 	}
 
 	pclc_base->hdr.length = htons(plen);
@@ -1171,10 +1172,12 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
 	return len > 0 ? 0 : len;
 }
 
-int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
+int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
+				      struct smc_clc_msg_proposal *pclc,
 				      struct smc_init_info *ini)
 {
 	struct smc_clc_v2_extension *pclc_v2_ext;
+	struct net *net = sock_net(&smc->sk);
 
 	ini->max_conns = SMC_CONN_PER_LGR_MAX;
 	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,
 		if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
 			return SMC_CLC_DECL_MAXCONNERR;
 
-		ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
+		ini->max_links = min_t(u8, pclc_v2_ext->max_links,
+				       net->smc.sysctl_max_links_per_lgr);
 		if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
 			return SMC_CLC_DECL_MAXLINKERR;
 	}
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index c5c8e7db775a..89b258cedffe 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -422,7 +422,8 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
 			 u8 version, u8 *eid, struct smc_init_info *ini);
 int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
 			u8 version, u8 *negotiated_eid, struct smc_init_info *ini);
-int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
+int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
+				      struct smc_clc_msg_proposal *pclc,
 				      struct smc_init_info *ini);
 int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
 				       struct smc_init_info *ini);
diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
index 5cbc18c6e62b..3e9bb921e40a 100644
--- a/net/smc/smc_sysctl.c
+++ b/net/smc/smc_sysctl.c
@@ -25,6 +25,8 @@ static int max_sndbuf = INT_MAX / 2;
 static int max_rcvbuf = INT_MAX / 2;
 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 struct ctl_table smc_table[] = {
 	{
@@ -68,6 +70,15 @@ static struct ctl_table smc_table[] = {
 		.extra1		= &min_rcvbuf,
 		.extra2		= &max_rcvbuf,
 	},
+	{
+		.procname	= "smcr_max_links_per_lgr",
+		.data		= &init_net.smc.sysctl_max_links_per_lgr,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &links_per_lgr_min,
+		.extra2		= &links_per_lgr_max,
+	},
 	{  }
 };
 
@@ -97,6 +108,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
 	net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
 	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;
 
 	return 0;
 
diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
index 0becc11bd2f4..5783dd7575dd 100644
--- a/net/smc/smc_sysctl.h
+++ b/net/smc/smc_sysctl.h
@@ -23,6 +23,7 @@ void __net_exit smc_sysctl_net_exit(struct net *net);
 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;
 	return 0;
 }
 
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/2] net/smc: add sysctl for max conns per lgr for SMC-R v2.1
  2023-11-22 13:52 [PATCH net-next 0/2] add two sysctl for SMC-R v2.1 Guangguan Wang
  2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
@ 2023-11-22 13:52 ` Guangguan Wang
  2023-11-24  5:51   ` Dust Li
  2023-11-24 12:22   ` Jan Karcher
  2023-11-24 12:20 ` [PATCH net-next 0/2] add two sysctl " patchwork-bot+netdevbpf
  2 siblings, 2 replies; 8+ messages in thread
From: Guangguan Wang @ 2023-11-22 13:52 UTC (permalink / raw)
  To: wenjia, jaka, kgraul, corbet, davem, kuba, pabeni, edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

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>
---
 Documentation/networking/smc-sysctl.rst |  6 ++++++
 include/net/netns/smc.h                 |  1 +
 net/smc/smc_clc.c                       |  5 +++--
 net/smc/smc_sysctl.c                    | 12 ++++++++++++
 net/smc/smc_sysctl.h                    |  1 +
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
index c6ef86ef4c4f..a874d007f2db 100644
--- a/Documentation/networking/smc-sysctl.rst
+++ b/Documentation/networking/smc-sysctl.rst
@@ -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
diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
index da7023587824..fc752a50f91b 100644
--- a/include/net/netns/smc.h
+++ b/include/net/netns/smc.h
@@ -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
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 1f87c8895a27..0fda5156eef0 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -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;
 
diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
index 3e9bb921e40a..a5946d1b9d60 100644
--- a/net/smc/smc_sysctl.c
+++ b/net/smc/smc_sysctl.c
@@ -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;
 
diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
index 5783dd7575dd..eb2465ae1e15 100644
--- a/net/smc/smc_sysctl.h
+++ b/net/smc/smc_sysctl.h
@@ -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;
 }
 
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr for SMC-R v2.1
  2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
@ 2023-11-24  5:50   ` Dust Li
  2023-11-24 12:22   ` Jan Karcher
  1 sibling, 0 replies; 8+ messages in thread
From: Dust Li @ 2023-11-24  5:50 UTC (permalink / raw)
  To: Guangguan Wang, wenjia, jaka, kgraul, corbet, davem, kuba, pabeni,
	edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

On Wed, Nov 22, 2023 at 09:52:57PM +0800, Guangguan Wang wrote:
>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>

LGTM

Reviewed-by: Dust Li <dust.li@linux.alibaba.com>

>---
> Documentation/networking/smc-sysctl.rst |  8 ++++++++
> include/net/netns/smc.h                 |  1 +
> net/smc/af_smc.c                        |  2 +-
> net/smc/smc_clc.c                       | 10 +++++++---
> net/smc/smc_clc.h                       |  3 ++-
> net/smc/smc_sysctl.c                    | 12 ++++++++++++
> net/smc/smc_sysctl.h                    |  1 +
> 7 files changed, 32 insertions(+), 5 deletions(-)
>
>diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
>index 769149d98773..c6ef86ef4c4f 100644
>--- a/Documentation/networking/smc-sysctl.rst
>+++ b/Documentation/networking/smc-sysctl.rst
>@@ -57,3 +57,11 @@ rmem - INTEGER
> 	only allowed 512KiB for SMC-R and 1MiB for SMC-D.
> 
> 	Default: 64KiB
>+
>+smcr_max_links_per_lgr - INTEGER
>+	Controls the max number of links can be added to a SMC-R link group. Notice that
>+	the actual number of the links added to a SMC-R link group depends on the number
>+	of RDMA devices exist in the system. The acceptable value ranges from 1 to 2. Only
>+	for SMC-R v2.1 and later.
>+
>+	Default: 2
>diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
>index 582212ada3ba..da7023587824 100644
>--- a/include/net/netns/smc.h
>+++ b/include/net/netns/smc.h
>@@ -22,5 +22,6 @@ struct netns_smc {
> 	int				sysctl_smcr_testlink_time;
> 	int				sysctl_wmem;
> 	int				sysctl_rmem;
>+	int				sysctl_max_links_per_lgr;
> };
> #endif
>diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
>index da97f946b79b..f8da484efe90 100644
>--- a/net/smc/af_smc.c
>+++ b/net/smc/af_smc.c
>@@ -2457,7 +2457,7 @@ static void smc_listen_work(struct work_struct *work)
> 	if (rc)
> 		goto out_decl;
> 
>-	rc = smc_clc_srv_v2x_features_validate(pclc, ini);
>+	rc = smc_clc_srv_v2x_features_validate(new_smc, pclc, ini);
> 	if (rc)
> 		goto out_decl;
> 
>diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
>index 8deb46c28f1d..1f87c8895a27 100644
>--- a/net/smc/smc_clc.c
>+++ b/net/smc/smc_clc.c
>@@ -824,6 +824,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
> 	struct smc_clc_smcd_gid_chid *gidchids;
> 	struct smc_clc_msg_proposal_area *pclc;
> 	struct smc_clc_ipv6_prefix *ipv6_prfx;
>+	struct net *net = sock_net(&smc->sk);
> 	struct smc_clc_v2_extension *v2_ext;
> 	struct smc_clc_msg_smcd *pclc_smcd;
> 	struct smc_clc_msg_trail *trl;
>@@ -944,7 +945,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_links = SMC_LINKS_PER_LGR_MAX_PREFER;
>+		v2_ext->max_links = net->smc.sysctl_max_links_per_lgr;
> 	}
> 
> 	pclc_base->hdr.length = htons(plen);
>@@ -1171,10 +1172,12 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
> 	return len > 0 ? 0 : len;
> }
> 
>-int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
>+int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
>+				      struct smc_clc_msg_proposal *pclc,
> 				      struct smc_init_info *ini)
> {
> 	struct smc_clc_v2_extension *pclc_v2_ext;
>+	struct net *net = sock_net(&smc->sk);
> 
> 	ini->max_conns = SMC_CONN_PER_LGR_MAX;
> 	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,
> 		if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
> 			return SMC_CLC_DECL_MAXCONNERR;
> 
>-		ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
>+		ini->max_links = min_t(u8, pclc_v2_ext->max_links,
>+				       net->smc.sysctl_max_links_per_lgr);
> 		if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
> 			return SMC_CLC_DECL_MAXLINKERR;
> 	}
>diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
>index c5c8e7db775a..89b258cedffe 100644
>--- a/net/smc/smc_clc.h
>+++ b/net/smc/smc_clc.h
>@@ -422,7 +422,8 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
> 			 u8 version, u8 *eid, struct smc_init_info *ini);
> int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
> 			u8 version, u8 *negotiated_eid, struct smc_init_info *ini);
>-int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
>+int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
>+				      struct smc_clc_msg_proposal *pclc,
> 				      struct smc_init_info *ini);
> int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
> 				       struct smc_init_info *ini);
>diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
>index 5cbc18c6e62b..3e9bb921e40a 100644
>--- a/net/smc/smc_sysctl.c
>+++ b/net/smc/smc_sysctl.c
>@@ -25,6 +25,8 @@ static int max_sndbuf = INT_MAX / 2;
> static int max_rcvbuf = INT_MAX / 2;
> 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 struct ctl_table smc_table[] = {
> 	{
>@@ -68,6 +70,15 @@ static struct ctl_table smc_table[] = {
> 		.extra1		= &min_rcvbuf,
> 		.extra2		= &max_rcvbuf,
> 	},
>+	{
>+		.procname	= "smcr_max_links_per_lgr",
>+		.data		= &init_net.smc.sysctl_max_links_per_lgr,
>+		.maxlen		= sizeof(int),
>+		.mode		= 0644,
>+		.proc_handler	= proc_dointvec_minmax,
>+		.extra1		= &links_per_lgr_min,
>+		.extra2		= &links_per_lgr_max,
>+	},
> 	{  }
> };
> 
>@@ -97,6 +108,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
> 	net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
> 	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;
> 
> 	return 0;
> 
>diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
>index 0becc11bd2f4..5783dd7575dd 100644
>--- a/net/smc/smc_sysctl.h
>+++ b/net/smc/smc_sysctl.h
>@@ -23,6 +23,7 @@ void __net_exit smc_sysctl_net_exit(struct net *net);
> 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;
> 	return 0;
> }
> 
>-- 
>2.24.3 (Apple Git-128)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net/smc: add sysctl for max conns per lgr for SMC-R v2.1
  2023-11-22 13:52 ` [PATCH net-next 2/2] net/smc: add sysctl for max conns " Guangguan Wang
@ 2023-11-24  5:51   ` Dust Li
  2023-11-24 12:22   ` Jan Karcher
  1 sibling, 0 replies; 8+ messages in thread
From: Dust Li @ 2023-11-24  5:51 UTC (permalink / raw)
  To: Guangguan Wang, wenjia, jaka, kgraul, corbet, davem, kuba, pabeni,
	edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

On Wed, Nov 22, 2023 at 09:52:58PM +0800, Guangguan Wang wrote:
>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>

>---
> Documentation/networking/smc-sysctl.rst |  6 ++++++
> include/net/netns/smc.h                 |  1 +
> net/smc/smc_clc.c                       |  5 +++--
> net/smc/smc_sysctl.c                    | 12 ++++++++++++
> net/smc/smc_sysctl.h                    |  1 +
> 5 files changed, 23 insertions(+), 2 deletions(-)
>
>diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
>index c6ef86ef4c4f..a874d007f2db 100644
>--- a/Documentation/networking/smc-sysctl.rst
>+++ b/Documentation/networking/smc-sysctl.rst
>@@ -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
>diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
>index da7023587824..fc752a50f91b 100644
>--- a/include/net/netns/smc.h
>+++ b/include/net/netns/smc.h
>@@ -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
>diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
>index 1f87c8895a27..0fda5156eef0 100644
>--- a/net/smc/smc_clc.c
>+++ b/net/smc/smc_clc.c
>@@ -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;
> 
>diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
>index 3e9bb921e40a..a5946d1b9d60 100644
>--- a/net/smc/smc_sysctl.c
>+++ b/net/smc/smc_sysctl.c
>@@ -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;
> 
>diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
>index 5783dd7575dd..eb2465ae1e15 100644
>--- a/net/smc/smc_sysctl.h
>+++ b/net/smc/smc_sysctl.h
>@@ -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;
> }
> 
>-- 
>2.24.3 (Apple Git-128)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] add two sysctl for SMC-R v2.1
  2023-11-22 13:52 [PATCH net-next 0/2] add two sysctl for SMC-R v2.1 Guangguan Wang
  2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
  2023-11-22 13:52 ` [PATCH net-next 2/2] net/smc: add sysctl for max conns " Guangguan Wang
@ 2023-11-24 12:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-24 12:20 UTC (permalink / raw)
  To: Guangguan Wang
  Cc: wenjia, jaka, kgraul, corbet, davem, kuba, pabeni, edumazet,
	tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 22 Nov 2023 21:52:56 +0800 you wrote:
> 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.
> 
> Guangguan Wang (2):
>   net/smc: add sysctl for max links per lgr for SMC-R v2.1
>   net/smc: add sysctl for max conns per lgr for SMC-R v2.1
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net/smc: add sysctl for max links per lgr for SMC-R v2.1
    https://git.kernel.org/netdev/net-next/c/f8e80fc4aceb
  - [net-next,2/2] net/smc: add sysctl for max conns per lgr for SMC-R v2.1
    https://git.kernel.org/netdev/net-next/c/1f2c9dd73f0a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr for SMC-R v2.1
  2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
  2023-11-24  5:50   ` Dust Li
@ 2023-11-24 12:22   ` Jan Karcher
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Karcher @ 2023-11-24 12:22 UTC (permalink / raw)
  To: Guangguan Wang, wenjia, kgraul, corbet, davem, kuba, pabeni,
	edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel



On 22/11/2023 14:52, Guangguan Wang wrote:
> 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>

Hi Guangguan,
thanks for your Submission.

Reviewed-by: Jan Karcher <jaka@linux.ibm.com>

> ---
>   Documentation/networking/smc-sysctl.rst |  8 ++++++++
>   include/net/netns/smc.h                 |  1 +
>   net/smc/af_smc.c                        |  2 +-
>   net/smc/smc_clc.c                       | 10 +++++++---
>   net/smc/smc_clc.h                       |  3 ++-
>   net/smc/smc_sysctl.c                    | 12 ++++++++++++
>   net/smc/smc_sysctl.h                    |  1 +
>   7 files changed, 32 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
> index 769149d98773..c6ef86ef4c4f 100644
> --- a/Documentation/networking/smc-sysctl.rst
> +++ b/Documentation/networking/smc-sysctl.rst
> @@ -57,3 +57,11 @@ rmem - INTEGER
>   	only allowed 512KiB for SMC-R and 1MiB for SMC-D.
>   
>   	Default: 64KiB
> +
> +smcr_max_links_per_lgr - INTEGER
> +	Controls the max number of links can be added to a SMC-R link group. Notice that
> +	the actual number of the links added to a SMC-R link group depends on the number
> +	of RDMA devices exist in the system. The acceptable value ranges from 1 to 2. Only
> +	for SMC-R v2.1 and later.
> +
> +	Default: 2
> diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
> index 582212ada3ba..da7023587824 100644
> --- a/include/net/netns/smc.h
> +++ b/include/net/netns/smc.h
> @@ -22,5 +22,6 @@ struct netns_smc {
>   	int				sysctl_smcr_testlink_time;
>   	int				sysctl_wmem;
>   	int				sysctl_rmem;
> +	int				sysctl_max_links_per_lgr;
>   };
>   #endif
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index da97f946b79b..f8da484efe90 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -2457,7 +2457,7 @@ static void smc_listen_work(struct work_struct *work)
>   	if (rc)
>   		goto out_decl;
>   
> -	rc = smc_clc_srv_v2x_features_validate(pclc, ini);
> +	rc = smc_clc_srv_v2x_features_validate(new_smc, pclc, ini);
>   	if (rc)
>   		goto out_decl;
>   
> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
> index 8deb46c28f1d..1f87c8895a27 100644
> --- a/net/smc/smc_clc.c
> +++ b/net/smc/smc_clc.c
> @@ -824,6 +824,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
>   	struct smc_clc_smcd_gid_chid *gidchids;
>   	struct smc_clc_msg_proposal_area *pclc;
>   	struct smc_clc_ipv6_prefix *ipv6_prfx;
> +	struct net *net = sock_net(&smc->sk);
>   	struct smc_clc_v2_extension *v2_ext;
>   	struct smc_clc_msg_smcd *pclc_smcd;
>   	struct smc_clc_msg_trail *trl;
> @@ -944,7 +945,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_links = SMC_LINKS_PER_LGR_MAX_PREFER;
> +		v2_ext->max_links = net->smc.sysctl_max_links_per_lgr;
>   	}
>   
>   	pclc_base->hdr.length = htons(plen);
> @@ -1171,10 +1172,12 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
>   	return len > 0 ? 0 : len;
>   }
>   
> -int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
> +int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
> +				      struct smc_clc_msg_proposal *pclc,
>   				      struct smc_init_info *ini)
>   {
>   	struct smc_clc_v2_extension *pclc_v2_ext;
> +	struct net *net = sock_net(&smc->sk);
>   
>   	ini->max_conns = SMC_CONN_PER_LGR_MAX;
>   	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,
>   		if (ini->max_conns < SMC_CONN_PER_LGR_MIN)
>   			return SMC_CLC_DECL_MAXCONNERR;
>   
> -		ini->max_links = min_t(u8, pclc_v2_ext->max_links, SMC_LINKS_PER_LGR_MAX_PREFER);
> +		ini->max_links = min_t(u8, pclc_v2_ext->max_links,
> +				       net->smc.sysctl_max_links_per_lgr);
>   		if (ini->max_links < SMC_LINKS_ADD_LNK_MIN)
>   			return SMC_CLC_DECL_MAXLINKERR;
>   	}
> diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
> index c5c8e7db775a..89b258cedffe 100644
> --- a/net/smc/smc_clc.h
> +++ b/net/smc/smc_clc.h
> @@ -422,7 +422,8 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
>   			 u8 version, u8 *eid, struct smc_init_info *ini);
>   int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
>   			u8 version, u8 *negotiated_eid, struct smc_init_info *ini);
> -int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
> +int smc_clc_srv_v2x_features_validate(struct smc_sock *smc,
> +				      struct smc_clc_msg_proposal *pclc,
>   				      struct smc_init_info *ini);
>   int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
>   				       struct smc_init_info *ini);
> diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
> index 5cbc18c6e62b..3e9bb921e40a 100644
> --- a/net/smc/smc_sysctl.c
> +++ b/net/smc/smc_sysctl.c
> @@ -25,6 +25,8 @@ static int max_sndbuf = INT_MAX / 2;
>   static int max_rcvbuf = INT_MAX / 2;
>   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 struct ctl_table smc_table[] = {
>   	{
> @@ -68,6 +70,15 @@ static struct ctl_table smc_table[] = {
>   		.extra1		= &min_rcvbuf,
>   		.extra2		= &max_rcvbuf,
>   	},
> +	{
> +		.procname	= "smcr_max_links_per_lgr",
> +		.data		= &init_net.smc.sysctl_max_links_per_lgr,
> +		.maxlen		= sizeof(int),
> +		.mode		= 0644,
> +		.proc_handler	= proc_dointvec_minmax,
> +		.extra1		= &links_per_lgr_min,
> +		.extra2		= &links_per_lgr_max,
> +	},
>   	{  }
>   };
>   
> @@ -97,6 +108,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
>   	net->smc.sysctl_smcr_testlink_time = SMC_LLC_TESTLINK_DEFAULT_TIME;
>   	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;
>   
>   	return 0;
>   
> diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
> index 0becc11bd2f4..5783dd7575dd 100644
> --- a/net/smc/smc_sysctl.h
> +++ b/net/smc/smc_sysctl.h
> @@ -23,6 +23,7 @@ void __net_exit smc_sysctl_net_exit(struct net *net);
>   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;
>   	return 0;
>   }
>   

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net/smc: add sysctl for max conns per lgr for SMC-R v2.1
  2023-11-22 13:52 ` [PATCH net-next 2/2] net/smc: add sysctl for max conns " Guangguan Wang
  2023-11-24  5:51   ` Dust Li
@ 2023-11-24 12:22   ` Jan Karcher
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Karcher @ 2023-11-24 12:22 UTC (permalink / raw)
  To: Guangguan Wang, wenjia, kgraul, corbet, davem, kuba, pabeni,
	edumazet
  Cc: tonylu, alibuda, guwen, netdev, linux-s390, linux-doc,
	linux-kernel



On 22/11/2023 14:52, Guangguan Wang wrote:
> 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>

Hi Guangguan,
thanks for your Submission.

Reviewed-by: Jan Karcher <jaka@linux.ibm.com>

> ---
>   Documentation/networking/smc-sysctl.rst |  6 ++++++
>   include/net/netns/smc.h                 |  1 +
>   net/smc/smc_clc.c                       |  5 +++--
>   net/smc/smc_sysctl.c                    | 12 ++++++++++++
>   net/smc/smc_sysctl.h                    |  1 +
>   5 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
> index c6ef86ef4c4f..a874d007f2db 100644
> --- a/Documentation/networking/smc-sysctl.rst
> +++ b/Documentation/networking/smc-sysctl.rst
> @@ -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
> diff --git a/include/net/netns/smc.h b/include/net/netns/smc.h
> index da7023587824..fc752a50f91b 100644
> --- a/include/net/netns/smc.h
> +++ b/include/net/netns/smc.h
> @@ -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
> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
> index 1f87c8895a27..0fda5156eef0 100644
> --- a/net/smc/smc_clc.c
> +++ b/net/smc/smc_clc.c
> @@ -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;
>   
> diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
> index 3e9bb921e40a..a5946d1b9d60 100644
> --- a/net/smc/smc_sysctl.c
> +++ b/net/smc/smc_sysctl.c
> @@ -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;
>   
> diff --git a/net/smc/smc_sysctl.h b/net/smc/smc_sysctl.h
> index 5783dd7575dd..eb2465ae1e15 100644
> --- a/net/smc/smc_sysctl.h
> +++ b/net/smc/smc_sysctl.h
> @@ -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;
>   }
>   

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-24 12:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 13:52 [PATCH net-next 0/2] add two sysctl for SMC-R v2.1 Guangguan Wang
2023-11-22 13:52 ` [PATCH net-next 1/2] net/smc: add sysctl for max links per lgr " Guangguan Wang
2023-11-24  5:50   ` Dust Li
2023-11-24 12:22   ` Jan Karcher
2023-11-22 13:52 ` [PATCH net-next 2/2] net/smc: add sysctl for max conns " Guangguan Wang
2023-11-24  5:51   ` Dust Li
2023-11-24 12:22   ` Jan Karcher
2023-11-24 12:20 ` [PATCH net-next 0/2] add two sysctl " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).