DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] eventdev: add adapter instance get API
@ 2022-06-06 17:25 Ganapati Kundapura
  2022-06-07  8:07 ` [PATCH v2] " Ganapati Kundapura
  0 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-06 17:25 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan

Added rte_event_eth_rx_adapter_instance_get() and
rte_event_eth_tx_adapter_instance_get() api's to get the
adapter instance id for a specified event port and
queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..a6d8987 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified event port and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..b14131d 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified event port and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..e0d2554 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -44,6 +45,8 @@
 
 #define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
 
+#define INVALID_INSTANCE_ID UINT8_MAX
+
 /*
  * Used to store port and queue ID of interrupting Rx queue
  */
@@ -251,7 +254,13 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
+static int rxa_array_sz;
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1421,9 +1430,13 @@ rte_event_eth_rx_adapter_init(void)
 	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
+	uint8_t i;
 
 	sz = sizeof(*event_eth_rx_adapter) *
 	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	rxa_array_sz = sz;
+
+	sz += RTE_MAX_ETHPORTS * sizeof(*event_eth_rxa_inst_info);
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1438,6 +1451,16 @@ rte_event_eth_rx_adapter_init(void)
 	}
 
 	event_eth_rx_adapter = mz->addr;
+
+	/* event_eth_rxa_inst_info array starts after rxa array */
+	event_eth_rxa_inst_info = (struct event_eth_rxa_inst_info **)
+					((uint64_t)event_eth_rx_adapter +
+					 rxa_array_sz);
+
+	/* Reset the rxa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_rxa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -1445,12 +1468,20 @@ static int
 rxa_memzone_lookup(void)
 {
 	const struct rte_memzone *mz;
+	unsigned int rxa_array_sz;
 
 	if (event_eth_rx_adapter == NULL) {
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
 		event_eth_rx_adapter = mz->addr;
+
+		/* event_eth_rxa_inst_info array starts after rxa array */
+		rxa_array_sz = sizeof(*event_eth_rx_adapter) *
+				RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+		event_eth_rxa_inst_info = (struct event_eth_rxa_inst_info **)
+					       ((uint64_t)event_eth_rx_adapter +
+					       rxa_array_sz);
 	}
 
 	return 0;
@@ -1950,6 +1981,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2025,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2122,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2587,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2612,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2636,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2804,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2913,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3368,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..f56938d 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index
+ *
+ * @param[out] rxa_inst_id
+ *  RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..1c9f9fc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -836,6 +896,31 @@ txa_service_queue_add(uint8_t id,
 	tdi->nb_queues++;
 	txa->nb_queues++;
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 ret_unlock:
 	rte_spinlock_unlock(&txa->tx_lock);
 	return 0;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..28f4fa9 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..b5bfcd5 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -105,6 +105,8 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v2] eventdev: add adapter instance get API
  2022-06-06 17:25 [PATCH v1] eventdev: add adapter instance get API Ganapati Kundapura
@ 2022-06-07  8:07 ` Ganapati Kundapura
  2022-06-07  8:21   ` [PATCH v3] " Ganapati Kundapura
  0 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-07  8:07 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan

Added rte_event_eth_rx_adapter_instance_get() and
rte_event_eth_tx_adapter_instance_get() api's to get the
adapter instance id for a specified event port and
queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..a6d8987 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified event port and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..b14131d 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified event port and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..bfcad62 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -42,7 +43,10 @@
 /* Sentinel value to detect initialized file handle */
 #define INIT_FD		-1
 
-#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
+#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
+#define RX_ADAPTER_INSTNACE_ARRAY "rx_adapter_instance_array"
+
+#define INVALID_INSTANCE_ID UINT8_MAX
 
 /*
  * Used to store port and queue ID of interrupting Rx queue
@@ -251,7 +255,12 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
+					      sizeof(*event_eth_rx_adapter),
+					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
+	if (event_eth_rxa_inst_info == NULL) {
+		event_eth_rxa_inst_info =
+			rxa_memzone_array_get(RX_ADAPTER_INSTNACE_ARRAY,
+					      sizeof(*event_eth_rxa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_rxa_inst_info == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+			event_eth_rxa_inst_info[i] = NULL;
+	}
+
 	return 0;
 }
 
@@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
 	const struct rte_memzone *mz;
 
 	if (event_eth_rx_adapter == NULL) {
-		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
+		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
+	if (event_eth_rxa_inst_info == NULL) {
+		mz = rte_memzone_lookup(RX_ADAPTER_INSTNACE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_eth_rxa_inst_info = mz->addr;
+	}
+
 	return 0;
 }
 
@@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2605,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
@@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..f56938d 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index
+ *
+ * @param[out] rxa_inst_id
+ *  RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..1c9f9fc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -836,6 +896,31 @@ txa_service_queue_add(uint8_t id,
 	tdi->nb_queues++;
 	txa->nb_queues++;
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 ret_unlock:
 	rte_spinlock_unlock(&txa->tx_lock);
 	return 0;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..28f4fa9 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..1c99d52 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -102,9 +102,11 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_event_eth_rx_adapter_create_with_params;
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v3] eventdev: add adapter instance get API
  2022-06-07  8:07 ` [PATCH v2] " Ganapati Kundapura
@ 2022-06-07  8:21   ` Ganapati Kundapura
  2022-06-07 13:18     ` Jayatheerthan, Jay
  2022-06-07 15:13     ` [PATCH v4] " Ganapati Kundapura
  0 siblings, 2 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-07  8:21 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan

Added rte_event_eth_rx_adapter_instance_get() and
rte_event_eth_tx_adapter_instance_get() api's to get the
adapter instance id for a specified event port and
queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..a6d8987 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified event port and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..b14131d 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified event port and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..3095647 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -42,7 +43,10 @@
 /* Sentinel value to detect initialized file handle */
 #define INIT_FD		-1
 
-#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
+#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
+#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
+
+#define INVALID_INSTANCE_ID UINT8_MAX
 
 /*
  * Used to store port and queue ID of interrupting Rx queue
@@ -251,7 +255,12 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
+					      sizeof(*event_eth_rx_adapter),
+					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
+	if (event_eth_rxa_inst_info == NULL) {
+		event_eth_rxa_inst_info =
+			rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_rxa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_rxa_inst_info == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+			event_eth_rxa_inst_info[i] = NULL;
+	}
+
 	return 0;
 }
 
@@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
 	const struct rte_memzone *mz;
 
 	if (event_eth_rx_adapter == NULL) {
-		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
+		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
+	if (event_eth_rxa_inst_info == NULL) {
+		mz = rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_eth_rxa_inst_info = mz->addr;
+	}
+
 	return 0;
 }
 
@@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2605,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
@@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..f56938d 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index
+ *
+ * @param[out] rxa_inst_id
+ *  RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..1c9f9fc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -836,6 +896,31 @@ txa_service_queue_add(uint8_t id,
 	tdi->nb_queues++;
 	txa->nb_queues++;
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 ret_unlock:
 	rte_spinlock_unlock(&txa->tx_lock);
 	return 0;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..28f4fa9 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..1c99d52 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -102,9 +102,11 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_event_eth_rx_adapter_create_with_params;
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v3] eventdev: add adapter instance get API
  2022-06-07  8:21   ` [PATCH v3] " Ganapati Kundapura
@ 2022-06-07 13:18     ` Jayatheerthan, Jay
  2022-06-08 11:23       ` Kundapura, Ganapati
  2022-06-07 15:13     ` [PATCH v4] " Ganapati Kundapura
  1 sibling, 1 reply; 81+ messages in thread
From: Jayatheerthan, Jay @ 2022-06-07 13:18 UTC (permalink / raw)
  To: Kundapura, Ganapati, jerinjacobk, dev

Hi Ganapati,
This patch could be split into multiple patches in a patchset to make it easier to review.

One way to split:
1. Rx adapter API
2. Telemetry changes for Rx adapter
3. Test changes for Rx adapter API
4. Tx adapter API
5. Telemetry changes for Tx adapter ?
6. Test changes for Tx adapter API
7. Document update.

-Jay


> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Tuesday, June 7, 2022 1:51 PM
> To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Subject: [PATCH v3] eventdev: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() and
> rte_event_eth_tx_adapter_instance_get() api's to get the
> adapter instance id for a specified event port and
> queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> 
> diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
> index e358a70..878004b 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
>  #define TEST_ETHDEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
> 
>  struct event_eth_rx_adapter_test_params {
>  	struct rte_mempool *mp;
> @@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +adapter_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong rx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_rx_queues + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> +
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Add another queue */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete queues from the Rx adapter */
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
>  static struct unit_test_suite event_eth_rx_tests = {
>  	.suite_name = "rx event eth adapter test suite",
>  	.setup = testsuite_setup,
> @@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
>  			     adapter_queue_event_buf_test),
>  		TEST_CASE_ST(adapter_create_with_params, adapter_free,
>  			     adapter_queue_stats_test),
> +		TEST_CASE_ST(adapter_create, adapter_free,
> +			     adapter_instance_get),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
> index 2900532..ebbc622 100644
> --- a/app/test/test_event_eth_tx_adapter.c
> +++ b/app/test/test_event_eth_tx_adapter.c
> @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
>  #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
>  #define SOCKET0			0
>  #define RING_SIZE		256
>  #define ETH_NAME_LEN		32
> @@ -639,6 +640,79 @@ tx_adapter_service(void)
>  }
> 
>  static int
> +tx_adapter_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong tx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_tx_queues + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Add another queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete queues from the Tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
>  tx_adapter_dynamic_device(void)
>  {
>  	uint16_t port_id = rte_eth_dev_count_avail();
> @@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
>  					tx_adapter_start_stop),
>  		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
>  					tx_adapter_service),
> +		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> +					tx_adapter_instance_get),
>  		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
> diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> index 3b4ef50..a6d8987 100644
> --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
>  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
>  reset queue level stats when queue level event buffer is in use.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The ``rte_event_eth_rx_adapter_instance_get()`` function reports
> +rx adapter instance id for a specified event port and rx queue index.
> +
>  Interrupt Based Rx Queues
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> index f80d226..b14131d 100644
> --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
>  the counts from the eventdev PMD callback if the callback is supported, and
>  the counts maintained by the service function, if one exists.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
> +tx adapter instance id for a specified event port and tx queue index.
> +
>  Tx event vectorization
>  ~~~~~~~~~~~~~~~~~~~~~~
> 
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..3095647 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -6,6 +6,7 @@
>  #include <sys/epoll.h>
>  #endif
>  #include <unistd.h>
> +#include <limits.h>
> 
>  #include <rte_cycles.h>
>  #include <rte_common.h>
> @@ -42,7 +43,10 @@
>  /* Sentinel value to detect initialized file handle */
>  #define INIT_FD		-1
> 
> -#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
> +#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
> +#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
> +
> +#define INVALID_INSTANCE_ID UINT8_MAX
> 
>  /*
>   * Used to store port and queue ID of interrupting Rx queue
> @@ -251,7 +255,12 @@ struct eth_rx_queue_info {
>  	struct rte_event_eth_rx_adapter_stats *stats;
>  };
> 
> +struct event_eth_rxa_inst_info {
> +	uint8_t rxa_inst_id;
> +};
> +
>  static struct event_eth_rx_adapter **event_eth_rx_adapter;
> +static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
> 
>  /* Enable dynamic timestamp field in mbuf */
>  static uint64_t event_eth_rx_timestamp_dynflag;
> @@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
> +					      sizeof(*event_eth_rx_adapter),
> +					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
> +	if (event_eth_rxa_inst_info == NULL) {
> +		event_eth_rxa_inst_info =
> +			rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_rxa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_rxa_inst_info == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +			event_eth_rxa_inst_info[i] = NULL;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
>  	const struct rte_memzone *mz;
> 
>  	if (event_eth_rx_adapter == NULL) {
> -		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> +		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> +	if (event_eth_rxa_inst_info == NULL) {
> +		mz = rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +
> +		event_eth_rxa_inst_info = mz->addr;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
>  	int pollq;
>  	int intrq;
>  	int sintrq;
> +	uint16_t eth_dev_id = dev_info->dev->data->port_id;
> 
> 
>  	if (rx_adapter->nb_queues == 0)
> @@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
>  		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
>  		dev_info->rx_queue[rx_queue_id].stats = NULL;
>  	}
> +
> +	/* unset rxa_inst_id for rx_queue_id */
> +	if (event_eth_rxa_inst_info[eth_dev_id])
> +		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +							INVALID_INSTANCE_ID;
>  }
> 
>  static int
> @@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
>  		}
>  	}
> 
> +	/* Allocate storage to store rxa_inst_id for rxq */
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_rxa_inst_info *i_info;
> +
> +		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
> +				n * sizeof(struct event_eth_rxa_inst_info),
> +				0,
> +				rx_adapter->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_rxa_inst_info");
> +			return -ENOMEM;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_rxa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
> +	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +								rx_adapter->id;
> +
>  	if (!rx_adapter->use_queue_event_buf)
>  		return 0;
> 
> @@ -2523,6 +2605,10 @@ int
>  rte_event_eth_rx_adapter_free(uint8_t id)
>  {
>  	struct event_eth_rx_adapter *rx_adapter;
> +	uint16_t eth_dev_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> 
> @@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
>  	rte_free(rx_adapter);
>  	event_eth_rx_adapter[id] = NULL;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
> +		if (event_eth_rxa_inst_info[eth_dev_id]) {
> +			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
> +			event_eth_rxa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_rx_adapter_free(id);
>  	return 0;
>  }
> @@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t inst_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
> +				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*rxa_inst_id = inst_id;
> +
> +	return 0;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> @@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
>  	return ret;
>  }
> 
> +static int
> +handle_rxa_instance_get(const char *cmd __rte_unused,
> +			const char *params,
> +			struct rte_tel_data *d)
> +{
> +	uint8_t instance_id;
> +	uint16_t rx_queue_id;
> +	int eth_dev_id, ret = -1;
> +	char *token, *l_params;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	l_params = strdup(params);
> +	if (l_params == NULL)
> +		return -ENOMEM;
> +	token = strtok(l_params, ",");
> +	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
> +
> +	/* Get device ID from parameter string */
> +	eth_dev_id = strtoul(token, NULL, 10);
> +	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
> +
> +	token = strtok(NULL, ",");
> +	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
> +
> +	/* Get Rx queue ID from parameter string */
> +	rx_queue_id = strtoul(token, NULL, 10);
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
> +		ret = -EINVAL;
> +		goto error;
> +	}
> +
> +	token = strtok(NULL, "\0");
> +	if (token != NULL)
> +		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
> +				 " telemetry command, ignoring");
> +
> +	/* Parsing parameter finished */
> +	free(l_params);
> +
> +	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						  rx_queue_id,
> +						  &instance_id)) {
> +		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
> +				 " for rx_queue_id = %d", rx_queue_id);
> +		return -1;
> +	}
> +
> +	rte_tel_data_start_dict(d);
> +	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
> +	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
> +	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
> +
> +	return 0;
> +
> +error:
> +	free(l_params);
> +	return ret;
> +}
> +
>  RTE_INIT(rxa_init_telemetry)
>  {
>  	rte_telemetry_register_cmd("/eventdev/rxa_stats",
> @@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
>  	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
>  		handle_rxa_queue_stats_reset,
>  		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
> +
> +	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
> +		handle_rxa_instance_get,
> +		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
>  }
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..f56938d 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
> @@ -704,6 +705,28 @@ __rte_experimental
>  int
>  rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index
> + *
> + * @param[out] rxa_inst_id
> + *  RX adapter instance identifier.
> + *
> + * @return
> + *  - 0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
> index 1b304f0..1c9f9fc 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -1,6 +1,8 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright(c) 2018 Intel Corporation.
>   */
> +#include <limits.h>
> +
>  #include <rte_spinlock.h>
>  #include <rte_service_component.h>
>  #include <ethdev_driver.h>
> @@ -17,6 +19,11 @@
>  #define TXA_MAX_NB_TX		128
>  #define TXA_INVALID_DEV_ID	INT32_C(-1)
>  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> +#define INVALID_INSTANCE_ID	UINT8_MAX
> +
> +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> +#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
> 
>  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> 
> @@ -140,6 +147,10 @@ struct txa_service_ethdev {
>  	void *queues;
>  };
> 
> +struct event_eth_txa_inst_info {
> +	uint8_t txa_inst_id;
> +};
> +
>  /* Array of adapter instances, initialized with event device id
>   * when adapter is created
>   */
> @@ -148,6 +159,9 @@ static int *txa_dev_id_array;
>  /* Array of pointers to service implementation data */
>  static struct txa_service_data **txa_service_data_array;
> 
> +/* array of adapter instances to store tx queue specific instance */
> +static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
> +
>  static int32_t txa_service_func(void *args);
>  static int txa_service_adapter_create_ext(uint8_t id,
>  			struct rte_eventdev *dev,
> @@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
>  }
> 
>  static int
> +txa_memzone_lookup(void)
> +{
> +	const struct rte_memzone *mz;
> +
> +	if (txa_dev_id_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_dev_id_array = mz->addr;
> +	}
> +
> +	if (txa_service_data_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_service_data_array = mz->addr;
> +	}
> +
> +	if (event_eth_txa_inst_info == NULL) {
> +		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		event_eth_txa_inst_info = mz->addr;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +static int
>  txa_dev_id_array_init(void)
>  {
>  	if (txa_dev_id_array == NULL) {
>  		int i;
> 
> -		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
> +		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
>  					sizeof(int),
>  					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_dev_id_array == NULL)
> @@ -221,15 +265,30 @@ txa_init(void)
>  static int
>  txa_service_data_init(void)
>  {
> +	uint8_t i;
> +
>  	if (txa_service_data_array == NULL) {
>  		txa_service_data_array =
> -				txa_memzone_array_get("txa_service_data_array",
> +				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
>  					sizeof(int),
>  					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_service_data_array == NULL)
>  			return -ENOMEM;
>  	}
> 
> +	if (event_eth_txa_inst_info == NULL) {
> +		event_eth_txa_inst_info =
> +			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_txa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_txa_inst_info == NULL)
> +			return -ENOMEM;
> +	}
> +
> +	/* Reset the txa instance pointers */
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +		event_eth_txa_inst_info[i] = NULL;
> +
>  	return 0;
>  }
> 
> @@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
>  	struct rte_eth_dev_tx_buffer *tb;
>  	struct txa_retry *txa_retry;
>  	int ret = 0;
> +	uint16_t eth_dev_id = eth_dev->data->port_id;
> 
>  	txa = txa_service_id_to_data(id);
> 
> @@ -836,6 +896,31 @@ txa_service_queue_add(uint8_t id,
>  	tdi->nb_queues++;
>  	txa->nb_queues++;
> 
> +	/* Allocate storage to store txa_inst_id for txq */
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_txa_inst_info *i_info;
> +
> +		n = eth_dev->data->nb_tx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
> +					n * sizeof(event_eth_txa_inst_info),
> +					0,
> +					txa->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_txa_inst_info");
> +			goto err_unlock;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_txa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
> +
>  ret_unlock:
>  	rte_spinlock_unlock(&txa->tx_lock);
>  	return 0;
> @@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
>  	txa->nb_queues--;
>  	txa->txa_ethdev[port_id].nb_queues--;
> 
> +	/* unset txa_inst_id for tx_queue_id */
> +	if (event_eth_txa_inst_info[port_id])
> +		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
> +							INVALID_INSTANCE_ID;
> +
> +
>  	txa_service_queue_array_free(txa, port_id);
>  	return 0;
>  }
> @@ -1056,6 +1147,10 @@ int
>  rte_event_eth_tx_adapter_free(uint8_t id)
>  {
>  	int ret;
> +	uint16_t eth_dev_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
>  		ret = txa_service_adapter_free(id);
>  	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
> +		if (event_eth_txa_inst_info[eth_dev_id]) {
> +			rte_free(event_eth_txa_inst_info[eth_dev_id]);
> +			event_eth_txa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
>  	return ret;
>  }
> @@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
>  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
>  	return ret;
>  }
> +
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id)
> +{
> +	uint8_t inst_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (txa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
> +				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*txa_inst_id = inst_id;
> +
> +	return 0;
> +}
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
> index 3908c2d..28f4fa9 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> @@ -34,6 +34,7 @@
>   *  - rte_event_eth_tx_adapter_enqueue()
>   *  - rte_event_eth_tx_adapter_event_port_get()
>   *  - rte_event_eth_tx_adapter_service_id_get()
> + *  - rte_event_eth_tx_adapter_instance_get()
>   *
>   * The application creates the adapter using
>   * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
> @@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
>  int
>  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
> 
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Etherdev device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier
> + */
> +__rte_experimental
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> index 886e2ec..1c99d52 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -102,9 +102,11 @@ EXPERIMENTAL {
> 
>  	# added in 21.11
>  	rte_event_eth_rx_adapter_create_with_params;
> +	rte_event_eth_rx_adapter_instance_get;
>  	rte_event_eth_rx_adapter_queue_conf_get;
>  	rte_event_eth_rx_adapter_queue_stats_get;
>  	rte_event_eth_rx_adapter_queue_stats_reset;
> +	rte_event_eth_tx_adapter_instance_get;
> 
>  	# added in 22.03
>  	rte_event_eth_rx_adapter_event_port_get;
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v4] eventdev: add adapter instance get API
  2022-06-07  8:21   ` [PATCH v3] " Ganapati Kundapura
  2022-06-07 13:18     ` Jayatheerthan, Jay
@ 2022-06-07 15:13     ` Ganapati Kundapura
  2022-06-08  4:26       ` Naga Harish K, S V
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
  1 sibling, 2 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-07 15:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan

Added rte_event_eth_rx_adapter_instance_get() and
rte_event_eth_tx_adapter_instance_get() api's to get the
adapter instance id for a specified event port and
queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..a6d8987 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified event port and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..b14131d 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified event port and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..3095647 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -42,7 +43,10 @@
 /* Sentinel value to detect initialized file handle */
 #define INIT_FD		-1
 
-#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
+#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
+#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
+
+#define INVALID_INSTANCE_ID UINT8_MAX
 
 /*
  * Used to store port and queue ID of interrupting Rx queue
@@ -251,7 +255,12 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
+					      sizeof(*event_eth_rx_adapter),
+					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
+	if (event_eth_rxa_inst_info == NULL) {
+		event_eth_rxa_inst_info =
+			rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_rxa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_rxa_inst_info == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+			event_eth_rxa_inst_info[i] = NULL;
+	}
+
 	return 0;
 }
 
@@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
 	const struct rte_memzone *mz;
 
 	if (event_eth_rx_adapter == NULL) {
-		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
+		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
+	if (event_eth_rxa_inst_info == NULL) {
+		mz = rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_eth_rxa_inst_info = mz->addr;
+	}
+
 	return 0;
 }
 
@@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2605,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
@@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..f56938d 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index
+ *
+ * @param[out] rxa_inst_id
+ *  RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..d9de6e5 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
 	rte_eth_tx_buffer_set_err_callback(tb,
 		txa_service_buffer_retry, txa_retry);
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 	tqi->tx_buf = tb;
 	tqi->added = 1;
 	tdi->nb_queues++;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..28f4fa9 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..1c99d52 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -102,9 +102,11 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_event_eth_rx_adapter_create_with_params;
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v4] eventdev: add adapter instance get API
  2022-06-07 15:13     ` [PATCH v4] " Ganapati Kundapura
@ 2022-06-08  4:26       ` Naga Harish K, S V
  2022-06-08 11:22         ` Kundapura, Ganapati
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
  1 sibling, 1 reply; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-08  4:26 UTC (permalink / raw)
  To: Kundapura, Ganapati, jerinjacobk, dev, Jayatheerthan, Jay

Hi Ganapati,
   Some comments inline.

> -----Original Message-----
> From: Ganapati Kundapura <ganapati.kundapura@intel.com>
> Sent: Tuesday, June 7, 2022 8:43 PM
> To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>
> Subject: [PATCH v4] eventdev: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() and
> rte_event_eth_tx_adapter_instance_get() api's to get the adapter instance
> id for a specified event port and queue index.

It is supposed to be ethernet device id, not event port

> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
> 
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> 
> diff --git a/app/test/test_event_eth_rx_adapter.c
> b/app/test/test_event_eth_rx_adapter.c
> index e358a70..878004b 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
>  #define TEST_ETHDEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
> 
>  struct event_eth_rx_adapter_test_params {
>  	struct rte_mempool *mp;
> @@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +adapter_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong rx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_rx_queues +
> 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> +
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Add another queue */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete queues from the Rx adapter */
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
>  static struct unit_test_suite event_eth_rx_tests = {
>  	.suite_name = "rx event eth adapter test suite",
>  	.setup = testsuite_setup,
> @@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
>  			     adapter_queue_event_buf_test),
>  		TEST_CASE_ST(adapter_create_with_params, adapter_free,
>  			     adapter_queue_stats_test),
> +		TEST_CASE_ST(adapter_create, adapter_free,
> +			     adapter_instance_get),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> diff --git a/app/test/test_event_eth_tx_adapter.c
> b/app/test/test_event_eth_tx_adapter.c
> index 2900532..ebbc622 100644
> --- a/app/test/test_event_eth_tx_adapter.c
> +++ b/app/test/test_event_eth_tx_adapter.c
> @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
>  #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
>  #define SOCKET0			0
>  #define RING_SIZE		256
>  #define ETH_NAME_LEN		32
> @@ -639,6 +640,79 @@ tx_adapter_service(void)  }
> 
>  static int
> +tx_adapter_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong tx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_tx_queues +
> 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Add another queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete queues from the Tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
>  tx_adapter_dynamic_device(void)
>  {
>  	uint16_t port_id = rte_eth_dev_count_avail(); @@ -695,6 +769,8
> @@ static struct unit_test_suite event_eth_tx_tests = {
>  					tx_adapter_start_stop),
>  		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
>  					tx_adapter_service),
> +		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> +					tx_adapter_instance_get),
>  		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
> diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> index 3b4ef50..a6d8987 100644
> --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
>  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used
> to  reset queue level stats when queue level event buffer is in use.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The ``rte_event_eth_rx_adapter_instance_get()`` function reports rx
> +adapter instance id for a specified event port and rx queue index.

Same as above. Event port -> ethernet device id

> +
>  Interrupt Based Rx Queues
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> index f80d226..b14131d 100644
> --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The
> counter values are the sum of  the counts from the eventdev PMD callback if
> the callback is supported, and  the counts maintained by the service function,
> if one exists.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports tx
> +adapter instance id for a specified event port and tx queue index.
> +
>  Tx event vectorization
>  ~~~~~~~~~~~~~~~~~~~~~~
> 
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..3095647 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -6,6 +6,7 @@
>  #include <sys/epoll.h>
>  #endif
>  #include <unistd.h>
> +#include <limits.h>
> 
>  #include <rte_cycles.h>
>  #include <rte_common.h>
> @@ -42,7 +43,10 @@
>  /* Sentinel value to detect initialized file handle */
>  #define INIT_FD		-1
> 
> -#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
> +#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
> +#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
> +
> +#define INVALID_INSTANCE_ID UINT8_MAX
> 
>  /*
>   * Used to store port and queue ID of interrupting Rx queue @@ -251,7
> +255,12 @@ struct eth_rx_queue_info {
>  	struct rte_event_eth_rx_adapter_stats *stats;  };
> 
> +struct event_eth_rxa_inst_info {
> +	uint8_t rxa_inst_id;
> +};
> +
>  static struct event_eth_rx_adapter **event_eth_rx_adapter;
> +static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
> 
>  /* Enable dynamic timestamp field in mbuf */  static uint64_t
> event_eth_rx_timestamp_dynflag; @@ -1415,15 +1424,13 @@
> rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> +nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +
> 	rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
> +					      sizeof(*event_eth_rx_adapter),
> +
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i <
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
> +	if (event_eth_rxa_inst_info == NULL) {
> +		event_eth_rxa_inst_info =
> +
> 	rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_rxa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_rxa_inst_info == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +			event_eth_rxa_inst_info[i] = NULL;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
>  	const struct rte_memzone *mz;
> 
>  	if (event_eth_rx_adapter == NULL) {
> -		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> +		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> +	if (event_eth_rxa_inst_info == NULL) {
> +		mz =
> rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +
> +		event_eth_rxa_inst_info = mz->addr;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  	int pollq;
>  	int intrq;
>  	int sintrq;
> +	uint16_t eth_dev_id = dev_info->dev->data->port_id;
> 
> 
>  	if (rx_adapter->nb_queues == 0)
> @@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
>  		dev_info->rx_queue[rx_queue_id].stats = NULL;
>  	}
> +
> +	/* unset rxa_inst_id for rx_queue_id */
> +	if (event_eth_rxa_inst_info[eth_dev_id])
> +
> 	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +
> 	INVALID_INSTANCE_ID;
>  }
> 
>  static int
> @@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter
> *rx_adapter,
>  		}
>  	}
> 
> +	/* Allocate storage to store rxa_inst_id for rxq */
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_rxa_inst_info *i_info;
> +
> +		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
> +				n * sizeof(struct event_eth_rxa_inst_info),
> +				0,
> +				rx_adapter->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_rxa_inst_info");
> +			return -ENOMEM;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_rxa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
> +	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +								rx_adapter-
> >id;
> +
>  	if (!rx_adapter->use_queue_event_buf)
>  		return 0;
> 
> @@ -2523,6 +2605,10 @@ int
>  rte_event_eth_rx_adapter_free(uint8_t id)  {
>  	struct event_eth_rx_adapter *rx_adapter;
> +	uint16_t eth_dev_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> 
> @@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
>  	rte_free(rx_adapter);
>  	event_eth_rx_adapter[id] = NULL;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> +		if (event_eth_rxa_inst_info[eth_dev_id]) {
> +			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
> +			event_eth_rxa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_rx_adapter_free(id);
>  	return 0;
>  }
> @@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3386,49 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,

Indent

> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t inst_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id
> %u",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id =
> event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id
> %u, "
> +				 "rx_queue_id %u", eth_dev_id,
> rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*rxa_inst_id = inst_id;
> +
> +	return 0;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> @@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd
> __rte_unused,
>  	return ret;
>  }
> 
> +static int
> +handle_rxa_instance_get(const char *cmd __rte_unused,
> +			const char *params,
> +			struct rte_tel_data *d)
> +{
> +	uint8_t instance_id;
> +	uint16_t rx_queue_id;
> +	int eth_dev_id, ret = -1;
> +	char *token, *l_params;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	l_params = strdup(params);
> +	if (l_params == NULL)
> +		return -ENOMEM;
> +	token = strtok(l_params, ",");
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> +
> +	/* Get device ID from parameter string */
> +	eth_dev_id = strtoul(token, NULL, 10);
> +	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -
> EINVAL);
> +
> +	token = strtok(NULL, ",");
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> +
> +	/* Get Rx queue ID from parameter string */
> +	rx_queue_id = strtoul(token, NULL, 10);
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u",
> rx_queue_id);
> +		ret = -EINVAL;
> +		goto error;
> +	}
> +
> +	token = strtok(NULL, "\0");
> +	if (token != NULL)
> +		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
> +				 " telemetry command, ignoring");
> +
> +	/* Parsing parameter finished */
> +	free(l_params);
> +
> +	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						  rx_queue_id,
> +						  &instance_id)) {
> +		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
> +				 " for rx_queue_id = %d", rx_queue_id);
> +		return -1;
> +	}
> +
> +	rte_tel_data_start_dict(d);
> +	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
> +	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
> +	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
> +
> +	return 0;
> +
> +error:
> +	free(l_params);
> +	return ret;
> +}
> +
>  RTE_INIT(rxa_init_telemetry)
>  {
>  	rte_telemetry_register_cmd("/eventdev/rxa_stats",
> @@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
>  	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
>  		handle_rxa_queue_stats_reset,
>  		"Reset Rx queue stats. Parameter: rxa_id, dev_id,
> queue_id");
> +
> +	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
> +		handle_rxa_instance_get,
> +		"Returns Rx adapter instance id. Parameter: dev_id,
> queue_id");
>  }
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..f56938d 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or
> rte_event_eth_rx_adapter_create() @@ -704,6 +705,28 @@
> __rte_experimental  int
> rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index
> + *
> + * @param[out] rxa_inst_id
> + *  RX adapter instance identifier.

It is a pointer to store RX adapter instance identifier

> + *
> + * @return
> + *  - 0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c
> b/lib/eventdev/rte_event_eth_tx_adapter.c
> index 1b304f0..d9de6e5 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -1,6 +1,8 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright(c) 2018 Intel Corporation.
>   */
> +#include <limits.h>
> +
>  #include <rte_spinlock.h>
>  #include <rte_service_component.h>
>  #include <ethdev_driver.h>
> @@ -17,6 +19,11 @@
>  #define TXA_MAX_NB_TX		128
>  #define TXA_INVALID_DEV_ID	INT32_C(-1)
>  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> +#define INVALID_INSTANCE_ID	UINT8_MAX
> +
> +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> +#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
> 
>  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> 
> @@ -140,6 +147,10 @@ struct txa_service_ethdev {
>  	void *queues;
>  };
> 
> +struct event_eth_txa_inst_info {
> +	uint8_t txa_inst_id;
> +};
> +
>  /* Array of adapter instances, initialized with event device id
>   * when adapter is created
>   */
> @@ -148,6 +159,9 @@ static int *txa_dev_id_array;
>  /* Array of pointers to service implementation data */  static struct
> txa_service_data **txa_service_data_array;
> 
> +/* array of adapter instances to store tx queue specific instance */
> +static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
> +
>  static int32_t txa_service_func(void *args);  static int
> txa_service_adapter_create_ext(uint8_t id,
>  			struct rte_eventdev *dev,
> @@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name,
> unsigned int elt_size, int nb_elems)  }
> 
>  static int
> +txa_memzone_lookup(void)
> +{
> +	const struct rte_memzone *mz;
> +
> +	if (txa_dev_id_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_dev_id_array = mz->addr;
> +	}
> +
> +	if (txa_service_data_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_service_data_array = mz->addr;
> +	}
> +
> +	if (event_eth_txa_inst_info == NULL) {
> +		mz =
> rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		event_eth_txa_inst_info = mz->addr;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +static int
>  txa_dev_id_array_init(void)
>  {
>  	if (txa_dev_id_array == NULL) {
>  		int i;
> 
> -		txa_dev_id_array =
> txa_memzone_array_get("txa_adapter_array",
> +		txa_dev_id_array =
> txa_memzone_array_get(TXA_ADAPTER_ARRAY,
>  					sizeof(int),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_dev_id_array == NULL)
> @@ -221,15 +265,30 @@ txa_init(void)
>  static int
>  txa_service_data_init(void)
>  {
> +	uint8_t i;
> +
>  	if (txa_service_data_array == NULL) {
>  		txa_service_data_array =
> -
> 	txa_memzone_array_get("txa_service_data_array",
> +
> 	txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
>  					sizeof(int),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_service_data_array == NULL)
>  			return -ENOMEM;
>  	}
> 
> +	if (event_eth_txa_inst_info == NULL) {
> +		event_eth_txa_inst_info =
> +
> 	txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_txa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_txa_inst_info == NULL)
> +			return -ENOMEM;
> +	}
> +
> +	/* Reset the txa instance pointers */
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +		event_eth_txa_inst_info[i] = NULL;
> +
>  	return 0;
>  }
> 
> @@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
>  	struct rte_eth_dev_tx_buffer *tb;
>  	struct txa_retry *txa_retry;
>  	int ret = 0;
> +	uint16_t eth_dev_id = eth_dev->data->port_id;
> 
>  	txa = txa_service_id_to_data(id);
> 
> @@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
>  	rte_eth_tx_buffer_set_err_callback(tb,
>  		txa_service_buffer_retry, txa_retry);
> 
> +	/* Allocate storage to store txa_inst_id for txq */
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_txa_inst_info *i_info;
> +
> +		n = eth_dev->data->nb_tx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
> +					n * sizeof(event_eth_txa_inst_info),
> +					0,
> +					txa->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_txa_inst_info");
> +			goto err_unlock;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_txa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id =
> id;
> +
>  	tqi->tx_buf = tb;
>  	tqi->added = 1;
>  	tdi->nb_queues++;
> @@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
>  	txa->nb_queues--;
>  	txa->txa_ethdev[port_id].nb_queues--;
> 
> +	/* unset txa_inst_id for tx_queue_id */
> +	if (event_eth_txa_inst_info[port_id])
> +		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id
> =
> +
> 	INVALID_INSTANCE_ID;
> +
> +
>  	txa_service_queue_array_free(txa, port_id);
>  	return 0;
>  }
> @@ -1056,6 +1147,10 @@ int
>  rte_event_eth_tx_adapter_free(uint8_t id)  {
>  	int ret;
> +	uint16_t eth_dev_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
>  		ret = txa_service_adapter_free(id);
>  	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> +		if (event_eth_txa_inst_info[eth_dev_id]) {
> +			rte_free(event_eth_txa_inst_info[eth_dev_id]);
> +			event_eth_txa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
>  	return ret;
>  }
> @@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
>  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
>  	return ret;
>  }
> +
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id)

Indent

> +{
> +	uint8_t inst_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_tx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (txa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id
> %d",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id =
> event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id
> %u, "
> +				 "tx_queue_id %u", eth_dev_id,
> tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*txa_inst_id = inst_id;
> +
> +	return 0;
> +}
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h
> b/lib/eventdev/rte_event_eth_tx_adapter.h
> index 3908c2d..28f4fa9 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> @@ -34,6 +34,7 @@
>   *  - rte_event_eth_tx_adapter_enqueue()
>   *  - rte_event_eth_tx_adapter_event_port_get()
>   *  - rte_event_eth_tx_adapter_service_id_get()
> + *  - rte_event_eth_tx_adapter_instance_get()
>   *
>   * The application creates the adapter using
>   * rte_event_eth_tx_adapter_create() or
> rte_event_eth_tx_adapter_create_ext().
> @@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
> int  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t
> *service_id);
> 
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Etherdev device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier  */ __rte_experimental
> +int rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id);

Indent

> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> 886e2ec..1c99d52 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -102,9 +102,11 @@ EXPERIMENTAL {
> 
>  	# added in 21.11
>  	rte_event_eth_rx_adapter_create_with_params;
> +	rte_event_eth_rx_adapter_instance_get;
>  	rte_event_eth_rx_adapter_queue_conf_get;
>  	rte_event_eth_rx_adapter_queue_stats_get;
>  	rte_event_eth_rx_adapter_queue_stats_reset;
> +	rte_event_eth_tx_adapter_instance_get;
> 
>  	# added in 22.03
>  	rte_event_eth_rx_adapter_event_port_get;
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-07 15:13     ` [PATCH v4] " Ganapati Kundapura
  2022-06-08  4:26       ` Naga Harish K, S V
@ 2022-06-08 11:16       ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                           ` (6 more replies)
  1 sibling, 7 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..d1b4874 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -42,7 +43,10 @@
 /* Sentinel value to detect initialized file handle */
 #define INIT_FD		-1
 
-#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
+#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
+#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
+
+#define INVALID_INSTANCE_ID UINT8_MAX
 
 /*
  * Used to store port and queue ID of interrupting Rx queue
@@ -251,7 +255,12 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
+					      sizeof(*event_eth_rx_adapter),
+					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
+	if (event_eth_rxa_inst_info == NULL) {
+		event_eth_rxa_inst_info =
+			rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_rxa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_rxa_inst_info == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+			event_eth_rxa_inst_info[i] = NULL;
+	}
+
 	return 0;
 }
 
@@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
 	const struct rte_memzone *mz;
 
 	if (event_eth_rx_adapter == NULL) {
-		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
+		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
+	if (event_eth_rxa_inst_info == NULL) {
+		mz = rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_eth_rxa_inst_info = mz->addr;
+	}
+
 	return 0;
 }
 
@@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2605,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..f56938d 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index
+ *
+ * @param[out] rxa_inst_id
+ *  RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..f1818a2 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -102,6 +102,7 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_event_eth_rx_adapter_create_with_params;
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                           ` (5 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index d1b4874..3095647 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3697,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3718,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 3/7] test/eth_rx: add test case for instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                           ` (4 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 4/7] eventdev/eth_tx: add instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                           ` (3 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index f56938d..45140a6 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -712,10 +712,10 @@ rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
  *  Port identifier of Ethernet device.
  *
  * @param rx_queue_id
- *  Ethernet device receive queue index
+ *  Ethernet device receive queue index.
  *
  * @param[out] rxa_inst_id
- *  RX adapter instance identifier.
+ *  Pointer to store RX adapter instance identifier.
  *
  * @return
  *  - 0: Success
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..d9de6e5 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
 	rte_eth_tx_buffer_set_err_callback(tb,
 		txa_service_buffer_retry, txa_retry);
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 	tqi->tx_buf = tb;
 	tqi->added = 1;
 	tdi->nb_queues++;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..20d28a7 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index.
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to store TX adapter instance identifier.
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index f1818a2..1c99d52 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -106,6 +106,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 5/7] test/eth_tx: add testcase for instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
                           ` (2 preceding siblings ...)
  2022-06-08 11:16         ` [PATCH v5 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 6/7] doc/eth_rx: update " Ganapati Kundapura
                           ` (2 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 6/7] doc/eth_rx: update instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
                           ` (3 preceding siblings ...)
  2022-06-08 11:16         ` [PATCH v5 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 11:16         ` [PATCH v5 7/7] doc/eth_tx: " Ganapati Kundapura
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v5 7/7] doc/eth_tx: update instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
                           ` (4 preceding siblings ...)
  2022-06-08 11:16         ` [PATCH v5 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-08 11:16         ` Ganapati Kundapura
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 11:16 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..dc3e6a1 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v4] eventdev: add adapter instance get API
  2022-06-08  4:26       ` Naga Harish K, S V
@ 2022-06-08 11:22         ` Kundapura, Ganapati
  0 siblings, 0 replies; 81+ messages in thread
From: Kundapura, Ganapati @ 2022-06-08 11:22 UTC (permalink / raw)
  To: Naga Harish K, S V, jerinjacobk, dev, Jayatheerthan, Jay

Hi Harish,

> -----Original Message-----
> From: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> Sent: 08 June 2022 09:57
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>
> Subject: RE: [PATCH v4] eventdev: add adapter instance get API
> 
> Hi Ganapati,
>    Some comments inline.
> 
> > -----Original Message-----
> > From: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > Sent: Tuesday, June 7, 2022 8:43 PM
> > To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> > <jay.jayatheerthan@intel.com>
> > Subject: [PATCH v4] eventdev: add adapter instance get API
> >
> > Added rte_event_eth_rx_adapter_instance_get() and
> > rte_event_eth_tx_adapter_instance_get() api's to get the adapter
> > instance id for a specified event port and queue index.
> 
> It is supposed to be ethernet device id, not event port
Addressed in V5
> 
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > ---
> > v4:
> > * Moved instance array allocation and instance id storage
> >   before adapter's nb_queue updation for handling the
> >   error case  properly
> >
> > v3:
> > * Fixed checkpatch error
> >
> > v2:
> > * Fixed build issues
> > * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> > * arranged functions in alphabetical order in version.map
> >
> > diff --git a/app/test/test_event_eth_rx_adapter.c
> > b/app/test/test_event_eth_rx_adapter.c
> > index e358a70..878004b 100644
> > --- a/app/test/test_event_eth_rx_adapter.c
> > +++ b/app/test/test_event_eth_rx_adapter.c
> > @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
> >  #define TEST_INST_ID		0
> >  #define TEST_DEV_ID		0
> >  #define TEST_ETHDEV_ID		0
> > +#define TEST_ETH_QUEUE_ID	0
> >
> >  struct event_eth_rx_adapter_test_params {
> >  	struct rte_mempool *mp;
> > @@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
> >  	return TEST_SUCCESS;
> >  }
> >
> > +static int
> > +adapter_instance_get(void)
> > +{
> > +	int err;
> > +	uint8_t inst_id;
> > +	uint16_t eth_dev_id;
> > +	struct rte_eth_dev_info dev_info;
> > +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> > +
> > +	/* Case 1: Test without configuring eth */
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 2: Test with wrong eth port */
> > +	eth_dev_id = rte_eth_dev_count_total() + 1;
> > +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 3: Test with wrong rx queue */
> > +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    dev_info.max_rx_queues +
> > 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 4: Test with right instance, port & rxq */
> > +	/* Add queue to Rx adapter */
> > +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> > +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> > +
> > +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID,
> > +						 &queue_conf);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Add another queue */
> > +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> > +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1,
> > +						 &queue_conf);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Case 5: Test with right instance, port & wrong rxq */
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 2,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Delete queues from the Rx adapter */
> > +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	return TEST_SUCCESS;
> > +}
> > +
> >  static struct unit_test_suite event_eth_rx_tests = {
> >  	.suite_name = "rx event eth adapter test suite",
> >  	.setup = testsuite_setup,
> > @@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests =
> {
> >  			     adapter_queue_event_buf_test),
> >  		TEST_CASE_ST(adapter_create_with_params, adapter_free,
> >  			     adapter_queue_stats_test),
> > +		TEST_CASE_ST(adapter_create, adapter_free,
> > +			     adapter_instance_get),
> >  		TEST_CASES_END() /**< NULL terminate unit test array */
> >  	}
> >  };
> > diff --git a/app/test/test_event_eth_tx_adapter.c
> > b/app/test/test_event_eth_tx_adapter.c
> > index 2900532..ebbc622 100644
> > --- a/app/test/test_event_eth_tx_adapter.c
> > +++ b/app/test/test_event_eth_tx_adapter.c
> > @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
> >  #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
> >  #define TEST_INST_ID		0
> >  #define TEST_DEV_ID		0
> > +#define TEST_ETH_QUEUE_ID	0
> >  #define SOCKET0			0
> >  #define RING_SIZE		256
> >  #define ETH_NAME_LEN		32
> > @@ -639,6 +640,79 @@ tx_adapter_service(void)  }
> >
> >  static int
> > +tx_adapter_instance_get(void)
> > +{
> > +	int err;
> > +	uint8_t inst_id;
> > +	uint16_t eth_dev_id;
> > +	struct rte_eth_dev_info dev_info;
> > +
> > +	/* Case 1: Test without configuring eth */
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 2: Test with wrong eth port */
> > +	eth_dev_id = rte_eth_dev_count_total() + 1;
> > +	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 3: Test with wrong tx queue */
> > +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    dev_info.max_tx_queues +
> > 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 4: Test with right instance, port & rxq */
> > +	/* Add queue to tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Add another queue to tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Case 5: Test with right instance, port & wrong rxq */
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 2,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Delete queues from the Tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	return TEST_SUCCESS;
> > +}
> > +
> > +static int
> >  tx_adapter_dynamic_device(void)
> >  {
> >  	uint16_t port_id = rte_eth_dev_count_avail(); @@ -695,6 +769,8
> @@
> > static struct unit_test_suite event_eth_tx_tests = {
> >  					tx_adapter_start_stop),
> >  		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> >  					tx_adapter_service),
> > +		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> > +					tx_adapter_instance_get),
> >  		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
> >  		TEST_CASES_END() /**< NULL terminate unit test array */
> >  	}
> > diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > index 3b4ef50..a6d8987 100644
> > --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
> >  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be
> > used to  reset queue level stats when queue level event buffer is in use.
> >
> > +Getting Adapter instance id
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +The ``rte_event_eth_rx_adapter_instance_get()`` function reports rx
> > +adapter instance id for a specified event port and rx queue index.
> 
> Same as above. Event port -> ethernet device id
Addressed in V5
> 
> > +
> >  Interrupt Based Rx Queues
> >  ~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > index f80d226..b14131d 100644
> > --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The
> > counter values are the sum of  the counts from the eventdev PMD
> > callback if the callback is supported, and  the counts maintained by
> > the service function, if one exists.
> >
> > +Getting Adapter instance id
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports tx
> > +adapter instance id for a specified event port and tx queue index.
> > +
> >  Tx event vectorization
> >  ~~~~~~~~~~~~~~~~~~~~~~
> >
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > index bf8741d..3095647 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > @@ -6,6 +6,7 @@
> >  #include <sys/epoll.h>
> >  #endif
> >  #include <unistd.h>
> > +#include <limits.h>
> >
> >  #include <rte_cycles.h>
> >  #include <rte_common.h>
> > @@ -42,7 +43,10 @@
> >  /* Sentinel value to detect initialized file handle */
> >  #define INIT_FD		-1
> >
> > -#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
> > +#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
> > +#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
> > +
> > +#define INVALID_INSTANCE_ID UINT8_MAX
> >
> >  /*
> >   * Used to store port and queue ID of interrupting Rx queue @@ -251,7
> > +255,12 @@ struct eth_rx_queue_info {
> >  	struct rte_event_eth_rx_adapter_stats *stats;  };
> >
> > +struct event_eth_rxa_inst_info {
> > +	uint8_t rxa_inst_id;
> > +};
> > +
> >  static struct event_eth_rx_adapter **event_eth_rx_adapter;
> > +static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
> >
> >  /* Enable dynamic timestamp field in mbuf */  static uint64_t
> > event_eth_rx_timestamp_dynflag; @@ -1415,15 +1424,13 @@
> > rxa_service_func(void *args)
> >  	return 0;
> >  }
> >
> > -static int
> > -rte_event_eth_rx_adapter_init(void)
> > +static void *
> > +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> > +nb_elems)
> >  {
> > -	const char *name = RXA_ADAPTER_ARRAY;
> >  	const struct rte_memzone *mz;
> >  	unsigned int sz;
> >
> > -	sz = sizeof(*event_eth_rx_adapter) *
> > -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > +	sz = elt_size * nb_elems;
> >  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> >
> >  	mz = rte_memzone_lookup(name);
> > @@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
> >  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
> >  						 RTE_CACHE_LINE_SIZE);
> >  		if (mz == NULL) {
> > -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> > = %"
> > -					PRId32, rte_errno);
> > -			return -rte_errno;
> > +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> > +					 " name = %s, err = %"
> > +					 PRId32, name, rte_errno);
> > +			return NULL;
> >  		}
> >  	}
> >
> > -	event_eth_rx_adapter = mz->addr;
> > +	return mz->addr;
> > +}
> > +
> > +static int
> > +rte_event_eth_rx_adapter_init(void)
> > +{
> > +	uint8_t i;
> > +
> > +	if (event_eth_rx_adapter == NULL) {
> > +		event_eth_rx_adapter =
> > +
> > 	rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
> > +					      sizeof(*event_eth_rx_adapter),
> > +
> > RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> > +		if (event_eth_rx_adapter == NULL)
> > +			return -ENOMEM;
> > +
> > +		for (i = 0; i <
> > RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> > +			event_eth_rx_adapter[i] = NULL;
> > +
> > +	}
> > +
> > +	if (event_eth_rxa_inst_info == NULL) {
> > +		event_eth_rxa_inst_info =
> > +
> > 	rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
> > +					      sizeof(*event_eth_rxa_inst_info),
> > +					      RTE_MAX_ETHPORTS);
> > +		if (event_eth_rxa_inst_info == NULL)
> > +			return -ENOMEM;
> > +
> > +		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> > +			event_eth_rxa_inst_info[i] = NULL;
> > +	}
> > +
> >  	return 0;
> >  }
> >
> > @@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
> >  	const struct rte_memzone *mz;
> >
> >  	if (event_eth_rx_adapter == NULL) {
> > -		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> > +		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
> >  		if (mz == NULL)
> >  			return -ENOMEM;
> > +
> >  		event_eth_rx_adapter = mz->addr;
> >  	}
> >
> > +	if (event_eth_rxa_inst_info == NULL) {
> > +		mz =
> > rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +
> > +		event_eth_rxa_inst_info = mz->addr;
> > +	}
> > +
> >  	return 0;
> >  }
> >
> > @@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter
> > *rx_adapter,
> >  	int pollq;
> >  	int intrq;
> >  	int sintrq;
> > +	uint16_t eth_dev_id = dev_info->dev->data->port_id;
> >
> >
> >  	if (rx_adapter->nb_queues == 0)
> > @@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter
> > *rx_adapter,
> >  		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
> >  		dev_info->rx_queue[rx_queue_id].stats = NULL;
> >  	}
> > +
> > +	/* unset rxa_inst_id for rx_queue_id */
> > +	if (event_eth_rxa_inst_info[eth_dev_id])
> > +
> > 	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> > +
> > 	INVALID_INSTANCE_ID;
> >  }
> >
> >  static int
> > @@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter
> > *rx_adapter,
> >  		}
> >  	}
> >
> > +	/* Allocate storage to store rxa_inst_id for rxq */
> > +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> > +		uint16_t n, i;
> > +		struct event_eth_rxa_inst_info *i_info;
> > +
> > +		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
> > +
> > +		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
> > +				n * sizeof(struct event_eth_rxa_inst_info),
> > +				0,
> > +				rx_adapter->socket_id);
> > +		if (i_info == NULL) {
> > +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> > +					 "event_eth_rxa_inst_info");
> > +			return -ENOMEM;
> > +		}
> > +
> > +		for (i = 0; i < n; i++)
> > +			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
> > +
> > +		event_eth_rxa_inst_info[eth_dev_id] = i_info;
> > +	}
> > +
> > +	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
> > +	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> > +								rx_adapter-
> > >id;
> > +
> >  	if (!rx_adapter->use_queue_event_buf)
> >  		return 0;
> >
> > @@ -2523,6 +2605,10 @@ int
> >  rte_event_eth_rx_adapter_free(uint8_t id)  {
> >  	struct event_eth_rx_adapter *rx_adapter;
> > +	uint16_t eth_dev_id;
> > +
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> >
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >
> > @@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
> >  	rte_free(rx_adapter);
> >  	event_eth_rx_adapter[id] = NULL;
> >
> > +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> > eth_dev_id++) {
> > +		if (event_eth_rxa_inst_info[eth_dev_id]) {
> > +			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
> > +			event_eth_rxa_inst_info[eth_dev_id] = NULL;
> > +		}
> > +	}
> > +
> >  	rte_eventdev_trace_eth_rx_adapter_free(id);
> >  	return 0;
> >  }
> > @@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t
> id,
> >  	struct eth_device_info *dev_info;
> >  	struct rte_event_eth_rx_adapter_vector_limits limits;
> >
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id,
> > uint16_t eth_dev_id,
> >  	uint32_t *rx_wrr = NULL;
> >  	int num_intr_vec;
> >
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id,
> > uint16_t eth_dev_id,
> >
> >  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
> >  		rx_queue_id, ret);
> > +
> >  	return ret;
> >  }
> >
> > @@ -3286,6 +3386,49 @@
> > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> >  	return 0;
> >  }
> >
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t rx_queue_id,
> 
> Indent
Indent is proper in terminal without any .vmrc settings
> 
> > +				      uint8_t *rxa_inst_id)
> > +{
> > +	uint8_t inst_id;
> > +
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> > +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> > eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> > >nb_rx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (rxa_inst_id == NULL) {
> > +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> > +		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id
> > %u",
> > +				 eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	inst_id =
> > event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
> > +	if (inst_id == INVALID_INSTANCE_ID) {
> > +		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id
> > %u, "
> > +				 "rx_queue_id %u", eth_dev_id,
> > rx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	*rxa_inst_id = inst_id;
> > +
> > +	return 0;
> > +}
> > +
> >  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s,
> > stats.s)
> >
> >  static int
> > @@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char
> *cmd
> > __rte_unused,
> >  	return ret;
> >  }
> >
> > +static int
> > +handle_rxa_instance_get(const char *cmd __rte_unused,
> > +			const char *params,
> > +			struct rte_tel_data *d)
> > +{
> > +	uint8_t instance_id;
> > +	uint16_t rx_queue_id;
> > +	int eth_dev_id, ret = -1;
> > +	char *token, *l_params;
> > +
> > +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> > +		return -1;
> > +
> > +	l_params = strdup(params);
> > +	if (l_params == NULL)
> > +		return -ENOMEM;
> > +	token = strtok(l_params, ",");
> > +
> > 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> > token, -1);
> > +
> > +	/* Get device ID from parameter string */
> > +	eth_dev_id = strtoul(token, NULL, 10);
> > +	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -
> > EINVAL);
> > +
> > +	token = strtok(NULL, ",");
> > +
> > 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> > token, -1);
> > +
> > +	/* Get Rx queue ID from parameter string */
> > +	rx_queue_id = strtoul(token, NULL, 10);
> > +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> > >nb_rx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u",
> > rx_queue_id);
> > +		ret = -EINVAL;
> > +		goto error;
> > +	}
> > +
> > +	token = strtok(NULL, "\0");
> > +	if (token != NULL)
> > +		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
> > +				 " telemetry command, ignoring");
> > +
> > +	/* Parsing parameter finished */
> > +	free(l_params);
> > +
> > +	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> > +						  rx_queue_id,
> > +						  &instance_id)) {
> > +		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
> > +				 " for rx_queue_id = %d", rx_queue_id);
> > +		return -1;
> > +	}
> > +
> > +	rte_tel_data_start_dict(d);
> > +	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
> > +	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
> > +	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
> > +
> > +	return 0;
> > +
> > +error:
> > +	free(l_params);
> > +	return ret;
> > +}
> > +
> >  RTE_INIT(rxa_init_telemetry)
> >  {
> >  	rte_telemetry_register_cmd("/eventdev/rxa_stats",
> > @@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
> >  	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
> >  		handle_rxa_queue_stats_reset,
> >  		"Reset Rx queue stats. Parameter: rxa_id, dev_id,
> queue_id");
> > +
> > +	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
> > +		handle_rxa_instance_get,
> > +		"Returns Rx adapter instance id. Parameter: dev_id,
> > queue_id");
> >  }
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> > b/lib/eventdev/rte_event_eth_rx_adapter.h
> > index 3608a7b..f56938d 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> > @@ -38,6 +38,7 @@
> >   *  - rte_event_eth_rx_adapter_queue_stats_get()
> >   *  - rte_event_eth_rx_adapter_queue_stats_reset()
> >   *  - rte_event_eth_rx_adapter_event_port_get()
> > + *  - rte_event_eth_rx_adapter_instance_get()
> >   *
> >   * The application creates an ethernet to event adapter using
> >   * rte_event_eth_rx_adapter_create_ext() or
> > rte_event_eth_rx_adapter_create() @@ -704,6 +705,28 @@
> > __rte_experimental  int
> > rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> > *event_port_id);
> >
> > +/**
> > + * Get RX adapter instance ID for a RX queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of Ethernet device.
> > + *
> > + * @param rx_queue_id
> > + *  Ethernet device receive queue index
> > + *
> > + * @param[out] rxa_inst_id
> > + *  RX adapter instance identifier.
> 
> It is a pointer to store RX adapter instance identifier
Addressed in V5
> 
> > + *
> > + * @return
> > + *  - 0: Success
> > + *  - <0: Error code on failure
> > + */
> > +__rte_experimental
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t rx_queue_id,
> > +				      uint8_t *rxa_inst_id);
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c
> > b/lib/eventdev/rte_event_eth_tx_adapter.c
> > index 1b304f0..d9de6e5 100644
> > --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> > @@ -1,6 +1,8 @@
> >  /* SPDX-License-Identifier: BSD-3-Clause
> >   * Copyright(c) 2018 Intel Corporation.
> >   */
> > +#include <limits.h>
> > +
> >  #include <rte_spinlock.h>
> >  #include <rte_service_component.h>
> >  #include <ethdev_driver.h>
> > @@ -17,6 +19,11 @@
> >  #define TXA_MAX_NB_TX		128
> >  #define TXA_INVALID_DEV_ID	INT32_C(-1)
> >  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> > +#define INVALID_INSTANCE_ID	UINT8_MAX
> > +
> > +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> > +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> > +#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
> >
> >  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> >
> > @@ -140,6 +147,10 @@ struct txa_service_ethdev {
> >  	void *queues;
> >  };
> >
> > +struct event_eth_txa_inst_info {
> > +	uint8_t txa_inst_id;
> > +};
> > +
> >  /* Array of adapter instances, initialized with event device id
> >   * when adapter is created
> >   */
> > @@ -148,6 +159,9 @@ static int *txa_dev_id_array;
> >  /* Array of pointers to service implementation data */  static struct
> > txa_service_data **txa_service_data_array;
> >
> > +/* array of adapter instances to store tx queue specific instance */
> > +static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
> > +
> >  static int32_t txa_service_func(void *args);  static int
> > txa_service_adapter_create_ext(uint8_t id,
> >  			struct rte_eventdev *dev,
> > @@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name,
> unsigned
> > int elt_size, int nb_elems)  }
> >
> >  static int
> > +txa_memzone_lookup(void)
> > +{
> > +	const struct rte_memzone *mz;
> > +
> > +	if (txa_dev_id_array == NULL) {
> > +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		txa_dev_id_array = mz->addr;
> > +	}
> > +
> > +	if (txa_service_data_array == NULL) {
> > +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		txa_service_data_array = mz->addr;
> > +	}
> > +
> > +	if (event_eth_txa_inst_info == NULL) {
> > +		mz =
> > rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		event_eth_txa_inst_info = mz->addr;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +
> > +static int
> >  txa_dev_id_array_init(void)
> >  {
> >  	if (txa_dev_id_array == NULL) {
> >  		int i;
> >
> > -		txa_dev_id_array =
> > txa_memzone_array_get("txa_adapter_array",
> > +		txa_dev_id_array =
> > txa_memzone_array_get(TXA_ADAPTER_ARRAY,
> >  					sizeof(int),
> >
> > 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
> >  		if (txa_dev_id_array == NULL)
> > @@ -221,15 +265,30 @@ txa_init(void)
> >  static int
> >  txa_service_data_init(void)
> >  {
> > +	uint8_t i;
> > +
> >  	if (txa_service_data_array == NULL) {
> >  		txa_service_data_array =
> > -
> > 	txa_memzone_array_get("txa_service_data_array",
> > +
> > 	txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
> >  					sizeof(int),
> >
> > 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
> >  		if (txa_service_data_array == NULL)
> >  			return -ENOMEM;
> >  	}
> >
> > +	if (event_eth_txa_inst_info == NULL) {
> > +		event_eth_txa_inst_info =
> > +
> > 	txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
> > +					      sizeof(*event_eth_txa_inst_info),
> > +					      RTE_MAX_ETHPORTS);
> > +		if (event_eth_txa_inst_info == NULL)
> > +			return -ENOMEM;
> > +	}
> > +
> > +	/* Reset the txa instance pointers */
> > +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> > +		event_eth_txa_inst_info[i] = NULL;
> > +
> >  	return 0;
> >  }
> >
> > @@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
> >  	struct rte_eth_dev_tx_buffer *tb;
> >  	struct txa_retry *txa_retry;
> >  	int ret = 0;
> > +	uint16_t eth_dev_id = eth_dev->data->port_id;
> >
> >  	txa = txa_service_id_to_data(id);
> >
> > @@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
> >  	rte_eth_tx_buffer_set_err_callback(tb,
> >  		txa_service_buffer_retry, txa_retry);
> >
> > +	/* Allocate storage to store txa_inst_id for txq */
> > +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> > +		uint16_t n, i;
> > +		struct event_eth_txa_inst_info *i_info;
> > +
> > +		n = eth_dev->data->nb_tx_queues;
> > +
> > +		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
> > +					n * sizeof(event_eth_txa_inst_info),
> > +					0,
> > +					txa->socket_id);
> > +		if (i_info == NULL) {
> > +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> > +					 "event_eth_txa_inst_info");
> > +			goto err_unlock;
> > +		}
> > +
> > +		for (i = 0; i < n; i++)
> > +			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
> > +
> > +		event_eth_txa_inst_info[eth_dev_id] = i_info;
> > +	}
> > +
> > +	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id =
> > id;
> > +
> >  	tqi->tx_buf = tb;
> >  	tqi->added = 1;
> >  	tdi->nb_queues++;
> > @@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
> >  	txa->nb_queues--;
> >  	txa->txa_ethdev[port_id].nb_queues--;
> >
> > +	/* unset txa_inst_id for tx_queue_id */
> > +	if (event_eth_txa_inst_info[port_id])
> > +		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id
> > =
> > +
> > 	INVALID_INSTANCE_ID;
> > +
> > +
> >  	txa_service_queue_array_free(txa, port_id);
> >  	return 0;
> >  }
> > @@ -1056,6 +1147,10 @@ int
> >  rte_event_eth_tx_adapter_free(uint8_t id)  {
> >  	int ret;
> > +	uint16_t eth_dev_id;
> > +
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> >
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
> >  		ret = txa_service_adapter_free(id);
> >  	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
> >
> > +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> > eth_dev_id++) {
> > +		if (event_eth_txa_inst_info[eth_dev_id]) {
> > +			rte_free(event_eth_txa_inst_info[eth_dev_id]);
> > +			event_eth_txa_inst_info[eth_dev_id] = NULL;
> > +		}
> > +	}
> > +
> >  	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
> >  	return ret;
> >  }
> > @@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t
> id,
> >  	int ret;
> >  	uint32_t caps;
> >
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t
> id,
> >  	int ret;
> >  	uint32_t caps;
> >
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
> >  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
> >  	return ret;
> >  }
> > +
> > +int
> > +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t tx_queue_id,
> > +				      uint8_t *txa_inst_id)
> 
> Indent
Indent is proper in my terminal without any settings in .vmrc
> 
> > +{
> > +	uint8_t inst_id;
> > +
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> > +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> > eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data-
> > >nb_tx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (txa_inst_id == NULL) {
> > +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> > +		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id
> > %d",
> > +				 eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	inst_id =
> > event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
> > +	if (inst_id == INVALID_INSTANCE_ID) {
> > +		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id
> > %u, "
> > +				 "tx_queue_id %u", eth_dev_id,
> > tx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	*txa_inst_id = inst_id;
> > +
> > +	return 0;
> > +}
> > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h
> > b/lib/eventdev/rte_event_eth_tx_adapter.h
> > index 3908c2d..28f4fa9 100644
> > --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> > +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> > @@ -34,6 +34,7 @@
> >   *  - rte_event_eth_tx_adapter_enqueue()
> >   *  - rte_event_eth_tx_adapter_event_port_get()
> >   *  - rte_event_eth_tx_adapter_service_id_get()
> > + *  - rte_event_eth_tx_adapter_instance_get()
> >   *
> >   * The application creates the adapter using
> >   * rte_event_eth_tx_adapter_create() or
> > rte_event_eth_tx_adapter_create_ext().
> > @@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t
> id);
> > int  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t
> > *service_id);
> >
> > +/**
> > + * Get TX adapter instance id for TX queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of Ethernet device
> > + *
> > + * @param tx_queue_id
> > + *  Etherdev device TX queue index
> > + *
> > + * @param[out] txa_inst_id
> > + *  Pointer to TX adapter instance identifier  */ __rte_experimental
> > +int rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t tx_queue_id,
> > +				      uint8_t *txa_inst_id);
> 
> Indent
Indent is proper in my terminal without any settings in .vmrc
> 
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> > 886e2ec..1c99d52 100644
> > --- a/lib/eventdev/version.map
> > +++ b/lib/eventdev/version.map
> > @@ -102,9 +102,11 @@ EXPERIMENTAL {
> >
> >  	# added in 21.11
> >  	rte_event_eth_rx_adapter_create_with_params;
> > +	rte_event_eth_rx_adapter_instance_get;
> >  	rte_event_eth_rx_adapter_queue_conf_get;
> >  	rte_event_eth_rx_adapter_queue_stats_get;
> >  	rte_event_eth_rx_adapter_queue_stats_reset;
> > +	rte_event_eth_tx_adapter_instance_get;
> >
> >  	# added in 22.03
> >  	rte_event_eth_rx_adapter_event_port_get;
> > --
> > 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v3] eventdev: add adapter instance get API
  2022-06-07 13:18     ` Jayatheerthan, Jay
@ 2022-06-08 11:23       ` Kundapura, Ganapati
  0 siblings, 0 replies; 81+ messages in thread
From: Kundapura, Ganapati @ 2022-06-08 11:23 UTC (permalink / raw)
  To: Jayatheerthan, Jay, jerinjacobk, dev

Hi Jay,
   Patch is split into 7 patch sets in V5 as suggested.

Thanks,
Ganapati

> -----Original Message-----
> From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Sent: 07 June 2022 18:49
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> jerinjacobk@gmail.com; dev@dpdk.org
> Subject: RE: [PATCH v3] eventdev: add adapter instance get API
> 
> Hi Ganapati,
> This patch could be split into multiple patches in a patchset to make it easier
> to review.
> 
> One way to split:
> 1. Rx adapter API
> 2. Telemetry changes for Rx adapter
> 3. Test changes for Rx adapter API
> 4. Tx adapter API
> 5. Telemetry changes for Tx adapter ?
> 6. Test changes for Tx adapter API
> 7. Document update.
> 
> -Jay
> 
> 
> > -----Original Message-----
> > From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > Sent: Tuesday, June 7, 2022 1:51 PM
> > To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> > <jay.jayatheerthan@intel.com>
> > Subject: [PATCH v3] eventdev: add adapter instance get API
> >
> > Added rte_event_eth_rx_adapter_instance_get() and
> > rte_event_eth_tx_adapter_instance_get() api's to get the adapter
> > instance id for a specified event port and queue index.
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > ---
> > v3:
> > * Fixed checkpatch error
> >
> > v2:
> > * Fixed build issues
> > * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> > * arranged functions in alphabetical order in version.map
> >
> > diff --git a/app/test/test_event_eth_rx_adapter.c
> > b/app/test/test_event_eth_rx_adapter.c
> > index e358a70..878004b 100644
> > --- a/app/test/test_event_eth_rx_adapter.c
> > +++ b/app/test/test_event_eth_rx_adapter.c
> > @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
> >  #define TEST_INST_ID		0
> >  #define TEST_DEV_ID		0
> >  #define TEST_ETHDEV_ID		0
> > +#define TEST_ETH_QUEUE_ID	0
> >
> >  struct event_eth_rx_adapter_test_params {
> >  	struct rte_mempool *mp;
> > @@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
> >  	return TEST_SUCCESS;
> >  }
> >
> > +static int
> > +adapter_instance_get(void)
> > +{
> > +	int err;
> > +	uint8_t inst_id;
> > +	uint16_t eth_dev_id;
> > +	struct rte_eth_dev_info dev_info;
> > +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> > +
> > +	/* Case 1: Test without configuring eth */
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 2: Test with wrong eth port */
> > +	eth_dev_id = rte_eth_dev_count_total() + 1;
> > +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 3: Test with wrong rx queue */
> > +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    dev_info.max_rx_queues +
> 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 4: Test with right instance, port & rxq */
> > +	/* Add queue to Rx adapter */
> > +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> > +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> > +
> > +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID,
> > +						 &queue_conf);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Add another queue */
> > +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> > +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1,
> > +						 &queue_conf);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Case 5: Test with right instance, port & wrong rxq */
> > +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 2,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Delete queues from the Rx adapter */
> > +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	return TEST_SUCCESS;
> > +}
> > +
> >  static struct unit_test_suite event_eth_rx_tests = {
> >  	.suite_name = "rx event eth adapter test suite",
> >  	.setup = testsuite_setup,
> > @@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests =
> {
> >  			     adapter_queue_event_buf_test),
> >  		TEST_CASE_ST(adapter_create_with_params, adapter_free,
> >  			     adapter_queue_stats_test),
> > +		TEST_CASE_ST(adapter_create, adapter_free,
> > +			     adapter_instance_get),
> >  		TEST_CASES_END() /**< NULL terminate unit test array */
> >  	}
> >  };
> > diff --git a/app/test/test_event_eth_tx_adapter.c
> > b/app/test/test_event_eth_tx_adapter.c
> > index 2900532..ebbc622 100644
> > --- a/app/test/test_event_eth_tx_adapter.c
> > +++ b/app/test/test_event_eth_tx_adapter.c
> > @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
> >  #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
> >  #define TEST_INST_ID		0
> >  #define TEST_DEV_ID		0
> > +#define TEST_ETH_QUEUE_ID	0
> >  #define SOCKET0			0
> >  #define RING_SIZE		256
> >  #define ETH_NAME_LEN		32
> > @@ -639,6 +640,79 @@ tx_adapter_service(void)  }
> >
> >  static int
> > +tx_adapter_instance_get(void)
> > +{
> > +	int err;
> > +	uint8_t inst_id;
> > +	uint16_t eth_dev_id;
> > +	struct rte_eth_dev_info dev_info;
> > +
> > +	/* Case 1: Test without configuring eth */
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 2: Test with wrong eth port */
> > +	eth_dev_id = rte_eth_dev_count_total() + 1;
> > +	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 3: Test with wrong tx queue */
> > +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    dev_info.max_tx_queues +
> 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Case 4: Test with right instance, port & rxq */
> > +	/* Add queue to tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Add another queue to tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 1,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	/* Case 5: Test with right instance, port & wrong rxq */
> > +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> > +						    TEST_ETH_QUEUE_ID + 2,
> > +						    &inst_id);
> > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > +
> > +	/* Delete queues from the Tx adapter */
> > +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> > +						 TEST_ETHDEV_ID,
> > +						 TEST_ETH_QUEUE_ID + 1);
> > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > +
> > +	return TEST_SUCCESS;
> > +}
> > +
> > +static int
> >  tx_adapter_dynamic_device(void)
> >  {
> >  	uint16_t port_id = rte_eth_dev_count_avail(); @@ -695,6 +769,8
> @@
> > static struct unit_test_suite event_eth_tx_tests = {
> >  					tx_adapter_start_stop),
> >  		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> >  					tx_adapter_service),
> > +		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> > +					tx_adapter_instance_get),
> >  		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
> >  		TEST_CASES_END() /**< NULL terminate unit test array */
> >  	}
> > diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > index 3b4ef50..a6d8987 100644
> > --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> > @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
> >  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be
> > used to  reset queue level stats when queue level event buffer is in use.
> >
> > +Getting Adapter instance id
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +The ``rte_event_eth_rx_adapter_instance_get()`` function reports rx
> > +adapter instance id for a specified event port and rx queue index.
> > +
> >  Interrupt Based Rx Queues
> >  ~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > index f80d226..b14131d 100644
> > --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> > @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The
> > counter values are the sum of  the counts from the eventdev PMD
> > callback if the callback is supported, and  the counts maintained by the
> service function, if one exists.
> >
> > +Getting Adapter instance id
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports tx
> > +adapter instance id for a specified event port and tx queue index.
> > +
> >  Tx event vectorization
> >  ~~~~~~~~~~~~~~~~~~~~~~
> >
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > index bf8741d..3095647 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > @@ -6,6 +6,7 @@
> >  #include <sys/epoll.h>
> >  #endif
> >  #include <unistd.h>
> > +#include <limits.h>
> >
> >  #include <rte_cycles.h>
> >  #include <rte_common.h>
> > @@ -42,7 +43,10 @@
> >  /* Sentinel value to detect initialized file handle */
> >  #define INIT_FD		-1
> >
> > -#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
> > +#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
> > +#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
> > +
> > +#define INVALID_INSTANCE_ID UINT8_MAX
> >
> >  /*
> >   * Used to store port and queue ID of interrupting Rx queue @@ -251,7
> > +255,12 @@ struct eth_rx_queue_info {
> >  	struct rte_event_eth_rx_adapter_stats *stats;  };
> >
> > +struct event_eth_rxa_inst_info {
> > +	uint8_t rxa_inst_id;
> > +};
> > +
> >  static struct event_eth_rx_adapter **event_eth_rx_adapter;
> > +static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
> >
> >  /* Enable dynamic timestamp field in mbuf */  static uint64_t
> > event_eth_rx_timestamp_dynflag; @@ -1415,15 +1424,13 @@
> > rxa_service_func(void *args)
> >  	return 0;
> >  }
> >
> > -static int
> > -rte_event_eth_rx_adapter_init(void)
> > +static void *
> > +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> > +nb_elems)
> >  {
> > -	const char *name = RXA_ADAPTER_ARRAY;
> >  	const struct rte_memzone *mz;
> >  	unsigned int sz;
> >
> > -	sz = sizeof(*event_eth_rx_adapter) *
> > -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > +	sz = elt_size * nb_elems;
> >  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> >
> >  	mz = rte_memzone_lookup(name);
> > @@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
> >  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
> >  						 RTE_CACHE_LINE_SIZE);
> >  		if (mz == NULL) {
> > -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> = %"
> > -					PRId32, rte_errno);
> > -			return -rte_errno;
> > +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> > +					 " name = %s, err = %"
> > +					 PRId32, name, rte_errno);
> > +			return NULL;
> >  		}
> >  	}
> >
> > -	event_eth_rx_adapter = mz->addr;
> > +	return mz->addr;
> > +}
> > +
> > +static int
> > +rte_event_eth_rx_adapter_init(void)
> > +{
> > +	uint8_t i;
> > +
> > +	if (event_eth_rx_adapter == NULL) {
> > +		event_eth_rx_adapter =
> > +
> 	rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
> > +					      sizeof(*event_eth_rx_adapter),
> > +
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> > +		if (event_eth_rx_adapter == NULL)
> > +			return -ENOMEM;
> > +
> > +		for (i = 0; i <
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> > +			event_eth_rx_adapter[i] = NULL;
> > +
> > +	}
> > +
> > +	if (event_eth_rxa_inst_info == NULL) {
> > +		event_eth_rxa_inst_info =
> > +
> 	rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
> > +					      sizeof(*event_eth_rxa_inst_info),
> > +					      RTE_MAX_ETHPORTS);
> > +		if (event_eth_rxa_inst_info == NULL)
> > +			return -ENOMEM;
> > +
> > +		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> > +			event_eth_rxa_inst_info[i] = NULL;
> > +	}
> > +
> >  	return 0;
> >  }
> >
> > @@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
> >  	const struct rte_memzone *mz;
> >
> >  	if (event_eth_rx_adapter == NULL) {
> > -		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> > +		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
> >  		if (mz == NULL)
> >  			return -ENOMEM;
> > +
> >  		event_eth_rx_adapter = mz->addr;
> >  	}
> >
> > +	if (event_eth_rxa_inst_info == NULL) {
> > +		mz =
> rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +
> > +		event_eth_rxa_inst_info = mz->addr;
> > +	}
> > +
> >  	return 0;
> >  }
> >
> > @@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
> >  	int pollq;
> >  	int intrq;
> >  	int sintrq;
> > +	uint16_t eth_dev_id = dev_info->dev->data->port_id;
> >
> >
> >  	if (rx_adapter->nb_queues == 0)
> > @@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
> >  		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
> >  		dev_info->rx_queue[rx_queue_id].stats = NULL;
> >  	}
> > +
> > +	/* unset rxa_inst_id for rx_queue_id */
> > +	if (event_eth_rxa_inst_info[eth_dev_id])
> > +
> 	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> > +
> 	INVALID_INSTANCE_ID;
> >  }
> >
> >  static int
> > @@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter
> *rx_adapter,
> >  		}
> >  	}
> >
> > +	/* Allocate storage to store rxa_inst_id for rxq */
> > +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> > +		uint16_t n, i;
> > +		struct event_eth_rxa_inst_info *i_info;
> > +
> > +		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
> > +
> > +		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
> > +				n * sizeof(struct event_eth_rxa_inst_info),
> > +				0,
> > +				rx_adapter->socket_id);
> > +		if (i_info == NULL) {
> > +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> > +					 "event_eth_rxa_inst_info");
> > +			return -ENOMEM;
> > +		}
> > +
> > +		for (i = 0; i < n; i++)
> > +			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
> > +
> > +		event_eth_rxa_inst_info[eth_dev_id] = i_info;
> > +	}
> > +
> > +	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
> > +	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> > +								rx_adapter-
> >id;
> > +
> >  	if (!rx_adapter->use_queue_event_buf)
> >  		return 0;
> >
> > @@ -2523,6 +2605,10 @@ int
> >  rte_event_eth_rx_adapter_free(uint8_t id)  {
> >  	struct event_eth_rx_adapter *rx_adapter;
> > +	uint16_t eth_dev_id;
> > +
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> >
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >
> > @@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
> >  	rte_free(rx_adapter);
> >  	event_eth_rx_adapter[id] = NULL;
> >
> > +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> > +		if (event_eth_rxa_inst_info[eth_dev_id]) {
> > +			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
> > +			event_eth_rxa_inst_info[eth_dev_id] = NULL;
> > +		}
> > +	}
> > +
> >  	rte_eventdev_trace_eth_rx_adapter_free(id);
> >  	return 0;
> >  }
> > @@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t
> id,
> >  	struct eth_device_info *dev_info;
> >  	struct rte_event_eth_rx_adapter_vector_limits limits;
> >
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id, uint16_t eth_dev_id,
> >  	uint32_t *rx_wrr = NULL;
> >  	int num_intr_vec;
> >
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id,
> > uint16_t eth_dev_id,
> >
> >  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
> >  		rx_queue_id, ret);
> > +
> >  	return ret;
> >  }
> >
> > @@ -3286,6 +3386,49 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> >  	return 0;
> >  }
> >
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t rx_queue_id,
> > +				      uint8_t *rxa_inst_id)
> > +{
> > +	uint8_t inst_id;
> > +
> > +	if (rxa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> > +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (rxa_inst_id == NULL) {
> > +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> > +		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id
> %u",
> > +				 eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	inst_id =
> event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
> > +	if (inst_id == INVALID_INSTANCE_ID) {
> > +		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id
> %u, "
> > +				 "rx_queue_id %u", eth_dev_id,
> rx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	*rxa_inst_id = inst_id;
> > +
> > +	return 0;
> > +}
> > +
> >  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s,
> > stats.s)
> >
> >  static int
> > @@ -3554,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char
> *cmd __rte_unused,
> >  	return ret;
> >  }
> >
> > +static int
> > +handle_rxa_instance_get(const char *cmd __rte_unused,
> > +			const char *params,
> > +			struct rte_tel_data *d)
> > +{
> > +	uint8_t instance_id;
> > +	uint16_t rx_queue_id;
> > +	int eth_dev_id, ret = -1;
> > +	char *token, *l_params;
> > +
> > +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> > +		return -1;
> > +
> > +	l_params = strdup(params);
> > +	if (l_params == NULL)
> > +		return -ENOMEM;
> > +	token = strtok(l_params, ",");
> > +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> > +
> > +	/* Get device ID from parameter string */
> > +	eth_dev_id = strtoul(token, NULL, 10);
> > +	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -
> EINVAL);
> > +
> > +	token = strtok(NULL, ",");
> > +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> > +
> > +	/* Get Rx queue ID from parameter string */
> > +	rx_queue_id = strtoul(token, NULL, 10);
> > +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u",
> rx_queue_id);
> > +		ret = -EINVAL;
> > +		goto error;
> > +	}
> > +
> > +	token = strtok(NULL, "\0");
> > +	if (token != NULL)
> > +		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
> > +				 " telemetry command, ignoring");
> > +
> > +	/* Parsing parameter finished */
> > +	free(l_params);
> > +
> > +	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> > +						  rx_queue_id,
> > +						  &instance_id)) {
> > +		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
> > +				 " for rx_queue_id = %d", rx_queue_id);
> > +		return -1;
> > +	}
> > +
> > +	rte_tel_data_start_dict(d);
> > +	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
> > +	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
> > +	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
> > +
> > +	return 0;
> > +
> > +error:
> > +	free(l_params);
> > +	return ret;
> > +}
> > +
> >  RTE_INIT(rxa_init_telemetry)
> >  {
> >  	rte_telemetry_register_cmd("/eventdev/rxa_stats",
> > @@ -3575,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
> >  	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
> >  		handle_rxa_queue_stats_reset,
> >  		"Reset Rx queue stats. Parameter: rxa_id, dev_id,
> queue_id");
> > +
> > +	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
> > +		handle_rxa_instance_get,
> > +		"Returns Rx adapter instance id. Parameter: dev_id,
> queue_id");
> >  }
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> > b/lib/eventdev/rte_event_eth_rx_adapter.h
> > index 3608a7b..f56938d 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> > @@ -38,6 +38,7 @@
> >   *  - rte_event_eth_rx_adapter_queue_stats_get()
> >   *  - rte_event_eth_rx_adapter_queue_stats_reset()
> >   *  - rte_event_eth_rx_adapter_event_port_get()
> > + *  - rte_event_eth_rx_adapter_instance_get()
> >   *
> >   * The application creates an ethernet to event adapter using
> >   * rte_event_eth_rx_adapter_create_ext() or
> > rte_event_eth_rx_adapter_create() @@ -704,6 +705,28 @@
> > __rte_experimental  int
> > rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> > *event_port_id);
> >
> > +/**
> > + * Get RX adapter instance ID for a RX queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of Ethernet device.
> > + *
> > + * @param rx_queue_id
> > + *  Ethernet device receive queue index
> > + *
> > + * @param[out] rxa_inst_id
> > + *  RX adapter instance identifier.
> > + *
> > + * @return
> > + *  - 0: Success
> > + *  - <0: Error code on failure
> > + */
> > +__rte_experimental
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t rx_queue_id,
> > +				      uint8_t *rxa_inst_id);
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c
> > b/lib/eventdev/rte_event_eth_tx_adapter.c
> > index 1b304f0..1c9f9fc 100644
> > --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> > @@ -1,6 +1,8 @@
> >  /* SPDX-License-Identifier: BSD-3-Clause
> >   * Copyright(c) 2018 Intel Corporation.
> >   */
> > +#include <limits.h>
> > +
> >  #include <rte_spinlock.h>
> >  #include <rte_service_component.h>
> >  #include <ethdev_driver.h>
> > @@ -17,6 +19,11 @@
> >  #define TXA_MAX_NB_TX		128
> >  #define TXA_INVALID_DEV_ID	INT32_C(-1)
> >  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> > +#define INVALID_INSTANCE_ID	UINT8_MAX
> > +
> > +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> > +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> > +#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
> >
> >  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> >
> > @@ -140,6 +147,10 @@ struct txa_service_ethdev {
> >  	void *queues;
> >  };
> >
> > +struct event_eth_txa_inst_info {
> > +	uint8_t txa_inst_id;
> > +};
> > +
> >  /* Array of adapter instances, initialized with event device id
> >   * when adapter is created
> >   */
> > @@ -148,6 +159,9 @@ static int *txa_dev_id_array;
> >  /* Array of pointers to service implementation data */  static struct
> > txa_service_data **txa_service_data_array;
> >
> > +/* array of adapter instances to store tx queue specific instance */
> > +static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
> > +
> >  static int32_t txa_service_func(void *args);  static int
> > txa_service_adapter_create_ext(uint8_t id,
> >  			struct rte_eventdev *dev,
> > @@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name,
> unsigned
> > int elt_size, int nb_elems)  }
> >
> >  static int
> > +txa_memzone_lookup(void)
> > +{
> > +	const struct rte_memzone *mz;
> > +
> > +	if (txa_dev_id_array == NULL) {
> > +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		txa_dev_id_array = mz->addr;
> > +	}
> > +
> > +	if (txa_service_data_array == NULL) {
> > +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		txa_service_data_array = mz->addr;
> > +	}
> > +
> > +	if (event_eth_txa_inst_info == NULL) {
> > +		mz =
> rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
> > +		if (mz == NULL)
> > +			return -ENOMEM;
> > +		event_eth_txa_inst_info = mz->addr;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +
> > +static int
> >  txa_dev_id_array_init(void)
> >  {
> >  	if (txa_dev_id_array == NULL) {
> >  		int i;
> >
> > -		txa_dev_id_array =
> txa_memzone_array_get("txa_adapter_array",
> > +		txa_dev_id_array =
> txa_memzone_array_get(TXA_ADAPTER_ARRAY,
> >  					sizeof(int),
> >
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
> >  		if (txa_dev_id_array == NULL)
> > @@ -221,15 +265,30 @@ txa_init(void)
> >  static int
> >  txa_service_data_init(void)
> >  {
> > +	uint8_t i;
> > +
> >  	if (txa_service_data_array == NULL) {
> >  		txa_service_data_array =
> > -
> 	txa_memzone_array_get("txa_service_data_array",
> > +
> 	txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
> >  					sizeof(int),
> >
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
> >  		if (txa_service_data_array == NULL)
> >  			return -ENOMEM;
> >  	}
> >
> > +	if (event_eth_txa_inst_info == NULL) {
> > +		event_eth_txa_inst_info =
> > +
> 	txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
> > +					      sizeof(*event_eth_txa_inst_info),
> > +					      RTE_MAX_ETHPORTS);
> > +		if (event_eth_txa_inst_info == NULL)
> > +			return -ENOMEM;
> > +	}
> > +
> > +	/* Reset the txa instance pointers */
> > +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> > +		event_eth_txa_inst_info[i] = NULL;
> > +
> >  	return 0;
> >  }
> >
> > @@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
> >  	struct rte_eth_dev_tx_buffer *tb;
> >  	struct txa_retry *txa_retry;
> >  	int ret = 0;
> > +	uint16_t eth_dev_id = eth_dev->data->port_id;
> >
> >  	txa = txa_service_id_to_data(id);
> >
> > @@ -836,6 +896,31 @@ txa_service_queue_add(uint8_t id,
> >  	tdi->nb_queues++;
> >  	txa->nb_queues++;
> >
> > +	/* Allocate storage to store txa_inst_id for txq */
> > +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> > +		uint16_t n, i;
> > +		struct event_eth_txa_inst_info *i_info;
> > +
> > +		n = eth_dev->data->nb_tx_queues;
> > +
> > +		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
> > +					n * sizeof(event_eth_txa_inst_info),
> > +					0,
> > +					txa->socket_id);
> > +		if (i_info == NULL) {
> > +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> > +					 "event_eth_txa_inst_info");
> > +			goto err_unlock;
> > +		}
> > +
> > +		for (i = 0; i < n; i++)
> > +			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
> > +
> > +		event_eth_txa_inst_info[eth_dev_id] = i_info;
> > +	}
> > +
> > +	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id =
> id;
> > +
> >  ret_unlock:
> >  	rte_spinlock_unlock(&txa->tx_lock);
> >  	return 0;
> > @@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
> >  	txa->nb_queues--;
> >  	txa->txa_ethdev[port_id].nb_queues--;
> >
> > +	/* unset txa_inst_id for tx_queue_id */
> > +	if (event_eth_txa_inst_info[port_id])
> > +		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id
> =
> > +
> 	INVALID_INSTANCE_ID;
> > +
> > +
> >  	txa_service_queue_array_free(txa, port_id);
> >  	return 0;
> >  }
> > @@ -1056,6 +1147,10 @@ int
> >  rte_event_eth_tx_adapter_free(uint8_t id)  {
> >  	int ret;
> > +	uint16_t eth_dev_id;
> > +
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> >
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
> >  		ret = txa_service_adapter_free(id);
> >  	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
> >
> > +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> > +		if (event_eth_txa_inst_info[eth_dev_id]) {
> > +			rte_free(event_eth_txa_inst_info[eth_dev_id]);
> > +			event_eth_txa_inst_info[eth_dev_id] = NULL;
> > +		}
> > +	}
> > +
> >  	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
> >  	return ret;
> >  }
> > @@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t
> id,
> >  	int ret;
> >  	uint32_t caps;
> >
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t
> id,
> >  	int ret;
> >  	uint32_t caps;
> >
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >  	TXA_CHECK_OR_ERR_RET(id);
> >
> > @@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
> >  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
> >  	return ret;
> >  }
> > +
> > +int
> > +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t tx_queue_id,
> > +				      uint8_t *txa_inst_id)
> > +{
> > +	uint8_t inst_id;
> > +
> > +	if (txa_memzone_lookup())
> > +		return -ENOMEM;
> > +
> > +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_tx_queues) {
> > +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (txa_inst_id == NULL) {
> > +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> > +		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id
> %d",
> > +				 eth_dev_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	inst_id =
> event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
> > +	if (inst_id == INVALID_INSTANCE_ID) {
> > +		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id
> %u, "
> > +				 "tx_queue_id %u", eth_dev_id,
> tx_queue_id);
> > +		return -EINVAL;
> > +	}
> > +
> > +	*txa_inst_id = inst_id;
> > +
> > +	return 0;
> > +}
> > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h
> > b/lib/eventdev/rte_event_eth_tx_adapter.h
> > index 3908c2d..28f4fa9 100644
> > --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> > +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> > @@ -34,6 +34,7 @@
> >   *  - rte_event_eth_tx_adapter_enqueue()
> >   *  - rte_event_eth_tx_adapter_event_port_get()
> >   *  - rte_event_eth_tx_adapter_service_id_get()
> > + *  - rte_event_eth_tx_adapter_instance_get()
> >   *
> >   * The application creates the adapter using
> >   * rte_event_eth_tx_adapter_create() or
> rte_event_eth_tx_adapter_create_ext().
> > @@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t
> id);
> > int  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t
> > *service_id);
> >
> > +/**
> > + * Get TX adapter instance id for TX queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of Ethernet device
> > + *
> > + * @param tx_queue_id
> > + *  Etherdev device TX queue index
> > + *
> > + * @param[out] txa_inst_id
> > + *  Pointer to TX adapter instance identifier  */ __rte_experimental
> > +int rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> > +				      uint16_t tx_queue_id,
> > +				      uint8_t *txa_inst_id);
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> > 886e2ec..1c99d52 100644
> > --- a/lib/eventdev/version.map
> > +++ b/lib/eventdev/version.map
> > @@ -102,9 +102,11 @@ EXPERIMENTAL {
> >
> >  	# added in 21.11
> >  	rte_event_eth_rx_adapter_create_with_params;
> > +	rte_event_eth_rx_adapter_instance_get;
> >  	rte_event_eth_rx_adapter_queue_conf_get;
> >  	rte_event_eth_rx_adapter_queue_stats_get;
> >  	rte_event_eth_rx_adapter_queue_stats_reset;
> > +	rte_event_eth_tx_adapter_instance_get;
> >
> >  	# added in 22.03
> >  	rte_event_eth_rx_adapter_event_port_get;
> > --
> > 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
                           ` (5 preceding siblings ...)
  2022-06-08 11:16         ` [PATCH v5 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-08 12:13         ` Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                             ` (7 more replies)
  6 siblings, 8 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..d1b4874 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -42,7 +43,10 @@
 /* Sentinel value to detect initialized file handle */
 #define INIT_FD		-1
 
-#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
+#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
+#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
+
+#define INVALID_INSTANCE_ID UINT8_MAX
 
 /*
  * Used to store port and queue ID of interrupting Rx queue
@@ -251,7 +255,12 @@ struct eth_rx_queue_info {
 	struct rte_event_eth_rx_adapter_stats *stats;
 };
 
+struct event_eth_rxa_inst_info {
+	uint8_t rxa_inst_id;
+};
+
 static struct event_eth_rx_adapter **event_eth_rx_adapter;
+static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
 
 /* Enable dynamic timestamp field in mbuf */
 static uint64_t event_eth_rx_timestamp_dynflag;
@@ -1415,15 +1424,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
+					      sizeof(*event_eth_rx_adapter),
+					      RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
+	if (event_eth_rxa_inst_info == NULL) {
+		event_eth_rxa_inst_info =
+			rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_rxa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_rxa_inst_info == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+			event_eth_rxa_inst_info[i] = NULL;
+	}
+
 	return 0;
 }
 
@@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
 	const struct rte_memzone *mz;
 
 	if (event_eth_rx_adapter == NULL) {
-		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
+		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
+	if (event_eth_rxa_inst_info == NULL) {
+		mz = rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_eth_rxa_inst_info = mz->addr;
+	}
+
 	return 0;
 }
 
@@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int pollq;
 	int intrq;
 	int sintrq;
+	uint16_t eth_dev_id = dev_info->dev->data->port_id;
 
 
 	if (rx_adapter->nb_queues == 0)
@@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
 		dev_info->rx_queue[rx_queue_id].stats = NULL;
 	}
+
+	/* unset rxa_inst_id for rx_queue_id */
+	if (event_eth_rxa_inst_info[eth_dev_id])
+		event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+							INVALID_INSTANCE_ID;
 }
 
 static int
@@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter *rx_adapter,
 		}
 	}
 
+	/* Allocate storage to store rxa_inst_id for rxq */
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_rxa_inst_info *i_info;
+
+		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
+				n * sizeof(struct event_eth_rxa_inst_info),
+				0,
+				rx_adapter->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_rxa_inst_info");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_rxa_inst_info[eth_dev_id] = i_info;
+	}
+
+	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
+	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
+								rx_adapter->id;
+
 	if (!rx_adapter->use_queue_event_buf)
 		return 0;
 
@@ -2523,6 +2605,10 @@ int
 rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
+	uint16_t eth_dev_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
 
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
@@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 	rte_free(rx_adapter);
 	event_eth_rx_adapter[id] = NULL;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_rxa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
+			event_eth_rxa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_rx_adapter_free(id);
 	return 0;
 }
@@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3386,49 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id %u",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id %u, "
+				 "rx_queue_id %u", eth_dev_id, rx_queue_id);
+		return -EINVAL;
+	}
+
+	*rxa_inst_id = inst_id;
+
+	return 0;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..45140a6 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,28 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *
+ * @return
+ *  - 0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..f1818a2 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -102,6 +102,7 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_event_eth_rx_adapter_create_with_params;
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
@ 2022-06-08 12:13           ` Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                             ` (6 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index d1b4874..3095647 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3697,6 +3697,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3718,4 +3780,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 3/7] test/eth_rx: add test case for instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-08 12:13           ` Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                             ` (5 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..878004b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,87 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1101,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 4/7] eventdev/eth_tx: add instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-08 12:13           ` Ganapati Kundapura
  2022-06-10  4:14             ` Naga Harish K, S V
  2022-06-08 12:13           ` [PATCH v6 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                             ` (4 subsequent siblings)
  7 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 1b304f0..d9de6e5 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation.
  */
+#include <limits.h>
+
 #include <rte_spinlock.h>
 #include <rte_service_component.h>
 #include <ethdev_driver.h>
@@ -17,6 +19,11 @@
 #define TXA_MAX_NB_TX		128
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
+#define INVALID_INSTANCE_ID	UINT8_MAX
+
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
 
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
@@ -140,6 +147,10 @@ struct txa_service_ethdev {
 	void *queues;
 };
 
+struct event_eth_txa_inst_info {
+	uint8_t txa_inst_id;
+};
+
 /* Array of adapter instances, initialized with event device id
  * when adapter is created
  */
@@ -148,6 +159,9 @@ static int *txa_dev_id_array;
 /* Array of pointers to service implementation data */
 static struct txa_service_data **txa_service_data_array;
 
+/* array of adapter instances to store tx queue specific instance */
+static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
+
 static int32_t txa_service_func(void *args);
 static int txa_service_adapter_create_ext(uint8_t id,
 			struct rte_eventdev *dev,
@@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	if (event_eth_txa_inst_info == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		event_eth_txa_inst_info = mz->addr;
+	}
+
+	return 0;
+}
+
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -221,15 +265,30 @@ txa_init(void)
 static int
 txa_service_data_init(void)
 {
+	uint8_t i;
+
 	if (txa_service_data_array == NULL) {
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
 	}
 
+	if (event_eth_txa_inst_info == NULL) {
+		event_eth_txa_inst_info =
+			txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
+					      sizeof(*event_eth_txa_inst_info),
+					      RTE_MAX_ETHPORTS);
+		if (event_eth_txa_inst_info == NULL)
+			return -ENOMEM;
+	}
+
+	/* Reset the txa instance pointers */
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		event_eth_txa_inst_info[i] = NULL;
+
 	return 0;
 }
 
@@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
 	struct rte_eth_dev_tx_buffer *tb;
 	struct txa_retry *txa_retry;
 	int ret = 0;
+	uint16_t eth_dev_id = eth_dev->data->port_id;
 
 	txa = txa_service_id_to_data(id);
 
@@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
 	rte_eth_tx_buffer_set_err_callback(tb,
 		txa_service_buffer_retry, txa_retry);
 
+	/* Allocate storage to store txa_inst_id for txq */
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		uint16_t n, i;
+		struct event_eth_txa_inst_info *i_info;
+
+		n = eth_dev->data->nb_tx_queues;
+
+		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
+					n * sizeof(event_eth_txa_inst_info),
+					0,
+					txa->socket_id);
+		if (i_info == NULL) {
+			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
+					 "event_eth_txa_inst_info");
+			goto err_unlock;
+		}
+
+		for (i = 0; i < n; i++)
+			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
+
+		event_eth_txa_inst_info[eth_dev_id] = i_info;
+	}
+
+	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id = id;
+
 	tqi->tx_buf = tb;
 	tqi->added = 1;
 	tdi->nb_queues++;
@@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
 	txa->nb_queues--;
 	txa->txa_ethdev[port_id].nb_queues--;
 
+	/* unset txa_inst_id for tx_queue_id */
+	if (event_eth_txa_inst_info[port_id])
+		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id =
+							INVALID_INSTANCE_ID;
+
+
 	txa_service_queue_array_free(txa, port_id);
 	return 0;
 }
@@ -1056,6 +1147,10 @@ int
 rte_event_eth_tx_adapter_free(uint8_t id)
 {
 	int ret;
+	uint16_t eth_dev_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
 
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
 		ret = txa_service_adapter_free(id);
 	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
 
+	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS; eth_dev_id++) {
+		if (event_eth_txa_inst_info[eth_dev_id]) {
+			rte_free(event_eth_txa_inst_info[eth_dev_id]);
+			event_eth_txa_inst_info[eth_dev_id] = NULL;
+		}
+	}
+
 	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
 	return ret;
 }
@@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
 	int ret;
 	uint32_t caps;
 
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 	TXA_CHECK_OR_ERR_RET(id);
 
@@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t inst_id;
+
+	if (txa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
+		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id %d",
+				 eth_dev_id);
+		return -EINVAL;
+	}
+
+	inst_id = event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
+	if (inst_id == INVALID_INSTANCE_ID) {
+		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id %u, "
+				 "tx_queue_id %u", eth_dev_id, tx_queue_id);
+		return -EINVAL;
+	}
+
+	*txa_inst_id = inst_id;
+
+	return 0;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..20d28a7 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index.
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to store TX adapter instance identifier.
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index f1818a2..1c99d52 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -106,6 +106,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_queue_conf_get;
 	rte_event_eth_rx_adapter_queue_stats_get;
 	rte_event_eth_rx_adapter_queue_stats_reset;
+	rte_event_eth_tx_adapter_instance_get;
 
 	# added in 22.03
 	rte_event_eth_rx_adapter_event_port_get;
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 5/7] test/eth_tx: add testcase for instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                             ` (2 preceding siblings ...)
  2022-06-08 12:13           ` [PATCH v6 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-08 12:13           ` Ganapati Kundapura
  2022-06-08 12:13           ` [PATCH v6 6/7] doc/eth_rx: update " Ganapati Kundapura
                             ` (3 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..ebbc622 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,79 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +769,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 6/7] doc/eth_rx: update instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                             ` (3 preceding siblings ...)
  2022-06-08 12:13           ` [PATCH v6 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-08 12:13           ` Ganapati Kundapura
  2022-06-08 12:14           ` [PATCH v6 7/7] doc/eth_tx: " Ganapati Kundapura
                             ` (2 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:13 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v6 7/7] doc/eth_tx: update instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                             ` (4 preceding siblings ...)
  2022-06-08 12:13           ` [PATCH v6 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-08 12:14           ` Ganapati Kundapura
  2022-06-10  4:12           ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-08 12:14 UTC (permalink / raw)
  To: jerinjacobk, dev, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..dc3e6a1 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v6 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                             ` (5 preceding siblings ...)
  2022-06-08 12:14           ` [PATCH v6 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-10  4:12           ` Naga Harish K, S V
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
  7 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-10  4:12 UTC (permalink / raw)
  To: Kundapura, Ganapati, jerinjacobk, dev, Jayatheerthan, Jay



> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 8, 2022 5:44 PM
> To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>
> Cc: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v6 1/7] eventdev/eth_rx: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() to get adapter instance id
> for specified ethernet device id and rx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
> v6:
> * rx adapter changes removed from patch4 and moved to patch1
> 
> v5:
> * patch is split into saperate patches
> 
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
> 
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> 
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..d1b4874 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -6,6 +6,7 @@
>  #include <sys/epoll.h>
>  #endif
>  #include <unistd.h>
> +#include <limits.h>
> 
>  #include <rte_cycles.h>
>  #include <rte_common.h>
> @@ -42,7 +43,10 @@
>  /* Sentinel value to detect initialized file handle */
>  #define INIT_FD		-1
> 
> -#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
> +#define RX_ADAPTER_DATA_ARRAY "rx_adapter_data_array"
> +#define RX_ADAPTER_INSTANCE_ARRAY "rx_adapter_instance_array"
> +
> +#define INVALID_INSTANCE_ID UINT8_MAX
> 
>  /*
>   * Used to store port and queue ID of interrupting Rx queue @@ -251,7
> +255,12 @@ struct eth_rx_queue_info {
>  	struct rte_event_eth_rx_adapter_stats *stats;  };
> 
> +struct event_eth_rxa_inst_info {
> +	uint8_t rxa_inst_id;
> +};
> +
>  static struct event_eth_rx_adapter **event_eth_rx_adapter;
> +static struct event_eth_rxa_inst_info **event_eth_rxa_inst_info;
> 
>  /* Enable dynamic timestamp field in mbuf */  static uint64_t
> event_eth_rx_timestamp_dynflag; @@ -1415,15 +1424,13 @@
> rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> +nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1438,46 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +
> 	rxa_memzone_array_get(RX_ADAPTER_DATA_ARRAY,
> +					      sizeof(*event_eth_rx_adapter),
> +
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i <
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
> +	if (event_eth_rxa_inst_info == NULL) {
> +		event_eth_rxa_inst_info =
> +
> 	rxa_memzone_array_get(RX_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_rxa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_rxa_inst_info == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +			event_eth_rxa_inst_info[i] = NULL;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1447,12 +1487,21 @@ rxa_memzone_lookup(void)
>  	const struct rte_memzone *mz;
> 
>  	if (event_eth_rx_adapter == NULL) {
> -		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> +		mz = rte_memzone_lookup(RX_ADAPTER_DATA_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> +	if (event_eth_rxa_inst_info == NULL) {
> +		mz =
> rte_memzone_lookup(RX_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +
> +		event_eth_rxa_inst_info = mz->addr;
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1950,6 +1999,7 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  	int pollq;
>  	int intrq;
>  	int sintrq;
> +	uint16_t eth_dev_id = dev_info->dev->data->port_id;
> 
> 
>  	if (rx_adapter->nb_queues == 0)
> @@ -1993,6 +2043,11 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  		dev_info->rx_queue[rx_queue_id].event_buf = NULL;
>  		dev_info->rx_queue[rx_queue_id].stats = NULL;
>  	}
> +
> +	/* unset rxa_inst_id for rx_queue_id */
> +	if (event_eth_rxa_inst_info[eth_dev_id])
> +
> 	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +
> 	INVALID_INSTANCE_ID;
>  }
> 
>  static int
> @@ -2085,6 +2140,33 @@ rxa_add_queue(struct event_eth_rx_adapter
> *rx_adapter,
>  		}
>  	}
> 
> +	/* Allocate storage to store rxa_inst_id for rxq */
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_rxa_inst_info *i_info;
> +
> +		n = rte_eth_devices[eth_dev_id].data->nb_rx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_rxa_inst_info",
> +				n * sizeof(struct event_eth_rxa_inst_info),
> +				0,
> +				rx_adapter->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_rxa_inst_info");
> +			return -ENOMEM;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].rxa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_rxa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	/* store rxa id for rx_queue_id in event_eth_rxa_inst_info */
> +	event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id =
> +								rx_adapter-
> >id;
> +
>  	if (!rx_adapter->use_queue_event_buf)
>  		return 0;
> 
> @@ -2523,6 +2605,10 @@ int
>  rte_event_eth_rx_adapter_free(uint8_t id)  {
>  	struct event_eth_rx_adapter *rx_adapter;
> +	uint16_t eth_dev_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> 
> @@ -2544,6 +2630,13 @@ rte_event_eth_rx_adapter_free(uint8_t id)
>  	rte_free(rx_adapter);
>  	event_eth_rx_adapter[id] = NULL;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> +		if (event_eth_rxa_inst_info[eth_dev_id]) {

if the queues of same eth_device are distributed among multiple adapter instances, there is a problem here.
the eth_device array may need to be freed only when none of the queues are assigned to any adapter instance.

each entry of the eth_dev and queue entry need to be checked here and skip the freeing of eth_device level array 
if there is any valid entry found.

> +			rte_free(event_eth_rxa_inst_info[eth_dev_id]);
> +			event_eth_rxa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_rx_adapter_free(id);
>  	return 0;
>  }
> @@ -2561,6 +2654,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2822,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2931,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3386,49 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t inst_id;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_rxa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid rxa instance for eth_dev_id
> %u",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id =
> event_eth_rxa_inst_info[eth_dev_id][rx_queue_id].rxa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid rxa instance for eth_dev_id
> %u, "
> +				 "rx_queue_id %u", eth_dev_id,
> rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*rxa_inst_id = inst_id;
> +
> +	return 0;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..45140a6 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or
> rte_event_eth_rx_adapter_create() @@ -704,6 +705,28 @@
> __rte_experimental  int
> rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index.
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to store RX adapter instance identifier.
> + *
> + * @return
> + *  - 0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> 886e2ec..f1818a2 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -102,6 +102,7 @@ EXPERIMENTAL {
> 
>  	# added in 21.11
>  	rte_event_eth_rx_adapter_create_with_params;
> +	rte_event_eth_rx_adapter_instance_get;
>  	rte_event_eth_rx_adapter_queue_conf_get;
>  	rte_event_eth_rx_adapter_queue_stats_get;
>  	rte_event_eth_rx_adapter_queue_stats_reset;
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v6 4/7] eventdev/eth_tx: add instance get API
  2022-06-08 12:13           ` [PATCH v6 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-10  4:14             ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-10  4:14 UTC (permalink / raw)
  To: Kundapura, Ganapati, jerinjacobk, dev, Jayatheerthan, Jay



> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 8, 2022 5:44 PM
> To: jerinjacobk@gmail.com; dev@dpdk.org; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>
> Cc: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v6 4/7] eventdev/eth_tx: add instance get API
> 
> Added rte_event_eth_tx_adapter_instance_get() to get the adapter
> instance id for specified ethernet device id and tx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> 
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c
> b/lib/eventdev/rte_event_eth_tx_adapter.c
> index 1b304f0..d9de6e5 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -1,6 +1,8 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright(c) 2018 Intel Corporation.
>   */
> +#include <limits.h>
> +
>  #include <rte_spinlock.h>
>  #include <rte_service_component.h>
>  #include <ethdev_driver.h>
> @@ -17,6 +19,11 @@
>  #define TXA_MAX_NB_TX		128
>  #define TXA_INVALID_DEV_ID	INT32_C(-1)
>  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> +#define INVALID_INSTANCE_ID	UINT8_MAX
> +
> +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> +#define TXA_ADAPTER_INSTANCE_ARRAY "txa_adapter_instance_array"
> 
>  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> 
> @@ -140,6 +147,10 @@ struct txa_service_ethdev {
>  	void *queues;
>  };
> 
> +struct event_eth_txa_inst_info {
> +	uint8_t txa_inst_id;
> +};
> +
>  /* Array of adapter instances, initialized with event device id
>   * when adapter is created
>   */
> @@ -148,6 +159,9 @@ static int *txa_dev_id_array;
>  /* Array of pointers to service implementation data */  static struct
> txa_service_data **txa_service_data_array;
> 
> +/* array of adapter instances to store tx queue specific instance */
> +static struct event_eth_txa_inst_info **event_eth_txa_inst_info;
> +
>  static int32_t txa_service_func(void *args);  static int
> txa_service_adapter_create_ext(uint8_t id,
>  			struct rte_eventdev *dev,
> @@ -194,12 +208,42 @@ txa_memzone_array_get(const char *name,
> unsigned int elt_size, int nb_elems)  }
> 
>  static int
> +txa_memzone_lookup(void)
> +{
> +	const struct rte_memzone *mz;
> +
> +	if (txa_dev_id_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_dev_id_array = mz->addr;
> +	}
> +
> +	if (txa_service_data_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_service_data_array = mz->addr;
> +	}
> +
> +	if (event_eth_txa_inst_info == NULL) {
> +		mz =
> rte_memzone_lookup(TXA_ADAPTER_INSTANCE_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		event_eth_txa_inst_info = mz->addr;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +static int
>  txa_dev_id_array_init(void)
>  {
>  	if (txa_dev_id_array == NULL) {
>  		int i;
> 
> -		txa_dev_id_array =
> txa_memzone_array_get("txa_adapter_array",
> +		txa_dev_id_array =
> txa_memzone_array_get(TXA_ADAPTER_ARRAY,
>  					sizeof(int),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_dev_id_array == NULL)
> @@ -221,15 +265,30 @@ txa_init(void)
>  static int
>  txa_service_data_init(void)
>  {
> +	uint8_t i;
> +
>  	if (txa_service_data_array == NULL) {
>  		txa_service_data_array =
> -
> 	txa_memzone_array_get("txa_service_data_array",
> +
> 	txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
>  					sizeof(int),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_service_data_array == NULL)
>  			return -ENOMEM;
>  	}
> 
> +	if (event_eth_txa_inst_info == NULL) {
> +		event_eth_txa_inst_info =
> +
> 	txa_memzone_array_get(TXA_ADAPTER_INSTANCE_ARRAY,
> +					      sizeof(*event_eth_txa_inst_info),
> +					      RTE_MAX_ETHPORTS);
> +		if (event_eth_txa_inst_info == NULL)
> +			return -ENOMEM;
> +	}
> +
> +	/* Reset the txa instance pointers */
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +		event_eth_txa_inst_info[i] = NULL;
> +
>  	return 0;
>  }
> 
> @@ -763,6 +822,7 @@ txa_service_queue_add(uint8_t id,
>  	struct rte_eth_dev_tx_buffer *tb;
>  	struct txa_retry *txa_retry;
>  	int ret = 0;
> +	uint16_t eth_dev_id = eth_dev->data->port_id;
> 
>  	txa = txa_service_id_to_data(id);
> 
> @@ -831,6 +891,31 @@ txa_service_queue_add(uint8_t id,
>  	rte_eth_tx_buffer_set_err_callback(tb,
>  		txa_service_buffer_retry, txa_retry);
> 
> +	/* Allocate storage to store txa_inst_id for txq */
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		uint16_t n, i;
> +		struct event_eth_txa_inst_info *i_info;
> +
> +		n = eth_dev->data->nb_tx_queues;
> +
> +		i_info = rte_zmalloc_socket("event_eth_txa_inst_info",
> +					n * sizeof(event_eth_txa_inst_info),
> +					0,
> +					txa->socket_id);
> +		if (i_info == NULL) {
> +			RTE_EDEV_LOG_ERR("Failed to allocate storage for "
> +					 "event_eth_txa_inst_info");
> +			goto err_unlock;
> +		}
> +
> +		for (i = 0; i < n; i++)
> +			i_info[i].txa_inst_id = INVALID_INSTANCE_ID;
> +
> +		event_eth_txa_inst_info[eth_dev_id] = i_info;
> +	}
> +
> +	event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id =
> id;
> +
>  	tqi->tx_buf = tb;
>  	tqi->added = 1;
>  	tdi->nb_queues++;
> @@ -902,6 +987,12 @@ txa_service_queue_del(uint8_t id,
>  	txa->nb_queues--;
>  	txa->txa_ethdev[port_id].nb_queues--;
> 
> +	/* unset txa_inst_id for tx_queue_id */
> +	if (event_eth_txa_inst_info[port_id])
> +		event_eth_txa_inst_info[port_id][tx_queue_id].txa_inst_id
> =
> +
> 	INVALID_INSTANCE_ID;
> +
> +
>  	txa_service_queue_array_free(txa, port_id);
>  	return 0;
>  }
> @@ -1056,6 +1147,10 @@ int
>  rte_event_eth_tx_adapter_free(uint8_t id)  {
>  	int ret;
> +	uint16_t eth_dev_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> 
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1067,6 +1162,13 @@ rte_event_eth_tx_adapter_free(uint8_t id)
>  		ret = txa_service_adapter_free(id);
>  	txa_dev_id_array[id] = TXA_INVALID_DEV_ID;
> 
> +	for (eth_dev_id = 0; eth_dev_id < RTE_MAX_ETHPORTS;
> eth_dev_id++) {
> +		if (event_eth_txa_inst_info[eth_dev_id]) {

Same as for rx_adapter

if the queues of same eth_device are distributed among multiple adapter instances, there is a problem here.
the eth_device array may need to be freed only when none of the queues are assigned to any adapter instance.

each entry of the eth_dev and queue entry need to be checked here and skip the freeing of eth_device level array 
if there is any valid entry found.

> +			rte_free(event_eth_txa_inst_info[eth_dev_id]);
> +			event_eth_txa_inst_info[eth_dev_id] = NULL;
> +		}
> +	}
> +
>  	rte_eventdev_trace_eth_tx_adapter_free(id, ret);
>  	return ret;
>  }
> @@ -1080,6 +1182,9 @@ rte_event_eth_tx_adapter_queue_add(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1113,6 +1218,9 @@ rte_event_eth_tx_adapter_queue_del(uint8_t id,
>  	int ret;
>  	uint32_t caps;
> 
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>  	TXA_CHECK_OR_ERR_RET(id);
> 
> @@ -1218,3 +1326,46 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
>  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
>  	return ret;
>  }
> +
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id)
> +{
> +	uint8_t inst_id;
> +
> +	if (txa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_tx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (txa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	if (event_eth_txa_inst_info[eth_dev_id] == NULL) {
> +		RTE_EDEV_LOG_ERR("No valid txa instance for eth_dev_id
> %d",
> +				 eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	inst_id =
> event_eth_txa_inst_info[eth_dev_id][tx_queue_id].txa_inst_id;
> +	if (inst_id == INVALID_INSTANCE_ID) {
> +		RTE_EDEV_LOG_ERR("Invalid txa instance for eth_dev_id
> %u, "
> +				 "tx_queue_id %u", eth_dev_id,
> tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	*txa_inst_id = inst_id;
> +
> +	return 0;
> +}
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h
> b/lib/eventdev/rte_event_eth_tx_adapter.h
> index 3908c2d..20d28a7 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> @@ -34,6 +34,7 @@
>   *  - rte_event_eth_tx_adapter_enqueue()
>   *  - rte_event_eth_tx_adapter_event_port_get()
>   *  - rte_event_eth_tx_adapter_service_id_get()
> + *  - rte_event_eth_tx_adapter_instance_get()
>   *
>   * The application creates the adapter using
>   * rte_event_eth_tx_adapter_create() or
> rte_event_eth_tx_adapter_create_ext().
> @@ -423,6 +424,24 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
> int  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t
> *service_id);
> 
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param tx_queue_id
> + *  Etherdev device TX queue index.
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to store TX adapter instance identifier.
> + */
> +__rte_experimental
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> f1818a2..1c99d52 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -106,6 +106,7 @@ EXPERIMENTAL {
>  	rte_event_eth_rx_adapter_queue_conf_get;
>  	rte_event_eth_rx_adapter_queue_stats_get;
>  	rte_event_eth_rx_adapter_queue_stats_reset;
> +	rte_event_eth_tx_adapter_instance_get;
> 
>  	# added in 22.03
>  	rte_event_eth_rx_adapter_event_port_get;
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                             ` (6 preceding siblings ...)
  2022-06-10  4:12           ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
@ 2022-06-22 10:37           ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                               ` (6 more replies)
  7 siblings, 7 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map
---
 lib/eventdev/eventdev_pmd.h             |  22 +++++
 lib/eventdev/rte_event_eth_rx_adapter.c | 141 +++++++++++++++++++++++++++++---
 lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 178 insertions(+), 10 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ebfa6ef 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -6,6 +6,7 @@
 #include <sys/epoll.h>
 #endif
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_cycles.h>
 #include <rte_common.h>
@@ -1415,15 +1416,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1430,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1470,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1972,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2544,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2584,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2752,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2861,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3316,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..d1ecda4 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -110,6 +110,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_event_port_get;
 
 	# added in 22.07
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                               ` (5 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 66 +++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ebfa6ef..d653550 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3675,6 +3675,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3696,4 +3758,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 3/7] test/eth_rx: add test case for instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                               ` (4 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 1 deletion(-)

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 4/7] eventdev/eth_tx: add instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                               ` (3 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/eventdev_pmd.h             |  23 +++++++
 lib/eventdev/rte_event_eth_tx_adapter.c | 102 +++++++++++++++++++++++++++++++-
 lib/eventdev/rte_event_eth_tx_adapter.h |  24 ++++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index c700fb7..44a60cc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1218,3 +1252,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index d1ecda4..dd9255c 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -111,6 +111,7 @@ EXPERIMENTAL {
 
 	# added in 22.07
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 5/7] test/eth_tx: add testcase for instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
                               ` (2 preceding siblings ...)
  2022-06-22 10:37             ` [PATCH v7 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 6/7] doc/eth_rx: update " Ganapati Kundapura
                               ` (2 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_tx_adapter.c | 75 ++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 6/7] doc/eth_rx: update instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
                               ` (3 preceding siblings ...)
  2022-06-22 10:37             ` [PATCH v7 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 10:37             ` [PATCH v7 7/7] doc/eth_tx: " Ganapati Kundapura
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v7 7/7] doc/eth_tx: update instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
                               ` (4 preceding siblings ...)
  2022-06-22 10:37             ` [PATCH v7 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-22 10:37             ` Ganapati Kundapura
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 10:37 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..dc3e6a1 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
                               ` (5 preceding siblings ...)
  2022-06-22 10:37             ` [PATCH v7 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-22 16:53             ` Ganapati Kundapura
  2022-06-22 16:54               ` [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                                 ` (8 more replies)
  6 siblings, 9 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:53 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v8:
* Removed limits.h inclusion

v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map
---
 lib/eventdev/eventdev_pmd.h             |  22 +++++
 lib/eventdev/rte_event_eth_rx_adapter.c | 140 +++++++++++++++++++++++++++++---
 lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 177 insertions(+), 10 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ababe13 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..d1ecda4 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -110,6 +110,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_event_port_get;
 
 	# added in 22.07
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:29                 ` Naga Harish K, S V
  2022-06-22 16:54               ` [PATCH v8 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                                 ` (7 subsequent siblings)
  8 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 66 +++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ababe13..64a6add 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 3/7] test/eth_rx: add test case for instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-22 16:54               ` [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:29                 ` Naga Harish K, S V
  2022-06-22 16:54               ` [PATCH v8 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                                 ` (6 subsequent siblings)
  8 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 1 deletion(-)

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 4/7] eventdev/eth_tx: add instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-22 16:54               ` [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-22 16:54               ` [PATCH v8 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:30                 ` Naga Harish K, S V
  2022-06-22 16:54               ` [PATCH v8 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                                 ` (5 subsequent siblings)
  8 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/eventdev_pmd.h             |  23 +++++++
 lib/eventdev/rte_event_eth_tx_adapter.c | 102 +++++++++++++++++++++++++++++++-
 lib/eventdev/rte_event_eth_tx_adapter.h |  24 ++++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index c700fb7..44a60cc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1218,3 +1252,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index d1ecda4..dd9255c 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -111,6 +111,7 @@ EXPERIMENTAL {
 
 	# added in 22.07
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 5/7] test/eth_tx: add testcase for instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (2 preceding siblings ...)
  2022-06-22 16:54               ` [PATCH v8 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:30                 ` Naga Harish K, S V
  2022-06-22 16:54               ` [PATCH v8 6/7] doc/eth_rx: update " Ganapati Kundapura
                                 ` (4 subsequent siblings)
  8 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_tx_adapter.c | 75 ++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 6/7] doc/eth_rx: update instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (3 preceding siblings ...)
  2022-06-22 16:54               ` [PATCH v8 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:30                 ` Naga Harish K, S V
  2022-06-22 16:54               ` [PATCH v8 7/7] doc/eth_tx: " Ganapati Kundapura
                                 ` (3 subsequent siblings)
  8 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v8 7/7] doc/eth_tx: update instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (4 preceding siblings ...)
  2022-06-22 16:54               ` [PATCH v8 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-22 16:54               ` Ganapati Kundapura
  2022-06-22 17:30                 ` Naga Harish K, S V
  2022-06-22 17:41                 ` Jayatheerthan, Jay
  2022-06-22 17:29               ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
                                 ` (2 subsequent siblings)
  8 siblings, 2 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-22 16:54 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..dc3e6a1 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instanceget()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (5 preceding siblings ...)
  2022-06-22 16:54               ` [PATCH v8 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-22 17:29               ` Naga Harish K, S V
  2022-06-22 17:44               ` Jayatheerthan, Jay
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
  8 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:29 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 1/7] eventdev/eth_rx: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() to get adapter instance id
> for specified ethernet device id and rx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
> v8:
> * Removed limits.h inclusion
> 
> v7:
> * Remove allocation of instance array and storage of instnace id
> * in instance array
> * Use Rx adapter instance data to query instance id for specified
> * eth_dev_id and rx_queue_id
> 
> v6:
> * rx adapter changes removed from patch4 and moved to patch1
> 
> v5:
> * patch is split into saperate patches
> 
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
> 
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> ---
>  lib/eventdev/eventdev_pmd.h             |  22 +++++
>  lib/eventdev/rte_event_eth_rx_adapter.c | 140
> +++++++++++++++++++++++++++++---
> lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
>  lib/eventdev/version.map                |   1 +
>  4 files changed, 177 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index 6940266..c58ba05 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -888,6 +888,26 @@ typedef int
> (*eventdev_eth_rx_adapter_vector_limits_get_t)(
>  	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
>  	struct rte_event_eth_rx_adapter_vector_limits *limits);
> 
> +/**
> + * Get Rx adapter instance id for Rx queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of ethernet device
> + *
> + * @param rx_queue_id
> + *  Ethernet device Rx queue index
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to Rx adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *   -  0: Success
> + *   - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> +	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
> +
>  typedef uint32_t rte_event_pmd_selftest_seqn_t;  extern int
> rte_event_pmd_selftest_seqn_dynfield_offset;
> 
> @@ -1321,6 +1341,8 @@ struct eventdev_ops {
>  	eventdev_eth_rx_adapter_vector_limits_get_t
>  		eth_rx_adapter_vector_limits_get;
>  	/**< Get event vector limits for the Rx adapter */
> +	eventdev_eth_rx_adapter_instance_get_t
> eth_rx_adapter_instance_get;
> +	/**< Get Rx adapter instance id for Rx queue */
> 
>  	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
>  	/**< Get timer adapter capabilities */ diff --git
> a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..ababe13 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> +nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> +					sizeof(*event_eth_rx_adapter),
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i <
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
>  		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  	int intrq;
>  	int sintrq;
> 
> -
>  	if (rx_adapter->nb_queues == 0)
>  		return;
> 
> @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)  {
>  	struct event_eth_rx_adapter *rx_adapter;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> 
>  	rx_adapter = rxa_id_to_adapter(id);
> @@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3315,97 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +static int
> +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> +		   uint16_t eth_dev_id,
> +		   uint16_t rx_queue_id)
> +{
> +	struct eth_device_info *dev_info;
> +	struct eth_rx_queue_info *queue_info;
> +
> +	if (!rx_adapter->eth_devices)
> +		return 0;
> +
> +	dev_info = &rx_adapter->eth_devices[eth_dev_id];
> +	if (!dev_info || !dev_info->rx_queue)
> +		return 0;
> +
> +	queue_info = &dev_info->rx_queue[rx_queue_id];
> +
> +	return queue_info && queue_info->queue_enabled; }
> +
> +#define rxa_evdev(rx_adapter)
> +(&rte_eventdevs[(rx_adapter)->eventdev_id])
> +
> +#define rxa_dev_instance_get(rx_adapter) \
> +		rxa_evdev((rx_adapter))->dev_ops-
> >eth_rx_adapter_instance_get
> +
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t id;
> +	int ret = -EINVAL;
> +	uint32_t caps;
> +	struct event_eth_rx_adapter *rx_adapter;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	/* Iterate through all adapter instances */
> +	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> id++) {
> +		rx_adapter = rxa_id_to_adapter(id);
> +		if (!rx_adapter)
> +			continue;
> +
> +		if (rxa_is_queue_added(rx_adapter, eth_dev_id,
> rx_queue_id)) {
> +			*rxa_inst_id = rx_adapter->id;
> +			ret = 0;
> +		}
> +
> +		/* Rx adapter internally mainatains queue information
> +		 * for both internal port and DPDK service port.
> +		 * Eventdev PMD callback is called for future proof only and
> +		 * overrides the above return value if defined.
> +		 */
> +		caps = 0;
> +		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter-
> >eventdev_id,
> +						      eth_dev_id,
> +						      &caps)) {
> +			if (caps &
> RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> +				ret = rxa_dev_instance_get(rx_adapter) ?
> +
> 	rxa_dev_instance_get(rx_adapter)
> +								(eth_dev_id,
> +								 rx_queue_id,
> +								 rxa_inst_id)
> +							: -EINVAL;
> +			}
> +		}
> +
> +		/* return if entry found */
> +		if (ret == 0)
> +			return ret;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..a3313c8 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or
> rte_event_eth_rx_adapter_create() @@ -704,6 +705,29 @@
> __rte_experimental  int
> rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index.
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to store RX adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> 886e2ec..d1ecda4 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -110,6 +110,7 @@ EXPERIMENTAL {
>  	rte_event_eth_rx_adapter_event_port_get;
> 
>  	# added in 22.07
> +	rte_event_eth_rx_adapter_instance_get;
>  	rte_event_port_quiesce;
>  	rte_event_queue_attr_set;
>  };
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-22 16:54               ` [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-22 17:29                 ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:29 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for
> instance get
> 
> Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
> to retrieve adapter instance id for specified ethernet device id and rx queue
> index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  lib/eventdev/rte_event_eth_rx_adapter.c | 66
> +++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
> 
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index ababe13..64a6add 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd
> __rte_unused,
>  	return ret;
>  }
> 
> +static int
> +handle_rxa_instance_get(const char *cmd __rte_unused,
> +			const char *params,
> +			struct rte_tel_data *d)
> +{
> +	uint8_t instance_id;
> +	uint16_t rx_queue_id;
> +	int eth_dev_id, ret = -1;
> +	char *token, *l_params;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	l_params = strdup(params);
> +	if (l_params == NULL)
> +		return -ENOMEM;
> +	token = strtok(l_params, ",");
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> +
> +	/* Get device ID from parameter string */
> +	eth_dev_id = strtoul(token, NULL, 10);
> +	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -
> EINVAL);
> +
> +	token = strtok(NULL, ",");
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(
> token, -1);
> +
> +	/* Get Rx queue ID from parameter string */
> +	rx_queue_id = strtoul(token, NULL, 10);
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u",
> rx_queue_id);
> +		ret = -EINVAL;
> +		goto error;
> +	}
> +
> +	token = strtok(NULL, "\0");
> +	if (token != NULL)
> +		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
> +				 " telemetry command, ignoring");
> +
> +	/* Parsing parameter finished */
> +	free(l_params);
> +
> +	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						  rx_queue_id,
> +						  &instance_id)) {
> +		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
> +				 " for rx_queue_id = %d", rx_queue_id);
> +		return -1;
> +	}
> +
> +	rte_tel_data_start_dict(d);
> +	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
> +	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
> +	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
> +
> +	return 0;
> +
> +error:
> +	free(l_params);
> +	return ret;
> +}
> +
>  RTE_INIT(rxa_init_telemetry)
>  {
>  	rte_telemetry_register_cmd("/eventdev/rxa_stats",
> @@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
>  	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
>  		handle_rxa_queue_stats_reset,
>  		"Reset Rx queue stats. Parameter: rxa_id, dev_id,
> queue_id");
> +
> +	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
> +		handle_rxa_instance_get,
> +		"Returns Rx adapter instance id. Parameter: dev_id,
> queue_id");
>  }
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 3/7] test/eth_rx: add test case for instance get API
  2022-06-22 16:54               ` [PATCH v8 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-22 17:29                 ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:29 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 3/7] test/eth_rx: add test case for instance get API
> 
> Added test case for rte_event_eth_rx_adapter_instance_get()
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  app/test/test_event_eth_rx_adapter.c | 203
> ++++++++++++++++++++++++++++++++++-
>  1 file changed, 202 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test/test_event_eth_rx_adapter.c
> b/app/test/test_event_eth_rx_adapter.c
> index e358a70..1da7782 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
>  #define TEST_ETHDEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
> 
>  struct event_eth_rx_adapter_test_params {
>  	struct rte_mempool *mp;
> @@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
>  	return TEST_SUCCESS;
>  }
> 
> +static int
> +adapter_pollq_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong rx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_rx_queues +
> 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue 1 to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> +	queue_conf.servicing_weight = 1; /* poll queue */
> +
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Add queue 2 to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Add queue 3 to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 2,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 3,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete all queues from the Rx adapter */
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 -1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
> +adapter_intrq_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong rx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_rx_queues +
> 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Intr enabled eth device can have both polled and intr queues.
> +	 * Add polled queue 1 to Rx adapter
> +	 */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
> +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> +	queue_conf.servicing_weight = 1; /* poll queue */
> +
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Add intr queue 2 to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
> +	queue_conf.servicing_weight = 0; /* intr  queue */
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Add intr queue 3 to Rx adapter */
> +	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
> +	queue_conf.servicing_weight = 0; /* intr  queue */
> +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 2,
> +						 &queue_conf);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 3,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete all queues from the Rx adapter */
> +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 -1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
>  static struct unit_test_suite event_eth_rx_tests = {
>  	.suite_name = "rx event eth adapter test suite",
>  	.setup = testsuite_setup,
> @@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
>  			     adapter_queue_event_buf_test),
>  		TEST_CASE_ST(adapter_create_with_params, adapter_free,
>  			     adapter_queue_stats_test),
> +		TEST_CASE_ST(adapter_create, adapter_free,
> +			     adapter_pollq_instance_get),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> @@ -1029,7 +1228,9 @@ static struct unit_test_suite
> event_eth_rx_intr_tests = {
>  	.teardown = testsuite_teardown_rx_intr,
>  	.unit_test_cases = {
>  		TEST_CASE_ST(adapter_create, adapter_free,
> -			adapter_intr_queue_add_del),
> +			     adapter_intr_queue_add_del),
> +		TEST_CASE_ST(adapter_create, adapter_free,
> +			     adapter_intrq_instance_get),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 4/7] eventdev/eth_tx: add instance get API
  2022-06-22 16:54               ` [PATCH v8 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-22 17:30                 ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:30 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 4/7] eventdev/eth_tx: add instance get API
> 
> Added rte_event_eth_tx_adapter_instance_get() to get the adapter
> instance id for specified ethernet device id and tx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  lib/eventdev/eventdev_pmd.h             |  23 +++++++
>  lib/eventdev/rte_event_eth_tx_adapter.c | 102
> +++++++++++++++++++++++++++++++-
> lib/eventdev/rte_event_eth_tx_adapter.h |  24 ++++++++
>  lib/eventdev/version.map                |   1 +
>  4 files changed, 148 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index c58ba05..f514a37 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -1274,6 +1274,27 @@ typedef int
> (*eventdev_eth_tx_adapter_stats_get_t)(
>  typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
>  					const struct rte_eventdev *dev);
> 
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Ethernet device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier
> + *  Contains valid Tx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_tx_adapter_instance_get_t)
> +	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
> +
> +
>  /** Event device operations function pointer table */  struct eventdev_ops {
>  	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
> @@ -1386,6 +1407,8 @@ struct eventdev_ops {
>  	/**< Get eth Tx adapter statistics */
>  	eventdev_eth_tx_adapter_stats_reset_t
> eth_tx_adapter_stats_reset;
>  	/**< Reset eth Tx adapter statistics */
> +	eventdev_eth_tx_adapter_instance_get_t
> eth_tx_adapter_instance_get;
> +	/**< Get Tx adapter instance id for Tx queue */
> 
>  	eventdev_selftest dev_selftest;
>  	/**< Start eventdev Selftest */
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c
> b/lib/eventdev/rte_event_eth_tx_adapter.c
> index c700fb7..44a60cc 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -18,6 +18,9 @@
>  #define TXA_INVALID_DEV_ID	INT32_C(-1)
>  #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
> 
> +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> +
>  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
> 
>  #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops-
> >eth_tx_adapter_caps_get
> @@ -41,6 +44,9 @@
> 
>  #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops-
> >eth_tx_adapter_stats_get
> 
> +#define txa_dev_instance_get(id) \
> +			txa_evdev(id)->dev_ops-
> >eth_tx_adapter_instance_get
> +
>  #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
> do { \
>  	if (!txa_valid_id(id)) { \
> @@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name,
> unsigned int elt_size, int nb_elems)  }
> 
>  static int
> +txa_lookup(void)
> +{
> +	const struct rte_memzone *mz;
> +
> +	if (txa_dev_id_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_dev_id_array = mz->addr;
> +	}
> +
> +	if (txa_service_data_array == NULL) {
> +		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> +		if (mz == NULL)
> +			return -ENOMEM;
> +		txa_service_data_array = mz->addr;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
>  txa_dev_id_array_init(void)
>  {
>  	if (txa_dev_id_array == NULL) {
>  		int i;
> 
> -		txa_dev_id_array =
> txa_memzone_array_get("txa_adapter_array",
> +		txa_dev_id_array =
> txa_memzone_array_get(TXA_ADAPTER_ARRAY,
>  					sizeof(int),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_dev_id_array == NULL)
> @@ -222,12 +250,18 @@ static int
>  txa_service_data_init(void)
>  {
>  	if (txa_service_data_array == NULL) {
> +		int i;
> +
>  		txa_service_data_array =
> -
> 	txa_memzone_array_get("txa_service_data_array",
> +
> 	txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
>  					sizeof(*txa_service_data_array),
> 
> 	RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>  		if (txa_service_data_array == NULL)
>  			return -ENOMEM;
> +
> +		/* Reset the txa service pointers */
> +		for (i = 0; i <
> RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
> +			txa_service_data_array[i] = NULL;
>  	}
> 
>  	return 0;
> @@ -1218,3 +1252,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
>  	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
>  	return ret;
>  }
> +
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id)
> +{
> +	uint8_t id;
> +	int ret = -EINVAL;
> +	uint32_t caps;
> +	struct txa_service_data *txa;
> +
> +	if (txa_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_tx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (txa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	/* Iterate through all Tx adapter instances */
> +	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE;
> id++) {
> +		txa = txa_service_id_to_data(id);
> +		if (!txa)
> +			continue;
> +
> +		caps = 0;
> +		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
> +						      eth_dev_id,
> +						      &caps))
> +			continue;
> +
> +		if (caps &
> RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
> +			ret = txa_dev_instance_get(id) ?
> +
> 	txa_dev_instance_get(id)(eth_dev_id,
> +								 tx_queue_id,
> +								 txa_inst_id)
> +							: -EINVAL;
> +			if (ret == 0)
> +				return ret;
> +		} else {
> +			struct rte_eth_dev *eth_dev;
> +
> +			eth_dev = &rte_eth_devices[eth_dev_id];
> +
> +			if (txa_service_is_queue_added(txa, eth_dev,
> +						       tx_queue_id)) {
> +				*txa_inst_id = txa->id;
> +				return 0;
> +			}
> +		}
> +	}
> +
> +	return -EINVAL;
> +}
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h
> b/lib/eventdev/rte_event_eth_tx_adapter.h
> index 3908c2d..9432b74 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> @@ -34,6 +34,7 @@
>   *  - rte_event_eth_tx_adapter_enqueue()
>   *  - rte_event_eth_tx_adapter_event_port_get()
>   *  - rte_event_eth_tx_adapter_service_id_get()
> + *  - rte_event_eth_tx_adapter_instance_get()
>   *
>   * The application creates the adapter using
>   * rte_event_eth_tx_adapter_create() or
> rte_event_eth_tx_adapter_create_ext().
> @@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
> int  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t
> *service_id);
> 
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Etherdev device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier
> + *  Contains valid Tx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t tx_queue_id,
> +				      uint8_t *txa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> d1ecda4..dd9255c 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -111,6 +111,7 @@ EXPERIMENTAL {
> 
>  	# added in 22.07
>  	rte_event_eth_rx_adapter_instance_get;
> +	rte_event_eth_tx_adapter_instance_get;
>  	rte_event_port_quiesce;
>  	rte_event_queue_attr_set;
>  };
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 5/7] test/eth_tx: add testcase for instance get API
  2022-06-22 16:54               ` [PATCH v8 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-22 17:30                 ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:30 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 5/7] test/eth_tx: add testcase for instance get API
> 
> Added testcase for rte_event_eth_tx_adapter_instance_get()
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  app/test/test_event_eth_tx_adapter.c | 75
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 75 insertions(+)
> 
> diff --git a/app/test/test_event_eth_tx_adapter.c
> b/app/test/test_event_eth_tx_adapter.c
> index 2900532..98debfd 100644
> --- a/app/test/test_event_eth_tx_adapter.c
> +++ b/app/test/test_event_eth_tx_adapter.c
> @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
>  #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
>  #define TEST_INST_ID		0
>  #define TEST_DEV_ID		0
> +#define TEST_ETH_QUEUE_ID	0
>  #define SOCKET0			0
>  #define RING_SIZE		256
>  #define ETH_NAME_LEN		32
> @@ -639,6 +640,78 @@ tx_adapter_service(void)  }
> 
>  static int
> +tx_adapter_instance_get(void)
> +{
> +	int err;
> +	uint8_t inst_id;
> +	uint16_t eth_dev_id;
> +	struct rte_eth_dev_info dev_info;
> +
> +	/* Case 1: Test without configuring eth */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 2: Test with wrong eth port */
> +	eth_dev_id = rte_eth_dev_count_total() + 1;
> +	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 3: Test with wrong tx queue */
> +	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    dev_info.max_tx_queues +
> 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Case 4: Test with right instance, port & rxq */
> +	/* Add queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Add another queue to tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 TEST_ETH_QUEUE_ID + 1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 1,
> +						    &inst_id);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
> +		    TEST_INST_ID, err);
> +
> +	/* Case 5: Test with right instance, port & wrong rxq */
> +	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
> +						    TEST_ETH_QUEUE_ID + 2,
> +						    &inst_id);
> +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> +
> +	/* Delete all queues from the Tx adapter */
> +	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
> +						 TEST_ETHDEV_ID,
> +						 -1);
> +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
>  tx_adapter_dynamic_device(void)
>  {
>  	uint16_t port_id = rte_eth_dev_count_avail(); @@ -695,6 +768,8
> @@ static struct unit_test_suite event_eth_tx_tests = {
>  					tx_adapter_start_stop),
>  		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
>  					tx_adapter_service),
> +		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
> +					tx_adapter_instance_get),
>  		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 6/7] doc/eth_rx: update instance get API
  2022-06-22 16:54               ` [PATCH v8 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-22 17:30                 ` Naga Harish K, S V
  0 siblings, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:30 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 6/7] doc/eth_rx: update instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() details
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> index 3b4ef50..5b9d0cf 100644
> --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
>  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used
> to  reset queue level stats when queue level event buffer is in use.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The ``rte_event_eth_rx_adapter_instance_get()`` function reports rx
> +adapter instance id for a specified ethernet device id and rx queue index.
> +
>  Interrupt Based Rx Queues
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 7/7] doc/eth_tx: update instance get API
  2022-06-22 16:54               ` [PATCH v8 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-22 17:30                 ` Naga Harish K, S V
  2022-06-22 17:41                 ` Jayatheerthan, Jay
  1 sibling, 0 replies; 81+ messages in thread
From: Naga Harish K, S V @ 2022-06-22 17:30 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Jayatheerthan, Jay

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 7/7] doc/eth_tx: update instance get API
> 
> Added rte_event_eth_tx_adapter_instance_get() details.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> index f80d226..dc3e6a1 100644
> --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The
> counter values are the sum of  the counts from the eventdev PMD callback if
> the callback is supported, and  the counts maintained by the service function,
> if one exists.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports tx
> +adapter instance id for a specified ethernet device id and tx queue index.
> +
>  Tx event vectorization
>  ~~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 7/7] doc/eth_tx: update instance get API
  2022-06-22 16:54               ` [PATCH v8 7/7] doc/eth_tx: " Ganapati Kundapura
  2022-06-22 17:30                 ` Naga Harish K, S V
@ 2022-06-22 17:41                 ` Jayatheerthan, Jay
  1 sibling, 0 replies; 81+ messages in thread
From: Jayatheerthan, Jay @ 2022-06-22 17:41 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Naga Harish K, S V

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 7/7] doc/eth_tx: update instance get API
> 
> Added rte_event_eth_tx_adapter_instance_get() details.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
>  doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> index f80d226..dc3e6a1 100644
> --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
>  the counts from the eventdev PMD callback if the callback is supported, and
>  the counts maintained by the service function, if one exists.
> 
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The  ``rte_event_eth_tx_adapter_instanceget()`` function reports

Nitpick: rte_event_eth_tx_adapter_instanceget -> rte_event_eth_tx_adapter_instance_get.

With this change you can include Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

> +tx adapter instance id for a specified ethernet device id and tx queue index.
> +
>  Tx event vectorization
>  ~~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v8 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (6 preceding siblings ...)
  2022-06-22 17:29               ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
@ 2022-06-22 17:44               ` Jayatheerthan, Jay
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
  8 siblings, 0 replies; 81+ messages in thread
From: Jayatheerthan, Jay @ 2022-06-22 17:44 UTC (permalink / raw)
  To: Kundapura, Ganapati, dev, jerinj, Naga Harish K, S V

Aside of the minor documentation fix in patch 7/7, the full patchset looks good to me. Thanks for posting it!

Please fix it and add Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

-Jay



> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev@dpdk.org; jerinj@marvell.com; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k@intel.com>
> Subject: [PATCH v8 1/7] eventdev/eth_rx: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() to get
> adapter instance id for specified ethernet device id and
> rx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> ---
> v8:
> * Removed limits.h inclusion
> 
> v7:
> * Remove allocation of instance array and storage of instnace id
> * in instance array
> * Use Rx adapter instance data to query instance id for specified
> * eth_dev_id and rx_queue_id
> 
> v6:
> * rx adapter changes removed from patch4 and moved to patch1
> 
> v5:
> * patch is split into saperate patches
> 
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
> 
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> ---
>  lib/eventdev/eventdev_pmd.h             |  22 +++++
>  lib/eventdev/rte_event_eth_rx_adapter.c | 140 +++++++++++++++++++++++++++++---
>  lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
>  lib/eventdev/version.map                |   1 +
>  4 files changed, 177 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index 6940266..c58ba05 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
>  	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
>  	struct rte_event_eth_rx_adapter_vector_limits *limits);
> 
> +/**
> + * Get Rx adapter instance id for Rx queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of ethernet device
> + *
> + * @param rx_queue_id
> + *  Ethernet device Rx queue index
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to Rx adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *   -  0: Success
> + *   - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> +	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
> +
>  typedef uint32_t rte_event_pmd_selftest_seqn_t;
>  extern int rte_event_pmd_selftest_seqn_dynfield_offset;
> 
> @@ -1321,6 +1341,8 @@ struct eventdev_ops {
>  	eventdev_eth_rx_adapter_vector_limits_get_t
>  		eth_rx_adapter_vector_limits_get;
>  	/**< Get event vector limits for the Rx adapter */
> +	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
> +	/**< Get Rx adapter instance id for Rx queue */
> 
>  	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
>  	/**< Get timer adapter capabilities */
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..ababe13 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> +					sizeof(*event_eth_rx_adapter),
> +					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
>  		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
>  	int intrq;
>  	int sintrq;
> 
> -
>  	if (rx_adapter->nb_queues == 0)
>  		return;
> 
> @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
>  {
>  	struct event_eth_rx_adapter *rx_adapter;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> 
>  	rx_adapter = rxa_id_to_adapter(id);
> @@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +static int
> +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> +		   uint16_t eth_dev_id,
> +		   uint16_t rx_queue_id)
> +{
> +	struct eth_device_info *dev_info;
> +	struct eth_rx_queue_info *queue_info;
> +
> +	if (!rx_adapter->eth_devices)
> +		return 0;
> +
> +	dev_info = &rx_adapter->eth_devices[eth_dev_id];
> +	if (!dev_info || !dev_info->rx_queue)
> +		return 0;
> +
> +	queue_info = &dev_info->rx_queue[rx_queue_id];
> +
> +	return queue_info && queue_info->queue_enabled;
> +}
> +
> +#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
> +
> +#define rxa_dev_instance_get(rx_adapter) \
> +		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
> +
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t id;
> +	int ret = -EINVAL;
> +	uint32_t caps;
> +	struct event_eth_rx_adapter *rx_adapter;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	/* Iterate through all adapter instances */
> +	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
> +		rx_adapter = rxa_id_to_adapter(id);
> +		if (!rx_adapter)
> +			continue;
> +
> +		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
> +			*rxa_inst_id = rx_adapter->id;
> +			ret = 0;
> +		}
> +
> +		/* Rx adapter internally mainatains queue information
> +		 * for both internal port and DPDK service port.
> +		 * Eventdev PMD callback is called for future proof only and
> +		 * overrides the above return value if defined.
> +		 */
> +		caps = 0;
> +		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
> +						      eth_dev_id,
> +						      &caps)) {
> +			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> +				ret = rxa_dev_instance_get(rx_adapter) ?
> +						rxa_dev_instance_get(rx_adapter)
> +								(eth_dev_id,
> +								 rx_queue_id,
> +								 rxa_inst_id)
> +							: -EINVAL;
> +			}
> +		}
> +
> +		/* return if entry found */
> +		if (ret == 0)
> +			return ret;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..a3313c8 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
> @@ -704,6 +705,29 @@ __rte_experimental
>  int
>  rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index.
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to store RX adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> index 886e2ec..d1ecda4 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -110,6 +110,7 @@ EXPERIMENTAL {
>  	rte_event_eth_rx_adapter_event_port_get;
> 
>  	# added in 22.07
> +	rte_event_eth_rx_adapter_instance_get;
>  	rte_event_port_quiesce;
>  	rte_event_queue_attr_set;
>  };
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                 ` (7 preceding siblings ...)
  2022-06-22 17:44               ` Jayatheerthan, Jay
@ 2022-06-23  6:24               ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                                   ` (6 more replies)
  8 siblings, 7 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
v9:
* Corrected rte_event_eth_tx_adapter_instanceget to
* rte_event_eth_tx_adapter_instance_get in event_ethernet_tx_adapter.rst

v8:
* Removed limits.h inclusion

v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map
---
 lib/eventdev/eventdev_pmd.h             |  22 +++++
 lib/eventdev/rte_event_eth_rx_adapter.c | 140 +++++++++++++++++++++++++++++---
 lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 177 insertions(+), 10 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ababe13 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..d1ecda4 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -110,6 +110,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_event_port_get;
 
 	# added in 22.07
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 66 +++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ababe13..64a6add 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 3/7] test/eth_rx: add test case for instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 1 deletion(-)

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 4/7] eventdev/eth_tx: add instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 lib/eventdev/eventdev_pmd.h             |  23 +++++++
 lib/eventdev/rte_event_eth_tx_adapter.c | 102 +++++++++++++++++++++++++++++++-
 lib/eventdev/rte_event_eth_tx_adapter.h |  24 ++++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index c700fb7..44a60cc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1218,3 +1252,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index d1ecda4..dd9255c 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -111,6 +111,7 @@ EXPERIMENTAL {
 
 	# added in 22.07
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 5/7] test/eth_tx: add testcase for instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
                                   ` (2 preceding siblings ...)
  2022-06-23  6:24                 ` [PATCH v9 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 6/7] doc/eth_rx: update " Ganapati Kundapura
                                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 app/test/test_event_eth_tx_adapter.c | 75 ++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 6/7] doc/eth_rx: update instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
                                   ` (3 preceding siblings ...)
  2022-06-23  6:24                 ` [PATCH v9 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  6:24                 ` [PATCH v9 7/7] doc/eth_tx: " Ganapati Kundapura
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v9 7/7] doc/eth_tx: update instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
                                   ` (4 preceding siblings ...)
  2022-06-23  6:24                 ` [PATCH v9 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-23  6:24                 ` Ganapati Kundapura
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  6:24 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
 doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..4da9bcd 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instance_get()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
                                   ` (5 preceding siblings ...)
  2022-06-23  6:24                 ` [PATCH v9 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-06-23  9:30                 ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                                     ` (6 more replies)
  6 siblings, 7 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
v10:
* Add Review and Ack to series

v9:
* Corrected rte_event_eth_tx_adapter_instanceget to
* rte_event_eth_tx_adapter_instance_get in event_ethernet_tx_adapter.rst

v8:
* Removed limits.h inclusion

v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map
---
 lib/eventdev/eventdev_pmd.h             |  22 +++++
 lib/eventdev/rte_event_eth_rx_adapter.c | 140 +++++++++++++++++++++++++++++---
 lib/eventdev/rte_event_eth_rx_adapter.h |  24 ++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 177 insertions(+), 10 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ababe13 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..d1ecda4 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -110,6 +110,7 @@ EXPERIMENTAL {
 	rte_event_eth_rx_adapter_event_port_get;
 
 	# added in 22.07
+	rte_event_eth_rx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 66 +++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ababe13..64a6add 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 3/7] test/eth_rx: add test case for instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 1 deletion(-)

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 4/7] eventdev/eth_tx: add instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 lib/eventdev/eventdev_pmd.h             |  23 +++++++
 lib/eventdev/rte_event_eth_tx_adapter.c | 102 +++++++++++++++++++++++++++++++-
 lib/eventdev/rte_event_eth_tx_adapter.h |  24 ++++++++
 lib/eventdev/version.map                |   1 +
 4 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index c700fb7..44a60cc 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1218,3 +1252,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index d1ecda4..dd9255c 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -111,6 +111,7 @@ EXPERIMENTAL {
 
 	# added in 22.07
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 5/7] test/eth_tx: add testcase for instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                     ` (2 preceding siblings ...)
  2022-06-23  9:30                   ` [PATCH v10 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 6/7] doc/eth_rx: update " Ganapati Kundapura
                                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 app/test/test_event_eth_tx_adapter.c | 75 ++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 6/7] doc/eth_rx: update instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                     ` (3 preceding siblings ...)
  2022-06-23  9:30                   ` [PATCH v10 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-06-23  9:30                   ` [PATCH v10 7/7] doc/eth_tx: " Ganapati Kundapura
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 doc/guides/prog_guide/event_ethernet_rx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v10 7/7] doc/eth_tx: update instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                     ` (4 preceding siblings ...)
  2022-06-23  9:30                   ` [PATCH v10 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-06-23  9:30                   ` Ganapati Kundapura
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-06-23  9:30 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan, s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 doc/guides/prog_guide/event_ethernet_tx_adapter.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..4da9bcd 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instance_get()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
  2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                     ` (5 preceding siblings ...)
  2022-06-23  9:30                   ` [PATCH v10 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-07-19  8:25                   ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                                       ` (7 more replies)
  6 siblings, 8 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
v11:
* added instance_get under 22.11 in version.map

v10:
* Add Review and Ack to series

v9:
* Corrected rte_event_eth_tx_adapter_instanceget to
* rte_event_eth_tx_adapter_instance_get in event_ethernet_tx_adapter.rst

v8:
* Removed limits.h inclusion

v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ababe13 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 886e2ec..da07a23 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -112,6 +112,9 @@ EXPERIMENTAL {
 	# added in 22.07
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
+
+	# added in 22.11
+	rte_event_eth_rx_adapter_instance_get;
 };
 
 INTERNAL {
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 2/7] eventdev/eth_rx: add telemetry callback for instance get
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
                                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ababe13..64a6add 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 3/7] test/eth_rx: add test case for instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 4/7] eventdev/eth_tx: add " Ganapati Kundapura
                                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 4/7] eventdev/eth_tx: add instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
                                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index b4b37f1..aaef352 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1222,3 +1256,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index da07a23..4510b38 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -115,6 +115,7 @@ EXPERIMENTAL {
 
 	# added in 22.11
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 };
 
 INTERNAL {
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 5/7] test/eth_tx: add testcase for instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                       ` (2 preceding siblings ...)
  2022-07-19  8:25                     ` [PATCH v11 4/7] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 6/7] doc/eth_rx: update " Ganapati Kundapura
                                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 6/7] doc/eth_rx: update instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                       ` (3 preceding siblings ...)
  2022-07-19  8:25                     ` [PATCH v11 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-07-19  8:25                     ` [PATCH v11 7/7] doc/eth_tx: " Ganapati Kundapura
                                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added rte_event_eth_rx_adapter_instance_get() details

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v11 7/7] doc/eth_tx: update instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                       ` (4 preceding siblings ...)
  2022-07-19  8:25                     ` [PATCH v11 6/7] doc/eth_rx: update " Ganapati Kundapura
@ 2022-07-19  8:25                     ` Ganapati Kundapura
  2022-08-11 13:28                     ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Kundapura, Ganapati
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
  7 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-07-19  8:25 UTC (permalink / raw)
  To: jerinj, jay.jayatheerthan, s.v.naga.harish.k, dev

Added rte_event_eth_tx_adapter_instance_get() details.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..4da9bcd 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instance_get()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                       ` (5 preceding siblings ...)
  2022-07-19  8:25                     ` [PATCH v11 7/7] doc/eth_tx: " Ganapati Kundapura
@ 2022-08-11 13:28                     ` Kundapura, Ganapati
  2022-08-27 12:14                       ` Jerin Jacob
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
  7 siblings, 1 reply; 81+ messages in thread
From: Kundapura, Ganapati @ 2022-08-11 13:28 UTC (permalink / raw)
  To: Kundapura, Ganapati, jerinj, Jayatheerthan, Jay, Naga Harish K, S V, dev

Hi Jerin,
   Could you please review this?

Thanks,
Ganapati

> -----Original Message-----
> From: Ganapati Kundapura <ganapati.kundapura@intel.com>
> Sent: 19 July 2022 13:56
> To: jerinj@marvell.com; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> Naga Harish K, S V <s.v.naga.harish.k@intel.com>; dev@dpdk.org
> Subject: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
> 
> Added rte_event_eth_rx_adapter_instance_get() to get adapter instance id
> for specified ethernet device id and rx queue index.
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> 
> Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
> ---
> v11:
> * added instance_get under 22.11 in version.map
> 
> v10:
> * Add Review and Ack to series
> 
> v9:
> * Corrected rte_event_eth_tx_adapter_instanceget to
> * rte_event_eth_tx_adapter_instance_get in
> event_ethernet_tx_adapter.rst
> 
> v8:
> * Removed limits.h inclusion
> 
> v7:
> * Remove allocation of instance array and storage of instnace id
> * in instance array
> * Use Rx adapter instance data to query instance id for specified
> * eth_dev_id and rx_queue_id
> 
> v6:
> * rx adapter changes removed from patch4 and moved to patch1
> 
> v5:
> * patch is split into saperate patches
> 
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
> 
> v3:
> * Fixed checkpatch error
> 
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
> 
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index 6940266..c58ba05 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -888,6 +888,26 @@ typedef int
> (*eventdev_eth_rx_adapter_vector_limits_get_t)(
>  	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
>  	struct rte_event_eth_rx_adapter_vector_limits *limits);
> 
> +/**
> + * Get Rx adapter instance id for Rx queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of ethernet device
> + *
> + * @param rx_queue_id
> + *  Ethernet device Rx queue index
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to Rx adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *   -  0: Success
> + *   - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> +	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
> +
>  typedef uint32_t rte_event_pmd_selftest_seqn_t;  extern int
> rte_event_pmd_selftest_seqn_dynfield_offset;
> 
> @@ -1321,6 +1341,8 @@ struct eventdev_ops {
>  	eventdev_eth_rx_adapter_vector_limits_get_t
>  		eth_rx_adapter_vector_limits_get;
>  	/**< Get event vector limits for the Rx adapter */
> +	eventdev_eth_rx_adapter_instance_get_t
> eth_rx_adapter_instance_get;
> +	/**< Get Rx adapter instance id for Rx queue */
> 
>  	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
>  	/**< Get timer adapter capabilities */ diff --git
> a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..ababe13 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
>  	return 0;
>  }
> 
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> +nb_elems)
>  {
> -	const char *name = RXA_ADAPTER_ARRAY;
>  	const struct rte_memzone *mz;
>  	unsigned int sz;
> 
> -	sz = sizeof(*event_eth_rx_adapter) *
> -	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +	sz = elt_size * nb_elems;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> 
>  	mz = rte_memzone_lookup(name);
> @@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
>  		mz = rte_memzone_reserve_aligned(name, sz,
> rte_socket_id(), 0,
>  						 RTE_CACHE_LINE_SIZE);
>  		if (mz == NULL) {
> -			RTE_EDEV_LOG_ERR("failed to reserve memzone err
> = %"
> -					PRId32, rte_errno);
> -			return -rte_errno;
> +			RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +					 " name = %s, err = %"
> +					 PRId32, name, rte_errno);
> +			return NULL;
>  		}
>  	}
> 
> -	event_eth_rx_adapter = mz->addr;
> +	return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +	uint8_t i;
> +
> +	if (event_eth_rx_adapter == NULL) {
> +		event_eth_rx_adapter =
> +			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> +					sizeof(*event_eth_rx_adapter),
> +
> 	RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +		if (event_eth_rx_adapter == NULL)
> +			return -ENOMEM;
> +
> +		for (i = 0; i <
> RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +			event_eth_rx_adapter[i] = NULL;
> +
> +	}
> +
>  	return 0;
>  }
> 
> @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
>  		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
>  		if (mz == NULL)
>  			return -ENOMEM;
> +
>  		event_eth_rx_adapter = mz->addr;
>  	}
> 
> @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter
> *rx_adapter,
>  	int intrq;
>  	int sintrq;
> 
> -
>  	if (rx_adapter->nb_queues == 0)
>  		return;
> 
> @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)  {
>  	struct event_eth_rx_adapter *rx_adapter;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
> 
>  	rx_adapter = rxa_id_to_adapter(id);
> @@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>  	struct eth_device_info *dev_info;
>  	struct rte_event_eth_rx_adapter_vector_limits limits;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
>  	uint32_t *rx_wrr = NULL;
>  	int num_intr_vec;
> 
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
>  	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> EINVAL);
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> 
> @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> uint16_t eth_dev_id,
> 
>  	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>  		rx_queue_id, ret);
> +
>  	return ret;
>  }
> 
> @@ -3286,6 +3315,97 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>  	return 0;
>  }
> 
> +static int
> +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> +		   uint16_t eth_dev_id,
> +		   uint16_t rx_queue_id)
> +{
> +	struct eth_device_info *dev_info;
> +	struct eth_rx_queue_info *queue_info;
> +
> +	if (!rx_adapter->eth_devices)
> +		return 0;
> +
> +	dev_info = &rx_adapter->eth_devices[eth_dev_id];
> +	if (!dev_info || !dev_info->rx_queue)
> +		return 0;
> +
> +	queue_info = &dev_info->rx_queue[rx_queue_id];
> +
> +	return queue_info && queue_info->queue_enabled; }
> +
> +#define rxa_evdev(rx_adapter)
> +(&rte_eventdevs[(rx_adapter)->eventdev_id])
> +
> +#define rxa_dev_instance_get(rx_adapter) \
> +		rxa_evdev((rx_adapter))->dev_ops-
> >eth_rx_adapter_instance_get
> +
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id)
> +{
> +	uint8_t id;
> +	int ret = -EINVAL;
> +	uint32_t caps;
> +	struct event_eth_rx_adapter *rx_adapter;
> +
> +	if (rxa_memzone_lookup())
> +		return -ENOMEM;
> +
> +	if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> eth_dev_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> >nb_rx_queues) {
> +		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +		return -EINVAL;
> +	}
> +
> +	if (rxa_inst_id == NULL) {
> +		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +		return -EINVAL;
> +	}
> +
> +	/* Iterate through all adapter instances */
> +	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> id++) {
> +		rx_adapter = rxa_id_to_adapter(id);
> +		if (!rx_adapter)
> +			continue;
> +
> +		if (rxa_is_queue_added(rx_adapter, eth_dev_id,
> rx_queue_id)) {
> +			*rxa_inst_id = rx_adapter->id;
> +			ret = 0;
> +		}
> +
> +		/* Rx adapter internally mainatains queue information
> +		 * for both internal port and DPDK service port.
> +		 * Eventdev PMD callback is called for future proof only and
> +		 * overrides the above return value if defined.
> +		 */
> +		caps = 0;
> +		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter-
> >eventdev_id,
> +						      eth_dev_id,
> +						      &caps)) {
> +			if (caps &
> RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> +				ret = rxa_dev_instance_get(rx_adapter) ?
> +
> 	rxa_dev_instance_get(rx_adapter)
> +								(eth_dev_id,
> +								 rx_queue_id,
> +								 rxa_inst_id)
> +							: -EINVAL;
> +			}
> +		}
> +
> +		/* return if entry found */
> +		if (ret == 0)
> +			return ret;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> 
>  static int
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..a3313c8 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or
> rte_event_eth_rx_adapter_create() @@ -704,6 +705,29 @@
> __rte_experimental  int
> rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> *event_port_id);
> 
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index.
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to store RX adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +				      uint16_t rx_queue_id,
> +				      uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> 886e2ec..da07a23 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -112,6 +112,9 @@ EXPERIMENTAL {
>  	# added in 22.07
>  	rte_event_port_quiesce;
>  	rte_event_queue_attr_set;
> +
> +	# added in 22.11
> +	rte_event_eth_rx_adapter_instance_get;
>  };
> 
>  INTERNAL {
> --
> 2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
  2022-08-11 13:28                     ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Kundapura, Ganapati
@ 2022-08-27 12:14                       ` Jerin Jacob
  2022-08-29  8:20                         ` Kundapura, Ganapati
  0 siblings, 1 reply; 81+ messages in thread
From: Jerin Jacob @ 2022-08-27 12:14 UTC (permalink / raw)
  To: Kundapura, Ganapati; +Cc: jerinj, Jayatheerthan, Jay, Naga Harish K, S V, dev

On Thu, Aug 11, 2022 at 6:58 PM Kundapura, Ganapati
<ganapati.kundapura@intel.com> wrote:
>
> Hi Jerin,
>    Could you please review this?


Series looks good to me. Some minor comments below. We can merge the
next version(v12).


1) Squash 1/7 and 6/7
2) Squash 4/7 and 7/7
3) Please update doc/guides/rel_notes/release_21_11.rst for new the APIs.




>
> Thanks,
> Ganapati
>
> > -----Original Message-----
> > From: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > Sent: 19 July 2022 13:56
> > To: jerinj@marvell.com; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> > Naga Harish K, S V <s.v.naga.harish.k@intel.com>; dev@dpdk.org
> > Subject: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
> >
> > Added rte_event_eth_rx_adapter_instance_get() to get adapter instance id
> > for specified ethernet device id and rx queue index.
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> > Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
> > ---
> > v11:
> > * added instance_get under 22.11 in version.map
> >
> > v10:
> > * Add Review and Ack to series
> >
> > v9:
> > * Corrected rte_event_eth_tx_adapter_instanceget to
> > * rte_event_eth_tx_adapter_instance_get in
> > event_ethernet_tx_adapter.rst
> >
> > v8:
> > * Removed limits.h inclusion
> >
> > v7:
> > * Remove allocation of instance array and storage of instnace id
> > * in instance array
> > * Use Rx adapter instance data to query instance id for specified
> > * eth_dev_id and rx_queue_id
> >
> > v6:
> > * rx adapter changes removed from patch4 and moved to patch1
> >
> > v5:
> > * patch is split into saperate patches
> >
> > v4:
> > * Moved instance array allocation and instance id storage
> >   before adapter's nb_queue updation for handling the
> >   error case  properly
> >
> > v3:
> > * Fixed checkpatch error
> >
> > v2:
> > * Fixed build issues
> > * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> > * arranged functions in alphabetical order in version.map
> >
> > diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> > index 6940266..c58ba05 100644
> > --- a/lib/eventdev/eventdev_pmd.h
> > +++ b/lib/eventdev/eventdev_pmd.h
> > @@ -888,6 +888,26 @@ typedef int
> > (*eventdev_eth_rx_adapter_vector_limits_get_t)(
> >       const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
> >       struct rte_event_eth_rx_adapter_vector_limits *limits);
> >
> > +/**
> > + * Get Rx adapter instance id for Rx queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of ethernet device
> > + *
> > + * @param rx_queue_id
> > + *  Ethernet device Rx queue index
> > + *
> > + * @param[out] rxa_inst_id
> > + *  Pointer to Rx adapter instance identifier.
> > + *  Contains valid Rx adapter instance id when return value is 0
> > + *
> > + * @return
> > + *   -  0: Success
> > + *   - <0: Error code on failure
> > + */
> > +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> > +     (uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
> > +
> >  typedef uint32_t rte_event_pmd_selftest_seqn_t;  extern int
> > rte_event_pmd_selftest_seqn_dynfield_offset;
> >
> > @@ -1321,6 +1341,8 @@ struct eventdev_ops {
> >       eventdev_eth_rx_adapter_vector_limits_get_t
> >               eth_rx_adapter_vector_limits_get;
> >       /**< Get event vector limits for the Rx adapter */
> > +     eventdev_eth_rx_adapter_instance_get_t
> > eth_rx_adapter_instance_get;
> > +     /**< Get Rx adapter instance id for Rx queue */
> >
> >       eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
> >       /**< Get timer adapter capabilities */ diff --git
> > a/lib/eventdev/rte_event_eth_rx_adapter.c
> > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > index bf8741d..ababe13 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
> >       return 0;
> >  }
> >
> > -static int
> > -rte_event_eth_rx_adapter_init(void)
> > +static void *
> > +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> > +nb_elems)
> >  {
> > -     const char *name = RXA_ADAPTER_ARRAY;
> >       const struct rte_memzone *mz;
> >       unsigned int sz;
> >
> > -     sz = sizeof(*event_eth_rx_adapter) *
> > -         RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > +     sz = elt_size * nb_elems;
> >       sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> >
> >       mz = rte_memzone_lookup(name);
> > @@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
> >               mz = rte_memzone_reserve_aligned(name, sz,
> > rte_socket_id(), 0,
> >                                                RTE_CACHE_LINE_SIZE);
> >               if (mz == NULL) {
> > -                     RTE_EDEV_LOG_ERR("failed to reserve memzone err
> > = %"
> > -                                     PRId32, rte_errno);
> > -                     return -rte_errno;
> > +                     RTE_EDEV_LOG_ERR("failed to reserve memzone"
> > +                                      " name = %s, err = %"
> > +                                      PRId32, name, rte_errno);
> > +                     return NULL;
> >               }
> >       }
> >
> > -     event_eth_rx_adapter = mz->addr;
> > +     return mz->addr;
> > +}
> > +
> > +static int
> > +rte_event_eth_rx_adapter_init(void)
> > +{
> > +     uint8_t i;
> > +
> > +     if (event_eth_rx_adapter == NULL) {
> > +             event_eth_rx_adapter =
> > +                     rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> > +                                     sizeof(*event_eth_rx_adapter),
> > +
> >       RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> > +             if (event_eth_rx_adapter == NULL)
> > +                     return -ENOMEM;
> > +
> > +             for (i = 0; i <
> > RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> > +                     event_eth_rx_adapter[i] = NULL;
> > +
> > +     }
> > +
> >       return 0;
> >  }
> >
> > @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
> >               mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> >               if (mz == NULL)
> >                       return -ENOMEM;
> > +
> >               event_eth_rx_adapter = mz->addr;
> >       }
> >
> > @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter
> > *rx_adapter,
> >       int intrq;
> >       int sintrq;
> >
> > -
> >       if (rx_adapter->nb_queues == 0)
> >               return;
> >
> > @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)  {
> >       struct event_eth_rx_adapter *rx_adapter;
> >
> > +     if (rxa_memzone_lookup())
> > +             return -ENOMEM;
> > +
> >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> > EINVAL);
> >
> >       rx_adapter = rxa_id_to_adapter(id);
> > @@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
> >       struct eth_device_info *dev_info;
> >       struct rte_event_eth_rx_adapter_vector_limits limits;
> >
> > +     if (rxa_memzone_lookup())
> > +             return -ENOMEM;
> > +
> >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> > EINVAL);
> >       RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> > uint16_t eth_dev_id,
> >       uint32_t *rx_wrr = NULL;
> >       int num_intr_vec;
> >
> > +     if (rxa_memzone_lookup())
> > +             return -ENOMEM;
> > +
> >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -
> > EINVAL);
> >       RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> >
> > @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id,
> > uint16_t eth_dev_id,
> >
> >       rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
> >               rx_queue_id, ret);
> > +
> >       return ret;
> >  }
> >
> > @@ -3286,6 +3315,97 @@
> > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> >       return 0;
> >  }
> >
> > +static int
> > +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> > +                uint16_t eth_dev_id,
> > +                uint16_t rx_queue_id)
> > +{
> > +     struct eth_device_info *dev_info;
> > +     struct eth_rx_queue_info *queue_info;
> > +
> > +     if (!rx_adapter->eth_devices)
> > +             return 0;
> > +
> > +     dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > +     if (!dev_info || !dev_info->rx_queue)
> > +             return 0;
> > +
> > +     queue_info = &dev_info->rx_queue[rx_queue_id];
> > +
> > +     return queue_info && queue_info->queue_enabled; }
> > +
> > +#define rxa_evdev(rx_adapter)
> > +(&rte_eventdevs[(rx_adapter)->eventdev_id])
> > +
> > +#define rxa_dev_instance_get(rx_adapter) \
> > +             rxa_evdev((rx_adapter))->dev_ops-
> > >eth_rx_adapter_instance_get
> > +
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +                                   uint16_t rx_queue_id,
> > +                                   uint8_t *rxa_inst_id)
> > +{
> > +     uint8_t id;
> > +     int ret = -EINVAL;
> > +     uint32_t caps;
> > +     struct event_eth_rx_adapter *rx_adapter;
> > +
> > +     if (rxa_memzone_lookup())
> > +             return -ENOMEM;
> > +
> > +     if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > +             RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> > eth_dev_id);
> > +             return -EINVAL;
> > +     }
> > +
> > +     if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> > >nb_rx_queues) {
> > +             RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> > +             return -EINVAL;
> > +     }
> > +
> > +     if (rxa_inst_id == NULL) {
> > +             RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> > +             return -EINVAL;
> > +     }
> > +
> > +     /* Iterate through all adapter instances */
> > +     for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > id++) {
> > +             rx_adapter = rxa_id_to_adapter(id);
> > +             if (!rx_adapter)
> > +                     continue;
> > +
> > +             if (rxa_is_queue_added(rx_adapter, eth_dev_id,
> > rx_queue_id)) {
> > +                     *rxa_inst_id = rx_adapter->id;
> > +                     ret = 0;
> > +             }
> > +
> > +             /* Rx adapter internally mainatains queue information
> > +              * for both internal port and DPDK service port.
> > +              * Eventdev PMD callback is called for future proof only and
> > +              * overrides the above return value if defined.
> > +              */
> > +             caps = 0;
> > +             if (!rte_event_eth_rx_adapter_caps_get(rx_adapter-
> > >eventdev_id,
> > +                                                   eth_dev_id,
> > +                                                   &caps)) {
> > +                     if (caps &
> > RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> > +                             ret = rxa_dev_instance_get(rx_adapter) ?
> > +
> >       rxa_dev_instance_get(rx_adapter)
> > +                                                             (eth_dev_id,
> > +                                                              rx_queue_id,
> > +                                                              rxa_inst_id)
> > +                                                     : -EINVAL;
> > +                     }
> > +             }
> > +
> > +             /* return if entry found */
> > +             if (ret == 0)
> > +                     return ret;
> > +     }
> > +
> > +     return -EINVAL;
> > +}
> > +
> >  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
> >
> >  static int
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> > b/lib/eventdev/rte_event_eth_rx_adapter.h
> > index 3608a7b..a3313c8 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> > @@ -38,6 +38,7 @@
> >   *  - rte_event_eth_rx_adapter_queue_stats_get()
> >   *  - rte_event_eth_rx_adapter_queue_stats_reset()
> >   *  - rte_event_eth_rx_adapter_event_port_get()
> > + *  - rte_event_eth_rx_adapter_instance_get()
> >   *
> >   * The application creates an ethernet to event adapter using
> >   * rte_event_eth_rx_adapter_create_ext() or
> > rte_event_eth_rx_adapter_create() @@ -704,6 +705,29 @@
> > __rte_experimental  int
> > rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> > *event_port_id);
> >
> > +/**
> > + * Get RX adapter instance ID for a RX queue
> > + *
> > + * @param eth_dev_id
> > + *  Port identifier of Ethernet device.
> > + *
> > + * @param rx_queue_id
> > + *  Ethernet device receive queue index.
> > + *
> > + * @param[out] rxa_inst_id
> > + *  Pointer to store RX adapter instance identifier.
> > + *  Contains valid Rx adapter instance id when return value is 0
> > + *
> > + * @return
> > + *  -  0: Success
> > + *  - <0: Error code on failure
> > + */
> > +__rte_experimental
> > +int
> > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > +                                   uint16_t rx_queue_id,
> > +                                   uint8_t *rxa_inst_id);
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index
> > 886e2ec..da07a23 100644
> > --- a/lib/eventdev/version.map
> > +++ b/lib/eventdev/version.map
> > @@ -112,6 +112,9 @@ EXPERIMENTAL {
> >       # added in 22.07
> >       rte_event_port_quiesce;
> >       rte_event_queue_attr_set;
> > +
> > +     # added in 22.11
> > +     rte_event_eth_rx_adapter_instance_get;
> >  };
> >
> >  INTERNAL {
> > --
> > 2.6.4
>

^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 1/6] eventdev/eth_rx: add adapter instance get API
  2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
                                       ` (6 preceding siblings ...)
  2022-08-11 13:28                     ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Kundapura, Ganapati
@ 2022-08-29  8:14                     ` Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 2/6] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
                                         ` (6 more replies)
  7 siblings, 7 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_rx_adapter_instance_get() to get
adapter instance id for specified ethernet device id and
rx queue index.

Added rte_event_eth_rx_adapter_instance_get() details in
prog_guide/event_ethernet_rx_adapter.rst

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

---
V12:
* Squashed 1/7 and 6/7
* Squashed 4/7 and 7/7
* Updated 22.11.rst for the new APIs

v11:
* added instance_get under 22.11 in version.map

v10:
* Add Review and Ack to series

v9:
* Corrected rte_event_eth_tx_adapter_instanceget to
* rte_event_eth_tx_adapter_instance_get in event_ethernet_tx_adapter.rst

v8:
* Removed limits.h inclusion

v7:
* Remove allocation of instance array and storage of instnace id
* in instance array
* Use Rx adapter instance data to query instance id for specified
* eth_dev_id and rx_queue_id

v6:
* rx adapter changes removed from patch4 and moved to patch1

v5:
* patch is split into saperate patches

v4:
* Moved instance array allocation and instance id storage
  before adapter's nb_queue updation for handling the
  error case  properly

v3:
* Fixed checkpatch error

v2:
* Fixed build issues
* Added telemetry support for rte_event_eth_rx_adapter_instance_get
* arranged functions in alphabetical order in version.map

diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 3b4ef50..5b9d0cf 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
 The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
 reset queue level stats when queue level event buffer is in use.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``rte_event_eth_rx_adapter_instance_get()`` function reports
+rx adapter instance id for a specified ethernet device id and rx queue index.
+
 Interrupt Based Rx Queues
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 6940266..c58ba05 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
 	const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
 	struct rte_event_eth_rx_adapter_vector_limits *limits);
 
+/**
+ * Get Rx adapter instance id for Rx queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of ethernet device
+ *
+ * @param rx_queue_id
+ *  Ethernet device Rx queue index
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to Rx adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *   -  0: Success
+ *   - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_rx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
+
 typedef uint32_t rte_event_pmd_selftest_seqn_t;
 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
 
@@ -1321,6 +1341,8 @@ struct eventdev_ops {
 	eventdev_eth_rx_adapter_vector_limits_get_t
 		eth_rx_adapter_vector_limits_get;
 	/**< Get event vector limits for the Rx adapter */
+	eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
+	/**< Get Rx adapter instance id for Rx queue */
 
 	eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
 	/**< Get timer adapter capabilities */
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d..ababe13 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
 	return 0;
 }
 
-static int
-rte_event_eth_rx_adapter_init(void)
+static void *
+rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 {
-	const char *name = RXA_ADAPTER_ARRAY;
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
-	sz = sizeof(*event_eth_rx_adapter) *
-	    RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
+	sz = elt_size * nb_elems;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
 	mz = rte_memzone_lookup(name);
@@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
 		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
-			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
-					PRId32, rte_errno);
-			return -rte_errno;
+			RTE_EDEV_LOG_ERR("failed to reserve memzone"
+					 " name = %s, err = %"
+					 PRId32, name, rte_errno);
+			return NULL;
 		}
 	}
 
-	event_eth_rx_adapter = mz->addr;
+	return mz->addr;
+}
+
+static int
+rte_event_eth_rx_adapter_init(void)
+{
+	uint8_t i;
+
+	if (event_eth_rx_adapter == NULL) {
+		event_eth_rx_adapter =
+			rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
+					sizeof(*event_eth_rx_adapter),
+					RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
+		if (event_eth_rx_adapter == NULL)
+			return -ENOMEM;
+
+		for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
+			event_eth_rx_adapter[i] = NULL;
+
+	}
+
 	return 0;
 }
 
@@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
 		mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
 		if (mz == NULL)
 			return -ENOMEM;
+
 		event_eth_rx_adapter = mz->addr;
 	}
 
@@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
 	int intrq;
 	int sintrq;
 
-
 	if (rx_adapter->nb_queues == 0)
 		return;
 
@@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
 {
 	struct event_eth_rx_adapter *rx_adapter;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	rx_adapter = rxa_id_to_adapter(id);
@@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
 	struct eth_device_info *dev_info;
 	struct rte_event_eth_rx_adapter_vector_limits limits;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 	uint32_t *rx_wrr = NULL;
 	int num_intr_vec;
 
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
 	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
 
@@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
 
 	rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
 		rx_queue_id, ret);
+
 	return ret;
 }
 
@@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
 	return 0;
 }
 
+static int
+rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
+		   uint16_t eth_dev_id,
+		   uint16_t rx_queue_id)
+{
+	struct eth_device_info *dev_info;
+	struct eth_rx_queue_info *queue_info;
+
+	if (!rx_adapter->eth_devices)
+		return 0;
+
+	dev_info = &rx_adapter->eth_devices[eth_dev_id];
+	if (!dev_info || !dev_info->rx_queue)
+		return 0;
+
+	queue_info = &dev_info->rx_queue[rx_queue_id];
+
+	return queue_info && queue_info->queue_enabled;
+}
+
+#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
+
+#define rxa_dev_instance_get(rx_adapter) \
+		rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
+
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct event_eth_rx_adapter *rx_adapter;
+
+	if (rxa_memzone_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rxa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
+		rx_adapter = rxa_id_to_adapter(id);
+		if (!rx_adapter)
+			continue;
+
+		if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
+			*rxa_inst_id = rx_adapter->id;
+			ret = 0;
+		}
+
+		/* Rx adapter internally mainatains queue information
+		 * for both internal port and DPDK service port.
+		 * Eventdev PMD callback is called for future proof only and
+		 * overrides the above return value if defined.
+		 */
+		caps = 0;
+		if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
+						      eth_dev_id,
+						      &caps)) {
+			if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
+				ret = rxa_dev_instance_get(rx_adapter) ?
+						rxa_dev_instance_get(rx_adapter)
+								(eth_dev_id,
+								 rx_queue_id,
+								 rxa_inst_id)
+							: -EINVAL;
+			}
+		}
+
+		/* return if entry found */
+		if (ret == 0)
+			return ret;
+	}
+
+	return -EINVAL;
+}
+
 #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
 
 static int
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
index 3608a7b..a3313c8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -38,6 +38,7 @@
  *  - rte_event_eth_rx_adapter_queue_stats_get()
  *  - rte_event_eth_rx_adapter_queue_stats_reset()
  *  - rte_event_eth_rx_adapter_event_port_get()
+ *  - rte_event_eth_rx_adapter_instance_get()
  *
  * The application creates an ethernet to event adapter using
  * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@@ -704,6 +705,29 @@ __rte_experimental
 int
 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
 
+/**
+ * Get RX adapter instance ID for a RX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device.
+ *
+ * @param rx_queue_id
+ *  Ethernet device receive queue index.
+ *
+ * @param[out] rxa_inst_id
+ *  Pointer to store RX adapter instance identifier.
+ *  Contains valid Rx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t rx_queue_id,
+				      uint8_t *rxa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index d99f996..0066187 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -112,6 +112,9 @@ EXPERIMENTAL {
 	# added in 22.07
 	rte_event_port_quiesce;
 	rte_event_queue_attr_set;
+
+	# added in 22.11
+	rte_event_eth_rx_adapter_instance_get;
 };
 
 INTERNAL {
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 2/6] eventdev/eth_rx: add telemetry callback for instance get
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 3/6] test/eth_rx: add test case for instance get API Ganapati Kundapura
                                         ` (5 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added telemetry handler for rte_event_eth_rx_adapter_instance_get()
to retrieve adapter instance id for specified ethernet device id
and rx queue index.

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ababe13..64a6add 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3674,6 +3674,68 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
 	return ret;
 }
 
+static int
+handle_rxa_instance_get(const char *cmd __rte_unused,
+			const char *params,
+			struct rte_tel_data *d)
+{
+	uint8_t instance_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id, ret = -1;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	l_params = strdup(params);
+	if (l_params == NULL)
+		return -ENOMEM;
+	token = strtok(l_params, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		ret = -EINVAL;
+		goto error;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, ignoring");
+
+	/* Parsing parameter finished */
+	free(l_params);
+
+	if (rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						  rx_queue_id,
+						  &instance_id)) {
+		RTE_EDEV_LOG_ERR("Failed to get RX adapter instance ID "
+				 " for rx_queue_id = %d", rx_queue_id);
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+
+	return 0;
+
+error:
+	free(l_params);
+	return ret;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3695,4 +3757,8 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
 		handle_rxa_queue_stats_reset,
 		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_rxq_instance_get",
+		handle_rxa_instance_get,
+		"Returns Rx adapter instance id. Parameter: dev_id, queue_id");
 }
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 3/6] test/eth_rx: add test case for instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 2/6] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 4/6] eventdev/eth_tx: add " Ganapati Kundapura
                                         ` (4 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@ adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 4/6] eventdev/eth_tx: add instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 2/6] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 3/6] test/eth_rx: add test case for instance get API Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-09-02 13:10                         ` Jerin Jacob
  2022-08-29  8:14                       ` [PATCH v12 5/6] test/eth_tx: add testcase for " Ganapati Kundapura
                                         ` (3 subsequent siblings)
  6 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rte_event_eth_tx_adapter_instance_get() to get the
adapter instance id for specified ethernet device id and
tx queue index.

Added rte_event_eth_tx_adapter_instance_get() details in
prog_guide/event_ethernet_tx_adapter.rst

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index f80d226..4da9bcd 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
 the counts from the eventdev PMD callback if the callback is supported, and
 the counts maintained by the service function, if one exists.
 
+Getting Adapter instance id
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The  ``rte_event_eth_tx_adapter_instance_get()`` function reports
+tx adapter instance id for a specified ethernet device id and tx queue index.
+
 Tx event vectorization
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index c58ba05..f514a37 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
 					const struct rte_eventdev *dev);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Ethernet device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+typedef int (*eventdev_eth_tx_adapter_instance_get_t)
+	(uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
+
+
 /** Event device operations function pointer table */
 struct eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -1386,6 +1407,8 @@ struct eventdev_ops {
 	/**< Get eth Tx adapter statistics */
 	eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
 	/**< Reset eth Tx adapter statistics */
+	eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
+	/**< Get Tx adapter instance id for Tx queue */
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index b4b37f1..aaef352 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -18,6 +18,9 @@
 #define TXA_INVALID_DEV_ID	INT32_C(-1)
 #define TXA_INVALID_SERVICE_ID	INT64_C(-1)
 
+#define TXA_ADAPTER_ARRAY "txa_adapter_array"
+#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
+
 #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
 
 #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
@@ -41,6 +44,9 @@
 
 #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
 
+#define txa_dev_instance_get(id) \
+			txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
+
 #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
 do { \
 	if (!txa_valid_id(id)) { \
@@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
 }
 
 static int
+txa_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (txa_dev_id_array == NULL) {
+		mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_dev_id_array = mz->addr;
+	}
+
+	if (txa_service_data_array == NULL) {
+		mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+		txa_service_data_array = mz->addr;
+	}
+
+	return 0;
+}
+
+static int
 txa_dev_id_array_init(void)
 {
 	if (txa_dev_id_array == NULL) {
 		int i;
 
-		txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
+		txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
 					sizeof(int),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_dev_id_array == NULL)
@@ -222,12 +250,18 @@ static int
 txa_service_data_init(void)
 {
 	if (txa_service_data_array == NULL) {
+		int i;
+
 		txa_service_data_array =
-				txa_memzone_array_get("txa_service_data_array",
+				txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
 					sizeof(*txa_service_data_array),
 					RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
 		if (txa_service_data_array == NULL)
 			return -ENOMEM;
+
+		/* Reset the txa service pointers */
+		for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
+			txa_service_data_array[i] = NULL;
 	}
 
 	return 0;
@@ -1222,3 +1256,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
 	rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
 	return ret;
 }
+
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id)
+{
+	uint8_t id;
+	int ret = -EINVAL;
+	uint32_t caps;
+	struct txa_service_data *txa;
+
+	if (txa_lookup())
+		return -ENOMEM;
+
+	if (eth_dev_id >= rte_eth_dev_count_avail()) {
+		RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
+		return -EINVAL;
+	}
+
+	if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
+		return -EINVAL;
+	}
+
+	if (txa_inst_id == NULL) {
+		RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
+		return -EINVAL;
+	}
+
+	/* Iterate through all Tx adapter instances */
+	for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
+		txa = txa_service_id_to_data(id);
+		if (!txa)
+			continue;
+
+		caps = 0;
+		if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
+						      eth_dev_id,
+						      &caps))
+			continue;
+
+		if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
+			ret = txa_dev_instance_get(id) ?
+					txa_dev_instance_get(id)(eth_dev_id,
+								 tx_queue_id,
+								 txa_inst_id)
+							: -EINVAL;
+			if (ret == 0)
+				return ret;
+		} else {
+			struct rte_eth_dev *eth_dev;
+
+			eth_dev = &rte_eth_devices[eth_dev_id];
+
+			if (txa_service_is_queue_added(txa, eth_dev,
+						       tx_queue_id)) {
+				*txa_inst_id = txa->id;
+				return 0;
+			}
+		}
+	}
+
+	return -EINVAL;
+}
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
index 3908c2d..9432b74 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -34,6 +34,7 @@
  *  - rte_event_eth_tx_adapter_enqueue()
  *  - rte_event_eth_tx_adapter_event_port_get()
  *  - rte_event_eth_tx_adapter_service_id_get()
+ *  - rte_event_eth_tx_adapter_instance_get()
  *
  * The application creates the adapter using
  * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
@@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
 int
 rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
 
+/**
+ * Get TX adapter instance id for TX queue
+ *
+ * @param eth_dev_id
+ *  Port identifier of Ethernet device
+ *
+ * @param tx_queue_id
+ *  Etherdev device TX queue index
+ *
+ * @param[out] txa_inst_id
+ *  Pointer to TX adapter instance identifier
+ *  Contains valid Tx adapter instance id when return value is 0
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
+				      uint16_t tx_queue_id,
+				      uint8_t *txa_inst_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 0066187..9a71cf3 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -115,6 +115,7 @@ EXPERIMENTAL {
 
 	# added in 22.11
 	rte_event_eth_rx_adapter_instance_get;
+	rte_event_eth_tx_adapter_instance_get;
 };
 
 INTERNAL {
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 5/6] test/eth_tx: add testcase for instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
                                         ` (2 preceding siblings ...)
  2022-08-29  8:14                       ` [PATCH v12 4/6] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 6/6] doc: Added adapter " Ganapati Kundapura
                                         ` (2 subsequent siblings)
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added testcase for rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c
index 2900532..98debfd 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void)
 #define MAX_NUM_QUEUE		RTE_PMD_RING_MAX_RX_RINGS
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 #define SOCKET0			0
 #define RING_SIZE		256
 #define ETH_NAME_LEN		32
@@ -639,6 +640,78 @@ tx_adapter_service(void)
 }
 
 static int
+tx_adapter_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_tx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong tx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_tx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add another queue to tx adapter */
+	err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Tx adapter */
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
 tx_adapter_dynamic_device(void)
 {
 	uint16_t port_id = rte_eth_dev_count_avail();
@@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_start_stop),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_service),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_instance_get),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 6/6] doc: Added adapter instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
                                         ` (3 preceding siblings ...)
  2022-08-29  8:14                       ` [PATCH v12 5/6] test/eth_tx: add testcase for " Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-08-29  8:14                       ` [PATCH v12 6/6] doc: added " Ganapati Kundapura
  2022-09-02 13:09                       ` [PATCH v12 1/6] eventdev/eth_rx: add " Jerin Jacob
  6 siblings, 0 replies; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rx adapter instance get - rte_event_eth_rx_adapter_instance_get()
and tx adapter instance get - rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 8c021cf..091cc84 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -23,6 +23,14 @@ DPDK Release 22.11
 
 New Features
 ------------
+* **Added adapter instance get API**
+
+* Added ``rte_event_eth_rx_adapter_instance_get`` to get
+  rx adapter instance id for specified ethernet device id and
+  rx queue index.
+* Added ``rte_event_eth_tx_adapter_instance_get`` to get the
+  tx adapter instance id for specified ethernet device id and
+  tx queue index.
 
 .. This section should contain new features added in this release.
    Sample format:
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH v12 6/6] doc: added adapter instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
                                         ` (4 preceding siblings ...)
  2022-08-29  8:14                       ` [PATCH v12 6/6] doc: Added adapter " Ganapati Kundapura
@ 2022-08-29  8:14                       ` Ganapati Kundapura
  2022-09-02 13:11                         ` Jerin Jacob
  2022-09-02 13:09                       ` [PATCH v12 1/6] eventdev/eth_rx: add " Jerin Jacob
  6 siblings, 1 reply; 81+ messages in thread
From: Ganapati Kundapura @ 2022-08-29  8:14 UTC (permalink / raw)
  To: dev, jerinj, jay.jayatheerthan; +Cc: s.v.naga.harish.k

Added rx adapter instance get - rte_event_eth_rx_adapter_instance_get()
and tx adapter instance get - rte_event_eth_tx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 8c021cf..091cc84 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -23,6 +23,14 @@ DPDK Release 22.11
 
 New Features
 ------------
+* **Added adapter instance get API**
+
+* Added ``rte_event_eth_rx_adapter_instance_get`` to get
+  rx adapter instance id for specified ethernet device id and
+  rx queue index.
+* Added ``rte_event_eth_tx_adapter_instance_get`` to get the
+  tx adapter instance id for specified ethernet device id and
+  tx queue index.
 
 .. This section should contain new features added in this release.
    Sample format:
-- 
2.6.4


^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
  2022-08-27 12:14                       ` Jerin Jacob
@ 2022-08-29  8:20                         ` Kundapura, Ganapati
  0 siblings, 0 replies; 81+ messages in thread
From: Kundapura, Ganapati @ 2022-08-29  8:20 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: jerinj, Jayatheerthan, Jay, Naga Harish K, S V, dev

Hi Jerin,

> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: 27 August 2022 17:44
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Cc: jerinj@marvell.com; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> Naga Harish K, S V <s.v.naga.harish.k@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get API
> 
> On Thu, Aug 11, 2022 at 6:58 PM Kundapura, Ganapati
> <ganapati.kundapura@intel.com> wrote:
> >
> > Hi Jerin,
> >    Could you please review this?
> 
> 
> Series looks good to me. Some minor comments below. We can merge the
> next version(v12).
> 
> 
> 1) Squash 1/7 and 6/7
> 2) Squash 4/7 and 7/7
> 3) Please update doc/guides/rel_notes/release_21_11.rst for new the APIs.
>
Posted V12 with the suggested changes
 
> 
> 
> 
> >
> > Thanks,
> > Ganapati
> >
> > > -----Original Message-----
> > > From: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > > Sent: 19 July 2022 13:56
> > > To: jerinj@marvell.com; Jayatheerthan, Jay
> > > <jay.jayatheerthan@intel.com>; Naga Harish K, S V
> > > <s.v.naga.harish.k@intel.com>; dev@dpdk.org
> > > Subject: [PATCH v11 1/7] eventdev/eth_rx: add adapter instance get
> > > API
> > >
> > > Added rte_event_eth_rx_adapter_instance_get() to get adapter
> > > instance id for specified ethernet device id and rx queue index.
> > >
> > > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > >
> > > Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> > > Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
> > > ---
> > > v11:
> > > * added instance_get under 22.11 in version.map
> > >
> > > v10:
> > > * Add Review and Ack to series
> > >
> > > v9:
> > > * Corrected rte_event_eth_tx_adapter_instanceget to
> > > * rte_event_eth_tx_adapter_instance_get in
> > > event_ethernet_tx_adapter.rst
> > >
> > > v8:
> > > * Removed limits.h inclusion
> > >
> > > v7:
> > > * Remove allocation of instance array and storage of instnace id
> > > * in instance array
> > > * Use Rx adapter instance data to query instance id for specified
> > > * eth_dev_id and rx_queue_id
> > >
> > > v6:
> > > * rx adapter changes removed from patch4 and moved to patch1
> > >
> > > v5:
> > > * patch is split into saperate patches
> > >
> > > v4:
> > > * Moved instance array allocation and instance id storage
> > >   before adapter's nb_queue updation for handling the
> > >   error case  properly
> > >
> > > v3:
> > > * Fixed checkpatch error
> > >
> > > v2:
> > > * Fixed build issues
> > > * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> > > * arranged functions in alphabetical order in version.map
> > >
> > > diff --git a/lib/eventdev/eventdev_pmd.h
> > > b/lib/eventdev/eventdev_pmd.h index 6940266..c58ba05 100644
> > > --- a/lib/eventdev/eventdev_pmd.h
> > > +++ b/lib/eventdev/eventdev_pmd.h
> > > @@ -888,6 +888,26 @@ typedef int
> > > (*eventdev_eth_rx_adapter_vector_limits_get_t)(
> > >       const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
> > >       struct rte_event_eth_rx_adapter_vector_limits *limits);
> > >
> > > +/**
> > > + * Get Rx adapter instance id for Rx queue
> > > + *
> > > + * @param eth_dev_id
> > > + *  Port identifier of ethernet device
> > > + *
> > > + * @param rx_queue_id
> > > + *  Ethernet device Rx queue index
> > > + *
> > > + * @param[out] rxa_inst_id
> > > + *  Pointer to Rx adapter instance identifier.
> > > + *  Contains valid Rx adapter instance id when return value is 0
> > > + *
> > > + * @return
> > > + *   -  0: Success
> > > + *   - <0: Error code on failure
> > > + */
> > > +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> > > +     (uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t
> > > +*rxa_inst_id);
> > > +
> > >  typedef uint32_t rte_event_pmd_selftest_seqn_t;  extern int
> > > rte_event_pmd_selftest_seqn_dynfield_offset;
> > >
> > > @@ -1321,6 +1341,8 @@ struct eventdev_ops {
> > >       eventdev_eth_rx_adapter_vector_limits_get_t
> > >               eth_rx_adapter_vector_limits_get;
> > >       /**< Get event vector limits for the Rx adapter */
> > > +     eventdev_eth_rx_adapter_instance_get_t
> > > eth_rx_adapter_instance_get;
> > > +     /**< Get Rx adapter instance id for Rx queue */
> > >
> > >       eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
> > >       /**< Get timer adapter capabilities */ diff --git
> > > a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > index bf8741d..ababe13 100644
> > > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
> > >       return 0;
> > >  }
> > >
> > > -static int
> > > -rte_event_eth_rx_adapter_init(void)
> > > +static void *
> > > +rxa_memzone_array_get(const char *name, unsigned int elt_size, int
> > > +nb_elems)
> > >  {
> > > -     const char *name = RXA_ADAPTER_ARRAY;
> > >       const struct rte_memzone *mz;
> > >       unsigned int sz;
> > >
> > > -     sz = sizeof(*event_eth_rx_adapter) *
> > > -         RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > > +     sz = elt_size * nb_elems;
> > >       sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> > >
> > >       mz = rte_memzone_lookup(name); @@ -1431,13 +1429,34 @@
> > > rte_event_eth_rx_adapter_init(void)
> > >               mz = rte_memzone_reserve_aligned(name, sz,
> > > rte_socket_id(), 0,
> > >                                                RTE_CACHE_LINE_SIZE);
> > >               if (mz == NULL) {
> > > -                     RTE_EDEV_LOG_ERR("failed to reserve memzone err
> > > = %"
> > > -                                     PRId32, rte_errno);
> > > -                     return -rte_errno;
> > > +                     RTE_EDEV_LOG_ERR("failed to reserve memzone"
> > > +                                      " name = %s, err = %"
> > > +                                      PRId32, name, rte_errno);
> > > +                     return NULL;
> > >               }
> > >       }
> > >
> > > -     event_eth_rx_adapter = mz->addr;
> > > +     return mz->addr;
> > > +}
> > > +
> > > +static int
> > > +rte_event_eth_rx_adapter_init(void)
> > > +{
> > > +     uint8_t i;
> > > +
> > > +     if (event_eth_rx_adapter == NULL) {
> > > +             event_eth_rx_adapter =
> > > +                     rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> > > +                                     sizeof(*event_eth_rx_adapter),
> > > +
> > >       RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> > > +             if (event_eth_rx_adapter == NULL)
> > > +                     return -ENOMEM;
> > > +
> > > +             for (i = 0; i <
> > > RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> > > +                     event_eth_rx_adapter[i] = NULL;
> > > +
> > > +     }
> > > +
> > >       return 0;
> > >  }
> > >
> > > @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
> > >               mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
> > >               if (mz == NULL)
> > >                       return -ENOMEM;
> > > +
> > >               event_eth_rx_adapter = mz->addr;
> > >       }
> > >
> > > @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter
> > > *rx_adapter,
> > >       int intrq;
> > >       int sintrq;
> > >
> > > -
> > >       if (rx_adapter->nb_queues == 0)
> > >               return;
> > >
> > > @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)  {
> > >       struct event_eth_rx_adapter *rx_adapter;
> > >
> > > +     if (rxa_memzone_lookup())
> > > +             return -ENOMEM;
> > > +
> > >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, - EINVAL);
> > >
> > >       rx_adapter = rxa_id_to_adapter(id); @@ -2561,6 +2583,9 @@
> > > rte_event_eth_rx_adapter_queue_add(uint8_t id,
> > >       struct eth_device_info *dev_info;
> > >       struct rte_event_eth_rx_adapter_vector_limits limits;
> > >
> > > +     if (rxa_memzone_lookup())
> > > +             return -ENOMEM;
> > > +
> > >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, - EINVAL);
> > >       RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> > >
> > > @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id,
> > > uint16_t eth_dev_id,
> > >       uint32_t *rx_wrr = NULL;
> > >       int num_intr_vec;
> > >
> > > +     if (rxa_memzone_lookup())
> > > +             return -ENOMEM;
> > > +
> > >       RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, - EINVAL);
> > >       RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
> > >
> > > @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t
> id,
> > > uint16_t eth_dev_id,
> > >
> > >       rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
> > >               rx_queue_id, ret);
> > > +
> > >       return ret;
> > >  }
> > >
> > > @@ -3286,6 +3315,97 @@
> > > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> > >       return 0;
> > >  }
> > >
> > > +static int
> > > +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> > > +                uint16_t eth_dev_id,
> > > +                uint16_t rx_queue_id) {
> > > +     struct eth_device_info *dev_info;
> > > +     struct eth_rx_queue_info *queue_info;
> > > +
> > > +     if (!rx_adapter->eth_devices)
> > > +             return 0;
> > > +
> > > +     dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > > +     if (!dev_info || !dev_info->rx_queue)
> > > +             return 0;
> > > +
> > > +     queue_info = &dev_info->rx_queue[rx_queue_id];
> > > +
> > > +     return queue_info && queue_info->queue_enabled; }
> > > +
> > > +#define rxa_evdev(rx_adapter)
> > > +(&rte_eventdevs[(rx_adapter)->eventdev_id])
> > > +
> > > +#define rxa_dev_instance_get(rx_adapter) \
> > > +             rxa_evdev((rx_adapter))->dev_ops-
> > > >eth_rx_adapter_instance_get
> > > +
> > > +int
> > > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > > +                                   uint16_t rx_queue_id,
> > > +                                   uint8_t *rxa_inst_id) {
> > > +     uint8_t id;
> > > +     int ret = -EINVAL;
> > > +     uint32_t caps;
> > > +     struct event_eth_rx_adapter *rx_adapter;
> > > +
> > > +     if (rxa_memzone_lookup())
> > > +             return -ENOMEM;
> > > +
> > > +     if (eth_dev_id >= rte_eth_dev_count_avail()) {
> > > +             RTE_EDEV_LOG_ERR("Invalid ethernet port id %u",
> > > eth_dev_id);
> > > +             return -EINVAL;
> > > +     }
> > > +
> > > +     if (rx_queue_id >= rte_eth_devices[eth_dev_id].data-
> > > >nb_rx_queues) {
> > > +             RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> > > +             return -EINVAL;
> > > +     }
> > > +
> > > +     if (rxa_inst_id == NULL) {
> > > +             RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> > > +             return -EINVAL;
> > > +     }
> > > +
> > > +     /* Iterate through all adapter instances */
> > > +     for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> > > id++) {
> > > +             rx_adapter = rxa_id_to_adapter(id);
> > > +             if (!rx_adapter)
> > > +                     continue;
> > > +
> > > +             if (rxa_is_queue_added(rx_adapter, eth_dev_id,
> > > rx_queue_id)) {
> > > +                     *rxa_inst_id = rx_adapter->id;
> > > +                     ret = 0;
> > > +             }
> > > +
> > > +             /* Rx adapter internally mainatains queue information
> > > +              * for both internal port and DPDK service port.
> > > +              * Eventdev PMD callback is called for future proof only and
> > > +              * overrides the above return value if defined.
> > > +              */
> > > +             caps = 0;
> > > +             if (!rte_event_eth_rx_adapter_caps_get(rx_adapter-
> > > >eventdev_id,
> > > +                                                   eth_dev_id,
> > > +                                                   &caps)) {
> > > +                     if (caps &
> > > RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> > > +                             ret = rxa_dev_instance_get(rx_adapter) ?
> > > +
> > >       rxa_dev_instance_get(rx_adapter)
> > > +                                                             (eth_dev_id,
> > > +                                                              rx_queue_id,
> > > +                                                              rxa_inst_id)
> > > +                                                     : -EINVAL;
> > > +                     }
> > > +             }
> > > +
> > > +             /* return if entry found */
> > > +             if (ret == 0)
> > > +                     return ret;
> > > +     }
> > > +
> > > +     return -EINVAL;
> > > +}
> > > +
> > >  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s,
> > > stats.s)
> > >
> > >  static int
> > > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h
> > > b/lib/eventdev/rte_event_eth_rx_adapter.h
> > > index 3608a7b..a3313c8 100644
> > > --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> > > +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> > > @@ -38,6 +38,7 @@
> > >   *  - rte_event_eth_rx_adapter_queue_stats_get()
> > >   *  - rte_event_eth_rx_adapter_queue_stats_reset()
> > >   *  - rte_event_eth_rx_adapter_event_port_get()
> > > + *  - rte_event_eth_rx_adapter_instance_get()
> > >   *
> > >   * The application creates an ethernet to event adapter using
> > >   * rte_event_eth_rx_adapter_create_ext() or
> > > rte_event_eth_rx_adapter_create() @@ -704,6 +705,29 @@
> > > __rte_experimental  int
> > > rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t
> > > *event_port_id);
> > >
> > > +/**
> > > + * Get RX adapter instance ID for a RX queue
> > > + *
> > > + * @param eth_dev_id
> > > + *  Port identifier of Ethernet device.
> > > + *
> > > + * @param rx_queue_id
> > > + *  Ethernet device receive queue index.
> > > + *
> > > + * @param[out] rxa_inst_id
> > > + *  Pointer to store RX adapter instance identifier.
> > > + *  Contains valid Rx adapter instance id when return value is 0
> > > + *
> > > + * @return
> > > + *  -  0: Success
> > > + *  - <0: Error code on failure
> > > + */
> > > +__rte_experimental
> > > +int
> > > +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> > > +                                   uint16_t rx_queue_id,
> > > +                                   uint8_t *rxa_inst_id);
> > > +
> > >  #ifdef __cplusplus
> > >  }
> > >  #endif
> > > diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> > > index
> > > 886e2ec..da07a23 100644
> > > --- a/lib/eventdev/version.map
> > > +++ b/lib/eventdev/version.map
> > > @@ -112,6 +112,9 @@ EXPERIMENTAL {
> > >       # added in 22.07
> > >       rte_event_port_quiesce;
> > >       rte_event_queue_attr_set;
> > > +
> > > +     # added in 22.11
> > > +     rte_event_eth_rx_adapter_instance_get;
> > >  };
> > >
> > >  INTERNAL {
> > > --
> > > 2.6.4
> >

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH v12 1/6] eventdev/eth_rx: add adapter instance get API
  2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
                                         ` (5 preceding siblings ...)
  2022-08-29  8:14                       ` [PATCH v12 6/6] doc: added " Ganapati Kundapura
@ 2022-09-02 13:09                       ` Jerin Jacob
  6 siblings, 0 replies; 81+ messages in thread
From: Jerin Jacob @ 2022-09-02 13:09 UTC (permalink / raw)
  To: Ganapati Kundapura
  Cc: dpdk-dev, Jerin Jacob, Jayatheerthan, Jay, Naga Harish K, S V

On Mon, Aug 29, 2022 at 1:44 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> Added rte_event_eth_rx_adapter_instance_get() to get
> adapter instance id for specified ethernet device id and
> rx queue index.
>
> Added rte_event_eth_rx_adapter_instance_get() details in
> prog_guide/event_ethernet_rx_adapter.rst
>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

No need space between these lines
Will fix on apply.

>
> Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>

>
> ---
> V12:
> * Squashed 1/7 and 6/7
> * Squashed 4/7 and 7/7
> * Updated 22.11.rst for the new APIs
>
> v11:
> * added instance_get under 22.11 in version.map
>
> v10:
> * Add Review and Ack to series
>
> v9:
> * Corrected rte_event_eth_tx_adapter_instanceget to
> * rte_event_eth_tx_adapter_instance_get in event_ethernet_tx_adapter.rst
>
> v8:
> * Removed limits.h inclusion
>
> v7:
> * Remove allocation of instance array and storage of instnace id
> * in instance array
> * Use Rx adapter instance data to query instance id for specified
> * eth_dev_id and rx_queue_id
>
> v6:
> * rx adapter changes removed from patch4 and moved to patch1
>
> v5:
> * patch is split into saperate patches
>
> v4:
> * Moved instance array allocation and instance id storage
>   before adapter's nb_queue updation for handling the
>   error case  properly
>
> v3:
> * Fixed checkpatch error
>
> v2:
> * Fixed build issues
> * Added telemetry support for rte_event_eth_rx_adapter_instance_get
> * arranged functions in alphabetical order in version.map
>
> diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> index 3b4ef50..5b9d0cf 100644
> --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
> @@ -177,6 +177,12 @@ used otherwise it returns -EINVAL.
>  The ``rte_event_eth_rx_adapter_queue_stats_reset`` function can be used to
>  reset queue level stats when queue level event buffer is in use.
>
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The ``rte_event_eth_rx_adapter_instance_get()`` function reports
> +rx adapter instance id for a specified ethernet device id and rx queue index.
> +
>  Interrupt Based Rx Queues
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index 6940266..c58ba05 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -888,6 +888,26 @@ typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
>         const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
>         struct rte_event_eth_rx_adapter_vector_limits *limits);
>
> +/**
> + * Get Rx adapter instance id for Rx queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of ethernet device
> + *
> + * @param rx_queue_id
> + *  Ethernet device Rx queue index
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to Rx adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *   -  0: Success
> + *   - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_rx_adapter_instance_get_t)
> +       (uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id);
> +
>  typedef uint32_t rte_event_pmd_selftest_seqn_t;
>  extern int rte_event_pmd_selftest_seqn_dynfield_offset;
>
> @@ -1321,6 +1341,8 @@ struct eventdev_ops {
>         eventdev_eth_rx_adapter_vector_limits_get_t
>                 eth_rx_adapter_vector_limits_get;
>         /**< Get event vector limits for the Rx adapter */
> +       eventdev_eth_rx_adapter_instance_get_t eth_rx_adapter_instance_get;
> +       /**< Get Rx adapter instance id for Rx queue */
>
>         eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
>         /**< Get timer adapter capabilities */
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index bf8741d..ababe13 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -1415,15 +1415,13 @@ rxa_service_func(void *args)
>         return 0;
>  }
>
> -static int
> -rte_event_eth_rx_adapter_init(void)
> +static void *
> +rxa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
>  {
> -       const char *name = RXA_ADAPTER_ARRAY;
>         const struct rte_memzone *mz;
>         unsigned int sz;
>
> -       sz = sizeof(*event_eth_rx_adapter) *
> -           RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE;
> +       sz = elt_size * nb_elems;
>         sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
>
>         mz = rte_memzone_lookup(name);
> @@ -1431,13 +1429,34 @@ rte_event_eth_rx_adapter_init(void)
>                 mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
>                                                  RTE_CACHE_LINE_SIZE);
>                 if (mz == NULL) {
> -                       RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> -                                       PRId32, rte_errno);
> -                       return -rte_errno;
> +                       RTE_EDEV_LOG_ERR("failed to reserve memzone"
> +                                        " name = %s, err = %"
> +                                        PRId32, name, rte_errno);
> +                       return NULL;
>                 }
>         }
>
> -       event_eth_rx_adapter = mz->addr;
> +       return mz->addr;
> +}
> +
> +static int
> +rte_event_eth_rx_adapter_init(void)
> +{
> +       uint8_t i;
> +
> +       if (event_eth_rx_adapter == NULL) {
> +               event_eth_rx_adapter =
> +                       rxa_memzone_array_get(RXA_ADAPTER_ARRAY,
> +                                       sizeof(*event_eth_rx_adapter),
> +                                       RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE);
> +               if (event_eth_rx_adapter == NULL)
> +                       return -ENOMEM;
> +
> +               for (i = 0; i < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; i++)
> +                       event_eth_rx_adapter[i] = NULL;
> +
> +       }
> +
>         return 0;
>  }
>
> @@ -1450,6 +1469,7 @@ rxa_memzone_lookup(void)
>                 mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
>                 if (mz == NULL)
>                         return -ENOMEM;
> +
>                 event_eth_rx_adapter = mz->addr;
>         }
>
> @@ -1951,7 +1971,6 @@ rxa_sw_del(struct event_eth_rx_adapter *rx_adapter,
>         int intrq;
>         int sintrq;
>
> -
>         if (rx_adapter->nb_queues == 0)
>                 return;
>
> @@ -2524,6 +2543,9 @@ rte_event_eth_rx_adapter_free(uint8_t id)
>  {
>         struct event_eth_rx_adapter *rx_adapter;
>
> +       if (rxa_memzone_lookup())
> +               return -ENOMEM;
> +
>         RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>
>         rx_adapter = rxa_id_to_adapter(id);
> @@ -2561,6 +2583,9 @@ rte_event_eth_rx_adapter_queue_add(uint8_t id,
>         struct eth_device_info *dev_info;
>         struct rte_event_eth_rx_adapter_vector_limits limits;
>
> +       if (rxa_memzone_lookup())
> +               return -ENOMEM;
> +
>         RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>         RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>
> @@ -2726,6 +2751,9 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
>         uint32_t *rx_wrr = NULL;
>         int num_intr_vec;
>
> +       if (rxa_memzone_lookup())
> +               return -ENOMEM;
> +
>         RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>         RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
>
> @@ -2832,6 +2860,7 @@ rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id,
>
>         rte_eventdev_trace_eth_rx_adapter_queue_del(id, eth_dev_id,
>                 rx_queue_id, ret);
> +
>         return ret;
>  }
>
> @@ -3286,6 +3315,97 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
>         return 0;
>  }
>
> +static int
> +rxa_is_queue_added(struct event_eth_rx_adapter *rx_adapter,
> +                  uint16_t eth_dev_id,
> +                  uint16_t rx_queue_id)
> +{
> +       struct eth_device_info *dev_info;
> +       struct eth_rx_queue_info *queue_info;
> +
> +       if (!rx_adapter->eth_devices)
> +               return 0;
> +
> +       dev_info = &rx_adapter->eth_devices[eth_dev_id];
> +       if (!dev_info || !dev_info->rx_queue)
> +               return 0;
> +
> +       queue_info = &dev_info->rx_queue[rx_queue_id];
> +
> +       return queue_info && queue_info->queue_enabled;
> +}
> +
> +#define rxa_evdev(rx_adapter) (&rte_eventdevs[(rx_adapter)->eventdev_id])
> +
> +#define rxa_dev_instance_get(rx_adapter) \
> +               rxa_evdev((rx_adapter))->dev_ops->eth_rx_adapter_instance_get
> +
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +                                     uint16_t rx_queue_id,
> +                                     uint8_t *rxa_inst_id)
> +{
> +       uint8_t id;
> +       int ret = -EINVAL;
> +       uint32_t caps;
> +       struct event_eth_rx_adapter *rx_adapter;
> +
> +       if (rxa_memzone_lookup())
> +               return -ENOMEM;
> +
> +       if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +               RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
> +               return -EINVAL;
> +       }
> +
> +       if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
> +               RTE_EDEV_LOG_ERR("Invalid Rx queue %u", rx_queue_id);
> +               return -EINVAL;
> +       }
> +
> +       if (rxa_inst_id == NULL) {
> +               RTE_EDEV_LOG_ERR("rxa_inst_id cannot be NULL");
> +               return -EINVAL;
> +       }
> +
> +       /* Iterate through all adapter instances */
> +       for (id = 0; id < RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE; id++) {
> +               rx_adapter = rxa_id_to_adapter(id);
> +               if (!rx_adapter)
> +                       continue;
> +
> +               if (rxa_is_queue_added(rx_adapter, eth_dev_id, rx_queue_id)) {
> +                       *rxa_inst_id = rx_adapter->id;
> +                       ret = 0;
> +               }
> +
> +               /* Rx adapter internally mainatains queue information
> +                * for both internal port and DPDK service port.
> +                * Eventdev PMD callback is called for future proof only and
> +                * overrides the above return value if defined.
> +                */
> +               caps = 0;
> +               if (!rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id,
> +                                                     eth_dev_id,
> +                                                     &caps)) {
> +                       if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {
> +                               ret = rxa_dev_instance_get(rx_adapter) ?
> +                                               rxa_dev_instance_get(rx_adapter)
> +                                                               (eth_dev_id,
> +                                                                rx_queue_id,
> +                                                                rxa_inst_id)
> +                                                       : -EINVAL;
> +                       }
> +               }
> +
> +               /* return if entry found */
> +               if (ret == 0)
> +                       return ret;
> +       }
> +
> +       return -EINVAL;
> +}
> +
>  #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
>
>  static int
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h
> index 3608a7b..a3313c8 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.h
> @@ -38,6 +38,7 @@
>   *  - rte_event_eth_rx_adapter_queue_stats_get()
>   *  - rte_event_eth_rx_adapter_queue_stats_reset()
>   *  - rte_event_eth_rx_adapter_event_port_get()
> + *  - rte_event_eth_rx_adapter_instance_get()
>   *
>   * The application creates an ethernet to event adapter using
>   * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
> @@ -704,6 +705,29 @@ __rte_experimental
>  int
>  rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id);
>
> +/**
> + * Get RX adapter instance ID for a RX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device.
> + *
> + * @param rx_queue_id
> + *  Ethernet device receive queue index.
> + *
> + * @param[out] rxa_inst_id
> + *  Pointer to store RX adapter instance identifier.
> + *  Contains valid Rx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
> +                                     uint16_t rx_queue_id,
> +                                     uint8_t *rxa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> index d99f996..0066187 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -112,6 +112,9 @@ EXPERIMENTAL {
>         # added in 22.07
>         rte_event_port_quiesce;
>         rte_event_queue_attr_set;
> +
> +       # added in 22.11
> +       rte_event_eth_rx_adapter_instance_get;
>  };
>
>  INTERNAL {
> --
> 2.6.4
>

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH v12 4/6] eventdev/eth_tx: add instance get API
  2022-08-29  8:14                       ` [PATCH v12 4/6] eventdev/eth_tx: add " Ganapati Kundapura
@ 2022-09-02 13:10                         ` Jerin Jacob
  0 siblings, 0 replies; 81+ messages in thread
From: Jerin Jacob @ 2022-09-02 13:10 UTC (permalink / raw)
  To: Ganapati Kundapura
  Cc: dpdk-dev, Jerin Jacob, Jayatheerthan, Jay, Naga Harish K, S V

On Mon, Aug 29, 2022 at 1:45 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> Added rte_event_eth_tx_adapter_instance_get() to get the
> adapter instance id for specified ethernet device id and
> tx queue index.
>
> Added rte_event_eth_tx_adapter_instance_get() details in
> prog_guide/event_ethernet_tx_adapter.rst
>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>


Acked-by: Jerin Jacob <jerinj@marvell.com>

>
> diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> index f80d226..4da9bcd 100644
> --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
> @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of
>  the counts from the eventdev PMD callback if the callback is supported, and
>  the counts maintained by the service function, if one exists.
>
> +Getting Adapter instance id
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The  ``rte_event_eth_tx_adapter_instance_get()`` function reports
> +tx adapter instance id for a specified ethernet device id and tx queue index.
> +
>  Tx event vectorization
>  ~~~~~~~~~~~~~~~~~~~~~~
>
> diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
> index c58ba05..f514a37 100644
> --- a/lib/eventdev/eventdev_pmd.h
> +++ b/lib/eventdev/eventdev_pmd.h
> @@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
>  typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
>                                         const struct rte_eventdev *dev);
>
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Ethernet device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier
> + *  Contains valid Tx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +typedef int (*eventdev_eth_tx_adapter_instance_get_t)
> +       (uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id);
> +
> +
>  /** Event device operations function pointer table */
>  struct eventdev_ops {
>         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
> @@ -1386,6 +1407,8 @@ struct eventdev_ops {
>         /**< Get eth Tx adapter statistics */
>         eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
>         /**< Reset eth Tx adapter statistics */
> +       eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get;
> +       /**< Get Tx adapter instance id for Tx queue */
>
>         eventdev_selftest dev_selftest;
>         /**< Start eventdev Selftest */
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
> index b4b37f1..aaef352 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.c
> @@ -18,6 +18,9 @@
>  #define TXA_INVALID_DEV_ID     INT32_C(-1)
>  #define TXA_INVALID_SERVICE_ID INT64_C(-1)
>
> +#define TXA_ADAPTER_ARRAY "txa_adapter_array"
> +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array"
> +
>  #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]])
>
>  #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get
> @@ -41,6 +44,9 @@
>
>  #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get
>
> +#define txa_dev_instance_get(id) \
> +                       txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get
> +
>  #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \
>  do { \
>         if (!txa_valid_id(id)) { \
> @@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems)
>  }
>
>  static int
> +txa_lookup(void)
> +{
> +       const struct rte_memzone *mz;
> +
> +       if (txa_dev_id_array == NULL) {
> +               mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY);
> +               if (mz == NULL)
> +                       return -ENOMEM;
> +               txa_dev_id_array = mz->addr;
> +       }
> +
> +       if (txa_service_data_array == NULL) {
> +               mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY);
> +               if (mz == NULL)
> +                       return -ENOMEM;
> +               txa_service_data_array = mz->addr;
> +       }
> +
> +       return 0;
> +}
> +
> +static int
>  txa_dev_id_array_init(void)
>  {
>         if (txa_dev_id_array == NULL) {
>                 int i;
>
> -               txa_dev_id_array = txa_memzone_array_get("txa_adapter_array",
> +               txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY,
>                                         sizeof(int),
>                                         RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>                 if (txa_dev_id_array == NULL)
> @@ -222,12 +250,18 @@ static int
>  txa_service_data_init(void)
>  {
>         if (txa_service_data_array == NULL) {
> +               int i;
> +
>                 txa_service_data_array =
> -                               txa_memzone_array_get("txa_service_data_array",
> +                               txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY,
>                                         sizeof(*txa_service_data_array),
>                                         RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE);
>                 if (txa_service_data_array == NULL)
>                         return -ENOMEM;
> +
> +               /* Reset the txa service pointers */
> +               for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++)
> +                       txa_service_data_array[i] = NULL;
>         }
>
>         return 0;
> @@ -1222,3 +1256,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id)
>         rte_eventdev_trace_eth_tx_adapter_stop(id, ret);
>         return ret;
>  }
> +
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +                                     uint16_t tx_queue_id,
> +                                     uint8_t *txa_inst_id)
> +{
> +       uint8_t id;
> +       int ret = -EINVAL;
> +       uint32_t caps;
> +       struct txa_service_data *txa;
> +
> +       if (txa_lookup())
> +               return -ENOMEM;
> +
> +       if (eth_dev_id >= rte_eth_dev_count_avail()) {
> +               RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id);
> +               return -EINVAL;
> +       }
> +
> +       if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) {
> +               RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id);
> +               return -EINVAL;
> +       }
> +
> +       if (txa_inst_id == NULL) {
> +               RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL");
> +               return -EINVAL;
> +       }
> +
> +       /* Iterate through all Tx adapter instances */
> +       for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) {
> +               txa = txa_service_id_to_data(id);
> +               if (!txa)
> +                       continue;
> +
> +               caps = 0;
> +               if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id,
> +                                                     eth_dev_id,
> +                                                     &caps))
> +                       continue;
> +
> +               if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) {
> +                       ret = txa_dev_instance_get(id) ?
> +                                       txa_dev_instance_get(id)(eth_dev_id,
> +                                                                tx_queue_id,
> +                                                                txa_inst_id)
> +                                                       : -EINVAL;
> +                       if (ret == 0)
> +                               return ret;
> +               } else {
> +                       struct rte_eth_dev *eth_dev;
> +
> +                       eth_dev = &rte_eth_devices[eth_dev_id];
> +
> +                       if (txa_service_is_queue_added(txa, eth_dev,
> +                                                      tx_queue_id)) {
> +                               *txa_inst_id = txa->id;
> +                               return 0;
> +                       }
> +               }
> +       }
> +
> +       return -EINVAL;
> +}
> diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h
> index 3908c2d..9432b74 100644
> --- a/lib/eventdev/rte_event_eth_tx_adapter.h
> +++ b/lib/eventdev/rte_event_eth_tx_adapter.h
> @@ -34,6 +34,7 @@
>   *  - rte_event_eth_tx_adapter_enqueue()
>   *  - rte_event_eth_tx_adapter_event_port_get()
>   *  - rte_event_eth_tx_adapter_service_id_get()
> + *  - rte_event_eth_tx_adapter_instance_get()
>   *
>   * The application creates the adapter using
>   * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().
> @@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id);
>  int
>  rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id);
>
> +/**
> + * Get TX adapter instance id for TX queue
> + *
> + * @param eth_dev_id
> + *  Port identifier of Ethernet device
> + *
> + * @param tx_queue_id
> + *  Etherdev device TX queue index
> + *
> + * @param[out] txa_inst_id
> + *  Pointer to TX adapter instance identifier
> + *  Contains valid Tx adapter instance id when return value is 0
> + *
> + * @return
> + *  -  0: Success
> + *  - <0: Error code on failure
> + */
> +__rte_experimental
> +int
> +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id,
> +                                     uint16_t tx_queue_id,
> +                                     uint8_t *txa_inst_id);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> index 0066187..9a71cf3 100644
> --- a/lib/eventdev/version.map
> +++ b/lib/eventdev/version.map
> @@ -115,6 +115,7 @@ EXPERIMENTAL {
>
>         # added in 22.11
>         rte_event_eth_rx_adapter_instance_get;
> +       rte_event_eth_tx_adapter_instance_get;
>  };
>
>  INTERNAL {
> --
> 2.6.4
>

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH v12 6/6] doc: added adapter instance get API
  2022-08-29  8:14                       ` [PATCH v12 6/6] doc: added " Ganapati Kundapura
@ 2022-09-02 13:11                         ` Jerin Jacob
  0 siblings, 0 replies; 81+ messages in thread
From: Jerin Jacob @ 2022-09-02 13:11 UTC (permalink / raw)
  To: Ganapati Kundapura
  Cc: dpdk-dev, Jerin Jacob, Jayatheerthan, Jay, Naga Harish K, S V

On Mon, Aug 29, 2022 at 1:45 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> Added rx adapter instance get - rte_event_eth_rx_adapter_instance_get()
> and tx adapter instance get - rte_event_eth_tx_adapter_instance_get()
>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Squashed this patch to the relevant API additions patch.

Series applied to dpdk-next-net-eventdev/for-main. Thanks



>
> diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
> index 8c021cf..091cc84 100644
> --- a/doc/guides/rel_notes/release_22_11.rst
> +++ b/doc/guides/rel_notes/release_22_11.rst
> @@ -23,6 +23,14 @@ DPDK Release 22.11
>
>  New Features
>  ------------
> +* **Added adapter instance get API**
> +
> +* Added ``rte_event_eth_rx_adapter_instance_get`` to get
> +  rx adapter instance id for specified ethernet device id and
> +  rx queue index.
> +* Added ``rte_event_eth_tx_adapter_instance_get`` to get the
> +  tx adapter instance id for specified ethernet device id and
> +  tx queue index.
>
>  .. This section should contain new features added in this release.
>     Sample format:
> --
> 2.6.4
>

^ permalink raw reply	[flat|nested] 81+ messages in thread

end of thread, other threads:[~2022-09-02 13:12 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 17:25 [PATCH v1] eventdev: add adapter instance get API Ganapati Kundapura
2022-06-07  8:07 ` [PATCH v2] " Ganapati Kundapura
2022-06-07  8:21   ` [PATCH v3] " Ganapati Kundapura
2022-06-07 13:18     ` Jayatheerthan, Jay
2022-06-08 11:23       ` Kundapura, Ganapati
2022-06-07 15:13     ` [PATCH v4] " Ganapati Kundapura
2022-06-08  4:26       ` Naga Harish K, S V
2022-06-08 11:22         ` Kundapura, Ganapati
2022-06-08 11:16       ` [PATCH v5 1/7] eventdev/eth_rx: " Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-08 11:16         ` [PATCH v5 7/7] doc/eth_tx: " Ganapati Kundapura
2022-06-08 12:13         ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
2022-06-08 12:13           ` [PATCH v6 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-08 12:13           ` [PATCH v6 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-08 12:13           ` [PATCH v6 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-10  4:14             ` Naga Harish K, S V
2022-06-08 12:13           ` [PATCH v6 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-08 12:13           ` [PATCH v6 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-08 12:14           ` [PATCH v6 7/7] doc/eth_tx: " Ganapati Kundapura
2022-06-10  4:12           ` [PATCH v6 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
2022-06-22 10:37           ` [PATCH v7 " Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-22 10:37             ` [PATCH v7 7/7] doc/eth_tx: " Ganapati Kundapura
2022-06-22 16:53             ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
2022-06-22 16:54               ` [PATCH v8 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-22 17:29                 ` Naga Harish K, S V
2022-06-22 16:54               ` [PATCH v8 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-22 17:29                 ` Naga Harish K, S V
2022-06-22 16:54               ` [PATCH v8 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-22 17:30                 ` Naga Harish K, S V
2022-06-22 16:54               ` [PATCH v8 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-22 17:30                 ` Naga Harish K, S V
2022-06-22 16:54               ` [PATCH v8 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-22 17:30                 ` Naga Harish K, S V
2022-06-22 16:54               ` [PATCH v8 7/7] doc/eth_tx: " Ganapati Kundapura
2022-06-22 17:30                 ` Naga Harish K, S V
2022-06-22 17:41                 ` Jayatheerthan, Jay
2022-06-22 17:29               ` [PATCH v8 1/7] eventdev/eth_rx: add adapter " Naga Harish K, S V
2022-06-22 17:44               ` Jayatheerthan, Jay
2022-06-23  6:24               ` [PATCH v9 " Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-23  6:24                 ` [PATCH v9 7/7] doc/eth_tx: " Ganapati Kundapura
2022-06-23  9:30                 ` [PATCH v10 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-06-23  9:30                   ` [PATCH v10 7/7] doc/eth_tx: " Ganapati Kundapura
2022-07-19  8:25                   ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 2/7] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 3/7] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 4/7] eventdev/eth_tx: add " Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 5/7] test/eth_tx: add testcase for " Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 6/7] doc/eth_rx: update " Ganapati Kundapura
2022-07-19  8:25                     ` [PATCH v11 7/7] doc/eth_tx: " Ganapati Kundapura
2022-08-11 13:28                     ` [PATCH v11 1/7] eventdev/eth_rx: add adapter " Kundapura, Ganapati
2022-08-27 12:14                       ` Jerin Jacob
2022-08-29  8:20                         ` Kundapura, Ganapati
2022-08-29  8:14                     ` [PATCH v12 1/6] " Ganapati Kundapura
2022-08-29  8:14                       ` [PATCH v12 2/6] eventdev/eth_rx: add telemetry callback for instance get Ganapati Kundapura
2022-08-29  8:14                       ` [PATCH v12 3/6] test/eth_rx: add test case for instance get API Ganapati Kundapura
2022-08-29  8:14                       ` [PATCH v12 4/6] eventdev/eth_tx: add " Ganapati Kundapura
2022-09-02 13:10                         ` Jerin Jacob
2022-08-29  8:14                       ` [PATCH v12 5/6] test/eth_tx: add testcase for " Ganapati Kundapura
2022-08-29  8:14                       ` [PATCH v12 6/6] doc: Added adapter " Ganapati Kundapura
2022-08-29  8:14                       ` [PATCH v12 6/6] doc: added " Ganapati Kundapura
2022-09-02 13:11                         ` Jerin Jacob
2022-09-02 13:09                       ` [PATCH v12 1/6] eventdev/eth_rx: add " Jerin Jacob

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).