[dpdk-dev,v2,05/12] app/eventdev: add perf ethport setup and destroy

Message ID 20171218214405.26763-5-pbhagavatula@caviumnetworks.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Pavan Nikhilesh Dec. 18, 2017, 9:43 p.m. UTC
  Add common ethdev port setup and destroy along with event dev destroy.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 app/test-eventdev/test_pipeline_common.c | 98 ++++++++++++++++++++++++++++++++
 app/test-eventdev/test_pipeline_common.h |  3 +
 2 files changed, 101 insertions(+)
  

Comments

Jerin Jacob Jan. 8, 2018, 2:10 p.m. UTC | #1
-----Original Message-----
> Date: Tue, 19 Dec 2017 03:13:58 +0530
> From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com,
>  bruce.richardson@intel.com, harry.van.haaren@intel.com,
>  gage.eads@intel.com, hemant.agrawal@nxp.com, nipun.gupta@nxp.com,
>  liang.j.ma@intel.com
> Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v2 05/12] app/eventdev: add perf ethport setup
>  and destroy
> X-Mailer: git-send-email 2.14.1
> 
> Add common ethdev port setup and destroy along with event dev destroy.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>  app/test-eventdev/test_pipeline_common.c | 98 ++++++++++++++++++++++++++++++++
>  app/test-eventdev/test_pipeline_common.h |  3 +
>  2 files changed, 101 insertions(+)
> 
> diff --git a/app/test-eventdev/test_pipeline_common.c b/app/test-eventdev/test_pipeline_common.c
> index d2ffcbe08..eb3ab6d44 100644
> --- a/app/test-eventdev/test_pipeline_common.c
> +++ b/app/test-eventdev/test_pipeline_common.c
> @@ -116,6 +116,104 @@ pipeline_opt_check(struct evt_options *opt, uint64_t nb_queues)
>  	return 0;
>  }
>  
> +#define NB_RX_DESC			128
> +#define NB_TX_DESC			512
> +int
> +pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
> +{
> +	int i;
> +	uint8_t nb_queues = 1;
> +	uint8_t mt_state = 0;
> +	struct test_pipeline *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,

Use new Rx/TX offload scheme.


> +		},
> +		.rx_adv_conf = {
> +			.rss_conf = {
> +				.rss_key = NULL,
> +				.rss_hf = ETH_RSS_IP,
> +			},
> +		},
> +	};
> +
> +	RTE_SET_USED(opt);
> +	if (!rte_eth_dev_count()) {
> +		evt_err("No ethernet ports found.\n");
> +		return -ENODEV;
> +	}
> +
  

Patch

diff --git a/app/test-eventdev/test_pipeline_common.c b/app/test-eventdev/test_pipeline_common.c
index d2ffcbe08..eb3ab6d44 100644
--- a/app/test-eventdev/test_pipeline_common.c
+++ b/app/test-eventdev/test_pipeline_common.c
@@ -116,6 +116,104 @@  pipeline_opt_check(struct evt_options *opt, uint64_t nb_queues)
 	return 0;
 }
 
+#define NB_RX_DESC			128
+#define NB_TX_DESC			512
+int
+pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
+{
+	int i;
+	uint8_t nb_queues = 1;
+	uint8_t mt_state = 0;
+	struct test_pipeline *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,
+			},
+		},
+	};
+
+	RTE_SET_USED(opt);
+	if (!rte_eth_dev_count()) {
+		evt_err("No ethernet ports found.\n");
+		return -ENODEV;
+	}
+
+	for (i = 0; i < rte_eth_dev_count(); i++) {
+		struct rte_eth_dev_info dev_info;
+
+		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+		rte_eth_dev_info_get(i, &dev_info);
+		mt_state = !(dev_info.tx_offload_capa &
+				DEV_TX_OFFLOAD_MT_LOCKFREE);
+
+		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
+					&port_conf)
+				< 0) {
+			evt_err("Failed to configure eth port [%d]\n", 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.\n",
+					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.\n",
+					i, 0);
+			return -EINVAL;
+		}
+
+		t->mt_unsafe |= mt_state;
+		t->tx_buf[i] =
+			rte_malloc(NULL, RTE_ETH_TX_BUFFER_SIZE(BURST_SIZE), 0);
+		if (t->tx_buf[i] == NULL)
+			rte_panic("Unable to allocate Tx buffer memory.");
+		rte_eth_promiscuous_enable(i);
+	}
+
+	return 0;
+}
+
+void
+pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+	int i;
+	RTE_SET_USED(test);
+	RTE_SET_USED(opt);
+
+	for (i = 0; i < rte_eth_dev_count(); i++) {
+		rte_event_eth_rx_adapter_stop(i);
+		rte_eth_dev_stop(i);
+		rte_eth_dev_close(i);
+	}
+}
+
+void
+pipeline_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
+{
+	RTE_SET_USED(test);
+
+	rte_event_dev_stop(opt->dev_id);
+	rte_event_dev_close(opt->dev_id);
+}
+
 int
 pipeline_mempool_setup(struct evt_test *test, struct evt_options *opt)
 {
diff --git a/app/test-eventdev/test_pipeline_common.h b/app/test-eventdev/test_pipeline_common.h
index e709a1000..204033a01 100644
--- a/app/test-eventdev/test_pipeline_common.h
+++ b/app/test-eventdev/test_pipeline_common.h
@@ -81,9 +81,12 @@  struct test_pipeline {
 int pipeline_test_result(struct evt_test *test, struct evt_options *opt);
 int pipeline_opt_check(struct evt_options *opt, uint64_t nb_queues);
 int pipeline_test_setup(struct evt_test *test, struct evt_options *opt);
+int pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt);
 int pipeline_mempool_setup(struct evt_test *test, struct evt_options *opt);
 void pipeline_opt_dump(struct evt_options *opt, uint8_t nb_queues);
 void pipeline_test_destroy(struct evt_test *test, struct evt_options *opt);
+void pipeline_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
+void pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
 void pipeline_mempool_destroy(struct evt_test *test, struct evt_options *opt);
 
 #endif /* _TEST_PIPELINE_COMMON_ */