diff mbox series

[v2,4/6] test/event: test cases to test runtime queue attribute

Message ID d5a2bc601be7aa609de8d520544d8cb36cbca02b.1649136534.git.sthotton@marvell.com (mailing list archive)
State Changes Requested
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 April 5, 2022, 5:41 a.m. UTC
Added test cases to test changing of queue QoS attributes priority,
weight and affinity at runtime.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_eventdev.c | 149 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 149 insertions(+)

Comments

Jerin Jacob May 9, 2022, 12:55 p.m. UTC | #1
On Tue, Apr 5, 2022 at 11:12 AM Shijith Thotton <sthotton@marvell.com> wrote:
>
> Added test cases to test changing of queue QoS attributes priority,
> weight and affinity at runtime.
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
>  app/test/test_eventdev.c | 149 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 149 insertions(+)
>
> diff --git a/app/test/test_eventdev.c b/app/test/test_eventdev.c
> index 4f51042bda..1af93d3b77 100644
> --- a/app/test/test_eventdev.c
> +++ b/app/test/test_eventdev.c
> @@ -385,6 +385,149 @@ test_eventdev_queue_attr_priority(void)
>         return TEST_SUCCESS;
>  }
>
> +static int
> +test_eventdev_queue_attr_priority_runtime(void)
> +{
> +       struct rte_event_queue_conf qconf;
> +       struct rte_event_dev_info info;
> +       uint32_t queue_count;
> +       int i, ret;
> +
> +       ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
> +       TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
> +
> +       if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
> +               return TEST_SKIPPED;
> +
> +               set_val = i % RTE_EVENT_DEV_PRIORITY_LOWEST;
> +               TEST_ASSERT_SUCCESS(
> +                       rte_event_queue_attr_set(TEST_DEV_ID, i,
> +                                                RTE_EVENT_QUEUE_ATTR_PRIORITY,
> +                                                set_val),
> +                       "Queue priority set failed");

If the return code is -ENOSUP, Please mark the test as TEST_SKIPPED

> +               TEST_ASSERT_SUCCESS(
> +                       rte_event_queue_attr_get(TEST_DEV_ID, i,
> +                                                RTE_EVENT_QUEUE_ATTR_PRIORITY,
> +                                                &get_val),
> +                       "Queue priority get failed");
> +               TEST_ASSERT_EQUAL(get_val, set_val,
> +                                 "Wrong priority value for queue%d", i);
> +       }
> +
> +       return TEST_SUCCESS;
> +}
> +
> +static int
> +test_eventdev_queue_attr_weight_runtime(void)
> +{
> +       struct rte_event_queue_conf qconf;
> +       struct rte_event_dev_info info;
> +       uint32_t queue_count;
> +       int i, ret;
> +
> +       ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
> +       TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
> +
> +       if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
> +               return TEST_SKIPPED;
> +
> +       TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
> +                                   TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
> +                                   &queue_count),
> +                           "Queue count get failed");
> +
> +       for (i = 0; i < (int)queue_count; i++) {
> +               ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
> +               TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
> +               ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
> +               TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
> +       }
> +
> +       for (i = 0; i < (int)queue_count; i++) {
> +               uint32_t get_val;
> +               uint64_t set_val;
> +
> +               set_val = i % RTE_EVENT_QUEUE_WEIGHT_HIGHEST;
> +               TEST_ASSERT_SUCCESS(
> +                       rte_event_queue_attr_set(TEST_DEV_ID, i,
> +                                                RTE_EVENT_QUEUE_ATTR_WEIGHT,
> +                                                set_val),
> +                       "Queue weight set failed");

If the return code is -ENOSUP, Please mark the test as TEST_SKIPPED


> +               TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(
> +                                           TEST_DEV_ID, i,
> +                                           RTE_EVENT_QUEUE_ATTR_WEIGHT, &get_val),
> +                                   "Queue weight get failed");
> +               TEST_ASSERT_EQUAL(get_val, set_val,
> +                                 "Wrong weight value for queue%d", i);
> +       }
> +
> +       return TEST_SUCCESS;
> +}
> +
> +static int
> +test_eventdev_queue_attr_affinity_runtime(void)
> +{

Please use rte_event_dequeue_burst() to get APIs to test the full
functionality to validate the
feature for both priority and affinity test cases.
diff mbox series

Patch

diff --git a/app/test/test_eventdev.c b/app/test/test_eventdev.c
index 4f51042bda..1af93d3b77 100644
--- a/app/test/test_eventdev.c
+++ b/app/test/test_eventdev.c
@@ -385,6 +385,149 @@  test_eventdev_queue_attr_priority(void)
 	return TEST_SUCCESS;
 }
 
+static int
+test_eventdev_queue_attr_priority_runtime(void)
+{
+	struct rte_event_queue_conf qconf;
+	struct rte_event_dev_info info;
+	uint32_t queue_count;
+	int i, ret;
+
+	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
+
+	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
+		return TEST_SKIPPED;
+
+	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
+				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
+				    &queue_count),
+			    "Queue count get failed");
+
+	for (i = 0; i < (int)queue_count; i++) {
+		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
+		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
+	}
+
+	for (i = 0; i < (int)queue_count; i++) {
+		uint32_t get_val;
+		uint64_t set_val;
+
+		set_val = i % RTE_EVENT_DEV_PRIORITY_LOWEST;
+		TEST_ASSERT_SUCCESS(
+			rte_event_queue_attr_set(TEST_DEV_ID, i,
+						 RTE_EVENT_QUEUE_ATTR_PRIORITY,
+						 set_val),
+			"Queue priority set failed");
+		TEST_ASSERT_SUCCESS(
+			rte_event_queue_attr_get(TEST_DEV_ID, i,
+						 RTE_EVENT_QUEUE_ATTR_PRIORITY,
+						 &get_val),
+			"Queue priority get failed");
+		TEST_ASSERT_EQUAL(get_val, set_val,
+				  "Wrong priority value for queue%d", i);
+	}
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_eventdev_queue_attr_weight_runtime(void)
+{
+	struct rte_event_queue_conf qconf;
+	struct rte_event_dev_info info;
+	uint32_t queue_count;
+	int i, ret;
+
+	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
+
+	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
+		return TEST_SKIPPED;
+
+	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
+				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
+				    &queue_count),
+			    "Queue count get failed");
+
+	for (i = 0; i < (int)queue_count; i++) {
+		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
+		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
+	}
+
+	for (i = 0; i < (int)queue_count; i++) {
+		uint32_t get_val;
+		uint64_t set_val;
+
+		set_val = i % RTE_EVENT_QUEUE_WEIGHT_HIGHEST;
+		TEST_ASSERT_SUCCESS(
+			rte_event_queue_attr_set(TEST_DEV_ID, i,
+						 RTE_EVENT_QUEUE_ATTR_WEIGHT,
+						 set_val),
+			"Queue weight set failed");
+		TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(
+					    TEST_DEV_ID, i,
+					    RTE_EVENT_QUEUE_ATTR_WEIGHT, &get_val),
+				    "Queue weight get failed");
+		TEST_ASSERT_EQUAL(get_val, set_val,
+				  "Wrong weight value for queue%d", i);
+	}
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_eventdev_queue_attr_affinity_runtime(void)
+{
+	struct rte_event_queue_conf qconf;
+	struct rte_event_dev_info info;
+	uint32_t queue_count;
+	int i, ret;
+
+	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
+
+	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
+		return TEST_SKIPPED;
+
+	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
+				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
+				    &queue_count),
+			    "Queue count get failed");
+
+	for (i = 0; i < (int)queue_count; i++) {
+		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
+		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
+		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
+	}
+
+	for (i = 0; i < (int)queue_count; i++) {
+		uint32_t get_val;
+		uint64_t set_val;
+
+		set_val = i % RTE_EVENT_QUEUE_AFFINITY_HIGHEST;
+		TEST_ASSERT_SUCCESS(
+			rte_event_queue_attr_set(TEST_DEV_ID, i,
+						 RTE_EVENT_QUEUE_ATTR_AFFINITY,
+						 set_val),
+			"Queue affinity set failed");
+		TEST_ASSERT_SUCCESS(
+			rte_event_queue_attr_get(TEST_DEV_ID, i,
+						 RTE_EVENT_QUEUE_ATTR_AFFINITY,
+						 &get_val),
+			"Queue affinity get failed");
+		TEST_ASSERT_EQUAL(get_val, set_val,
+				  "Wrong affinity value for queue%d", i);
+	}
+
+	return TEST_SUCCESS;
+}
+
 static int
 test_eventdev_queue_attr_nb_atomic_flows(void)
 {
@@ -964,6 +1107,12 @@  static struct unit_test_suite eventdev_common_testsuite  = {
 			test_eventdev_queue_count),
 		TEST_CASE_ST(eventdev_configure_setup, NULL,
 			test_eventdev_queue_attr_priority),
+		TEST_CASE_ST(eventdev_configure_setup, NULL,
+			test_eventdev_queue_attr_priority_runtime),
+		TEST_CASE_ST(eventdev_configure_setup, NULL,
+			test_eventdev_queue_attr_weight_runtime),
+		TEST_CASE_ST(eventdev_configure_setup, NULL,
+			test_eventdev_queue_attr_affinity_runtime),
 		TEST_CASE_ST(eventdev_configure_setup, NULL,
 			test_eventdev_queue_attr_nb_atomic_flows),
 		TEST_CASE_ST(eventdev_configure_setup, NULL,