diff options
author | Damjan Marion <damarion@cisco.com> | 2022-01-05 23:25:12 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-01-06 20:05:25 +0000 |
commit | 632ea7089f404186cc7209bdfb2644b24593a2df (patch) | |
tree | 752f7e382c17be7859170bb688286906360871c3 /src/plugins/dpdk/device/common.c | |
parent | 2a8d3083747e3b881bdc71ad6c1add79850e8731 (diff) |
dpdk: cleanup MTU handling
Type: improvement
Change-Id: I4b929693f3671be8ee63a58afcbac75a27d99d57
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/device/common.c')
-rw-r--r-- | src/plugins/dpdk/device/common.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c index f77e377e14c..c32382a55c6 100644 --- a/src/plugins/dpdk/device/common.c +++ b/src/plugins/dpdk/device/common.c @@ -48,6 +48,7 @@ dpdk_device_setup (dpdk_device_t * xd) vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, xd->hw_if_index); struct rte_eth_dev_info dev_info; u64 bitmap; + u16 mtu; int rv; int j; @@ -89,6 +90,12 @@ dpdk_device_setup (dpdk_device_t * xd) xd->port_conf.rxmode.offloads ^= bitmap; } + if (xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) + xd->port_conf.rxmode.max_rx_pkt_len = + clib_min (ETHERNET_MAX_PACKET_BYTES, dev_info.max_rx_pktlen); + else + xd->port_conf.rxmode.max_rx_pkt_len = 0; + rv = rte_eth_dev_configure (xd->port_id, xd->conf.n_rx_queues, xd->conf.n_tx_queues, &xd->port_conf); @@ -98,6 +105,21 @@ dpdk_device_setup (dpdk_device_t * xd) goto error; } + rte_eth_dev_get_mtu (xd->port_id, &mtu); + dpdk_log_debug ("[%u] device default mtu %u", xd->port_id, mtu); + + hi->max_supported_packet_bytes = mtu; + if (hi->max_packet_bytes > mtu) + { + vnet_hw_interface_set_mtu (vnm, xd->hw_if_index, mtu); + } + else + { + rte_eth_dev_set_mtu (xd->port_id, hi->max_packet_bytes); + dpdk_log_debug ("[%u] port mtu set to %u", xd->port_id, + hi->max_packet_bytes); + } + vec_validate_aligned (xd->tx_queues, xd->conf.n_tx_queues - 1, CLIB_CACHE_LINE_BYTES); for (j = 0; j < xd->conf.n_tx_queues; j++) @@ -144,7 +166,6 @@ dpdk_device_setup (dpdk_device_t * xd) if (vec_len (xd->errors)) goto error; - rte_eth_dev_set_mtu (xd->port_id, hi->max_packet_bytes); xd->buffer_flags = (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_EXT_HDR_VALID); |