net: mana: Add Interrupt Moderation support
Subsystems (5)
PATCH v5 1/1 net: mana: Add Interrupt Moderation support
From: Haiyang Zhang <[email protected]>
Add Static and Dynamic Interrupt Moderation (DIM) support for Rx and Tx.
Update queue creation procedure with new data struct with the related settings.
Add functions to collect stat for DIM, and workers to update DIM data and settings.
Update ethtool handler to get/set the moderation settings from a user. To avoid detach/re-attach ops, ring DIM doorbell to change settings at run time.
By default, adaptive-rx/tx (DIM) are enabled if supported by HW.
---
v5:
Updated function return type and comments suggested by Paolo Abeni.
v4:
Fixed tx stat, concurrency, and mb issues from Simon's review.
v3:
Updated to avoid detach/re-attach ops as suggested by Paolo.
v2:
Updated with comments from Jedrzej.
--- drivers/net/ethernet/microsoft/Kconfig | 1 + .../net/ethernet/microsoft/mana/gdma_main.c | 29 +++ drivers/net/ethernet/microsoft/mana/mana_en.c | 175 ++++++++++++++++++ .../ethernet/microsoft/mana/mana_ethtool.c | 167 ++++++++++++++++- include/net/mana/gdma.h | 24 ++- include/net/mana/mana.h | 54 ++++++ 6 files changed, 441 insertions(+), 9 deletions(-)
drivers/net/ethernet/microsoft/Kconfig +1 -0
@@ -21,6 +21,7 @@ config MICROSOFT_MANA depends on X86_64 || (ARM64 && !CPU_BIG_ENDIAN) depends on PCI_HYPERV select AUXILIARY_BUS + select DIMLIB select PAGE_POOL select NET_SHAPER help
drivers/net/ethernet/microsoft/mana/gdma_main.c +29 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* Copyright (c) 2021, Microsoft Corporation. */ +#include <linux/bitfield.h> #include <linux/debugfs.h> #include <linux/module.h> #include <linux/pci.h>
@@ -466,6 +467,7 @@ static int mana_gd_disable_queue(struct gdma_queue *queue)#define DOORBELL_OFFSET_RQ 0x400#define DOORBELL_OFFSET_CQ 0x800#define DOORBELL_OFFSET_EQ 0xFF8 +#define DOORBELL_OFFSET_DIM 0x820 static void mana_gd_ring_doorbell(struct gdma_context *gc, u32 db_index, enum gdma_queue_type q_type, u32 qid,
@@ -506,6 +508,16 @@ static void mana_gd_ring_doorbell(struct gdma_context *gc, u32 db_index, addr +=DOORBELL_OFFSET_SQ ;break ; +case GDMA_DIM : + e.dim.id = qid; + e.dim.mod_usec =FIELD_GET (MANA_INTR_MODR_USEC_MAX , tail_ptr); + e.dim.mod_usec_vld = !!(tail_ptr &MANA_INTR_MODR_USEC_VLD ); + e.dim.mod_comps =FIELD_GET (MANA_INTR_MODR_COMP_MASK , tail_ptr); + e.dim.mod_comps_vld = num_req; + + addr +=DOORBELL_OFFSET_DIM ; +break ; +default :WARN_ON (1 );return ;
@@ -540,6 +552,23 @@ void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit) }EXPORT_SYMBOL_NS (mana_gd_ring_cq,"NET_MANA" ); +void mana_gd_ring_dim (struct gdma_queue *cq,u32 mod_usec,bool mod_usec_vld, +u32 mod_comps,bool mod_comps_vld) +{ +struct gdma_context *gc = cq->gdma_dev->gdma_context; +u32 dim_val; + +/* Convert the DIM values to doorbell parameters */ + dim_val =FIELD_PREP (MANA_INTR_MODR_USEC_MAX , mod_usec) | +FIELD_PREP (MANA_INTR_MODR_COMP_MASK , mod_comps); +if (mod_usec_vld) + dim_val |=MANA_INTR_MODR_USEC_VLD ; + +mana_gd_ring_doorbell (gc, cq->gdma_dev->doorbell,GDMA_DIM , cq->id, + dim_val, mod_comps_vld); +} +EXPORT_SYMBOL_NS (mana_gd_ring_dim,"NET_MANA" ); +#define MANA_SERVICE_PERIOD 10static void mana_serv_rescan (struct pci_dev *pdev)
drivers/net/ethernet/microsoft/mana/mana_en.c +175 -0
265 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +159 -8
199 lines not on this page · raw message
include/net/mana/gdma.h +23 -1
@@ -47,6 +47,7 @@ enum gdma_queue_type {GDMA_RQ ,GDMA_CQ ,GDMA_EQ , + GDMA_DIM, }; enum gdma_work_request_flags {
@@ -126,6 +127,17 @@ union gdma_doorbell_entry { u64 tail_ptr : 31; u64 arm : 1; } eq; + +struct { +u64 id :24 ; +u64 reserved :8 ; +u64 mod_usec :10 ; +u64 reserve1 :5 ; +u64 mod_usec_vld :1 ; +u64 mod_comps :8 ; +u64 reserve2 :7 ; +u64 mod_comps_vld:1 ; + } dim; };/* HW DATA */ struct gdma_msg_hdr {
@@ -502,6 +514,9 @@ void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit);int mana_schedule_serv_work (struct gdma_context *gc,enum gdma_eqe_type type); +void mana_gd_ring_dim (struct gdma_queue *cq,u32 mod_usec,bool mod_usec_vld, +u32 mod_comps,bool mod_comps_vld); +struct gdma_wqe {u32 reserved :24 ;u32 last_vbytes :8 ;
@@ -650,6 +665,9 @@ enum {/* Driver supports self recovery on Hardware Channel timeouts */ #define GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECOVERY BIT(25) +/* Driver supports dynamic interrupt moderation - DIM */ +#define GDMA_DRV_CAP_FLAG_1_DYN_INTERRUPT_MODERATION BIT(28) +#define GDMA_DRV_CAP_FLAGS1 \ (GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \ GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \
@@ -665,7 +683,8 @@ enum {GDMA_DRV_CAP_FLAG_1_PROBE_RECOVERY | \GDMA_DRV_CAP_FLAG_1_HANDLE_STALL_SQ_RECOVERY | \GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECOVERY | \ - GDMA_DRV_CAP_FLAG_1_EQ_MSI_UNSHARE_MULTI_VPORT) +GDMA_DRV_CAP_FLAG_1_EQ_MSI_UNSHARE_MULTI_VPORT | \ + GDMA_DRV_CAP_FLAG_1_DYN_INTERRUPT_MODERATION) #define GDMA_DRV_CAP_FLAGS2 0
@@ -701,6 +720,9 @@ struct gdma_verify_ver_req {u8 os_ver_str4[128 ]; };/* HW DATA */ +/* HW supports dynamic interrupt moderation - DIM */ +#define GDMA_PF_CAP_FLAG_1_DYN_INTERRUPT_MODERATION BIT(15) +struct gdma_verify_ver_resp {struct gdma_resp_hdr hdr;u64 gdma_protocol_ver;
include/net/mana/mana.h +54 -0
102 lines not on this page · raw message
Signature · 1 line
2.34.1
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 13 lines · On Thu, 2 Jul 2026 15:01:04 -0700 you wrote:
From: Haiyang Zhang <[email protected]>
Add Static and Dynamic Interrupt Moderation (DIM) support for Rx and Tx.
Update queue creation procedure with new data struct with the related settings.
Add functions to collect stat for DIM, and workers to update DIM data and settings.
Update ethtool handler to get/set the moderation settings from a user. To avoid detach/re-attach ops, ring DIM doorbell to change settings at run time.
By default, adaptive-rx/tx (DIM) are enabled if supported by HW.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v5] net: mana: Add Interrupt Moderation support
https://git.kernel.org/netdev/net-next/c/433f482add31
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html