git: 3c7da27a473e - main - iflib: Add sysctl to request extra MSIX vectors on driver load

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Thu, 18 Apr 2024 23:23:17 UTC
The branch main has been updated by erj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c7da27a473e339392121404e06c506df040c16f

commit 3c7da27a473e339392121404e06c506df040c16f
Author:     Eric Joyner <erj@FreeBSD.org>
AuthorDate: 2023-03-22 19:18:44 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2024-04-18 23:13:47 +0000

    iflib: Add sysctl to request extra MSIX vectors on driver load
    
    Intended to be used with upcoming feature to add sub-interfaces, since
    those new interfaces will be dynamically created and will need to have
    spare MSI-X interrupts already allocated for them on driver load.
    
    This sysctl is marked as a tunable since it will need to be set before
    the driver is loaded since MSI-X interrupt allocation and setup is
    done during the attach process.
    
    Signed-off-by: Eric Joyner <erj@FreeBSD.org>
    
    MFC after:      3 days
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D41326
---
 sys/net/iflib.c | 14 ++++++++++++++
 sys/net/iflib.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 5e1f71f6f9c2..9be99df08a81 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -194,6 +194,7 @@ struct iflib_ctx {
 #define	CORE_OFFSET_UNSPECIFIED	0xffff
 	uint8_t  ifc_sysctl_separate_txrx;
 	uint8_t  ifc_sysctl_use_logical_cores;
+	uint16_t ifc_sysctl_extra_msix_vectors;
 	bool	 ifc_cpus_are_physical_cores;
 
 	qidx_t ifc_sysctl_ntxds[8];
@@ -264,6 +265,13 @@ iflib_get_sctx(if_ctx_t ctx)
 	return (ctx->ifc_sctx);
 }
 
+uint16_t
+iflib_get_extra_msix_vectors_sysctl(if_ctx_t ctx)
+{
+
+	return (ctx->ifc_sysctl_extra_msix_vectors);
+}
+
 #define IP_ALIGNED(m) ((((uintptr_t)(m)->m_data) & 0x3) == 0x2)
 #define CACHE_PTR_INCREMENT (CACHE_LINE_SIZE/sizeof(void*))
 #define CACHE_PTR_NEXT(ptr) ((void *)(((uintptr_t)(ptr)+CACHE_LINE_SIZE-1) & (CACHE_LINE_SIZE-1)))
@@ -6803,6 +6811,12 @@ iflib_add_device_sysctl_pre(if_ctx_t ctx)
 	SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "use_logical_cores",
 	    CTLFLAG_RDTUN, &ctx->ifc_sysctl_use_logical_cores, 0,
 	    "try to make use of logical cores for TX and RX");
+	SYSCTL_ADD_U16(ctx_list, oid_list, OID_AUTO, "use_extra_msix_vectors",
+	    CTLFLAG_RDTUN, &ctx->ifc_sysctl_extra_msix_vectors, 0,
+	    "attempt to reserve the given number of extra MSI-X vectors during driver load for the creation of additional interfaces later");
+	SYSCTL_ADD_INT(ctx_list, oid_list, OID_AUTO, "allocated_msix_vectors",
+       	    CTLFLAG_RDTUN, &ctx->ifc_softc_ctx.isc_vectors, 0,
+	    "total # of MSI-X vectors allocated by driver");
 
 	/* XXX change for per-queue sizes */
 	SYSCTL_ADD_PROC(ctx_list, oid_list, OID_AUTO, "override_ntxds",
diff --git a/sys/net/iflib.h b/sys/net/iflib.h
index b16e2805aab6..5e1adccf202c 100644
--- a/sys/net/iflib.h
+++ b/sys/net/iflib.h
@@ -489,5 +489,6 @@ void iflib_led_create(if_ctx_t ctx);
 
 void iflib_add_int_delay_sysctl(if_ctx_t, const char *, const char *,
 								if_int_delay_info_t, int, int);
+uint16_t iflib_get_extra_msix_vectors_sysctl(if_ctx_t ctx);
 
 #endif /*  __IFLIB_H_ */