[v2,7/7] app/testpmd: verify mtu with rte_eth_dev_info_get()
diff mbox series

Message ID 1553259678-4515-8-git-send-email-ian.stokes@intel.com
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: add min/max MTU to device info
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ian Stokes March 22, 2019, 1:01 p.m. UTC
This commit uses the mtu fields populated in rte_eth_dev_info_get()
to validate the mtu value being passed in port_mtu_set().

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
---
 app/test-pmd/config.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ferruh Yigit March 25, 2019, 2:20 p.m. UTC | #1
On 3/22/2019 1:01 PM, Ian Stokes wrote:
> This commit uses the mtu fields populated in rte_eth_dev_info_get()
> to validate the mtu value being passed in port_mtu_set().
> 
> Signed-off-by: Ian Stokes <ian.stokes@intel.com>

For patch title, I think 'rte_eth_dev_info_get()' is implementation detail here,
what we are verifying mtu against min/max MTU information provided by PMDs.
What do you think something like:
app/testpmd: verify MTU with PMD provided limits

> ---
>  app/test-pmd/config.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index b9e5dd923..6ca97d0e7 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1063,9 +1063,13 @@ void
>  port_mtu_set(portid_t port_id, uint16_t mtu)
>  {
>  	int diag;
> +	struct rte_eth_dev_info dev_info;
>  
>  	if (port_id_is_invalid(port_id, ENABLED_WARN))
>  		return;
> +	rte_eth_dev_info_get(port_id, &dev_info);
> +	if (mtu > dev_info.max_mtu || mtu < dev_info.min_mtu)
> +		return;

This fails silently, I think better to put a log for failure.

>  	diag = rte_eth_dev_set_mtu(port_id, mtu);
>  	if (diag == 0)
>  		return;
>
Ferruh Yigit March 28, 2019, 4:41 p.m. UTC | #2
On 3/25/2019 2:20 PM, Ferruh Yigit wrote:
> On 3/22/2019 1:01 PM, Ian Stokes wrote:
>> This commit uses the mtu fields populated in rte_eth_dev_info_get()
>> to validate the mtu value being passed in port_mtu_set().
>>
>> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
> 
> For patch title, I think 'rte_eth_dev_info_get()' is implementation detail here,
> what we are verifying mtu against min/max MTU information provided by PMDs.
> What do you think something like:
> app/testpmd: verify MTU with PMD provided limits
> 
>> ---
>>  app/test-pmd/config.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index b9e5dd923..6ca97d0e7 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -1063,9 +1063,13 @@ void
>>  port_mtu_set(portid_t port_id, uint16_t mtu)
>>  {
>>  	int diag;
>> +	struct rte_eth_dev_info dev_info;
>>  
>>  	if (port_id_is_invalid(port_id, ENABLED_WARN))
>>  		return;
>> +	rte_eth_dev_info_get(port_id, &dev_info);
>> +	if (mtu > dev_info.max_mtu || mtu < dev_info.min_mtu)
>> +		return;
> 
> This fails silently, I think better to put a log for failure.

Ian seems out of office, I can update this myself if set of the patchset is good.

Patch
diff mbox series

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b9e5dd923..6ca97d0e7 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1063,9 +1063,13 @@  void
 port_mtu_set(portid_t port_id, uint16_t mtu)
 {
 	int diag;
+	struct rte_eth_dev_info dev_info;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return;
+	rte_eth_dev_info_get(port_id, &dev_info);
+	if (mtu > dev_info.max_mtu || mtu < dev_info.min_mtu)
+		return;
 	diag = rte_eth_dev_set_mtu(port_id, mtu);
 	if (diag == 0)
 		return;