aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2016-01-28 15:24:40 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-02-08 20:45:25 +0300
commit833f57876d310ec717e94bb6d11e5795dd1492ed (patch)
treeba7c48bf2a7b0b22315d33c173b91a84c5f7ee6a /platform
parent5b30e7b7b5098afe9035ec4c569524299f70b5be (diff)
api: queue: moved queue type into queue parameters
Added type into queue parameters structure, since the type specifies other parameters usage (e.g. sched params must be filled for SCHED queue type). It's also provides future proof odp_queue_create(), etc function prototype definition. Defined PLAIN as the default type, since it does not require definition of any other queue params (e.g. sched params). Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/odp_packet_io.c27
-rw-r--r--platform/linux-generic/odp_queue.c13
-rw-r--r--platform/linux-generic/odp_schedule.c5
-rw-r--r--platform/linux-generic/pktio/loop.c2
4 files changed, 29 insertions, 18 deletions
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index c5c87892a..287fb1c4b 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -53,6 +53,8 @@ int odp_pktio_init_global(void)
odp_spinlock_init(&pktio_tbl->lock);
for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
+ odp_queue_param_t param;
+
pktio_entry = &pktio_tbl->entries[id - 1];
odp_ticketlock_init(&pktio_entry->s.rxl);
@@ -66,7 +68,10 @@ int odp_pktio_init_global(void)
snprintf(name, sizeof(name), "%i-pktio_outq_default", (int)id);
name[ODP_QUEUE_NAME_LEN-1] = '\0';
- qid = odp_queue_create(name, ODP_QUEUE_TYPE_PKTOUT, NULL);
+ odp_queue_param_init(&param);
+ param.type = ODP_QUEUE_TYPE_PKTOUT;
+
+ qid = odp_queue_create(name, &param);
if (qid == ODP_QUEUE_INVALID)
return -1;
pktio_entry->s.outq_default = qid;
@@ -1088,17 +1093,19 @@ int odp_pktio_input_queues_config(odp_pktio_t pktio,
for (i = 0; i < num_queues; i++) {
if (mode == ODP_PKTIN_MODE_QUEUE ||
mode == ODP_PKTIN_MODE_SCHED) {
- odp_queue_type_t type = ODP_QUEUE_TYPE_PLAIN;
+ odp_queue_param_t queue_param;
+
+ memcpy(&queue_param, &param->queue_param,
+ sizeof(odp_queue_param_t));
+
+ queue_param.type = ODP_QUEUE_TYPE_PLAIN;
if (mode == ODP_PKTIN_MODE_SCHED)
- type = ODP_QUEUE_TYPE_SCHED;
-
- /* Ugly cast to uintptr_t is needed since queue_param
- * is not defined as const in odp_queue_create() */
- queue = odp_queue_create("pktio_in", type,
- (odp_queue_param_t *)
- (uintptr_t)
- &param->queue_param);
+ queue_param.type = ODP_QUEUE_TYPE_SCHED;
+
+ queue = odp_queue_create("pktio_in",
+ &queue_param);
+
if (queue == ODP_QUEUE_INVALID) {
destroy_in_queues(entry, i + 1);
return -1;
diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 7817afe22..232692827 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -87,7 +87,7 @@ queue_entry_t *get_qentry(uint32_t queue_id)
}
static int queue_init(queue_entry_t *queue, const char *name,
- odp_queue_type_t type, odp_queue_param_t *param)
+ odp_queue_type_t type, const odp_queue_param_t *param)
{
strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1);
queue->s.type = type;
@@ -250,12 +250,17 @@ int odp_queue_lock_count(odp_queue_t handle)
(int)queue->s.param.sched.lock_count : -1;
}
-odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type,
- odp_queue_param_t *param)
+odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
{
uint32_t i;
queue_entry_t *queue;
odp_queue_t handle = ODP_QUEUE_INVALID;
+ odp_queue_type_t type;
+
+ if (param == NULL)
+ type = ODP_QUEUE_TYPE_PLAIN;
+ else
+ type = param->type;
for (i = 0; i < ODP_CONFIG_QUEUES; i++) {
queue = &queue_tbl->queue[i];
@@ -946,6 +951,7 @@ void queue_unlock(queue_entry_t *queue)
void odp_queue_param_init(odp_queue_param_t *params)
{
memset(params, 0, sizeof(odp_queue_param_t));
+ params->type = ODP_QUEUE_TYPE_PLAIN;
}
/* These routines exists here rather than in odp_schedule
@@ -1101,7 +1107,6 @@ int odp_queue_info(odp_queue_t handle, odp_queue_info_t *info)
}
info->name = queue->s.name;
- info->type = queue->s.type;
info->param = queue->s.param;
UNLOCK(&queue->s.lock);
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index cd1c9db6f..fc54ee5d0 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -178,8 +178,7 @@ int odp_schedule_init_global(void)
name[10] = '0' + j / 10;
name[11] = '0' + j - 10*(j / 10);
- queue = odp_queue_create(name,
- ODP_QUEUE_TYPE_PLAIN, NULL);
+ queue = odp_queue_create(name, NULL);
if (queue == ODP_QUEUE_INVALID) {
ODP_ERR("Sched init: Queue create failed.\n");
@@ -199,7 +198,7 @@ int odp_schedule_init_global(void)
name[13] = '0' + i / 10;
name[14] = '0' + i - 10 * (i / 10);
- queue = odp_queue_create(name, ODP_QUEUE_TYPE_PLAIN, NULL);
+ queue = odp_queue_create(name, NULL);
if (queue == ODP_QUEUE_INVALID) {
ODP_ERR("Sched init: Queue create failed.\n");
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index a9823d9f7..e8203ff16 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -33,7 +33,7 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry,
snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq",
odp_pktio_to_u64(id));
pktio_entry->s.pkt_loop.loopq =
- odp_queue_create(loopq_name, ODP_QUEUE_TYPE_PLAIN, NULL);
+ odp_queue_create(loopq_name, NULL);
if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID)
return -1;