Skip to content

Commit d71ebe8

Browse files
jasowangdavem330
authored andcommitted
virtio-net: correctly enable callback during start_xmit
Commit a7766ef("virtio_net: disable cb aggressively") enables virtqueue callback via the following statement: do { if (use_napi) virtqueue_disable_cb(sq->vq); free_old_xmit_skbs(sq, false); } while (use_napi && kick && unlikely(!virtqueue_enable_cb_delayed(sq->vq))); When NAPI is used and kick is false, the callback won't be enabled here. And when the virtqueue is about to be full, the tx will be disabled, but we still don't enable tx interrupt which will cause a TX hang. This could be observed when using pktgen with burst enabled. TO be consistent with the logic that tries to disable cb only for NAPI, fixing this by trying to enable delayed callback only when NAPI is enabled when the queue is about to be full. Fixes: a7766ef ("virtio_net: disable cb aggressively") Signed-off-by: Jason Wang <[email protected]> Tested-by: Laurent Vivier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7b90f5a commit d71ebe8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/virtio_net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,8 +1877,10 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
18771877
*/
18781878
if (sq->vq->num_free < 2+MAX_SKB_FRAGS) {
18791879
netif_stop_subqueue(dev, qnum);
1880-
if (!use_napi &&
1881-
unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
1880+
if (use_napi) {
1881+
if (unlikely(!virtqueue_enable_cb_delayed(sq->vq)))
1882+
virtqueue_napi_schedule(&sq->napi, sq->vq);
1883+
} else if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
18821884
/* More just got used, free them then recheck. */
18831885
free_old_xmit_skbs(sq, false);
18841886
if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {

0 commit comments

Comments
 (0)