[dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Ferruh Yigit ferruh.yigit at intel.com
Tue Jan 26 01:44:06 CET 2021


On 1/25/2021 7:41 PM, Lance Richardson wrote:
> On Mon, Jan 25, 2021 at 1:15 PM Ferruh Yigit <ferruh.yigit at intel.com> wrote:
>>
>> From: Steve Yang <stevex.yang at intel.com>
>>
>> "port config all max-pkt-len" command fails because it doesn't set the
>> 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.
>>
>> Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload
>> flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'.
>> 'init_config()' function is only called during testpmd startup, but the
>> flag status needs to be calculated whenever 'max_rx_pkt_len' changes.
>>
>> The issue can be reproduce as [1], where the 'max-pkt-len' reduced and
>> 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it
>> didn't.
>>
>> Adding the 'update_jumbo_frame_offload()' helper function to update
>> 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This
>> function is called both by 'init_config()' and
>> 'cmd_config_max_pkt_len_parsed()'.
>>
>> Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()'
>> updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it
>> is zero.
>> If '--max-pkt-len=N' argument provided, it will be used instead.
>> And with each "port config all max-pkt-len" command, the
>> 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is
>> updated.
>>
>> [1]
> 
> <snip>
> 
>> +/*
>> + * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME offload,
>> + * MTU is also aligned if JUMBO_FRAME offload is not set.
>> + *
>> + * port->dev_info should be get before calling this function.
> 
> Should this be "port->dev_info should be set ..." instead?
> 

Ack.

> 
> <snip>
> 
>> +       if (rx_offloads != port->dev_conf.rxmode.offloads) {
>> +               uint16_t qid;
>> +
>> +               port->dev_conf.rxmode.offloads = rx_offloads;
>> +
>> +               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
>> +               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
>> +                       if (on)
>> +                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
>> +                       else
>> +                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
>> +               }
> 
> Is it correct to set per-queue offloads that aren't advertised by the PMD
> as supported in rx_queue_offload_capa?
> 

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values 
are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 
'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have 
it. And the port level capability is already checked above.

>> +       }
>> +
>> +       /* If JUMBO_FRAME is set MTU conversion done by ethdev layer,
>> +        * if unset do it here
>> +        */
>> +       if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
>> +               ret = rte_eth_dev_set_mtu(portid,
>> +                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
>> +               if (ret)
>> +                       printf("Failed to set MTU to %u for port %u\n",
>> +                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead,
>> +                               portid);
>> +       }
>> +
>> +       return 0;
>> +}
>> +
> 
> Applied and tested with a few iterations of configuring max packet size
> back and forth between jumbo and non-jumbo sizes, also tried setting
> max packet size using the command-line option, all seems good based
> on rx offloads and packet forwarding.
> 
> Two minor questions above, otherwise LGTM.
> 

Thanks for testing. I will wait for more comments before new version.


More information about the dev mailing list