diff options
author | Kevin Bowling <kbowling@FreeBSD.org> | 2024-09-27 08:03:31 +0000 |
---|---|---|
committer | Kevin Bowling <kbowling@FreeBSD.org> | 2024-09-27 08:30:05 +0000 |
commit | 9bf9164fc8aad1ca828c725413e06462aef1e4dd (patch) | |
tree | 32781a98c83354a0836e802a2c8a4dbdfff0354b | |
parent | 1c578f1c93112d3d53820f8b6b411488b83f0ab2 (diff) | |
download | src-9bf9164fc8aa.tar.gz src-9bf9164fc8aa.zip |
e1000: Clean up ITR/EITR in preparation for AIM
Provide macros to derive the various needed values and make it a bit
more clear the differences between em and igb.
The igb default EITR was not landing at the right offset.
Respect the 'max_interrupt_rate' tunable.
MFC after: 1 week
Sponsored by: BBOX.io
-rw-r--r-- | sys/dev/e1000/if_em.c | 20 | ||||
-rw-r--r-- | sys/dev/e1000/if_em.h | 11 |
2 files changed, 17 insertions, 14 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index cdadec17e355..b9c6131e6741 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -499,9 +499,6 @@ static driver_t igb_if_driver = { #define EM_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000) #define EM_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024) -#define MAX_INTS_PER_SEC 8000 -#define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) - /* Allow common code without TSO */ #ifndef CSUM_TSO #define CSUM_TSO 0 @@ -551,7 +548,7 @@ SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, /* ** Tuneable Interrupt rate */ -static int em_max_interrupt_rate = 8000; +static int em_max_interrupt_rate = EM_INTS_PER_SEC; SYSCTL_INT(_hw_em, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &em_max_interrupt_rate, 0, "Maximum interrupts per second"); @@ -1050,7 +1047,8 @@ em_if_attach_pre(if_ctx_t ctx) E1000_REGISTER(hw, E1000_TADV), em_tx_abs_int_delay_dflt); em_add_int_delay_sysctl(sc, "itr", "interrupt delay limit in usecs/4", &sc->tx_itr, - E1000_REGISTER(hw, E1000_ITR), DEFAULT_ITR); + E1000_REGISTER(hw, E1000_ITR), + EM_INTS_TO_ITR(em_max_interrupt_rate)); } hw->mac.autoneg = DO_AUTO_NEG; @@ -2287,7 +2285,7 @@ igb_configure_queues(struct e1000_softc *sc) /* Set the igb starting interrupt rate */ if (em_max_interrupt_rate > 0) { - newitr = (4000000 / em_max_interrupt_rate) & 0x7FFC; + newitr = IGB_INTS_TO_EITR(em_max_interrupt_rate); if (hw->mac.type == e1000_82575) newitr |= newitr << 16; @@ -3386,11 +3384,9 @@ em_initialize_receive_unit(if_ctx_t ctx) if (hw->mac.type >= e1000_82540) { E1000_WRITE_REG(hw, E1000_RADV, sc->rx_abs_int_delay.value); - /* - * Set the interrupt throttling rate. Value is calculated - * as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns) - */ - E1000_WRITE_REG(hw, E1000_ITR, DEFAULT_ITR); + /* Set the default interrupt throttling rate */ + E1000_WRITE_REG(hw, E1000_ITR, + EM_INTS_TO_ITR(em_max_interrupt_rate)); } /* XXX TEMPORARY WORKAROUND: on some systems with 82573 @@ -3418,7 +3414,7 @@ em_initialize_receive_unit(if_ctx_t ctx) if (hw->mac.type == e1000_82574) { for (int i = 0; i < 4; i++) E1000_WRITE_REG(hw, E1000_EITR_82574(i), - DEFAULT_ITR); + EM_INTS_TO_ITR(em_max_interrupt_rate)); /* Disable accelerated acknowledge */ rfctl |= E1000_RFCTL_ACK_DIS; } diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 244762e8ed0d..7219dc57c333 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -244,8 +244,15 @@ #define IGB_MEDIA_RESET (1 << 0) /* Define the starting Interrupt rate per Queue */ -#define IGB_INTS_PER_SEC 8000 -#define IGB_DEFAULT_ITR ((1000000/IGB_INTS_PER_SEC) << 2) +#define EM_INTS_PER_SEC 8000 +#define EM_INTS_MULTIPLIER 256 +#define EM_ITR_DIVIDEND 1000000000 +#define EM_INTS_TO_ITR(i) (EM_ITR_DIVIDEND/(i * EM_INTS_MULTIPLIER)) +#define IGB_ITR_DIVIDEND 1000000 +#define IGB_ITR_SHIFT 2 +#define IGB_QVECTOR_MASK 0x7FFC +#define IGB_INTS_TO_EITR(i) (((IGB_ITR_DIVIDEND/i) & IGB_QVECTOR_MASK) << \ + IGB_ITR_SHIFT) #define IGB_LINK_ITR 2000 #define I210_LINK_DELAY 1000 |