diff mbox series

vhost: don't track remaining packets separately

Message ID 5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com (mailing list archive)
State Superseded
Delegated to: Maxime Coquelin
Headers show
Series vhost: don't track remaining packets separately | expand

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Balazs Nemeth April 8, 2021, 2:44 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 | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Maxime Coquelin April 13, 2021, 11:36 a.m. UTC | #1
Hi Balazs,

Your patch does not apply, it needs to be rebased:
http://patches.dpdk.org/project/dpdk/patch/5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com/

Can you please send a rebased version.

Thanks,
Maxime

On 4/8/21 4:44 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 | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index e8cc5f659..cfd52360d 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -1353,16 +1353,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;
>  			}
>  		}
> @@ -1370,7 +1368,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);
>  
> @@ -2480,12 +2477,11 @@ virtio_dev_tx_packed(struct virtio_net *dev,
>  	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,
>  							&pkts[pkt_idx])) {
>  				pkt_idx += PACKED_BATCH_SIZE;
> -				remained -= PACKED_BATCH_SIZE;
>  
>  				continue;
>  			}
> @@ -2496,9 +2492,7 @@ virtio_dev_tx_packed(struct virtio_net *dev,
>  			break;
>  		}
>  		pkt_idx++;
> -		remained--;
> -
> -	} while (remained);
> +	} while (pkt_idx < count);
>  
>  	if (pkt_idx != count) {
>  		rte_pktmbuf_free_bulk(&pkts[pkt_idx], count - pkt_idx);
>
diff mbox series

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index e8cc5f659..cfd52360d 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1353,16 +1353,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;
 			}
 		}
@@ -1370,7 +1368,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);
 
@@ -2480,12 +2477,11 @@  virtio_dev_tx_packed(struct virtio_net *dev,
 	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,
 							&pkts[pkt_idx])) {
 				pkt_idx += PACKED_BATCH_SIZE;
-				remained -= PACKED_BATCH_SIZE;
 
 				continue;
 			}
@@ -2496,9 +2492,7 @@  virtio_dev_tx_packed(struct virtio_net *dev,
 			break;
 		}
 		pkt_idx++;
-		remained--;
-
-	} while (remained);
+	} while (pkt_idx < count);
 
 	if (pkt_idx != count) {
 		rte_pktmbuf_free_bulk(&pkts[pkt_idx], count - pkt_idx);