From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v1 06/13] ethdev: register ether layer as a class
Date: Thu, 30 Aug 2018 15:41:57 +0200 [thread overview]
Message-ID: <262be7b626fdae02441a2613b3d46419d5dc782d.1535633784.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1535633783.git.gaetan.rivet@6wind.com>
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_ethdev/Makefile | 3 +-
lib/librte_ethdev/meson.build | 1 +
lib/librte_ethdev/rte_class_eth.c | 79 +++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 lib/librte_ethdev/rte_class_eth.c
diff --git a/lib/librte_ethdev/Makefile b/lib/librte_ethdev/Makefile
index 3c1c92cb9..91899b083 100644
--- a/lib/librte_ethdev/Makefile
+++ b/lib/librte_ethdev/Makefile
@@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
LDLIBS += -lrte_net -lrte_eal -lrte_mempool -lrte_ring
-LDLIBS += -lrte_mbuf
+LDLIBS += -lrte_mbuf -lrte_kvargs
EXPORT_MAP := rte_ethdev_version.map
@@ -20,6 +20,7 @@ LIBABIVER := 10
SRCS-y += eth_private.c
SRCS-y += rte_ethdev.c
+SRCS-y += rte_class_eth.c
SRCS-y += rte_flow.c
SRCS-y += rte_tm.c
SRCS-y += rte_mtr.c
diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.build
index 372d3ca06..8d2e2bf4e 100644
--- a/lib/librte_ethdev/meson.build
+++ b/lib/librte_ethdev/meson.build
@@ -6,6 +6,7 @@ version = 10
allow_experimental_apis = true
sources = files('eth_private.c',
'ethdev_profile.c',
+ 'rte_class_eth.c',
'rte_ethdev.c',
'rte_flow.c',
'rte_mtr.c',
diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c
new file mode 100644
index 000000000..32c736d32
--- /dev/null
+++ b/lib/librte_ethdev/rte_class_eth.c
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Gaëtan Rivet
+ */
+
+#include <string.h>
+
+#include <rte_class.h>
+#include <rte_compat.h>
+#include <rte_errno.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+
+#include "rte_ethdev.h"
+#include "rte_ethdev_core.h"
+#include "eth_private.h"
+
+enum eth_params {
+ RTE_ETH_PARAMS_MAX,
+};
+
+static const char * const eth_params_keys[] = {
+ [RTE_ETH_PARAMS_MAX] = NULL,
+};
+
+struct eth_dev_match_arg {
+ struct rte_device *device;
+ struct rte_kvargs *kvlist;
+};
+
+#define eth_dev_match_arg(d, k) \
+ (&(const struct eth_dev_match_arg) { \
+ .device = (d), \
+ .kvlist = (k), \
+ })
+
+static int
+eth_dev_match(const struct rte_eth_dev *edev,
+ const void *_arg)
+{
+ const struct eth_dev_match_arg *arg = _arg;
+ const struct rte_kvargs *kvlist = arg->kvlist;
+
+ if (edev->state == RTE_ETH_DEV_UNUSED)
+ return -1;
+ if (edev->device != arg->device)
+ return -1;
+ if (kvlist == NULL)
+ /* Empty string matches everything. */
+ return 0;
+ return 0;
+}
+
+static void *
+eth_dev_iterate(const void *start,
+ const char *str,
+ const struct rte_dev_iterator *it)
+{
+ struct rte_kvargs *kvargs = NULL;
+ struct rte_eth_dev *edev = NULL;
+
+ if (str != NULL) {
+ kvargs = rte_kvargs_parse(str, eth_params_keys);
+ if (kvargs == NULL) {
+ RTE_LOG(ERR, EAL, "cannot parse argument list\n");
+ rte_errno = EINVAL;
+ return NULL;
+ }
+ }
+ edev = eth_find_device(start, eth_dev_match,
+ eth_dev_match_arg(it->device, kvargs));
+ rte_kvargs_free(kvargs);
+ return edev;
+}
+
+struct rte_class rte_class_eth = {
+ .dev_iterate = eth_dev_iterate,
+};
+
+RTE_REGISTER_CLASS(eth, rte_class_eth);
--
2.18.0
next prev parent reply other threads:[~2018-08-30 13:42 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 13:41 [dpdk-dev] [PATCH v1 00/13] Implement new devargs framework Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-08-31 10:09 ` Andrew Rybchenko
2018-08-31 10:22 ` Gaëtan Rivet
2018-08-30 13:41 ` Gaetan Rivet [this message]
2018-08-31 10:09 ` [dpdk-dev] [PATCH v1 06/13] ethdev: register ether layer as a class Andrew Rybchenko
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 07/13] ethdev: add device matching field name Gaetan Rivet
2018-08-31 10:10 ` Andrew Rybchenko
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 08/13] app/testpmd: add show device command Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-08-30 16:15 ` Stephen Hemminger
2018-08-30 16:37 ` Gaëtan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-08-31 10:10 ` Andrew Rybchenko
2018-08-31 12:16 ` Gaëtan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 13/13] eal: add generic dev parameter Gaetan Rivet
2018-08-30 15:42 ` [dpdk-dev] [PATCH v1 00/13] Implement new devargs framework Stephen Hemminger
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 " Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-09-20 16:11 ` Thomas Monjalon
2018-09-21 11:53 ` Gaëtan Rivet
2018-09-21 12:55 ` Thomas Monjalon
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-09-20 10:02 ` Andrew Rybchenko
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 06/13] ethdev: register ether layer as a class Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 07/13] ethdev: add device matching field name Gaetan Rivet
2018-09-20 16:17 ` Thomas Monjalon
2018-09-21 12:16 ` Gaëtan Rivet
2018-09-21 13:06 ` Thomas Monjalon
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: add show device command Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-09-20 10:11 ` Andrew Rybchenko
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 13/13] eal: add generic dev parameter Gaetan Rivet
2018-10-03 12:31 ` [dpdk-dev] [PATCH v2 00/13] Implement new devargs framework Thomas Monjalon
2020-02-19 5:43 ` Pavan Nikhilesh Bhagavatula
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=262be7b626fdae02441a2613b3d46419d5dc782d.1535633784.git.gaetan.rivet@6wind.com \
--to=gaetan.rivet@6wind.com \
--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;
as well as URLs for NNTP newsgroup(s).