[dpdk-dev,v3,06/11] event/octeontx: add selftest to device arguments

Message ID 20171225191738.17151-6-pbhagavatula@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pavan Nikhilesh Dec. 25, 2017, 7:17 p.m. UTC
  Add selftest as a device argument that can be enabled by suppling
'self_test=1' as a vdev parameter

	--vdev="event_octeontx,self_test=1"

The selftest is run after vdev creation is successfully
complete.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 drivers/event/octeontx/Makefile      |  2 +-
 drivers/event/octeontx/ssovf_evdev.c | 43 ++++++++++++++++++++++++++++++++++++
 drivers/event/octeontx/ssovf_evdev.h |  2 ++
 3 files changed, 46 insertions(+), 1 deletion(-)
  

Comments

Jerin Jacob Jan. 8, 2018, 10:14 a.m. UTC | #1
-----Original Message-----
> Date: Tue, 26 Dec 2017 00:47:33 +0530
> From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> To: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com,
>  gage.eads@intel.com, liang.j.ma@intel.com
> Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v3 06/11] event/octeontx: add selftest to device
>  arguments
> X-Mailer: git-send-email 2.14.1
> 
> Add selftest as a device argument that can be enabled by suppling
> 'self_test=1' as a vdev parameter
> 
> 	--vdev="event_octeontx,self_test=1"
> 
> The selftest is run after vdev creation is successfully
> complete.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>  /* Initialize and register event driver with DPDK Application */
>  static const struct rte_eventdev_ops ssovf_ops = {
>  	.dev_infos_get    = ssovf_info_get,
> @@ -630,7 +640,14 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
>  	struct rte_eventdev *eventdev;
>  	static int ssovf_init_once;
>  	const char *name;
> +	const char *params;
>  	int ret;
> +	int selftest = 0;
> +
> +	static const char *const args[] = {
> +		SSOVF_SELFTEST_ARG,
> +		NULL
> +	};
>  
>  	name = rte_vdev_device_name(vdev);
>  	/* More than one instance is not supported */
> @@ -639,6 +656,30 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
>  		return -EINVAL;
>  	}
>  
> +	params = rte_vdev_device_args(vdev);
> +	if (params != NULL && params[0] != '\0') {
> +		struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
> +
> +		if (!kvlist) {
> +			ssovf_log_info(
> +				"Ignoring unsupported paramss supplied '%s'",

s/paramss/params

> +				name);
> +		} else {
> +			int ret = rte_kvargs_process(kvlist,
> +					SSOVF_SELFTEST_ARG,
> +					ssovf_selftest, &selftest);
> +			if (ret != 0) {
> +				ssovf_log_err(
> +					"%s: Error in selftest",
> +					name);

I think, above three lines can be squashed to one line.

With above changes:
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
  

Patch

diff --git a/drivers/event/octeontx/Makefile b/drivers/event/octeontx/Makefile
index 1ad638574..bf45133f7 100644
--- a/drivers/event/octeontx/Makefile
+++ b/drivers/event/octeontx/Makefile
@@ -42,7 +42,7 @@  CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx/
 CFLAGS += -I$(RTE_SDK)/drivers/net/octeontx/
 
 LDLIBS += -lrte_eal -lrte_eventdev -lrte_mempool_octeontx
-LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_mbuf
+LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_mbuf -lrte_kvargs
 LDLIBS += -lrte_bus_vdev
 
 EXPORT_MAP := rte_pmd_octeontx_ssovf_version.map
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 0a96fbd7f..8c78b323a 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -38,6 +38,7 @@ 
 #include <rte_eal.h>
 #include <rte_ethdev.h>
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_kvargs.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
@@ -593,6 +594,15 @@  ssovf_close(struct rte_eventdev *dev)
 	return 0;
 }
 
+static int
+ssovf_selftest(const char *key __rte_unused, const char *value,
+		void *opaque)
+{
+	int *flag = opaque;
+	*flag = !!atoi(value);
+	return 0;
+}
+
 /* Initialize and register event driver with DPDK Application */
 static const struct rte_eventdev_ops ssovf_ops = {
 	.dev_infos_get    = ssovf_info_get,
@@ -630,7 +640,14 @@  ssovf_vdev_probe(struct rte_vdev_device *vdev)
 	struct rte_eventdev *eventdev;
 	static int ssovf_init_once;
 	const char *name;
+	const char *params;
 	int ret;
+	int selftest = 0;
+
+	static const char *const args[] = {
+		SSOVF_SELFTEST_ARG,
+		NULL
+	};
 
 	name = rte_vdev_device_name(vdev);
 	/* More than one instance is not supported */
@@ -639,6 +656,30 @@  ssovf_vdev_probe(struct rte_vdev_device *vdev)
 		return -EINVAL;
 	}
 
+	params = rte_vdev_device_args(vdev);
+	if (params != NULL && params[0] != '\0') {
+		struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
+
+		if (!kvlist) {
+			ssovf_log_info(
+				"Ignoring unsupported paramss supplied '%s'",
+				name);
+		} else {
+			int ret = rte_kvargs_process(kvlist,
+					SSOVF_SELFTEST_ARG,
+					ssovf_selftest, &selftest);
+			if (ret != 0) {
+				ssovf_log_err(
+					"%s: Error in selftest",
+					name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+		}
+
+		rte_kvargs_free(kvlist);
+	}
+
 	eventdev = rte_event_pmd_vdev_init(name, sizeof(struct ssovf_evdev),
 				rte_socket_id());
 	if (eventdev == NULL) {
@@ -689,6 +730,8 @@  ssovf_vdev_probe(struct rte_vdev_device *vdev)
 			edev->max_event_ports);
 
 	ssovf_init_once = 1;
+	if (selftest)
+		test_eventdev_octeontx();
 	return 0;
 
 error:
diff --git a/drivers/event/octeontx/ssovf_evdev.h b/drivers/event/octeontx/ssovf_evdev.h
index 72a980447..018fbdfa5 100644
--- a/drivers/event/octeontx/ssovf_evdev.h
+++ b/drivers/event/octeontx/ssovf_evdev.h
@@ -117,6 +117,8 @@ 
 #define SSO_GRP_GET_PRIORITY              0x7
 #define SSO_GRP_SET_PRIORITY              0x8
 
+#define SSOVF_SELFTEST_ARG               ("selftest")
+
 /*
  * In Cavium OcteonTX SoC, all accesses to the device registers are
  * implictly strongly ordered. So, The relaxed version of IO operation is