[30/39] eventdev: add routine to access eventmode link info

Message ID 1559583160-13944-31-git-send-email-anoobj@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series adding eventmode helper library |

Checks

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

Commit Message

Anoob Joseph June 3, 2019, 5:32 p.m. UTC
  When the application is drafted for single stage eventmode, it will be
efficient to have the loop in the application space, rather than passing
it on to the helper. But application would need to have info on the
links to be able to do that efficiently. This function exposes the links
to that application.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Lukasz Bartosik <lbartosik@marvell.com>
---
 lib/librte_eventdev/rte_eventdev_version.map |  1 +
 lib/librte_eventdev/rte_eventmode_helper.c   | 80 ++++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventmode_helper.h   | 24 +++++++++
 3 files changed, 105 insertions(+)
  

Patch

diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map
index 8b78a68..8137cb5 100644
--- a/lib/librte_eventdev/rte_eventdev_version.map
+++ b/lib/librte_eventdev/rte_eventdev_version.map
@@ -133,4 +133,5 @@  EXPERIMENTAL {
 	rte_eventmode_helper_parse_args;
 	rte_eventmode_helper_initialize_devs;
 	rte_eventmode_helper_display_conf;
+	rte_eventmode_helper_get_event_lcore_links;
 };
diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index a333c4a..6c853f6 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -847,3 +847,83 @@  rte_eventmode_helper_initialize_devs(
 
 	return 0;
 }
+
+/* Helper functions for eventmode workers */
+
+uint8_t __rte_experimental
+rte_eventmode_helper_get_event_lcore_links(uint32_t lcore_id,
+		struct rte_eventmode_helper_conf *mode_conf,
+		struct rte_eventmode_helper_event_link_info **links)
+{
+	int i;
+	int index = 0;
+	uint8_t lcore_nb_link = 0;
+	struct rte_eventmode_helper_event_link_info *link;
+	struct rte_eventmode_helper_event_link_info *link_cache;
+	struct eventmode_conf *em_conf = NULL;
+	size_t cache_size;
+	size_t single_link_size;
+
+	if (mode_conf == NULL || links == NULL) {
+		RTE_EM_HLPR_LOG_ERR("Invalid args");
+		return 0;
+	}
+
+	/* Get eventmode conf */
+	em_conf = (struct eventmode_conf *)(mode_conf->mode_params);
+
+	if (em_conf == NULL) {
+		RTE_EM_HLPR_LOG_ERR("Invalid event mode conf");
+		return 0;
+	}
+
+	/* Get the number of links registered */
+	for (i = 0; i < em_conf->nb_link; i++) {
+
+		/* Get link */
+		link = &(em_conf->link[i]);
+
+		/* Check if we have link intended for this lcore */
+		if (link->lcore_id == lcore_id) {
+
+			/* Update the number of links for this core */
+			lcore_nb_link++;
+
+		}
+	}
+
+	/* Compute size of one entry to be copied */
+	single_link_size = sizeof(struct rte_eventmode_helper_event_link_info);
+
+	/* Compute size of the buffer required */
+	cache_size = lcore_nb_link *
+			sizeof(struct rte_eventmode_helper_event_link_info);
+
+	/* Allocate memory for caching the links */
+	link_cache = rte_zmalloc("eventmode-event-lcore-links", cache_size,
+			RTE_CACHE_LINE_SIZE);
+
+	/* Get the number of links registered */
+	for (i = 0; i < em_conf->nb_link; i++) {
+
+		/* Get link */
+		link = &(em_conf->link[i]);
+
+		/* Check if we have link intended for this lcore */
+		if (link->lcore_id == lcore_id) {
+
+			/* Cache the link */
+			memcpy(&link_cache[index], link, single_link_size);
+
+			/* Update index */
+			index++;
+		}
+	}
+
+	/* Update the links for application to use the cached links */
+	*links = link_cache;
+
+	/* Return the number of cached links */
+	return lcore_nb_link;
+}
+
diff --git a/lib/librte_eventdev/rte_eventmode_helper.h b/lib/librte_eventdev/rte_eventmode_helper.h
index d4941be..925b660 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.h
+++ b/lib/librte_eventdev/rte_eventmode_helper.h
@@ -112,6 +112,30 @@  rte_eventmode_helper_initialize_devs(
 void __rte_experimental
 rte_eventmode_helper_display_conf(struct rte_eventmode_helper_conf *mode_conf);
 
+/**
+ * Get event dev - lcore links
+ *
+ * Since the execution loop is in the application, the application would need
+ * the info on which event port to be polled by an lcore etc. This helper
+ * function would help the application in doing so. The 'links' would point
+ * to the memory allocated for the links list, and the application should
+ * release this, once the use is over.
+ *
+ * @param lcore_id
+ *   ID of the lcore for which the links list need to be populated
+ * @param mode_conf
+ *   Configuration of the mode in which app is doing packet handling
+ * @param links
+ *   Used to pass the pointer of the memory allocated by the helper to the
+ *   application
+ * @return
+ *   Number of links found for the lcore
+ */
+uint8_t __rte_experimental
+rte_eventmode_helper_get_event_lcore_links(uint32_t lcore_id,
+		struct rte_eventmode_helper_conf *mode_conf,
+		struct rte_eventmode_helper_event_link_info **links);
+
 #ifdef __cplusplus
 }
 #endif