git: ff28ca091142 - stable/14 - iflib: Add sysctl to request extra MSIX vectors on driver load

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Wed, 24 Apr 2024 22:14:59 UTC
The branch stable/14 has been updated by erj:

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

commit ff28ca091142538330b3469be7c9af678db65107
Author:     Eric Joyner <erj@FreeBSD.org>
AuthorDate: 2023-03-22 19:18:44 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2024-04-24 22:14:48 +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>
    
    Sponsored by:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D41326
    
    (cherry picked from commit 3c7da27a473e339392121404e06c506df040c16f)
---
 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 999a86fabc79..ac27450480c9 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)))
@@ -6802,6 +6810,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_ */