DPDK patches and discussions
 help / color / mirror / Atom feed
From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, Marko Kovacevic <marko.kovacevic@intel.com>,
	Ori Kam <orika@mellanox.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	"Radu Nicolau" <radu.nicolau@intel.com>,
	Akhil Goyal <akhil.goyal@nxp.com>,
	"Tomasz Kantecki" <tomasz.kantecki@intel.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Pavan Nikhilesh <pbhagavatula@marvell.com>
Cc: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v8 02/10] examples/l2fwd-event: add infra for eventdev
Date: Wed, 30 Oct 2019 21:56:43 +0530	[thread overview]
Message-ID: <20191030162651.3001-3-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20191030162651.3001-1-pbhagavatula@marvell.com>

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Add infra to select event device as a mode to process packets through
command line arguments. Also, allow the user to select the schedule type
to be RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC or
RTE_SCHED_TYPE_PARALLEL.

Usage:

`--mode="eventdev"` or `--mode="poll"`
`--eventq-sched="ordered"`, `--eventq-sched="atomic"` or
`--event-sched=parallel`

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 examples/l2fwd-event/Makefile       |  1 +
 examples/l2fwd-event/l2fwd_common.h |  4 +++
 examples/l2fwd-event/l2fwd_event.c  | 34 +++++++++++++++++++
 examples/l2fwd-event/l2fwd_event.h  | 21 ++++++++++++
 examples/l2fwd-event/main.c         | 52 +++++++++++++++++++++++++++--
 examples/l2fwd-event/meson.build    |  1 +
 6 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 examples/l2fwd-event/l2fwd_event.c
 create mode 100644 examples/l2fwd-event/l2fwd_event.h

diff --git a/examples/l2fwd-event/Makefile b/examples/l2fwd-event/Makefile
index 73f02dd3b..08ba1835d 100644
--- a/examples/l2fwd-event/Makefile
+++ b/examples/l2fwd-event/Makefile
@@ -8,6 +8,7 @@ APP = l2fwd-event
 # all source are stored in SRCS-y
 SRCS-y := main.c
 SRCS-y += l2fwd_poll.c
+SRCS-y += l2fwd_event.c
 SRCS-y += l2fwd_common.c
 
 # Build using pkg-config variables if possible
diff --git a/examples/l2fwd-event/l2fwd_common.h b/examples/l2fwd-event/l2fwd_common.h
index 7b74f92b3..a4e17ab97 100644
--- a/examples/l2fwd-event/l2fwd_common.h
+++ b/examples/l2fwd-event/l2fwd_common.h
@@ -65,6 +65,8 @@ struct l2fwd_port_statistics {
 
 struct l2fwd_resources {
 	volatile uint8_t force_quit;
+	uint8_t event_mode;
+	uint8_t sched_type;
 	uint8_t mac_updating;
 	uint8_t rx_queue_per_lcore;
 	uint16_t nb_rxd;
@@ -75,6 +77,7 @@ struct l2fwd_resources {
 	uint32_t dst_ports[RTE_MAX_ETHPORTS];
 	struct rte_ether_addr eth_addr[RTE_MAX_ETHPORTS];
 	struct l2fwd_port_statistics port_stats[RTE_MAX_ETHPORTS];
+	void *evt_rsrc;
 	void *poll_rsrc;
 } __rte_cache_aligned;
 
@@ -112,6 +115,7 @@ l2fwd_get_rsrc(void)
 		memset(rsrc, 0, sizeof(struct l2fwd_resources));
 		rsrc->mac_updating = true;
 		rsrc->rx_queue_per_lcore = 1;
+		rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC;
 		rsrc->timer_period = 10 * rte_get_timer_hz();
 
 		return mz->addr;
diff --git a/examples/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c
new file mode 100644
index 000000000..48d32d718
--- /dev/null
+++ b/examples/l2fwd-event/l2fwd_event.c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
+#include <stdbool.h>
+#include <getopt.h>
+
+#include <rte_atomic.h>
+#include <rte_cycles.h>
+#include <rte_ethdev.h>
+#include <rte_eventdev.h>
+#include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
+#include <rte_lcore.h>
+#include <rte_malloc.h>
+#include <rte_spinlock.h>
+
+#include "l2fwd_event.h"
+
+void
+l2fwd_event_resource_setup(struct l2fwd_resources *rsrc)
+{
+	struct l2fwd_event_resources *evt_rsrc;
+
+	if (!rte_event_dev_count())
+		rte_panic("No Eventdev found\n");
+
+	evt_rsrc = rte_zmalloc("l2fwd_event",
+				 sizeof(struct l2fwd_event_resources), 0);
+	if (evt_rsrc == NULL)
+		rte_panic("Failed to allocate memory\n");
+
+	rsrc->evt_rsrc = evt_rsrc;
+}
diff --git a/examples/l2fwd-event/l2fwd_event.h b/examples/l2fwd-event/l2fwd_event.h
new file mode 100644
index 000000000..9a1bb1612
--- /dev/null
+++ b/examples/l2fwd-event/l2fwd_event.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
+#ifndef __L2FWD_EVENT_H__
+#define __L2FWD_EVENT_H__
+
+#include <rte_common.h>
+#include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
+#include <rte_mbuf.h>
+#include <rte_spinlock.h>
+
+#include "l2fwd_common.h"
+
+struct l2fwd_event_resources {
+};
+
+void l2fwd_event_resource_setup(struct l2fwd_resources *rsrc);
+
+#endif /* __L2FWD_EVENT_H__ */
diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index a4e41ddb4..2a1fe4e11 100644
--- a/examples/l2fwd-event/main.c
+++ b/examples/l2fwd-event/main.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2019 Marvell International Ltd.
  */
 
+#include "l2fwd_event.h"
 #include "l2fwd_poll.h"
 
 /* display usage */
@@ -16,7 +17,12 @@ l2fwd_event_usage(const char *prgname)
 	       "  --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\n"
 	       "      When enabled:\n"
 	       "       - The source MAC address is replaced by the TX port MAC address\n"
-	       "       - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n",
+	       "       - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n"
+	       "  --mode: Packet transfer mode for I/O, poll or eventdev\n"
+	       "          Default mode = eventdev\n"
+	       "  --eventq-sched: Event queue schedule type, ordered, atomic or parallel.\n"
+	       "                  Default: atomic\n"
+	       "                  Valid only if --mode=eventdev\n\n",
 	       prgname);
 }
 
@@ -71,6 +77,28 @@ l2fwd_event_parse_timer_period(const char *q_arg)
 	return n;
 }
 
+static void
+l2fwd_event_parse_mode(const char *optarg,
+		       struct l2fwd_resources *rsrc)
+{
+	if (!strncmp(optarg, "poll", 4))
+		rsrc->event_mode = false;
+	else if (!strncmp(optarg, "eventdev", 8))
+		rsrc->event_mode = true;
+}
+
+static void
+l2fwd_event_parse_eventq_sched(const char *optarg,
+			       struct l2fwd_resources *rsrc)
+{
+	if (!strncmp(optarg, "ordered", 7))
+		rsrc->sched_type = RTE_SCHED_TYPE_ORDERED;
+	else if (!strncmp(optarg, "atomic", 6))
+		rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC;
+	else if (!strncmp(optarg, "parallel", 8))
+		rsrc->sched_type = RTE_SCHED_TYPE_PARALLEL;
+}
+
 static const char short_options[] =
 	"p:"  /* portmask */
 	"q:"  /* number of queues */
@@ -79,6 +107,8 @@ static const char short_options[] =
 
 #define CMD_LINE_OPT_MAC_UPDATING "mac-updating"
 #define CMD_LINE_OPT_NO_MAC_UPDATING "no-mac-updating"
+#define CMD_LINE_OPT_MODE "mode"
+#define CMD_LINE_OPT_EVENTQ_SCHED "eventq-sched"
 
 enum {
 	/* long options mapped to a short option */
@@ -87,6 +117,8 @@ enum {
 	 * conflict with short options
 	 */
 	CMD_LINE_OPT_MIN_NUM = 256,
+	CMD_LINE_OPT_MODE_NUM,
+	CMD_LINE_OPT_EVENTQ_SCHED_NUM,
 };
 
 /* Parse the argument given in the command line of the application */
@@ -98,6 +130,10 @@ l2fwd_event_parse_args(int argc, char **argv,
 	struct option lgopts[] = {
 		{ CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1},
 		{ CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0},
+		{ CMD_LINE_OPT_MODE, required_argument, NULL,
+							CMD_LINE_OPT_MODE_NUM},
+		{ CMD_LINE_OPT_EVENTQ_SCHED, required_argument, NULL,
+						CMD_LINE_OPT_EVENTQ_SCHED_NUM},
 		{NULL, 0, 0, 0}
 	};
 	int opt, ret, timer_secs;
@@ -145,6 +181,14 @@ l2fwd_event_parse_args(int argc, char **argv,
 			rsrc->timer_period *= rte_get_timer_hz();
 			break;
 
+		case CMD_LINE_OPT_MODE_NUM:
+			l2fwd_event_parse_mode(optarg, rsrc);
+			break;
+
+		case CMD_LINE_OPT_EVENTQ_SCHED_NUM:
+			l2fwd_event_parse_eventq_sched(optarg, rsrc);
+			break;
+
 		/* long options */
 		case 0:
 			break;
@@ -404,7 +448,11 @@ main(int argc, char **argv)
 	if (!nb_ports_available)
 		rte_panic("All available ports are disabled. Please set portmask.\n");
 
-	l2fwd_poll_resource_setup(rsrc);
+	/* Configure eventdev parameters if required */
+	if (rsrc->event_mode)
+		l2fwd_event_resource_setup(rsrc);
+	else
+		l2fwd_poll_resource_setup(rsrc);
 
 	/* initialize port stats */
 	memset(&rsrc->port_stats, 0,
diff --git a/examples/l2fwd-event/meson.build b/examples/l2fwd-event/meson.build
index c936aa72e..c1ae2037c 100644
--- a/examples/l2fwd-event/meson.build
+++ b/examples/l2fwd-event/meson.build
@@ -12,4 +12,5 @@ sources = files(
 	'main.c',
 	'l2fwd_poll.c',
 	'l2fwd_common.c',
+	'l2fwd_event.c',
 )
-- 
2.17.1


  parent reply	other threads:[~2019-10-30 16:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 16:26 [dpdk-dev] [PATCH v8 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-30 16:26 ` pbhagavatula [this message]
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-30 16:26 ` [dpdk-dev] [PATCH v8 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-30 17:03 ` [dpdk-dev] [PATCH v8 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-30 18:17 ` [dpdk-dev] [PATCH v8 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-11-04 17:11   ` Jerin Jacob

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=20191030162651.3001-3-pbhagavatula@marvell.com \
    --to=pbhagavatula@marvell.com \
    --cc=akhil.goyal@nxp.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=marko.kovacevic@intel.com \
    --cc=orika@mellanox.com \
    --cc=radu.nicolau@intel.com \
    --cc=skori@marvell.com \
    --cc=tomasz.kantecki@intel.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).