eventdev: add queue attribute function
authorHarry van Haaren <harry.van.haaren@intel.com>
Wed, 20 Sep 2017 13:36:01 +0000 (14:36 +0100)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Tue, 10 Oct 2017 16:31:17 +0000 (18:31 +0200)
This commit adds a generic queue attribute function. It also removes
the previous rte_event_queue_priority() and priority() functions, and
updates the map files and unit tests to use the new attr functions.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
lib/librte_eventdev/rte_eventdev.c
lib/librte_eventdev/rte_eventdev.h
lib/librte_eventdev/rte_eventdev_version.map
test/test/test_eventdev.c

index 7456213..2bf8b6b 100644 (file)
@@ -613,18 +613,6 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
        return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf);
 }
 
        return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf);
 }
 
-uint8_t
-rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id)
-{
-       struct rte_eventdev *dev;
-
-       dev = &rte_eventdevs[dev_id];
-       if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
-               return dev->data->queues_prio[queue_id];
-       else
-               return RTE_EVENT_DEV_PRIORITY_NORMAL;
-}
-
 static inline int
 is_valid_port(struct rte_eventdev *dev, uint8_t port_id)
 {
 static inline int
 is_valid_port(struct rte_eventdev *dev, uint8_t port_id)
 {
@@ -792,6 +780,34 @@ rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
        return 0;
 }
 
        return 0;
 }
 
+int
+rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
+                       uint32_t *attr_value)
+{
+       struct rte_eventdev *dev;
+
+       if (!attr_value)
+               return -EINVAL;
+
+       RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+       dev = &rte_eventdevs[dev_id];
+       if (!is_valid_queue(dev, queue_id)) {
+               RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
+               return -EINVAL;
+       }
+
+       switch (attr_id) {
+       case RTE_EVENT_QUEUE_ATTR_PRIORITY:
+               *attr_value = RTE_EVENT_DEV_PRIORITY_NORMAL;
+               if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
+                       *attr_value = dev->data->queues_prio[queue_id];
+               break;
+       default:
+               return -EINVAL;
+       };
+       return 0;
+}
+
 int
 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
                    const uint8_t queues[], const uint8_t priorities[],
 int
 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
                    const uint8_t queues[], const uint8_t priorities[],
index 7acd62b..97a46af 100644 (file)
@@ -633,31 +633,26 @@ rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
                      const struct rte_event_queue_conf *queue_conf);
 
 /**
                      const struct rte_event_queue_conf *queue_conf);
 
 /**
- * Get the number of event queues on a specific event device
- *
- * @param dev_id
- *   Event device identifier.
- * @return
- *   - The number of configured event queues
+ * The priority of the queue.
  */
  */
-uint8_t
-rte_event_queue_count(uint8_t dev_id);
+#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
 
 /**
 
 /**
- * Get the priority of the event queue on a specific event device
+ * Get an attribute from a queue.
  *
  *
- * @param dev_id
- *   Event device identifier.
- * @param queue_id
- *   Event queue identifier.
- * @return
- *   - If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then the
- *    configured priority of the event queue in
- *    [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST] range
- *    else the value RTE_EVENT_DEV_PRIORITY_NORMAL
+ * @param dev_id Eventdev id
+ * @param queue_id Eventdev queue id
+ * @param attr_id The attribute ID to retrieve
+ * @param[out] attr_value A pointer that will be filled in with the attribute
+ *             value if successful
+ *
+ * @retval 0 Successfully returned value
+ *         -EINVAL invalid device, queue or attr_id provided, or attr_value
+ *         was NULL
  */
  */
-uint8_t
-rte_event_queue_priority(uint8_t dev_id, uint8_t queue_id);
+int
+rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
+                       uint32_t *attr_value);
 
 /* Event port specific APIs */
 
 
 /* Event port specific APIs */
 
index 1353a6d..90266a8 100644 (file)
@@ -25,7 +25,6 @@ DPDK_17.05 {
 
        rte_event_queue_default_conf_get;
        rte_event_queue_setup;
 
        rte_event_queue_default_conf_get;
        rte_event_queue_setup;
-       rte_event_queue_priority;
 
        rte_event_dequeue_timeout_ticks;
 
 
        rte_event_dequeue_timeout_ticks;
 
@@ -53,5 +52,6 @@ DPDK_17.11 {
 
        rte_event_dev_attr_get;
        rte_event_port_attr_get;
 
        rte_event_dev_attr_get;
        rte_event_port_attr_get;
+       rte_event_queue_attr_get;
 
 } DPDK_17.08;
 
 } DPDK_17.08;
index 47514e6..c29a05a 100644 (file)
@@ -381,7 +381,11 @@ test_eventdev_queue_priority(void)
        }
 
        for (i = 0; i < (int)queue_count; i++) {
        }
 
        for (i = 0; i < (int)queue_count; i++) {
-               priority =  rte_event_queue_priority(TEST_DEV_ID, i);
+               uint32_t tmp;
+               TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
+                                   RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp),
+                                   "Queue priority get failed");
+               priority = tmp;
 
                if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
                        TEST_ASSERT_EQUAL(priority,
 
                if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
                        TEST_ASSERT_EQUAL(priority,