Skip to content

Commit c3e14ae

Browse files
LorenzoBianconigregkh
authored andcommitted
net: airoha: Take into account out-of-order tx completions in airoha_dev_xmit()
[ Upstream commit bd5afca ] Completion napi can free out-of-order tx descriptors if hw QoS is enabled and packets with different priority are queued to same DMA ring. Take into account possible out-of-order reports checking if the tx queue is full using circular buffer head/tail pointer instead of the number of queued packets. Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Suggested-by: Simon Horman <horms@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20251012-airoha-tx-busy-queue-v2-1-a600b08bab2d@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6e3a266 commit c3e14ae

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,20 @@ static u32 airoha_get_dsa_tag(struct sk_buff *skb, struct net_device *dev)
18721872
#endif
18731873
}
18741874

1875+
static bool airoha_dev_tx_queue_busy(struct airoha_queue *q, u32 nr_frags)
1876+
{
1877+
u32 tail = q->tail <= q->head ? q->tail + q->ndesc : q->tail;
1878+
u32 index = q->head + nr_frags;
1879+
1880+
/* completion napi can free out-of-order tx descriptors if hw QoS is
1881+
* enabled and packets with different priorities are queued to the same
1882+
* DMA ring. Take into account possible out-of-order reports checking
1883+
* if the tx queue is full using circular buffer head/tail pointers
1884+
* instead of the number of queued packets.
1885+
*/
1886+
return index >= tail;
1887+
}
1888+
18751889
static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
18761890
struct net_device *dev)
18771891
{
@@ -1925,7 +1939,7 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
19251939
txq = netdev_get_tx_queue(dev, qid);
19261940
nr_frags = 1 + skb_shinfo(skb)->nr_frags;
19271941

1928-
if (q->queued + nr_frags > q->ndesc) {
1942+
if (airoha_dev_tx_queue_busy(q, nr_frags)) {
19291943
/* not enough space in the queue */
19301944
netif_tx_stop_queue(txq);
19311945
spin_unlock_bh(&q->lock);

0 commit comments

Comments
 (0)