vhost: remove remaining packets count
authorBalazs Nemeth <bnemeth@redhat.com>
Tue, 13 Apr 2021 13:31:03 +0000 (15:31 +0200)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 28 Apr 2021 02:49:09 +0000 (04:49 +0200)
The remained variable stores the same information as the difference
between count and pkt_idx. Remove the remained variable to simplify.

Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/vhost/virtio_net.c

index 9197b82..61bf0d6 100644 (file)
@@ -1355,16 +1355,14 @@ virtio_dev_rx_packed(struct virtio_net *dev,
                     uint32_t count)
 {
        uint32_t pkt_idx = 0;
-       uint32_t remained = count;
 
        do {
                rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]);
 
-               if (remained >= PACKED_BATCH_SIZE) {
+               if (count - pkt_idx >= PACKED_BATCH_SIZE) {
                        if (!virtio_dev_rx_batch_packed(dev, vq,
                                                        &pkts[pkt_idx])) {
                                pkt_idx += PACKED_BATCH_SIZE;
-                               remained -= PACKED_BATCH_SIZE;
                                continue;
                        }
                }
@@ -1372,7 +1370,6 @@ virtio_dev_rx_packed(struct virtio_net *dev,
                if (virtio_dev_rx_single_packed(dev, vq, pkts[pkt_idx]))
                        break;
                pkt_idx++;
-               remained--;
 
        } while (pkt_idx < count);
 
@@ -2463,16 +2460,14 @@ virtio_dev_tx_packed(struct virtio_net *dev,
                     uint32_t count)
 {
        uint32_t pkt_idx = 0;
-       uint32_t remained = count;
 
        do {
                rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]);
 
-               if (remained >= PACKED_BATCH_SIZE) {
+               if (count - pkt_idx >= PACKED_BATCH_SIZE) {
                        if (!virtio_dev_tx_batch_packed(dev, vq, mbuf_pool,
                                                        &pkts[pkt_idx])) {
                                pkt_idx += PACKED_BATCH_SIZE;
-                               remained -= PACKED_BATCH_SIZE;
                                continue;
                        }
                }
@@ -2481,9 +2476,7 @@ virtio_dev_tx_packed(struct virtio_net *dev,
                                                &pkts[pkt_idx]))
                        break;
                pkt_idx++;
-               remained--;
-
-       } while (remained);
+       } while (pkt_idx < count);
 
        if (vq->shadow_used_idx) {
                do_data_copy_dequeue(vq);