* [PATCH net-next v2 1/3] queue_api: add subqueue variant netif_subqueue_sent
2025-05-22 6:54 [PATCH net-next v2 0/3] hinic3: queue_api related fixes Gur Stavi
@ 2025-05-22 6:54 ` Gur Stavi
2025-05-27 10:06 ` Paolo Abeni
2025-05-22 6:54 ` [PATCH net-next v2 2/3] hinic3: use netif_subqueue_sent api Gur Stavi
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Gur Stavi @ 2025-05-22 6:54 UTC (permalink / raw)
To: Gur Stavi
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Fan Gong
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.
Signed-off-by: Gur Stavi <gur.stavi@huawei.com>
---
include/net/netdev_queues.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index ba2eaf39089b..7b6656ee549f 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -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; \
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/3] hinic3: use netif_subqueue_sent api
2025-05-22 6:54 [PATCH net-next v2 0/3] hinic3: queue_api related fixes Gur Stavi
2025-05-22 6:54 ` [PATCH net-next v2 1/3] queue_api: add subqueue variant netif_subqueue_sent Gur Stavi
@ 2025-05-22 6:54 ` Gur Stavi
2025-05-22 6:54 ` [PATCH net-next v2 3/3] hinic3: remove tx_q name collision hack Gur Stavi
2025-05-22 16:58 ` [PATCH net-next v2 0/3] hinic3: queue_api related fixes Jakub Kicinski
3 siblings, 0 replies; 6+ messages in thread
From: Gur Stavi @ 2025-05-22 6:54 UTC (permalink / raw)
To: Gur Stavi
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Fan Gong
Improve consistency of code by using only netif_subqueue variant apis
Signed-off-by: Gur Stavi <gur.stavi@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index ae08257dd1d2..7b6f101da313 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -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,
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 3/3] hinic3: remove tx_q name collision hack
2025-05-22 6:54 [PATCH net-next v2 0/3] hinic3: queue_api related fixes Gur Stavi
2025-05-22 6:54 ` [PATCH net-next v2 1/3] queue_api: add subqueue variant netif_subqueue_sent Gur Stavi
2025-05-22 6:54 ` [PATCH net-next v2 2/3] hinic3: use netif_subqueue_sent api Gur Stavi
@ 2025-05-22 6:54 ` Gur Stavi
2025-05-22 16:58 ` [PATCH net-next v2 0/3] hinic3: queue_api related fixes Jakub Kicinski
3 siblings, 0 replies; 6+ messages in thread
From: Gur Stavi @ 2025-05-22 6:54 UTC (permalink / raw)
To: Gur Stavi
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Fan Gong
A local variable of tx_q worked around name collision with internal
txq variable in netif_subqueue macros.
This workaround is no longer needed.
Signed-off-by: Gur Stavi <gur.stavi@huawei.com>
---
.../net/ethernet/huawei/hinic3/hinic3_tx.c | 20 +++++++++----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index 7b6f101da313..3f7f73430be4 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -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;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread