DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ganapati Kundapura <ganapati.kundapura@intel.com>
To: jerinjacobk@gmail.com, dev@dpdk.org, jay.jayatheerthan@intel.com
Cc: s.v.naga.harish.k@intel.com
Subject: [PATCH v5 1/7] eventdev/eth_rx: add adapter instance get API
Date: Wed,  8 Jun 2022 06:16:38 -0500	[thread overview]
Message-ID: <20220608111644.3939628-1-ganapati.kundapura@intel.com> (raw)
In-Reply-To: <20220607151320.3561528-1-ganapati.kundapura@intel.com>

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


  parent reply	other threads:[~2022-06-08 11:16 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 17:25 [PATCH v1] eventdev: " 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       ` Ganapati Kundapura [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608111644.3939628-1-ganapati.kundapura@intel.com \
    --to=ganapati.kundapura@intel.com \
    --cc=dev@dpdk.org \
    --cc=jay.jayatheerthan@intel.com \
    --cc=jerinjacobk@gmail.com \
    --cc=s.v.naga.harish.k@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).