From: Rohit Raj <rohit....@nxp.com> Since DPDK was able to configure mtu in VSP/Shared interface mode, it was causing misconfiguration of the hw which further caused crashes.
This patch allow only kernel to config MTU in such cases Signed-off-by: Rohit Raj <rohit....@nxp.com> Signed-off-by: Vanshika Shukla <vanshika.shu...@nxp.com> --- drivers/net/dpaa/dpaa_ethdev.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 935a4f2ada..c25576b7c7 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -14,6 +14,7 @@ #include <pthread.h> #include <sys/types.h> #include <sys/syscall.h> +#include <sys/ioctl.h> #include <rte_string_fns.h> #include <rte_byteorder.h> @@ -165,9 +166,15 @@ dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE; uint32_t buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; + struct fman_if *fif = dev->process_private; PMD_INIT_FUNC_TRACE(); + if (fif->is_shared_mac) { + DPAA_PMD_ERR("Cannot configure mtu from DPDK in VSP mode."); + return -ENOTSUP; + } + /* * Refuse mtu that requires the support of scattered packets * when this feature has not been enabled before. @@ -206,7 +213,8 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) struct rte_intr_handle *intr_handle; uint32_t max_rx_pktlen; int speed, duplex; - int ret, rx_status; + int ret, rx_status, socket_fd; + struct ifreq ifr; PMD_INIT_FUNC_TRACE(); @@ -222,6 +230,26 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) dpaa_intf->name); return -EHOSTDOWN; } + + socket_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (socket_fd == -1) { + DPAA_PMD_ERR("Cannot open IF socket"); + return -errno; + } + + strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ); + + if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) { + DPAA_PMD_ERR("Cannot get interface mtu"); + close(socket_fd); + return -errno; + } + + close(socket_fd); + DPAA_PMD_INFO("Using kernel configured mtu size(%u)", + ifr.ifr_mtu); + + eth_conf->rxmode.mtu = ifr.ifr_mtu; } /* Rx offloads which are enabled by default */ @@ -249,7 +277,8 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) max_rx_pktlen = DPAA_MAX_RX_PKT_LEN; } - fman_if_set_maxfrm(dev->process_private, max_rx_pktlen); + if (!fif->is_shared_mac) + fman_if_set_maxfrm(dev->process_private, max_rx_pktlen); if (rx_offloads & RTE_ETH_RX_OFFLOAD_SCATTER) { DPAA_PMD_DEBUG("enabling scatter mode"); -- 2.25.1