diff mbox series

[v4,2/5] eventdev: add weight and affinity to queue attributes

Message ID 043ba4c16cac74e28e001ae46619a2e4bcfc0f00.1652722314.git.sthotton@marvell.com (mailing list archive)
State Accepted
Delegated to: Jerin Jacob
Headers show
Series Extend and set event queue attributes at runtime | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shijith Thotton May 16, 2022, 5:35 p.m. UTC
Extended eventdev queue QoS attributes to support weight and affinity.
If queues are of the same priority, events from the queue with highest
weight will be scheduled first. Affinity indicates the number of times,
the subsequent schedule calls from an event port will use the same event
queue. Schedule call selects another queue if current queue goes empty
or schedule count reaches affinity count.

To avoid ABI break, weight and affinity attributes are not yet added to
queue config structure and rely on PMD for managing it. New eventdev op
queue_attr_get can be used to get it from the PMD.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 doc/guides/rel_notes/release_22_07.rst |  7 +++++
 lib/eventdev/eventdev_pmd.h            | 22 +++++++++++++++
 lib/eventdev/rte_eventdev.c            | 12 ++++++++
 lib/eventdev/rte_eventdev.h            | 38 ++++++++++++++++++++++++--
 4 files changed, 77 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index a7a912d665..f35a31bbdf 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -70,6 +70,13 @@  New Features
   Added new API ``rte_event_queue_attr_set()``, to set event queue attributes
   at runtime.
 
+* **Added new queues attributes weight and affinity in eventdev.**
+
+  Defined new event queue attributes weight and affinity as below:
+
+  * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
+  * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
+
 
 Removed Items
 -------------
diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h
index 3b85d9f7a5..5495aee4f6 100644
--- a/lib/eventdev/eventdev_pmd.h
+++ b/lib/eventdev/eventdev_pmd.h
@@ -341,6 +341,26 @@  typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
 		uint8_t queue_id);
 
+/**
+ * Get an event queue attribute at runtime.
+ *
+ * @param dev
+ *   Event device pointer
+ * @param queue_id
+ *   Event queue index
+ * @param attr_id
+ *   Event queue attribute id
+ * @param[out] attr_value
+ *   Event queue attribute value
+ *
+ * @return
+ *  - 0: Success.
+ *  - <0: Error code on failure.
+ */
+typedef int (*eventdev_queue_attr_get_t)(struct rte_eventdev *dev,
+					 uint8_t queue_id, uint32_t attr_id,
+					 uint32_t *attr_value);
+
 /**
  * Set an event queue attribute at runtime.
  *
@@ -1231,6 +1251,8 @@  struct eventdev_ops {
 	/**< Set up an event queue. */
 	eventdev_queue_release_t queue_release;
 	/**< Release an event queue. */
+	eventdev_queue_attr_get_t queue_attr_get;
+	/**< Get an event queue attribute. */
 	eventdev_queue_attr_set_t queue_attr_set;
 	/**< Set an event queue attribute. */
 
diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
index a31e99be02..12b261f923 100644
--- a/lib/eventdev/rte_eventdev.c
+++ b/lib/eventdev/rte_eventdev.c
@@ -838,6 +838,18 @@  rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
 
 		*attr_value = conf->schedule_type;
 		break;
+	case RTE_EVENT_QUEUE_ATTR_WEIGHT:
+		*attr_value = RTE_EVENT_QUEUE_WEIGHT_LOWEST;
+		if (dev->dev_ops->queue_attr_get)
+			return (*dev->dev_ops->queue_attr_get)(
+				dev, queue_id, attr_id, attr_value);
+		break;
+	case RTE_EVENT_QUEUE_ATTR_AFFINITY:
+		*attr_value = RTE_EVENT_QUEUE_AFFINITY_LOWEST;
+		if (dev->dev_ops->queue_attr_get)
+			return (*dev->dev_ops->queue_attr_get)(
+				dev, queue_id, attr_id, attr_value);
+		break;
 	default:
 		return -EINVAL;
 	};
diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index a79b1397eb..9a7c0bcf25 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -222,8 +222,14 @@  struct rte_event;
 
 /* Event device capability bitmap flags */
 #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)
-/**< Event scheduling prioritization is based on the priority associated with
- *  each event queue.
+/**< Event scheduling prioritization is based on the priority and weight
+ * associated with each event queue. Events from a queue with highest priority
+ * is scheduled first. If the queues are of same priority, weight of the queues
+ * are considered to select a queue in a weighted round robin fashion.
+ * Subsequent dequeue calls from an event port could see events from the same
+ * event queue, if the queue is configured with an affinity count. Affinity
+ * count is the number of subsequent dequeue calls, in which an event port
+ * should use the same event queue if the queue is non-empty
  *
  *  @see rte_event_queue_setup(), rte_event_queue_attr_set()
  */
@@ -331,6 +337,26 @@  struct rte_event;
  * @see rte_event_port_link()
  */
 
+/* Event queue scheduling weights */
+#define RTE_EVENT_QUEUE_WEIGHT_HIGHEST 255
+/**< Highest weight of an event queue
+ * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
+ */
+#define RTE_EVENT_QUEUE_WEIGHT_LOWEST 0
+/**< Lowest weight of an event queue
+ * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
+ */
+
+/* Event queue scheduling affinity */
+#define RTE_EVENT_QUEUE_AFFINITY_HIGHEST 255
+/**< Highest scheduling affinity of an event queue
+ * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
+ */
+#define RTE_EVENT_QUEUE_AFFINITY_LOWEST 0
+/**< Lowest scheduling affinity of an event queue
+ * @see rte_event_queue_attr_get(), rte_event_queue_attr_set()
+ */
+
 /**
  * Get the total number of event devices that have been successfully
  * initialised.
@@ -684,6 +710,14 @@  rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
  * The schedule type of the queue.
  */
 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
+/**
+ * The weight of the queue.
+ */
+#define RTE_EVENT_QUEUE_ATTR_WEIGHT 5
+/**
+ * Affinity of the queue.
+ */
+#define RTE_EVENT_QUEUE_ATTR_AFFINITY 6
 
 /**
  * Get an attribute from a queue.