net/virtio: report max/min/align desc limits in dev info get

Message ID 20210820124812.3522838-1-andrew.rybchenko@oktetlabs.ru (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: report max/min/align desc limits in dev info get |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Andrew Rybchenko Aug. 20, 2021, 12:48 p.m. UTC
  From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>

Report max/min/align descriptors limits in device info get callback.
Before calling the callback, rte_eth_dev_info_get() provides
default values of nb_min as zero and nb_max as UINT16_MAX that are
not correct for the driver, so one can't rely on them.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Comments

Maxime Coquelin Sept. 13, 2021, 7:52 p.m. UTC | #1
On 8/20/21 2:48 PM, Andrew Rybchenko wrote:
> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> 
> Report max/min/align descriptors limits in device info get callback.
> Before calling the callback, rte_eth_dev_info_get() provides
> default values of nb_min as zero and nb_max as UINT16_MAX that are
> not correct for the driver, so one can't rely on them.
> 
> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index e58085a2c9..601c03e079 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -33,6 +33,7 @@
>  #include "virtio_logs.h"
>  #include "virtqueue.h"
>  #include "virtio_rxtx.h"
> +#include "virtio_rxtx_simple.h"
>  #include "virtio_user/virtio_user_dev.h"
>  
>  static int  virtio_dev_configure(struct rte_eth_dev *dev);
> @@ -2536,6 +2537,30 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>  	if ((host_features & tso_mask) == tso_mask)
>  		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
>  
> +	if (host_features & (1ULL << VIRTIO_F_RING_PACKED)) {
> +		/*
> +		 * According to 2.7 Packed Virtqueues,
> +		 * 2.7.10.1 Structure Size and Alignment:
> +		 * The Queue Size value does not have to be a power of 2.
> +		 */
> +		dev_info->rx_desc_lim.nb_max = UINT16_MAX;
> +	} else {
> +		/*
> +		 * According to 2.6 Split Virtqueues:
> +		 * Queue Size value is always a power of 2. The maximum Queue
> +		 * Size value is 32768.
> +		 */
> +		dev_info->rx_desc_lim.nb_max = 32768;
> +	}
> +	/*
> +	 * Actual minimum is not the same for virtqueues of different kinds,
> +	 * but to avoid tangling the code with separate branches, rely on
> +	 * default thresholds since desc number must be at least of their size.
> +	 */
> +	dev_info->rx_desc_lim.nb_min = RTE_MAX(DEFAULT_RX_FREE_THRESH,
> +					       RTE_VIRTIO_VPMD_RX_REARM_THRESH);
> +	dev_info->rx_desc_lim.nb_align = 1;
> +

It makes sense, but shouldn't we do the same for dev_info->tx_desc_lim?

>  	return 0;
>  }
>  
>
  
Andrew Rybchenko Sept. 14, 2021, 6:43 a.m. UTC | #2
On 9/13/21 10:52 PM, Maxime Coquelin wrote:
> 
> 
> On 8/20/21 2:48 PM, Andrew Rybchenko wrote:
>> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
>>
>> Report max/min/align descriptors limits in device info get callback.
>> Before calling the callback, rte_eth_dev_info_get() provides
>> default values of nb_min as zero and nb_max as UINT16_MAX that are
>> not correct for the driver, so one can't rely on them.
>>
>> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> ---
>>  drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>
>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
>> index e58085a2c9..601c03e079 100644
>> --- a/drivers/net/virtio/virtio_ethdev.c
>> +++ b/drivers/net/virtio/virtio_ethdev.c
>> @@ -33,6 +33,7 @@
>>  #include "virtio_logs.h"
>>  #include "virtqueue.h"
>>  #include "virtio_rxtx.h"
>> +#include "virtio_rxtx_simple.h"
>>  #include "virtio_user/virtio_user_dev.h"
>>  
>>  static int  virtio_dev_configure(struct rte_eth_dev *dev);
>> @@ -2536,6 +2537,30 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>>  	if ((host_features & tso_mask) == tso_mask)
>>  		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
>>  
>> +	if (host_features & (1ULL << VIRTIO_F_RING_PACKED)) {
>> +		/*
>> +		 * According to 2.7 Packed Virtqueues,
>> +		 * 2.7.10.1 Structure Size and Alignment:
>> +		 * The Queue Size value does not have to be a power of 2.
>> +		 */
>> +		dev_info->rx_desc_lim.nb_max = UINT16_MAX;
>> +	} else {
>> +		/*
>> +		 * According to 2.6 Split Virtqueues:
>> +		 * Queue Size value is always a power of 2. The maximum Queue
>> +		 * Size value is 32768.
>> +		 */
>> +		dev_info->rx_desc_lim.nb_max = 32768;
>> +	}
>> +	/*
>> +	 * Actual minimum is not the same for virtqueues of different kinds,
>> +	 * but to avoid tangling the code with separate branches, rely on
>> +	 * default thresholds since desc number must be at least of their size.
>> +	 */
>> +	dev_info->rx_desc_lim.nb_min = RTE_MAX(DEFAULT_RX_FREE_THRESH,
>> +					       RTE_VIRTIO_VPMD_RX_REARM_THRESH);
>> +	dev_info->rx_desc_lim.nb_align = 1;
>> +
> 
> It makes sense, but shouldn't we do the same for dev_info->tx_desc_lim?

Yes, you're right. We'll care about it.

I suggest to add "Rx" in the summary and care about Tx in a
subsequent patch.

net/virtio: report max/min/align Rx desc limits in dev info

OK?
  
Maxime Coquelin Sept. 14, 2021, 7:29 a.m. UTC | #3
On 9/14/21 8:43 AM, Andrew Rybchenko wrote:
> On 9/13/21 10:52 PM, Maxime Coquelin wrote:
>>
>>
>> On 8/20/21 2:48 PM, Andrew Rybchenko wrote:
>>> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
>>>
>>> Report max/min/align descriptors limits in device info get callback.
>>> Before calling the callback, rte_eth_dev_info_get() provides
>>> default values of nb_min as zero and nb_max as UINT16_MAX that are
>>> not correct for the driver, so one can't rely on them.
>>>
>>> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
>>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>> ---
>>>  drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
>>>  1 file changed, 25 insertions(+)
>>>
>>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
>>> index e58085a2c9..601c03e079 100644
>>> --- a/drivers/net/virtio/virtio_ethdev.c
>>> +++ b/drivers/net/virtio/virtio_ethdev.c
>>> @@ -33,6 +33,7 @@
>>>  #include "virtio_logs.h"
>>>  #include "virtqueue.h"
>>>  #include "virtio_rxtx.h"
>>> +#include "virtio_rxtx_simple.h"
>>>  #include "virtio_user/virtio_user_dev.h"
>>>  
>>>  static int  virtio_dev_configure(struct rte_eth_dev *dev);
>>> @@ -2536,6 +2537,30 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>>>  	if ((host_features & tso_mask) == tso_mask)
>>>  		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
>>>  
>>> +	if (host_features & (1ULL << VIRTIO_F_RING_PACKED)) {
>>> +		/*
>>> +		 * According to 2.7 Packed Virtqueues,
>>> +		 * 2.7.10.1 Structure Size and Alignment:
>>> +		 * The Queue Size value does not have to be a power of 2.
>>> +		 */
>>> +		dev_info->rx_desc_lim.nb_max = UINT16_MAX;
>>> +	} else {
>>> +		/*
>>> +		 * According to 2.6 Split Virtqueues:
>>> +		 * Queue Size value is always a power of 2. The maximum Queue
>>> +		 * Size value is 32768.
>>> +		 */
>>> +		dev_info->rx_desc_lim.nb_max = 32768;
>>> +	}
>>> +	/*
>>> +	 * Actual minimum is not the same for virtqueues of different kinds,
>>> +	 * but to avoid tangling the code with separate branches, rely on
>>> +	 * default thresholds since desc number must be at least of their size.
>>> +	 */
>>> +	dev_info->rx_desc_lim.nb_min = RTE_MAX(DEFAULT_RX_FREE_THRESH,
>>> +					       RTE_VIRTIO_VPMD_RX_REARM_THRESH);
>>> +	dev_info->rx_desc_lim.nb_align = 1;
>>> +
>>
>> It makes sense, but shouldn't we do the same for dev_info->tx_desc_lim?
> 
> Yes, you're right. We'll care about it.
> 
> I suggest to add "Rx" in the summary and care about Tx in a
> subsequent patch.
> 
> net/virtio: report max/min/align Rx desc limits in dev info
> 
> OK?
> 

Works for me! I will fix the title while applying.

Thanks,
Maxime
  
Maxime Coquelin Sept. 14, 2021, 9:45 a.m. UTC | #4
On 8/20/21 2:48 PM, Andrew Rybchenko wrote:
> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> 
> Report max/min/align descriptors limits in device info get callback.
> Before calling the callback, rte_eth_dev_info_get() provides
> default values of nb_min as zero and nb_max as UINT16_MAX that are
> not correct for the driver, so one can't rely on them.
> 
> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 

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

Thanks,
Maxime
  
Maxime Coquelin Sept. 14, 2021, 11:26 a.m. UTC | #5
On 8/20/21 2:48 PM, Andrew Rybchenko wrote:
> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> 
> Report max/min/align descriptors limits in device info get callback.
> Before calling the callback, rte_eth_dev_info_get() provides
> default values of nb_min as zero and nb_max as UINT16_MAX that are
> not correct for the driver, so one can't rely on them.
> 
> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

Applied to dpdk-next-virtio/main.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index e58085a2c9..601c03e079 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -33,6 +33,7 @@ 
 #include "virtio_logs.h"
 #include "virtqueue.h"
 #include "virtio_rxtx.h"
+#include "virtio_rxtx_simple.h"
 #include "virtio_user/virtio_user_dev.h"
 
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
@@ -2536,6 +2537,30 @@  virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	if ((host_features & tso_mask) == tso_mask)
 		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
 
+	if (host_features & (1ULL << VIRTIO_F_RING_PACKED)) {
+		/*
+		 * According to 2.7 Packed Virtqueues,
+		 * 2.7.10.1 Structure Size and Alignment:
+		 * The Queue Size value does not have to be a power of 2.
+		 */
+		dev_info->rx_desc_lim.nb_max = UINT16_MAX;
+	} else {
+		/*
+		 * According to 2.6 Split Virtqueues:
+		 * Queue Size value is always a power of 2. The maximum Queue
+		 * Size value is 32768.
+		 */
+		dev_info->rx_desc_lim.nb_max = 32768;
+	}
+	/*
+	 * Actual minimum is not the same for virtqueues of different kinds,
+	 * but to avoid tangling the code with separate branches, rely on
+	 * default thresholds since desc number must be at least of their size.
+	 */
+	dev_info->rx_desc_lim.nb_min = RTE_MAX(DEFAULT_RX_FREE_THRESH,
+					       RTE_VIRTIO_VPMD_RX_REARM_THRESH);
+	dev_info->rx_desc_lim.nb_align = 1;
+
 	return 0;
 }