[v3] vhost: don't track remaining packets separately

Message ID e427b1f691770d4c7706d9b7d469e549eadb1f8e.1618320615.git.bnemeth@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v3] vhost: don't track remaining packets separately |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Balazs Nemeth April 13, 2021, 1:31 p.m. UTC
  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>
---
 lib/librte_vhost/virtio_net.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
  

Comments

Maxime Coquelin April 15, 2021, 4:22 p.m. UTC | #1
On 4/13/21 3:31 PM, Balazs Nemeth wrote:
> 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>
> ---
>  lib/librte_vhost/virtio_net.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Chenbo Xia April 28, 2021, 3:14 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Balazs Nemeth
> Sent: Tuesday, April 13, 2021 9:31 PM
> To: bnemeth@redhat.com; dev@dpdk.org; maxime.coquelin@redhat.com
> Subject: [dpdk-dev] [PATCH v3] vhost: don't track remaining packets separately
> 
> 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>
> ---
>  lib/librte_vhost/virtio_net.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index ff39878609..01b849f6cb 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> --
> 2.30.2

Patch applied to next-virtio/main, thanks
  

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index ff39878609..01b849f6cb 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1352,16 +1352,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;
 			}
 		}
@@ -1369,7 +1367,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);
 
@@ -2460,16 +2457,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;
 			}
 		}
@@ -2478,9 +2473,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);