DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: don't track remaining packets separately
@ 2021-04-08 14:44 Balazs Nemeth
  2021-04-13 11:36 ` Maxime Coquelin
  2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
  0 siblings, 2 replies; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-08 14:44 UTC (permalink / raw)
  To: bnemeth, dev

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);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: don't track remaining packets separately
  2021-04-08 14:44 [dpdk-dev] [PATCH] vhost: don't track remaining packets separately Balazs Nemeth
@ 2021-04-13 11:36 ` Maxime Coquelin
  2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2021-04-13 11:36 UTC (permalink / raw)
  To: Balazs Nemeth, dev

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);
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] vhost: don't track remaining packets separately
  2021-04-08 14:44 [dpdk-dev] [PATCH] vhost: don't track remaining packets separately Balazs Nemeth
  2021-04-13 11:36 ` Maxime Coquelin
@ 2021-04-13 13:20 ` Balazs Nemeth
  2021-04-13 13:31   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
  1 sibling, 1 reply; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-13 13:20 UTC (permalink / raw)
  To: bnemeth, dev, maxime.coquelin

The remained variable stores the same information as the difference
between count and pkt_idx. Remove the remained variable to simplify.
---
 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
@@ -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);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v3] vhost: don't track remaining packets separately
  2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
@ 2021-04-13 13:31   ` Balazs Nemeth
  2021-04-15 16:22     ` Maxime Coquelin
  2021-04-28  3:14     ` Xia, Chenbo
  0 siblings, 2 replies; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-13 13:31 UTC (permalink / raw)
  To: bnemeth, dev, maxime.coquelin

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
@@ -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);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: don't track remaining packets separately
  2021-04-13 13:31   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
@ 2021-04-15 16:22     ` Maxime Coquelin
  2021-04-28  3:14     ` Xia, Chenbo
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2021-04-15 16:22 UTC (permalink / raw)
  To: Balazs Nemeth, dev



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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: don't track remaining packets separately
  2021-04-13 13:31   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
  2021-04-15 16:22     ` Maxime Coquelin
@ 2021-04-28  3:14     ` Xia, Chenbo
  1 sibling, 0 replies; 6+ messages in thread
From: Xia, Chenbo @ 2021-04-28  3:14 UTC (permalink / raw)
  To: Balazs Nemeth, dev, maxime.coquelin

> -----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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-28  3:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 14:44 [dpdk-dev] [PATCH] vhost: don't track remaining packets separately Balazs Nemeth
2021-04-13 11:36 ` Maxime Coquelin
2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
2021-04-13 13:31   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
2021-04-15 16:22     ` Maxime Coquelin
2021-04-28  3:14     ` Xia, Chenbo

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git