DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Vijay Kumar Srivastava <vsrivast@xilinx.com>
Subject: [dpdk-dev] [PATCH v4 6/8] common/sfc_efx: add support to get the device class
Date: Tue, 16 Mar 2021 11:58:30 +0300	[thread overview]
Message-ID: <20210316085832.942481-7-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210316085832.942481-1-andrew.rybchenko@oktetlabs.ru>

From: Vijay Kumar Srivastava <vsrivast@xilinx.com>

Device class argument would be used to select compatible driver.
Driver probe would be skipped for incompatible device class.

Signed-off-by: Vijay Kumar Srivastava <vsrivast@xilinx.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/sfc_efx.c   | 49 ++++++++++++++++++++++++++++++
 drivers/common/sfc_efx/sfc_efx.h   | 34 +++++++++++++++++++++
 drivers/common/sfc_efx/version.map |  2 ++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/common/sfc_efx/sfc_efx.h

diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index d7a84c9835..a3146db255 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -7,12 +7,61 @@
  * for Solarflare) and Solarflare Communications, Inc.
  */
 
+#include <string.h>
 #include <rte_log.h>
+#include <rte_kvargs.h>
+#include <rte_devargs.h>
 
 #include "sfc_efx_log.h"
+#include "sfc_efx.h"
 
 uint32_t sfc_efx_logtype;
 
+static int
+sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key,
+				const char *class_str, void *opaque)
+{
+	enum sfc_efx_dev_class *dev_class = opaque;
+
+	if (class_str == NULL)
+		return *dev_class;
+
+	if (strcmp(class_str, "vdpa") == 0) {
+		*dev_class = SFC_EFX_DEV_CLASS_VDPA;
+	} else if (strcmp(class_str, "net") == 0) {
+		*dev_class = SFC_EFX_DEV_CLASS_NET;
+	} else {
+		SFC_EFX_LOG(ERR, "Unsupported class %s.", class_str);
+		*dev_class = SFC_EFX_DEV_CLASS_INVALID;
+	}
+
+	return 0;
+}
+
+enum sfc_efx_dev_class
+sfc_efx_dev_class_get(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvargs;
+	const char *key = SFC_EFX_KVARG_DEV_CLASS;
+	enum sfc_efx_dev_class dev_class = SFC_EFX_DEV_CLASS_NET;
+
+	if (devargs == NULL)
+		return dev_class;
+
+	kvargs = rte_kvargs_parse(devargs->args, NULL);
+	if (kvargs == NULL)
+		return dev_class;
+
+	if (rte_kvargs_count(kvargs, key) != 0) {
+		rte_kvargs_process(kvargs, key, sfc_efx_kvarg_dev_class_handler,
+				   &dev_class);
+	}
+
+	rte_kvargs_free(kvargs);
+
+	return dev_class;
+}
+
 RTE_INIT(sfc_efx_register_logtype)
 {
 	int ret;
diff --git a/drivers/common/sfc_efx/sfc_efx.h b/drivers/common/sfc_efx/sfc_efx.h
new file mode 100644
index 0000000000..f2aff0b4e8
--- /dev/null
+++ b/drivers/common/sfc_efx/sfc_efx.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2021 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_EFX_H_
+#define _SFC_EFX_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SFC_EFX_KVARG_DEV_CLASS	"class"
+
+enum sfc_efx_dev_class {
+	SFC_EFX_DEV_CLASS_INVALID = 0,
+	SFC_EFX_DEV_CLASS_NET,
+	SFC_EFX_DEV_CLASS_VDPA,
+
+	SFC_EFX_DEV_NCLASS
+};
+
+__rte_internal
+enum sfc_efx_dev_class sfc_efx_dev_class_get(struct rte_devargs *devargs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SFC_EFX_H_ */
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index 403feeaf11..a3345d34f7 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -221,6 +221,8 @@ INTERNAL {
 	efx_txq_nbufs;
 	efx_txq_size;
 
+	sfc_efx_dev_class_get;
+
 	sfc_efx_mcdi_init;
 	sfc_efx_mcdi_fini;
 
-- 
2.30.1


  parent reply	other threads:[~2021-03-16  8:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 11:03 [dpdk-dev] [PATCH 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-14  0:36   ` Ferruh Yigit
2021-03-15 14:01     ` Andrew Rybchenko
2021-03-15 13:58 ` [dpdk-dev] [PATCH v2 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-15 15:54   ` [dpdk-dev] [PATCH v2 0/8] common/sfc_efx: prepare to introduce vDPA driver Ferruh Yigit
2021-03-16  7:25     ` Andrew Rybchenko
2021-03-16  6:15 ` [dpdk-dev] [PATCH v3 " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-16  8:55   ` [dpdk-dev] [PATCH v3 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-16  8:58 ` [dpdk-dev] [PATCH v4 " Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-16 11:30     ` Ferruh Yigit
2021-03-16 11:47       ` Andrew Rybchenko
2021-03-16 11:58         ` Ferruh Yigit
2021-03-16 12:14           ` Andrew Rybchenko
2021-03-16 12:41             ` Ferruh Yigit
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-16  8:58   ` Andrew Rybchenko [this message]
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 7/8] net/sfc: skip driver probe for incompatible device class Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-16 11:26   ` [dpdk-dev] [PATCH v4 0/8] common/sfc_efx: prepare to introduce vDPA driver Ferruh Yigit
2021-03-16 11:30     ` Andrew Rybchenko
2021-03-16 11:32       ` Ferruh Yigit
2021-03-16 11:34         ` Ferruh Yigit
2021-03-16 11:46   ` Ferruh Yigit

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=20210316085832.942481-7-andrew.rybchenko@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=vsrivast@xilinx.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;
as well as URLs for NNTP newsgroup(s).