[2/2] app/test: add net null dev creation in Rx adapter autotest

Message ID 20201003090541.32449-2-jay.jayatheerthan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [1/2] app/test: uninit vdevs in event eth Rx adapter autotest |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS

Commit Message

Jayatheerthan, Jay Oct. 3, 2020, 9:05 a.m. UTC
  From: "Jay Jayatheerthan" <jay.jayatheerthan@intel.com>

Allows creation of net_null if vdev EAL option is not specified and
uninit vdev created in the test. The change also adds error checks
for vdev init and uninit.

Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 61 +++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 2 deletions(-)
  

Comments

Jayatheerthan, Jay Oct. 6, 2020, 5:47 p.m. UTC | #1
Hi,
Request to review the changes below.

Regards,
Jay

> -----Original Message-----
> From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Sent: Saturday, October 3, 2020 2:36 PM
> To: jerinj@marvell.com; thomas@monjalon.net; Rao, Nikhil <nikhil.rao@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Subject: [PATCH 2/2] app/test: add net null dev creation in Rx adapter autotest
> 
> From: "Jay Jayatheerthan" <jay.jayatheerthan@intel.com>
> 
> Allows creation of net_null if vdev EAL option is not specified and
> uninit vdev created in the test. The change also adds error checks
> for vdev init and uninit.
> 
> Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
> ---
>  app/test/test_event_eth_rx_adapter.c | 61 +++++++++++++++++++++++++++-
>  1 file changed, 59 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
> index 71c946164..dbf85be35 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -30,6 +30,8 @@ struct event_eth_rx_adapter_test_params {
>  };
> 
>  static struct event_eth_rx_adapter_test_params default_params;
> +static bool event_dev_created;
> +static bool eth_dev_created;
> 
>  static inline int
>  port_init_common(uint16_t port, const struct rte_eth_conf *port_conf,
> @@ -202,7 +204,10 @@ testsuite_setup(void)
>  	if (!count) {
>  		printf("Failed to find a valid event device,"
>  			" testing with event_skeleton device\n");
> -		rte_vdev_init("event_skeleton", NULL);
> +		err = rte_vdev_init("event_skeleton", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
> +			    err);
> +		event_dev_created = true;
>  	}
> 
>  	struct rte_event_dev_config config = {
> @@ -222,6 +227,15 @@ testsuite_setup(void)
>  	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
>  			err);
> 
> +	count = rte_eth_dev_count_total();
> +	if (!count) {
> +		printf("Testing with net_null device\n");
> +		err = rte_vdev_init("net_null", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
> +			    err);
> +		eth_dev_created = true;
> +	}
> +
>  	/*
>  	 * eth devices like octeontx use event device to receive packets
>  	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
> @@ -249,7 +263,10 @@ testsuite_setup_rx_intr(void)
>  	if (!count) {
>  		printf("Failed to find a valid event device,"
>  			" testing with event_skeleton device\n");
> -		rte_vdev_init("event_skeleton", NULL);
> +		err = rte_vdev_init("event_skeleton", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
> +			    err);
> +		event_dev_created = true;
>  	}
> 
>  	struct rte_event_dev_config config = {
> @@ -270,6 +287,15 @@ testsuite_setup_rx_intr(void)
>  	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
>  			err);
> 
> +	count = rte_eth_dev_count_total();
> +	if (!count) {
> +		printf("Testing with net_null device\n");
> +		err = rte_vdev_init("net_null", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
> +			    err);
> +		eth_dev_created = true;
> +	}
> +
>  	/*
>  	 * eth devices like octeontx use event device to receive packets
>  	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
> @@ -292,21 +318,52 @@ testsuite_setup_rx_intr(void)
>  static void
>  testsuite_teardown(void)
>  {
> +	int err;
>  	uint32_t i;
>  	RTE_ETH_FOREACH_DEV(i)
>  		rte_eth_dev_stop(i);
> 
> +	if (eth_dev_created) {
> +		err = rte_vdev_uninit("net_null");
> +		if (err)
> +			printf("Failed to delete net_null. err=%d", err);
> +		eth_dev_created = false;
> +	}
> +
>  	rte_mempool_free(default_params.mp);
> +	if (event_dev_created) {
> +		err = rte_vdev_uninit("event_skeleton");
> +		if (err)
> +			printf("Failed to delete event_skeleton. err=%d", err);
> +		event_dev_created = false;
> +	}
> +
> +	memset(&default_params, 0, sizeof(default_params));
>  }
> 
>  static void
>  testsuite_teardown_rx_intr(void)
>  {
> +	int err;
>  	if (!default_params.rx_intr_port_inited)
>  		return;
> 
>  	rte_eth_dev_stop(default_params.rx_intr_port);
> +	if (eth_dev_created) {
> +		err = rte_vdev_uninit("net_null");
> +		if (err)
> +			printf("Failed to delete net_null. err=%d", err);
> +		eth_dev_created = false;
> +	}
>  	rte_mempool_free(default_params.mp);
> +	if (event_dev_created) {
> +		err = rte_vdev_uninit("event_skeleton");
> +		if (err)
> +			printf("Failed to delete event_skeleton. err=%d", err);
> +		event_dev_created = false;
> +	}
> +
> +	memset(&default_params, 0, sizeof(default_params));
>  }
> 
>  static int
> --
> 2.17.1
  
Rao, Nikhil Oct. 7, 2020, 10:15 a.m. UTC | #2
> -----Original Message-----
> From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Sent: Saturday, October 3, 2020 2:36 PM
> To: jerinj@marvell.com; thomas@monjalon.net; Rao, Nikhil
> <nikhil.rao@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>
> Subject: [PATCH 2/2] app/test: add net null dev creation in Rx adapter
> autotest
> 
> From: "Jay Jayatheerthan" <jay.jayatheerthan@intel.com>
> 
> Allows creation of net_null if vdev EAL option is not specified and uninit vdev
> created in the test. The change also adds error checks for vdev init and uninit.
> 
> Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
> ---
>  app/test/test_event_eth_rx_adapter.c | 61 +++++++++++++++++++++++++++-
>  1 file changed, 59 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test_event_eth_rx_adapter.c
> b/app/test/test_event_eth_rx_adapter.c
> index 71c946164..dbf85be35 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -30,6 +30,8 @@ struct event_eth_rx_adapter_test_params {  };
> 
>  static struct event_eth_rx_adapter_test_params default_params;
> +static bool event_dev_created;
> +static bool eth_dev_created;
> 
>  static inline int
>  port_init_common(uint16_t port, const struct rte_eth_conf *port_conf, @@ -
> 202,7 +204,10 @@ testsuite_setup(void)
>  	if (!count) {
>  		printf("Failed to find a valid event device,"
>  			" testing with event_skeleton device\n");
> -		rte_vdev_init("event_skeleton", NULL);
> +		err = rte_vdev_init("event_skeleton", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create event_skeleton.
> err=%d",
> +			    err);
> +		event_dev_created = true;
>  	}
> 
>  	struct rte_event_dev_config config = { @@ -222,6 +227,15 @@
> testsuite_setup(void)
>  	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
>  			err);
> 
> +	count = rte_eth_dev_count_total();
> +	if (!count) {
> +		printf("Testing with net_null device\n");
> +		err = rte_vdev_init("net_null", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
> +			    err);
> +		eth_dev_created = true;
> +	}
> +
>  	/*
>  	 * eth devices like octeontx use event device to receive packets
>  	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
> @@ -249,7 +263,10 @@ testsuite_setup_rx_intr(void)
>  	if (!count) {
>  		printf("Failed to find a valid event device,"
>  			" testing with event_skeleton device\n");
> -		rte_vdev_init("event_skeleton", NULL);
> +		err = rte_vdev_init("event_skeleton", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create event_skeleton.
> err=%d",
> +			    err);
> +		event_dev_created = true;
>  	}
> 
>  	struct rte_event_dev_config config = { @@ -270,6 +287,15 @@
> testsuite_setup_rx_intr(void)
>  	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
>  			err);
> 
> +	count = rte_eth_dev_count_total();
> +	if (!count) {
> +		printf("Testing with net_null device\n");
> +		err = rte_vdev_init("net_null", NULL);
> +		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
> +			    err);
> +		eth_dev_created = true;
> +	}
> +
>  	/*
>  	 * eth devices like octeontx use event device to receive packets
>  	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
> @@ -292,21 +318,52 @@ testsuite_setup_rx_intr(void)  static void
>  testsuite_teardown(void)
>  {
> +	int err;
>  	uint32_t i;
>  	RTE_ETH_FOREACH_DEV(i)
>  		rte_eth_dev_stop(i);
> 
> +	if (eth_dev_created) {
> +		err = rte_vdev_uninit("net_null");
> +		if (err)
> +			printf("Failed to delete net_null. err=%d", err);
> +		eth_dev_created = false;
> +	}
> +
>  	rte_mempool_free(default_params.mp);
> +	if (event_dev_created) {
> +		err = rte_vdev_uninit("event_skeleton");
> +		if (err)
> +			printf("Failed to delete event_skeleton. err=%d", err);
> +		event_dev_created = false;
> +	}
> +
> +	memset(&default_params, 0, sizeof(default_params));
>  }
> 
>  static void
>  testsuite_teardown_rx_intr(void)
>  {
> +	int err;
>  	if (!default_params.rx_intr_port_inited)
>  		return;
> 
>  	rte_eth_dev_stop(default_params.rx_intr_port);
> +	if (eth_dev_created) {
> +		err = rte_vdev_uninit("net_null");
> +		if (err)
> +			printf("Failed to delete net_null. err=%d", err);
> +		eth_dev_created = false;
> +	}
>  	rte_mempool_free(default_params.mp);
> +	if (event_dev_created) {
> +		err = rte_vdev_uninit("event_skeleton");
> +		if (err)
> +			printf("Failed to delete event_skeleton. err=%d", err);
> +		event_dev_created = false;
> +	}
> +
> +	memset(&default_params, 0, sizeof(default_params));
>  }
> 
>  static int
> --
> 2.17.1
Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
  

Patch

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 71c946164..dbf85be35 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -30,6 +30,8 @@  struct event_eth_rx_adapter_test_params {
 };
 
 static struct event_eth_rx_adapter_test_params default_params;
+static bool event_dev_created;
+static bool eth_dev_created;
 
 static inline int
 port_init_common(uint16_t port, const struct rte_eth_conf *port_conf,
@@ -202,7 +204,10 @@  testsuite_setup(void)
 	if (!count) {
 		printf("Failed to find a valid event device,"
 			" testing with event_skeleton device\n");
-		rte_vdev_init("event_skeleton", NULL);
+		err = rte_vdev_init("event_skeleton", NULL);
+		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
+			    err);
+		event_dev_created = true;
 	}
 
 	struct rte_event_dev_config config = {
@@ -222,6 +227,15 @@  testsuite_setup(void)
 	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
 			err);
 
+	count = rte_eth_dev_count_total();
+	if (!count) {
+		printf("Testing with net_null device\n");
+		err = rte_vdev_init("net_null", NULL);
+		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
+			    err);
+		eth_dev_created = true;
+	}
+
 	/*
 	 * eth devices like octeontx use event device to receive packets
 	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
@@ -249,7 +263,10 @@  testsuite_setup_rx_intr(void)
 	if (!count) {
 		printf("Failed to find a valid event device,"
 			" testing with event_skeleton device\n");
-		rte_vdev_init("event_skeleton", NULL);
+		err = rte_vdev_init("event_skeleton", NULL);
+		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
+			    err);
+		event_dev_created = true;
 	}
 
 	struct rte_event_dev_config config = {
@@ -270,6 +287,15 @@  testsuite_setup_rx_intr(void)
 	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
 			err);
 
+	count = rte_eth_dev_count_total();
+	if (!count) {
+		printf("Testing with net_null device\n");
+		err = rte_vdev_init("net_null", NULL);
+		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
+			    err);
+		eth_dev_created = true;
+	}
+
 	/*
 	 * eth devices like octeontx use event device to receive packets
 	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
@@ -292,21 +318,52 @@  testsuite_setup_rx_intr(void)
 static void
 testsuite_teardown(void)
 {
+	int err;
 	uint32_t i;
 	RTE_ETH_FOREACH_DEV(i)
 		rte_eth_dev_stop(i);
 
+	if (eth_dev_created) {
+		err = rte_vdev_uninit("net_null");
+		if (err)
+			printf("Failed to delete net_null. err=%d", err);
+		eth_dev_created = false;
+	}
+
 	rte_mempool_free(default_params.mp);
+	if (event_dev_created) {
+		err = rte_vdev_uninit("event_skeleton");
+		if (err)
+			printf("Failed to delete event_skeleton. err=%d", err);
+		event_dev_created = false;
+	}
+
+	memset(&default_params, 0, sizeof(default_params));
 }
 
 static void
 testsuite_teardown_rx_intr(void)
 {
+	int err;
 	if (!default_params.rx_intr_port_inited)
 		return;
 
 	rte_eth_dev_stop(default_params.rx_intr_port);
+	if (eth_dev_created) {
+		err = rte_vdev_uninit("net_null");
+		if (err)
+			printf("Failed to delete net_null. err=%d", err);
+		eth_dev_created = false;
+	}
 	rte_mempool_free(default_params.mp);
+	if (event_dev_created) {
+		err = rte_vdev_uninit("event_skeleton");
+		if (err)
+			printf("Failed to delete event_skeleton. err=%d", err);
+		event_dev_created = false;
+	}
+
+	memset(&default_params, 0, sizeof(default_params));
 }
 
 static int