netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] net: wangxun: complete ethtool coalesce options
@ 2025-07-24  8:05 Jiawen Wu
  2025-07-24  8:05 ` [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting Jiawen Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jiawen Wu @ 2025-07-24  8:05 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jacob Keller
  Cc: Mengyuan Lou, Jiawen Wu

Support to use adaptive RX coalescing. Change the default RX coalesce
usecs and limit the range of parameters for various types of devices,
according to their hardware design.

---
v3:
- detail the commits messages
- support DIM algorithm

v2: https://lore.kernel.org/all/20250721080103.30964-1-jiawenwu@trustnetic.com/
- split into 3 patches
- add missing functions
- adjust the weird codes and comments

v1: https://lore.kernel.org/all/3D9FB44035A7556E+20250714092811.51244-1-jiawenwu@trustnetic.com/ 
---

Jiawen Wu (3):
  net: wangxun: change the default ITR setting
  net: wangxun: limit tx_max_coalesced_frames_irq
  net: wangxun: support to use adaptive RX coalescing

 drivers/net/ethernet/wangxun/Kconfig          |   1 +
 .../net/ethernet/wangxun/libwx/wx_ethtool.c   |  41 +++----
 drivers/net/ethernet/wangxun/libwx/wx_lib.c   | 100 +++++++++++++++++-
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |   5 +
 .../net/ethernet/wangxun/libwx/wx_vf_lib.c    |   2 +-
 .../net/ethernet/wangxun/libwx/wx_vf_lib.h    |   1 +
 .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c  |   3 +-
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |   5 +-
 .../ethernet/wangxun/txgbe/txgbe_ethtool.c    |   3 +-
 9 files changed, 135 insertions(+), 26 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting
  2025-07-24  8:05 [PATCH net-next v3 0/3] net: wangxun: complete ethtool coalesce options Jiawen Wu
@ 2025-07-24  8:05 ` Jiawen Wu
  2025-07-26  0:30   ` Jakub Kicinski
  2025-07-24  8:05 ` [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq Jiawen Wu
  2025-07-24  8:05 ` [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing Jiawen Wu
  2 siblings, 1 reply; 9+ messages in thread
From: Jiawen Wu @ 2025-07-24  8:05 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jacob Keller
  Cc: Mengyuan Lou, Jiawen Wu

Change the default RX/TX ITR for wx_mac_em devices from 20K to 7K, which
is an experience value from out-of-tree ngbe driver, to get higher
performance on various platforms.

And cleanup the code for the next patches.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 .../net/ethernet/wangxun/libwx/wx_ethtool.c   | 24 +++++++------------
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |  5 ++--
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
index c12a4cb951f6..85fb23b238d1 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -340,13 +340,19 @@ int wx_set_coalesce(struct net_device *netdev,
 	switch (wx->mac.type) {
 	case wx_mac_sp:
 		max_eitr = WX_SP_MAX_EITR;
+		rx_itr_param = WX_20K_ITR;
+		tx_itr_param = WX_12K_ITR;
 		break;
 	case wx_mac_aml:
 	case wx_mac_aml40:
 		max_eitr = WX_AML_MAX_EITR;
+		rx_itr_param = WX_20K_ITR;
+		tx_itr_param = WX_12K_ITR;
 		break;
 	default:
 		max_eitr = WX_EM_MAX_EITR;
+		rx_itr_param = WX_7K_ITR;
+		tx_itr_param = WX_7K_ITR;
 		break;
 	}
 
@@ -359,9 +365,7 @@ int wx_set_coalesce(struct net_device *netdev,
 	else
 		wx->rx_itr_setting = ec->rx_coalesce_usecs;
 
-	if (wx->rx_itr_setting == 1)
-		rx_itr_param = WX_20K_ITR;
-	else
+	if (wx->rx_itr_setting != 1)
 		rx_itr_param = wx->rx_itr_setting;
 
 	if (ec->tx_coalesce_usecs > 1)
@@ -369,20 +373,8 @@ int wx_set_coalesce(struct net_device *netdev,
 	else
 		wx->tx_itr_setting = ec->tx_coalesce_usecs;
 
-	if (wx->tx_itr_setting == 1) {
-		switch (wx->mac.type) {
-		case wx_mac_sp:
-		case wx_mac_aml:
-		case wx_mac_aml40:
-			tx_itr_param = WX_12K_ITR;
-			break;
-		default:
-			tx_itr_param = WX_20K_ITR;
-			break;
-		}
-	} else {
+	if (wx->tx_itr_setting != 1)
 		tx_itr_param = wx->tx_itr_setting;
-	}
 
 	/* mixed Rx/Tx */
 	if (wx->q_vector[0]->tx.count && wx->q_vector[0]->rx.count)
diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
index e0fc897b0a58..3fff73ae44af 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
@@ -119,9 +119,8 @@ static int ngbe_sw_init(struct wx *wx)
 						   num_online_cpus());
 	wx->rss_enabled = true;
 
-	/* enable itr by default in dynamic mode */
-	wx->rx_itr_setting = 1;
-	wx->tx_itr_setting = 1;
+	wx->rx_itr_setting = WX_7K_ITR;
+	wx->tx_itr_setting = WX_7K_ITR;
 
 	/* set default ring sizes */
 	wx->tx_ring_count = NGBE_DEFAULT_TXD;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq
  2025-07-24  8:05 [PATCH net-next v3 0/3] net: wangxun: complete ethtool coalesce options Jiawen Wu
  2025-07-24  8:05 ` [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting Jiawen Wu
@ 2025-07-24  8:05 ` Jiawen Wu
  2025-07-26  0:31   ` Jakub Kicinski
  2025-07-24  8:05 ` [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing Jiawen Wu
  2 siblings, 1 reply; 9+ messages in thread
From: Jiawen Wu @ 2025-07-24  8:05 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jacob Keller
  Cc: Mengyuan Lou, Jiawen Wu

Add limitation on tx_max_coalesced_frames_irq as 0 ~ 65535, because
'wx->tx_work_limit' is declared as a member of type u16.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 7 +++++--
 drivers/net/ethernet/wangxun/libwx/wx_type.h    | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
index 85fb23b238d1..ebef99185bca 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -334,8 +334,11 @@ int wx_set_coalesce(struct net_device *netdev,
 			return -EOPNOTSUPP;
 	}
 
-	if (ec->tx_max_coalesced_frames_irq)
-		wx->tx_work_limit = ec->tx_max_coalesced_frames_irq;
+	if (ec->tx_max_coalesced_frames_irq > WX_MAX_TX_WORK ||
+	    !ec->tx_max_coalesced_frames_irq)
+		return -EINVAL;
+
+	wx->tx_work_limit = ec->tx_max_coalesced_frames_irq;
 
 	switch (wx->mac.type) {
 	case wx_mac_sp:
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index 9d5d10f9e410..5c52a1db4024 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -411,6 +411,7 @@ enum WX_MSCA_CMD_value {
 #define WX_7K_ITR                    595
 #define WX_12K_ITR                   336
 #define WX_20K_ITR                   200
+#define WX_MAX_TX_WORK               65535
 #define WX_SP_MAX_EITR               0x00000FF8U
 #define WX_AML_MAX_EITR              0x00000FFFU
 #define WX_EM_MAX_EITR               0x00007FFCU
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing
  2025-07-24  8:05 [PATCH net-next v3 0/3] net: wangxun: complete ethtool coalesce options Jiawen Wu
  2025-07-24  8:05 ` [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting Jiawen Wu
  2025-07-24  8:05 ` [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq Jiawen Wu
@ 2025-07-24  8:05 ` Jiawen Wu
  2025-07-26  0:34   ` Jakub Kicinski
  2 siblings, 1 reply; 9+ messages in thread
From: Jiawen Wu @ 2025-07-24  8:05 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Jacob Keller
  Cc: Mengyuan Lou, Jiawen Wu

Support to turn on/off adaptive RX coalesce. When adaptive RX coalesce
is on, use DIM algorithm for a dynamic interrupt moderation.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/Kconfig          |   1 +
 .../net/ethernet/wangxun/libwx/wx_ethtool.c   |  10 +-
 drivers/net/ethernet/wangxun/libwx/wx_lib.c   | 100 +++++++++++++++++-
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |   4 +
 .../net/ethernet/wangxun/libwx/wx_vf_lib.c    |   2 +-
 .../net/ethernet/wangxun/libwx/wx_vf_lib.h    |   1 +
 .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c  |   3 +-
 .../ethernet/wangxun/txgbe/txgbe_ethtool.c    |   3 +-
 8 files changed, 119 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/wangxun/Kconfig b/drivers/net/ethernet/wangxun/Kconfig
index 424ec3212128..d138dea7d208 100644
--- a/drivers/net/ethernet/wangxun/Kconfig
+++ b/drivers/net/ethernet/wangxun/Kconfig
@@ -20,6 +20,7 @@ config LIBWX
 	tristate
 	depends on PTP_1588_CLOCK_OPTIONAL
 	select PAGE_POOL
+	select DIMLIB
 	help
 	Common library for Wangxun(R) Ethernet drivers.
 
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
index ebef99185bca..f2d888825659 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -303,6 +303,9 @@ int wx_get_coalesce(struct net_device *netdev,
 	else
 		ec->rx_coalesce_usecs = wx->rx_itr_setting >> 2;
 
+	if (wx->rx_itr_setting == 1)
+		ec->use_adaptive_rx_coalesce = 1;
+
 	/* if in mixed tx/rx queues per vector mode, report only rx settings */
 	if (wx->q_vector[0]->tx.count && wx->q_vector[0]->rx.count)
 		return 0;
@@ -363,10 +366,15 @@ int wx_set_coalesce(struct net_device *netdev,
 	    (ec->tx_coalesce_usecs > (max_eitr >> 2)))
 		return -EINVAL;
 
+	if (ec->use_adaptive_rx_coalesce) {
+		wx->rx_itr_setting = 1;
+		return 0;
+	}
+
 	if (ec->rx_coalesce_usecs > 1)
 		wx->rx_itr_setting = ec->rx_coalesce_usecs << 2;
 	else
-		wx->rx_itr_setting = ec->rx_coalesce_usecs;
+		wx->rx_itr_setting = rx_itr_param;
 
 	if (wx->rx_itr_setting != 1)
 		rx_itr_param = wx->rx_itr_setting;
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index 723785ef87bb..8699103b59e5 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -16,6 +16,7 @@
 #include "wx_lib.h"
 #include "wx_ptp.h"
 #include "wx_hw.h"
+#include "wx_vf_lib.h"
 
 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
 static struct wx_dec_ptype wx_ptype_lookup[256] = {
@@ -832,6 +833,36 @@ static bool wx_clean_tx_irq(struct wx_q_vector *q_vector,
 	return !!budget;
 }
 
+static void wx_update_rx_dim_sample(struct wx_q_vector *q_vector)
+{
+	struct dim_sample sample = {};
+
+	dim_update_sample(q_vector->total_events,
+			  q_vector->rx.total_packets,
+			  q_vector->rx.total_bytes,
+			  &sample);
+
+	net_dim(&q_vector->rx.dim, &sample);
+}
+
+static void wx_update_tx_dim_sample(struct wx_q_vector *q_vector)
+{
+	struct dim_sample sample = {};
+
+	dim_update_sample(q_vector->total_events,
+			  q_vector->tx.total_packets,
+			  q_vector->tx.total_bytes,
+			  &sample);
+
+	net_dim(&q_vector->tx.dim, &sample);
+}
+
+static void wx_update_dim_sample(struct wx_q_vector *q_vector)
+{
+	wx_update_rx_dim_sample(q_vector);
+	wx_update_tx_dim_sample(q_vector);
+}
+
 /**
  * wx_poll - NAPI polling RX/TX cleanup routine
  * @napi: napi struct with our devices info in it
@@ -878,6 +909,8 @@ static int wx_poll(struct napi_struct *napi, int budget)
 
 	/* all work done, exit the polling mode */
 	if (likely(napi_complete_done(napi, work_done))) {
+		if (wx->rx_itr_setting == 1)
+			wx_update_dim_sample(q_vector);
 		if (netif_running(wx->netdev))
 			wx_intr_enable(wx, WX_INTR_Q(q_vector->v_idx));
 	}
@@ -1591,6 +1624,62 @@ netdev_tx_t wx_xmit_frame(struct sk_buff *skb,
 }
 EXPORT_SYMBOL(wx_xmit_frame);
 
+static void wx_set_itr(struct wx_q_vector *q_vector)
+{
+	struct wx *wx = q_vector->wx;
+	u32 new_itr;
+
+	/* use the smallest value of new ITR delay calculations */
+	new_itr = min(q_vector->rx.itr, q_vector->tx.itr);
+	new_itr <<= 2;
+
+	if (new_itr != q_vector->itr) {
+		/* save the algorithm value here */
+		q_vector->itr = new_itr;
+
+		if (wx->pdev->is_virtfn)
+			wx_write_eitr_vf(q_vector);
+		else
+			wx_write_eitr(q_vector);
+	}
+}
+
+static void wx_rx_dim_work(struct work_struct *work)
+{
+	struct dim *dim = container_of(work, struct dim, work);
+	struct dim_cq_moder rx_moder;
+	struct wx_ring_container *rx;
+	struct wx_q_vector *q_vector;
+
+	rx = container_of(dim, struct wx_ring_container, dim);
+
+	rx_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
+	rx->itr = rx_moder.usec;
+
+	q_vector = container_of(rx, struct wx_q_vector, rx);
+	wx_set_itr(q_vector);
+
+	dim->state = DIM_START_MEASURE;
+}
+
+static void wx_tx_dim_work(struct work_struct *work)
+{
+	struct dim *dim = container_of(work, struct dim, work);
+	struct dim_cq_moder tx_moder;
+	struct wx_ring_container *tx;
+	struct wx_q_vector *q_vector;
+
+	tx = container_of(dim, struct wx_ring_container, dim);
+
+	tx_moder = net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
+	tx->itr = tx_moder.usec;
+
+	q_vector = container_of(tx, struct wx_q_vector, tx);
+	wx_set_itr(q_vector);
+
+	dim->state = DIM_START_MEASURE;
+}
+
 void wx_napi_enable_all(struct wx *wx)
 {
 	struct wx_q_vector *q_vector;
@@ -1598,6 +1687,11 @@ void wx_napi_enable_all(struct wx *wx)
 
 	for (q_idx = 0; q_idx < wx->num_q_vectors; q_idx++) {
 		q_vector = wx->q_vector[q_idx];
+
+		INIT_WORK(&q_vector->rx.dim.work, wx_rx_dim_work);
+		INIT_WORK(&q_vector->tx.dim.work, wx_tx_dim_work);
+		q_vector->rx.dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;
+		q_vector->tx.dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;
 		napi_enable(&q_vector->napi);
 	}
 }
@@ -1611,6 +1705,8 @@ void wx_napi_disable_all(struct wx *wx)
 	for (q_idx = 0; q_idx < wx->num_q_vectors; q_idx++) {
 		q_vector = wx->q_vector[q_idx];
 		napi_disable(&q_vector->napi);
+		cancel_work_sync(&q_vector->rx.dim.work);
+		cancel_work_sync(&q_vector->tx.dim.work);
 	}
 }
 EXPORT_SYMBOL(wx_napi_disable_all);
@@ -2197,8 +2293,10 @@ irqreturn_t wx_msix_clean_rings(int __always_unused irq, void *data)
 	struct wx_q_vector *q_vector = data;
 
 	/* EIAM disabled interrupts (on this vector) for us */
-	if (q_vector->rx.ring || q_vector->tx.ring)
+	if (q_vector->rx.ring || q_vector->tx.ring) {
 		napi_schedule_irqoff(&q_vector->napi);
+		q_vector->total_events++;
+	}
 
 	return IRQ_HANDLED;
 }
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index 5c52a1db4024..a9572c8028b8 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -10,6 +10,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
 #include <linux/phylink.h>
+#include <linux/dim.h>
 #include <net/ip.h>
 
 #define WX_NCSI_SUP                             0x8000
@@ -1034,6 +1035,7 @@ struct wx_ring_container {
 	unsigned int total_packets;     /* total packets processed this int */
 	u8 count;                       /* total number of rings in vector */
 	u8 itr;                         /* current ITR setting for ring */
+	struct dim dim;                 /* data for net_dim algorithm */
 };
 struct wx_ring {
 	struct wx_ring *next;           /* pointer to next ring in q_vector */
@@ -1090,6 +1092,8 @@ struct wx_q_vector {
 	struct napi_struct napi;
 	struct rcu_head rcu;    /* to avoid race with update stats on free */
 
+	u16 total_events;       /* number of interrupts processed */
+
 	char name[IFNAMSIZ + 17];
 
 	/* for dynamic allocation of rings associated with this q_vector */
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
index 5d48df7a849f..7bcf7e90883b 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
@@ -10,7 +10,7 @@
 #include "wx_vf.h"
 #include "wx_vf_lib.h"
 
-static void wx_write_eitr_vf(struct wx_q_vector *q_vector)
+void wx_write_eitr_vf(struct wx_q_vector *q_vector)
 {
 	struct wx *wx = q_vector->wx;
 	int v_idx = q_vector->v_idx;
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.h b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.h
index 43ea126b79eb..a4bd23c92800 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.h
@@ -4,6 +4,7 @@
 #ifndef _WX_VF_LIB_H_
 #define _WX_VF_LIB_H_
 
+void wx_write_eitr_vf(struct wx_q_vector *q_vector);
 void wx_configure_msix_vf(struct wx *wx);
 int wx_write_uc_addr_list_vf(struct net_device *netdev);
 void wx_setup_psrtype_vf(struct wx *wx);
diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
index 7e2d9ec38a30..2ca127a7aa77 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
@@ -115,7 +115,8 @@ static int ngbe_set_channels(struct net_device *dev,
 
 static const struct ethtool_ops ngbe_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
-				     ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ,
+				     ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ |
+				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
 	.get_drvinfo		= wx_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
 	.get_link_ksettings	= wx_get_link_ksettings,
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c
index a4753402660e..86f3c106f1ed 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c
@@ -538,7 +538,8 @@ static int txgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
 
 static const struct ethtool_ops txgbe_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
-				     ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ,
+				     ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ |
+				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
 	.get_drvinfo		= wx_get_drvinfo,
 	.nway_reset		= wx_nway_reset,
 	.get_link		= ethtool_op_get_link,
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting
  2025-07-24  8:05 ` [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting Jiawen Wu
@ 2025-07-26  0:30   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-07-26  0:30 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Simon Horman, Jacob Keller, Mengyuan Lou

On Thu, 24 Jul 2025 16:05:46 +0800 Jiawen Wu wrote:
> Change the default RX/TX ITR for wx_mac_em devices from 20K to 7K, which
> is an experience value from out-of-tree ngbe driver, to get higher
> performance on various platforms.

"out-of-tree driver does it" + "higher performance on various platforms"
doesn't sound much in terms of justification. Shouldn't be too hard to
run a TCP_STREAM and TCP_RR tests and add the result to the commit msg..

> And cleanup the code for the next patches.

Should be a separate patch

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq
  2025-07-24  8:05 ` [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq Jiawen Wu
@ 2025-07-26  0:31   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-07-26  0:31 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Simon Horman, Jacob Keller, Mengyuan Lou

On Thu, 24 Jul 2025 16:05:47 +0800 Jiawen Wu wrote:
> Add limitation on tx_max_coalesced_frames_irq as 0 ~ 65535, because
> 'wx->tx_work_limit' is declared as a member of type u16.

okay if that's the case then..

> -	if (ec->tx_max_coalesced_frames_irq)
> -		wx->tx_work_limit = ec->tx_max_coalesced_frames_irq;
> +	if (ec->tx_max_coalesced_frames_irq > WX_MAX_TX_WORK ||

	if (ec->tx_max_coalesced_frames_irq > U16_MAX ||

? why create a new define if the boundary is basically dictated 
by type width?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing
  2025-07-24  8:05 ` [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing Jiawen Wu
@ 2025-07-26  0:34   ` Jakub Kicinski
  2025-07-28  2:15     ` Jiawen Wu
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-07-26  0:34 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Simon Horman, Jacob Keller, Mengyuan Lou

On Thu, 24 Jul 2025 16:05:48 +0800 Jiawen Wu wrote:
> Support to turn on/off adaptive RX coalesce. When adaptive RX coalesce
> is on, use DIM algorithm for a dynamic interrupt moderation.

you say Rx, and you add Rx as the flag

> +				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,

so far so good, but then you also have dim instances for Tx ?!

> +		q_vector->tx.dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;

> +static void wx_tx_dim_work(struct work_struct *work)

I don't get it.

> @@ -363,10 +366,15 @@ int wx_set_coalesce(struct net_device *netdev,
>  	    (ec->tx_coalesce_usecs > (max_eitr >> 2)))
>  		return -EINVAL;
>  
> +	if (ec->use_adaptive_rx_coalesce) {
> +		wx->rx_itr_setting = 1;
> +		return 0;
> +	}
> +
>  	if (ec->rx_coalesce_usecs > 1)
>  		wx->rx_itr_setting = ec->rx_coalesce_usecs << 2;
>  	else
> -		wx->rx_itr_setting = ec->rx_coalesce_usecs;
> +		wx->rx_itr_setting = rx_itr_param;

looks racy, you should probably cancel the DIM works?
Otherwise if the work is in flight as the user sets the values
the work will overwrite user settings.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing
  2025-07-26  0:34   ` Jakub Kicinski
@ 2025-07-28  2:15     ` Jiawen Wu
  2025-07-28 15:23       ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Jiawen Wu @ 2025-07-28  2:15 UTC (permalink / raw)
  To: 'Jakub Kicinski'
  Cc: netdev, 'Andrew Lunn', 'David S. Miller',
	'Eric Dumazet', 'Paolo Abeni',
	'Simon Horman', 'Jacob Keller',
	'Mengyuan Lou'

On Sat, Jul 26, 2025 8:34 AM, Jakub Kicinski wrote:
> On Thu, 24 Jul 2025 16:05:48 +0800 Jiawen Wu wrote:
> > Support to turn on/off adaptive RX coalesce. When adaptive RX coalesce
> > is on, use DIM algorithm for a dynamic interrupt moderation.
> 
> you say Rx, and you add Rx as the flag
> 
> > +				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
> 
> so far so good, but then you also have dim instances for Tx ?!

I hope RX and TX can share ITR value, because they share the interrupt.
Once adaptive RX coalesce is on, use the smallest value got from RX sample and TX sample.
If adaptive TX flag is also set, how should I properly set it? Cooperate with RX?

> 
> > +		q_vector->tx.dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;
> 
> > +static void wx_tx_dim_work(struct work_struct *work)
> 
> I don't get it.
> 
> > @@ -363,10 +366,15 @@ int wx_set_coalesce(struct net_device *netdev,
> >  	    (ec->tx_coalesce_usecs > (max_eitr >> 2)))
> >  		return -EINVAL;
> >
> > +	if (ec->use_adaptive_rx_coalesce) {
> > +		wx->rx_itr_setting = 1;
> > +		return 0;
> > +	}
> > +
> >  	if (ec->rx_coalesce_usecs > 1)
> >  		wx->rx_itr_setting = ec->rx_coalesce_usecs << 2;
> >  	else
> > -		wx->rx_itr_setting = ec->rx_coalesce_usecs;
> > +		wx->rx_itr_setting = rx_itr_param;
> 
> looks racy, you should probably cancel the DIM works?
> Otherwise if the work is in flight as the user sets the values
> the work will overwrite user settings.
> --
> pw-bot: cr
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing
  2025-07-28  2:15     ` Jiawen Wu
@ 2025-07-28 15:23       ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-07-28 15:23 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, 'Andrew Lunn', 'David S. Miller',
	'Eric Dumazet', 'Paolo Abeni',
	'Simon Horman', 'Jacob Keller',
	'Mengyuan Lou'

On Mon, 28 Jul 2025 10:15:42 +0800 Jiawen Wu wrote:
> > > +				     ETHTOOL_COALESCE_USE_ADAPTIVE_RX,  
> > 
> > so far so good, but then you also have dim instances for Tx ?!  
> 
> I hope RX and TX can share ITR value, because they share the interrupt.
> Once adaptive RX coalesce is on, use the smallest value got from RX sample and TX sample.
> If adaptive TX flag is also set, how should I properly set it? Cooperate with RX?

You can require that both adaptive-rx and adaptive-tx are set to the
same value.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-28 15:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24  8:05 [PATCH net-next v3 0/3] net: wangxun: complete ethtool coalesce options Jiawen Wu
2025-07-24  8:05 ` [PATCH net-next v3 1/3] net: wangxun: change the default ITR setting Jiawen Wu
2025-07-26  0:30   ` Jakub Kicinski
2025-07-24  8:05 ` [PATCH net-next v3 2/3] net: wangxun: limit tx_max_coalesced_frames_irq Jiawen Wu
2025-07-26  0:31   ` Jakub Kicinski
2025-07-24  8:05 ` [PATCH net-next v3 3/3] net: wangxun: support to use adaptive RX coalescing Jiawen Wu
2025-07-26  0:34   ` Jakub Kicinski
2025-07-28  2:15     ` Jiawen Wu
2025-07-28 15:23       ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).