diff options
author | Damjan Marion <damarion@cisco.com> | 2022-02-13 20:08:30 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-04-05 16:02:30 +0000 |
commit | 57eb4b6269dd22b042deb2a7a535cf31387a0161 (patch) | |
tree | 7501b8dd4e92f3df3bbe6918bb199672011f10b8 /src/plugins/dpdk | |
parent | 35cf8aa93bfb8414ae58bfcb1d668b2c374ff583 (diff) |
dpdk: fix max frame size
Type: fix
Change-Id: I70f9ec2eb6c9c1494a4ecd56e06898f6162a0e0e
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/dpdk')
-rw-r--r-- | src/plugins/dpdk/device/common.c | 19 | ||||
-rw-r--r-- | src/plugins/dpdk/device/init.c | 3 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c index df80a85872d..61ab7b4a5b2 100644 --- a/src/plugins/dpdk/device/common.c +++ b/src/plugins/dpdk/device/common.c @@ -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, diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 9d68775d86a..3b5b90704df 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -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", |