]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
virtio_net: Cleanup '2+MAX_SKB_FRAGS'
authorLaurent Vivier <lvivier@redhat.com>
Wed, 21 May 2025 09:22:35 +0000 (11:22 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 3 Jul 2025 09:40:02 +0000 (11:40 +0200)
Improve consistency by using everywhere it is needed
'MAX_SKB_FRAGS + 2' rather than '2+MAX_SKB_FRAGS' or
'2 + MAX_SKB_FRAGS'.

No functional change.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://patch.msgid.link/20250521092236.661410-3-lvivier@redhat.com
Tested-by: Lei Yang <leiyang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/virtio_net.c

index 50ff9a309ddc55ce42548b6b890a0acea4f00402..031f8227531699c9dfaf7d128c4f1408764225b9 100644 (file)
@@ -1104,7 +1104,7 @@ static bool tx_may_stop(struct virtnet_info *vi,
         * Since most packets only take 1 or 2 ring slots, stopping the queue
         * early means 16 slots are typically wasted.
         */
-       if (sq->vq->num_free < 2+MAX_SKB_FRAGS) {
+       if (sq->vq->num_free < MAX_SKB_FRAGS + 2) {
                struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum);
 
                netif_tx_stop_queue(txq);
@@ -1136,7 +1136,7 @@ static void check_sq_full_and_disable(struct virtnet_info *vi,
                } else if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
                        /* More just got used, free them then recheck. */
                        free_old_xmit(sq, txq, false);
-                       if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {
+                       if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) {
                                netif_start_subqueue(dev, qnum);
                                u64_stats_update_begin(&sq->stats.syncp);
                                u64_stats_inc(&sq->stats.wake);
@@ -3021,7 +3021,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq, int budget)
                        free_old_xmit(sq, txq, !!budget);
                } while (unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
 
-               if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) {
+               if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) {
                        if (netif_tx_queue_stopped(txq)) {
                                u64_stats_update_begin(&sq->stats.syncp);
                                u64_stats_inc(&sq->stats.wake);
@@ -3218,7 +3218,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
        else
                free_old_xmit(sq, txq, !!budget);
 
-       if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) {
+       if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) {
                if (netif_tx_queue_stopped(txq)) {
                        u64_stats_update_begin(&sq->stats.syncp);
                        u64_stats_inc(&sq->stats.wake);