Skip to content

Commit 47879b7

Browse files
fengidrikuba-moo
authored andcommitted
virtio_net: separate virtnet_rx_resize()
This patch separates two sub-functions from virtnet_rx_resize(): * virtnet_rx_pause * virtnet_rx_resume Then the subsequent reset rx for xsk can share these two functions. Signed-off-by: Xuan Zhuo <[email protected]> Acked-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 41d4a17 commit 47879b7

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

drivers/net/virtio_net.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,28 +2665,41 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
26652665
return NETDEV_TX_OK;
26662666
}
26672667

2668-
static int virtnet_rx_resize(struct virtnet_info *vi,
2669-
struct receive_queue *rq, u32 ring_num)
2668+
static void virtnet_rx_pause(struct virtnet_info *vi, struct receive_queue *rq)
26702669
{
26712670
bool running = netif_running(vi->dev);
2672-
int err, qindex;
2673-
2674-
qindex = rq - vi->rq;
26752671

26762672
if (running) {
26772673
napi_disable(&rq->napi);
26782674
virtnet_cancel_dim(vi, &rq->dim);
26792675
}
2676+
}
26802677

2681-
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf);
2682-
if (err)
2683-
netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qindex, err);
2678+
static void virtnet_rx_resume(struct virtnet_info *vi, struct receive_queue *rq)
2679+
{
2680+
bool running = netif_running(vi->dev);
26842681

26852682
if (!try_fill_recv(vi, rq, GFP_KERNEL))
26862683
schedule_delayed_work(&vi->refill, 0);
26872684

26882685
if (running)
26892686
virtnet_napi_enable(rq->vq, &rq->napi);
2687+
}
2688+
2689+
static int virtnet_rx_resize(struct virtnet_info *vi,
2690+
struct receive_queue *rq, u32 ring_num)
2691+
{
2692+
int err, qindex;
2693+
2694+
qindex = rq - vi->rq;
2695+
2696+
virtnet_rx_pause(vi, rq);
2697+
2698+
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf);
2699+
if (err)
2700+
netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qindex, err);
2701+
2702+
virtnet_rx_resume(vi, rq);
26902703
return err;
26912704
}
26922705

0 commit comments

Comments
 (0)