Skip to content

Commit 81d0885

Browse files
yoongsiang2davem330
authored andcommitted
net: stmmac: Fix overall budget calculation for rxtx_napi
tx_done is not used for napi_complete_done(). Thus, NAPI busy polling mechanism by gro_flush_timeout and napi_defer_hard_irqs will not able be triggered after a packet is transmitted when there is no receive packet. Fix this by taking the maximum value between tx_done and rx_done as overall budget completed by the rxtx NAPI poll to ensure XDP Tx ZC operation is continuously polling for next Tx frame. This gives benefit of lower packet submission processing latency and jitter under XDP Tx ZC mode. Performance of tx-only using xdp-sock on Intel ADL-S platform is the same with and without this patch. root@intel-corei7-64:~# ./xdpsock -i enp0s30f4 -t -z -q 1 -n 10 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511630 8659520 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511625 13775808 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511619 18892032 Fixes: 132c32e ("net: stmmac: Add TX via XDP zero-copy socket") Cc: <[email protected]> # 5.13.x Co-developed-by: Ong Boon Leong <[email protected]> Signed-off-by: Ong Boon Leong <[email protected]> Signed-off-by: Song Yoong Siang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ecbd690 commit 81d0885

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,7 +5347,7 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
53475347
struct stmmac_channel *ch =
53485348
container_of(napi, struct stmmac_channel, rxtx_napi);
53495349
struct stmmac_priv *priv = ch->priv_data;
5350-
int rx_done, tx_done;
5350+
int rx_done, tx_done, rxtx_done;
53515351
u32 chan = ch->index;
53525352

53535353
priv->xstats.napi_poll++;
@@ -5357,14 +5357,16 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
53575357

53585358
rx_done = stmmac_rx_zc(priv, budget, chan);
53595359

5360+
rxtx_done = max(tx_done, rx_done);
5361+
53605362
/* If either TX or RX work is not complete, return budget
53615363
* and keep pooling
53625364
*/
5363-
if (tx_done >= budget || rx_done >= budget)
5365+
if (rxtx_done >= budget)
53645366
return budget;
53655367

53665368
/* all work done, exit the polling mode */
5367-
if (napi_complete_done(napi, rx_done)) {
5369+
if (napi_complete_done(napi, rxtx_done)) {
53685370
unsigned long flags;
53695371

53705372
spin_lock_irqsave(&ch->lock, flags);
@@ -5375,7 +5377,7 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
53755377
spin_unlock_irqrestore(&ch->lock, flags);
53765378
}
53775379

5378-
return min(rx_done, budget - 1);
5380+
return min(rxtx_done, budget - 1);
53795381
}
53805382

53815383
/**

0 commit comments

Comments
 (0)