]> git.droids-corp.org - dpdk.git/commitdiff
examples/vhost: fix port init in mergeable mode
authorChenbo Xia <chenbo.xia@intel.com>
Thu, 4 Nov 2021 05:11:02 +0000 (13:11 +0800)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Tue, 16 Nov 2021 10:01:22 +0000 (11:01 +0100)
When the example starts in mergeable mode with an i40e port,
it fails to launch because the examples use default mtu MAX_MTU
to configure ethdev. The root cause is some devices have Ethernet
frame overhead and then MAX_MTU will be larger than device's max
mtu, so the ethdev configure will fail.

This patch checks the device's max MTU before setting the ethdev
configuration. If the device has a max MTU, use that value to
configure.

Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length")
Reported-by: Xingguang He <xingguang.he@intel.com>
Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
examples/vhost/main.c

index 8685dfd81b1dbf46fc49a95a845f2b2e435229b3..8bf61b32b669c0f8869fa934e9537eade459cf54 100644 (file)
@@ -273,6 +273,13 @@ port_init(uint16_t port)
 
        tx_rings = (uint16_t)rte_lcore_count();
 
+       if (mergeable) {
+               if (dev_info.max_mtu != UINT16_MAX && dev_info.max_rx_pktlen > dev_info.max_mtu)
+                       vmdq_conf_default.rxmode.mtu = dev_info.max_mtu;
+               else
+                       vmdq_conf_default.rxmode.mtu = MAX_MTU;
+       }
+
        /* Get port configuration. */
        retval = get_eth_conf(&port_conf, num_devices);
        if (retval < 0)
@@ -631,8 +638,6 @@ us_vhost_parse_args(int argc, char **argv)
                                return -1;
                        }
                        mergeable = !!ret;
-                       if (ret)
-                               vmdq_conf_default.rxmode.mtu = MAX_MTU;
                        break;
 
                case OPT_STATS_NUM: