hinic3: queue_api related fixes
Subsystems (3)
v2 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:
* Update cover letter subject and text.
* Add 2 patches for user code related to queue api.
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 | 8 +++++++ 2 files changed, 18 insertions(+), 13 deletions(-)
base-commit: 3da895b23901964fcf23450f10b529d45069f333
Signature · 1 line
2.45.2
PATCH v2 1/3 queue_api: add subqueue variant netif_subqueue_sent
Add a new macro, 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 | 8 ++++++++ 1 file changed, 8 insertions(+)
include/net/netdev_queues.h +8 -0
@@ -294,6 +294,14 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,netif_txq_try_stop (_txq, get_desc, start_thrs); \ }) +#define netif_subqueue_sent (dev, idx, 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
PATCH v2 2/3 hinic3: use netif_subqueue_sent api
In reply to Gur StaviImprove 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
@@ -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
PATCH v2 3/3 hinic3: remove tx_q name collision hack
In reply to Gur StaviA 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
@@ -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
Quoted 6 lines · On Thu, 22 May 2025 09:54:40 +0300 Gur Stavi wrote:
This patch series contains improvement to
queue_apiand 2queue_apirelated patches to the hinic3 driver.Changes:
Thanks!
reminder: please respect the 24h reposting delay per
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#resending-after-review
Signature · 1 line
pv-bot: 24h
Paolo Abeni
maintainerRe: [PATCH net-next v2 1/3] queue_api: add subqueue variant netif_subqueue_sent
In reply to Gur StaviQuoted 5 lines · Gur Stavi
include/net/netdev_queues.h +0
-0
include/net/netdev_queues.h netdev_txq_completed_mb(struct netdev_queue *dev_queue, · line 303
Quoted 10 lines
include/net/netdev_queues.h +7
-0@@ -294,6 +294,14 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,netif_txq_try_stop (_txq, get_desc, start_thrs); \ }) +#define netif_subqueue_sent (dev, idx, bytes) \ + ({ \ + struct netdev_queue *_txq; \ + \ + _txq = netdev_get_tx_queue(dev, idx); \ + netdev_tx_sent_queue(_txq, bytes); \ + })
The above could be (and should be) a static inline function. Note that (most of) the existing queue API helper are macros to allow quering the tx ring without using indirect calls/function pointers.
Thanks,
Paolo