Skip to contentSkip to conversation

example/vhost_crypto: fix incorrect fetch size

PATCH In review Fan Zhang 2 participants 9 messages Nov 26, 2019 – Apr 10, 2020

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 example/vhost_crypto: fix incorrect fetch size

Coverity issue: 343401

Fixes f5188211c721 ("examples/vhost_crypto: add sample application")
---
 examples/vhost_crypto/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost_crypto/main.c +1 -1
index 1d7ba9419..5d80bcaca 100644
@@ -387,7 +387,7 @@ vhost_crypto_worker(void *arg)
 				continue;
 
 			for (j = 0; j < NB_VIRTIO_QUEUES; j++) {
-				to_fetch = RTE_MIN(burst_size,
+				to_fetch = RTE_MAX(burst_size,
 						(NB_CRYPTO_DESCRIPTORS -
 						info->nb_inflight_ops));
 				fetched = rte_vhost_crypto_fetch_requests(
Signature · 1 line
2.20.1
#1 lore raw

Hi Fan,

Quoted 16 lines · Fan Zhang

Coverity issue: 343401

Fixes f5188211c721 ("examples/vhost_crypto: add sample application")
---
 examples/vhost_crypto/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost_crypto/main.c +0 -0
index 1d7ba9419..5d80bcaca 100644

examples/vhost_crypto/main.c vhost_crypto_worker(void *arg) · line 393

Quoted 8 lines
examples/vhost_crypto/main.c +1 -1
@@ -387,7 +387,7 @@ vhost_crypto_worker(void *arg)
 				continue;
 
 			for (j = 0; j < NB_VIRTIO_QUEUES; j++) {
-				to_fetch = RTE_MIN(burst_size,
+				to_fetch = RTE_MAX(burst_size,
 						(NB_CRYPTO_DESCRIPTORS -
 						info->nb_inflight_ops));
 				fetched = rte_vhost_crypto_fetch_requests(

Could you please add a commit message to explain the change? With just the patch context, this fix looks weird.

Thanks!
Maxime

#2 lore raw

Hi Maxime,

Sorry for the late reply.
This patch is incorrect. I have sent the correct version http://patchwork.dpdk.org/patch/65302/

Regards,
Fan

Quoted 40 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, January 14, 2020 9:30 AM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Subject: Re: [PATCH] example/vhost_crypto: fix incorrect fetch size

Hi Fan,

Quoted 15 lines · Fan Zhang

Coverity issue: 343401

Fixes f5188211c721 ("examples/vhost_crypto: add sample application")
---
 examples/vhost_crypto/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/examples/vhost_crypto/main.c index 1d7ba9419..5d80bcaca 100644

examples/vhost_crypto/main.c vhost_crypto_worker(void *arg) · line 391

Quoted 6 lines
examples/vhost_crypto/main.c +1 -1
@@ -387,7 +387,7 @@ vhost_crypto_worker(void *arg)
 				continue;
 
 			for (j = 0; j < NB_VIRTIO_QUEUES; j++) {
-				to_fetch = RTE_MIN(burst_size,
+				to_fetch = RTE_MAX(burst_size,
 						(NB_CRYPTO_DESCRIPTORS

-

examples/vhost_crypto/main.c vhost_crypto_worker(void *arg) · line 393

Quoted 3 lines
examples/vhost_crypto/main.c +0 -0
 						info->nb_inflight_ops));
 				fetched = rte_vhost_crypto_fetch_requests(

Could you please add a commit message to explain the change? With just the patch context, this fix looks weird.

Thanks!
Maxime

author
#3 lore raw

PATCH 1/1 vhost/crypto: fix missed user protocol flag

In reply to Fan Zhang
Fixes 939066d96563 ("vhost/crypto: add public function implementation")

This patch fixes the vhost crypto missed "VHOST_USER_PROTOCOL_F_CONFIG" flag problem during initialization. Newer Qemu version requires this feature enabled.

---
 lib/librte_vhost/rte_vhost.h    | 5 +++++
 lib/librte_vhost/vhost_crypto.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)
lib/librte_vhost/rte_vhost.h +5 -0
index 7b5dc87c2..ad6e71702 100644
@@ -68,6 +68,10 @@ extern "C" {
 #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8
 #endif
 
+#ifndef VHOST_USER_PROTOCOL_F_CONFIG
+#define VHOST_USER_PROTOCOL_F_CONFIG 9
+#endif
+
 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
 #endif
@@ -85,6 +89,7 @@ extern "C" {
 #define VHOST_USER_F_PROTOCOL_FEATURES	30
 #endif
 
+
 /**
  * Information relating to memory regions including offsets to
  * addresses in QEMUs memory file.
lib/librte_vhost/vhost_crypto.c +2 -1
index 684fddc30..242fa5333 100644
@@ -40,7 +40,8 @@
 		(1 << VIRTIO_RING_F_EVENT_IDX) |			\
 		(1 << VIRTIO_CRYPTO_SERVICE_CIPHER) |			\
 		(1 << VIRTIO_CRYPTO_SERVICE_MAC) |			\
-		(1 << VIRTIO_NET_F_CTRL_VQ))
+		(1 << VIRTIO_NET_F_CTRL_VQ) |				\
+		(1 << VHOST_USER_PROTOCOL_F_CONFIG))
 
 #define IOVA_TO_VVA(t, r, a, l, p)					\
 	((t)(uintptr_t)vhost_iova_to_vva(r->dev, r->vq, a, l, p))
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#4 lore raw

Re: [dpdk-dev] [PATCH] vhost/crypto: fix missed user protocol flag

Quoted 7 lines · Fan Zhang
Fixes 939066d96563 ("vhost/crypto: add public function implementation")

This patch fixes the vhost crypto missed "VHOST_USER_PROTOCOL_F_CONFIG" flag problem during initialization. Newer Qemu version requires this feature enabled.

Quoted 6 lines
---
 lib/librte_vhost/rte_vhost.h    | 5 +++++
 lib/librte_vhost/vhost_crypto.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Thanks,
Maxime

#5 lore raw

Re: [dpdk-dev] [PATCH] vhost/crypto: fix missed user protocol flag

In reply to Fan Zhang
Quoted 7 lines · Fan Zhang
Fixes 939066d96563 ("vhost/crypto: add public function implementation")

This patch fixes the vhost crypto missed "VHOST_USER_PROTOCOL_F_CONFIG" flag problem during initialization. Newer Qemu version requires this feature enabled.

Quoted 5 lines
---
 lib/librte_vhost/rte_vhost.h    | 5 +++++
 lib/librte_vhost/vhost_crypto.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime

author
#6 lore raw

PATCH 1/1 vhost/crypto: fix incorrect fetch size

In reply to Fan Zhang

Coverity issue: 343401

This patch fixes the incorrect rte_vhost_crypto_fetch_requests return value.

Fixes 3bb595ecd682 ("vhost/crypto: add request handler")
---
 lib/librte_vhost/vhost_crypto.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/librte_vhost/vhost_crypto.c +5 -5
index 684fddc30..68911972b 100644
@@ -1539,18 +1539,18 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
 
 	if (unlikely(dev == NULL)) {
 		VC_LOG_ERR("Invalid vid %i", vid);
-		return -EINVAL;
+		return 0;
 	}
 
 	if (unlikely(qid >= VHOST_MAX_QUEUE_PAIRS)) {
 		VC_LOG_ERR("Invalid qid %u", qid);
-		return -EINVAL;
+		return 0;
 	}
 
 	vcrypto = (struct vhost_crypto *)dev->extern_data;
 	if (unlikely(vcrypto == NULL)) {
 		VC_LOG_ERR("Cannot find required data, is it initialized?");
-		return -ENOENT;
+		return 0;
 	}
 
 	vq = dev->virtqueue[qid];
@@ -1572,7 +1572,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
 		if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool,
 				(void **)mbufs, count * 2) < 0)) {
 			VC_LOG_ERR("Insufficient memory");
-			return -ENOMEM;
+			return 0;
 		}
 
 		for (i = 0; i < count; i++) {
@@ -1602,7 +1602,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
 		if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool,
 				(void **)mbufs, count) < 0)) {
 			VC_LOG_ERR("Insufficient memory");
-			return -ENOMEM;
+			return 0;
 		}
 
 		for (i = 0; i < count; i++) {
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#7 lore raw

Re: [dpdk-dev] [PATCH] vhost/crypto: fix incorrect fetch size

Quoted 5 lines · Fan Zhang

Coverity issue: 343401

This patch fixes the incorrect rte_vhost_crypto_fetch_requests return value.

Quoted 9 lines
Fixes 3bb595ecd682 ("vhost/crypto: add request handler")
---
 lib/librte_vhost/vhost_crypto.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Thanks,
Maxime

#8 lore raw

Re: [dpdk-dev] [PATCH] vhost/crypto: fix incorrect fetch size

In reply to Fan Zhang
Quoted 5 lines · Fan Zhang

Coverity issue: 343401

This patch fixes the incorrect rte_vhost_crypto_fetch_requests return value.

Quoted 8 lines
Fixes 3bb595ecd682 ("vhost/crypto: add request handler")
---
 lib/librte_vhost/vhost_crypto.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Applied to dpdk-next-virtio tree.

Thanks,
Maxime