[1/3] app/testpmd: update Rx offload after setting MTU sccessfully

Message ID 20200121114433.57543-2-huwei013@chinasoftinc.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fixes for testpmd application |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS

Commit Message

Wei Hu (Xavier) Jan. 21, 2020, 11:44 a.m. UTC
  From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

Currently, Rx offload capabilities and max_rx_pkt_len in the struct
variable named rte_port are not updated after setting mtu successfully
in port_mtu_set function by 'port config mtu <port_id> <value>' command.
This may lead to reconfig mtu to the initial value in the driver when
recalling rte_eth_dev_configure API interface.

This patch updates Rx offload capabilities and max_rx_pkt_len after
setting mtu successfully when configuring mtu.

Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 app/test-pmd/config.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit Jan. 28, 2020, 11:27 a.m. UTC | #1
On 1/21/2020 11:44 AM, Wei Hu (Xavier) wrote:
> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
> 
> Currently, Rx offload capabilities and max_rx_pkt_len in the struct
> variable named rte_port are not updated after setting mtu successfully
> in port_mtu_set function by 'port config mtu <port_id> <value>' command.
> This may lead to reconfig mtu to the initial value in the driver when
> recalling rte_eth_dev_configure API interface.
> 
> This patch updates Rx offload capabilities and max_rx_pkt_len after
> setting mtu successfully when configuring mtu.
> 
> Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> ---
>  app/test-pmd/config.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 9669cbd4c..09a1579f5 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1216,7 +1216,9 @@ void
>  port_mtu_set(portid_t port_id, uint16_t mtu)
>  {
>  	int diag;
> +	struct rte_port *rte_port = &ports[port_id];
>  	struct rte_eth_dev_info dev_info;
> +	uint16_t eth_overhead;
>  	int ret;
>  
>  	if (port_id_is_invalid(port_id, ENABLED_WARN))
> @@ -1232,8 +1234,22 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
>  		return;
>  	}
>  	diag = rte_eth_dev_set_mtu(port_id, mtu);
> -	if (diag == 0)
> +	if (diag == 0) {
> +		/*
> +		 * Ether overhead in driver is equal to the difference of
> +		 * max_rx_pktlen and max_mtu in rte_eth_dev_info.
> +		 */
> +		eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
> +		if (mtu > RTE_ETHER_MAX_LEN - eth_overhead)
> +			rte_port->dev_conf.rxmode.offloads |=
> +						DEV_RX_OFFLOAD_JUMBO_FRAME;
> +		else
> +			rte_port->dev_conf.rxmode.offloads &=
> +						~DEV_RX_OFFLOAD_JUMBO_FRAME;

If the jumbo frame capability supported or not should be tested before setting it.

> +		rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;

May need to check against 'dev_info.max_rx_pktlen', if the 'max_rx_pkt_len' is
bigger than this, it will fail in next configure.

Also some divers already does this in PMD code, should we clean that code or not
is a question.
  
Wei Hu (Xavier) Feb. 12, 2020, 12:25 a.m. UTC | #2
Hi, Ferruh Yigit

On 2020/1/28 19:27, Ferruh Yigit wrote:
> On 1/21/2020 11:44 AM, Wei Hu (Xavier) wrote:
>> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
>>
>> Currently, Rx offload capabilities and max_rx_pkt_len in the struct
>> variable named rte_port are not updated after setting mtu successfully
>> in port_mtu_set function by 'port config mtu <port_id> <value>' command.
>> This may lead to reconfig mtu to the initial value in the driver when
>> recalling rte_eth_dev_configure API interface.
>>
>> This patch updates Rx offload capabilities and max_rx_pkt_len after
>> setting mtu successfully when configuring mtu.
>>
>> Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>> ---
>>   app/test-pmd/config.c | 18 +++++++++++++++++-
>>   1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index 9669cbd4c..09a1579f5 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -1216,7 +1216,9 @@ void
>>   port_mtu_set(portid_t port_id, uint16_t mtu)
>>   {
>>   	int diag;
>> +	struct rte_port *rte_port = &ports[port_id];
>>   	struct rte_eth_dev_info dev_info;
>> +	uint16_t eth_overhead;
>>   	int ret;
>>   
>>   	if (port_id_is_invalid(port_id, ENABLED_WARN))
>> @@ -1232,8 +1234,22 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
>>   		return;
>>   	}
>>   	diag = rte_eth_dev_set_mtu(port_id, mtu);
>> -	if (diag == 0)
>> +	if (diag == 0) {
>> +		/*
>> +		 * Ether overhead in driver is equal to the difference of
>> +		 * max_rx_pktlen and max_mtu in rte_eth_dev_info.
>> +		 */
>> +		eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
>> +		if (mtu > RTE_ETHER_MAX_LEN - eth_overhead)
>> +			rte_port->dev_conf.rxmode.offloads |=
>> +						DEV_RX_OFFLOAD_JUMBO_FRAME;
>> +		else
>> +			rte_port->dev_conf.rxmode.offloads &=
>> +						~DEV_RX_OFFLOAD_JUMBO_FRAME;
> 
> If the jumbo frame capability supported or not should be tested before setting it.
> 
>> +		rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;
> 
> May need to check against 'dev_info.max_rx_pktlen', if the 'max_rx_pkt_len' is
> bigger than this, it will fail in next configure.
> 
> Also some divers already does this in PMD code, should we clean that code or not
> is a question.
> 
The snippset is adjusted as follows:

if (mtu > RTE_ETHER_MAX_LEN - eth_overhead && dev_info.rx_offload_capa & 
DEV_RX_OFFLOAD_JUMBO_FRAME) {
	rte_port->dev_conf.rxmode.offloads |= 			
                                          DEV_RX_OFFLOAD_JUMBO_FRAME;
	rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;
} else
	rte_port->dev_conf.rxmode.offloads &=
					~DEV_RX_OFFLOAD_JUMBO_FRAME;

We only modifies the internal variables of testpmd, don't impact on the 
implementation of the driver.

Thanks for more suggestions.

Xavier
  
Wei Hu (Xavier) Feb. 13, 2020, 1:52 a.m. UTC | #3
Hi, Ferruh Yigit

On 2020/2/12 8:25, Wei Hu (Xavier) wrote:
> Hi, Ferruh Yigit
> 
> On 2020/1/28 19:27, Ferruh Yigit wrote:
>> On 1/21/2020 11:44 AM, Wei Hu (Xavier) wrote:
>>> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
>>>
>>> Currently, Rx offload capabilities and max_rx_pkt_len in the struct
>>> variable named rte_port are not updated after setting mtu successfully
>>> in port_mtu_set function by 'port config mtu <port_id> <value>' command.
>>> This may lead to reconfig mtu to the initial value in the driver when
>>> recalling rte_eth_dev_configure API interface.
>>>
>>> This patch updates Rx offload capabilities and max_rx_pkt_len after
>>> setting mtu successfully when configuring mtu.
>>>
>>> Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>>> ---
>>>   app/test-pmd/config.c | 18 +++++++++++++++++-
>>>   1 file changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>>> index 9669cbd4c..09a1579f5 100644
>>> --- a/app/test-pmd/config.c
>>> +++ b/app/test-pmd/config.c
>>> @@ -1216,7 +1216,9 @@ void
>>>   port_mtu_set(portid_t port_id, uint16_t mtu)
>>>   {
>>>       int diag;
>>> +    struct rte_port *rte_port = &ports[port_id];
>>>       struct rte_eth_dev_info dev_info;
>>> +    uint16_t eth_overhead;
>>>       int ret;
>>>       if (port_id_is_invalid(port_id, ENABLED_WARN))
>>> @@ -1232,8 +1234,22 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
>>>           return;
>>>       }
>>>       diag = rte_eth_dev_set_mtu(port_id, mtu);
>>> -    if (diag == 0)
>>> +    if (diag == 0) {
>>> +        /*
>>> +         * Ether overhead in driver is equal to the difference of
>>> +         * max_rx_pktlen and max_mtu in rte_eth_dev_info.
>>> +         */
>>> +        eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
>>> +        if (mtu > RTE_ETHER_MAX_LEN - eth_overhead)
>>> +            rte_port->dev_conf.rxmode.offloads |=
>>> +                        DEV_RX_OFFLOAD_JUMBO_FRAME;
>>> +        else
>>> +            rte_port->dev_conf.rxmode.offloads &=
>>> +                        ~DEV_RX_OFFLOAD_JUMBO_FRAME;
>>
>> If the jumbo frame capability supported or not should be tested before 
>> setting it.
>>
>>> +        rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;
>>
>> May need to check against 'dev_info.max_rx_pktlen', if the 
>> 'max_rx_pkt_len' is
>> bigger than this, it will fail in next configure.
>>
>> Also some divers already does this in PMD code, should we clean that 
>> code or not
>> is a question.
>>
> The snippset is adjusted as follows:
> 
> if (mtu > RTE_ETHER_MAX_LEN - eth_overhead && dev_info.rx_offload_capa & 
> DEV_RX_OFFLOAD_JUMBO_FRAME) {
>      rte_port->dev_conf.rxmode.offloads |=
>                                           DEV_RX_OFFLOAD_JUMBO_FRAME;
>      rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;
> } else
>      rte_port->dev_conf.rxmode.offloads &=
>                      ~DEV_RX_OFFLOAD_JUMBO_FRAME;
> 
> We only modifies the internal variables of testpmd, don't impact on the 
> implementation of the driver.
> 
> Thanks for more suggestions.
> 
> XavierThe code is modified as follows:

diag = rte_eth_dev_set_mtu(port_id, mtu);
if (diag == 0 &&
     dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) {
          /*
           * Ether overhead in driver is equal to the difference of
           * max_rx_pktlen and max_mtu in rte_eth_dev_info when the
           * device supports jumbo frame.
           */
          eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
          if (mtu > RTE_ETHER_MAX_LEN - eth_overhead) {
                 rte_port->dev_conf.rxmode.offloads |= 

                         DEV_RX_OFFLOAD_JUMBO_FRAME;
                 rte_port->dev_conf.rxmode.max_rx_pkt_len =
                         mtu + eth_overhead;
          } else
                 rte_port->dev_conf.rxmode.offloads &= 

                        ~DEV_RX_OFFLOAD_JUMBO_FRAME;

         return;
}

We will send V2. Thanks

Xavier
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9669cbd4c..09a1579f5 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1216,7 +1216,9 @@  void
 port_mtu_set(portid_t port_id, uint16_t mtu)
 {
 	int diag;
+	struct rte_port *rte_port = &ports[port_id];
 	struct rte_eth_dev_info dev_info;
+	uint16_t eth_overhead;
 	int ret;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
@@ -1232,8 +1234,22 @@  port_mtu_set(portid_t port_id, uint16_t mtu)
 		return;
 	}
 	diag = rte_eth_dev_set_mtu(port_id, mtu);
-	if (diag == 0)
+	if (diag == 0) {
+		/*
+		 * Ether overhead in driver is equal to the difference of
+		 * max_rx_pktlen and max_mtu in rte_eth_dev_info.
+		 */
+		eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
+		if (mtu > RTE_ETHER_MAX_LEN - eth_overhead)
+			rte_port->dev_conf.rxmode.offloads |=
+						DEV_RX_OFFLOAD_JUMBO_FRAME;
+		else
+			rte_port->dev_conf.rxmode.offloads &=
+						~DEV_RX_OFFLOAD_JUMBO_FRAME;
+		rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead;
+
 		return;
+	}
 	printf("Set MTU failed. diag=%d\n", diag);
 }