All of lore.kernel.org
 help / color / mirror / Atom feed
From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, <konstantin.ananyev@intel.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>, Nipun Gupta <nipun.gupta@nxp.com>
Subject: [dpdk-dev] [PATCH v3 04/11] examples/l3fwd: add ethdev setup based on eventdev
Date: Sat, 11 Jan 2020 19:17:23 +0530	[thread overview]
Message-ID: <20200111134730.5329-5-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20200111134730.5329-1-pbhagavatula@marvell.com>

From: Sunil Kumar Kori <skori@marvell.com>

Add ethernet port Rx/Tx queue setup for event device which are later
used for setting up event eth Rx/Tx adapters.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 examples/l3fwd/l3fwd.h       |  10 +++
 examples/l3fwd/l3fwd_event.c | 138 ++++++++++++++++++++++++++++++++++-
 examples/l3fwd/l3fwd_event.h |   2 +-
 examples/l3fwd/main.c        |  15 ++--
 4 files changed, 153 insertions(+), 12 deletions(-)

diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
index e2399d76b..ed5ba5f3b 100644
--- a/examples/l3fwd/l3fwd.h
+++ b/examples/l3fwd/l3fwd.h
@@ -16,9 +16,16 @@
 #define NO_HASH_MULTI_LOOKUP 1
 #endif
 
+/*
+ * Configurable number of RX/TX ring descriptors
+ */
+#define RTE_TEST_RX_DESC_DEFAULT 1024
+#define RTE_TEST_TX_DESC_DEFAULT 1024
+
 #define MAX_PKT_BURST     32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
 
+#define MEMPOOL_CACHE_SIZE 256
 #define MAX_RX_QUEUE_PER_LCORE 16
 
 /*
@@ -170,6 +177,9 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)
 }
 #endif /* DO_RFC_1812_CHECKS */
 
+int
+init_mem(uint16_t portid, unsigned int nb_mbuf);
+
 /* Function pointers for LPM or EM functionality. */
 void
 setup_lpm(const int socketid);
diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c
index 9cb46c711..f9491ecc6 100644
--- a/examples/l3fwd/l3fwd_event.c
+++ b/examples/l3fwd/l3fwd_event.c
@@ -10,6 +10,14 @@
 #include "l3fwd.h"
 #include "l3fwd_event.h"
 
+static void
+print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr)
+{
+	char buf[RTE_ETHER_ADDR_FMT_SIZE];
+	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", name, buf);
+}
+
 struct l3fwd_event_resources *
 l3fwd_get_eventdev_rsrc(void)
 {
@@ -30,6 +38,131 @@ l3fwd_get_eventdev_rsrc(void)
 	return NULL;
 }
 
+static void
+l3fwd_eth_dev_port_setup(struct rte_eth_conf *port_conf)
+{
+	struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc();
+	uint16_t nb_ports = rte_eth_dev_count_avail();
+	uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
+	uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
+	unsigned int nb_lcores = rte_lcore_count();
+	struct rte_eth_conf local_port_conf;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_txconf txconf;
+	struct rte_eth_rxconf rxconf;
+	unsigned int nb_mbuf;
+	uint16_t port_id;
+	uint8_t eth_qid;
+	int32_t ret;
+
+	/* initialize all ports */
+	RTE_ETH_FOREACH_DEV(port_id) {
+		local_port_conf = *port_conf;
+		/* skip ports that are not enabled */
+		if ((evt_rsrc->port_mask & (1 << port_id)) == 0) {
+			printf("\nSkipping disabled port %d\n", port_id);
+			continue;
+		}
+
+		/* init port */
+		printf("Initializing port %d ... ", port_id);
+		fflush(stdout);
+		printf("Creating queues: nb_rxq=%d nb_txq=1...\n",
+		       evt_rsrc->eth_rx_queues);
+
+		rte_eth_dev_info_get(port_id, &dev_info);
+		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+			local_port_conf.txmode.offloads |=
+						DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+						dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf->rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function "
+			       "based on hardware support,"
+			       "requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			       port_id,
+			       port_conf->rx_adv_conf.rss_conf.rss_hf,
+			       local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
+		ret = rte_eth_dev_configure(port_id, evt_rsrc->eth_rx_queues,
+					    1, &local_port_conf);
+		if (ret < 0)
+			rte_exit(EXIT_FAILURE,
+				 "Cannot configure device: err=%d, port=%d\n",
+				 ret, port_id);
+
+		ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd,
+						       &nb_txd);
+		if (ret < 0)
+			rte_exit(EXIT_FAILURE,
+				 "Cannot adjust number of descriptors: err=%d, "
+				 "port=%d\n", ret, port_id);
+
+		rte_eth_macaddr_get(port_id, &ports_eth_addr[port_id]);
+		print_ethaddr(" Address:", &ports_eth_addr[port_id]);
+		printf(", ");
+		print_ethaddr("Destination:",
+			(const struct rte_ether_addr *)&dest_eth_addr[port_id]);
+		printf(", ");
+
+		/* prepare source MAC for each port. */
+		rte_ether_addr_copy(&ports_eth_addr[port_id],
+			(struct rte_ether_addr *)(val_eth + port_id) + 1);
+
+		/* init memory */
+		if (!evt_rsrc->per_port_pool) {
+			/* port_id = 0; this is *not* signifying the first port,
+			 * rather, it signifies that port_id is ignored.
+			 */
+			nb_mbuf = RTE_MAX(nb_ports * nb_rxd +
+					  nb_ports * nb_txd +
+					  nb_ports * nb_lcores *
+							MAX_PKT_BURST +
+					  nb_lcores * MEMPOOL_CACHE_SIZE,
+					  8192u);
+			ret = init_mem(0, nb_mbuf);
+		} else {
+			nb_mbuf = RTE_MAX(nb_rxd + nb_rxd +
+					  nb_lcores * MAX_PKT_BURST +
+					  nb_lcores * MEMPOOL_CACHE_SIZE,
+					  8192u);
+			ret = init_mem(port_id, nb_mbuf);
+		}
+		/* init Rx queues per port */
+		rxconf = dev_info.default_rxconf;
+		rxconf.offloads = local_port_conf.rxmode.offloads;
+
+		for (eth_qid = 0; eth_qid < evt_rsrc->eth_rx_queues;
+		     eth_qid++) {
+			if (!evt_rsrc->per_port_pool)
+				ret = rte_eth_rx_queue_setup(port_id, eth_qid,
+					nb_rxd, 0, &rxconf,
+					evt_rsrc->pkt_pool[0][0]);
+			else
+				ret = rte_eth_rx_queue_setup(port_id, eth_qid,
+					nb_rxd, 0, &rxconf,
+					evt_rsrc->pkt_pool[port_id][0]);
+			if (ret < 0)
+				rte_exit(EXIT_FAILURE,
+					 "rte_eth_rx_queue_setup: err=%d, "
+					 "port=%d, eth_qid: %d\n",
+					 ret, port_id, eth_qid);
+		}
+
+		/* init one Tx queue per port */
+		txconf = dev_info.default_txconf;
+		txconf.offloads = local_port_conf.txmode.offloads;
+		ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd, 0, &txconf);
+		if (ret < 0)
+			rte_exit(EXIT_FAILURE,
+				 "rte_eth_tx_queue_setup: err=%d, "
+				 "port=%d\n", ret, port_id);
+	}
+}
+
 static void
 l3fwd_event_capability_setup(void)
 {
@@ -56,7 +189,7 @@ l3fwd_event_capability_setup(void)
 }
 
 void
-l3fwd_event_resource_setup(void)
+l3fwd_event_resource_setup(struct rte_eth_conf *port_conf)
 {
 	struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc();
 
@@ -69,6 +202,9 @@ l3fwd_event_resource_setup(void)
 	/* Setup eventdev capability callbacks */
 	l3fwd_event_capability_setup();
 
+	/* Ethernet device configuration */
+	l3fwd_eth_dev_port_setup(port_conf);
+
 	/* Event device configuration */
 	evt_rsrc->ops.event_device_setup();
 }
diff --git a/examples/l3fwd/l3fwd_event.h b/examples/l3fwd/l3fwd_event.h
index fc3862ec1..53feea069 100644
--- a/examples/l3fwd/l3fwd_event.h
+++ b/examples/l3fwd/l3fwd_event.h
@@ -72,7 +72,7 @@ struct l3fwd_event_resources {
 };
 
 struct l3fwd_event_resources *l3fwd_get_eventdev_rsrc(void);
-void l3fwd_event_resource_setup(void);
+void l3fwd_event_resource_setup(struct rte_eth_conf *port_conf);
 void l3fwd_event_set_generic_ops(struct l3fwd_event_setup_ops *ops);
 void l3fwd_event_set_internal_port_ops(struct l3fwd_event_setup_ops *ops);
 
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 582f2f135..0618daa38 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -48,12 +48,6 @@
 #include "l3fwd.h"
 #include "l3fwd_event.h"
 
-/*
- * Configurable number of RX/TX ring descriptors
- */
-#define RTE_TEST_RX_DESC_DEFAULT 1024
-#define RTE_TEST_TX_DESC_DEFAULT 1024
-
 #define MAX_TX_QUEUE_PER_PORT RTE_MAX_ETHPORTS
 #define MAX_RX_QUEUE_PER_PORT 128
 
@@ -495,7 +489,6 @@ parse_event_eth_rx_queues(const char *eth_rx_queues)
 }
 
 #define MAX_JUMBO_PKT_LEN  9600
-#define MEMPOOL_CACHE_SIZE 256
 
 static const char short_options[] =
 	"p:"  /* portmask */
@@ -730,7 +723,7 @@ print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr)
 	printf("%s%s", name, buf);
 }
 
-static int
+int
 init_mem(uint16_t portid, unsigned int nb_mbuf)
 {
 	struct lcore_conf *qconf;
@@ -917,14 +910,16 @@ main(int argc, char **argv)
 	}
 
 	evt_rsrc = l3fwd_get_eventdev_rsrc();
-	RTE_SET_USED(evt_rsrc);
 	/* parse application arguments (after the EAL ones) */
 	ret = parse_args(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n");
 
+	evt_rsrc->per_port_pool = per_port_pool;
+	evt_rsrc->pkt_pool = pktmbuf_pool;
+	evt_rsrc->port_mask = enabled_port_mask;
 	/* Configure eventdev parameters if user has requested */
-	l3fwd_event_resource_setup();
+	l3fwd_event_resource_setup(&port_conf);
 
 	if (check_lcore_params() < 0)
 		rte_exit(EXIT_FAILURE, "check_lcore_params failed\n");
-- 
2.17.1


  parent reply	other threads:[~2020-01-11 13:48 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 14:43 [dpdk-dev] [PATCH v2 00/11] example/l3fwd: introduce event device support pbhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 01/11] examples/l3fwd: add framework for event device pbhagavatula
2020-01-03 12:49   ` Ananyev, Konstantin
2020-01-06  4:27     ` Pavan Nikhilesh Bhagavatula
2020-01-06 12:32       ` Ananyev, Konstantin
2020-01-07 16:34         ` Pavan Nikhilesh Bhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 02/11] examples/l3fwd: split pipelines based on capability pbhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 03/11] examples/l3fwd: add event device configuration pbhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 04/11] examples/l3fwd: add ethdev setup based on eventdev pbhagavatula
2019-12-27 13:33   ` Nipun Gupta
2019-12-29 15:42     ` Pavan Nikhilesh Bhagavatula
2019-12-30  7:40       ` Nipun Gupta
2020-01-02  6:21         ` Pavan Nikhilesh Bhagavatula
2020-01-02  8:49           ` Nipun Gupta
2020-01-02  9:33             ` Jerin Jacob
2020-01-03  9:06               ` Nipun Gupta
2020-01-03  9:09                 ` Jerin Jacob
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 05/11] examples/l3fwd: add event port and queue setup pbhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 06/11] examples/l3fwd: add event eth Rx/Tx adapter setup pbhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 07/11] examples/l3fwd: add service core setup based on caps pbhagavatula
2020-01-03 13:07   ` Ananyev, Konstantin
2020-01-06  4:29     ` Pavan Nikhilesh Bhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 08/11] examples/l3fwd: add event lpm main loop pbhagavatula
2020-01-03 13:16   ` Ananyev, Konstantin
2020-01-06  4:43     ` Pavan Nikhilesh Bhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 09/11] examples/l3fwd: add event em " pbhagavatula
2020-01-03 13:45   ` Ananyev, Konstantin
2020-01-06  4:44     ` Pavan Nikhilesh Bhagavatula
2020-01-06 12:27       ` Ananyev, Konstantin
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 10/11] examples/l3fwd: add graceful teardown for eventdevice pbhagavatula
2020-01-03 13:52   ` Ananyev, Konstantin
2020-01-06  4:50     ` Pavan Nikhilesh Bhagavatula
2020-01-06 12:12       ` Ananyev, Konstantin
2020-01-07 16:28         ` Pavan Nikhilesh Bhagavatula
2019-12-04 14:43 ` [dpdk-dev] [PATCH v2 11/11] doc: update l3fwd user guide to support eventdev pbhagavatula
2019-12-04 15:16 ` [dpdk-dev] [PATCH v2 00/11] example/l3fwd: introduce event device support Jerin Jacob
2020-01-11 13:47 ` [dpdk-dev] [PATCH v3 " pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 01/11] examples/l3fwd: add framework for event device pbhagavatula
2020-01-21  8:44     ` Jerin Jacob
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 02/11] examples/l3fwd: split pipelines based on capability pbhagavatula
2020-01-21  8:46     ` Jerin Jacob
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 03/11] examples/l3fwd: add event device configuration pbhagavatula
2020-01-21  8:51     ` Jerin Jacob
2020-01-11 13:47   ` pbhagavatula [this message]
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 05/11] examples/l3fwd: add event port and queue setup pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 06/11] examples/l3fwd: add event eth Rx/Tx adapter setup pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 07/11] examples/l3fwd: add service core setup based on caps pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 08/11] examples/l3fwd: add event lpm main loop pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 09/11] examples/l3fwd: add event em " pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 10/11] examples/l3fwd: add graceful teardown for eventdevice pbhagavatula
2020-01-11 13:47   ` [dpdk-dev] [PATCH v3 11/11] doc: update l3fwd user guide to support eventdev pbhagavatula
2020-01-13 12:02   ` [dpdk-dev] [PATCH v3 00/11] example/l3fwd: introduce event device support Nipun Gupta
2020-01-22 18:28   ` [dpdk-dev] [PATCH v4 " pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 01/11] examples/l3fwd: add framework for event device pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 02/11] examples/l3fwd: split pipelines based on capability pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 03/11] examples/l3fwd: add event device configuration pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 04/11] examples/l3fwd: add ethdev setup based on eventdev pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 05/11] examples/l3fwd: add event port and queue setup pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 06/11] examples/l3fwd: add event eth Rx/Tx adapter setup pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 07/11] examples/l3fwd: add service core setup based on caps pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 08/11] examples/l3fwd: add event lpm main loop pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 09/11] examples/l3fwd: add event em " pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 10/11] examples/l3fwd: add graceful teardown for eventdevice pbhagavatula
2020-01-22 18:28     ` [dpdk-dev] [PATCH v4 11/11] doc: update l3fwd user guide to support eventdev pbhagavatula
2020-01-23  5:25       ` Jerin Jacob
2020-01-24  4:05     ` [dpdk-dev] [PATCH v5 00/11] example/l3fwd: introduce event device support pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 01/11] examples/l3fwd: add framework for event device pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 02/11] examples/l3fwd: split pipelines based on capability pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 03/11] examples/l3fwd: add event device configuration pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 04/11] examples/l3fwd: add ethdev setup based on eventdev pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 05/11] examples/l3fwd: add event port and queue setup pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 06/11] examples/l3fwd: add event eth Rx/Tx adapter setup pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 07/11] examples/l3fwd: add service core setup based on caps pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 08/11] examples/l3fwd: add event lpm main loop pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 09/11] examples/l3fwd: add event em " pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 10/11] examples/l3fwd: add graceful teardown for eventdevice pbhagavatula
2020-01-24  4:05       ` [dpdk-dev] [PATCH v5 11/11] doc: update l3fwd user guide to support eventdev pbhagavatula
2020-01-27 16:17       ` [dpdk-dev] [PATCH v5 00/11] example/l3fwd: introduce event device support 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=20200111134730.5329-5-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=konstantin.ananyev@intel.com \
    --cc=marko.kovacevic@intel.com \
    --cc=nipun.gupta@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.