git: 1eb348e090fd - stable/13 - iflib: Add sysctl to request extra MSIX vectors on driver load

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Wed, 31 Jul 2024 04:38:19 UTC
The branch stable/13 has been updated by erj:

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

commit 1eb348e090fd3bda6c0f799fc4a22568f579f576
Author:     Eric Joyner <erj@FreeBSD.org>
AuthorDate: 2023-03-22 19:18:44 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2024-07-31 04:29:21 +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 fec432a0cb65..ed82ff9a3d09 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];
@@ -270,6 +271,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)))
@@ -7027,6 +7035,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 a444a4937a3c..f9b1045266c4 100644
--- a/sys/net/iflib.h
+++ b/sys/net/iflib.h
@@ -498,6 +498,7 @@ 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);
 
 /*
  * Pseudo device support