dpdk: fix max frame size 93/35293/5
authorDamjan Marion <damarion@cisco.com>
Sun, 13 Feb 2022 19:08:30 +0000 (20:08 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 5 Apr 2022 16:02:30 +0000 (16:02 +0000)
Type: fix
Change-Id: I70f9ec2eb6c9c1494a4ecd56e06898f6162a0e0e
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/dpdk/device/common.c
src/plugins/dpdk/device/init.c

index df80a85..61ab7b4 100644 (file)
@@ -66,7 +66,7 @@ dpdk_device_setup (dpdk_device_t * xd)
   struct rte_eth_dev_info dev_info;
   struct rte_eth_conf conf = {};
   u64 rxo, txo;
-  u16 mtu;
+  u16 max_frame_size;
   int rv;
   int j;
 
@@ -179,12 +179,11 @@ dpdk_device_setup (dpdk_device_t * xd)
     xd->max_supported_frame_size = dev_info.max_rx_pktlen;
 #endif
 
-  mtu = clib_min (xd->max_supported_frame_size - xd->driver_frame_overhead,
-                 ethernet_main.default_mtu);
-  mtu = mtu + hi->frame_overhead - xd->driver_frame_overhead;
+  max_frame_size = clib_min (xd->max_supported_frame_size,
+                            ethernet_main.default_mtu + hi->frame_overhead);
 
 #if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
-  conf.rxmode.mtu = mtu;
+  conf.rxmode.mtu = max_frame_size - xd->driver_frame_overhead;
 #endif
 
 retry:
@@ -197,15 +196,15 @@ retry:
     }
 
 #if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
-  rte_eth_dev_set_mtu (xd->port_id, mtu);
+  rte_eth_dev_set_mtu (xd->port_id,
+                      max_frame_size - xd->driver_frame_overhead);
 #endif
 
   hi->max_frame_size = 0;
-  vnet_hw_interface_set_max_frame_size (vnm, xd->hw_if_index,
-                                       mtu + hi->frame_overhead);
-  dpdk_log_debug ("[%u] mtu %u max_frame_size %u max max_frame_size %u "
+  vnet_hw_interface_set_max_frame_size (vnm, xd->hw_if_index, max_frame_size);
+  dpdk_log_debug ("[%u] max_frame_size %u max max_frame_size %u "
                  "driver_frame_overhead %u",
-                 xd->port_id, mtu, hi->max_frame_size,
+                 xd->port_id, hi->max_frame_size,
                  xd->max_supported_frame_size, xd->driver_frame_overhead);
 
   vec_validate_aligned (xd->tx_queues, xd->conf.n_tx_queues - 1,
index 9d68775..3b5b907 100644 (file)
@@ -399,7 +399,8 @@ dpdk_lib_init (dpdk_main_t * dm)
 #if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
       q = di.max_rx_pktlen - di.max_mtu;
 
-      if (q < xd->driver_frame_overhead && q > 0)
+      /* attempt to protect from bogus value provided by pmd */
+      if (q < (2 * xd->driver_frame_overhead) && q > 0)
        xd->driver_frame_overhead = q;
       dpdk_log_debug ("[%u] min_mtu: %u, max_mtu: %u, min_rx_bufsize: %u, "
                      "max_rx_pktlen: %u, max_lro_pkt_size: %u",