From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Long Li <longli@microsoft.com>, Wei Hu <weh@microsoft.com>
Subject: [PATCH 9/9] net/mana: use common sysfs routines
Date: Fri, 11 Sep 2026 23:30:28 -0700 [thread overview]
Message-ID: <20260912063319.4117869-10-stephen@networkplumber.org> (raw)
In-Reply-To: <20260912063319.4117869-1-stephen@networkplumber.org>
Read dev_port with the EAL routine rather than opening the file and
parsing it with fscanf().
The value was read with fscanf("%d") and is now converted with base
0, so a value with a leading zero would parse as octal. The kernel
does not print dev_port with leading zeros.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/mana/mana.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 0b72f711a1..39bfb5b4b7 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -14,6 +14,7 @@
#include <rte_kvargs.h>
#include <rte_eal_paging.h>
#include <rte_pci.h>
+#include <rte_sysfs.h>
#include <infiniband/verbs.h>
#include <infiniband/manadv.h>
@@ -1282,6 +1283,7 @@ get_port_mac(struct ibv_device *device, unsigned int port,
DIR *dir;
struct dirent *dent;
unsigned int dev_port;
+ unsigned long val;
MANA_MKSTR(path, "%s/device/net", device->ibdev_path);
@@ -1293,23 +1295,15 @@ get_port_mac(struct ibv_device *device, unsigned int port,
char *name = dent->d_name;
char *mac = NULL;
- MANA_MKSTR(port_path, "%s/%s/dev_port", path, name);
-
/* Ignore . and .. */
if ((name[0] == '.') &&
((name[1] == '\0') ||
((name[1] == '.') && (name[2] == '\0'))))
continue;
- file = fopen(port_path, "r");
- if (!file)
- continue;
-
- ret = fscanf(file, "%u", &dev_port);
- fclose(file);
-
- if (ret != 1)
+ if (rte_sysfs_parse_uint(&val, "%s/%s/dev_port", path, name) != 0)
continue;
+ dev_port = val;
/* Ethernet ports start at 0, IB port start at 1 */
if (dev_port == port - 1) {
--
2.53.0
next prev parent reply other threads:[~2026-09-12 6:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 6:30 [PATCH 0/9] consolidate sysfs access Stephen Hemminger
2026-09-12 6:30 ` [PATCH 1/9] eal: add common sysfs value routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 2/9] dma/idxd: use common sysfs routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 3/9] common/ionic: " Stephen Hemminger
2026-09-12 6:30 ` [PATCH 4/9] bus/vmbus: " Stephen Hemminger
2026-09-12 6:30 ` [PATCH 5/9] power: " Stephen Hemminger
2026-09-12 6:30 ` [PATCH 6/9] drivers/bus: remove duplicate sysfs string helpers Stephen Hemminger
2026-09-12 6:30 ` [PATCH 7/9] common/mlx5: use common sysfs routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 8/9] net/mlx5: " Stephen Hemminger
2026-09-12 6:30 ` Stephen Hemminger [this message]
2026-09-12 17:02 ` [PATCH v2 0/9] consolidate sysfs access Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 1/9] eal: add common sysfs value routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 2/9] dma/idxd: use common sysfs routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 3/9] common/ionic: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 4/9] bus/vmbus: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 5/9] power: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 6/9] drivers/bus: remove duplicate sysfs string helpers Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 7/9] common/mlx5: use common sysfs routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 8/9] net/mlx5: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 9/9] net/mana: " 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=20260912063319.4117869-10-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=longli@microsoft.com \
--cc=weh@microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.