Skip to contentSkip to conversation

eth: fbnic: Add ethtool support for IRQ coalescing

PATCH Applied Mohsin Bashir 3 participants 3 messages Feb 18, 2025 – Feb 20, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 eth: fbnic: Add ethtool support for IRQ coalescing

Add ethtool support to configure the IRQ coalescing behavior. Support separate timers for Rx and Tx for time based coalescing. For frame based configuration, currently we only support the Rx side.

The hardware allows configuration of descriptor count instead of frame count requiring conversion between the two. We assume 2 descriptors per frame, one for the metadata and one for the data segment.

When rx-frames are not configured, we set the RX descriptor count to half the ring size as a fail safe.

Default configuration:

ethtool -c eth0 | grep -E "rx-usecs:|tx-usecs:|rx-frames:"
rx-usecs:       30
rx-frames:      0
tx-usecs:       35

IRQ rate test:
With single iperf flow we monitor IRQ rate while changing the tx-usesc and rx-usecs to high and low values.

ethtool -C eth0 rx-frames 8192 rx-usecs 150 tx-usecs 150

irq/sec   13k
irq/sec   14k
irq/sec   14k

ethtool -C eth0 rx-frames 8192 rx-usecs 10 tx-usecs 10

irq/sec  27k
irq/sec  28k
irq/sec  28k

Validating the use of extack:
ethtool -C eth0 rx-frames 16384
netlink error: fbnic: rx_frames is above device max netlink error: Invalid argument

---
V4: Add missing 'Reviewed-by' tags

V3: https://lore.kernel.org/netdev/[email protected]
- Rebased on the net-next

V2: https://lore.kernel.org/netdev/[email protected]
- Update fbnic_set_coalesce() to use extack to highlight incorrect config
- Simplify fbnic_config_rx_frames()

V1: https://lore.kernel.org/netdev/[email protected]

---
 drivers/net/ethernet/meta/fbnic/fbnic.h       |  3 +
 .../net/ethernet/meta/fbnic/fbnic_ethtool.c   | 60 +++++++++++++++++++
 .../net/ethernet/meta/fbnic/fbnic_netdev.c    |  4 ++
 .../net/ethernet/meta/fbnic/fbnic_netdev.h    |  6 ++
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c  | 53 +++++++++++++---
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.h  |  3 +
 6 files changed, 121 insertions(+), 8 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic.h +3 -0
index 37f81db1fc30..4ca7b99ef131 100644
@@ -186,6 +186,9 @@ void fbnic_dbg_exit(void);
 void fbnic_csr_get_regs(struct fbnic_dev *fbd, u32 *data, u32 *regs_version);
 int fbnic_csr_regs_len(struct fbnic_dev *fbd);
 
+void fbnic_config_txrx_usecs(struct fbnic_napi_vector *nv, u32 arm);
+void fbnic_config_rx_frames(struct fbnic_napi_vector *nv);
+
 enum fbnic_boards {
 	fbnic_board_asic
 };
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +60 -0

76 lines not on this page · raw message

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +4 -0
index c59f1ce8de32..cf8feb90b617 100644
@@ -641,6 +641,10 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
 	fbn->ppq_size = FBNIC_PPQ_SIZE_DEFAULT;
 	fbn->rcq_size = FBNIC_RCQ_SIZE_DEFAULT;
 
+	fbn->tx_usecs = FBNIC_TX_USECS_DEFAULT;
+	fbn->rx_usecs = FBNIC_RX_USECS_DEFAULT;
+	fbn->rx_max_frames = FBNIC_RX_FRAMES_DEFAULT;
+
 	default_queues = netif_get_num_default_rss_queues();
 	if (default_queues > fbd->max_num_queues)
 		default_queues = fbd->max_num_queues;
drivers/net/ethernet/meta/fbnic/fbnic_netdev.h +6 -0
index b84b447a8d8a..561837e80ec8 100644
@@ -12,6 +12,7 @@
 #include "fbnic_txrx.h"
 
 #define FBNIC_MAX_NAPI_VECTORS		128u
+#define FBNIC_MIN_RXD_PER_FRAME		2
 
 /* Natively supported tunnel GSO features (not thru GSO_PARTIAL) */
 #define FBNIC_TUN_GSO_FEATURES		NETIF_F_GSO_IPXIP6
@@ -30,6 +31,11 @@ struct fbnic_net {
 	u32 ppq_size;
 	u32 rcq_size;
 
+	u16 rx_usecs;
+	u16 tx_usecs;
+
+	u32 rx_max_frames;
+
 	u16 num_napi;
 
 	struct phylink *phylink;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +45 -8

74 lines not on this page · raw message

drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +3 -0
index 89a5c394f846..54368dc22328 100644
@@ -31,6 +31,9 @@ struct fbnic_net;
 #define FBNIC_HPQ_SIZE_DEFAULT		256
 #define FBNIC_PPQ_SIZE_DEFAULT		256
 #define FBNIC_RCQ_SIZE_DEFAULT		1024
+#define FBNIC_TX_USECS_DEFAULT		35
+#define FBNIC_RX_USECS_DEFAULT		30
+#define FBNIC_RX_FRAMES_DEFAULT		0
 
 #define FBNIC_RX_TROOM \
 	SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
Signature · 1 line
2.43.5
Reviewed-by on v4 1/1
#1 lore raw
Quoted 32 lines · Mohsin Bashir

Add ethtool support to configure the IRQ coalescing behavior. Support separate timers for Rx and Tx for time based coalescing. For frame based configuration, currently we only support the Rx side.

The hardware allows configuration of descriptor count instead of frame count requiring conversion between the two. We assume 2 descriptors per frame, one for the metadata and one for the data segment.

When rx-frames are not configured, we set the RX descriptor count to half the ring size as a fail safe.

Default configuration:

ethtool -c eth0 | grep -E "rx-usecs:|tx-usecs:|rx-frames:"
rx-usecs:       30
rx-frames:      0
tx-usecs:       35

IRQ rate test:
With single iperf flow we monitor IRQ rate while changing the tx-usesc and rx-usecs to high and low values.

ethtool -C eth0 rx-frames 8192 rx-usecs 150 tx-usecs 150

irq/sec   13k
irq/sec   14k
irq/sec   14k

ethtool -C eth0 rx-frames 8192 rx-usecs 10 tx-usecs 10

irq/sec  27k
irq/sec  28k
irq/sec  28k
Quoted 8 lines

Validating the use of extack:
ethtool -C eth0 rx-frames 16384
netlink error: fbnic: rx_frames is above device max netlink error: Invalid argument

LGTM,

Signature · 2 lines
Regards,
Kalesh AP
#2 lore raw
In reply to Mohsin Bashir
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 17 Feb 2025 18:35:20 -0800 you wrote:

Add ethtool support to configure the IRQ coalescing behavior. Support separate timers for Rx and Tx for time based coalescing. For frame based configuration, currently we only support the Rx side.

The hardware allows configuration of descriptor count instead of frame count requiring conversion between the two. We assume 2 descriptors per frame, one for the metadata and one for the data segment.

[...]

Here is the summary with links:
- [net-next,V4] eth: fbnic: Add ethtool support for IRQ coalescing

    https://git.kernel.org/netdev/net-next/c/7b5b7a597fbc

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html