diff mbox

[API-NEXT,PATCHv5,7/7] linux-generic: default state for pktio is STOP

Message ID 1440604147-24703-8-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit d25e010f59ba78796a586a5a549fe8864618e0b7
Headers show

Commit Message

Maxim Uvarov Aug. 26, 2015, 3:49 p.m. UTC
After open pktio remains stopped. Inside worker thread (after all
configuration done it should be started.) In that patch I just start
it everywhere to keep original logic and be easy for review. Putting
it inside worker threads will require thread arguments change and
understanding logic of current app. It's better to do further changes
in separate patches per app.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 example/classifier/odp_classifier.c                       | 5 +++++
 example/generator/odp_generator.c                         | 4 ++++
 example/ipsec/odp_ipsec.c                                 | 6 ++++++
 example/packet/odp_pktio.c                                | 4 ++++
 platform/linux-generic/pktio/loop.c                       | 2 +-
 platform/linux-generic/pktio/socket.c                     | 2 +-
 platform/linux-generic/pktio/socket_mmap.c                | 2 +-
 test/performance/odp_l2fwd.c                              | 6 ++++++
 test/performance/odp_pktio_perf.c                         | 6 ++++++
 test/validation/classification/odp_classification_tests.c | 7 +++++++
 test/validation/pktio/pktio.c                             | 3 +++
 11 files changed, 44 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index ac204af..685f335 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -463,6 +463,11 @@  int main(int argc, char *argv[])
 	/* configure default Cos and default queue */
 	configure_default_queue(pktio, args);
 
+	if (odp_pktio_start(pktio)) {
+		EXAMPLE_ERR("Error: unable to start pktio.\n");
+		exit(EXIT_FAILURE);
+	}
+
 	/* Create and init worker threads */
 	memset(thread_tbl, 0, sizeof(thread_tbl));
 
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index c1974dc..4710411 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -357,6 +357,10 @@  static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool)
 	if (ret != 0)
 		EXAMPLE_ABORT("Error: default input-Q setup for %s\n", dev);
 
+	ret = odp_pktio_start(pktio);
+	if (ret)
+		EXAMPLE_ABORT("Error: unable to start %s\n", dev);
+
 	printf("  created pktio:%02" PRIu64
 	       ", dev:%s, queue mode (ATOMIC queues)\n"
 	       "          default pktio%02" PRIu64
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 85dbc00..96effe2 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -556,6 +556,12 @@  void initialize_intf(char *intf)
 		exit(EXIT_FAILURE);
 	}
 
+	ret = odp_pktio_start(pktio);
+	if (ret) {
+		EXAMPLE_ERR("Error: unable to start %s\n", intf);
+		exit(EXIT_FAILURE);
+	}
+
 	/* Read the source MAC address for this interface */
 	ret = odp_pktio_mac_addr(pktio, src_mac, sizeof(src_mac));
 	if (ret <= 0) {
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 835fb96..df53ea2 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -171,6 +171,10 @@  static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode)
 	if (ret != 0)
 		EXAMPLE_ABORT("Error: default input-Q setup for %s\n", dev);
 
+	ret = odp_pktio_start(pktio);
+	if (ret != 0)
+		EXAMPLE_ABORT("Error: unable to start %s\n", dev);
+
 	printf("  created pktio:%02" PRIu64
 	       ", dev:%s, queue mode (ATOMIC queues)\n"
 	       "  \tdefault pktio%02" PRIu64 "-INPUT queue:%" PRIu64 "\n",
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index f61ccd5..ef77e34 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -41,7 +41,7 @@  static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry,
 	if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID)
 		return -1;
 
-	pktio_entry->s.state = STATE_START;
+	pktio_entry->s.state = STATE_STOP;
 	return 0;
 }
 
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 43c5f67..6fcdb46 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -234,7 +234,7 @@  static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev,
 		goto error;
 	}
 
-	pktio_entry->s.state = STATE_START;
+	pktio_entry->s.state = STATE_STOP;
 	return 0;
 
 error:
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index 2e55672..3fd2b0f 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -486,7 +486,7 @@  static int sock_mmap_open(odp_pktio_t id ODP_UNUSED,
 			goto error;
 	}
 
-	pktio_entry->s.state = STATE_START;
+	pktio_entry->s.state = STATE_STOP;
 	return 0;
 
 error:
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index db26a58..ce4efa8 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -317,6 +317,12 @@  static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
 		return ODP_PKTIO_INVALID;
 	}
 
+	ret = odp_pktio_start(pktio);
+	if (ret != 0) {
+		LOG_ERR("Error: unable to start %s\n", dev);
+		return ODP_PKTIO_INVALID;
+	}
+
 	return pktio;
 }
 
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 1552579..709becf 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -777,6 +777,12 @@  static int test_init(void)
 	if (odp_pktio_inq_setdef(gbl_args->pktio_rx, inq_def) != 0)
 		return -1;
 
+	if (odp_pktio_start(gbl_args->pktio_tx) != 0)
+		return -1;
+	if (gbl_args->args.num_ifaces > 1 &&
+	    odp_pktio_start(gbl_args->pktio_rx))
+		return -1;
+
 	return 0;
 }
 
diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index c44ceb9..127683a 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -325,6 +325,13 @@  int classification_suite_init(void)
 		queue_list[i] = ODP_QUEUE_INVALID;
 
 	odp_atomic_init_u32(&seq, 0);
+
+	ret = odp_pktio_start(pktio_loop);
+	if (ret) {
+		fprintf(stderr, "unable to start loop\n");
+		return -1;
+	}
+
 	return 0;
 }
 
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 874e28e..d7ddd16 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -470,6 +470,9 @@  static void test_txrx(odp_queue_type_t q_type, int num_pkts)
 			io->inq = odp_pktio_inq_getdef(io->id);
 		else
 			io->inq = ODP_QUEUE_INVALID;
+
+		ret = odp_pktio_start(io->id);
+		CU_ASSERT(ret == 0);
 	}
 
 	/* if we have two interfaces then send through one and receive on