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: sta...@dpdk.org
Fixes: c9cce42876f5 ("ethdev: remove deprecated attach/detach functions")

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

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();
 }
 
-- 
2.18.1

Reply via email to