From patchwork Tue Jul 9 10:05:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vanshika Shukla X-Patchwork-Id: 142261 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63621455E2; Tue, 9 Jul 2024 12:05:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A3BE43338; Tue, 9 Jul 2024 12:05:18 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 318E3410F9; Tue, 9 Jul 2024 12:05:11 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 132471A1936; Tue, 9 Jul 2024 12:05:11 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CF50C1A0CCB; Tue, 9 Jul 2024 12:05:10 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 2F1F8181D0F9; Tue, 9 Jul 2024 18:05:10 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena , Jun Yang Cc: stable@dpdk.org, Rohit Raj , Vanshika Shukla Subject: [v4 7/8] net/dpaa: restrict MTU config for shared intf Date: Tue, 9 Jul 2024 15:35:04 +0530 Message-Id: <20240709100505.2476972-8-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240709100505.2476972-1-vanshika.shukla@nxp.com> References: <20240708072945.2376209-1-vanshika.shukla@nxp.com> <20240709100505.2476972-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Rohit Raj 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 Fixes: e4abd4ff183c ("net/dpaa: support virtual storage profile") Cc: jun.yang@nxp.com Cc: stable@dpdk.org Signed-off-by: Rohit Raj Signed-off-by: Vanshika Shukla --- 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 44bac67803..060b8c678f 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -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 - 1); + + 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");