Skip to content

Commit 391aa2a

Browse files
fengidrikuba-moo
authored andcommitted
virtio_net: separate virtnet_tx_resize()
This patch separates two sub-functions from virtnet_tx_resize(): * virtnet_tx_pause * virtnet_tx_resume Then the subsequent virtnet_tx_reset() 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 47879b7 commit 391aa2a

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

drivers/net/virtio_net.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,12 +2703,11 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
27032703
return err;
27042704
}
27052705

2706-
static int virtnet_tx_resize(struct virtnet_info *vi,
2707-
struct send_queue *sq, u32 ring_num)
2706+
static void virtnet_tx_pause(struct virtnet_info *vi, struct send_queue *sq)
27082707
{
27092708
bool running = netif_running(vi->dev);
27102709
struct netdev_queue *txq;
2711-
int err, qindex;
2710+
int qindex;
27122711

27132712
qindex = sq - vi->sq;
27142713

@@ -2729,10 +2728,17 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
27292728
netif_stop_subqueue(vi->dev, qindex);
27302729

27312730
__netif_tx_unlock_bh(txq);
2731+
}
27322732

2733-
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf);
2734-
if (err)
2735-
netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qindex, err);
2733+
static void virtnet_tx_resume(struct virtnet_info *vi, struct send_queue *sq)
2734+
{
2735+
bool running = netif_running(vi->dev);
2736+
struct netdev_queue *txq;
2737+
int qindex;
2738+
2739+
qindex = sq - vi->sq;
2740+
2741+
txq = netdev_get_tx_queue(vi->dev, qindex);
27362742

27372743
__netif_tx_lock_bh(txq);
27382744
sq->reset = false;
@@ -2741,6 +2747,23 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
27412747

27422748
if (running)
27432749
virtnet_napi_tx_enable(vi, sq->vq, &sq->napi);
2750+
}
2751+
2752+
static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
2753+
u32 ring_num)
2754+
{
2755+
int qindex, err;
2756+
2757+
qindex = sq - vi->sq;
2758+
2759+
virtnet_tx_pause(vi, sq);
2760+
2761+
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf);
2762+
if (err)
2763+
netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qindex, err);
2764+
2765+
virtnet_tx_resume(vi, sq);
2766+
27442767
return err;
27452768
}
27462769

0 commit comments

Comments
 (0)