Skip to content

Commit bd5afca

Browse files
LorenzoBianconiPaolo Abeni
authored andcommitted
net: airoha: Take into account out-of-order tx completions in airoha_dev_xmit()
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 <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 295ce1e commit bd5afca

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
@@ -1873,6 +1873,20 @@ static u32 airoha_get_dsa_tag(struct sk_buff *skb, struct net_device *dev)
18731873
#endif
18741874
}
18751875

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

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

0 commit comments

Comments
 (0)