From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC32A606A31C for ; Tue, 17 Nov 2026 05:46:20 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 909E7402D9; Tue, 17 Nov 2026 06:46:06 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTPS id 690814026F for ; Tue, 17 Nov 2026 06:46:03 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3566E1A0012; Tue, 17 Nov 2026 06:46:03 +0100 (CET) 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 0064F1A0003; Tue, 17 Nov 2026 06:46:03 +0100 (CET) Received: from lsv03457.swis.in-blr01.nxp.com (lsv03457.swis.in-blr01.nxp.com [92.120.147.250]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 8B1DE18000BE; Tue, 17 Nov 2026 13:46:02 +0800 (+08) From: Gagandeep Singh To: dev@dpdk.org Cc: hemant.agrawal@nxp.com Subject: [PATCH v5 3/4] net/dpaa: support non fmX-macY type of shared Ethernet name Date: Tue, 17 Nov 2026 11:15:57 +0530 Message-Id: <20261117054558.1297266-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261117054558.1297266-1-g.singh@nxp.com> References: <20261116062512.726405-1-g.singh@nxp.com> <20261117054558.1297266-1-g.singh@nxp.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Hemant Agrawal A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs. Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name. Signed-off-by: Hemant Agrawal --- doc/guides/nics/dpaa.rst | 6 ++- drivers/net/dpaa/dpaa_ethdev.c | 68 +++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst index 7658e6d454..d391c0607f 100644 --- a/doc/guides/nics/dpaa.rst +++ b/doc/guides/nics/dpaa.rst @@ -276,6 +276,11 @@ Refer to the document :doc:`build_and_test` for details. and thus disabling hardware based packet handling at driver level, e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``. +* For a shared MAC interface the kernel network interface name is looked up + in sysfs from the device tree node the port was created from, + so a kernel interface that does not follow + the ``fmX-macY`` naming style is handled without extra configuration. + ``drv_bh_port`` Name of the back-half port associated with an offline (O/H) port device. It is passed on the offline port device itself, which is named @@ -307,7 +312,6 @@ port identified by its ``port_id``, via the experimental ``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()`` APIs declared in ``rte_pmd_dpaa_oldev.h``. - FMAN Config ----------- diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index fe49c7b961..a821e68807 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -9,12 +9,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -57,6 +59,61 @@ #define DRIVER_RECV_ERR_PKTS "recv_err_pkts" #define RTE_PRIORITY_103 103 +#define DPAA_OF_BASE_PATH "/sys/firmware/devicetree/base" + +/* + * Get the kernel netdev name bound to the same device tree node as this + * port, by matching each /sys/class/net//device/of_node against + * node_path. Returns 1 on success, 0 if none was found, negative on error. + */ +static int +dpaa_get_kernel_ifname(const char *node_path, char *name, size_t size) +{ + char path[PATH_MAX], resolved[PATH_MAX]; + struct dirent *entry; + DIR *dir; + int ret; + + if (!node_path || node_path[0] == '\0') + return 0; + + dir = opendir("/sys/class/net"); + if (!dir) + return 0; + + ret = 0; + while ((entry = readdir(dir)) != NULL) { + if (entry->d_name[0] == '.') + continue; + + if (snprintf(path, sizeof(path), + "/sys/class/net/%s/device/of_node", + entry->d_name) >= (int)sizeof(path)) + continue; + + if (realpath(path, resolved) == NULL) + continue; + + if (strncmp(resolved, DPAA_OF_BASE_PATH, + strlen(DPAA_OF_BASE_PATH)) != 0) + continue; + + if (strcmp(resolved + strlen(DPAA_OF_BASE_PATH), + node_path) != 0) + continue; + + if (rte_strscpy(name, entry->d_name, size) < 0) { + ret = -ENAMETOOLONG; + break; + } + ret = 1; + break; + } + + closedir(dir); + return ret; +} + /* Supported Rx offloads */ static uint64_t dev_rx_offloads_sup = RTE_ETH_RX_OFFLOAD_SCATTER; @@ -251,6 +308,7 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) int speed, duplex; int ret, rx_status, socket_fd; struct ifreq ifr; + char sh_if_name[IFNAMSIZ]; PMD_INIT_FUNC_TRACE(); @@ -272,7 +330,15 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) DPAA_PMD_ERR("Cannot open IF socket"); return -errno; } - strlcpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ); + + /* The DPDK port name matches the netdev only for fmX-macY. */ + sh_if_name[0] = '\0'; + ret = dpaa_get_kernel_ifname(__fif->node_path, sh_if_name, + sizeof(sh_if_name)); + if (ret <= 0 || sh_if_name[0] == '\0') + strlcpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ); + else + strlcpy(ifr.ifr_name, sh_if_name, IFNAMSIZ); if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) { DPAA_PMD_ERR("Cannot get interface mtu"); -- 2.25.1