From 5e5fe7291a1f235c690b9758711c0397002de5fd Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 7 Feb 2024 14:44:37 +0100 Subject: [PATCH] nic/ipxe: add throttle RX interrupt support The commit adds support to throttle the rate of the RX IRQs to a specified value. The effect is, that no RX IRQs below the time threshold will fire and therefore the CPU load gets reduced on the host. Trade-off gaming between cpu load, throughput, overload. Modular Sculpt 23.10 on S938 as testcase. In brackets the CPU affinity is denoted. ipxe (0,0) -> nic_router (1,0) -> Debian VM vbox6 (3,0) and (3,1) VM: iperf -C X.X.X.X -t 60 -R iperf server X.X.X.X is outside Sculpt and sends data due to '-R' to VM Non representative measure points: cpu load - ipxe - nic_router - iperf throughput -------------------------------------------------- w/o patch - ~80% - ~50% - ~706 MBit/s - 0 -> throttling off by default on S938 patch 651 - ~20% - ~35% - ~763 MBit/s - 651 -> 0.166ms throttle RX IRQ patch 5580 - ~15% - ~25% - ~650 MBit/s - 5580 -> 1.4ms throttle RX IRQ Issue #5149 --- .../dde_ipxe/patches/intel_rx_throttle.patch | 42 +++++++++++++++++++ repos/dde_ipxe/ports/dde_ipxe.hash | 2 +- repos/dde_ipxe/ports/dde_ipxe.port | 3 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 repos/dde_ipxe/patches/intel_rx_throttle.patch diff --git a/repos/dde_ipxe/patches/intel_rx_throttle.patch b/repos/dde_ipxe/patches/intel_rx_throttle.patch new file mode 100644 index 0000000000..7d3518d753 --- /dev/null +++ b/repos/dde_ipxe/patches/intel_rx_throttle.patch @@ -0,0 +1,42 @@ +--- a/src/drivers/net/intel.c ++++ b/src/drivers/net/intel.c +@@ -681,6 +681,27 @@ + intel->force_icr = INTEL_IRQ_RXT0; + } + ++ /* ++ * Intel PCI/PCI-X family of Gigabit Ethernet control Software Developers's ++ * Manual Rev 4.0 ++ * ++ * 13.4.18 Interrupt Throttling Register ++ * advises - 651 to 5580 - for "optimal performance setting" ++ */ ++ ++ uint32_t const throttle_before = readl ( intel->regs + INTEL_ITR ); ++ uint32_t const throttle = 651; /* 651 * 256µs -> 0.166 ms */ ++ ++ writel( throttle, intel->regs + INTEL_ITR ); ++ ++ uint64_t const value = readl ( intel->regs + INTEL_ITR ); ++ ++ dde_printf("throttle RX interrupt %luµs%s -> %luµs - %s\n", ++ 256ul * throttle_before / 1000ul, ++ throttle_before ? "" : "(off)", ++ 256ul * value / 1000ul, ++ value == throttle ? "succeeded" : "failed"); ++ + return 0; + + intel_destroy_ring ( intel, &intel->rx ); +--- a/src/drivers/net/intel.h ++++ b/src/drivers/net/intel.h +@@ -102,6 +102,9 @@ + #define INTEL_IRQ_RXO 0x00000040UL /**< Receive overrun */ + #define INTEL_IRQ_RXT0 0x00000080UL /**< Receive timer */ + ++/** Interrupt throttling Register */ ++#define INTEL_ITR 0x000C4UL ++ + /** Interrupt Mask Set/Read Register */ + #define INTEL_IMS 0x000d0UL + diff --git a/repos/dde_ipxe/ports/dde_ipxe.hash b/repos/dde_ipxe/ports/dde_ipxe.hash index 17cbf4fa29..931410cb53 100644 --- a/repos/dde_ipxe/ports/dde_ipxe.hash +++ b/repos/dde_ipxe/ports/dde_ipxe.hash @@ -1 +1 @@ -c20a39b17bca4d9cefcee43f366f5c23296396e0 +a7206d6c2a1b2de7fa7fde6733a3500411a64de2 diff --git a/repos/dde_ipxe/ports/dde_ipxe.port b/repos/dde_ipxe/ports/dde_ipxe.port index 426ec7c82b..797c63f30d 100644 --- a/repos/dde_ipxe/ports/dde_ipxe.port +++ b/repos/dde_ipxe/ports/dde_ipxe.port @@ -11,7 +11,8 @@ PATCHES := patches/dde_ipxe.patch \ patches/intel_update.patch \ patches/tg3.patch \ patches/realtek.patch \ - patches/intel_tx_batch.patch + patches/intel_tx_batch.patch \ + patches/intel_rx_throttle.patch PATCH_OPT := -p1 -d ${DIR(ipxe)}