Skip to contentSkip to conversation

hinic3: queue_api related fixes

PATCH Applied Gur Stavi 2 participants 5 messages Jun 9, 2025 – Jun 10, 2025

Subsystems (3)
lore
Share & tools
lore

Gur Stavi

author
#0 lore raw

v3 cover hinic3: queue_api related fixes

This patch series contains improvement to queue_api and 2 queue_api related patches to the hinic3 driver.

Changes:

v1: http://lore.kernel.org/netdev/[email protected]

v2: https://lore.kernel.org/netdev/[email protected]
* Update cover letter subject and text.
* Add 2 patches for user code related to queue api.

v3:
* Turn netif_subqueue_sent to inline function (Paolo Abeni)

Gur Stavi (3):
queue_api: add subqueue variant netif_subqueue_sent
hinic3: use netif_subqueue_sent api
hinic3: remove tx_q name collision hack

 .../net/ethernet/huawei/hinic3/hinic3_tx.c    | 23 ++++++++-----------
 include/net/netdev_queues.h                   |  9 ++++++++
 2 files changed, 19 insertions(+), 13 deletions(-)

base-commit: 90b83efa6701656e02c86e7df2cb1765ea602d07

Signature · 1 line
2.45.2
author
#1 lore raw

PATCH v3 1/3 queue_api: add subqueue variant netif_subqueue_sent

Add a new function, netif_subqueue_sent, which is a wrapper for netdev_tx_sent_queue.

Drivers that use the subqueue variant macros, netif_subqueue_xxx, identify queue by index and are not required to obtain struct netdev_queue explicitly.

Such drivers still need to call netdev_tx_sent_queue which is a counterpart of netif_subqueue_completed_wake. Allowing drivers to use a subqueue variant for this purpose improves their code consistency by always referring to queue by its index.

---
 include/net/netdev_queues.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/net/netdev_queues.h +9 -0
index ba2eaf39089b..6e835972abd1 100644
@@ -294,6 +294,15 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
 		netif_txq_try_stop(_txq, get_desc, start_thrs);		\
 	})
 
+static inline void netif_subqueue_sent(const struct net_device *dev,
+				       unsigned int idx, unsigned int bytes)
+{
+	struct netdev_queue *txq;
+
+	txq = netdev_get_tx_queue(dev, idx);
+	netdev_tx_sent_queue(txq, bytes);
+}
+
 #define netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, start_thrs) \
 	({								\
 		struct netdev_queue *_txq;				\
Signature · 1 line
2.45.2
author
#2 lore raw

PATCH v3 2/3 hinic3: use netif_subqueue_sent api

In reply to Gur Stavi

Improve consistency of code by using only netif_subqueue variant apis

---
 drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +1 -2
index ae08257dd1d2..7b6f101da313 100644
@@ -542,8 +542,7 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
 		goto err_drop_pkt;
 	}
 
-	netdev_tx_sent_queue(netdev_get_tx_queue(netdev, txq->sq->q_id),
-			     skb->len);
+	netif_subqueue_sent(netdev, txq->sq->q_id, skb->len);
 	netif_subqueue_maybe_stop(netdev, tx_q->sq->q_id,
 				  hinic3_wq_free_wqebbs(&tx_q->sq->wq),
 				  tx_q->tx_stop_thrs,
Signature · 1 line
2.45.2
author
#3 lore raw

PATCH v3 3/3 hinic3: remove tx_q name collision hack

In reply to Gur Stavi

A local variable of tx_q worked around name collision with internal txq variable in netif_subqueue macros.
This workaround is no longer needed.

---
 .../net/ethernet/huawei/hinic3/hinic3_tx.c    | 20 +++++++++----------
 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +9 -11
index 7b6f101da313..3f7f73430be4 100644
@@ -482,7 +482,6 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
 {
 	struct hinic3_sq_wqe_combo wqe_combo = {};
 	struct hinic3_tx_info *tx_info;
-	struct hinic3_txq *tx_q = txq;
 	u32 offload, queue_info = 0;
 	struct hinic3_sq_task task;
 	u16 wqebb_cnt, num_sge;
@@ -506,9 +505,9 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
 		if (likely(wqebb_cnt > txq->tx_stop_thrs))
 			txq->tx_stop_thrs = min(wqebb_cnt, txq->tx_start_thrs);
 
-		netif_subqueue_try_stop(netdev, tx_q->sq->q_id,
-					hinic3_wq_free_wqebbs(&tx_q->sq->wq),
-					tx_q->tx_start_thrs);
+		netif_subqueue_try_stop(netdev, txq->sq->q_id,
+					hinic3_wq_free_wqebbs(&txq->sq->wq),
+					txq->tx_start_thrs);
 
 		return NETDEV_TX_BUSY;
 	}
@@ -543,10 +542,10 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
 	}
 
 	netif_subqueue_sent(netdev, txq->sq->q_id, skb->len);
-	netif_subqueue_maybe_stop(netdev, tx_q->sq->q_id,
-				  hinic3_wq_free_wqebbs(&tx_q->sq->wq),
-				  tx_q->tx_stop_thrs,
-				  tx_q->tx_start_thrs);
+	netif_subqueue_maybe_stop(netdev, txq->sq->q_id,
+				  hinic3_wq_free_wqebbs(&txq->sq->wq),
+				  txq->tx_stop_thrs,
+				  txq->tx_start_thrs);
 
 	hinic3_prepare_sq_ctrl(&wqe_combo, queue_info, num_sge, owner);
 	hinic3_write_db(txq->sq, 0, DB_CFLAG_DP_SQ,
@@ -630,7 +629,6 @@ bool hinic3_tx_poll(struct hinic3_txq *txq, int budget)
 	struct net_device *netdev = txq->netdev;
 	u16 hw_ci, sw_ci, q_id = txq->sq->q_id;
 	struct hinic3_tx_info *tx_info;
-	struct hinic3_txq *tx_q = txq;
 	unsigned int bytes_compl = 0;
 	unsigned int pkts = 0;
 	u16 wqebb_cnt = 0;
@@ -662,8 +660,8 @@ bool hinic3_tx_poll(struct hinic3_txq *txq, int budget)
 	hinic3_wq_put_wqebbs(&txq->sq->wq, wqebb_cnt);
 
 	netif_subqueue_completed_wake(netdev, q_id, pkts, bytes_compl,
-				      hinic3_wq_free_wqebbs(&tx_q->sq->wq),
-				      tx_q->tx_start_thrs);
+				      hinic3_wq_free_wqebbs(&txq->sq->wq),
+				      txq->tx_start_thrs);
 
 	return pkts == HINIC3_TX_POLL_WEIGHT;
 }
Signature · 1 line
2.45.2
#4 lore raw
In reply to Gur Stavi
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 8 lines · On Mon, 9 Jun 2025 18:07:51 +0300 you wrote:

This patch series contains improvement to queue_api and 2 queue_api related patches to the hinic3 driver.

Changes:

v1: http://lore.kernel.org/netdev/[email protected]

[...]

Here is the summary with links:
- [net-next,v3,1/3] queue_api: add subqueue variant netif_subqueue_sent

    https://git.kernel.org/netdev/net-next/c/2bc64b89c4c4
  - [net-next,v3,2/3] hinic3: use netif_subqueue_sent api
    https://git.kernel.org/netdev/net-next/c/eb89bc3744f3
  - [net-next,v3,3/3] hinic3: remove tx_q name collision hack
    https://git.kernel.org/netdev/net-next/c/48b9ce0a7c72

You are awesome, thank you!

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