This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via d9473fe65b531bfbe54d83d4e429d72e553c17dc (commit) via 98b09c8289e0888ce09f68f454a066a415597ea2 (commit) via f72ae9c821eed99323a98a012659acd655095bb3 (commit) via 08863bb877feb8643d1583e29912cc08f2ca8105 (commit) via d55156b2eacf07e88cbff9f51d60238536dfb7ad (commit) via 1239cc0c12ad2be11d329eebbe4df7fad05b03d7 (commit) via e3fce2fca6067b03f7fd18c9a438d2058521fe11 (commit) via 29ad363b5ab3c5e6569f20ddf63e64cc53eeb019 (commit) via 8ef745b7b78b49fc58d14e7b79b450c0bb560558 (commit) via d9c85310cb82f83010c839b6a1bbb5a1fa672ceb (commit) via 5a38050f431d904b7354cd50611304da0a601727 (commit) via 200782c3da2104a020f278691b3b23b8d55893e0 (commit) from 29641a1e0d0868c09f35f9f32e6c8491efb62b2d (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit d9473fe65b531bfbe54d83d4e429d72e553c17dc Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:43 2017 +0300
linux-gen: queue: remove type set from interface
TM should not modify queue type. Remove type_set queue interface function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 7ba5c3c5..410c6b79 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -71,7 +71,6 @@ typedef void (*queue_set_enq_deq_fn_t)(queue_t q_int, queue_enq_multi_fn_t enq_multi, queue_deq_fn_t deq, queue_deq_multi_fn_t deq_multi); -typedef void (*queue_set_type_fn_t)(queue_t q_int, odp_queue_type_t type);
/* Queue functions towards other internal components */ typedef struct { @@ -90,7 +89,6 @@ typedef struct { queue_get_pktin_fn_t get_pktin; queue_set_pktin_fn_t set_pktin; queue_set_enq_deq_fn_t set_enq_deq_fn; - queue_set_type_fn_t set_type; } queue_fn_t;
extern const queue_fn_t *queue_fn; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index ec225d00..d52814b2 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -769,11 +769,6 @@ static void queue_set_enq_deq_func(queue_t q_int, qentry->s.dequeue_multi = deq_multi; }
-static void queue_set_type(queue_t q_int, odp_queue_type_t type) -{ - qentry_from_int(q_int)->s.type = type; -} - static queue_t queue_from_ext(odp_queue_t handle) { return qentry_to_int(handle_to_qentry(handle)); @@ -822,6 +817,5 @@ queue_fn_t queue_default_fn = { .set_pktout = queue_set_pktout, .get_pktin = queue_get_pktin, .set_pktin = queue_set_pktin, - .set_enq_deq_fn = queue_set_enq_deq_func, - .set_type = queue_set_type + .set_enq_deq_fn = queue_set_enq_deq_func }; diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 1f254d75..ec2d331f 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -37,9 +37,6 @@ static const pkt_desc_t EMPTY_PKT_DESC = { .word = 0 }; #define MAX_PRIORITIES ODP_TM_MAX_PRIORITIES #define NUM_SHAPER_COLORS ODP_NUM_SHAPER_COLORS
-/* Traffic manager queue */ -#define QUEUE_TYPE_TM 4 - static tm_prop_t basic_prop_tbl[MAX_PRIORITIES][NUM_SHAPER_COLORS] = { [0] = { [ODP_TM_SHAPER_GREEN] = { 0, DECR_BOTH }, @@ -3926,7 +3923,6 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm, return ODP_TM_INVALID; } tm_queue_obj->tm_qentry = queue_fn->from_ext(queue); - queue_fn->set_type(tm_queue_obj->tm_qentry, QUEUE_TYPE_TM); queue_fn->set_enq_deq_fn(tm_queue_obj->tm_qentry, queue_tm_reenq, queue_tm_reenq_multi, NULL, NULL);
commit 98b09c8289e0888ce09f68f454a066a415597ea2 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:42 2017 +0300
linux-gen: queue: combine queue interface set functions
Decrease queue interface size by combining four queue operation set functions into a single function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index b5cbd515..7ba5c3c5 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -66,12 +66,11 @@ typedef void (*queue_set_pktout_fn_t)(queue_t q_int, odp_pktio_t pktio, typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t q_int); typedef void (*queue_set_pktin_fn_t)(queue_t q_int, odp_pktio_t pktio, int index); -typedef void (*queue_set_enq_fn_t)(queue_t q_int, queue_enq_fn_t func); -typedef void (*queue_set_enq_multi_fn_t)(queue_t q_int, - queue_enq_multi_fn_t func); -typedef void (*queue_set_deq_fn_t)(queue_t q_int, queue_deq_fn_t func); -typedef void (*queue_set_deq_multi_fn_t)(queue_t q_int, - queue_deq_multi_fn_t func); +typedef void (*queue_set_enq_deq_fn_t)(queue_t q_int, + queue_enq_fn_t enq, + queue_enq_multi_fn_t enq_multi, + queue_deq_fn_t deq, + queue_deq_multi_fn_t deq_multi); typedef void (*queue_set_type_fn_t)(queue_t q_int, odp_queue_type_t type);
/* Queue functions towards other internal components */ @@ -90,10 +89,7 @@ typedef struct { queue_set_pktout_fn_t set_pktout; queue_get_pktin_fn_t get_pktin; queue_set_pktin_fn_t set_pktin; - queue_set_enq_fn_t set_enq_fn; - queue_set_enq_multi_fn_t set_enq_multi_fn; - queue_set_deq_fn_t set_deq_fn; - queue_set_deq_multi_fn_t set_deq_multi_fn; + queue_set_enq_deq_fn_t set_enq_deq_fn; queue_set_type_fn_t set_type; } queue_fn_t;
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 0d825f91..6a181f53 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -1154,30 +1154,30 @@ int odp_pktio_stats_reset(odp_pktio_t pktio) return ret; }
-static int pktin_enqueue(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr ODP_UNUSED) +static int abort_pktin_enqueue(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return -1; }
-static int pktin_enq_multi(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, - int num ODP_UNUSED) +static int abort_pktin_enq_multi(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, + int num ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return 0; }
-static odp_buffer_hdr_t *pktout_dequeue(queue_t q_int ODP_UNUSED) +static odp_buffer_hdr_t *abort_pktout_dequeue(queue_t q_int ODP_UNUSED) { ODP_ABORT("attempted dequeue from a pktout queue"); return NULL; }
-static int pktout_deq_multi(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, - int num ODP_UNUSED) +static int abort_pktout_deq_multi(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, + int num ODP_UNUSED) { ODP_ABORT("attempted dequeue from a pktout queue"); return 0; @@ -1272,12 +1272,11 @@ int odp_pktin_queue_config(odp_pktio_t pktio,
if (mode == ODP_PKTIN_MODE_QUEUE) { queue_fn->set_pktin(q_int, pktio, i); - queue_fn->set_enq_fn(q_int, pktin_enqueue); - queue_fn->set_deq_fn(q_int, pktin_dequeue); - queue_fn->set_enq_multi_fn(q_int, - pktin_enq_multi); - queue_fn->set_deq_multi_fn(q_int, - pktin_deq_multi); + queue_fn->set_enq_deq_fn(q_int, + abort_pktin_enqueue, + abort_pktin_enq_multi, + pktin_dequeue, + pktin_deq_multi); }
entry->s.in_queue[i].queue = queue; @@ -1401,10 +1400,11 @@ int odp_pktout_queue_config(odp_pktio_t pktio, queue_fn->set_pktout(q_int, pktio, i);
/* Override default enqueue / dequeue functions */ - queue_fn->set_enq_fn(q_int, pktout_enqueue); - queue_fn->set_deq_fn(q_int, pktout_dequeue); - queue_fn->set_enq_multi_fn(q_int, pktout_enq_multi); - queue_fn->set_deq_multi_fn(q_int, pktout_deq_multi); + queue_fn->set_enq_deq_fn(q_int, + pktout_enqueue, + pktout_enq_multi, + abort_pktout_dequeue, + abort_pktout_deq_multi);
entry->s.out_queue[i].queue = queue; } diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 60f88f09..ec225d00 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -748,24 +748,25 @@ static void queue_set_pktin(queue_t q_int, odp_pktio_t pktio, int index) qentry->s.pktin.index = index; }
-static void queue_set_enq_func(queue_t q_int, queue_enq_fn_t func) +static void queue_set_enq_deq_func(queue_t q_int, + queue_enq_fn_t enq, + queue_enq_multi_fn_t enq_multi, + queue_deq_fn_t deq, + queue_deq_multi_fn_t deq_multi) { - qentry_from_int(q_int)->s.enqueue = func; -} + queue_entry_t *qentry = qentry_from_int(q_int);
-static void queue_set_enq_multi_func(queue_t q_int, queue_enq_multi_fn_t func) -{ - qentry_from_int(q_int)->s.enqueue_multi = func; -} + if (enq) + qentry->s.enqueue = enq;
-static void queue_set_deq_func(queue_t q_int, queue_deq_fn_t func) -{ - qentry_from_int(q_int)->s.dequeue = func; -} + if (enq_multi) + qentry->s.enqueue_multi = enq_multi;
-static void queue_set_deq_multi_func(queue_t q_int, queue_deq_multi_fn_t func) -{ - qentry_from_int(q_int)->s.dequeue_multi = func; + if (deq) + qentry->s.dequeue = deq; + + if (deq_multi) + qentry->s.dequeue_multi = deq_multi; }
static void queue_set_type(queue_t q_int, odp_queue_type_t type) @@ -821,9 +822,6 @@ queue_fn_t queue_default_fn = { .set_pktout = queue_set_pktout, .get_pktin = queue_get_pktin, .set_pktin = queue_set_pktin, - .set_enq_fn = queue_set_enq_func, - .set_enq_multi_fn = queue_set_enq_multi_func, - .set_deq_fn = queue_set_deq_func, - .set_deq_multi_fn = queue_set_deq_multi_func, + .set_enq_deq_fn = queue_set_enq_deq_func, .set_type = queue_set_type }; diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 8b5f3187..1f254d75 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -3927,9 +3927,9 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm, } tm_queue_obj->tm_qentry = queue_fn->from_ext(queue); queue_fn->set_type(tm_queue_obj->tm_qentry, QUEUE_TYPE_TM); - queue_fn->set_enq_fn(tm_queue_obj->tm_qentry, queue_tm_reenq); - queue_fn->set_enq_multi_fn(tm_queue_obj->tm_qentry, - queue_tm_reenq_multi); + queue_fn->set_enq_deq_fn(tm_queue_obj->tm_qentry, + queue_tm_reenq, queue_tm_reenq_multi, + NULL, NULL);
tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = tm_queue_obj; odp_ticketlock_lock(&tm_system->tm_system_lock);
commit f72ae9c821eed99323a98a012659acd655095bb3 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:41 2017 +0300
linux-gen: pktio: remove unused header file
odp_packet_io_queue.h is not needed anymore as the queue interface has replaced it.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 45dd0f4d..33299564 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -145,7 +145,6 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ipc_internal.h \ - ${srcdir}/include/odp_packet_io_queue.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_dpdk.h \ diff --git a/platform/linux-generic/include/odp_packet_io_queue.h b/platform/linux-generic/include/odp_packet_io_queue.h deleted file mode 100644 index 71333ddc..00000000 --- a/platform/linux-generic/include/odp_packet_io_queue.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP packet IO - implementation internal - */ - -#ifndef ODP_PACKET_IO_QUEUE_H_ -#define ODP_PACKET_IO_QUEUE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp_queue_if.h> -#include <odp_buffer_internal.h> -#include <odp_config_internal.h> - -/** Max nbr of pkts to receive in one burst (keep same as QUEUE_MULTI_MAX) */ -#define ODP_PKTIN_QUEUE_MAX_BURST CONFIG_BURST_SIZE -/* pktin_deq_multi() depends on the condition: */ -ODP_STATIC_ASSERT(ODP_PKTIN_QUEUE_MAX_BURST >= QUEUE_MULTI_MAX, - "ODP_PKTIN_DEQ_MULTI_MAX_ERROR"); - -int pktin_enqueue(queue_t queue, odp_buffer_hdr_t *buf_hdr); -odp_buffer_hdr_t *pktin_dequeue(queue_t queue); - -int pktin_enq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); -int pktin_deq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); - - -int pktout_enqueue(queue_t queue, odp_buffer_hdr_t *buf_hdr); -odp_buffer_hdr_t *pktout_dequeue(queue_t queue); - -int pktout_enq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); -int pktout_deq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 3ed51ac9..0d825f91 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -7,7 +7,6 @@
#include <odp/api/packet_io.h> #include <odp_packet_io_internal.h> -#include <odp_packet_io_queue.h> #include <odp/api/packet.h> #include <odp_packet_internal.h> #include <odp_internal.h> @@ -580,7 +579,7 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, return num_rx; }
-int pktout_enqueue(queue_t q_int, odp_buffer_hdr_t *buf_hdr) +static int pktout_enqueue(queue_t q_int, odp_buffer_hdr_t *buf_hdr) { odp_packet_t pkt = packet_from_buf_hdr(buf_hdr); int len = 1; @@ -593,13 +592,7 @@ int pktout_enqueue(queue_t q_int, odp_buffer_hdr_t *buf_hdr) return (nbr == len ? 0 : -1); }
-odp_buffer_hdr_t *pktout_dequeue(queue_t q_int ODP_UNUSED) -{ - ODP_ABORT("attempted dequeue from a pktout queue"); - return NULL; -} - -int pktout_enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) +static int pktout_enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; int nbr; @@ -615,22 +608,7 @@ int pktout_enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) return nbr; }
-int pktout_deq_multi(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, - int num ODP_UNUSED) -{ - ODP_ABORT("attempted dequeue from a pktout queue"); - return 0; -} - -int pktin_enqueue(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr ODP_UNUSED) -{ - ODP_ABORT("attempted enqueue to a pktin queue"); - return -1; -} - -odp_buffer_hdr_t *pktin_dequeue(queue_t q_int) +static odp_buffer_hdr_t *pktin_dequeue(queue_t q_int) { odp_buffer_hdr_t *buf_hdr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; @@ -652,14 +630,7 @@ odp_buffer_hdr_t *pktin_dequeue(queue_t q_int) return buf_hdr; }
-int pktin_enq_multi(queue_t q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, int num ODP_UNUSED) -{ - ODP_ABORT("attempted enqueue to a pktin queue"); - return 0; -} - -int pktin_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) +static int pktin_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { int nbr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; @@ -1183,6 +1154,35 @@ int odp_pktio_stats_reset(odp_pktio_t pktio) return ret; }
+static int pktin_enqueue(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr ODP_UNUSED) +{ + ODP_ABORT("attempted enqueue to a pktin queue"); + return -1; +} + +static int pktin_enq_multi(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, + int num ODP_UNUSED) +{ + ODP_ABORT("attempted enqueue to a pktin queue"); + return 0; +} + +static odp_buffer_hdr_t *pktout_dequeue(queue_t q_int ODP_UNUSED) +{ + ODP_ABORT("attempted dequeue from a pktout queue"); + return NULL; +} + +static int pktout_deq_multi(queue_t q_int ODP_UNUSED, + odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, + int num ODP_UNUSED) +{ + ODP_ABORT("attempted dequeue from a pktout queue"); + return 0; +} + int odp_pktin_queue_config(odp_pktio_t pktio, const odp_pktin_queue_param_t *param) { diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 4c85027b..60f88f09 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -19,7 +19,6 @@ #include <odp_schedule_if.h> #include <odp_config_internal.h> #include <odp_packet_io_internal.h> -#include <odp_packet_io_queue.h> #include <odp_debug_internal.h> #include <odp/api/hints.h> #include <odp/api/sync.h>
commit 08863bb877feb8643d1583e29912cc08f2ca8105 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:40 2017 +0300
linux-gen: pktio: convert queue handle only once
Avoid queue handle conversion on fast path. Convert once after queue create and save value.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 89bb6f3a..93040681 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -24,6 +24,7 @@ extern "C" { #include <odp_align_internal.h> #include <odp_debug_internal.h> #include <odp_packet_io_ring_internal.h> +#include <odp_queue_if.h>
#include <odp_config_internal.h> #include <odp/api/hints.h> @@ -165,6 +166,7 @@ struct pktio_entry {
struct { odp_queue_t queue; + queue_t queue_int; odp_pktin_queue_t pktin; } in_queue[PKTIO_MAX_QUEUES];
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index af1307c0..3ed51ac9 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -128,6 +128,7 @@ static void init_in_queues(pktio_entry_t *entry)
for (i = 0; i < PKTIO_MAX_QUEUES; i++) { entry->s.in_queue[i].queue = ODP_QUEUE_INVALID; + entry->s.in_queue[i].queue_int = QUEUE_NULL; entry->s.in_queue[i].pktin = PKTIN_INVALID; } } @@ -305,6 +306,7 @@ static void destroy_in_queues(pktio_entry_t *entry, int num) if (entry->s.in_queue[i].queue != ODP_QUEUE_INVALID) { odp_queue_destroy(entry->s.in_queue[i].queue); entry->s.in_queue[i].queue = ODP_QUEUE_INVALID; + entry->s.in_queue[i].queue_int = QUEUE_NULL; } } } @@ -708,8 +710,7 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) }
for (idx = 0; idx < num_queue; idx++) { - queue_t qentry; - odp_queue_t queue; + queue_t q_int; odp_pktin_queue_t pktin = entry->s.in_queue[index[idx]].pktin;
num = pktin_recv_buf(pktin, hdr_tbl, QUEUE_MULTI_MAX); @@ -722,9 +723,8 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) return -1; }
- queue = entry->s.in_queue[index[idx]].queue; - qentry = queue_fn->from_ext(queue); - queue_fn->enq_multi(qentry, hdr_tbl, num); + q_int = entry->s.in_queue[index[idx]].queue_int; + queue_fn->enq_multi(q_int, hdr_tbl, num); }
return 0; @@ -1281,8 +1281,11 @@ int odp_pktin_queue_config(odp_pktio_t pktio, }
entry->s.in_queue[i].queue = queue; + entry->s.in_queue[i].queue_int = q_int; + } else { entry->s.in_queue[i].queue = ODP_QUEUE_INVALID; + entry->s.in_queue[i].queue_int = QUEUE_NULL; }
entry->s.in_queue[i].pktin.index = i;
commit d55156b2eacf07e88cbff9f51d60238536dfb7ad Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:39 2017 +0300
linux-gen: pktio: dont use qentry for queue_t
These are not any more queue_entry_t* but queue_t. Align variable names with the new type.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 6ff35046..af1307c0 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -578,42 +578,42 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, return num_rx; }
-int pktout_enqueue(queue_t qentry, odp_buffer_hdr_t *buf_hdr) +int pktout_enqueue(queue_t q_int, odp_buffer_hdr_t *buf_hdr) { odp_packet_t pkt = packet_from_buf_hdr(buf_hdr); int len = 1; int nbr;
- if (sched_fn->ord_enq_multi(qentry, (void **)buf_hdr, len, &nbr)) + if (sched_fn->ord_enq_multi(q_int, (void **)buf_hdr, len, &nbr)) return (nbr == len ? 0 : -1);
- nbr = odp_pktout_send(queue_fn->get_pktout(qentry), &pkt, len); + nbr = odp_pktout_send(queue_fn->get_pktout(q_int), &pkt, len); return (nbr == len ? 0 : -1); }
-odp_buffer_hdr_t *pktout_dequeue(queue_t qentry ODP_UNUSED) +odp_buffer_hdr_t *pktout_dequeue(queue_t q_int ODP_UNUSED) { ODP_ABORT("attempted dequeue from a pktout queue"); return NULL; }
-int pktout_enq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) +int pktout_enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; int nbr; int i;
- if (sched_fn->ord_enq_multi(qentry, (void **)buf_hdr, num, &nbr)) + if (sched_fn->ord_enq_multi(q_int, (void **)buf_hdr, num, &nbr)) return nbr;
for (i = 0; i < num; ++i) pkt_tbl[i] = packet_from_buf_hdr(buf_hdr[i]);
- nbr = odp_pktout_send(queue_fn->get_pktout(qentry), pkt_tbl, num); + nbr = odp_pktout_send(queue_fn->get_pktout(q_int), pkt_tbl, num); return nbr; }
-int pktout_deq_multi(queue_t qentry ODP_UNUSED, +int pktout_deq_multi(queue_t q_int ODP_UNUSED, odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, int num ODP_UNUSED) { @@ -621,49 +621,49 @@ int pktout_deq_multi(queue_t qentry ODP_UNUSED, return 0; }
-int pktin_enqueue(queue_t qentry ODP_UNUSED, +int pktin_enqueue(queue_t q_int ODP_UNUSED, odp_buffer_hdr_t *buf_hdr ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return -1; }
-odp_buffer_hdr_t *pktin_dequeue(queue_t qentry) +odp_buffer_hdr_t *pktin_dequeue(queue_t q_int) { odp_buffer_hdr_t *buf_hdr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts;
- buf_hdr = queue_fn->deq(qentry); + buf_hdr = queue_fn->deq(q_int); if (buf_hdr != NULL) return buf_hdr;
- pkts = pktin_recv_buf(queue_fn->get_pktin(qentry), + pkts = pktin_recv_buf(queue_fn->get_pktin(q_int), hdr_tbl, QUEUE_MULTI_MAX);
if (pkts <= 0) return NULL;
if (pkts > 1) - queue_fn->enq_multi(qentry, &hdr_tbl[1], pkts - 1); + queue_fn->enq_multi(q_int, &hdr_tbl[1], pkts - 1); buf_hdr = hdr_tbl[0]; return buf_hdr; }
-int pktin_enq_multi(queue_t qentry ODP_UNUSED, +int pktin_enq_multi(queue_t q_int ODP_UNUSED, odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, int num ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return 0; }
-int pktin_deq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) +int pktin_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { int nbr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts, i, j;
- nbr = queue_fn->deq_multi(qentry, buf_hdr, num); + nbr = queue_fn->deq_multi(q_int, buf_hdr, num); if (odp_unlikely(nbr > num)) ODP_ABORT("queue_deq_multi req: %d, returned %d\n", num, nbr);
@@ -673,7 +673,7 @@ int pktin_deq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) if (nbr == num) return nbr;
- pkts = pktin_recv_buf(queue_fn->get_pktin(qentry), + pkts = pktin_recv_buf(queue_fn->get_pktin(q_int), hdr_tbl, QUEUE_MULTI_MAX); if (pkts <= 0) return nbr; @@ -686,7 +686,7 @@ int pktin_deq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) hdr_tbl[j] = hdr_tbl[i];
if (j) - queue_fn->enq_multi(qentry, hdr_tbl, j); + queue_fn->enq_multi(q_int, hdr_tbl, j); return nbr; }
@@ -1193,6 +1193,7 @@ int odp_pktin_queue_config(odp_pktio_t pktio, unsigned i; int rc; odp_queue_t queue; + queue_t q_int; odp_pktin_queue_param_t default_param;
if (param == NULL) { @@ -1267,16 +1268,15 @@ int odp_pktin_queue_config(odp_pktio_t pktio, return -1; }
- if (mode == ODP_PKTIN_MODE_QUEUE) { - queue_t qentry; + q_int = queue_fn->from_ext(queue);
- qentry = queue_fn->from_ext(queue); - queue_fn->set_pktin(qentry, pktio, i); - queue_fn->set_enq_fn(qentry, pktin_enqueue); - queue_fn->set_deq_fn(qentry, pktin_dequeue); - queue_fn->set_enq_multi_fn(qentry, + if (mode == ODP_PKTIN_MODE_QUEUE) { + queue_fn->set_pktin(q_int, pktio, i); + queue_fn->set_enq_fn(q_int, pktin_enqueue); + queue_fn->set_deq_fn(q_int, pktin_dequeue); + queue_fn->set_enq_multi_fn(q_int, pktin_enq_multi); - queue_fn->set_deq_multi_fn(qentry, + queue_fn->set_deq_multi_fn(q_int, pktin_deq_multi); }
@@ -1374,7 +1374,7 @@ int odp_pktout_queue_config(odp_pktio_t pktio, for (i = 0; i < num_queues; i++) { odp_queue_t queue; odp_queue_param_t queue_param; - queue_t qentry; + queue_t q_int; char name[ODP_QUEUE_NAME_LEN]; int pktio_id = pktio_to_id(pktio);
@@ -1394,14 +1394,14 @@ int odp_pktout_queue_config(odp_pktio_t pktio, return -1; }
- qentry = queue_fn->from_ext(queue); - queue_fn->set_pktout(qentry, pktio, i); + q_int = queue_fn->from_ext(queue); + queue_fn->set_pktout(q_int, pktio, i);
/* Override default enqueue / dequeue functions */ - queue_fn->set_enq_fn(qentry, pktout_enqueue); - queue_fn->set_deq_fn(qentry, pktout_dequeue); - queue_fn->set_enq_multi_fn(qentry, pktout_enq_multi); - queue_fn->set_deq_multi_fn(qentry, pktout_deq_multi); + queue_fn->set_enq_fn(q_int, pktout_enqueue); + queue_fn->set_deq_fn(q_int, pktout_dequeue); + queue_fn->set_enq_multi_fn(q_int, pktout_enq_multi); + queue_fn->set_deq_multi_fn(q_int, pktout_deq_multi);
entry->s.out_queue[i].queue = queue; }
commit 1239cc0c12ad2be11d329eebbe4df7fad05b03d7 Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jul 4 12:53:38 2017 +0300
linux-gen: cls: avoid queue conversions
Use internal queue type instead of API handle. This way per packet queue conversions are avoided.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index cdd139bb..d513f05e 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -27,6 +27,7 @@ extern "C" { #include <odp/api/crypto.h> #include <odp_crypto_internal.h> #include <odp/api/plat/packet_types.h> +#include <odp_queue_if.h>
/** Minimum segment length expected by packet_parse_common() */ #define PACKET_PARSE_SEG_LEN 96 @@ -126,7 +127,7 @@ typedef struct { odp_time_t timestamp;
/* Classifier destination queue */ - odp_queue_t dst_queue; + queue_t dst_queue;
/* Result for crypto */ odp_crypto_generic_op_result_t op_result; diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 168d0e9e..b5cbd515 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -48,6 +48,8 @@ typedef struct { typedef struct { char dummy; } _queue_t; typedef _queue_t *queue_t;
+#define QUEUE_NULL ((queue_t)NULL) + typedef int (*queue_init_global_fn_t)(void); typedef int (*queue_term_global_fn_t)(void); typedef int (*queue_init_local_fn_t)(void); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 5f153e73..cc08b9f4 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -162,7 +162,7 @@ odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param)
/* Packets are dropped if Queue or Pool is invalid*/ if (param->queue == ODP_QUEUE_INVALID) - queue = NULL; + queue = QUEUE_NULL; else queue = queue_fn->from_ext(param->queue);
@@ -264,7 +264,7 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id) /* Locking is not required as intermittent stale data during CoS modification is acceptable*/ if (queue_id == ODP_QUEUE_INVALID) - cos->s.queue = NULL; + cos->s.queue = QUEUE_NULL; else cos->s.queue = queue_fn->from_ext(queue_id); return 0; @@ -279,7 +279,7 @@ odp_queue_t odp_cos_queue(odp_cos_t cos_id) return ODP_QUEUE_INVALID; }
- if (!cos->s.queue) + if (cos->s.queue == QUEUE_NULL) return ODP_QUEUE_INVALID;
return queue_fn->to_ext(cos->s.queue); @@ -841,12 +841,12 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, if (cos == NULL) return -EINVAL;
- if (cos->s.queue == NULL || cos->s.pool == ODP_POOL_INVALID) + if (cos->s.queue == QUEUE_NULL || cos->s.pool == ODP_POOL_INVALID) return -EFAULT;
*pool = cos->s.pool; pkt_hdr->p.input_flags.dst_queue = 1; - pkt_hdr->dst_queue = queue_fn->to_ext(cos->s.queue); + pkt_hdr->dst_queue = cos->s.queue;
return 0; } diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 4dd28549..6ff35046 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -566,11 +566,9 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, buf_hdr = packet_to_buf_hdr(pkt);
if (pkt_hdr->p.input_flags.dst_queue) { - queue_t dst_queue; int ret;
- dst_queue = queue_fn->from_ext(pkt_hdr->dst_queue); - ret = queue_fn->enq(dst_queue, buf_hdr); + ret = queue_fn->enq(pkt_hdr->dst_queue, buf_hdr); if (ret < 0) odp_packet_free(pkt); continue;
commit e3fce2fca6067b03f7fd18c9a438d2058521fe11 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Jun 30 17:10:56 2017 +0300
linux-gen: sched: remove unused sched interface functions
Removed functions that are no longer used. Also removed unused parameter from save_context function.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 9b283678..4cd8c3e5 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -35,7 +35,7 @@ typedef int (*schedule_term_local_fn_t)(void); typedef void (*schedule_order_lock_fn_t)(void); typedef void (*schedule_order_unlock_fn_t)(void); typedef unsigned (*schedule_max_ordered_locks_fn_t)(void); -typedef void (*schedule_save_context_fn_t)(uint32_t queue_index, void *ptr); +typedef void (*schedule_save_context_fn_t)(uint32_t queue_index);
typedef struct schedule_fn_t { int status_sync; @@ -68,11 +68,6 @@ extern const schedule_fn_t *sched_fn; int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]); void sched_cb_pktio_stop_finalize(int pktio_index); int sched_cb_num_pktio(void); -int sched_cb_num_queues(void); -int sched_cb_queue_prio(uint32_t queue_index); -int sched_cb_queue_grp(uint32_t queue_index); -int sched_cb_queue_is_ordered(uint32_t queue_index); -int sched_cb_queue_is_atomic(uint32_t queue_index); odp_queue_t sched_cb_queue_handle(uint32_t queue_index); void sched_cb_queue_destroy_finalize(uint32_t queue_index); int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num); diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index d907779b..4c85027b 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -520,7 +520,7 @@ static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], queue->s.tail = NULL;
if (status_sync && queue->s.type == ODP_QUEUE_TYPE_SCHED) - sched_fn->save_context(queue->s.index, queue); + sched_fn->save_context(queue->s.index);
UNLOCK(&queue->s.lock);
@@ -672,25 +672,6 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return 0; }
-int sched_cb_num_queues(void) -{ - return ODP_CONFIG_QUEUES; -} - -int sched_cb_queue_prio(uint32_t queue_index) -{ - queue_entry_t *qe = get_qentry(queue_index); - - return qe->s.param.sched.prio; -} - -int sched_cb_queue_grp(uint32_t queue_index) -{ - queue_entry_t *qe = get_qentry(queue_index); - - return qe->s.param.sched.group; -} - odp_queue_t sched_cb_queue_handle(uint32_t queue_index) { return queue_from_id(queue_index); diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index c46e700b..d374dedd 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1305,10 +1305,8 @@ static inline bool is_ordered_queue(unsigned int queue_index) return (sched->queues[queue_index].sync == ODP_SCHED_SYNC_ORDERED); }
-static void schedule_save_context(uint32_t queue_index, void *ptr) +static void schedule_save_context(uint32_t queue_index) { - (void)ptr; - if (is_atomic_queue(queue_index)) { thread_local.atomic = &sched->availables[queue_index]; } else if (is_ordered_queue(queue_index)) {
commit 29ad363b5ab3c5e6569f20ddf63e64cc53eeb019 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Jun 30 17:10:55 2017 +0300
linux-gen: sched: remove most dependecies to qentry
Moved ordered queue context structure from queue internal structure to the scheduler. Ordering is a scheduler feature and thus all data and code about ordering should be in scheduler implementation. This removes most dependencies to qentry from the scheduler. Remaining dependecies are due to queue interface definition, which is not changed in this patch.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index d79abd23..032dde88 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -42,13 +42,6 @@ struct queue_entry_s { odp_buffer_hdr_t *tail; int status;
- struct { - odp_atomic_u64_t ctx; /**< Current ordered context id */ - odp_atomic_u64_t next_ctx; /**< Next unallocated context id */ - /** Array of ordered locks */ - odp_atomic_u64_t lock[CONFIG_QUEUE_MAX_ORD_LOCKS]; - } ordered ODP_ALIGNED_CACHE; - queue_enq_fn_t enqueue ODP_ALIGNED_CACHE; queue_deq_fn_t dequeue; queue_enq_multi_fn_t enqueue_multi; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 2db95fc6..d907779b 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -57,16 +57,6 @@ static inline odp_queue_t queue_from_id(uint32_t queue_id) return _odp_cast_scalar(odp_queue_t, queue_id + 1); }
-static inline int queue_is_atomic(queue_entry_t *qe) -{ - return qe->s.param.sched.sync == ODP_SCHED_SYNC_ATOMIC; -} - -static inline int queue_is_ordered(queue_entry_t *qe) -{ - return qe->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED; -} - queue_entry_t *get_qentry(uint32_t queue_id) { return &queue_tbl->queue[queue_id]; @@ -278,13 +268,6 @@ static int queue_destroy(odp_queue_t handle) ODP_ERR("queue "%s" not empty\n", queue->s.name); return -1; } - if (queue_is_ordered(queue) && - odp_atomic_load_u64(&queue->s.ordered.ctx) != - odp_atomic_load_u64(&queue->s.ordered.next_ctx)) { - UNLOCK(&queue->s.lock); - ODP_ERR("queue "%s" reorder incomplete\n", queue->s.name); - return -1; - }
switch (queue->s.status) { case QUEUE_STATUS_READY: @@ -610,20 +593,9 @@ static int queue_init(queue_entry_t *queue, const char *name, if (queue->s.param.sched.lock_count > sched_fn->max_ordered_locks()) return -1;
- if (param->type == ODP_QUEUE_TYPE_SCHED) { + if (param->type == ODP_QUEUE_TYPE_SCHED) queue->s.param.deq_mode = ODP_QUEUE_OP_DISABLED;
- if (param->sched.sync == ODP_SCHED_SYNC_ORDERED) { - unsigned i; - - odp_atomic_init_u64(&queue->s.ordered.ctx, 0); - odp_atomic_init_u64(&queue->s.ordered.next_ctx, 0); - - for (i = 0; i < queue->s.param.sched.lock_count; i++) - odp_atomic_init_u64(&queue->s.ordered.lock[i], - 0); - } - } queue->s.type = queue->s.param.type;
queue->s.enqueue = queue_int_enq; @@ -719,16 +691,6 @@ int sched_cb_queue_grp(uint32_t queue_index) return qe->s.param.sched.group; }
-int sched_cb_queue_is_ordered(uint32_t queue_index) -{ - return queue_is_ordered(get_qentry(queue_index)); -} - -int sched_cb_queue_is_atomic(uint32_t queue_index) -{ - return queue_is_atomic(get_qentry(queue_index)); -} - odp_queue_t sched_cb_queue_handle(uint32_t queue_index) { return queue_from_id(queue_index); diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 00452279..bbcc85a5 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -65,8 +65,11 @@ ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) && /* Maximum number of pktio poll commands */ #define NUM_PKTIO_CMD (MAX_PKTIN * NUM_PKTIO)
+/* Not a valid index */ +#define NULL_INDEX ((uint32_t)-1) + /* Not a valid poll command */ -#define PKTIO_CMD_INVALID ((uint32_t)-1) +#define PKTIO_CMD_INVALID NULL_INDEX
/* Pktio command is free */ #define PKTIO_CMD_FREE PKTIO_CMD_INVALID @@ -90,7 +93,7 @@ ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) && #define PRIO_QUEUE_MASK (PRIO_QUEUE_RING_SIZE - 1)
/* Priority queue empty, not a valid queue index. */ -#define PRIO_QUEUE_EMPTY ((uint32_t)-1) +#define PRIO_QUEUE_EMPTY NULL_INDEX
/* For best performance, the number of queues should be a power of two. */ ODP_STATIC_ASSERT(CHECK_IS_POWER2(ODP_CONFIG_QUEUES), @@ -127,7 +130,7 @@ ODP_STATIC_ASSERT((8 * sizeof(pri_mask_t)) >= QUEUES_PER_PRIO, /* Storage for stashed enqueue operation arguments */ typedef struct { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; - queue_entry_t *queue; + uint32_t queue_index; int num; } ordered_stash_t;
@@ -152,7 +155,8 @@ typedef struct { odp_queue_t queue; odp_event_t ev_stash[MAX_DEQ]; struct { - queue_entry_t *src_queue; /**< Source queue entry */ + /* Source queue index */ + uint32_t src_queue; uint64_t ctx; /**< Ordered context id */ int stash_num; /**< Number of stashed enqueue operations */ uint8_t in_order; /**< Order status */ @@ -197,6 +201,19 @@ typedef struct { uint32_t cmd_index; } pktio_cmd_t;
+/* Order context of a queue */ +typedef struct { + /* Current ordered context id */ + odp_atomic_u64_t ctx ODP_ALIGNED_CACHE; + + /* Next unallocated context id */ + odp_atomic_u64_t next_ctx; + + /* Array of ordered locks */ + odp_atomic_u64_t lock[CONFIG_QUEUE_MAX_ORD_LOCKS]; + +} order_context_t ODP_ALIGNED_CACHE; + typedef struct { pri_mask_t pri_mask[NUM_PRIO]; odp_spinlock_t mask_lock; @@ -230,6 +247,8 @@ typedef struct { int grp; int prio; int queue_per_prio; + int sync; + unsigned order_lock_count; } queue[ODP_CONFIG_QUEUES];
struct { @@ -237,6 +256,8 @@ typedef struct { int num_cmd; } pktio[NUM_PKTIO];
+ order_context_t order[ODP_CONFIG_QUEUES]; + } sched_global_t;
/* Global scheduler context */ @@ -259,6 +280,7 @@ static void sched_local_init(void) sched_local.thr = odp_thread_id(); sched_local.queue = ODP_QUEUE_INVALID; sched_local.queue_index = PRIO_QUEUE_EMPTY; + sched_local.ordered.src_queue = NULL_INDEX;
id = sched_local.thr & (QUEUES_PER_PRIO - 1);
@@ -488,16 +510,35 @@ static void pri_clr_queue(uint32_t queue_index, int prio) static int schedule_init_queue(uint32_t queue_index, const odp_schedule_param_t *sched_param) { + int i; int prio = sched_param->prio;
pri_set_queue(queue_index, prio); sched->queue[queue_index].grp = sched_param->group; sched->queue[queue_index].prio = prio; sched->queue[queue_index].queue_per_prio = queue_per_prio(queue_index); + sched->queue[queue_index].sync = sched_param->sync; + sched->queue[queue_index].order_lock_count = sched_param->lock_count; + + odp_atomic_init_u64(&sched->order[queue_index].ctx, 0); + odp_atomic_init_u64(&sched->order[queue_index].next_ctx, 0); + + for (i = 0; i < CONFIG_QUEUE_MAX_ORD_LOCKS; i++) + odp_atomic_init_u64(&sched->order[queue_index].lock[i], 0);
return 0; }
+static inline int queue_is_atomic(uint32_t queue_index) +{ + return sched->queue[queue_index].sync == ODP_SCHED_SYNC_ATOMIC; +} + +static inline int queue_is_ordered(uint32_t queue_index) +{ + return sched->queue[queue_index].sync == ODP_SCHED_SYNC_ORDERED; +} + static void schedule_destroy_queue(uint32_t queue_index) { int prio = sched->queue[queue_index].prio; @@ -506,6 +547,11 @@ static void schedule_destroy_queue(uint32_t queue_index) sched->queue[queue_index].grp = 0; sched->queue[queue_index].prio = 0; sched->queue[queue_index].queue_per_prio = 0; + + if (queue_is_ordered(queue_index) && + odp_atomic_load_u64(&sched->order[queue_index].ctx) != + odp_atomic_load_u64(&sched->order[queue_index].next_ctx)) + ODP_ERR("queue reorder incomplete\n"); }
static int poll_cmd_queue_idx(int pktio_index, int pktin_idx) @@ -606,20 +652,20 @@ static void schedule_release_atomic(void) } }
-static inline int ordered_own_turn(queue_entry_t *queue) +static inline int ordered_own_turn(uint32_t queue_index) { uint64_t ctx;
- ctx = odp_atomic_load_acq_u64(&queue->s.ordered.ctx); + ctx = odp_atomic_load_acq_u64(&sched->order[queue_index].ctx);
return ctx == sched_local.ordered.ctx; }
-static inline void wait_for_order(queue_entry_t *queue) +static inline void wait_for_order(uint32_t queue_index) { /* Busy loop to synchronize ordered processing */ while (1) { - if (ordered_own_turn(queue)) + if (ordered_own_turn(queue_index)) break; odp_cpu_pause(); } @@ -635,52 +681,54 @@ static inline void ordered_stash_release(void) int i;
for (i = 0; i < sched_local.ordered.stash_num; i++) { - queue_entry_t *queue; + queue_entry_t *queue_entry; + uint32_t queue_index; odp_buffer_hdr_t **buf_hdr; int num;
- queue = sched_local.ordered.stash[i].queue; + queue_index = sched_local.ordered.stash[i].queue_index; + queue_entry = get_qentry(queue_index); buf_hdr = sched_local.ordered.stash[i].buf_hdr; num = sched_local.ordered.stash[i].num;
- queue_fn->enq_multi(qentry_to_int(queue), buf_hdr, num); + queue_fn->enq_multi(qentry_to_int(queue_entry), buf_hdr, num); } sched_local.ordered.stash_num = 0; }
static inline void release_ordered(void) { + uint32_t qi; unsigned i; - queue_entry_t *queue;
- queue = sched_local.ordered.src_queue; + qi = sched_local.ordered.src_queue;
- wait_for_order(queue); + wait_for_order(qi);
/* Release all ordered locks */ - for (i = 0; i < queue->s.param.sched.lock_count; i++) { + for (i = 0; i < sched->queue[qi].order_lock_count; i++) { if (!sched_local.ordered.lock_called.u8[i]) - odp_atomic_store_rel_u64(&queue->s.ordered.lock[i], + odp_atomic_store_rel_u64(&sched->order[qi].lock[i], sched_local.ordered.ctx + 1); }
sched_local.ordered.lock_called.all = 0; - sched_local.ordered.src_queue = NULL; + sched_local.ordered.src_queue = NULL_INDEX; sched_local.ordered.in_order = 0;
ordered_stash_release();
/* Next thread can continue processing */ - odp_atomic_add_rel_u64(&queue->s.ordered.ctx, 1); + odp_atomic_add_rel_u64(&sched->order[qi].ctx, 1); }
static void schedule_release_ordered(void) { - queue_entry_t *queue; + uint32_t queue_index;
- queue = sched_local.ordered.src_queue; + queue_index = sched_local.ordered.src_queue;
- if (odp_unlikely(!queue || sched_local.num)) + if (odp_unlikely((queue_index == NULL_INDEX) || sched_local.num)) return;
release_ordered(); @@ -688,7 +736,7 @@ static void schedule_release_ordered(void)
static inline void schedule_release_context(void) { - if (sched_local.ordered.src_queue != NULL) + if (sched_local.ordered.src_queue != NULL_INDEX) release_ordered(); else schedule_release_atomic(); @@ -715,9 +763,9 @@ static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], int i; uint32_t stash_num = sched_local.ordered.stash_num; queue_entry_t *dst_queue = qentry_from_int(q_int); - queue_entry_t *src_queue = sched_local.ordered.src_queue; + uint32_t src_queue = sched_local.ordered.src_queue;
- if (!sched_local.ordered.src_queue || sched_local.ordered.in_order) + if ((src_queue == NULL_INDEX) || sched_local.ordered.in_order) return 0;
if (ordered_own_turn(src_queue)) { @@ -740,7 +788,7 @@ static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], return 0; }
- sched_local.ordered.stash[stash_num].queue = dst_queue; + sched_local.ordered.stash[stash_num].queue_index = dst_queue->s.index; sched_local.ordered.stash[stash_num].num = num; for (i = 0; i < num; i++) sched_local.ordered.stash[stash_num].buf_hdr[i] = buf_hdr[i]; @@ -803,7 +851,7 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[], prio > ODP_SCHED_PRIO_DEFAULT)) max_deq = MAX_DEQ / 2;
- ordered = sched_cb_queue_is_ordered(qi); + ordered = queue_is_ordered(qi);
/* Do not cache ordered events locally to improve * parallelism. Ordered context can only be released @@ -835,21 +883,18 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[],
if (ordered) { uint64_t ctx; - queue_entry_t *queue; odp_atomic_u64_t *next_ctx;
- queue = get_qentry(qi); - next_ctx = &queue->s.ordered.next_ctx; - + next_ctx = &sched->order[qi].next_ctx; ctx = odp_atomic_fetch_inc_u64(next_ctx);
sched_local.ordered.ctx = ctx; - sched_local.ordered.src_queue = queue; + sched_local.ordered.src_queue = qi;
/* Continue scheduling ordered queues */ ring_enq(ring, PRIO_QUEUE_MASK, qi);
- } else if (sched_cb_queue_is_atomic(qi)) { + } else if (queue_is_atomic(qi)) { /* Hold queue during atomic access */ sched_local.queue_index = qi; } else { @@ -1039,14 +1084,14 @@ static int schedule_multi(odp_queue_t *out_queue, uint64_t wait,
static inline void order_lock(void) { - queue_entry_t *queue; + uint32_t queue_index;
- queue = sched_local.ordered.src_queue; + queue_index = sched_local.ordered.src_queue;
- if (!queue) + if (queue_index == NULL_INDEX) return;
- wait_for_order(queue); + wait_for_order(queue_index); }
static void order_unlock(void) @@ -1056,14 +1101,15 @@ static void order_unlock(void) static void schedule_order_lock(unsigned lock_index) { odp_atomic_u64_t *ord_lock; - queue_entry_t *queue; + uint32_t queue_index;
- queue = sched_local.ordered.src_queue; + queue_index = sched_local.ordered.src_queue;
- ODP_ASSERT(queue && lock_index <= queue->s.param.sched.lock_count && + ODP_ASSERT(queue_index != NULL_INDEX && + lock_index <= sched->queue[queue_index].order_lock_count && !sched_local.ordered.lock_called.u8[lock_index]);
- ord_lock = &queue->s.ordered.lock[lock_index]; + ord_lock = &sched->order[queue_index].lock[lock_index];
/* Busy loop to synchronize ordered processing */ while (1) { @@ -1082,13 +1128,14 @@ static void schedule_order_lock(unsigned lock_index) static void schedule_order_unlock(unsigned lock_index) { odp_atomic_u64_t *ord_lock; - queue_entry_t *queue; + uint32_t queue_index;
- queue = sched_local.ordered.src_queue; + queue_index = sched_local.ordered.src_queue;
- ODP_ASSERT(queue && lock_index <= queue->s.param.sched.lock_count); + ODP_ASSERT(queue_index != NULL_INDEX && + lock_index <= sched->queue[queue_index].order_lock_count);
- ord_lock = &queue->s.ordered.lock[lock_index]; + ord_lock = &sched->order[queue_index].lock[lock_index];
ODP_ASSERT(sched_local.ordered.ctx == odp_atomic_load_u64(ord_lock));
diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index fd0ca5e8..c46e700b 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -70,6 +70,8 @@ typedef struct { /* Maximum number of pktio poll commands */ #define NUM_PKTIO_CMD (MAX_PKTIN * NUM_PKTIO)
+/* Not a valid index */ +#define NULL_INDEX ((uint32_t)-1) /* Pktio command is free */ #define PKTIO_CMD_FREE ((uint32_t)-1)
@@ -116,6 +118,19 @@ typedef struct { /* Forward declaration */ typedef struct sched_thread_local sched_thread_local_t;
+/* Order context of a queue */ +typedef struct { + /* Current ordered context id */ + odp_atomic_u64_t ctx ODP_ALIGNED_CACHE; + + /* Next unallocated context id */ + odp_atomic_u64_t next_ctx; + + /* Array of ordered locks */ + odp_atomic_u64_t lock[CONFIG_QUEUE_MAX_ORD_LOCKS]; + +} order_context_t ODP_ALIGNED_CACHE; + typedef struct { odp_shm_t selfie;
@@ -138,6 +153,8 @@ typedef struct {
/* Quick reference to per thread context */ sched_thread_local_t *threads[ODP_THREAD_COUNT_MAX]; + + order_context_t order[ODP_CONFIG_QUEUES]; } sched_global_t;
/* Per thread events cache */ @@ -153,7 +170,7 @@ typedef struct { /* Storage for stashed enqueue operation arguments */ typedef struct { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; - queue_entry_t *queue; + uint32_t queue_index; int num; } ordered_stash_t;
@@ -194,7 +211,8 @@ struct sched_thread_local { sparse_bitmap_iterator_t iterators[NUM_SCHED_PRIO];
struct { - queue_entry_t *src_queue; /**< Source queue entry */ + /* Source queue index */ + uint32_t src_queue; uint64_t ctx; /**< Ordered context id */ int stash_num; /**< Number of stashed enqueue operations */ uint8_t in_order; /**< Order status */ @@ -313,6 +331,7 @@ static void sched_thread_local_reset(void)
thread_local.thread = odp_thread_id(); thread_local.cache.queue = ODP_QUEUE_INVALID; + thread_local.ordered.src_queue = NULL_INDEX;
odp_rwlock_init(&thread_local.lock);
@@ -394,7 +413,7 @@ static int schedule_term_local(void) static int init_sched_queue(uint32_t queue_index, const odp_schedule_param_t *sched_param) { - int prio, group, thread; + int prio, group, thread, i; sched_prio_t *P; sched_group_t *G; sched_thread_local_t *local; @@ -427,6 +446,12 @@ static int init_sched_queue(uint32_t queue_index, memcpy(&sched->queues[queue_index], sched_param, sizeof(odp_schedule_param_t));
+ odp_atomic_init_u64(&sched->order[queue_index].ctx, 0); + odp_atomic_init_u64(&sched->order[queue_index].next_ctx, 0); + + for (i = 0; i < CONFIG_QUEUE_MAX_ORD_LOCKS; i++) + odp_atomic_init_u64(&sched->order[queue_index].lock[i], 0); + /* Update all threads in this schedule group to * start check this queue index upon scheduling. */ @@ -501,6 +526,11 @@ static void destroy_sched_queue(uint32_t queue_index)
__destroy_sched_queue(G, queue_index); odp_rwlock_write_unlock(&G->lock); + + if (sched->queues[queue_index].sync == ODP_SCHED_SYNC_ORDERED && + odp_atomic_load_u64(&sched->order[queue_index].ctx) != + odp_atomic_load_u64(&sched->order[queue_index].next_ctx)) + ODP_ERR("queue reorder incomplete\n"); }
static int pktio_cmd_queue_hash(int pktio, int pktin) @@ -1067,20 +1097,20 @@ static void schedule_release_atomic(void) } }
-static inline int ordered_own_turn(queue_entry_t *queue) +static inline int ordered_own_turn(uint32_t queue_index) { uint64_t ctx;
- ctx = odp_atomic_load_acq_u64(&queue->s.ordered.ctx); + ctx = odp_atomic_load_acq_u64(&sched->order[queue_index].ctx);
return ctx == thread_local.ordered.ctx; }
-static inline void wait_for_order(queue_entry_t *queue) +static inline void wait_for_order(uint32_t queue_index) { /* Busy loop to synchronize ordered processing */ while (1) { - if (ordered_own_turn(queue)) + if (ordered_own_turn(queue_index)) break; odp_cpu_pause(); } @@ -1096,52 +1126,55 @@ static inline void ordered_stash_release(void) int i;
for (i = 0; i < thread_local.ordered.stash_num; i++) { - queue_entry_t *queue; + queue_entry_t *queue_entry; + uint32_t queue_index; odp_buffer_hdr_t **buf_hdr; int num;
- queue = thread_local.ordered.stash[i].queue; + queue_index = thread_local.ordered.stash[i].queue_index; + queue_entry = get_qentry(queue_index); buf_hdr = thread_local.ordered.stash[i].buf_hdr; num = thread_local.ordered.stash[i].num;
- queue_fn->enq_multi(qentry_to_int(queue), buf_hdr, num); + queue_fn->enq_multi(qentry_to_int(queue_entry), buf_hdr, num); } thread_local.ordered.stash_num = 0; }
static inline void release_ordered(void) { + uint32_t qi; unsigned i; - queue_entry_t *queue;
- queue = thread_local.ordered.src_queue; + qi = thread_local.ordered.src_queue;
- wait_for_order(queue); + wait_for_order(qi);
/* Release all ordered locks */ - for (i = 0; i < queue->s.param.sched.lock_count; i++) { + for (i = 0; i < sched->queues[qi].lock_count; i++) { if (!thread_local.ordered.lock_called.u8[i]) - odp_atomic_store_rel_u64(&queue->s.ordered.lock[i], + odp_atomic_store_rel_u64(&sched->order[qi].lock[i], thread_local.ordered.ctx + 1); }
thread_local.ordered.lock_called.all = 0; - thread_local.ordered.src_queue = NULL; + thread_local.ordered.src_queue = NULL_INDEX; thread_local.ordered.in_order = 0;
ordered_stash_release();
/* Next thread can continue processing */ - odp_atomic_add_rel_u64(&queue->s.ordered.ctx, 1); + odp_atomic_add_rel_u64(&sched->order[qi].ctx, 1); }
static void schedule_release_ordered(void) { - queue_entry_t *queue; + uint32_t queue_index;
- queue = thread_local.ordered.src_queue; + queue_index = thread_local.ordered.src_queue;
- if (odp_unlikely(!queue || thread_local.cache.count)) + if (odp_unlikely((queue_index == NULL_INDEX) || + thread_local.cache.count)) return;
release_ordered(); @@ -1149,7 +1182,7 @@ static void schedule_release_ordered(void)
static inline void schedule_release_context(void) { - if (thread_local.ordered.src_queue != NULL) + if (thread_local.ordered.src_queue != NULL_INDEX) release_ordered(); else schedule_release_atomic(); @@ -1161,9 +1194,9 @@ static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], int i; uint32_t stash_num = thread_local.ordered.stash_num; queue_entry_t *dst_queue = qentry_from_int(q_int); - queue_entry_t *src_queue = thread_local.ordered.src_queue; + uint32_t src_queue = thread_local.ordered.src_queue;
- if (!thread_local.ordered.src_queue || thread_local.ordered.in_order) + if ((src_queue == NULL_INDEX) || thread_local.ordered.in_order) return 0;
if (ordered_own_turn(src_queue)) { @@ -1186,7 +1219,7 @@ static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], return 0; }
- thread_local.ordered.stash[stash_num].queue = dst_queue; + thread_local.ordered.stash[stash_num].queue_index = dst_queue->s.index; thread_local.ordered.stash[stash_num].num = num; for (i = 0; i < num; i++) thread_local.ordered.stash[stash_num].buf_hdr[i] = buf_hdr[i]; @@ -1199,14 +1232,14 @@ static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[],
static void order_lock(void) { - queue_entry_t *queue; + uint32_t queue_index;
- queue = thread_local.ordered.src_queue; + queue_index = thread_local.ordered.src_queue;
- if (!queue) + if (queue_index == NULL_INDEX) return;
- wait_for_order(queue); + wait_for_order(queue_index); }
static void order_unlock(void) @@ -1216,14 +1249,15 @@ static void order_unlock(void) static void schedule_order_lock(unsigned lock_index) { odp_atomic_u64_t *ord_lock; - queue_entry_t *queue; + uint32_t queue_index;
- queue = thread_local.ordered.src_queue; + queue_index = thread_local.ordered.src_queue;
- ODP_ASSERT(queue && lock_index <= queue->s.param.sched.lock_count && + ODP_ASSERT(queue_index != NULL_INDEX && + lock_index <= sched->queues[queue_index].lock_count && !thread_local.ordered.lock_called.u8[lock_index]);
- ord_lock = &queue->s.ordered.lock[lock_index]; + ord_lock = &sched->order[queue_index].lock[lock_index];
/* Busy loop to synchronize ordered processing */ while (1) { @@ -1242,13 +1276,14 @@ static void schedule_order_lock(unsigned lock_index) static void schedule_order_unlock(unsigned lock_index) { odp_atomic_u64_t *ord_lock; - queue_entry_t *queue; + uint32_t queue_index;
- queue = thread_local.ordered.src_queue; + queue_index = thread_local.ordered.src_queue;
- ODP_ASSERT(queue && lock_index <= queue->s.param.sched.lock_count); + ODP_ASSERT(queue_index != NULL_INDEX && + lock_index <= sched->queues[queue_index].lock_count);
- ord_lock = &queue->s.ordered.lock[lock_index]; + ord_lock = &sched->order[queue_index].lock[lock_index];
ODP_ASSERT(thread_local.ordered.ctx == odp_atomic_load_u64(ord_lock));
@@ -1272,7 +1307,7 @@ static inline bool is_ordered_queue(unsigned int queue_index)
static void schedule_save_context(uint32_t queue_index, void *ptr) { - queue_entry_t *queue = ptr; + (void)ptr;
if (is_atomic_queue(queue_index)) { thread_local.atomic = &sched->availables[queue_index]; @@ -1280,11 +1315,11 @@ static void schedule_save_context(uint32_t queue_index, void *ptr) uint64_t ctx; odp_atomic_u64_t *next_ctx;
- next_ctx = &queue->s.ordered.next_ctx; + next_ctx = &sched->order[queue_index].next_ctx; ctx = odp_atomic_fetch_inc_u64(next_ctx);
thread_local.ordered.ctx = ctx; - thread_local.ordered.src_queue = queue; + thread_local.ordered.src_queue = queue_index; } }
commit 8ef745b7b78b49fc58d14e7b79b450c0bb560558 Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Jun 30 17:10:54 2017 +0300
linux-gen: sched: use config max ordered locks
Use config file value for the number of ordered locks everywhere.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h index e7d84c90..292be356 100644 --- a/platform/linux-generic/include/odp_config_internal.h +++ b/platform/linux-generic/include/odp_config_internal.h @@ -24,7 +24,7 @@ extern "C" { /* * Maximum number of ordered locks per queue */ -#define CONFIG_QUEUE_MAX_ORD_LOCKS 4 +#define CONFIG_QUEUE_MAX_ORD_LOCKS 2
/* * Maximum number of packet IO resources diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 3a462995..00452279 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -121,12 +121,6 @@ ODP_STATIC_ASSERT((8 * sizeof(pri_mask_t)) >= QUEUES_PER_PRIO, /* Maximum number of dequeues */ #define MAX_DEQ CONFIG_BURST_SIZE
-/* Maximum number of ordered locks per queue */ -#define MAX_ORDERED_LOCKS_PER_QUEUE 2 - -ODP_STATIC_ASSERT(MAX_ORDERED_LOCKS_PER_QUEUE <= CONFIG_QUEUE_MAX_ORD_LOCKS, - "Too_many_ordered_locks"); - /* Ordered stash size */ #define MAX_ORDERED_STASH 512
@@ -449,7 +443,7 @@ static inline int grp_update_tbl(void)
static unsigned schedule_max_ordered_locks(void) { - return MAX_ORDERED_LOCKS_PER_QUEUE; + return CONFIG_QUEUE_MAX_ORD_LOCKS; }
static inline int queue_per_prio(uint32_t queue_index) diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 6eea24c6..fd0ca5e8 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -147,12 +147,6 @@ typedef struct { odp_event_t stash[MAX_DEQ], *top; } event_cache_t;
-/* Maximum number of ordered locks per queue */ -#define MAX_ORDERED_LOCKS_PER_QUEUE 2 - -ODP_STATIC_ASSERT(MAX_ORDERED_LOCKS_PER_QUEUE <= CONFIG_QUEUE_MAX_ORD_LOCKS, - "Too_many_ordered_locks"); - /* Ordered stash size */ #define MAX_ORDERED_STASH 512
@@ -1263,7 +1257,7 @@ static void schedule_order_unlock(unsigned lock_index)
static unsigned schedule_max_ordered_locks(void) { - return MAX_ORDERED_LOCKS_PER_QUEUE; + return CONFIG_QUEUE_MAX_ORD_LOCKS; }
static inline bool is_atomic_queue(unsigned int queue_index)
commit d9c85310cb82f83010c839b6a1bbb5a1fa672ceb Author: Petri Savolainen petri.savolainen@linaro.org Date: Fri Jun 30 17:10:53 2017 +0300
linux-gen: sched: remove schedule interface depedency to qentry
Do not use queue internal type in schedule interface.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 5d10cd37..9b283678 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -35,9 +35,10 @@ typedef int (*schedule_term_local_fn_t)(void); typedef void (*schedule_order_lock_fn_t)(void); typedef void (*schedule_order_unlock_fn_t)(void); typedef unsigned (*schedule_max_ordered_locks_fn_t)(void); -typedef void (*schedule_save_context_fn_t)(queue_entry_t *queue); +typedef void (*schedule_save_context_fn_t)(uint32_t queue_index, void *ptr);
typedef struct schedule_fn_t { + int status_sync; schedule_pktio_start_fn_t pktio_start; schedule_thr_add_fn_t thr_add; schedule_thr_rem_fn_t thr_rem; @@ -45,7 +46,6 @@ typedef struct schedule_fn_t { schedule_init_queue_fn_t init_queue; schedule_destroy_queue_fn_t destroy_queue; schedule_sched_queue_fn_t sched_queue; - schedule_unsched_queue_fn_t unsched_queue; schedule_ord_enq_multi_fn_t ord_enq_multi; schedule_init_global_fn_t init_global; schedule_term_global_fn_t term_global; @@ -54,7 +54,11 @@ typedef struct schedule_fn_t { schedule_order_lock_fn_t order_lock; schedule_order_unlock_fn_t order_unlock; schedule_max_ordered_locks_fn_t max_ordered_locks; + + /* Called only when status_sync is set */ + schedule_unsched_queue_fn_t unsched_queue; schedule_save_context_fn_t save_context; + } schedule_fn_t;
/* Interface towards the scheduler */ diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 19945584..2db95fc6 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -474,6 +474,7 @@ static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int i, j; queue_entry_t *queue; int updated = 0; + int status_sync = sched_fn->status_sync;
queue = qentry_from_int(q_int); LOCK(&queue->s.lock); @@ -490,7 +491,9 @@ static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], /* Already empty queue */ if (queue->s.status == QUEUE_STATUS_SCHED) { queue->s.status = QUEUE_STATUS_NOTSCHED; - sched_fn->unsched_queue(queue->s.index); + + if (status_sync) + sched_fn->unsched_queue(queue->s.index); }
UNLOCK(&queue->s.lock); @@ -533,8 +536,8 @@ static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], if (hdr == NULL) queue->s.tail = NULL;
- if (queue->s.type == ODP_QUEUE_TYPE_SCHED) - sched_fn->save_context(queue); + if (status_sync && queue->s.type == ODP_QUEUE_TYPE_SCHED) + sched_fn->save_context(queue->s.index, queue);
UNLOCK(&queue->s.lock);
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 92634235..3a462995 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -22,6 +22,9 @@ #include <odp/api/sync.h> #include <odp/api/packet_io.h> #include <odp_ring_internal.h> +#include <odp_timer_internal.h> + +/* Should remove this dependency */ #include <odp_queue_internal.h>
/* Number of priority levels */ @@ -1337,22 +1340,14 @@ static int schedule_sched_queue(uint32_t queue_index) return 0; }
-static int schedule_unsched_queue(uint32_t queue_index ODP_UNUSED) -{ - return 0; -} - static int schedule_num_grps(void) { return NUM_SCHED_GRPS; }
-static void schedule_save_context(queue_entry_t *queue ODP_UNUSED) -{ -} - /* Fill in scheduler interface */ const schedule_fn_t schedule_default_fn = { + .status_sync = 0, .pktio_start = schedule_pktio_start, .thr_add = schedule_thr_add, .thr_rem = schedule_thr_rem, @@ -1360,7 +1355,6 @@ const schedule_fn_t schedule_default_fn = { .init_queue = schedule_init_queue, .destroy_queue = schedule_destroy_queue, .sched_queue = schedule_sched_queue, - .unsched_queue = schedule_unsched_queue, .ord_enq_multi = schedule_ord_enq_multi, .init_global = schedule_init_global, .term_global = schedule_term_global, @@ -1369,7 +1363,8 @@ const schedule_fn_t schedule_default_fn = { .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = schedule_max_ordered_locks, - .save_context = schedule_save_context + .unsched_queue = NULL, + .save_context = NULL };
/* Fill in scheduler API calls */ diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 79086843..6eea24c6 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -12,7 +12,6 @@ #include <odp_internal.h> #include <odp_debug_internal.h> #include <odp_ring_internal.h> -#include <odp_queue_internal.h> #include <odp_buffer_internal.h> #include <odp_bitmap_internal.h> #include <odp/api/thread.h> @@ -24,6 +23,9 @@ #include <odp/api/packet_io.h> #include <odp_config_internal.h>
+/* Should remove this dependency */ +#include <odp_queue_internal.h> + /* Number of priority levels */ #define NUM_SCHED_PRIO 8
@@ -1264,11 +1266,23 @@ static unsigned schedule_max_ordered_locks(void) return MAX_ORDERED_LOCKS_PER_QUEUE; }
-static void schedule_save_context(queue_entry_t *queue) +static inline bool is_atomic_queue(unsigned int queue_index) +{ + return (sched->queues[queue_index].sync == ODP_SCHED_SYNC_ATOMIC); +} + +static inline bool is_ordered_queue(unsigned int queue_index) +{ + return (sched->queues[queue_index].sync == ODP_SCHED_SYNC_ORDERED); +} + +static void schedule_save_context(uint32_t queue_index, void *ptr) { - if (queue->s.param.sched.sync == ODP_SCHED_SYNC_ATOMIC) { - thread_local.atomic = &sched->availables[queue->s.index]; - } else if (queue->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED) { + queue_entry_t *queue = ptr; + + if (is_atomic_queue(queue_index)) { + thread_local.atomic = &sched->availables[queue_index]; + } else if (is_ordered_queue(queue_index)) { uint64_t ctx; odp_atomic_u64_t *next_ctx;
@@ -1282,6 +1296,7 @@ static void schedule_save_context(queue_entry_t *queue)
/* Fill in scheduler interface */ const schedule_fn_t schedule_iquery_fn = { + .status_sync = 1, .pktio_start = schedule_pktio_start, .thr_add = group_add_thread, .thr_rem = group_remove_thread, @@ -1289,7 +1304,6 @@ const schedule_fn_t schedule_iquery_fn = { .init_queue = init_sched_queue, .destroy_queue = destroy_sched_queue, .sched_queue = schedule_sched_queue, - .unsched_queue = schedule_unsched_queue, .ord_enq_multi = schedule_ord_enq_multi, .init_global = schedule_init_global, .term_global = schedule_term_global, @@ -1298,7 +1312,8 @@ const schedule_fn_t schedule_iquery_fn = { .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = schedule_max_ordered_locks, - .save_context = schedule_save_context, + .unsched_queue = schedule_unsched_queue, + .save_context = schedule_save_context };
/* Fill in scheduler API calls */ @@ -1425,18 +1440,6 @@ static void thread_clear_interests(sched_thread_local_t *thread, } }
-static inline bool is_atomic_queue(unsigned int queue_index) -{ - return (sched->queues[queue_index].sync - == ODP_SCHED_SYNC_ATOMIC); -} - -static inline bool is_ordered_queue(unsigned int queue_index) -{ - return (sched->queues[queue_index].sync - == ODP_SCHED_SYNC_ORDERED); -} - static inline bool compete_atomic_queue(unsigned int queue_index) { bool expected = sched->availables[queue_index]; diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 66715c13..d2ba539c 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -409,11 +409,6 @@ static int sched_queue(uint32_t qi) return 0; }
-static int unsched_queue(uint32_t qi ODP_UNUSED) -{ - return 0; -} - static int ord_enq_multi(queue_t q_int, void *buf_hdr[], int num, int *ret) { @@ -827,12 +822,9 @@ static void order_unlock(void) { }
-static void save_context(queue_entry_t *queue ODP_UNUSED) -{ -} - /* Fill in scheduler interface */ const schedule_fn_t schedule_sp_fn = { + .status_sync = 0, .pktio_start = pktio_start, .thr_add = thr_add, .thr_rem = thr_rem, @@ -840,16 +832,16 @@ const schedule_fn_t schedule_sp_fn = { .init_queue = init_queue, .destroy_queue = destroy_queue, .sched_queue = sched_queue, - .unsched_queue = unsched_queue, .ord_enq_multi = ord_enq_multi, .init_global = init_global, .term_global = term_global, .init_local = init_local, .term_local = term_local, - .order_lock = order_lock, - .order_unlock = order_unlock, + .order_lock = order_lock, + .order_unlock = order_unlock, .max_ordered_locks = max_ordered_locks, - .save_context = save_context + .unsched_queue = NULL, + .save_context = NULL };
/* Fill in scheduler API calls */
commit 5a38050f431d904b7354cd50611304da0a601727 Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Jun 12 14:11:33 2017 +0300
linux-gen: queue: clean up after modular interface
Clean up function and parameter naming after modular interface patch. Queue_t type is referred as "queue internal": queue_int or q_int. Term "handle" is reserved for API level handles (e.g. odp_queue_t, odp_pktio_t, etc) through out linux-gen implementation.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 4359435f..168d0e9e 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -53,24 +53,24 @@ typedef int (*queue_term_global_fn_t)(void); typedef int (*queue_init_local_fn_t)(void); typedef int (*queue_term_local_fn_t)(void); typedef queue_t (*queue_from_ext_fn_t)(odp_queue_t handle); -typedef odp_queue_t (*queue_to_ext_fn_t)(queue_t handle); -typedef int (*queue_enq_fn_t)(queue_t handle, odp_buffer_hdr_t *); -typedef int (*queue_enq_multi_fn_t)(queue_t handle, odp_buffer_hdr_t **, int); -typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(queue_t handle); -typedef int (*queue_deq_multi_fn_t)(queue_t handle, odp_buffer_hdr_t **, int); -typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(queue_t handle); -typedef void (*queue_set_pktout_fn_t)(queue_t handle, odp_pktio_t pktio, +typedef odp_queue_t (*queue_to_ext_fn_t)(queue_t q_int); +typedef int (*queue_enq_fn_t)(queue_t q_int, odp_buffer_hdr_t *); +typedef int (*queue_enq_multi_fn_t)(queue_t q_int, odp_buffer_hdr_t **, int); +typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(queue_t q_int); +typedef int (*queue_deq_multi_fn_t)(queue_t q_int, odp_buffer_hdr_t **, int); +typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(queue_t q_int); +typedef void (*queue_set_pktout_fn_t)(queue_t q_int, odp_pktio_t pktio, int index); -typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t handle); -typedef void (*queue_set_pktin_fn_t)(queue_t handle, odp_pktio_t pktio, +typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t q_int); +typedef void (*queue_set_pktin_fn_t)(queue_t q_int, odp_pktio_t pktio, int index); -typedef void (*queue_set_enq_fn_t)(queue_t handle, queue_enq_fn_t func); -typedef void (*queue_set_enq_multi_fn_t)(queue_t handle, +typedef void (*queue_set_enq_fn_t)(queue_t q_int, queue_enq_fn_t func); +typedef void (*queue_set_enq_multi_fn_t)(queue_t q_int, queue_enq_multi_fn_t func); -typedef void (*queue_set_deq_fn_t)(queue_t handle, queue_deq_fn_t func); -typedef void (*queue_set_deq_multi_fn_t)(queue_t handle, +typedef void (*queue_set_deq_fn_t)(queue_t q_int, queue_deq_fn_t func); +typedef void (*queue_set_deq_multi_fn_t)(queue_t q_int, queue_deq_multi_fn_t func); -typedef void (*queue_set_type_fn_t)(queue_t handle, odp_queue_type_t type); +typedef void (*queue_set_type_fn_t)(queue_t q_int, odp_queue_type_t type);
/* Queue functions towards other internal components */ typedef struct { diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 0c31ce8a..d79abd23 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -78,9 +78,9 @@ static inline uint32_t queue_to_id(odp_queue_t handle) return _odp_typeval(handle) - 1; }
-static inline queue_entry_t *qentry_from_int(queue_t handle) +static inline queue_entry_t *qentry_from_int(queue_t q_int) { - return (queue_entry_t *)(void *)(handle); + return (queue_entry_t *)(void *)(q_int); }
static inline queue_t qentry_to_int(queue_entry_t *qentry) diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 9adacef7..5d10cd37 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -26,7 +26,7 @@ typedef int (*schedule_init_queue_fn_t)(uint32_t queue_index, typedef void (*schedule_destroy_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_sched_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_unsched_queue_fn_t)(uint32_t queue_index); -typedef int (*schedule_ord_enq_multi_fn_t)(queue_t handle, +typedef int (*schedule_ord_enq_multi_fn_t)(queue_t q_int, void *buf_hdr[], int num, int *ret); typedef int (*schedule_init_global_fn_t)(void); typedef int (*schedule_term_global_fn_t)(void); diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 3e18f578..19945584 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -35,20 +35,22 @@ #include <string.h> #include <inttypes.h>
+static int queue_init(queue_entry_t *queue, const char *name, + const odp_queue_param_t *param); + typedef struct queue_table_t { queue_entry_t queue[ODP_CONFIG_QUEUES]; } queue_table_t;
static queue_table_t *queue_tbl;
-static queue_t queue_from_ext(odp_queue_t handle); -static int _queue_enq(queue_t handle, odp_buffer_hdr_t *buf_hdr); -static odp_buffer_hdr_t *_queue_deq(queue_t handle); +static inline queue_entry_t *handle_to_qentry(odp_queue_t handle) +{ + uint32_t queue_id;
-static int _queue_enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num); -static int _queue_deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num); + queue_id = queue_to_id(handle); + return get_qentry(queue_id); +}
static inline odp_queue_t queue_from_id(uint32_t queue_id) { @@ -70,50 +72,6 @@ queue_entry_t *get_qentry(uint32_t queue_id) return &queue_tbl->queue[queue_id]; }
-static int queue_init(queue_entry_t *queue, const char *name, - const odp_queue_param_t *param) -{ - if (name == NULL) { - queue->s.name[0] = 0; - } else { - strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1); - queue->s.name[ODP_QUEUE_NAME_LEN - 1] = 0; - } - memcpy(&queue->s.param, param, sizeof(odp_queue_param_t)); - if (queue->s.param.sched.lock_count > sched_fn->max_ordered_locks()) - return -1; - - if (param->type == ODP_QUEUE_TYPE_SCHED) { - queue->s.param.deq_mode = ODP_QUEUE_OP_DISABLED; - - if (param->sched.sync == ODP_SCHED_SYNC_ORDERED) { - unsigned i; - - odp_atomic_init_u64(&queue->s.ordered.ctx, 0); - odp_atomic_init_u64(&queue->s.ordered.next_ctx, 0); - - for (i = 0; i < queue->s.param.sched.lock_count; i++) - odp_atomic_init_u64(&queue->s.ordered.lock[i], - 0); - } - } - queue->s.type = queue->s.param.type; - - queue->s.enqueue = _queue_enq; - queue->s.dequeue = _queue_deq; - queue->s.enqueue_multi = _queue_enq_multi; - queue->s.dequeue_multi = _queue_deq_multi; - - queue->s.pktin = PKTIN_INVALID; - queue->s.pktout = PKTOUT_INVALID; - - queue->s.head = NULL; - queue->s.tail = NULL; - - return 0; -} - - static int queue_init_global(void) { uint32_t i; @@ -204,27 +162,27 @@ static int queue_capability(odp_queue_capability_t *capa)
static odp_queue_type_t queue_type(odp_queue_t handle) { - return qentry_from_int(queue_from_ext(handle))->s.type; + return handle_to_qentry(handle)->s.type; }
static odp_schedule_sync_t queue_sched_type(odp_queue_t handle) { - return qentry_from_int(queue_from_ext(handle))->s.param.sched.sync; + return handle_to_qentry(handle)->s.param.sched.sync; }
static odp_schedule_prio_t queue_sched_prio(odp_queue_t handle) { - return qentry_from_int(queue_from_ext(handle))->s.param.sched.prio; + return handle_to_qentry(handle)->s.param.sched.prio; }
static odp_schedule_group_t queue_sched_group(odp_queue_t handle) { - return qentry_from_int(queue_from_ext(handle))->s.param.sched.group; + return handle_to_qentry(handle)->s.param.sched.group; }
static int queue_lock_count(odp_queue_t handle) { - queue_entry_t *queue = qentry_from_int(queue_from_ext(handle)); + queue_entry_t *queue = handle_to_qentry(handle);
return queue->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED ? (int)queue->s.param.sched.lock_count : -1; @@ -299,7 +257,7 @@ void sched_cb_queue_destroy_finalize(uint32_t queue_index) static int queue_destroy(odp_queue_t handle) { queue_entry_t *queue; - queue = qentry_from_int(queue_from_ext(handle)); + queue = handle_to_qentry(handle);
if (handle == ODP_QUEUE_INVALID) return -1; @@ -352,14 +310,14 @@ static int queue_context_set(odp_queue_t handle, void *context, uint32_t len ODP_UNUSED) { odp_mb_full(); - qentry_from_int(queue_from_ext(handle))->s.param.context = context; + handle_to_qentry(handle)->s.param.context = context; odp_mb_full(); return 0; }
static void *queue_context(odp_queue_t handle) { - return qentry_from_int(queue_from_ext(handle))->s.param.context; + return handle_to_qentry(handle)->s.param.context; }
static odp_queue_t queue_lookup(const char *name) @@ -385,7 +343,7 @@ static odp_queue_t queue_lookup(const char *name) return ODP_QUEUE_INVALID; }
-static inline int enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], +static inline int enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { int sched = 0; @@ -393,8 +351,8 @@ static inline int enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], queue_entry_t *queue; odp_buffer_hdr_t *hdr, *tail, *next_hdr;
- queue = qentry_from_int(handle); - if (sched_fn->ord_enq_multi(handle, (void **)buf_hdr, num, &ret)) + queue = qentry_from_int(q_int); + if (sched_fn->ord_enq_multi(q_int, (void **)buf_hdr, num, &ret)) return ret;
/* Optimize the common case of single enqueue */ @@ -462,17 +420,17 @@ static inline int enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], return num; /* All events enqueued */ }
-static int _queue_enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num) +static int queue_int_enq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], + int num) { - return enq_multi(handle, buf_hdr, num); + return enq_multi(q_int, buf_hdr, num); }
-static int _queue_enq(queue_t handle, odp_buffer_hdr_t *buf_hdr) +static int queue_int_enq(queue_t q_int, odp_buffer_hdr_t *buf_hdr) { int ret;
- ret = enq_multi(handle, &buf_hdr, 1); + ret = enq_multi(q_int, &buf_hdr, 1);
if (ret == 1) return 0; @@ -489,7 +447,7 @@ static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) if (num > QUEUE_MULTI_MAX) num = QUEUE_MULTI_MAX;
- queue = qentry_from_int(queue_from_ext(handle)); + queue = handle_to_qentry(handle);
for (i = 0; i < num; i++) buf_hdr[i] = buf_hdl_to_hdr(odp_buffer_from_event(ev[i])); @@ -503,13 +461,13 @@ static int queue_enq(odp_queue_t handle, odp_event_t ev) odp_buffer_hdr_t *buf_hdr; queue_entry_t *queue;
- queue = qentry_from_int(queue_from_ext(handle)); + queue = handle_to_qentry(handle); buf_hdr = buf_hdl_to_hdr(odp_buffer_from_event(ev));
return queue->s.enqueue(qentry_to_int(queue), buf_hdr); }
-static inline int deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], +static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) { odp_buffer_hdr_t *hdr, *next; @@ -517,7 +475,7 @@ static inline int deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], queue_entry_t *queue; int updated = 0;
- queue = qentry_from_int(handle); + queue = qentry_from_int(q_int); LOCK(&queue->s.lock); if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { /* Bad queue, or queue has been destroyed. @@ -583,18 +541,18 @@ static inline int deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], return i; }
-static int _queue_deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num) +static int queue_int_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], + int num) { - return deq_multi(handle, buf_hdr, num); + return deq_multi(q_int, buf_hdr, num); }
-static odp_buffer_hdr_t *_queue_deq(queue_t handle) +static odp_buffer_hdr_t *queue_int_deq(queue_t q_int) { odp_buffer_hdr_t *buf_hdr = NULL; int ret;
- ret = deq_multi(handle, &buf_hdr, 1); + ret = deq_multi(q_int, &buf_hdr, 1);
if (ret == 1) return buf_hdr; @@ -611,7 +569,7 @@ static int queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num) if (num > QUEUE_MULTI_MAX) num = QUEUE_MULTI_MAX;
- queue = qentry_from_int(queue_from_ext(handle)); + queue = handle_to_qentry(handle);
ret = queue->s.dequeue_multi(qentry_to_int(queue), buf_hdr, num);
@@ -627,7 +585,7 @@ static odp_event_t queue_deq(odp_queue_t handle) queue_entry_t *queue; odp_buffer_hdr_t *buf_hdr;
- queue = qentry_from_int(queue_from_ext(handle)); + queue = handle_to_qentry(handle); buf_hdr = queue->s.dequeue(qentry_to_int(queue));
if (buf_hdr) @@ -636,6 +594,49 @@ static odp_event_t queue_deq(odp_queue_t handle) return ODP_EVENT_INVALID; }
+static int queue_init(queue_entry_t *queue, const char *name, + const odp_queue_param_t *param) +{ + if (name == NULL) { + queue->s.name[0] = 0; + } else { + strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1); + queue->s.name[ODP_QUEUE_NAME_LEN - 1] = 0; + } + memcpy(&queue->s.param, param, sizeof(odp_queue_param_t)); + if (queue->s.param.sched.lock_count > sched_fn->max_ordered_locks()) + return -1; + + if (param->type == ODP_QUEUE_TYPE_SCHED) { + queue->s.param.deq_mode = ODP_QUEUE_OP_DISABLED; + + if (param->sched.sync == ODP_SCHED_SYNC_ORDERED) { + unsigned i; + + odp_atomic_init_u64(&queue->s.ordered.ctx, 0); + odp_atomic_init_u64(&queue->s.ordered.next_ctx, 0); + + for (i = 0; i < queue->s.param.sched.lock_count; i++) + odp_atomic_init_u64(&queue->s.ordered.lock[i], + 0); + } + } + queue->s.type = queue->s.param.type; + + queue->s.enqueue = queue_int_enq; + queue->s.dequeue = queue_int_deq; + queue->s.enqueue_multi = queue_int_enq_multi; + queue->s.dequeue_multi = queue_int_deq_multi; + + queue->s.pktin = PKTIN_INVALID; + queue->s.pktout = PKTOUT_INVALID; + + queue->s.head = NULL; + queue->s.tail = NULL; + + return 0; +} + void queue_lock(queue_entry_t *queue) { LOCK(&queue->s.lock); @@ -776,64 +777,65 @@ static uint64_t queue_to_u64(odp_queue_t hdl) return _odp_pri(hdl); }
-static odp_pktout_queue_t queue_get_pktout(queue_t handle) +static odp_pktout_queue_t queue_get_pktout(queue_t q_int) { - return qentry_from_int(handle)->s.pktout; + return qentry_from_int(q_int)->s.pktout; }
-static void queue_set_pktout(queue_t handle, odp_pktio_t pktio, int index) +static void queue_set_pktout(queue_t q_int, odp_pktio_t pktio, int index) { - qentry_from_int(handle)->s.pktout.pktio = pktio; - qentry_from_int(handle)->s.pktout.index = index; + queue_entry_t *qentry = qentry_from_int(q_int); + + qentry->s.pktout.pktio = pktio; + qentry->s.pktout.index = index; }
-static odp_pktin_queue_t queue_get_pktin(queue_t handle) +static odp_pktin_queue_t queue_get_pktin(queue_t q_int) { - return qentry_from_int(handle)->s.pktin; + return qentry_from_int(q_int)->s.pktin; }
-static void queue_set_pktin(queue_t handle, odp_pktio_t pktio, int index) +static void queue_set_pktin(queue_t q_int, odp_pktio_t pktio, int index) { - qentry_from_int(handle)->s.pktin.pktio = pktio; - qentry_from_int(handle)->s.pktin.index = index; + queue_entry_t *qentry = qentry_from_int(q_int); + + qentry->s.pktin.pktio = pktio; + qentry->s.pktin.index = index; }
-static void queue_set_enq_func(queue_t handle, queue_enq_fn_t func) +static void queue_set_enq_func(queue_t q_int, queue_enq_fn_t func) { - qentry_from_int(handle)->s.enqueue = func; + qentry_from_int(q_int)->s.enqueue = func; }
-static void queue_set_enq_multi_func(queue_t handle, queue_enq_multi_fn_t func) +static void queue_set_enq_multi_func(queue_t q_int, queue_enq_multi_fn_t func) { - qentry_from_int(handle)->s.enqueue_multi = func; + qentry_from_int(q_int)->s.enqueue_multi = func; }
-static void queue_set_deq_func(queue_t handle, queue_deq_fn_t func) +static void queue_set_deq_func(queue_t q_int, queue_deq_fn_t func) { - qentry_from_int(handle)->s.dequeue = func; + qentry_from_int(q_int)->s.dequeue = func; }
-static void queue_set_deq_multi_func(queue_t handle, queue_deq_multi_fn_t func) +static void queue_set_deq_multi_func(queue_t q_int, queue_deq_multi_fn_t func) { - qentry_from_int(handle)->s.dequeue_multi = func; + qentry_from_int(q_int)->s.dequeue_multi = func; }
-static void queue_set_type(queue_t handle, odp_queue_type_t type) +static void queue_set_type(queue_t q_int, odp_queue_type_t type) { - qentry_from_int(handle)->s.type = type; + qentry_from_int(q_int)->s.type = type; }
static queue_t queue_from_ext(odp_queue_t handle) { - uint32_t queue_id; - - queue_id = queue_to_id(handle); - return qentry_to_int(get_qentry(queue_id)); + return qentry_to_int(handle_to_qentry(handle)); }
-static odp_queue_t queue_to_ext(queue_t handle) +static odp_queue_t queue_to_ext(queue_t q_int) { - return qentry_from_int(handle)->s.handle; + return qentry_from_int(q_int)->s.handle; }
/* API functions */ @@ -866,10 +868,10 @@ queue_fn_t queue_default_fn = { .term_local = queue_term_local, .from_ext = queue_from_ext, .to_ext = queue_to_ext, - .enq = _queue_enq, - .enq_multi = _queue_enq_multi, - .deq = _queue_deq, - .deq_multi = _queue_deq_multi, + .enq = queue_int_enq, + .enq_multi = queue_int_enq_multi, + .deq = queue_int_deq, + .deq_multi = queue_int_deq_multi, .get_pktout = queue_get_pktout, .set_pktout = queue_set_pktout, .get_pktin = queue_get_pktin, diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 011d4dc4..92634235 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -712,12 +712,12 @@ static inline int copy_events(odp_event_t out_ev[], unsigned int max) return i; }
-static int schedule_ord_enq_multi(queue_t handle, void *buf_hdr[], +static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = sched_local.ordered.stash_num; - queue_entry_t *dst_queue = qentry_from_int(handle); + queue_entry_t *dst_queue = qentry_from_int(q_int); queue_entry_t *src_queue = sched_local.ordered.src_queue;
if (!sched_local.ordered.src_queue || sched_local.ordered.in_order) diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index bdf1a460..79086843 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1159,12 +1159,12 @@ static inline void schedule_release_context(void) schedule_release_atomic(); }
-static int schedule_ord_enq_multi(queue_t handle, void *buf_hdr[], +static int schedule_ord_enq_multi(queue_t q_int, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = thread_local.ordered.stash_num; - queue_entry_t *dst_queue = qentry_from_int(handle); + queue_entry_t *dst_queue = qentry_from_int(q_int); queue_entry_t *src_queue = thread_local.ordered.src_queue;
if (!thread_local.ordered.src_queue || thread_local.ordered.in_order) diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 91d70e3a..66715c13 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -414,10 +414,10 @@ static int unsched_queue(uint32_t qi ODP_UNUSED) return 0; }
-static int ord_enq_multi(queue_t handle, void *buf_hdr[], int num, +static int ord_enq_multi(queue_t q_int, void *buf_hdr[], int num, int *ret) { - (void)handle; + (void)q_int; (void)buf_hdr; (void)num; (void)ret;
commit 200782c3da2104a020f278691b3b23b8d55893e0 Author: Honnappa Nagarahalli honnappa.nagarahalli@arm.com Date: Fri Jun 2 13:27:00 2017 -0500
linux-generic: queue: modular queue interface
Created abstract queue type. Queue APIs and functions towards the internal components are converted into function pointers.
Signed-off-by: Honnappa Nagarahalli honnappa.nagarahalli@arm.com
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 989a65b6..45dd0f4d 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -156,6 +156,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_posix_extensions.h \ ${srcdir}/include/odp_queue_internal.h \ ${srcdir}/include/odp_ring_internal.h \ + ${srcdir}/include/odp_queue_if.h \ ${srcdir}/include/odp_schedule_if.h \ ${srcdir}/include/odp_sorted_list_internal.h \ ${srcdir}/include/odp_shm_internal.h \ @@ -208,6 +209,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_pkt_queue.c \ odp_pool.c \ odp_queue.c \ + odp_queue_if.c \ odp_rwlock.c \ odp_rwlock_recursive.c \ odp_schedule.c \ diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h index 9df756bf..fbe10cb4 100644 --- a/platform/linux-generic/include/odp_classification_datamodel.h +++ b/platform/linux-generic/include/odp_classification_datamodel.h @@ -24,7 +24,7 @@ extern "C" { #include <odp_pool_internal.h> #include <odp_packet_internal.h> #include <odp_packet_io_internal.h> -#include <odp_queue_internal.h> +#include <odp_queue_if.h> #include <protocols/ip.h>
/* Maximum Class Of Service Entry */ @@ -85,7 +85,7 @@ typedef struct pmr_term_value { Class Of Service */ struct cos_s { - queue_entry_t *queue; /* Associated Queue */ + queue_t queue; /* Associated Queue */ odp_pool_t pool; /* Associated Buffer pool */ union pmr_u *pmr[ODP_PMR_PER_COS_MAX]; /* Chained PMR */ union cos_u *linked_cos[ODP_PMR_PER_COS_MAX]; /* Chained CoS with PMR*/ diff --git a/platform/linux-generic/include/odp_packet_io_queue.h b/platform/linux-generic/include/odp_packet_io_queue.h index d1d4b225..71333ddc 100644 --- a/platform/linux-generic/include/odp_packet_io_queue.h +++ b/platform/linux-generic/include/odp_packet_io_queue.h @@ -18,7 +18,7 @@ extern "C" { #endif
-#include <odp_queue_internal.h> +#include <odp_queue_if.h> #include <odp_buffer_internal.h> #include <odp_config_internal.h>
@@ -28,20 +28,18 @@ extern "C" { ODP_STATIC_ASSERT(ODP_PKTIN_QUEUE_MAX_BURST >= QUEUE_MULTI_MAX, "ODP_PKTIN_DEQ_MULTI_MAX_ERROR");
-int pktin_enqueue(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr); -odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *queue); +int pktin_enqueue(queue_t queue, odp_buffer_hdr_t *buf_hdr); +odp_buffer_hdr_t *pktin_dequeue(queue_t queue);
-int pktin_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num); -int pktin_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num); +int pktin_enq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); +int pktin_deq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num);
-int pktout_enqueue(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr); -odp_buffer_hdr_t *pktout_dequeue(queue_entry_t *queue); +int pktout_enqueue(queue_t queue, odp_buffer_hdr_t *buf_hdr); +odp_buffer_hdr_t *pktout_dequeue(queue_t queue);
-int pktout_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], - int num); -int pktout_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], - int num); +int pktout_enq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num); +int pktout_deq_multi(queue_t queue, odp_buffer_hdr_t *buf_hdr[], int num);
#ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h new file mode 100644 index 00000000..4359435f --- /dev/null +++ b/platform/linux-generic/include/odp_queue_if.h @@ -0,0 +1,104 @@ +/* Copyright (c) 2017, ARM Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_QUEUE_IF_H_ +#define ODP_QUEUE_IF_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/queue.h> +#include <odp/api/schedule.h> +#include <odp/api/packet_io.h> +#include <odp_forward_typedefs_internal.h> + +#define QUEUE_MULTI_MAX CONFIG_BURST_SIZE + +/* Queue API functions */ +typedef struct { + odp_queue_t (*queue_create)(const char *name, + const odp_queue_param_t *param); + int (*queue_destroy)(odp_queue_t queue); + odp_queue_t (*queue_lookup)(const char *name); + int (*queue_capability)(odp_queue_capability_t *capa); + int (*queue_context_set)(odp_queue_t queue, void *context, + uint32_t len); + void *(*queue_context)(odp_queue_t queue); + int (*queue_enq)(odp_queue_t queue, odp_event_t ev); + int (*queue_enq_multi)(odp_queue_t queue, const odp_event_t events[], + int num); + odp_event_t (*queue_deq)(odp_queue_t queue); + int (*queue_deq_multi)(odp_queue_t queue, odp_event_t events[], + int num); + odp_queue_type_t (*queue_type)(odp_queue_t queue); + odp_schedule_sync_t (*queue_sched_type)(odp_queue_t queue); + odp_schedule_prio_t (*queue_sched_prio)(odp_queue_t queue); + odp_schedule_group_t (*queue_sched_group)(odp_queue_t queue); + int (*queue_lock_count)(odp_queue_t queue); + uint64_t (*queue_to_u64)(odp_queue_t hdl); + void (*queue_param_init)(odp_queue_param_t *param); + int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info); +} queue_api_t; + +/* Internal abstract queue handle */ +typedef struct { char dummy; } _queue_t; +typedef _queue_t *queue_t; + +typedef int (*queue_init_global_fn_t)(void); +typedef int (*queue_term_global_fn_t)(void); +typedef int (*queue_init_local_fn_t)(void); +typedef int (*queue_term_local_fn_t)(void); +typedef queue_t (*queue_from_ext_fn_t)(odp_queue_t handle); +typedef odp_queue_t (*queue_to_ext_fn_t)(queue_t handle); +typedef int (*queue_enq_fn_t)(queue_t handle, odp_buffer_hdr_t *); +typedef int (*queue_enq_multi_fn_t)(queue_t handle, odp_buffer_hdr_t **, int); +typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(queue_t handle); +typedef int (*queue_deq_multi_fn_t)(queue_t handle, odp_buffer_hdr_t **, int); +typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(queue_t handle); +typedef void (*queue_set_pktout_fn_t)(queue_t handle, odp_pktio_t pktio, + int index); +typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t handle); +typedef void (*queue_set_pktin_fn_t)(queue_t handle, odp_pktio_t pktio, + int index); +typedef void (*queue_set_enq_fn_t)(queue_t handle, queue_enq_fn_t func); +typedef void (*queue_set_enq_multi_fn_t)(queue_t handle, + queue_enq_multi_fn_t func); +typedef void (*queue_set_deq_fn_t)(queue_t handle, queue_deq_fn_t func); +typedef void (*queue_set_deq_multi_fn_t)(queue_t handle, + queue_deq_multi_fn_t func); +typedef void (*queue_set_type_fn_t)(queue_t handle, odp_queue_type_t type); + +/* Queue functions towards other internal components */ +typedef struct { + queue_init_global_fn_t init_global; + queue_term_global_fn_t term_global; + queue_init_local_fn_t init_local; + queue_term_local_fn_t term_local; + queue_from_ext_fn_t from_ext; + queue_to_ext_fn_t to_ext; + queue_enq_fn_t enq; + queue_enq_multi_fn_t enq_multi; + queue_deq_fn_t deq; + queue_deq_multi_fn_t deq_multi; + queue_get_pktout_fn_t get_pktout; + queue_set_pktout_fn_t set_pktout; + queue_get_pktin_fn_t get_pktin; + queue_set_pktin_fn_t set_pktin; + queue_set_enq_fn_t set_enq_fn; + queue_set_enq_multi_fn_t set_enq_multi_fn; + queue_set_deq_fn_t set_deq_fn; + queue_set_deq_multi_fn_t set_deq_multi_fn; + queue_set_type_fn_t set_type; +} queue_fn_t; + +extern const queue_fn_t *queue_fn; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 560f826e..0c31ce8a 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -20,7 +20,7 @@ extern "C" {
#include <odp/api/queue.h> #include <odp_forward_typedefs_internal.h> -#include <odp_schedule_if.h> +#include <odp_queue_if.h> #include <odp_buffer_internal.h> #include <odp_align_internal.h> #include <odp/api/packet_io.h> @@ -29,26 +29,12 @@ extern "C" { #include <odp/api/ticketlock.h> #include <odp_config_internal.h>
-#define QUEUE_MULTI_MAX CONFIG_BURST_SIZE - #define QUEUE_STATUS_FREE 0 #define QUEUE_STATUS_DESTROYED 1 #define QUEUE_STATUS_READY 2 #define QUEUE_STATUS_NOTSCHED 3 #define QUEUE_STATUS_SCHED 4
- -/* forward declaration */ -union queue_entry_u; - -typedef int (*enq_func_t)(union queue_entry_u *, odp_buffer_hdr_t *); -typedef odp_buffer_hdr_t *(*deq_func_t)(union queue_entry_u *); - -typedef int (*enq_multi_func_t)(union queue_entry_u *, - odp_buffer_hdr_t **, int); -typedef int (*deq_multi_func_t)(union queue_entry_u *, - odp_buffer_hdr_t **, int); - struct queue_entry_s { odp_ticketlock_t lock ODP_ALIGNED_CACHE;
@@ -63,10 +49,10 @@ struct queue_entry_s { odp_atomic_u64_t lock[CONFIG_QUEUE_MAX_ORD_LOCKS]; } ordered ODP_ALIGNED_CACHE;
- enq_func_t enqueue ODP_ALIGNED_CACHE; - deq_func_t dequeue; - enq_multi_func_t enqueue_multi; - deq_multi_func_t dequeue_multi; + queue_enq_fn_t enqueue ODP_ALIGNED_CACHE; + queue_deq_fn_t dequeue; + queue_enq_multi_fn_t enqueue_multi; + queue_deq_multi_fn_t dequeue_multi;
uint32_t index; odp_queue_t handle; @@ -82,15 +68,8 @@ union queue_entry_u { uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct queue_entry_s))]; };
- queue_entry_t *get_qentry(uint32_t queue_id);
-int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr); -odp_buffer_hdr_t *queue_deq(queue_entry_t *queue); - -int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num); -int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num); - void queue_lock(queue_entry_t *queue); void queue_unlock(queue_entry_t *queue);
@@ -99,12 +78,14 @@ static inline uint32_t queue_to_id(odp_queue_t handle) return _odp_typeval(handle) - 1; }
-static inline queue_entry_t *queue_to_qentry(odp_queue_t handle) +static inline queue_entry_t *qentry_from_int(queue_t handle) { - uint32_t queue_id; + return (queue_entry_t *)(void *)(handle); +}
- queue_id = queue_to_id(handle); - return get_qentry(queue_id); +static inline queue_t qentry_to_int(queue_entry_t *qentry) +{ + return (queue_t)(qentry); }
#ifdef __cplusplus diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 530d157f..9adacef7 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -26,7 +26,7 @@ typedef int (*schedule_init_queue_fn_t)(uint32_t queue_index, typedef void (*schedule_destroy_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_sched_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_unsched_queue_fn_t)(uint32_t queue_index); -typedef int (*schedule_ord_enq_multi_fn_t)(uint32_t queue_index, +typedef int (*schedule_ord_enq_multi_fn_t)(queue_t handle, void *buf_hdr[], int num, int *ret); typedef int (*schedule_init_global_fn_t)(void); typedef int (*schedule_term_global_fn_t)(void); diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h b/platform/linux-generic/include/odp_traffic_mngr_internal.h index 9f821fe4..e8254f5e 100644 --- a/platform/linux-generic/include/odp_traffic_mngr_internal.h +++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h @@ -29,7 +29,7 @@ extern "C" { #include <odp_internal.h> #include <odp_debug_internal.h> #include <odp_buffer_internal.h> -#include <odp_queue_internal.h> +#include <odp_queue_if.h> #include <odp_packet_internal.h>
typedef struct stat file_stat_t; @@ -286,7 +286,7 @@ struct tm_queue_obj_s { uint8_t tm_idx; uint8_t delayed_cnt; uint8_t blocked_cnt; - queue_entry_t tm_qentry; + queue_t tm_qentry; };
struct tm_node_obj_s { diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 7ebc47d7..5f153e73 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -157,14 +157,14 @@ int odp_cls_capability(odp_cls_capability_t *capability) odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param) { int i, j; - queue_entry_t *queue; + queue_t queue; odp_cls_drop_t drop_policy;
/* Packets are dropped if Queue or Pool is invalid*/ if (param->queue == ODP_QUEUE_INVALID) queue = NULL; else - queue = queue_to_qentry(param->queue); + queue = queue_fn->from_ext(param->queue);
drop_policy = param->drop_policy;
@@ -266,7 +266,7 @@ int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id) if (queue_id == ODP_QUEUE_INVALID) cos->s.queue = NULL; else - cos->s.queue = queue_to_qentry(queue_id); + cos->s.queue = queue_fn->from_ext(queue_id); return 0; }
@@ -282,7 +282,7 @@ odp_queue_t odp_cos_queue(odp_cos_t cos_id) if (!cos->s.queue) return ODP_QUEUE_INVALID;
- return cos->s.queue->s.handle; + return queue_fn->to_ext(cos->s.queue); }
int odp_cos_drop_set(odp_cos_t cos_id, odp_cls_drop_t drop_policy) @@ -846,7 +846,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base,
*pool = cos->s.pool; pkt_hdr->p.input_flags.dst_queue = 1; - pkt_hdr->dst_queue = cos->s.queue->s.handle; + pkt_hdr->dst_queue = queue_fn->to_ext(cos->s.queue);
return 0; } diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index ab2d6fb0..35a285ea 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -83,7 +83,7 @@ int odp_init_global(odp_instance_t *instance, } stage = POOL_INIT;
- if (odp_queue_init_global()) { + if (queue_fn->init_global()) { ODP_ERR("ODP queue init failed.\n"); goto init_failed; } @@ -204,7 +204,7 @@ int _odp_term_global(enum init_stage stage) /* Fall through */
case QUEUE_INIT: - if (odp_queue_term_global()) { + if (queue_fn->term_global()) { ODP_ERR("ODP queue term failed.\n"); rc = -1; } @@ -299,6 +299,12 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) } stage = POOL_INIT;
+ if (queue_fn->init_local()) { + ODP_ERR("ODP queue local init failed.\n"); + goto init_fail; + } + stage = QUEUE_INIT; + if (sched_fn->init_local()) { ODP_ERR("ODP schedule local init failed.\n"); goto init_fail; @@ -332,6 +338,13 @@ int _odp_term_local(enum init_stage stage) } /* Fall through */
+ case QUEUE_INIT: + if (queue_fn->term_local()) { + ODP_ERR("ODP queue local term failed.\n"); + rc = -1; + } + /* Fall through */ + case POOL_INIT: if (odp_pool_term_local()) { ODP_ERR("ODP buffer pool local term failed.\n"); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index e5436a90..4dd28549 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -16,7 +16,7 @@ #include <odp/api/shared_memory.h> #include <odp_packet_socket.h> #include <odp_config_internal.h> -#include <odp_queue_internal.h> +#include <odp_queue_if.h> #include <odp_schedule_if.h> #include <odp_classification_internal.h> #include <odp_debug_internal.h> @@ -566,11 +566,11 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, buf_hdr = packet_to_buf_hdr(pkt);
if (pkt_hdr->p.input_flags.dst_queue) { - queue_entry_t *dst_queue; + queue_t dst_queue; int ret;
- dst_queue = queue_to_qentry(pkt_hdr->dst_queue); - ret = queue_enq(dst_queue, buf_hdr); + dst_queue = queue_fn->from_ext(pkt_hdr->dst_queue); + ret = queue_fn->enq(dst_queue, buf_hdr); if (ret < 0) odp_packet_free(pkt); continue; @@ -580,45 +580,42 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, return num_rx; }
-int pktout_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr) +int pktout_enqueue(queue_t qentry, odp_buffer_hdr_t *buf_hdr) { odp_packet_t pkt = packet_from_buf_hdr(buf_hdr); int len = 1; int nbr;
- if (sched_fn->ord_enq_multi(qentry->s.index, (void **)buf_hdr, len, - &nbr)) + if (sched_fn->ord_enq_multi(qentry, (void **)buf_hdr, len, &nbr)) return (nbr == len ? 0 : -1);
- nbr = odp_pktout_send(qentry->s.pktout, &pkt, len); + nbr = odp_pktout_send(queue_fn->get_pktout(qentry), &pkt, len); return (nbr == len ? 0 : -1); }
-odp_buffer_hdr_t *pktout_dequeue(queue_entry_t *qentry ODP_UNUSED) +odp_buffer_hdr_t *pktout_dequeue(queue_t qentry ODP_UNUSED) { ODP_ABORT("attempted dequeue from a pktout queue"); return NULL; }
-int pktout_enq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], - int num) +int pktout_enq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) { odp_packet_t pkt_tbl[QUEUE_MULTI_MAX]; int nbr; int i;
- if (sched_fn->ord_enq_multi(qentry->s.index, (void **)buf_hdr, num, - &nbr)) + if (sched_fn->ord_enq_multi(qentry, (void **)buf_hdr, num, &nbr)) return nbr;
for (i = 0; i < num; ++i) pkt_tbl[i] = packet_from_buf_hdr(buf_hdr[i]);
- nbr = odp_pktout_send(qentry->s.pktout, pkt_tbl, num); + nbr = odp_pktout_send(queue_fn->get_pktout(qentry), pkt_tbl, num); return nbr; }
-int pktout_deq_multi(queue_entry_t *qentry ODP_UNUSED, +int pktout_deq_multi(queue_t qentry ODP_UNUSED, odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, int num ODP_UNUSED) { @@ -626,48 +623,49 @@ int pktout_deq_multi(queue_entry_t *qentry ODP_UNUSED, return 0; }
-int pktin_enqueue(queue_entry_t *qentry ODP_UNUSED, +int pktin_enqueue(queue_t qentry ODP_UNUSED, odp_buffer_hdr_t *buf_hdr ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return -1; }
-odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry) +odp_buffer_hdr_t *pktin_dequeue(queue_t qentry) { odp_buffer_hdr_t *buf_hdr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts;
- buf_hdr = queue_deq(qentry); + buf_hdr = queue_fn->deq(qentry); if (buf_hdr != NULL) return buf_hdr;
- pkts = pktin_recv_buf(qentry->s.pktin, hdr_tbl, QUEUE_MULTI_MAX); + pkts = pktin_recv_buf(queue_fn->get_pktin(qentry), + hdr_tbl, QUEUE_MULTI_MAX);
if (pkts <= 0) return NULL;
if (pkts > 1) - queue_enq_multi(qentry, &hdr_tbl[1], pkts - 1); + queue_fn->enq_multi(qentry, &hdr_tbl[1], pkts - 1); buf_hdr = hdr_tbl[0]; return buf_hdr; }
-int pktin_enq_multi(queue_entry_t *qentry ODP_UNUSED, +int pktin_enq_multi(queue_t qentry ODP_UNUSED, odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, int num ODP_UNUSED) { ODP_ABORT("attempted enqueue to a pktin queue"); return 0; }
-int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) +int pktin_deq_multi(queue_t qentry, odp_buffer_hdr_t *buf_hdr[], int num) { int nbr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts, i, j;
- nbr = queue_deq_multi(qentry, buf_hdr, num); + nbr = queue_fn->deq_multi(qentry, buf_hdr, num); if (odp_unlikely(nbr > num)) ODP_ABORT("queue_deq_multi req: %d, returned %d\n", num, nbr);
@@ -677,7 +675,8 @@ int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) if (nbr == num) return nbr;
- pkts = pktin_recv_buf(qentry->s.pktin, hdr_tbl, QUEUE_MULTI_MAX); + pkts = pktin_recv_buf(queue_fn->get_pktin(qentry), + hdr_tbl, QUEUE_MULTI_MAX); if (pkts <= 0) return nbr;
@@ -689,7 +688,7 @@ int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) hdr_tbl[j] = hdr_tbl[i];
if (j) - queue_enq_multi(qentry, hdr_tbl, j); + queue_fn->enq_multi(qentry, hdr_tbl, j); return nbr; }
@@ -711,7 +710,7 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) }
for (idx = 0; idx < num_queue; idx++) { - queue_entry_t *qentry; + queue_t qentry; odp_queue_t queue; odp_pktin_queue_t pktin = entry->s.in_queue[index[idx]].pktin;
@@ -726,8 +725,8 @@ int sched_cb_pktin_poll(int pktio_index, int num_queue, int index[]) }
queue = entry->s.in_queue[index[idx]].queue; - qentry = queue_to_qentry(queue); - queue_enq_multi(qentry, hdr_tbl, num); + qentry = queue_fn->from_ext(queue); + queue_fn->enq_multi(qentry, hdr_tbl, num); }
return 0; @@ -1271,16 +1270,16 @@ int odp_pktin_queue_config(odp_pktio_t pktio, }
if (mode == ODP_PKTIN_MODE_QUEUE) { - queue_entry_t *qentry; - - qentry = queue_to_qentry(queue); - qentry->s.pktin.index = i; - qentry->s.pktin.pktio = pktio; - - qentry->s.enqueue = pktin_enqueue; - qentry->s.dequeue = pktin_dequeue; - qentry->s.enqueue_multi = pktin_enq_multi; - qentry->s.dequeue_multi = pktin_deq_multi; + queue_t qentry; + + qentry = queue_fn->from_ext(queue); + queue_fn->set_pktin(qentry, pktio, i); + queue_fn->set_enq_fn(qentry, pktin_enqueue); + queue_fn->set_deq_fn(qentry, pktin_dequeue); + queue_fn->set_enq_multi_fn(qentry, + pktin_enq_multi); + queue_fn->set_deq_multi_fn(qentry, + pktin_deq_multi); }
entry->s.in_queue[i].queue = queue; @@ -1377,7 +1376,7 @@ int odp_pktout_queue_config(odp_pktio_t pktio, for (i = 0; i < num_queues; i++) { odp_queue_t queue; odp_queue_param_t queue_param; - queue_entry_t *qentry; + queue_t qentry; char name[ODP_QUEUE_NAME_LEN]; int pktio_id = pktio_to_id(pktio);
@@ -1397,15 +1396,14 @@ int odp_pktout_queue_config(odp_pktio_t pktio, return -1; }
- qentry = queue_to_qentry(queue); - qentry->s.pktout.index = i; - qentry->s.pktout.pktio = pktio; + qentry = queue_fn->from_ext(queue); + queue_fn->set_pktout(qentry, pktio, i);
/* Override default enqueue / dequeue functions */ - qentry->s.enqueue = pktout_enqueue; - qentry->s.dequeue = pktout_dequeue; - qentry->s.enqueue_multi = pktout_enq_multi; - qentry->s.dequeue_multi = pktout_deq_multi; + queue_fn->set_enq_fn(qentry, pktout_enqueue); + queue_fn->set_deq_fn(qentry, pktout_dequeue); + queue_fn->set_enq_multi_fn(qentry, pktout_enq_multi); + queue_fn->set_deq_multi_fn(qentry, pktout_deq_multi);
entry->s.out_queue[i].queue = queue; } diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index dd430cd1..3e18f578 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -6,6 +6,7 @@
#include <odp/api/queue.h> #include <odp_queue_internal.h> +#include <odp_queue_if.h> #include <odp/api/std_types.h> #include <odp/api/align.h> #include <odp/api/buffer.h> @@ -40,6 +41,15 @@ typedef struct queue_table_t {
static queue_table_t *queue_tbl;
+static queue_t queue_from_ext(odp_queue_t handle); +static int _queue_enq(queue_t handle, odp_buffer_hdr_t *buf_hdr); +static odp_buffer_hdr_t *_queue_deq(queue_t handle); + +static int _queue_enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], + int num); +static int _queue_deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], + int num); + static inline odp_queue_t queue_from_id(uint32_t queue_id) { return _odp_cast_scalar(odp_queue_t, queue_id + 1); @@ -89,10 +99,10 @@ static int queue_init(queue_entry_t *queue, const char *name, } queue->s.type = queue->s.param.type;
- queue->s.enqueue = queue_enq; - queue->s.dequeue = queue_deq; - queue->s.enqueue_multi = queue_enq_multi; - queue->s.dequeue_multi = queue_deq_multi; + queue->s.enqueue = _queue_enq; + queue->s.dequeue = _queue_deq; + queue->s.enqueue_multi = _queue_enq_multi; + queue->s.dequeue_multi = _queue_deq_multi;
queue->s.pktin = PKTIN_INVALID; queue->s.pktout = PKTOUT_INVALID; @@ -104,7 +114,7 @@ static int queue_init(queue_entry_t *queue, const char *name, }
-int odp_queue_init_global(void) +static int queue_init_global(void) { uint32_t i; odp_shm_t shm; @@ -141,7 +151,17 @@ int odp_queue_init_global(void) return 0; }
-int odp_queue_term_global(void) +static int queue_init_local(void) +{ + return 0; +} + +static int queue_term_local(void) +{ + return 0; +} + +static int queue_term_global(void) { int ret = 0; int rc = 0; @@ -167,7 +187,7 @@ int odp_queue_term_global(void) return rc; }
-int odp_queue_capability(odp_queue_capability_t *capa) +static int queue_capability(odp_queue_capability_t *capa) { memset(capa, 0, sizeof(odp_queue_capability_t));
@@ -182,51 +202,36 @@ int odp_queue_capability(odp_queue_capability_t *capa) return 0; }
-odp_queue_type_t odp_queue_type(odp_queue_t handle) +static odp_queue_type_t queue_type(odp_queue_t handle) { - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.type; + return qentry_from_int(queue_from_ext(handle))->s.type; }
-odp_schedule_sync_t odp_queue_sched_type(odp_queue_t handle) +static odp_schedule_sync_t queue_sched_type(odp_queue_t handle) { - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.param.sched.sync; + return qentry_from_int(queue_from_ext(handle))->s.param.sched.sync; }
-odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t handle) +static odp_schedule_prio_t queue_sched_prio(odp_queue_t handle) { - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.param.sched.prio; + return qentry_from_int(queue_from_ext(handle))->s.param.sched.prio; }
-odp_schedule_group_t odp_queue_sched_group(odp_queue_t handle) +static odp_schedule_group_t queue_sched_group(odp_queue_t handle) { - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.param.sched.group; + return qentry_from_int(queue_from_ext(handle))->s.param.sched.group; }
-int odp_queue_lock_count(odp_queue_t handle) +static int queue_lock_count(odp_queue_t handle) { - queue_entry_t *queue = queue_to_qentry(handle); + queue_entry_t *queue = qentry_from_int(queue_from_ext(handle));
return queue->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED ? (int)queue->s.param.sched.lock_count : -1; }
-odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param) +static odp_queue_t queue_create(const char *name, + const odp_queue_param_t *param) { uint32_t i; queue_entry_t *queue; @@ -291,10 +296,10 @@ void sched_cb_queue_destroy_finalize(uint32_t queue_index) UNLOCK(&queue->s.lock); }
-int odp_queue_destroy(odp_queue_t handle) +static int queue_destroy(odp_queue_t handle) { queue_entry_t *queue; - queue = queue_to_qentry(handle); + queue = qentry_from_int(queue_from_ext(handle));
if (handle == ODP_QUEUE_INVALID) return -1; @@ -343,25 +348,21 @@ int odp_queue_destroy(odp_queue_t handle) return 0; }
-int odp_queue_context_set(odp_queue_t handle, void *context, - uint32_t len ODP_UNUSED) +static int queue_context_set(odp_queue_t handle, void *context, + uint32_t len ODP_UNUSED) { - queue_entry_t *queue; - queue = queue_to_qentry(handle); odp_mb_full(); - queue->s.param.context = context; + qentry_from_int(queue_from_ext(handle))->s.param.context = context; odp_mb_full(); return 0; }
-void *odp_queue_context(odp_queue_t handle) +static void *queue_context(odp_queue_t handle) { - queue_entry_t *queue; - queue = queue_to_qentry(handle); - return queue->s.param.context; + return qentry_from_int(queue_from_ext(handle))->s.param.context; }
-odp_queue_t odp_queue_lookup(const char *name) +static odp_queue_t queue_lookup(const char *name) { uint32_t i;
@@ -384,15 +385,16 @@ odp_queue_t odp_queue_lookup(const char *name) return ODP_QUEUE_INVALID; }
-static inline int enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], +static inline int enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { int sched = 0; int i, ret; + queue_entry_t *queue; odp_buffer_hdr_t *hdr, *tail, *next_hdr;
- if (sched_fn->ord_enq_multi(queue->s.index, (void **)buf_hdr, num, - &ret)) + queue = qentry_from_int(handle); + if (sched_fn->ord_enq_multi(handle, (void **)buf_hdr, num, &ret)) return ret;
/* Optimize the common case of single enqueue */ @@ -460,16 +462,17 @@ static inline int enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], return num; /* All events enqueued */ }
-int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) +static int _queue_enq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], + int num) { - return enq_multi(queue, buf_hdr, num); + return enq_multi(handle, buf_hdr, num); }
-int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) +static int _queue_enq(queue_t handle, odp_buffer_hdr_t *buf_hdr) { int ret;
- ret = enq_multi(queue, &buf_hdr, 1); + ret = enq_multi(handle, &buf_hdr, 1);
if (ret == 1) return 0; @@ -477,7 +480,7 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) return -1; }
-int odp_queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) +static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; queue_entry_t *queue; @@ -486,33 +489,35 @@ int odp_queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) if (num > QUEUE_MULTI_MAX) num = QUEUE_MULTI_MAX;
- queue = queue_to_qentry(handle); + queue = qentry_from_int(queue_from_ext(handle));
for (i = 0; i < num; i++) buf_hdr[i] = buf_hdl_to_hdr(odp_buffer_from_event(ev[i]));
- return num == 0 ? 0 : queue->s.enqueue_multi(queue, buf_hdr, - num); + return num == 0 ? 0 : queue->s.enqueue_multi(qentry_to_int(queue), + buf_hdr, num); }
-int odp_queue_enq(odp_queue_t handle, odp_event_t ev) +static int queue_enq(odp_queue_t handle, odp_event_t ev) { odp_buffer_hdr_t *buf_hdr; queue_entry_t *queue;
- queue = queue_to_qentry(handle); + queue = qentry_from_int(queue_from_ext(handle)); buf_hdr = buf_hdl_to_hdr(odp_buffer_from_event(ev));
- return queue->s.enqueue(queue, buf_hdr); + return queue->s.enqueue(qentry_to_int(queue), buf_hdr); }
-static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], +static inline int deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { odp_buffer_hdr_t *hdr, *next; int i, j; + queue_entry_t *queue; int updated = 0;
+ queue = qentry_from_int(handle); LOCK(&queue->s.lock); if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { /* Bad queue, or queue has been destroyed. @@ -578,17 +583,18 @@ static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], return i; }
-int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) +static int _queue_deq_multi(queue_t handle, odp_buffer_hdr_t *buf_hdr[], + int num) { - return deq_multi(queue, buf_hdr, num); + return deq_multi(handle, buf_hdr, num); }
-odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) +static odp_buffer_hdr_t *_queue_deq(queue_t handle) { odp_buffer_hdr_t *buf_hdr = NULL; int ret;
- ret = deq_multi(queue, &buf_hdr, 1); + ret = deq_multi(handle, &buf_hdr, 1);
if (ret == 1) return buf_hdr; @@ -596,7 +602,7 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) return NULL; }
-int odp_queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num) +static int queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num) { queue_entry_t *queue; odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; @@ -605,9 +611,9 @@ int odp_queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num) if (num > QUEUE_MULTI_MAX) num = QUEUE_MULTI_MAX;
- queue = queue_to_qentry(handle); + queue = qentry_from_int(queue_from_ext(handle));
- ret = queue->s.dequeue_multi(queue, buf_hdr, num); + ret = queue->s.dequeue_multi(qentry_to_int(queue), buf_hdr, num);
for (i = 0; i < ret; i++) events[i] = odp_buffer_to_event(buf_hdr[i]->handle.handle); @@ -616,13 +622,13 @@ int odp_queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num) }
-odp_event_t odp_queue_deq(odp_queue_t handle) +static odp_event_t queue_deq(odp_queue_t handle) { queue_entry_t *queue; odp_buffer_hdr_t *buf_hdr;
- queue = queue_to_qentry(handle); - buf_hdr = queue->s.dequeue(queue); + queue = qentry_from_int(queue_from_ext(handle)); + buf_hdr = queue->s.dequeue(qentry_to_int(queue));
if (buf_hdr) return odp_buffer_to_event(buf_hdr->handle.handle); @@ -640,7 +646,7 @@ void queue_unlock(queue_entry_t *queue) UNLOCK(&queue->s.lock); }
-void odp_queue_param_init(odp_queue_param_t *params) +static void queue_param_init(odp_queue_param_t *params) { memset(params, 0, sizeof(odp_queue_param_t)); params->type = ODP_QUEUE_TYPE_PLAIN; @@ -651,7 +657,7 @@ void odp_queue_param_init(odp_queue_param_t *params) params->sched.group = ODP_SCHED_GROUP_ALL; }
-int odp_queue_info(odp_queue_t handle, odp_queue_info_t *info) +static int queue_info(odp_queue_t handle, odp_queue_info_t *info) { uint32_t queue_id; queue_entry_t *queue; @@ -730,7 +736,7 @@ int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num) queue_entry_t *qe = get_qentry(queue_index); odp_buffer_hdr_t *buf_hdr[num];
- ret = deq_multi(qe, buf_hdr, num); + ret = deq_multi(qentry_to_int(qe), buf_hdr, num);
if (ret > 0) for (i = 0; i < ret; i++) @@ -765,7 +771,112 @@ int sched_cb_queue_empty(uint32_t queue_index) return ret; }
-uint64_t odp_queue_to_u64(odp_queue_t hdl) +static uint64_t queue_to_u64(odp_queue_t hdl) { return _odp_pri(hdl); } + +static odp_pktout_queue_t queue_get_pktout(queue_t handle) +{ + return qentry_from_int(handle)->s.pktout; +} + +static void queue_set_pktout(queue_t handle, odp_pktio_t pktio, int index) +{ + qentry_from_int(handle)->s.pktout.pktio = pktio; + qentry_from_int(handle)->s.pktout.index = index; +} + +static odp_pktin_queue_t queue_get_pktin(queue_t handle) +{ + return qentry_from_int(handle)->s.pktin; +} + +static void queue_set_pktin(queue_t handle, odp_pktio_t pktio, int index) +{ + qentry_from_int(handle)->s.pktin.pktio = pktio; + qentry_from_int(handle)->s.pktin.index = index; +} + +static void queue_set_enq_func(queue_t handle, queue_enq_fn_t func) +{ + qentry_from_int(handle)->s.enqueue = func; +} + +static void queue_set_enq_multi_func(queue_t handle, queue_enq_multi_fn_t func) +{ + qentry_from_int(handle)->s.enqueue_multi = func; +} + +static void queue_set_deq_func(queue_t handle, queue_deq_fn_t func) +{ + qentry_from_int(handle)->s.dequeue = func; +} + +static void queue_set_deq_multi_func(queue_t handle, queue_deq_multi_fn_t func) +{ + qentry_from_int(handle)->s.dequeue_multi = func; +} + +static void queue_set_type(queue_t handle, odp_queue_type_t type) +{ + qentry_from_int(handle)->s.type = type; +} + +static queue_t queue_from_ext(odp_queue_t handle) +{ + uint32_t queue_id; + + queue_id = queue_to_id(handle); + return qentry_to_int(get_qentry(queue_id)); +} + +static odp_queue_t queue_to_ext(queue_t handle) +{ + return qentry_from_int(handle)->s.handle; +} + +/* API functions */ +queue_api_t queue_default_api = { + .queue_create = queue_create, + .queue_destroy = queue_destroy, + .queue_lookup = queue_lookup, + .queue_capability = queue_capability, + .queue_context_set = queue_context_set, + .queue_context = queue_context, + .queue_enq = queue_enq, + .queue_enq_multi = queue_enq_multi, + .queue_deq = queue_deq, + .queue_deq_multi = queue_deq_multi, + .queue_type = queue_type, + .queue_sched_type = queue_sched_type, + .queue_sched_prio = queue_sched_prio, + .queue_sched_group = queue_sched_group, + .queue_lock_count = queue_lock_count, + .queue_to_u64 = queue_to_u64, + .queue_param_init = queue_param_init, + .queue_info = queue_info +}; + +/* Functions towards internal components */ +queue_fn_t queue_default_fn = { + .init_global = queue_init_global, + .term_global = queue_term_global, + .init_local = queue_init_local, + .term_local = queue_term_local, + .from_ext = queue_from_ext, + .to_ext = queue_to_ext, + .enq = _queue_enq, + .enq_multi = _queue_enq_multi, + .deq = _queue_deq, + .deq_multi = _queue_deq_multi, + .get_pktout = queue_get_pktout, + .set_pktout = queue_set_pktout, + .get_pktin = queue_get_pktin, + .set_pktin = queue_set_pktin, + .set_enq_fn = queue_set_enq_func, + .set_enq_multi_fn = queue_set_enq_multi_func, + .set_deq_fn = queue_set_deq_func, + .set_deq_multi_fn = queue_set_deq_multi_func, + .set_type = queue_set_type +}; diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c new file mode 100644 index 00000000..c91f00eb --- /dev/null +++ b/platform/linux-generic/odp_queue_if.c @@ -0,0 +1,103 @@ +/* Copyright (c) 2017, ARM Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <odp_queue_if.h> + +extern const queue_api_t queue_default_api; +extern const queue_fn_t queue_default_fn; + +const queue_api_t *queue_api = &queue_default_api; +const queue_fn_t *queue_fn = &queue_default_fn; + +odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param) +{ + return queue_api->queue_create(name, param); +} + +int odp_queue_destroy(odp_queue_t queue) +{ + return queue_api->queue_destroy(queue); +} + +odp_queue_t odp_queue_lookup(const char *name) +{ + return queue_api->queue_lookup(name); +} + +int odp_queue_capability(odp_queue_capability_t *capa) +{ + return queue_api->queue_capability(capa); +} + +int odp_queue_context_set(odp_queue_t queue, void *context, uint32_t len) +{ + return queue_api->queue_context_set(queue, context, len); +} + +void *odp_queue_context(odp_queue_t queue) +{ + return queue_api->queue_context(queue); +} + +int odp_queue_enq(odp_queue_t queue, odp_event_t ev) +{ + return queue_api->queue_enq(queue, ev); +} + +int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[], int num) +{ + return queue_api->queue_enq_multi(queue, events, num); +} + +odp_event_t odp_queue_deq(odp_queue_t queue) +{ + return queue_api->queue_deq(queue); +} + +int odp_queue_deq_multi(odp_queue_t queue, odp_event_t events[], int num) +{ + return queue_api->queue_deq_multi(queue, events, num); +} + +odp_queue_type_t odp_queue_type(odp_queue_t queue) +{ + return queue_api->queue_type(queue); +} + +odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue) +{ + return queue_api->queue_sched_type(queue); +} + +odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue) +{ + return queue_api->queue_sched_prio(queue); +} + +odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue) +{ + return queue_api->queue_sched_group(queue); +} + +int odp_queue_lock_count(odp_queue_t queue) +{ + return queue_api->queue_lock_count(queue); +} + +uint64_t odp_queue_to_u64(odp_queue_t hdl) +{ + return queue_api->queue_to_u64(hdl); +} + +void odp_queue_param_init(odp_queue_param_t *param) +{ + return queue_api->queue_param_init(param); +} + +int odp_queue_info(odp_queue_t queue, odp_queue_info_t *info) +{ + return queue_api->queue_info(queue, info); +} diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index c4567d81..011d4dc4 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -646,7 +646,7 @@ static inline void ordered_stash_release(void) buf_hdr = sched_local.ordered.stash[i].buf_hdr; num = sched_local.ordered.stash[i].num;
- queue_enq_multi(queue, buf_hdr, num); + queue_fn->enq_multi(qentry_to_int(queue), buf_hdr, num); } sched_local.ordered.stash_num = 0; } @@ -712,12 +712,12 @@ static inline int copy_events(odp_event_t out_ev[], unsigned int max) return i; }
-static int schedule_ord_enq_multi(uint32_t queue_index, void *buf_hdr[], +static int schedule_ord_enq_multi(queue_t handle, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = sched_local.ordered.stash_num; - queue_entry_t *dst_queue = get_qentry(queue_index); + queue_entry_t *dst_queue = qentry_from_int(handle); queue_entry_t *src_queue = sched_local.ordered.src_queue;
if (!sched_local.ordered.src_queue || sched_local.ordered.in_order) diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 75470aff..bdf1a460 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1108,7 +1108,7 @@ static inline void ordered_stash_release(void) buf_hdr = thread_local.ordered.stash[i].buf_hdr; num = thread_local.ordered.stash[i].num;
- queue_enq_multi(queue, buf_hdr, num); + queue_fn->enq_multi(qentry_to_int(queue), buf_hdr, num); } thread_local.ordered.stash_num = 0; } @@ -1159,12 +1159,12 @@ static inline void schedule_release_context(void) schedule_release_atomic(); }
-static int schedule_ord_enq_multi(uint32_t queue_index, void *buf_hdr[], +static int schedule_ord_enq_multi(queue_t handle, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = thread_local.ordered.stash_num; - queue_entry_t *dst_queue = get_qentry(queue_index); + queue_entry_t *dst_queue = qentry_from_int(handle); queue_entry_t *src_queue = thread_local.ordered.src_queue;
if (!thread_local.ordered.src_queue || thread_local.ordered.in_order) diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 0fd4d87d..91d70e3a 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -414,10 +414,10 @@ static int unsched_queue(uint32_t qi ODP_UNUSED) return 0; }
-static int ord_enq_multi(uint32_t queue_index, void *buf_hdr[], int num, +static int ord_enq_multi(queue_t handle, void *buf_hdr[], int num, int *ret) { - (void)queue_index; + (void)handle; (void)buf_hdr; (void)num; (void)ret; diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index a93b3ba9..8b5f3187 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -102,7 +102,7 @@ static odp_bool_t tm_demote_pkt_desc(tm_system_t *tm_system, tm_shaper_obj_t *timer_shaper, pkt_desc_t *demoted_pkt_desc);
-static int queue_tm_reenq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) +static int queue_tm_reenq(queue_t queue, odp_buffer_hdr_t *buf_hdr) { odp_tm_queue_t tm_queue = MAKE_ODP_TM_QUEUE((uint8_t *)queue - offsetof(tm_queue_obj_t, @@ -112,7 +112,7 @@ static int queue_tm_reenq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) return odp_tm_enq(tm_queue, pkt); }
-static int queue_tm_reenq_multi(queue_entry_t *queue ODP_UNUSED, +static int queue_tm_reenq_multi(queue_t queue ODP_UNUSED, odp_buffer_hdr_t *buf[] ODP_UNUSED, int num ODP_UNUSED) { @@ -3882,6 +3882,7 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm, tm_queue_obj_t *tm_queue_obj; tm_wred_node_t *tm_wred_node; odp_tm_queue_t odp_tm_queue; + odp_queue_t queue; odp_tm_wred_t wred_profile; tm_system_t *tm_system; uint32_t color; @@ -3918,9 +3919,17 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm, tm_queue_obj->pkt = ODP_PACKET_INVALID; odp_ticketlock_init(&tm_wred_node->tm_wred_node_lock);
- tm_queue_obj->tm_qentry.s.type = QUEUE_TYPE_TM; - tm_queue_obj->tm_qentry.s.enqueue = queue_tm_reenq; - tm_queue_obj->tm_qentry.s.enqueue_multi = queue_tm_reenq_multi; + queue = odp_queue_create(NULL, NULL); + if (queue == ODP_QUEUE_INVALID) { + free(tm_wred_node); + free(tm_queue_obj); + return ODP_TM_INVALID; + } + tm_queue_obj->tm_qentry = queue_fn->from_ext(queue); + queue_fn->set_type(tm_queue_obj->tm_qentry, QUEUE_TYPE_TM); + queue_fn->set_enq_fn(tm_queue_obj->tm_qentry, queue_tm_reenq); + queue_fn->set_enq_multi_fn(tm_queue_obj->tm_qentry, + queue_tm_reenq_multi);
tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = tm_queue_obj; odp_ticketlock_lock(&tm_system->tm_system_lock); @@ -3992,6 +4001,8 @@ int odp_tm_queue_destroy(odp_tm_queue_t tm_queue) odp_ticketlock_lock(&tm_system->tm_system_lock); tm_system->queue_num_tbl[tm_queue_obj->queue_num - 1] = NULL;
+ odp_queue_destroy(queue_fn->to_ext(tm_queue_obj->tm_qentry)); + /* First delete any associated tm_wred_node and then the tm_queue_obj * itself */ free(tm_queue_obj->tm_wred_node); diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index cc636eba..c825393a 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -11,6 +11,7 @@ #include <odp_classification_internal.h> #include <odp_debug_internal.h> #include <odp/api/hints.h> +#include <odp_queue_if.h>
#include <protocols/eth.h> #include <protocols/ip.h> @@ -55,7 +56,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, { int nbr, i; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; - queue_entry_t *qentry; + queue_t queue; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; odp_packet_t pkt; @@ -69,8 +70,8 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.rxl);
- qentry = queue_to_qentry(pktio_entry->s.pkt_loop.loopq); - nbr = queue_deq_multi(qentry, hdr_tbl, len); + queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq); + nbr = queue_fn->deq_multi(queue, hdr_tbl, len);
if (pktio_entry->s.config.pktin.bit.ts_all || pktio_entry->s.config.pktin.bit.ts_ptp) { @@ -154,7 +155,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_tbl[], int len) { odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; - queue_entry_t *qentry; + queue_t queue; int i; int ret; uint32_t bytes = 0; @@ -169,8 +170,8 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.txl);
- qentry = queue_to_qentry(pktio_entry->s.pkt_loop.loopq); - ret = queue_enq_multi(qentry, hdr_tbl, len); + queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq); + ret = queue_fn->enq_multi(queue, hdr_tbl, len);
if (ret > 0) { pktio_entry->s.stats.out_ucast_pkts += ret;
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/Makefile.am | 3 +- .../include/odp_classification_datamodel.h | 4 +- .../linux-generic/include/odp_config_internal.h | 2 +- .../linux-generic/include/odp_packet_internal.h | 3 +- .../linux-generic/include/odp_packet_io_internal.h | 2 + .../linux-generic/include/odp_packet_io_queue.h | 50 --- platform/linux-generic/include/odp_queue_if.h | 100 ++++++ .../linux-generic/include/odp_queue_internal.h | 48 +-- platform/linux-generic/include/odp_schedule_if.h | 15 +- .../include/odp_traffic_mngr_internal.h | 4 +- platform/linux-generic/odp_classification.c | 18 +- platform/linux-generic/odp_init.c | 17 +- platform/linux-generic/odp_packet_io.c | 145 ++++---- platform/linux-generic/odp_queue.c | 376 ++++++++++++--------- platform/linux-generic/odp_queue_if.c | 103 ++++++ platform/linux-generic/odp_schedule.c | 164 +++++---- platform/linux-generic/odp_schedule_iquery.c | 162 +++++---- platform/linux-generic/odp_schedule_sp.c | 22 +- platform/linux-generic/odp_traffic_mngr.c | 23 +- platform/linux-generic/pktio/loop.c | 13 +- 20 files changed, 766 insertions(+), 508 deletions(-) delete mode 100644 platform/linux-generic/include/odp_packet_io_queue.h create mode 100644 platform/linux-generic/include/odp_queue_if.h create mode 100644 platform/linux-generic/odp_queue_if.c
hooks/post-receive