Add ethernet device setup functions to configure ethdev ports incase
prod_type_ethdev option is enabled.

Signed-off-by: Pavan Nikhilesh <pbhagavat...@caviumnetworks.com>
Acked-by: Jerin Jacob <jerin.ja...@caviumnetworks.com>
---

 v2 Changes:
  - Removed unnecessary "\n" from evt_err, reworked ethernet queue setup.

 app/test-eventdev/test_perf_atq.c    |  1 +
 app/test-eventdev/test_perf_common.c | 65 ++++++++++++++++++++++++++++++++++++
 app/test-eventdev/test_perf_common.h |  1 +
 app/test-eventdev/test_perf_queue.c  |  1 +
 4 files changed, 68 insertions(+)

diff --git a/app/test-eventdev/test_perf_atq.c 
b/app/test-eventdev/test_perf_atq.c
index 6082d4ff3..a2067345d 100644
--- a/app/test-eventdev/test_perf_atq.c
+++ b/app/test-eventdev/test_perf_atq.c
@@ -280,6 +280,7 @@ static const struct evt_test_ops perf_atq =  {
        .opt_check          = perf_atq_opt_check,
        .opt_dump           = perf_atq_opt_dump,
        .test_setup         = perf_test_setup,
+       .ethdev_setup       = perf_ethdev_setup,
        .mempool_setup      = perf_mempool_setup,
        .eventdev_setup     = perf_atq_eventdev_setup,
        .launch_lcores      = perf_atq_launch_lcores,
diff --git a/app/test-eventdev/test_perf_common.c 
b/app/test-eventdev/test_perf_common.c
index 18945c0eb..ff5c499f9 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -407,6 +407,71 @@ perf_elt_init(struct rte_mempool *mp, void *arg 
__rte_unused,
        memset(obj, 0, mp->elt_size);
 }

+#define NB_RX_DESC                     128
+#define NB_TX_DESC                     512
+int
+perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
+{
+       int i;
+       struct test_perf *t = evt_test_priv(test);
+       struct rte_eth_conf port_conf = {
+               .rxmode = {
+                       .mq_mode = ETH_MQ_RX_RSS,
+                       .max_rx_pkt_len = ETHER_MAX_LEN,
+                       .split_hdr_size = 0,
+                       .header_split   = 0,
+                       .hw_ip_checksum = 0,
+                       .hw_vlan_filter = 0,
+                       .hw_vlan_strip  = 0,
+                       .hw_vlan_extend = 0,
+                       .jumbo_frame    = 0,
+                       .hw_strip_crc   = 1,
+               },
+               .rx_adv_conf = {
+                       .rss_conf = {
+                               .rss_key = NULL,
+                               .rss_hf = ETH_RSS_IP,
+                       },
+               },
+       };
+
+       if (opt->prod_type == EVT_PROD_TYPE_SYNT)
+               return 0;
+
+       if (!rte_eth_dev_count()) {
+               evt_err("No ethernet ports found.");
+               return -ENODEV;
+       }
+
+       for (i = 0; i < rte_eth_dev_count(); i++) {
+
+               if (rte_eth_dev_configure(i, 1, 1,
+                                       &port_conf)
+                               < 0) {
+                       evt_err("Failed to configure eth port [%d]", i);
+                       return -EINVAL;
+               }
+
+               if (rte_eth_rx_queue_setup(i, 0, NB_RX_DESC,
+                               rte_socket_id(), NULL, t->pool) < 0) {
+                       evt_err("Failed to setup eth port [%d] rx_queue: %d.",
+                                       i, 0);
+                       return -EINVAL;
+               }
+
+               if (rte_eth_tx_queue_setup(i, 0, NB_TX_DESC,
+                                       rte_socket_id(), NULL) < 0) {
+                       evt_err("Failed to setup eth port [%d] tx_queue: %d.",
+                                       i, 0);
+                       return -EINVAL;
+               }
+
+               rte_eth_promiscuous_enable(i);
+       }
+
+       return 0;
+}
+
 int
 perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
 {
diff --git a/app/test-eventdev/test_perf_common.h 
b/app/test-eventdev/test_perf_common.h
index ab2e59988..5c6a615ef 100644
--- a/app/test-eventdev/test_perf_common.h
+++ b/app/test-eventdev/test_perf_common.h
@@ -157,6 +157,7 @@ perf_nb_event_ports(struct evt_options *opt)
 int perf_test_result(struct evt_test *test, struct evt_options *opt);
 int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
 int perf_test_setup(struct evt_test *test, struct evt_options *opt);
+int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
 int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
 int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
                                uint8_t stride, uint8_t nb_queues);
diff --git a/app/test-eventdev/test_perf_queue.c 
b/app/test-eventdev/test_perf_queue.c
index 0caf5757c..18e1bd59b 100644
--- a/app/test-eventdev/test_perf_queue.c
+++ b/app/test-eventdev/test_perf_queue.c
@@ -293,6 +293,7 @@ static const struct evt_test_ops perf_queue =  {
        .opt_dump           = perf_queue_opt_dump,
        .test_setup         = perf_test_setup,
        .mempool_setup      = perf_mempool_setup,
+       .ethdev_setup       = perf_ethdev_setup,
        .eventdev_setup     = perf_queue_eventdev_setup,
        .launch_lcores      = perf_queue_launch_lcores,
        .eventdev_destroy   = perf_eventdev_destroy,
--
2.14.1

Reply via email to