From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, <bruce.richardson@intel.com>,
<akhil.goyal@nxp.com>,
Marko Kovacevic <marko.kovacevic@intel.com>,
Ori Kam <orika@mellanox.com>,
Radu Nicolau <radu.nicolau@intel.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 v2 04/10] examples/l2fwd-event: add eth port setup for eventdev
Date: Thu, 19 Sep 2019 14:55:58 +0530 [thread overview]
Message-ID: <20190919092603.5485-5-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20190919092603.5485-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>
---
examples/l2fwd-event/l2fwd_eventdev.c | 114 ++++++++++++++++++++++++++
examples/l2fwd-event/l2fwd_eventdev.h | 1 +
examples/l2fwd-event/main.c | 17 ++++
3 files changed, 132 insertions(+)
diff --git a/examples/l2fwd-event/l2fwd_eventdev.c b/examples/l2fwd-event/l2fwd_eventdev.c
index df76f1c1f..0d0d3b8b9 100644
--- a/examples/l2fwd-event/l2fwd_eventdev.c
+++ b/examples/l2fwd-event/l2fwd_eventdev.c
@@ -18,6 +18,14 @@
#include "l2fwd_common.h"
#include "l2fwd_eventdev.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);
+}
+
static void
parse_mode(const char *optarg)
{
@@ -76,6 +84,108 @@ parse_eventdev_args(char **argv, int argc)
return 0;
}
+static void
+eth_dev_port_setup(uint16_t ethdev_count __rte_unused)
+{
+ struct eventdev_resources *eventdev_rsrc = get_eventdev_rsrc();
+ static struct rte_eth_conf port_config = {
+ .rxmode = {
+ .mq_mode = ETH_MQ_RX_RSS,
+ .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
+ .split_hdr_size = 0,
+ .offloads = DEV_RX_OFFLOAD_CHECKSUM
+ },
+ .rx_adv_conf = {
+ .rss_conf = {
+ .rss_key = NULL,
+ .rss_hf = ETH_RSS_IP,
+ }
+ },
+ .txmode = {
+ .mq_mode = ETH_MQ_TX_NONE,
+ }
+ };
+ struct rte_eth_conf local_port_conf;
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_txconf txconf;
+ struct rte_eth_rxconf rxconf;
+ uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
+ uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
+ uint16_t port_id;
+ int32_t ret;
+
+ /* initialize all ports */
+ RTE_ETH_FOREACH_DEV(port_id) {
+ local_port_conf = port_config;
+ /* skip ports that are not enabled */
+ if ((eventdev_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);
+ 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_config.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_config.rx_adv_conf.rss_conf.rss_hf,
+ local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+ }
+
+ ret = rte_eth_dev_configure(port_id, 1, 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,
+ &eventdev_rsrc->ports_eth_addr[port_id]);
+ print_ethaddr(" Address:",
+ &eventdev_rsrc->ports_eth_addr[port_id]);
+ printf("\n");
+
+
+ /* init one Rx queue per port */
+ rxconf = dev_info.default_rxconf;
+ rxconf.offloads = local_port_conf.rxmode.offloads;
+ ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, 0, &rxconf,
+ eventdev_rsrc->pkt_pool);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_rx_queue_setup: err=%d, "
+ "port=%d\n", ret, port_id);
+
+ /* 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);
+
+ rte_eth_promiscuous_enable(port_id);
+ }
+}
+
static void
eventdev_capability_setup(void)
{
@@ -105,6 +215,7 @@ void
eventdev_resource_setup(void)
{
struct eventdev_resources *eventdev_rsrc = get_eventdev_rsrc();
+ uint16_t ethdev_count = rte_eth_dev_count_avail();
uint32_t service_id;
int32_t ret;
@@ -119,6 +230,9 @@ eventdev_resource_setup(void)
/* Setup eventdev capability callbacks */
eventdev_capability_setup();
+ /* Ethernet device configuration */
+ eth_dev_port_setup(ethdev_count);
+
/* Start event device service */
ret = rte_event_dev_service_id_get(eventdev_rsrc->event_d_id,
&service_id);
diff --git a/examples/l2fwd-event/l2fwd_eventdev.h b/examples/l2fwd-event/l2fwd_eventdev.h
index 717f688ce..cc0bdd1ad 100644
--- a/examples/l2fwd-event/l2fwd_eventdev.h
+++ b/examples/l2fwd-event/l2fwd_eventdev.h
@@ -51,6 +51,7 @@ struct eventdev_resources {
uint8_t enabled;
uint8_t nb_args;
char **args;
+ struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
};
static inline struct eventdev_resources *
diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index 661f0833f..f24bdd4a4 100644
--- a/examples/l2fwd-event/main.c
+++ b/examples/l2fwd-event/main.c
@@ -602,6 +602,22 @@ main(int argc, char **argv)
/* Configure eventdev parameters if user has requested */
eventdev_resource_setup();
+ if (eventdev_rsrc->enabled) {
+ /* All settings are done. Now enable eth devices */
+ RTE_ETH_FOREACH_DEV(portid) {
+ /* skip ports that are not enabled */
+ if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
+ continue;
+
+ ret = rte_eth_dev_start(portid);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_dev_start:err=%d, port=%u\n",
+ ret, portid);
+ }
+
+ goto skip_port_config;
+ }
/* Initialize the port/queue configuration of each logical core */
RTE_ETH_FOREACH_DEV(portid) {
@@ -733,6 +749,7 @@ main(int argc, char **argv)
"All available ports are disabled. Please set portmask.\n");
}
+skip_port_config:
check_all_ports_link_status(l2fwd_enabled_port_mask);
ret = 0;
--
2.17.1
next prev parent reply other threads:[~2019-09-19 9:26 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 9:25 [dpdk-dev] [PATCH v2 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-19 9:25 ` [dpdk-dev] [PATCH v2 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-19 9:43 ` Sunil Kumar Kori
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 04/10] examples/l2fwd-event: add eth port setup for eventdev pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-19 10:35 ` Sunil Kumar Kori
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-09-19 10:13 ` [dpdk-dev] [PATCH v3 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-09-24 9:41 ` [dpdk-dev] [PATCH v4 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-26 17:28 ` Jerin Jacob
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-26 17:33 ` Jerin Jacob
2019-09-27 13:08 ` Nipun Gupta
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 04/10] examples/l2fwd-event: add eth port setup for eventdev pbhagavatula
2019-09-27 13:15 ` Nipun Gupta
2019-09-27 14:45 ` Pavan Nikhilesh Bhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-27 13:22 ` Nipun Gupta
2019-09-27 14:43 ` Pavan Nikhilesh Bhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-27 13:28 ` Nipun Gupta
2019-09-27 14:35 ` Pavan Nikhilesh Bhagavatula
2019-09-30 5:38 ` Nipun Gupta
2019-09-30 6:38 ` Jerin Jacob
2019-09-30 7:46 ` Nipun Gupta
2019-09-30 8:09 ` Pavan Nikhilesh Bhagavatula
2019-09-30 17:50 ` Nipun Gupta
2019-10-01 5:59 ` Pavan Nikhilesh Bhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-09-24 9:42 ` [dpdk-dev] [PATCH v4 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-09-26 17:42 ` Jerin Jacob
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-11 14:41 ` Jerin Jacob
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-04 12:30 ` Nipun Gupta
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-11 14:52 ` Jerin Jacob
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-02 20:57 ` [dpdk-dev] [PATCH v5 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-11 14:11 ` Jerin Jacob
2019-10-03 10:33 ` [dpdk-dev] [PATCH v5 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-10-03 12:40 ` Hemant Agrawal
2019-10-03 12:47 ` Jerin Jacob
2019-10-09 7:50 ` Nipun Gupta
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 " pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-16 19:07 ` Stephen Hemminger
2019-10-21 3:29 ` Varghese, Vipin
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-21 3:19 ` Varghese, Vipin
2019-10-21 16:53 ` Pavan Nikhilesh Bhagavatula
2019-10-22 3:13 ` Varghese, Vipin
2019-10-22 17:02 ` Pavan Nikhilesh Bhagavatula
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-21 3:12 ` Varghese, Vipin
2019-10-21 16:56 ` Pavan Nikhilesh Bhagavatula
2019-10-22 2:48 ` Varghese, Vipin
2019-10-14 18:22 ` [dpdk-dev] [PATCH v6 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-16 12:38 ` [dpdk-dev] [PATCH v6 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-10-21 3:25 ` Varghese, Vipin
2019-10-21 17:02 ` Pavan Nikhilesh Bhagavatula
2019-10-22 2:57 ` Varghese, Vipin
2019-10-22 15:55 ` Pavan Nikhilesh Bhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 " pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-26 11:10 ` [dpdk-dev] [PATCH v7 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-30 13:19 ` Jerin Jacob
2019-10-30 12:58 ` [dpdk-dev] [PATCH v7 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-09-19 9:25 ` [dpdk-dev] [PATCH v2 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-19 9:25 ` [dpdk-dev] [PATCH v2 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-19 9:25 ` pbhagavatula [this message]
2019-09-19 9:25 ` [dpdk-dev] [PATCH v2 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-19 9:26 ` [dpdk-dev] [PATCH v2 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-19 9:26 ` [dpdk-dev] [PATCH v2 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-19 9:26 ` [dpdk-dev] [PATCH v2 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-19 9:26 ` [dpdk-dev] [PATCH v2 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
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=20190919092603.5485-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=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).