From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org
Cc: hemant.agrawal@nxp.com
Subject: [PATCH v3 3/4] net/dpaa: support non fmX-macY type of shared Ethernet name
Date: Tue, 3 Nov 2026 15:06:00 +0530 [thread overview]
Message-ID: <20261103093601.3736486-4-g.singh@nxp.com> (raw)
In-Reply-To: <20261103093601.3736486-1-g.singh@nxp.com>
From: Hemant Agrawal <hemant.agrawal@nxp.com>
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 <hemant.agrawal@nxp.com>
---
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 <inttypes.h>
#include <unistd.h>
#include <limits.h>
+#include <stdlib.h>
#include <sched.h>
#include <signal.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/ioctl.h>
+#include <dirent.h>
#include <eal_export.h>
#include <rte_string_fns.h>
@@ -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/<ifname>/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
next prev parent reply other threads:[~2026-11-03 9:36 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 8:55 [PATCH v1 0/3] DPAA driver changes Gagandeep Singh
2026-10-28 8:55 ` [PATCH v1 1/3] drivers: add offline (O/H) port device support Gagandeep Singh
2026-10-28 8:55 ` [PATCH v1 2/3] net/dpaa: support non fmX-macY type of shared Ethernet name Gagandeep Singh
2026-10-28 8:55 ` [PATCH v1 3/3] drivers: add DPAA cgrid cleanup support Gagandeep Singh
2026-10-28 14:41 ` [PATCH v1 0/3] DPAA driver changes Stephen Hemminger
2026-10-30 4:43 ` Gagandeep Singh
2026-10-30 4:43 ` [PATCH v2 0/4] " Gagandeep Singh
2026-10-30 4:43 ` [PATCH v2 1/4] bus/dpaa: fix out-of-bounds read of mac_idx array Gagandeep Singh
2026-10-30 4:43 ` [PATCH v2 2/4] drivers: add offline (O/H) port device support Gagandeep Singh
2026-10-30 4:43 ` [PATCH v2 3/4] net/dpaa: support non fmX-macY type of shared Ethernet name Gagandeep Singh
2026-10-30 4:43 ` [PATCH v2 4/4] drivers: add DPAA cgrid cleanup support Gagandeep Singh
2026-11-02 8:09 ` [PATCH v2 0/4] DPAA driver changes Stephen Hemminger
2026-11-02 13:23 ` Stephen Hemminger
2026-11-03 9:38 ` Gagandeep Singh
2026-11-03 9:35 ` [PATCH v3 " Gagandeep Singh
2026-11-03 9:35 ` [PATCH v3 1/4] bus/dpaa: fix out-of-bounds read of mac_idx array Gagandeep Singh
2026-11-03 9:35 ` [PATCH v3 2/4] drivers: add offline (O/H) port device support Gagandeep Singh
2026-11-03 9:36 ` Gagandeep Singh [this message]
2026-11-03 9:36 ` [PATCH v3 4/4] drivers: add DPAA cgrid cleanup support Gagandeep Singh
2026-11-04 11:29 ` [PATCH v3 0/4] DPAA driver changes Stephen Hemminger
2026-11-05 5:53 ` Gagandeep Singh
2026-11-16 6:25 ` [PATCH v4 " Gagandeep Singh
2026-11-16 6:25 ` [PATCH v4 1/4] bus/dpaa: fix out-of-bounds read of mac_idx array Gagandeep Singh
2026-11-16 6:25 ` [PATCH v4 2/4] drivers: add offline (O/H) port device support Gagandeep Singh
2026-11-16 6:25 ` [PATCH v4 3/4] net/dpaa: support non fmX-macY type of shared Ethernet name Gagandeep Singh
2026-11-16 6:25 ` [PATCH v4 4/4] drivers: add DPAA cgrid cleanup support Gagandeep Singh
2026-11-16 22:48 ` [PATCH v4 0/4] DPAA driver changes Stephen Hemminger
2026-11-17 5:45 ` [PATCH v5 " Gagandeep Singh
2026-11-17 5:45 ` [PATCH v5 1/4] bus/dpaa: fix out-of-bounds read of mac_idx array Gagandeep Singh
2026-11-17 5:45 ` [PATCH v5 2/4] drivers: add offline (O/H) port device support Gagandeep Singh
2026-11-17 5:45 ` [PATCH v5 3/4] net/dpaa: support non fmX-macY type of shared Ethernet name Gagandeep Singh
2026-11-17 5:45 ` [PATCH v5 4/4] drivers: add DPAA cgrid cleanup support Gagandeep Singh
2026-11-17 17:25 ` [PATCH v5 0/4] DPAA driver changes Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103093601.3736486-4-g.singh@nxp.com \
--to=g.singh@nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox