vhost: add protocol feature check
diff mbox series

Message ID 20191225142445.66106-1-jin.yu@intel.com
State Rejected, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • vhost: add protocol feature check
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Jin Yu Dec. 25, 2019, 2:24 p.m. UTC
Add VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD check in
getting inflight ring functions.

Fixes: 4d891f77ddfa ("vhost: add APIs to get inflight ring")
Cc: stable@dpdk.org

Signed-off-by: Jin Yu <jin.yu@intel.com>
---
 lib/librte_vhost/vhost.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Tiwei Bie Jan. 13, 2020, 2:52 a.m. UTC | #1
On Wed, Dec 25, 2019 at 10:24:45PM +0800, Jin Yu wrote:
> Add VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD check in
> getting inflight ring functions.
> 
> Fixes: 4d891f77ddfa ("vhost: add APIs to get inflight ring")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jin Yu <jin.yu@intel.com>
> ---
>  lib/librte_vhost/vhost.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 1cbe948f7..dfb71732b 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -862,6 +862,10 @@ rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
>  	if (unlikely(!dev))
>  		return -1;
>  
> +	if (unlikely(!(dev->protocol_features &
> +	    (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))))
> +		return 0;

Why this is needed?
The caller needs to know whether _INFLIGHT_SHMFD is negotiated or
not anyway. Even if rte_vhost_get_vhost_ring_inflight() returns
success, the inflight info returned is still invalid.


> +
>  	if (vring_idx >= VHOST_MAX_VRING)
>  		return -1;
>  
> @@ -1431,6 +1435,10 @@ rte_vhost_get_vring_base_from_inflight(int vid,
>  	if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL)
>  		return -1;
>  
> +	if (unlikely(!(dev->protocol_features &
> +	    (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))))
> +		return 0;
> +
>  	if (!vq_is_packed(dev))
>  		return -1;
>  
> -- 
> 2.17.2
>

Patch
diff mbox series

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 1cbe948f7..dfb71732b 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -862,6 +862,10 @@  rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
 	if (unlikely(!dev))
 		return -1;
 
+	if (unlikely(!(dev->protocol_features &
+	    (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))))
+		return 0;
+
 	if (vring_idx >= VHOST_MAX_VRING)
 		return -1;
 
@@ -1431,6 +1435,10 @@  rte_vhost_get_vring_base_from_inflight(int vid,
 	if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL)
 		return -1;
 
+	if (unlikely(!(dev->protocol_features &
+	    (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))))
+		return 0;
+
 	if (!vq_is_packed(dev))
 		return -1;