@@ -503,6 +503,7 @@ struct virtio_net_common_hdr {
503
503
static struct virtio_net_common_hdr xsk_hdr ;
504
504
505
505
static void virtnet_sq_free_unused_buf (struct virtqueue * vq , void * buf );
506
+ static void virtnet_sq_free_unused_buf_done (struct virtqueue * vq );
506
507
static int virtnet_xdp_handler (struct bpf_prog * xdp_prog , struct xdp_buff * xdp ,
507
508
struct net_device * dev ,
508
509
unsigned int * xdp_xmit ,
@@ -3054,7 +3055,6 @@ static int virtnet_enable_queue_pair(struct virtnet_info *vi, int qp_index)
3054
3055
if (err < 0 )
3055
3056
goto err_xdp_reg_mem_model ;
3056
3057
3057
- netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , qp_index ));
3058
3058
virtnet_napi_enable (vi -> rq [qp_index ].vq , & vi -> rq [qp_index ].napi );
3059
3059
virtnet_napi_tx_enable (vi , vi -> sq [qp_index ].vq , & vi -> sq [qp_index ].napi );
3060
3060
@@ -3332,7 +3332,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
3332
3332
3333
3333
virtnet_rx_pause (vi , rq );
3334
3334
3335
- err = virtqueue_resize (rq -> vq , ring_num , virtnet_rq_unmap_free_buf );
3335
+ err = virtqueue_resize (rq -> vq , ring_num , virtnet_rq_unmap_free_buf , NULL );
3336
3336
if (err )
3337
3337
netdev_err (vi -> dev , "resize rx fail: rx queue index: %d err: %d\n" , qindex , err );
3338
3338
@@ -3395,7 +3395,8 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
3395
3395
3396
3396
virtnet_tx_pause (vi , sq );
3397
3397
3398
- err = virtqueue_resize (sq -> vq , ring_num , virtnet_sq_free_unused_buf );
3398
+ err = virtqueue_resize (sq -> vq , ring_num , virtnet_sq_free_unused_buf ,
3399
+ virtnet_sq_free_unused_buf_done );
3399
3400
if (err )
3400
3401
netdev_err (vi -> dev , "resize tx fail: tx queue index: %d err: %d\n" , qindex , err );
3401
3402
@@ -5710,7 +5711,7 @@ static int virtnet_rq_bind_xsk_pool(struct virtnet_info *vi, struct receive_queu
5710
5711
5711
5712
virtnet_rx_pause (vi , rq );
5712
5713
5713
- err = virtqueue_reset (rq -> vq , virtnet_rq_unmap_free_buf );
5714
+ err = virtqueue_reset (rq -> vq , virtnet_rq_unmap_free_buf , NULL );
5714
5715
if (err ) {
5715
5716
netdev_err (vi -> dev , "reset rx fail: rx queue index: %d err: %d\n" , qindex , err );
5716
5717
@@ -5739,7 +5740,8 @@ static int virtnet_sq_bind_xsk_pool(struct virtnet_info *vi,
5739
5740
5740
5741
virtnet_tx_pause (vi , sq );
5741
5742
5742
- err = virtqueue_reset (sq -> vq , virtnet_sq_free_unused_buf );
5743
+ err = virtqueue_reset (sq -> vq , virtnet_sq_free_unused_buf ,
5744
+ virtnet_sq_free_unused_buf_done );
5743
5745
if (err ) {
5744
5746
netdev_err (vi -> dev , "reset tx fail: tx queue index: %d err: %d\n" , qindex , err );
5745
5747
pool = NULL ;
@@ -6214,7 +6216,7 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
6214
6216
{
6215
6217
struct virtnet_info * vi = vq -> vdev -> priv ;
6216
6218
struct send_queue * sq ;
6217
- int i = vq2rxq (vq );
6219
+ int i = vq2txq (vq );
6218
6220
6219
6221
sq = & vi -> sq [i ];
6220
6222
@@ -6234,6 +6236,14 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
6234
6236
}
6235
6237
}
6236
6238
6239
+ static void virtnet_sq_free_unused_buf_done (struct virtqueue * vq )
6240
+ {
6241
+ struct virtnet_info * vi = vq -> vdev -> priv ;
6242
+ int i = vq2txq (vq );
6243
+
6244
+ netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , i ));
6245
+ }
6246
+
6237
6247
static void free_unused_bufs (struct virtnet_info * vi )
6238
6248
{
6239
6249
void * buf ;
@@ -6966,11 +6976,20 @@ static int virtnet_probe(struct virtio_device *vdev)
6966
6976
6967
6977
static void remove_vq_common (struct virtnet_info * vi )
6968
6978
{
6979
+ int i ;
6980
+
6969
6981
virtio_reset_device (vi -> vdev );
6970
6982
6971
6983
/* Free unused buffers in both send and recv, if any. */
6972
6984
free_unused_bufs (vi );
6973
6985
6986
+ /*
6987
+ * Rule of thumb is netdev_tx_reset_queue() should follow any
6988
+ * skb freeing not followed by netdev_tx_completed_queue()
6989
+ */
6990
+ for (i = 0 ; i < vi -> max_queue_pairs ; i ++ )
6991
+ netdev_tx_reset_queue (netdev_get_tx_queue (vi -> dev , i ));
6992
+
6974
6993
free_receive_bufs (vi );
6975
6994
6976
6995
free_receive_page_frags (vi );
0 commit comments