From: spinler@cesnet.cz
To: dev@dpdk.org
Cc: Martin Spinler <spinler@cesnet.cz>
Subject: [PATCH v10 4/8] net/nfb: add device argument "port" to limit used ports
Date: Tue, 17 Feb 2026 08:10:36 +0100 [thread overview]
Message-ID: <20260217071040.2855133-5-spinler@cesnet.cz> (raw)
In-Reply-To: <20260217071040.2855133-1-spinler@cesnet.cz>
From: Martin Spinler <spinler@cesnet.cz>
NFB devices do not use separate PCI device for each port; one PCI device
contains handles for all ports instead. For some application this approach
can be limiting.
The "port" argument can be used to select only desired ports.
It can be used multiple times. When is not used at all, the driver
selects all ports.
Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
drivers/net/nfb/nfb.h | 7 ++++
drivers/net/nfb/nfb_ethdev.c | 71 ++++++++++++++++++++++++++++++++++--
drivers/net/nfb/nfb_vdev.c | 3 +-
3 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index a854d16426..22fcb68cd7 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -42,6 +42,13 @@ extern int nfb_logtype;
#define RTE_NFB_DRIVER_NAME net_nfb
+/* Device arguments */
+#define NFB_ARG_PORT "port"
+
+#define NFB_COMMON_ARGS \
+ NFB_ARG_PORT "=<number>" \
+ ""
+
/*
* Handles obtained from the libnfb: each process must use own instance.
* Stored inside dev->process_private.
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 233eb91e18..706b90bae5 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -4,6 +4,7 @@
* All rights reserved.
*/
+#include <ctype.h>
#include <sys/queue.h>
#include <eal_export.h>
#include <rte_tailq.h>
@@ -22,12 +23,19 @@
#include "nfb_rxmode.h"
#include "nfb.h"
+static const char * const VALID_KEYS[] = {
+ NFB_ARG_PORT,
+ NULL
+};
+
struct nfb_ifc_create_params {
struct nfb_probe_params *probe_params;
struct nc_ifc_map_info map_info;
struct nc_ifc_info *ifc_info;
int basename_len; /* Cached real length of original probe_params->name */
+ /* Return value of failed nfb_eth_dev_create_for_ifc when rte_kvargs_process is used */
+ int ret;
};
/* The TAILQ entries are used for cleanup of allocated resources
@@ -738,6 +746,33 @@ nfb_eth_dev_create_for_ifc(struct nfb_ifc_create_params *cp)
return ret;
}
+static int nfb_eth_dev_create_for_ifc_by_port(const char *key __rte_unused,
+ const char *value, void *opaque)
+{
+ int ret = -EINVAL;
+ char *end;
+ unsigned long port;
+ struct nfb_ifc_create_params *ifc_params = opaque;
+
+ if (value == NULL || strlen(value) == 0 || !isdigit(*value))
+ goto out;
+
+ errno = 0;
+ port = strtoul(value, &end, 10);
+ if (errno != 0 || *end != '\0')
+ goto out;
+
+ if (port >= LONG_MAX || port >= (unsigned long)ifc_params->map_info.ifc_cnt)
+ goto out;
+
+ ifc_params->ifc_info = &ifc_params->map_info.ifc[port];
+ ret = nfb_eth_dev_create_for_ifc(ifc_params);
+
+out:
+ ifc_params->ret = ret;
+ return ret;
+}
+
int
nfb_eth_common_probe(struct nfb_probe_params *params)
{
@@ -746,6 +781,7 @@ nfb_eth_common_probe(struct nfb_probe_params *params)
struct nfb_device *nfb_dev;
struct nfb_ifc_create_params ifc_params;
+ struct rte_kvargs *kvlist = NULL;
/* Open the device handle just for parsing ifc_params.
* A separate handle is used later for each netdev.
@@ -760,16 +796,38 @@ nfb_eth_common_probe(struct nfb_probe_params *params)
if (ret)
goto err_map_info_create;
+ if (params->args != NULL && strlen(params->args) > 0) {
+ kvlist = rte_kvargs_parse(params->args, VALID_KEYS);
+ if (kvlist == NULL) {
+ NFB_LOG(ERR, "Failed to parse device arguments %s", params->args);
+ ret = -EINVAL;
+ goto err_parse_args;
+ }
+ }
+
+ ifc_params.ret = 0;
ifc_params.probe_params = params;
ifc_params.basename_len = strlen(params->name);
- for (i = 0; i < ifc_params.map_info.ifc_cnt; i++) {
- ifc_params.ifc_info = &ifc_params.map_info.ifc[i];
- ret = nfb_eth_dev_create_for_ifc(&ifc_params);
- if (ret)
+ /* When at least one port argument is specified, create only selected ports */
+ if (kvlist && rte_kvargs_count(kvlist, NFB_ARG_PORT)) {
+ ret = rte_kvargs_process(kvlist, NFB_ARG_PORT,
+ nfb_eth_dev_create_for_ifc_by_port, (void *)&ifc_params);
+ if (ret) {
+ ret = ifc_params.ret;
goto err_dev_create;
+ }
+ } else {
+ for (i = 0; i < ifc_params.map_info.ifc_cnt; i++) {
+ ifc_params.ifc_info = &ifc_params.map_info.ifc[i];
+ ret = nfb_eth_dev_create_for_ifc(&ifc_params);
+ if (ret)
+ goto err_dev_create;
+ }
}
+ rte_kvargs_free(kvlist);
+
nc_map_info_destroy(&ifc_params.map_info);
nfb_close(nfb_dev);
@@ -777,6 +835,8 @@ nfb_eth_common_probe(struct nfb_probe_params *params)
err_dev_create:
nfb_eth_common_remove(params->device);
+ rte_kvargs_free(kvlist);
+err_parse_args:
nc_map_info_destroy(&ifc_params.map_info);
err_map_info_create:
nfb_close(nfb_dev);
@@ -882,3 +942,6 @@ RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_table);
RTE_PMD_REGISTER_KMOD_DEP(RTE_NFB_DRIVER_NAME, "* nfb");
RTE_LOG_REGISTER_DEFAULT(nfb_logtype, NOTICE);
+RTE_PMD_REGISTER_PARAM_STRING(RTE_NFB_DRIVER_NAME,
+ NFB_COMMON_ARGS
+ );
diff --git a/drivers/net/nfb/nfb_vdev.c b/drivers/net/nfb/nfb_vdev.c
index b79f7ac416..57f10d2068 100644
--- a/drivers/net/nfb/nfb_vdev.c
+++ b/drivers/net/nfb/nfb_vdev.c
@@ -102,5 +102,6 @@ static struct rte_vdev_driver vdev_nfb_vdev = {
RTE_PMD_REGISTER_VDEV(VDEV_NFB_DRIVER, vdev_nfb_vdev);
RTE_PMD_REGISTER_ALIAS(VDEV_NFB_DRIVER, eth_vdev_nfb);
RTE_PMD_REGISTER_PARAM_STRING(net_vdev_nfb,
- VDEV_NFB_ARG_DEV "=<string>"
+ VDEV_NFB_ARG_DEV "=<string> "
+ NFB_COMMON_ARGS
);
--
2.53.0
next prev parent reply other threads:[~2026-02-17 7:11 UTC|newest]
Thread overview: 131+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 15:16 [PATCH 0/8] net/nfb: rework to real multiport spinler
2026-01-15 15:16 ` [PATCH 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-16 17:34 ` Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-15 15:16 ` [PATCH 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-15 15:16 ` [PATCH 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-15 15:16 ` [PATCH 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-16 17:36 ` Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-16 17:36 ` Stephen Hemminger
2026-01-16 17:37 ` Stephen Hemminger
2026-01-15 15:16 ` [PATCH 5/8] net/nfb: init only MACs associated with device spinler
2026-01-15 15:16 ` [PATCH 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-15 15:16 ` [PATCH 7/8] net/nfb: report firmware version spinler
2026-01-15 15:16 ` [PATCH 8/8] doc/nfb: cleanup and update guide spinler
2026-01-16 5:50 ` [PATCH 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-16 16:44 ` [PATCH v2 " spinler
2026-01-16 16:44 ` [PATCH v2 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-16 16:44 ` [PATCH v2 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-16 16:44 ` [PATCH v2 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-16 16:44 ` [PATCH v2 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-16 16:44 ` [PATCH v2 5/8] net/nfb: init only MACs associated with device spinler
2026-01-16 16:44 ` [PATCH v2 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-16 16:44 ` [PATCH v2 7/8] net/nfb: report firmware version spinler
2026-01-16 16:44 ` [PATCH v2 8/8] doc/nfb: cleanup and update guide spinler
2026-01-20 2:25 ` [PATCH v2 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-21 17:03 ` [PATCH v3 " spinler
2026-01-21 17:03 ` [PATCH v3 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-21 17:03 ` [PATCH v3 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-21 17:03 ` [PATCH v3 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-21 17:40 ` Stephen Hemminger
2026-01-21 17:03 ` [PATCH v3 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-21 17:03 ` [PATCH v3 5/8] net/nfb: init only MACs associated with device spinler
2026-01-21 17:03 ` [PATCH v3 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-21 17:03 ` [PATCH v3 7/8] net/nfb: report firmware version spinler
2026-01-21 17:03 ` [PATCH v3 8/8] doc/nfb: cleanup and update guide spinler
2026-01-21 17:41 ` Stephen Hemminger
2026-01-21 17:42 ` [PATCH v3 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-22 7:27 ` [PATCH v4 " spinler
2026-01-22 7:27 ` [PATCH v4 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-22 7:27 ` [PATCH v4 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-22 7:27 ` [PATCH v4 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-22 7:27 ` [PATCH v4 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-22 7:27 ` [PATCH v4 5/8] net/nfb: init only MACs associated with device spinler
2026-01-22 7:27 ` [PATCH v4 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-22 7:27 ` [PATCH v4 7/8] net/nfb: report firmware version spinler
2026-01-22 7:27 ` [PATCH v4 8/8] doc/nfb: cleanup and update guide spinler
2026-01-23 1:00 ` [PATCH v4 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-23 1:01 ` Stephen Hemminger
2026-01-23 1:14 ` Stephen Hemminger
2026-01-23 17:34 ` Martin Spinler
2026-01-23 17:22 ` [PATCH v5 " spinler
2026-01-23 17:22 ` [PATCH v5 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-23 17:22 ` [PATCH v5 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-01-27 0:37 ` Stephen Hemminger
2026-01-27 8:12 ` Martin Spinler
2026-01-27 14:09 ` Stephen Hemminger
2026-01-23 17:22 ` [PATCH v5 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-23 17:22 ` [PATCH v5 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-23 17:22 ` [PATCH v5 5/8] net/nfb: init only MACs associated with device spinler
2026-01-23 17:22 ` [PATCH v5 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-23 17:22 ` [PATCH v5 7/8] net/nfb: report firmware version spinler
2026-01-23 17:22 ` [PATCH v5 8/8] doc/nfb: cleanup and update guide spinler
2026-01-24 19:10 ` [REVIEW] " Stephen Hemminger
2026-01-24 19:19 ` [PATCH v5 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-02 15:34 ` [PATCH v6 " spinler
2026-02-02 15:34 ` [PATCH v6 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-02 17:50 ` Stephen Hemminger
2026-02-02 15:34 ` [PATCH v6 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-02 15:34 ` [PATCH v6 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-02 15:34 ` [PATCH v6 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-02 15:34 ` [PATCH v6 5/8] net/nfb: init only MACs associated with device spinler
2026-02-02 15:34 ` [PATCH v6 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-02 15:34 ` [PATCH v6 7/8] net/nfb: report firmware version spinler
2026-02-02 15:34 ` [PATCH v6 8/8] doc/nfb: cleanup and update guide spinler
2026-02-02 17:42 ` [REVIEW] " Stephen Hemminger
2026-02-02 17:51 ` Stephen Hemminger
2026-02-02 17:52 ` Stephen Hemminger
2026-02-02 17:54 ` Stephen Hemminger
2026-02-02 17:54 ` Stephen Hemminger
2026-02-04 12:31 ` [PATCH v7 0/8] net/nfb: rework to real multiport spinler
2026-02-04 12:31 ` [PATCH v7 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-04 12:31 ` [PATCH v7 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-04 12:31 ` [PATCH v7 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-04 12:31 ` [PATCH v7 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-04 12:31 ` [PATCH v7 5/8] net/nfb: init only MACs associated with device spinler
2026-02-04 12:31 ` [PATCH v7 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-04 12:31 ` [PATCH v7 7/8] net/nfb: report firmware version spinler
2026-02-04 12:31 ` [PATCH v7 8/8] doc/nfb: cleanup and update guide spinler
2026-02-10 0:35 ` [PATCH v7 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-13 18:53 ` Martin Špinler
2026-02-12 18:35 ` Stephen Hemminger
2026-02-13 18:53 ` Martin Špinler
2026-02-13 18:53 ` [PATCH v8 " spinler
2026-02-13 18:53 ` [PATCH v8 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-13 18:53 ` [PATCH v8 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-13 19:33 ` Stephen Hemminger
2026-02-13 18:53 ` [PATCH v8 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-13 18:53 ` [PATCH v8 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-13 18:53 ` [PATCH v8 5/8] net/nfb: init only MACs associated with device spinler
2026-02-13 18:53 ` [PATCH v8 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-13 18:53 ` [PATCH v8 7/8] net/nfb: report firmware version spinler
2026-02-13 18:53 ` [PATCH v8 8/8] doc/nfb: cleanup and update guide spinler
2026-02-13 19:39 ` [PATCH v8 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-13 20:13 ` Martin Špinler
2026-02-16 16:24 ` [PATCH v9 " spinler
2026-02-16 16:24 ` [PATCH v9 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-16 16:25 ` [PATCH v9 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-16 16:25 ` [PATCH v9 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-16 16:25 ` [PATCH v9 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-16 16:25 ` [PATCH v9 5/8] net/nfb: init only MACs associated with device spinler
2026-02-16 16:25 ` [PATCH v9 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-16 16:25 ` [PATCH v9 7/8] net/nfb: report firmware version spinler
2026-02-16 16:25 ` [PATCH v9 8/8] doc/nfb: cleanup and update guide spinler
2026-02-16 22:11 ` [PATCH v9 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-17 7:09 ` Martin Spinler
2026-02-17 7:10 ` [PATCH v10 " spinler
2026-02-17 7:10 ` [PATCH v10 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-17 7:10 ` [PATCH v10 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-17 7:10 ` [PATCH v10 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-17 7:10 ` spinler [this message]
2026-02-17 7:10 ` [PATCH v10 5/8] net/nfb: init only MACs associated with device spinler
2026-02-17 7:10 ` [PATCH v10 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-17 7:10 ` [PATCH v10 7/8] net/nfb: report firmware version spinler
2026-02-17 7:10 ` [PATCH v10 8/8] doc/nfb: cleanup and update guide spinler
2026-03-13 16:48 ` Thomas Monjalon
2026-02-17 14:58 ` [PATCH v10 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-17 15:05 ` Martin Spinler
2026-02-17 15:22 ` Martin Spinler
2026-02-19 0:12 ` 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=20260217071040.2855133-5-spinler@cesnet.cz \
--to=spinler@cesnet.cz \
--cc=dev@dpdk.org \
/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