[dpdk-dev] [PATCH 17/20] eventdev: add routine to access eventmode link info

Anoob Joseph anoob.joseph at caviumnetworks.com
Fri Jun 8 19:24:16 CEST 2018


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 <anoob.joseph at caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventmode_helper.c | 80 ++++++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventmode_helper.h | 25 ++++++++++
 2 files changed, 105 insertions(+)

diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index 82cc6d3..7827ea6 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -877,3 +877,83 @@ rte_eventmode_helper_initialize_devs(
 
 	return 0;
 }
+
+/* Helper functions for eventmode workers */
+
+uint8_t
+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 c1676e3..1d8af44 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.h
+++ b/lib/librte_eventdev/rte_eventmode_helper.h
@@ -107,4 +107,29 @@ rte_eventmode_helper_initialize_devs(
 void
 rte_eventmode_helper_display_conf(struct rte_eventmode_helper_conf *mode_conf);
 
+/**
+ * Get event dev - lcore links
+ *
+ * When the application is doing single stage execution, the execution loop
+ * will be in the application. So the application would need the info on which
+ * event port need 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_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);
+
 #endif /* _RTE_EVENTMODE_HELPER_H_ */
-- 
2.7.4



More information about the dev mailing list