app/testpmd: fix offloads for the newly attached port

Message ID 20210619154012.27295-1-viacheslavo@nvidia.com (mailing list archive)
State Changes Requested, archived
Delegated to: Andrew Rybchenko
Headers
Series app/testpmd: fix offloads for the newly attached port |

Checks

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

Commit Message

Slava Ovsiienko June 19, 2021, 3:40 p.m. UTC
  For the newly attached ports (with "port attach" command) the
default offloads settings, configured from application command
line, were not applied, causing port start failure following
the attach. For example, if scattering offload was configured
in command line and rxpkts was configured for multiple segments,
the newly attached port start was failed due to missing scattering
offload enable in the new port settings. The missing code to apply
the offloads to the new device and its queues is added.

Cc: stable@dpdk.org
Fixes: c9cce42876f5 ("ethdev: remove deprecated attach/detach functions")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 app/test-pmd/testpmd.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
  

Comments

Singh, Aman Deep June 23, 2021, 9:09 a.m. UTC | #1
Acked-by: Aman Deep Singh <aman.deep.singh@intel.com>

On 6/19/2021 9:10 PM, Viacheslav Ovsiienko wrote:
> For the newly attached ports (with "port attach" command) the
> default offloads settings, configured from application command
> line, were not applied, causing port start failure following
> the attach. For example, if scattering offload was configured
> in command line and rxpkts was configured for multiple segments,
> the newly attached port start was failed due to missing scattering
> offload enable in the new port settings. The missing code to apply
> the offloads to the new device and its queues is added.
>
> Cc: stable@dpdk.org
> Fixes: c9cce42876f5 ("ethdev: remove deprecated attach/detach functions")
>
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>
>
  
Andrew Rybchenko July 1, 2021, 2:01 p.m. UTC | #2
On 6/19/21 6:40 PM, Viacheslav Ovsiienko wrote:
> For the newly attached ports (with "port attach" command) the
> default offloads settings, configured from application command
> line, were not applied, causing port start failure following
> the attach. For example, if scattering offload was configured
> in command line and rxpkts was configured for multiple segments,
> the newly attached port start was failed due to missing scattering
> offload enable in the new port settings. The missing code to apply
> the offloads to the new device and its queues is added.
> 
> Cc: stable@dpdk.org
> Fixes: c9cce42876f5 ("ethdev: remove deprecated attach/detach functions")

Two above lines should be swapped.

> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

The patch duplicates too much from init_config() function.
Please, factor out a helper function to do the job and
use it in init_config() and reconfig().
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 8ed1b97dec..b4ec182423 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1599,6 +1599,7 @@  reconfig(portid_t new_port_id, unsigned socket_id)
 {
 	struct rte_port *port;
 	int ret;
+	int i;
 
 	/* Reconfiguration of Ethernet ports. */
 	port = &ports[new_port_id];
@@ -1611,7 +1612,38 @@  reconfig(portid_t new_port_id, unsigned socket_id)
 	port->need_reconfig = 1;
 	port->need_reconfig_queues = 1;
 	port->socket_id = socket_id;
+	port->tx_metadata = 0;
+
+	/* Apply default TxRx configuration to the port */
+	port->dev_conf.txmode = tx_mode;
+	port->dev_conf.rxmode = rx_mode;
+
+	if (!(port->dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE))
+		port->dev_conf.txmode.offloads &=
+					~DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	/* Apply Rx offloads configuration */
+	for (i = 0; i < port->dev_info.max_rx_queues; i++)
+		port->rx_conf[i].offloads = port->dev_conf.rxmode.offloads;
+	/* Apply Tx offloads configuration */
+	for (i = 0; i < port->dev_info.max_tx_queues; i++)
+		port->tx_conf[i].offloads = port->dev_conf.txmode.offloads;
+
+	/* Check for maximum number of segments per MTU. Accordingly
+	 * update the mbuf data size.
+	 */
+	if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX &&
+	    port->dev_info.rx_desc_lim.nb_mtu_seg_max != 0) {
+		uint16_t data_size = rx_mode.max_rx_pkt_len /
+				port->dev_info.rx_desc_lim.nb_mtu_seg_max;
 
+		if ((data_size + RTE_PKTMBUF_HEADROOM) > mbuf_data_size[0]) {
+			mbuf_data_size[0] = data_size + RTE_PKTMBUF_HEADROOM;
+			TESTPMD_LOG(WARNING,
+			    "Adjusted mbuf size of the first segment %hu\n",
+			    mbuf_data_size[0]);
+		}
+	}
 	init_port_config();
 }