iflib: Allow drivers to determine which queue to TX on

Adds a new function pointer to struct if_txrx in order to allow
drivers to set their own function that will determine which queue
a packet should be sent on.

Since this includes a kernel ABI change, bump the __FreeBSD_version
as well.

(This motivation behind this is to allow the driver to examine the
UP in the VLAN tag and determine which queue to TX on based on
that, in support of HW TX traffic shaping.)

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Reviewed by:	kbowling@, stallamr@netapp.com
Tested by:	jeffrey.e.pieper@intel.com
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D31485
This commit is contained in:
Eric Joyner 2021-07-29 16:24:14 -07:00
parent 4f0e50b293
commit 213e91399b
No known key found for this signature in database
GPG Key ID: 96F0C6FD61E05DE3
3 changed files with 20 additions and 6 deletions

View File

@ -209,6 +209,7 @@ struct iflib_ctx {
#define isc_rxd_refill ifc_txrx.ift_rxd_refill
#define isc_rxd_flush ifc_txrx.ift_rxd_flush
#define isc_legacy_intr ifc_txrx.ift_legacy_intr
#define isc_txq_select ifc_txrx.ift_txq_select
eventhandler_tag ifc_vlan_attach_event;
eventhandler_tag ifc_vlan_detach_event;
struct ether_addr ifc_mac;
@ -4153,11 +4154,14 @@ iflib_if_transmit(if_t ifp, struct mbuf *m)
MPASS(m->m_nextpkt == NULL);
/* ALTQ-enabled interfaces always use queue 0. */
qidx = 0;
if ((NTXQSETS(ctx) > 1) && M_HASHTYPE_GET(m) && !ALTQ_IS_ENABLED(&ifp->if_snd))
/* Use driver-supplied queue selection method if it exists */
if (ctx->isc_txq_select)
qidx = ctx->isc_txq_select(ctx->ifc_softc, m);
/* If not, use iflib's standard method */
else if ((NTXQSETS(ctx) > 1) && M_HASHTYPE_GET(m) && !ALTQ_IS_ENABLED(&ifp->if_snd))
qidx = QIDX(ctx, m);
/*
* XXX calculate buf_ring based on flowid (divvy up bits?)
*/
/* Set TX queue */
txq = &ctx->ifc_txqs[qidx];
#ifdef DRIVER_BACKPRESSURE

View File

@ -187,6 +187,7 @@ typedef struct if_txrx {
void (*ift_rxd_refill) (void * , if_rxd_update_t iru);
void (*ift_rxd_flush) (void *, uint16_t qsidx, uint8_t flidx, qidx_t pidx);
int (*ift_legacy_intr) (void *);
qidx_t (*ift_txq_select) (void *, struct mbuf *);
} *if_txrx_t;
typedef struct if_softc_ctx {
@ -397,7 +398,6 @@ typedef enum {
* emulating ethernet
*/
#define IFLIB_PSEUDO_ETHER 0x80000
/*
* Interface has an admin completion queue
*/
@ -407,6 +407,16 @@ typedef enum {
*/
#define IFLIB_PRESERVE_TX_INDICES 0x200000
/* The following IFLIB_FEATURE_* defines are for driver modules to determine
* what features this version of iflib supports. They shall be defined to the
* first __FreeBSD_version that introduced the feature.
*/
/*
* Driver can set its own TX queue selection function
* as ift_txq_select in struct if_txrx
*/
#define IFLIB_FEATURE_QUEUE_SELECT 1400050
/*
* These enum values are used in iflib_needs_restart to indicate to iflib
* functions whether or not the interface needs restarting when certain events

View File

@ -76,7 +76,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1400049
#define __FreeBSD_version 1400050
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,