Added queue capability structure and replaced the config API
definitions with it.

Signed-off-by: Petri Savolainen <[email protected]>
---
 include/odp/api/spec/config.h                      | 25 ---------------
 include/odp/api/spec/queue.h                       | 30 ++++++++++++++++++
 platform/linux-generic/include/odp/api/config.h    | 36 ----------------------
 .../include/odp/api/plat/schedule_types.h          |  4 +--
 .../linux-generic/include/odp_config_internal.h    | 20 ++++++++++++
 platform/linux-generic/odp_queue.c                 | 12 ++++++++
 platform/linux-generic/odp_schedule.c              |  9 +++++-
 platform/linux-generic/odp_thread.c                |  2 +-
 .../classification/odp_classification_tests.c      |  4 ++-
 test/validation/scheduler/scheduler.c              | 27 +++++++++++-----
 10 files changed, 96 insertions(+), 73 deletions(-)

diff --git a/include/odp/api/spec/config.h b/include/odp/api/spec/config.h
index 2a1f621..4c1df41 100644
--- a/include/odp/api/spec/config.h
+++ b/include/odp/api/spec/config.h
@@ -33,31 +33,6 @@ extern "C" {
  */
 
 /**
- * Maximum number of queues
- * @return The maximum number of queues supported by this platform
- */
-int odp_config_queues(void);
-
-/**
- * Maximum number of ordered locks per queue
- * @return The maximum number of ordered locks per queue supported by
- * this platform.
- */
-int odp_config_max_ordered_locks_per_queue(void);
-
-/**
- * Number of scheduling priorities
- * @return The number of scheduling priorities supported by this platform
- */
-int odp_config_sched_prios(void);
-
-/**
- * Number of scheduling groups
- * @return Number of scheduling groups supported by this platofmr
- */
-int odp_config_sched_grps(void);
-
-/**
  * @}
  */
 
diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 7cc031d..e87df9f 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -97,6 +97,24 @@ typedef enum odp_queue_op_mode_t {
 } odp_queue_op_mode_t;
 
 /**
+ * Queue capabilities
+ */
+typedef struct odp_queue_capability_t {
+       /** Maximum number of event queues */
+       uint32_t max_queues;
+
+       /** Maximum number of ordered locks per queue */
+       unsigned max_ordered_locks;
+
+       /** Maximum number of scheduling groups */
+       unsigned max_sched_groups;
+
+       /** Number of scheduling priorities */
+       unsigned sched_prios;
+
+} odp_queue_capability_t;
+
+/**
  * ODP Queue parameters
  */
 typedef struct odp_queue_param_t {
@@ -191,6 +209,18 @@ int odp_queue_destroy(odp_queue_t queue);
 odp_queue_t odp_queue_lookup(const char *name);
 
 /**
+ * Query queue capabilities
+ *
+ * Outputs queue capabilities on success.
+ *
+ * @param[out] capa   Pointer to capability structure for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_queue_capability(odp_queue_capability_t *capa);
+
+/**
  * Set queue context
  *
  * It is the responsibility of the user to ensure that the queue context
diff --git a/platform/linux-generic/include/odp/api/config.h 
b/platform/linux-generic/include/odp/api/config.h
index 2fba933..1f16438 100644
--- a/platform/linux-generic/include/odp/api/config.h
+++ b/platform/linux-generic/include/odp/api/config.h
@@ -22,42 +22,6 @@ extern "C" {
  * @{
  */
 
-/**
- * Maximum number of queues
- */
-#define ODP_CONFIG_QUEUES 1024
-static inline int odp_config_queues(void)
-{
-       return ODP_CONFIG_QUEUES;
-}
-
-/**
- * Number of ordered locks per queue
- */
-#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2
-static inline int odp_config_max_ordered_locks_per_queue(void)
-{
-       return ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE;
-}
-
-/**
- * Number of scheduling priorities
- */
-#define ODP_CONFIG_SCHED_PRIOS 8
-static inline int odp_config_sched_prios(void)
-{
-       return ODP_CONFIG_SCHED_PRIOS;
-}
-
-/**
- * Number of scheduling groups
- */
-#define ODP_CONFIG_SCHED_GRPS 256
-static inline int odp_config_sched_grps(void)
-{
-       return ODP_CONFIG_SCHED_GRPS;
-}
-
 #include <odp/api/spec/config.h>
 
 /**
diff --git a/platform/linux-generic/include/odp/api/plat/schedule_types.h 
b/platform/linux-generic/include/odp/api/plat/schedule_types.h
index a4a352c..535fd6d 100644
--- a/platform/linux-generic/include/odp/api/plat/schedule_types.h
+++ b/platform/linux-generic/include/odp/api/plat/schedule_types.h
@@ -29,9 +29,9 @@ typedef int odp_schedule_prio_t;
 
 #define ODP_SCHED_PRIO_HIGHEST  0
 
-#define ODP_SCHED_PRIO_NORMAL   (ODP_CONFIG_SCHED_PRIOS / 2)
+#define ODP_SCHED_PRIO_NORMAL   4
 
-#define ODP_SCHED_PRIO_LOWEST   (ODP_CONFIG_SCHED_PRIOS - 1)
+#define ODP_SCHED_PRIO_LOWEST   7
 
 #define ODP_SCHED_PRIO_DEFAULT  ODP_SCHED_PRIO_NORMAL
 
diff --git a/platform/linux-generic/include/odp_config_internal.h 
b/platform/linux-generic/include/odp_config_internal.h
index fecfbec..b2c00dd 100644
--- a/platform/linux-generic/include/odp_config_internal.h
+++ b/platform/linux-generic/include/odp_config_internal.h
@@ -130,6 +130,26 @@ extern "C" {
  */
 #define ODP_CONFIG_PKTIO_ENTRIES 64
 
+/*
+ * Maximum number of queues
+ */
+#define ODP_CONFIG_QUEUES 1024
+
+/*
+ * Number of ordered locks per queue
+ */
+#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2
+
+/*
+ * Number of scheduling priorities
+ */
+#define ODP_CONFIG_SCHED_PRIOS 8
+
+/*
+ * Number of scheduling groups
+ */
+#define ODP_CONFIG_SCHED_GRPS 256
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index 9538240..d4043f0 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -188,6 +188,18 @@ int odp_queue_term_global(void)
        return rc;
 }
 
+int odp_queue_capability(odp_queue_capability_t *capa)
+{
+       memset(capa, 0, sizeof(odp_queue_capability_t));
+
+       capa->max_queues        = ODP_CONFIG_QUEUES;
+       capa->max_ordered_locks = ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE;
+       capa->max_sched_groups  = ODP_CONFIG_SCHED_GRPS;
+       capa->sched_prios       = ODP_CONFIG_SCHED_PRIOS;
+
+       return 0;
+}
+
 odp_queue_type_t odp_queue_type(odp_queue_t handle)
 {
        queue_entry_t *queue;
diff --git a/platform/linux-generic/odp_schedule.c 
b/platform/linux-generic/odp_schedule.c
index 0595e70..1aaab93 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -13,7 +13,7 @@
 #include <odp/api/buffer.h>
 #include <odp/api/pool.h>
 #include <odp_internal.h>
-#include <odp/api/config.h>
+#include <odp_config_internal.h>
 #include <odp_debug_internal.h>
 #include <odp/api/thread.h>
 #include <odp/api/time.h>
@@ -26,6 +26,13 @@
 
 odp_thrmask_t sched_mask_all;
 
+ODP_STATIC_ASSERT(ODP_SCHED_PRIO_LOWEST == (ODP_CONFIG_SCHED_PRIOS - 1),
+                 "lowest_prio_does_not_match_with_num_prios");
+
+ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) &&
+                 (ODP_SCHED_PRIO_NORMAL < (ODP_CONFIG_SCHED_PRIOS - 1)),
+                 "normal_prio_is_not_between_highest_and_lowest");
+
 /* Number of schedule commands.
  * One per scheduled queue and packet interface */
 #define NUM_SCHED_CMD (ODP_CONFIG_QUEUES + ODP_CONFIG_PKTIO_ENTRIES)
diff --git a/platform/linux-generic/odp_thread.c 
b/platform/linux-generic/odp_thread.c
index 420e4eb..866d58f 100644
--- a/platform/linux-generic/odp_thread.c
+++ b/platform/linux-generic/odp_thread.c
@@ -11,7 +11,7 @@
 #include <odp/api/thrmask.h>
 #include <odp_internal.h>
 #include <odp/api/spinlock.h>
-#include <odp/api/config.h>
+#include <odp_config_internal.h>
 #include <odp_debug_internal.h>
 #include <odp/api/shared_memory.h>
 #include <odp/api/align.h>
diff --git a/test/validation/classification/odp_classification_tests.c 
b/test/validation/classification/odp_classification_tests.c
index f33a2a6..1236056 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -136,14 +136,16 @@ void configure_cls_pmr_chain(void)
        uint32_t addr;
        uint32_t mask;
        odp_pmr_param_t pmr_param;
+       odp_queue_capability_t queue_capa;
 
+       CU_ASSERT_FATAL(odp_queue_capability(&queue_capa) == 0);
 
        odp_queue_param_init(&qparam);
        qparam.type       = ODP_QUEUE_TYPE_SCHED;
        qparam.sched.prio = ODP_SCHED_PRIO_NORMAL;
        qparam.sched.sync = ODP_SCHED_SYNC_PARALLEL;
        qparam.sched.group = ODP_SCHED_GROUP_ALL;
-       qparam.sched.lock_count = ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE;
+       qparam.sched.lock_count = queue_capa.max_ordered_locks;
        sprintf(queuename, "%s", "SrcQueue");
 
        queue_list[CLS_PMR_CHAIN_SRC] = odp_queue_create(queuename, &qparam);
diff --git a/test/validation/scheduler/scheduler.c 
b/test/validation/scheduler/scheduler.c
index 5d2c048..dce21cb 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -9,6 +9,7 @@
 #include "scheduler.h"
 
 #define MAX_WORKERS_THREADS    32
+#define MAX_ORDERED_LOCKS       2
 #define MSG_POOL_SIZE          (4 * 1024 * 1024)
 #define QUEUES_PER_PRIO                16
 #define BUF_SIZE               64
@@ -79,7 +80,7 @@ typedef struct {
 
 typedef struct {
        uint64_t sequence;
-       uint64_t lock_sequence[ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE];
+       uint64_t lock_sequence[MAX_ORDERED_LOCKS];
        uint64_t output_sequence;
 } buf_contents;
 
@@ -87,7 +88,7 @@ typedef struct {
        odp_buffer_t ctx_handle;
        odp_queue_t pq_handle;
        uint64_t sequence;
-       uint64_t lock_sequence[ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE];
+       uint64_t lock_sequence[MAX_ORDERED_LOCKS];
 } queue_context;
 
 typedef struct {
@@ -1319,11 +1320,24 @@ void scheduler_test_pause_resume(void)
 static int create_queues(void)
 {
        int i, j, prios, rc;
+       odp_queue_capability_t capa;
        odp_pool_param_t params;
        odp_buffer_t queue_ctx_buf;
        queue_context *qctx, *pqctx;
        uint32_t ndx;
 
+       if (odp_queue_capability(&capa) < 0) {
+               printf("Queue capability query failed\n");
+               return -1;
+       }
+
+       /* Limit to test maximum */
+       if (capa.max_ordered_locks > MAX_ORDERED_LOCKS) {
+               capa.max_ordered_locks = MAX_ORDERED_LOCKS;
+               printf("Testing only %u ordered locks\n",
+                      capa.max_ordered_locks);
+       }
+
        prios = odp_schedule_num_prio();
        odp_pool_param_init(&params);
        params.buf.size = sizeof(queue_context);
@@ -1393,8 +1407,7 @@ static int create_queues(void)
 
                        snprintf(name, sizeof(name), "sched_%d_%d_o", i, j);
                        p.sched.sync = ODP_SCHED_SYNC_ORDERED;
-                       p.sched.lock_count =
-                               ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE;
+                       p.sched.lock_count = capa.max_ordered_locks;
                        q = odp_queue_create(name, &p);
 
                        if (q == ODP_QUEUE_INVALID) {
@@ -1402,12 +1415,12 @@ static int create_queues(void)
                                return -1;
                        }
                        if (odp_queue_lock_count(q) !=
-                           ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE) {
+                           (int)capa.max_ordered_locks) {
                                printf("Queue %" PRIu64 " created with "
                                       "%d locks instead of expected %d\n",
                                       odp_queue_to_u64(q),
                                       odp_queue_lock_count(q),
-                                      ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE);
+                                      capa.max_ordered_locks);
                                return -1;
                        }
 
@@ -1424,7 +1437,7 @@ static int create_queues(void)
                        qctx->sequence = 0;
 
                        for (ndx = 0;
-                            ndx < ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE;
+                            ndx < capa.max_ordered_locks;
                             ndx++) {
                                qctx->lock_sequence[ndx] = 0;
                        }
-- 
2.8.1

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to