git: dd6ab49a9aeb - main - netmap: add a tunable for the maximum number of VALE switches
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 06 Mar 2022 17:36:24 UTC
The branch main has been updated by vmaffione:
URL: https://cgit.FreeBSD.org/src/commit/?id=dd6ab49a9aebb5fbb85973d9a859d24daa5e2165
commit dd6ab49a9aebb5fbb85973d9a859d24daa5e2165
Author: Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2022-03-06 17:28:44 +0000
Commit: Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2022-03-06 17:29:44 +0000
netmap: add a tunable for the maximum number of VALE switches
The new dev.netmap.max_bridges sysctl tunable can be set in
loader.conf(5) to change the default maximum number of VALE
switches that can be created. Current defaults is 8.
MFC after: 2 weeks
---
share/man/man4/netmap.4 | 7 ++++++-
share/man/man4/vale.4 | 5 +++--
sys/dev/netmap/netmap_bdg.c | 4 ++--
sys/dev/netmap/netmap_kern.h | 4 +++-
sys/dev/netmap/netmap_vale.c | 13 +++++++++----
5 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/share/man/man4/netmap.4 b/share/man/man4/netmap.4
index 46a2f53b9b1f..535b2dfdfb4e 100644
--- a/share/man/man4/netmap.4
+++ b/share/man/man4/netmap.4
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 3, 2020
+.Dd March 6, 2022
.Dt NETMAP 4
.Os
.Sh NAME
@@ -933,6 +933,11 @@ Batch size used when moving packets across a
switch.
Values above 64 generally guarantee good
performance.
+.It Va dev.netmap.max_bridges: 8
+Max number of
+.Nm VALE
+switches that can be created. This tunable can be specified
+at loader time.
.It Va dev.netmap.ptnet_vnet_hdr: 1
Allow ptnet devices to use virtio-net headers
.El
diff --git a/share/man/man4/vale.4 b/share/man/man4/vale.4
index a28114470a6e..f805b1b4031b 100644
--- a/share/man/man4/vale.4
+++ b/share/man/man4/vale.4
@@ -28,7 +28,7 @@
.\" $FreeBSD$
.\" $Id: $
.\"
-.Dd February 6, 2020
+.Dd March 6, 2022
.Dt VALE 4
.Os
.Sh NAME
@@ -77,7 +77,8 @@ See
for details on the API.
.Ss LIMITS
.Nm
-currently supports up to 8 switches, with 254 ports per switch.
+currently supports up to 254 ports per switch. The maximum
+number of switches is provided by the max_bridges sysctl variable.
.Sh SYSCTL VARIABLES
See
.Xr netmap 4
diff --git a/sys/dev/netmap/netmap_bdg.c b/sys/dev/netmap/netmap_bdg.c
index 103a3b00762e..1d49a97eec12 100644
--- a/sys/dev/netmap/netmap_bdg.c
+++ b/sys/dev/netmap/netmap_bdg.c
@@ -1828,7 +1828,7 @@ netmap_init_bridges(void)
#ifdef CONFIG_NET_NS
return netmap_bns_register();
#else
- nm_bridges = netmap_init_bridges2(NM_BRIDGES);
+ nm_bridges = netmap_init_bridges2(vale_max_bridges);
if (nm_bridges == NULL)
return ENOMEM;
return 0;
@@ -1841,6 +1841,6 @@ netmap_uninit_bridges(void)
#ifdef CONFIG_NET_NS
netmap_bns_unregister();
#else
- netmap_uninit_bridges2(nm_bridges, NM_BRIDGES);
+ netmap_uninit_bridges2(nm_bridges, vale_max_bridges);
#endif
}
diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h
index 5d8957241c21..f8d824f08ebb 100644
--- a/sys/dev/netmap/netmap_kern.h
+++ b/sys/dev/netmap/netmap_kern.h
@@ -1559,6 +1559,8 @@ int netmap_get_vale_na(struct nmreq_header *hdr, struct netmap_adapter **na,
void *netmap_vale_create(const char *bdg_name, int *return_status);
int netmap_vale_destroy(const char *bdg_name, void *auth_token);
+extern unsigned int vale_max_bridges;
+
#else /* !WITH_VALE */
#define netmap_bdg_learning(_1, _2, _3, _4) 0
#define netmap_get_vale_na(_1, _2, _3, _4) 0
@@ -1606,7 +1608,7 @@ extern struct nm_bridge *nm_bridges;
#define netmap_bns_get()
#define netmap_bns_put(_1)
#define netmap_bns_getbridges(b, n) \
- do { *b = nm_bridges; *n = NM_BRIDGES; } while (0)
+ do { *b = nm_bridges; *n = vale_max_bridges; } while (0)
#endif
/* Various prototypes */
diff --git a/sys/dev/netmap/netmap_vale.c b/sys/dev/netmap/netmap_vale.c
index aac4cfe6736a..7813984ad295 100644
--- a/sys/dev/netmap/netmap_vale.c
+++ b/sys/dev/netmap/netmap_vale.c
@@ -84,10 +84,9 @@ __FBSDID("$FreeBSD$");
/*
* system parameters (most of them in netmap_kern.h)
- * NM_BDG_NAME prefix for switch port names, default "vale"
+ * NM_BDG_NAME prefix for switch port names, default "vale"
* NM_BDG_MAXPORTS number of ports
- * NM_BRIDGES max number of switches in the system.
- * XXX should become a sysctl or tunable
+ * NM_BRIDGES max number of switches in the system.
*
* Switch ports are named valeX:Y where X is the switch name and Y
* is the port. If Y matches a physical interface name, the port is
@@ -115,10 +114,16 @@ __FBSDID("$FreeBSD$");
* last packet in the block may overflow the size.
*/
static int bridge_batch = NM_BDG_BATCH; /* bridge batch size */
+
+/* Max number of vale bridges (loader tunable). */
+unsigned int vale_max_bridges = NM_BRIDGES;
+
SYSBEGIN(vars_vale);
SYSCTL_DECL(_dev_netmap);
SYSCTL_INT(_dev_netmap, OID_AUTO, bridge_batch, CTLFLAG_RW, &bridge_batch, 0,
"Max batch size to be used in the bridge");
+SYSCTL_UINT(_dev_netmap, OID_AUTO, max_bridges, CTLFLAG_RDTUN, &vale_max_bridges, 0,
+ "Max number of vale bridges");
SYSEND;
static int netmap_vale_vp_create(struct nmreq_header *hdr, struct ifnet *,
@@ -366,7 +371,7 @@ netmap_vale_list(struct nmreq_header *hdr)
j = req->nr_port_idx;
NMG_LOCK();
- for (error = ENOENT; i < NM_BRIDGES; i++) {
+ for (error = ENOENT; i < vale_max_bridges; i++) {
b = bridges + i;
for ( ; j < NM_BDG_MAXPORTS; j++) {
if (b->bdg_ports[j] == NULL)