[v2,2/2] vhost: do not limit packed ring size

Message ID 20191030092421.38220-2-yong.liu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v2,1/2] net/virtio: do not limit packed ring size |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Marvin Liu Oct. 30, 2019, 9:24 a.m. UTC
  Virtio spec only set rule that packed ring maximum size is up to 2^15
entries. Should not limit packed ring size to power of two.

Fixes: 708e14d8b9ac ("vhost: advertize packed ring layout support")
Cc: stable@dpdk.org

Signed-off-by: Marvin Liu <yong.liu@intel.com>
---
 lib/librte_vhost/vhost_user.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
  

Comments

Tiwei Bie Nov. 4, 2019, 4:54 a.m. UTC | #1
On Wed, Oct 30, 2019 at 05:24:21PM +0800, Marvin Liu wrote:
> Virtio spec only set rule that packed ring maximum size is up to 2^15
> entries. Should not limit packed ring size to power of two.
> 
> Fixes: 708e14d8b9ac ("vhost: advertize packed ring layout support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
  
Maxime Coquelin Nov. 6, 2019, 2:19 p.m. UTC | #2
On 10/30/19 10:24 AM, Marvin Liu wrote:
> Virtio spec only set rule that packed ring maximum size is up to 2^15
> entries. Should not limit packed ring size to power of two.
> 
> Fixes: 708e14d8b9ac ("vhost: advertize packed ring layout support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 61ef699ac..df9bbf0ac 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -363,8 +363,20 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
>  	 *
>  	 *   Queue Size value is always a power of 2. The maximum Queue Size
>  	 *   value is 32768.
> +	 *
> +	 * VIRTIO 1.1 2.7 Virtqueues says:
> +	 *
> +	 *   Packed virtqueues support up to 2^15 entries each.
>  	 */
> -	if ((vq->size & (vq->size - 1)) || vq->size > 32768) {
> +	if (!vq_is_packed(dev)) {
> +		if (vq->size & (vq->size - 1)) {
> +			RTE_LOG(ERR, VHOST_CONFIG,
> +				"invalid virtqueue size %u\n", vq->size);
> +			return RTE_VHOST_MSG_RESULT_ERR;
> +		}
> +	}
> +
> +	if (vq->size > 32768) {
>  		RTE_LOG(ERR, VHOST_CONFIG,
>  			"invalid virtqueue size %u\n", vq->size);
>  		return RTE_VHOST_MSG_RESULT_ERR;
> 

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

Thanks,
Maxime
  
Maxime Coquelin Nov. 6, 2019, 8:58 p.m. UTC | #3
On 10/30/19 10:24 AM, Marvin Liu wrote:
> Virtio spec only set rule that packed ring maximum size is up to 2^15
> entries. Should not limit packed ring size to power of two.
> 
> Fixes: 708e14d8b9ac ("vhost: advertize packed ring layout support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 61ef699ac..df9bbf0ac 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -363,8 +363,20 @@  vhost_user_set_vring_num(struct virtio_net **pdev,
 	 *
 	 *   Queue Size value is always a power of 2. The maximum Queue Size
 	 *   value is 32768.
+	 *
+	 * VIRTIO 1.1 2.7 Virtqueues says:
+	 *
+	 *   Packed virtqueues support up to 2^15 entries each.
 	 */
-	if ((vq->size & (vq->size - 1)) || vq->size > 32768) {
+	if (!vq_is_packed(dev)) {
+		if (vq->size & (vq->size - 1)) {
+			RTE_LOG(ERR, VHOST_CONFIG,
+				"invalid virtqueue size %u\n", vq->size);
+			return RTE_VHOST_MSG_RESULT_ERR;
+		}
+	}
+
+	if (vq->size > 32768) {
 		RTE_LOG(ERR, VHOST_CONFIG,
 			"invalid virtqueue size %u\n", vq->size);
 		return RTE_VHOST_MSG_RESULT_ERR;