From patchwork Fri Aug 17 13:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144480 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp745086ljj; Fri, 17 Aug 2018 06:00:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwK9TrkXw6SdwUlPjalWG98suCkzIITtlWHWpiey1hgHop1syplymMMJ5w7cOr/xpC/HYmh X-Received: by 2002:a0c:adf8:: with SMTP id x53-v6mr31091851qvc.19.1534510834434; Fri, 17 Aug 2018 06:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534510834; cv=none; d=google.com; s=arc-20160816; b=gqP3EBYYv+fK9lXcbbm363AqRjQbd1q7CH4/jrtJtTLxz3DTgz8H9AnOQ3nP75/0SS YzDs76VL0I1ARFMziRvQF8ydQOzkCxNeRdRWYs2rIYWynRTXxVnD9rfULc3q0tgzIUQ9 bBBU2Ys+Xn5ZbxBv7HEf4n5YAaeGBrITLfac7vnqhSbXDNGgPGjHDb4fQBbs0rh/ax70 6dONCqqnMI5COjfsbicO1tfgRx0PadWzhMQV+V2m4TOCd/2V94t4lQQThwq64jy00Htr Wguj8Qc+yD8dRT53rztcbkPXB0iNEff7b5mduqqvTUfEbqel5gNKNuMmRiTtOocd+ijE Pjog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=J22t+IcDa5r3Y1Eg5AESL1iHsXfFQ8pvUS3WQi5AAPU=; b=YqVdVNuVDz3UwEh5JyopWsUnzQ7f7gPl7vFUDiy7jGTqJLN3/FpXXxi0UcVDKBIfXW lTPuinxUQe0Roxf4KC+6WZSV9i+yr9oXK+AtGuu8g/zJBrbzbuqtltWX1VK0D4iG1SEf ZgV+s0Dn0r3xPgYcvQV/iWTiMylRGPWGEcIOOlEShxXyMEhDbF10WdDiPiBWRzXOMBpU 2vnlxuvyuKQKtKS0W0Xn02R4ifqQHc0B4SY/YarXJDz8DxkLswtXDWS/ISuzlRImJ3OG JgGQxpmTJm/D8cxhIjEcPC5pq94E2w5Y7ibSd2jMagUzx1V/3oR+vhEQ1ZA6XjVEvANu dkaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id f7-v6si1926044qvl.25.2018.08.17.06.00.33; Fri, 17 Aug 2018 06:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4E3496782D; Fri, 17 Aug 2018 13:00:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 80D4A609AA; Fri, 17 Aug 2018 13:00:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3647661730; Fri, 17 Aug 2018 13:00:15 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 83AAB609AA for ; Fri, 17 Aug 2018 13:00:11 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 096BD181BFD for ; Fri, 17 Aug 2018 16:00:10 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 6MNz0G98iI-0918lPfn; Fri, 17 Aug 2018 16:00:09 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-08qGgZMX; Fri, 17 Aug 2018 16:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:02 +0000 Message-Id: <1534510807-11066-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 1/6] api: queue: split queue spec header file X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Split typedefs into a separate header file, so that queue functions can be inlined. API content was not changed, only moved it. Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ include/Makefile.am | 1 + include/odp/api/spec/queue.h | 277 +------------------------ include/odp/api/spec/queue_types.h | 311 +++++++++++++++++++++++++++++ 3 files changed, 313 insertions(+), 276 deletions(-) create mode 100644 include/odp/api/spec/queue_types.h diff --git a/include/Makefile.am b/include/Makefile.am index 512002f87..97f528408 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -82,6 +82,7 @@ odpapispecinclude_HEADERS = \ odp/api/spec/packet_io_stats.h \ odp/api/spec/pool.h \ odp/api/spec/queue.h \ + odp/api/spec/queue_types.h \ odp/api/spec/random.h \ odp/api/spec/rwlock.h \ odp/api/spec/rwlock_recursive.h \ diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h index 3015d7799..2f5e1230f 100644 --- a/include/odp/api/spec/queue.h +++ b/include/odp/api/spec/queue.h @@ -19,8 +19,8 @@ extern "C" { #endif -#include #include +#include /** @defgroup odp_queue ODP QUEUE * Macros and operation on a queue. @@ -42,272 +42,6 @@ extern "C" { * Maximum queue name length in chars including null char */ -/** - * Queue type - */ -typedef enum odp_queue_type_t { - /** Plain queue - * - * Plain queues offer simple FIFO storage of events. Application may - * dequeue directly from these queues. */ - ODP_QUEUE_TYPE_PLAIN = 0, - - /** Scheduled queue - * - * Scheduled queues are connected to the scheduler. Application must - * not dequeue events directly from these queues but use the scheduler - * instead. */ - ODP_QUEUE_TYPE_SCHED -} odp_queue_type_t; - -/** - * Queue operation mode - */ -typedef enum odp_queue_op_mode_t { - /** Multithread safe operation - * - * Queue operation (enqueue or dequeue) is multithread safe. Any - * number of application threads may perform the operation - * concurrently. */ - ODP_QUEUE_OP_MT = 0, - - /** Not multithread safe operation - * - * Queue operation (enqueue or dequeue) may not be multithread safe. - * Application ensures synchronization between threads so that - * simultaneously only single thread attempts the operation on - * the same queue. */ - ODP_QUEUE_OP_MT_UNSAFE, - - /** Disabled - * - * Direct enqueue or dequeue operation from application is disabled. - * An attempt to enqueue/dequeue directly will result undefined - * behaviour. Various ODP functions (e.g. packet input, timer, - * crypto, scheduler, etc) are able to perform enqueue or - * dequeue operations normally on the queue. - * */ - ODP_QUEUE_OP_DISABLED - -} odp_queue_op_mode_t; - -/** - * Non-blocking level - * - * A non-blocking level defines implementation guarantees for application - * progress when multiple threads operate on the same resource (e.g. a queue) - * simultaneously. The first level (ODP_BLOCKING) does not have any block - * freedom guarantees, but a suspending thread may block the other threads for - * the entire time it remains suspended (infinitely if crashed). - * On the contrary, actual non-blocking levels provide guarantees of progress: - * - * ODP_NONBLOCKING_LF: A non-blocking and lock-free implementation guarantees - * that at least one of the threads successfully completes - * its operations, regardless of what other threads do. - * Application progress is guaranteed, but individual - * threads may starve while trying to execute their - * operations on the shared resource. - * - * ODP_NONBLOCKING_WF: A non-blocking and wait-free implementation guarantees - * application progress with starvation freedom. All - * threads are guaranteed to complete their operations in - * a bounded number of steps, regardless of what other - * threads do. - * - * Non-blocking levels are listed from the weakest to the strongest guarantee of - * block freedom. Performance of a non-blocking implementation may be lower than - * the blocking one. Non-blocking guarantees are important e.g. for real-time - * applications when real-time and non real-time threads share a resource. - */ -typedef enum odp_nonblocking_t { - /** Blocking implementation. A suspeding thread may block all other - * threads, i.e. no block freedom guarantees. This is the lowest level. - */ - ODP_BLOCKING = 0, - - /** Non-blocking and lock-free implementation. Other threads can make - * progress while a thread is suspended. Starvation freedom is not - * guaranteed. - */ - ODP_NONBLOCKING_LF, - - /** Non-blocking and wait-free implementation. Other threads can make - * progress while a thread is suspended. Starvation freedom is - * guaranteed. - */ - ODP_NONBLOCKING_WF - -} odp_nonblocking_t; - -/** - * Queue capabilities - */ -typedef struct odp_queue_capability_t { - /** Maximum number of event queues of any type (default size). Use - * this in addition to queue type specific 'max_num', if both queue - * types are used simultaneously. */ - uint32_t max_queues; - - /** Maximum number of ordered locks per queue */ - uint32_t max_ordered_locks; - - /** Maximum number of scheduling groups */ - unsigned max_sched_groups; - - /** Number of scheduling priorities */ - unsigned sched_prios; - - /** Plain queue capabilities */ - struct { - /** Maximum number of plain (ODP_BLOCKING) queues of the - * default size. */ - uint32_t max_num; - - /** Maximum number of events a plain (ODP_BLOCKING) queue can - * store simultaneously. The value of zero means that plain - * queues do not have a size limit, but a single queue can - * store all available events. */ - uint32_t max_size; - - /** Lock-free (ODP_NONBLOCKING_LF) implementation capabilities. - * The specification is the same as for the blocking - * implementation. */ - struct { - /** Maximum number of queues. Lock-free queues are not - * supported when zero. */ - uint32_t max_num; - - /** Maximum queue size */ - uint32_t max_size; - - } lockfree; - - /** Wait-free (ODP_NONBLOCKING_WF) implementation capabilities. - * The specification is the same as for the blocking - * implementation. */ - struct { - /** Maximum number of queues. Wait-free queues are not - * supported when zero. */ - uint32_t max_num; - - /** Maximum queue size */ - uint32_t max_size; - - } waitfree; - - } plain; - - /** Scheduled queue capabilities */ - struct { - /** Maximum number of scheduled (ODP_BLOCKING) queues of the - * default size. */ - uint32_t max_num; - - /** Maximum number of events a scheduled (ODP_BLOCKING) queue - * can store simultaneously. The value of zero means that - * scheduled queues do not have a size limit, but a single - * queue can store all available events. */ - uint32_t max_size; - - /** Lock-free (ODP_NONBLOCKING_LF) implementation capabilities. - * The specification is the same as for the blocking - * implementation. */ - struct { - /** Maximum number of queues. Lock-free queues are not - * supported when zero. */ - uint32_t max_num; - - /** Maximum queue size */ - uint32_t max_size; - - } lockfree; - - /** Wait-free (ODP_NONBLOCKING_WF) implementation capabilities. - * The specification is the same as for the blocking - * implementation. */ - struct { - /** Maximum number of queues. Wait-free queues are not - * supported when zero. */ - uint32_t max_num; - - /** Maximum queue size */ - uint32_t max_size; - - } waitfree; - - } sched; - -} odp_queue_capability_t; - -/** - * ODP Queue parameters - */ -typedef struct odp_queue_param_t { - /** Queue type - * - * Valid values for other parameters in this structure depend on - * the queue type. */ - odp_queue_type_t type; - - /** Enqueue mode - * - * Default value for both queue types is ODP_QUEUE_OP_MT. Application - * may enable performance optimizations by defining MT_UNSAFE or - * DISABLED modes when applicable. */ - odp_queue_op_mode_t enq_mode; - - /** Dequeue mode - * - * For PLAIN queues, the default value is ODP_QUEUE_OP_MT. Application - * may enable performance optimizations by defining MT_UNSAFE or - * DISABLED modes when applicable. However, when a plain queue is input - * to the implementation (e.g. a queue for packet output), the - * parameter is ignored in queue creation and the value is - * ODP_QUEUE_OP_DISABLED. - * - * For SCHED queues, the parameter is ignored in queue creation and - * the value is ODP_QUEUE_OP_DISABLED. */ - odp_queue_op_mode_t deq_mode; - - /** Scheduler parameters - * - * These parameters are considered only when queue type is - * ODP_QUEUE_TYPE_SCHED. */ - odp_schedule_param_t sched; - - /** Non-blocking level - * - * Queue implementation must guarantee at least this level of block - * freedom for queue enqueue and dequeue/schedule operations. - * The default value is ODP_BLOCKING. */ - odp_nonblocking_t nonblocking; - - /** Queue context pointer - * - * User defined context pointer associated with the queue. The same - * pointer can be accessed with odp_queue_context() and - * odp_queue_context_set() calls. The implementation may read the - * pointer for prefetching the context data. Default value of the - * pointer is NULL. */ - void *context; - - /** Queue context data length - * - * User defined context data length in bytes for prefetching. - * The implementation may use this value as a hint for the number of - * context data bytes to prefetch. Default value is zero (no hint). */ - uint32_t context_len; - - /** Queue size - * - * The queue must be able to store at minimum this many events - * simultaneously. The value must not exceed 'max_size' queue - * capability. The value of zero means implementation specific - * default size. */ - uint32_t size; - -} odp_queue_param_t; - /** * Queue create * @@ -527,15 +261,6 @@ uint64_t odp_queue_to_u64(odp_queue_t hdl); */ void odp_queue_param_init(odp_queue_param_t *param); -/** - * Queue information - * Retrieve information about a queue with odp_queue_info() - */ -typedef struct odp_queue_info_t { - const char *name; /**< queue name */ - odp_queue_param_t param; /**< queue parameters */ -} odp_queue_info_t; - /** * Retrieve information about a queue * diff --git a/include/odp/api/spec/queue_types.h b/include/odp/api/spec/queue_types.h new file mode 100644 index 000000000..be7e79a81 --- /dev/null +++ b/include/odp/api/spec/queue_types.h @@ -0,0 +1,311 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP queue types + */ + +#ifndef ODP_API_SPEC_QUEUE_TYPES_H_ +#define ODP_API_SPEC_QUEUE_TYPES_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odp_queue + * @{ + */ + +/** + * Queue type + */ +typedef enum odp_queue_type_t { + /** Plain queue + * + * Plain queues offer simple FIFO storage of events. Application may + * dequeue directly from these queues. */ + ODP_QUEUE_TYPE_PLAIN = 0, + + /** Scheduled queue + * + * Scheduled queues are connected to the scheduler. Application must + * not dequeue events directly from these queues but use the scheduler + * instead. */ + ODP_QUEUE_TYPE_SCHED +} odp_queue_type_t; + +/** + * Queue operation mode + */ +typedef enum odp_queue_op_mode_t { + /** Multithread safe operation + * + * Queue operation (enqueue or dequeue) is multithread safe. Any + * number of application threads may perform the operation + * concurrently. */ + ODP_QUEUE_OP_MT = 0, + + /** Not multithread safe operation + * + * Queue operation (enqueue or dequeue) may not be multithread safe. + * Application ensures synchronization between threads so that + * simultaneously only single thread attempts the operation on + * the same queue. */ + ODP_QUEUE_OP_MT_UNSAFE, + + /** Disabled + * + * Direct enqueue or dequeue operation from application is disabled. + * An attempt to enqueue/dequeue directly will result undefined + * behaviour. Various ODP functions (e.g. packet input, timer, + * crypto, scheduler, etc) are able to perform enqueue or + * dequeue operations normally on the queue. + * */ + ODP_QUEUE_OP_DISABLED + +} odp_queue_op_mode_t; + +/** + * Non-blocking level + * + * A non-blocking level defines implementation guarantees for application + * progress when multiple threads operate on the same resource (e.g. a queue) + * simultaneously. The first level (ODP_BLOCKING) does not have any block + * freedom guarantees, but a suspending thread may block the other threads for + * the entire time it remains suspended (infinitely if crashed). + * On the contrary, actual non-blocking levels provide guarantees of progress: + * + * ODP_NONBLOCKING_LF: A non-blocking and lock-free implementation guarantees + * that at least one of the threads successfully completes + * its operations, regardless of what other threads do. + * Application progress is guaranteed, but individual + * threads may starve while trying to execute their + * operations on the shared resource. + * + * ODP_NONBLOCKING_WF: A non-blocking and wait-free implementation guarantees + * application progress with starvation freedom. All + * threads are guaranteed to complete their operations in + * a bounded number of steps, regardless of what other + * threads do. + * + * Non-blocking levels are listed from the weakest to the strongest guarantee of + * block freedom. Performance of a non-blocking implementation may be lower than + * the blocking one. Non-blocking guarantees are important e.g. for real-time + * applications when real-time and non real-time threads share a resource. + */ +typedef enum odp_nonblocking_t { + /** Blocking implementation. A suspeding thread may block all other + * threads, i.e. no block freedom guarantees. This is the lowest level. + */ + ODP_BLOCKING = 0, + + /** Non-blocking and lock-free implementation. Other threads can make + * progress while a thread is suspended. Starvation freedom is not + * guaranteed. + */ + ODP_NONBLOCKING_LF, + + /** Non-blocking and wait-free implementation. Other threads can make + * progress while a thread is suspended. Starvation freedom is + * guaranteed. + */ + ODP_NONBLOCKING_WF + +} odp_nonblocking_t; + +/** + * Queue capabilities + */ +typedef struct odp_queue_capability_t { + /** Maximum number of event queues of any type (default size). Use + * this in addition to queue type specific 'max_num', if both queue + * types are used simultaneously. */ + uint32_t max_queues; + + /** Maximum number of ordered locks per queue */ + uint32_t max_ordered_locks; + + /** Maximum number of scheduling groups */ + unsigned max_sched_groups; + + /** Number of scheduling priorities */ + unsigned sched_prios; + + /** Plain queue capabilities */ + struct { + /** Maximum number of plain (ODP_BLOCKING) queues of the + * default size. */ + uint32_t max_num; + + /** Maximum number of events a plain (ODP_BLOCKING) queue can + * store simultaneously. The value of zero means that plain + * queues do not have a size limit, but a single queue can + * store all available events. */ + uint32_t max_size; + + /** Lock-free (ODP_NONBLOCKING_LF) implementation capabilities. + * The specification is the same as for the blocking + * implementation. */ + struct { + /** Maximum number of queues. Lock-free queues are not + * supported when zero. */ + uint32_t max_num; + + /** Maximum queue size */ + uint32_t max_size; + + } lockfree; + + /** Wait-free (ODP_NONBLOCKING_WF) implementation capabilities. + * The specification is the same as for the blocking + * implementation. */ + struct { + /** Maximum number of queues. Wait-free queues are not + * supported when zero. */ + uint32_t max_num; + + /** Maximum queue size */ + uint32_t max_size; + + } waitfree; + + } plain; + + /** Scheduled queue capabilities */ + struct { + /** Maximum number of scheduled (ODP_BLOCKING) queues of the + * default size. */ + uint32_t max_num; + + /** Maximum number of events a scheduled (ODP_BLOCKING) queue + * can store simultaneously. The value of zero means that + * scheduled queues do not have a size limit, but a single + * queue can store all available events. */ + uint32_t max_size; + + /** Lock-free (ODP_NONBLOCKING_LF) implementation capabilities. + * The specification is the same as for the blocking + * implementation. */ + struct { + /** Maximum number of queues. Lock-free queues are not + * supported when zero. */ + uint32_t max_num; + + /** Maximum queue size */ + uint32_t max_size; + + } lockfree; + + /** Wait-free (ODP_NONBLOCKING_WF) implementation capabilities. + * The specification is the same as for the blocking + * implementation. */ + struct { + /** Maximum number of queues. Wait-free queues are not + * supported when zero. */ + uint32_t max_num; + + /** Maximum queue size */ + uint32_t max_size; + + } waitfree; + + } sched; + +} odp_queue_capability_t; + +/** + * ODP Queue parameters + */ +typedef struct odp_queue_param_t { + /** Queue type + * + * Valid values for other parameters in this structure depend on + * the queue type. */ + odp_queue_type_t type; + + /** Enqueue mode + * + * Default value for both queue types is ODP_QUEUE_OP_MT. Application + * may enable performance optimizations by defining MT_UNSAFE or + * DISABLED modes when applicable. */ + odp_queue_op_mode_t enq_mode; + + /** Dequeue mode + * + * For PLAIN queues, the default value is ODP_QUEUE_OP_MT. Application + * may enable performance optimizations by defining MT_UNSAFE or + * DISABLED modes when applicable. However, when a plain queue is input + * to the implementation (e.g. a queue for packet output), the + * parameter is ignored in queue creation and the value is + * ODP_QUEUE_OP_DISABLED. + * + * For SCHED queues, the parameter is ignored in queue creation and + * the value is ODP_QUEUE_OP_DISABLED. */ + odp_queue_op_mode_t deq_mode; + + /** Scheduler parameters + * + * These parameters are considered only when queue type is + * ODP_QUEUE_TYPE_SCHED. */ + odp_schedule_param_t sched; + + /** Non-blocking level + * + * Queue implementation must guarantee at least this level of block + * freedom for queue enqueue and dequeue/schedule operations. + * The default value is ODP_BLOCKING. */ + odp_nonblocking_t nonblocking; + + /** Queue context pointer + * + * User defined context pointer associated with the queue. The same + * pointer can be accessed with odp_queue_context() and + * odp_queue_context_set() calls. The implementation may read the + * pointer for prefetching the context data. Default value of the + * pointer is NULL. */ + void *context; + + /** Queue context data length + * + * User defined context data length in bytes for prefetching. + * The implementation may use this value as a hint for the number of + * context data bytes to prefetch. Default value is zero (no hint). */ + uint32_t context_len; + + /** Queue size + * + * The queue must be able to store at minimum this many events + * simultaneously. The value must not exceed 'max_size' queue + * capability. The value of zero means implementation specific + * default size. */ + uint32_t size; + +} odp_queue_param_t; + +/** + * Queue information + * Retrieve information about a queue with odp_queue_info() + */ +typedef struct odp_queue_info_t { + const char *name; /**< queue name */ + odp_queue_param_t param; /**< queue parameters */ +} odp_queue_info_t; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#include +#endif From patchwork Fri Aug 17 13:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144482 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp750056ljj; Fri, 17 Aug 2018 06:03:44 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyuQDVp7+SOH9pv9Ez+BPMHjlFxSr36mfP3NeHSSEGSH3ijsnP68ldVg/S9BSwFyFRrMm70 X-Received: by 2002:a0c:e74c:: with SMTP id g12-v6mr30789744qvn.118.1534511023966; Fri, 17 Aug 2018 06:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534511023; cv=none; d=google.com; s=arc-20160816; b=XBVxGI4Ztx213awbqmR1klwSpsj10nGjVthZGZWDA3Am70knjJiEyjCZ1V7pBIR6QT jdtzUhJvQYK5HJlx1l+yQVOYuCxjQPobNL8M2AK+EMhdjsmHfYtkxdhS1G7x+6o89znp EF45BAy/123BLmnvcqR2eaS3jXC5Hf7FC3KYQzrkVJBLtVdOj3QjHrS7qvjde+t24KxD 5OpGQ/GvwUUQdMOq2/wgrjXKezJNNHlVfvGdXUuJ/4IkvXleqv3VCrNfqcKPgFcWWoyD ZGfiV2u/7pHGQKZ6okg567Qig0PxZhvQhZVT0UhrnuBFa26wUnmCmNX0kojbI5zj6GNj IZ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=B+dgrpUh+PHwuLWmX+23HDOMuP+7K5oRPiA4QDMJh20=; b=tiy02iy2IJq/O8YdGtgDzHXYUvTcrT5sAKfsVqpopcGBIewdakfPtqAl3CySiN0JLG EUTwVrjVcb4Eo0KzURSlV3BjlyEhAJmjXCYuzqTj/gUTYzHyWnMvYb/DMcDBejumnhUS LfmiA/h1wtrIuakT+UMZM4XU/A5uFgC3jEw21uilRz1YlMYVavJRqr8LogncxdnAae5x eCjC8hjfUngPSzddHSfxteTva1Bp7zfygfRbggpdzxyH80JRY+r+FhAHsJnUgrayTDKg kPidQsMNxUv31qbvcDbErMiGm1v2Qqajj2Ef5K3EFWWIyGkhOT5JfMRsnZuupx/Wu2t3 N18w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id i14-v6si1838514qvo.40.2018.08.17.06.03.43; Fri, 17 Aug 2018 06:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A1C2A685E0; Fri, 17 Aug 2018 13:03:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 8E8A5609AA; Fri, 17 Aug 2018 13:00:44 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B419561730; Fri, 17 Aug 2018 13:00:22 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id C231C609BA for ; Fri, 17 Aug 2018 13:00:12 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 1D62D4305424 for ; Fri, 17 Aug 2018 16:00:11 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WB3mnQJmLF-0BGG1WZo; Fri, 17 Aug 2018 16:00:11 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-0AqagOjt; Fri, 17 Aug 2018 16:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:03 +0000 Message-Id: <1534510807-11066-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 2/6] linux-gen: queue: inline enq and deq functions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Inline queue enqueue and dequeue functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ .../include/odp/api/plat/queue_inline_types.h | 26 +++++++++ .../include/odp/api/plat/queue_inlines.h | 29 +++++++++- platform/linux-generic/include/odp_queue_if.h | 25 --------- platform/linux-generic/odp_queue_basic.c | 2 +- platform/linux-generic/odp_queue_if.c | 56 ++++++------------- platform/linux-generic/odp_queue_scalable.c | 2 +- 6 files changed, 74 insertions(+), 66 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h index 3a8df7a4b..f81a84782 100644 --- a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h @@ -12,6 +12,7 @@ extern "C" { #endif #include +#include /** @cond _ODP_HIDE_FROM_DOXYGEN_ */ @@ -26,6 +27,31 @@ typedef struct _odp_queue_inline_offset_t { } _odp_queue_inline_offset_t; +/* 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); + 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); + uint32_t (*queue_lock_count)(odp_queue_t queue); + uint64_t (*queue_to_u64)(odp_queue_t queue); + void (*queue_param_init)(odp_queue_param_t *param); + int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info); +} _odp_queue_api_fn_t; + /** @endcond */ #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp/api/plat/queue_inlines.h b/platform/linux-generic/include/odp/api/plat/queue_inlines.h index f802c96e7..c557b4ba3 100644 --- a/platform/linux-generic/include/odp/api/plat/queue_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/queue_inlines.h @@ -12,11 +12,16 @@ /** @cond _ODP_HIDE_FROM_DOXYGEN_ */ extern _odp_queue_inline_offset_t _odp_queue_inline_offset; +extern const _odp_queue_api_fn_t *_odp_queue_api; #ifndef _ODP_NO_INLINE /* Inline functions by default */ #define _ODP_INLINE static inline - #define odp_queue_context __odp_queue_context + #define odp_queue_context __odp_queue_context + #define odp_queue_enq __odp_queue_enq + #define odp_queue_enq_multi __odp_queue_enq_multi + #define odp_queue_deq __odp_queue_deq + #define odp_queue_deq_multi __odp_queue_deq_multi #else #define _ODP_INLINE #endif @@ -31,6 +36,28 @@ _ODP_INLINE void *odp_queue_context(odp_queue_t handle) return context; } +_ODP_INLINE int odp_queue_enq(odp_queue_t queue, odp_event_t ev) +{ + return _odp_queue_api->queue_enq(queue, ev); +} + +_ODP_INLINE int odp_queue_enq_multi(odp_queue_t queue, + const odp_event_t events[], int num) +{ + return _odp_queue_api->queue_enq_multi(queue, events, num); +} + +_ODP_INLINE odp_event_t odp_queue_deq(odp_queue_t queue) +{ + return _odp_queue_api->queue_deq(queue); +} + +_ODP_INLINE int odp_queue_deq_multi(odp_queue_t queue, + odp_event_t events[], int num) +{ + return _odp_queue_api->queue_deq_multi(queue, events, num); +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 2eaf8771e..f89690bd7 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -18,31 +18,6 @@ extern "C" { #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); - 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); - uint32_t (*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; - 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_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 89eed3c0d..3f57a23db 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -902,7 +902,7 @@ static odp_queue_t queue_to_ext(void *q_int) } /* API functions */ -queue_api_t queue_basic_api = { +_odp_queue_api_fn_t queue_basic_api = { .queue_create = queue_create, .queue_destroy = queue_destroy, .queue_lookup = queue_lookup, diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c index f3984542a..65f65006e 100644 --- a/platform/linux-generic/odp_queue_if.c +++ b/platform/linux-generic/odp_queue_if.c @@ -19,101 +19,81 @@ #include _odp_queue_inline_offset_t ODP_ALIGNED_CACHE _odp_queue_inline_offset; +const _odp_queue_api_fn_t *_odp_queue_api; #include -extern const queue_api_t queue_scalable_api; +extern const _odp_queue_api_fn_t queue_scalable_api; extern const queue_fn_t queue_scalable_fn; -extern const queue_api_t queue_basic_api; +extern const _odp_queue_api_fn_t queue_basic_api; extern const queue_fn_t queue_basic_fn; -const queue_api_t *queue_api; const queue_fn_t *queue_fn; odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param) { - return queue_api->queue_create(name, param); + return _odp_queue_api->queue_create(name, param); } int odp_queue_destroy(odp_queue_t queue) { - return queue_api->queue_destroy(queue); + return _odp_queue_api->queue_destroy(queue); } odp_queue_t odp_queue_lookup(const char *name) { - return queue_api->queue_lookup(name); + return _odp_queue_api->queue_lookup(name); } int odp_queue_capability(odp_queue_capability_t *capa) { - return queue_api->queue_capability(capa); + return _odp_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); -} - -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); + return _odp_queue_api->queue_context_set(queue, context, len); } odp_queue_type_t odp_queue_type(odp_queue_t queue) { - return queue_api->queue_type(queue); + return _odp_queue_api->queue_type(queue); } odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue) { - return queue_api->queue_sched_type(queue); + return _odp_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); + return _odp_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); + return _odp_queue_api->queue_sched_group(queue); } uint32_t odp_queue_lock_count(odp_queue_t queue) { - return queue_api->queue_lock_count(queue); + return _odp_queue_api->queue_lock_count(queue); } uint64_t odp_queue_to_u64(odp_queue_t hdl) { - return queue_api->queue_to_u64(hdl); + return _odp_queue_api->queue_to_u64(hdl); } void odp_queue_param_init(odp_queue_param_t *param) { - return queue_api->queue_param_init(param); + return _odp_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); + return _odp_queue_api->queue_info(queue, info); } int _odp_queue_init_global(void) @@ -127,10 +107,10 @@ int _odp_queue_init_global(void) !strcmp(sched, "sp") || !strcmp(sched, "iquery")) { queue_fn = &queue_basic_fn; - queue_api = &queue_basic_api; + _odp_queue_api = &queue_basic_api; } else if (!strcmp(sched, "scalable")) { queue_fn = &queue_scalable_fn; - queue_api = &queue_scalable_api; + _odp_queue_api = &queue_scalable_api; } else { ODP_ABORT("Unknown scheduler specified via ODP_SCHEDULER\n"); return -1; diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c index 13e93bc19..3ca865b05 100644 --- a/platform/linux-generic/odp_queue_scalable.c +++ b/platform/linux-generic/odp_queue_scalable.c @@ -961,7 +961,7 @@ static odp_queue_t queue_to_ext(void *handle) } /* API functions */ -queue_api_t queue_scalable_api = { +_odp_queue_api_fn_t queue_scalable_api = { .queue_create = queue_create, .queue_destroy = queue_destroy, .queue_lookup = queue_lookup, From patchwork Fri Aug 17 13:00:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144483 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp752000ljj; Fri, 17 Aug 2018 06:05:09 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwsJP3bZ4sXgI9ahMP8ADVOR8BwmesJj8flzS9E68+OBgdCKQUVEpIYGxCkvNBvljzgxgm7 X-Received: by 2002:a0c:bf49:: with SMTP id b9-v6mr31031873qvj.65.1534511109445; Fri, 17 Aug 2018 06:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534511109; cv=none; d=google.com; s=arc-20160816; b=ODQEfI1XEo4cImUZDILF1YFsyW0gQ9r5Q2+YxROSgozcexRHaBxzLzhlCJ+0Is4tj+ JP9P61wvZUV8yYMKt7S9MkcEYB88rp4u74vwKnd62CtRwbYDb/PXanw4EOVG232bDvFv aBp0XqCift6oEsPGIiQv6xZqMseblDc0uH84qngxrAG6dkR+4479Xcu9fhmsB+RYJYcL oCQ5F004UEYG42v3o3UxHhv3SoL2DPQclixo2CLIEewrgnnGso4M1N9g3S5Uj0r81tYt b52uF/TFXyM6lWZbGtr/TsXOOBkTwdgc9lXC/URLK3CbnHB8q+LPu2mM5uGlP15nKfWK dNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=rUC9eHCgXMJyLPKa5DEwKbJOPEGHqAabxCw0A9ATENA=; b=tNick8AMlpDY5TMZQJHdDTBxI3wvol5XuSYQGm9/JbmoAJj4Q0WeUqi9ROjdIa5XjS mLTKDSy92LhSoF/nDCHSPqgVsVA6CNZxyE0/7YX2nXZZTWbzKPhxuwJlYlPgnmfRecxx PwTftzZpPWtQI+/z/bUTlR/wJkK/7UbZenSnwaAJXV0R+FENpekc4usnEhAXlw3aNFRd eJ9UjKyxNaE7z/mJ8s2Osbjq/FZd+LnBmvxAHaiAP93aDAJaVpnrBSHIVKiC2KMjsoPo h8NRNtsCSswf7owB6lMLqKub1ISpod4dQpuC7MzGRBE4YTOzVaXnSJ6znDbWDmxaSXNz LtoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id y5-v6si1944957qkb.239.2018.08.17.06.05.09; Fri, 17 Aug 2018 06:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 271FA60B04; Fri, 17 Aug 2018 13:05:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E571B61730; Fri, 17 Aug 2018 13:00:58 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 194CD62796; Fri, 17 Aug 2018 13:00:25 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 8C80060B53 for ; Fri, 17 Aug 2018 13:00:13 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 8B59934C3FFD for ; Fri, 17 Aug 2018 16:00:12 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id d4meqmQq5s-0CWSuVrH; Fri, 17 Aug 2018 16:00:12 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-0Bqe63NG; Fri, 17 Aug 2018 16:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:04 +0000 Message-Id: <1534510807-11066-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 3/6] linux-gen: queue: remove internal queue handle conversions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Use odp_queue_t as internal queue handle. This simplifies internal queue interface as intermediate type (void *q_int) and additional conversions (from_ext() and to_ext()) are not needed. Queue handle stores pointer to queue entry as before. Conversion is a simple cast (nop as an inline function) for both queue implementations. Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ .../include/odp_packet_internal.h | 2 +- .../include/odp_packet_io_internal.h | 1 - .../include/odp_queue_basic_internal.h | 5 ++ platform/linux-generic/include/odp_queue_if.h | 24 +++--- .../include/odp_queue_scalable_internal.h | 8 +- .../linux-generic/include/odp_schedule_if.h | 2 +- .../include/odp_traffic_mngr_internal.h | 2 +- platform/linux-generic/odp_classification.c | 5 +- platform/linux-generic/odp_ipsec.c | 2 +- platform/linux-generic/odp_packet_io.c | 83 +++++++++---------- platform/linux-generic/odp_queue_basic.c | 76 +++++++---------- platform/linux-generic/odp_queue_lf.c | 16 ++-- platform/linux-generic/odp_queue_scalable.c | 47 ++++------- platform/linux-generic/odp_queue_spsc.c | 28 +++---- platform/linux-generic/odp_schedule_basic.c | 16 ++-- platform/linux-generic/odp_schedule_iquery.c | 16 ++-- .../linux-generic/odp_schedule_scalable.c | 2 +- platform/linux-generic/odp_schedule_sp.c | 4 +- platform/linux-generic/odp_traffic_mngr.c | 22 ++--- platform/linux-generic/pktio/loop.c | 8 +- 20 files changed, 169 insertions(+), 200 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index cd2db2ecd..4b5127d93 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -105,7 +105,7 @@ typedef struct { odp_time_t timestamp; /* Classifier destination queue */ - void *dst_queue; + odp_queue_t dst_queue; /* Result for crypto packet op */ odp_crypto_packet_result_t crypto_op_result; diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index d2446d19f..080850783 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -105,7 +105,6 @@ struct pktio_entry { struct { odp_queue_t queue; - void *queue_int; odp_pktin_queue_t pktin; } in_queue[PKTIO_MAX_QUEUES]; diff --git a/platform/linux-generic/include/odp_queue_basic_internal.h b/platform/linux-generic/include/odp_queue_basic_internal.h index 654b9e312..369eb19a1 100644 --- a/platform/linux-generic/include/odp_queue_basic_internal.h +++ b/platform/linux-generic/include/odp_queue_basic_internal.h @@ -96,6 +96,11 @@ static inline odp_queue_t queue_from_index(uint32_t queue_id) return (odp_queue_t)qentry_from_index(queue_id); } +static inline queue_entry_t *qentry_from_handle(odp_queue_t handle) +{ + return (queue_entry_t *)(uintptr_t)handle; +} + void queue_spsc_init(queue_entry_t *queue, uint32_t queue_size); /* Functions for schedulers */ diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index f89690bd7..7c7649219 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -22,19 +22,19 @@ 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 void *(*queue_from_ext_fn_t)(odp_queue_t handle); -typedef odp_queue_t (*queue_to_ext_fn_t)(void *q_int); -typedef int (*queue_enq_fn_t)(void *q_int, odp_buffer_hdr_t *); -typedef int (*queue_enq_multi_fn_t)(void *q_int, odp_buffer_hdr_t **, int); -typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(void *q_int); -typedef int (*queue_deq_multi_fn_t)(void *q_int, odp_buffer_hdr_t **, int); -typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(void *q_int); -typedef void (*queue_set_pktout_fn_t)(void *q_int, odp_pktio_t pktio, +typedef int (*queue_enq_fn_t)(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr); +typedef int (*queue_enq_multi_fn_t)(odp_queue_t queue, + odp_buffer_hdr_t **buf_hdr, int num); +typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(odp_queue_t queue); +typedef int (*queue_deq_multi_fn_t)(odp_queue_t queue, + odp_buffer_hdr_t **buf_hdr, int num); +typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(odp_queue_t queue); +typedef void (*queue_set_pktout_fn_t)(odp_queue_t queue, odp_pktio_t pktio, int index); -typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(void *q_int); -typedef void (*queue_set_pktin_fn_t)(void *q_int, odp_pktio_t pktio, +typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(odp_queue_t queue); +typedef void (*queue_set_pktin_fn_t)(odp_queue_t queue, odp_pktio_t pktio, int index); -typedef void (*queue_set_enq_deq_fn_t)(void *q_int, +typedef void (*queue_set_enq_deq_fn_t)(odp_queue_t queue, queue_enq_fn_t enq, queue_enq_multi_fn_t enq_multi, queue_deq_fn_t deq, @@ -46,8 +46,6 @@ typedef struct { 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; diff --git a/platform/linux-generic/include/odp_queue_scalable_internal.h b/platform/linux-generic/include/odp_queue_scalable_internal.h index 71aaa3ba7..cc5b52191 100644 --- a/platform/linux-generic/include/odp_queue_scalable_internal.h +++ b/platform/linux-generic/include/odp_queue_scalable_internal.h @@ -80,14 +80,14 @@ static inline uint32_t queue_to_id(odp_queue_t handle) return qentry_from_ext(handle)->s.index; } -static inline queue_entry_t *qentry_from_int(void *handle) +static inline queue_entry_t *qentry_from_int(odp_queue_t handle) { - return (queue_entry_t *)handle; + return (queue_entry_t *)(uintptr_t)handle; } -static inline void *qentry_to_int(queue_entry_t *qentry) +static inline odp_queue_t qentry_to_int(queue_entry_t *qentry) { - return qentry; + return (odp_queue_t)qentry; } static inline odp_queue_t queue_get_handle(queue_entry_t *queue) diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 8f082aaaf..30481773d 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -32,7 +32,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)(void *q_int, +typedef int (*schedule_ord_enq_multi_fn_t)(odp_queue_t queue, 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 919831a3d..770a64900 100644 --- a/platform/linux-generic/include/odp_traffic_mngr_internal.h +++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h @@ -282,7 +282,7 @@ struct tm_queue_obj_s { uint8_t tm_idx; uint8_t delayed_cnt; uint8_t blocked_cnt; - void *tm_qentry; + odp_queue_t queue; }; struct tm_node_obj_s { diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 70e8def69..d02fb5070 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -1036,7 +1036,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, pkt_hdr->p.input_flags.dst_queue = 1; if (!cos->s.queue_group) { - pkt_hdr->dst_queue = queue_fn->from_ext(cos->s.queue); + pkt_hdr->dst_queue = cos->s.queue; return 0; } @@ -1045,8 +1045,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, hash = hash & (CLS_COS_QUEUE_MAX - 1); tbl_index = (cos->s.index * CLS_COS_QUEUE_MAX) + (hash % cos->s.num_queue); - pkt_hdr->dst_queue = queue_fn->from_ext(queue_grp_tbl-> - s.queue[tbl_index]); + pkt_hdr->dst_queue = queue_grp_tbl->s.queue[tbl_index]; return 0; } diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 5b739cc1a..36bea6cf8 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -1745,7 +1745,7 @@ int _odp_ipsec_try_inline(odp_packet_t *pkt) pkt_hdr = packet_hdr(*pkt); pkt_hdr->p.input_flags.dst_queue = 1; - pkt_hdr->dst_queue = queue_fn->from_ext(ipsec_sa->queue); + pkt_hdr->dst_queue = ipsec_sa->queue; /* Last thing */ _odp_ipsec_sa_unuse(ipsec_sa); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 7759f83e4..a10aaf10c 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -137,7 +137,6 @@ 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 = NULL; entry->s.in_queue[i].pktin = PKTIN_INVALID; } } @@ -327,7 +326,6 @@ 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 = NULL; } } } @@ -637,46 +635,47 @@ static inline int pktin_recv_buf(pktio_entry_t *entry, int pktin_index, return num_rx; } -static int pktout_enqueue(void *q_int, odp_buffer_hdr_t *buf_hdr) +static int pktout_enqueue(odp_queue_t queue, 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(q_int, (void **)buf_hdr, len, &nbr)) + if (sched_fn->ord_enq_multi(queue, (void **)buf_hdr, len, &nbr)) return (nbr == len ? 0 : -1); - nbr = odp_pktout_send(queue_fn->get_pktout(q_int), &pkt, len); + nbr = odp_pktout_send(queue_fn->get_pktout(queue), &pkt, len); return (nbr == len ? 0 : -1); } -static int pktout_enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], int num) +static int pktout_enq_multi(odp_queue_t queue, 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(q_int, (void **)buf_hdr, num, &nbr)) + if (sched_fn->ord_enq_multi(queue, (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(q_int), pkt_tbl, num); + nbr = odp_pktout_send(queue_fn->get_pktout(queue), pkt_tbl, num); return nbr; } -static odp_buffer_hdr_t *pktin_dequeue(void *q_int) +static odp_buffer_hdr_t *pktin_dequeue(odp_queue_t queue) { odp_buffer_hdr_t *buf_hdr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts; - odp_pktin_queue_t pktin_queue = queue_fn->get_pktin(q_int); + odp_pktin_queue_t pktin_queue = queue_fn->get_pktin(queue); odp_pktio_t pktio = pktin_queue.pktio; int pktin_index = pktin_queue.index; pktio_entry_t *entry = get_pktio_entry(pktio); - buf_hdr = queue_fn->deq(q_int); + buf_hdr = queue_fn->deq(queue); if (buf_hdr != NULL) return buf_hdr; @@ -689,7 +688,7 @@ static odp_buffer_hdr_t *pktin_dequeue(void *q_int) int num_enq; int num = pkts - 1; - num_enq = queue_fn->enq_multi(q_int, &hdr_tbl[1], num); + num_enq = queue_fn->enq_multi(queue, &hdr_tbl[1], num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) @@ -705,17 +704,18 @@ static odp_buffer_hdr_t *pktin_dequeue(void *q_int) return buf_hdr; } -static int pktin_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], int num) +static int pktin_deq_multi(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr[], + int num) { int nbr; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; int pkts, i, j; - odp_pktin_queue_t pktin_queue = queue_fn->get_pktin(q_int); + odp_pktin_queue_t pktin_queue = queue_fn->get_pktin(queue); odp_pktio_t pktio = pktin_queue.pktio; int pktin_index = pktin_queue.index; pktio_entry_t *entry = get_pktio_entry(pktio); - nbr = queue_fn->deq_multi(q_int, buf_hdr, num); + nbr = queue_fn->deq_multi(queue, buf_hdr, num); if (odp_unlikely(nbr > num)) ODP_ABORT("queue_deq_multi req: %d, returned %d\n", num, nbr); @@ -740,7 +740,7 @@ static int pktin_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], int num) if (j) { int num_enq; - num_enq = queue_fn->enq_multi(q_int, hdr_tbl, j); + num_enq = queue_fn->enq_multi(queue, hdr_tbl, j); if (odp_unlikely(num_enq < j)) { if (odp_unlikely(num_enq < 0)) @@ -765,7 +765,7 @@ int sched_cb_pktin_poll_one(int pktio_index, odp_packet_hdr_t *pkt_hdr; odp_buffer_hdr_t *buf_hdr; odp_packet_t packets[QUEUE_MULTI_MAX]; - void *q_int; + odp_queue_t queue; if (odp_unlikely(entry->s.state != PKTIO_STATE_STARTED)) { if (entry->s.state < PKTIO_STATE_ACTIVE || @@ -785,9 +785,9 @@ int sched_cb_pktin_poll_one(int pktio_index, pkt = packets[i]; pkt_hdr = packet_hdr(pkt); if (odp_unlikely(pkt_hdr->p.input_flags.dst_queue)) { - q_int = pkt_hdr->dst_queue; + queue = pkt_hdr->dst_queue; buf_hdr = packet_to_buf_hdr(pkt); - if (queue_fn->enq_multi(q_int, &buf_hdr, 1) < 0) { + if (queue_fn->enq_multi(queue, &buf_hdr, 1) < 0) { /* Queue full? */ odp_packet_free(pkt); __atomic_fetch_add(&entry->s.stats.in_discards, @@ -836,7 +836,7 @@ int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int index[]) } for (idx = 0; idx < num_queue; idx++) { - void *q_int; + odp_queue_t queue; int num_enq; num = pktin_recv_buf(entry, index[idx], hdr_tbl, @@ -850,8 +850,8 @@ int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int index[]) return -1; } - q_int = entry->s.in_queue[index[idx]].queue_int; - num_enq = queue_fn->enq_multi(q_int, hdr_tbl, num); + queue = entry->s.in_queue[index[idx]].queue; + num_enq = queue_fn->enq_multi(queue, hdr_tbl, num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) @@ -1371,31 +1371,37 @@ int odp_pktio_stats_reset(odp_pktio_t pktio) return ret; } -static int abort_pktin_enqueue(void *q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr ODP_UNUSED) +static int abort_pktin_enqueue(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr) { + (void)queue; + (void)buf_hdr; ODP_ABORT("attempted enqueue to a pktin queue"); return -1; } -static int abort_pktin_enq_multi(void *q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, - int num ODP_UNUSED) +static int abort_pktin_enq_multi(odp_queue_t queue, + odp_buffer_hdr_t *buf_hdr[], int num) { + (void)queue; + (void)buf_hdr; + (void)num; ODP_ABORT("attempted enqueue to a pktin queue"); return 0; } -static odp_buffer_hdr_t *abort_pktout_dequeue(void *q_int ODP_UNUSED) +static odp_buffer_hdr_t *abort_pktout_dequeue(odp_queue_t queue) { + (void)queue; ODP_ABORT("attempted dequeue from a pktout queue"); return NULL; } -static int abort_pktout_deq_multi(void *q_int ODP_UNUSED, - odp_buffer_hdr_t *buf_hdr[] ODP_UNUSED, - int num ODP_UNUSED) +static int abort_pktout_deq_multi(odp_queue_t queue, + odp_buffer_hdr_t *buf_hdr[], int num) { + (void)queue; + (void)buf_hdr; + (void)num; ODP_ABORT("attempted dequeue from a pktout queue"); return 0; } @@ -1410,7 +1416,6 @@ int odp_pktin_queue_config(odp_pktio_t pktio, unsigned i; int rc; odp_queue_t queue; - void *q_int; odp_pktin_queue_param_t default_param; if (param == NULL) { @@ -1490,11 +1495,9 @@ int odp_pktin_queue_config(odp_pktio_t pktio, return -1; } - q_int = queue_fn->from_ext(queue); - if (mode == ODP_PKTIN_MODE_QUEUE) { - queue_fn->set_pktin(q_int, pktio, i); - queue_fn->set_enq_deq_fn(q_int, + queue_fn->set_pktin(queue, pktio, i); + queue_fn->set_enq_deq_fn(queue, abort_pktin_enqueue, abort_pktin_enq_multi, pktin_dequeue, @@ -1502,11 +1505,9 @@ 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 = NULL; } entry->s.in_queue[i].pktin.index = i; @@ -1598,7 +1599,6 @@ 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; - void *q_int; char name[ODP_QUEUE_NAME_LEN]; int pktio_id = odp_pktio_index(pktio); @@ -1618,11 +1618,10 @@ int odp_pktout_queue_config(odp_pktio_t pktio, return -1; } - q_int = queue_fn->from_ext(queue); - queue_fn->set_pktout(q_int, pktio, i); + queue_fn->set_pktout(queue, pktio, i); /* Override default enqueue / dequeue functions */ - queue_fn->set_enq_deq_fn(q_int, + queue_fn->set_enq_deq_fn(queue, pktout_enqueue, pktout_enq_multi, abort_pktout_dequeue, diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 3f57a23db..2b3b6dfc4 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -47,11 +47,6 @@ static int queue_init(queue_entry_t *queue, const char *name, queue_global_t *queue_glb; extern _odp_queue_inline_offset_t _odp_queue_inline_offset; -static inline queue_entry_t *qentry_from_handle(odp_queue_t handle) -{ - return (queue_entry_t *)(uintptr_t)handle; -} - static int queue_capa(odp_queue_capability_t *capa, int sched) { memset(capa, 0, sizeof(odp_queue_capability_t)); @@ -489,7 +484,7 @@ static inline void buffer_index_to_buf(odp_buffer_hdr_t *buf_hdr[], } } -static inline int enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], +static inline int enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { int sched = 0; @@ -499,10 +494,10 @@ static inline int enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], ring_st_t *ring_st; uint32_t buf_idx[num]; - queue = q_int; + queue = qentry_from_handle(handle); ring_st = &queue->s.ring_st; - if (sched_fn->ord_enq_multi(q_int, (void **)buf_hdr, num, &ret)) + if (sched_fn->ord_enq_multi(handle, (void **)buf_hdr, num, &ret)) return ret; buffer_index_from_buf(buf_idx, buf_hdr, num); @@ -536,17 +531,17 @@ static inline int enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], return num_enq; } -static int queue_int_enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], +static int queue_int_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { - return enq_multi(q_int, buf_hdr, num); + return enq_multi(handle, buf_hdr, num); } -static int queue_int_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) +static int queue_int_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { int ret; - ret = enq_multi(q_int, &buf_hdr, 1); + ret = enq_multi(handle, &buf_hdr, 1); if (ret == 1) return 0; @@ -564,7 +559,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; - return queue->s.enqueue_multi(queue, + return queue->s.enqueue_multi(handle, (odp_buffer_hdr_t **)(uintptr_t)ev, num); } @@ -572,17 +567,19 @@ static int queue_enq(odp_queue_t handle, odp_event_t ev) { queue_entry_t *queue = qentry_from_handle(handle); - return queue->s.enqueue(queue, + return queue->s.enqueue(handle, (odp_buffer_hdr_t *)(uintptr_t)ev); } -static inline int plain_queue_deq(queue_entry_t *queue, +static inline int plain_queue_deq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { int num_deq; + queue_entry_t *queue; ring_st_t *ring_st; uint32_t buf_idx[num]; + queue = qentry_from_handle(handle); ring_st = &queue->s.ring_st; LOCK(queue); @@ -605,21 +602,18 @@ static inline int plain_queue_deq(queue_entry_t *queue, return num_deq; } -static int queue_int_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], +static int queue_int_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { - queue_entry_t *queue = q_int; - - return plain_queue_deq(queue, buf_hdr, num); + return plain_queue_deq(handle, buf_hdr, num); } -static odp_buffer_hdr_t *queue_int_deq(void *q_int) +static odp_buffer_hdr_t *queue_int_deq(odp_queue_t handle) { - queue_entry_t *queue = q_int; odp_buffer_hdr_t *buf_hdr = NULL; int ret; - ret = plain_queue_deq(queue, &buf_hdr, 1); + ret = plain_queue_deq(handle, &buf_hdr, 1); if (ret == 1) return buf_hdr; @@ -634,7 +628,7 @@ static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) if (num > QUEUE_MULTI_MAX) num = QUEUE_MULTI_MAX; - return queue->s.dequeue_multi(queue, + return queue->s.dequeue_multi(handle, (odp_buffer_hdr_t **)ev, num); } @@ -642,7 +636,7 @@ static odp_event_t queue_deq(odp_queue_t handle) { queue_entry_t *queue = qentry_from_handle(handle); - return (odp_event_t)queue->s.dequeue(queue); + return (odp_event_t)queue->s.dequeue(handle); } static int queue_init(queue_entry_t *queue, const char *name, @@ -838,43 +832,43 @@ static uint64_t queue_to_u64(odp_queue_t hdl) return _odp_pri(hdl); } -static odp_pktout_queue_t queue_get_pktout(void *q_int) +static odp_pktout_queue_t queue_get_pktout(odp_queue_t handle) { - queue_entry_t *qentry = q_int; + queue_entry_t *qentry = qentry_from_handle(handle); return qentry->s.pktout; } -static void queue_set_pktout(void *q_int, odp_pktio_t pktio, int index) +static void queue_set_pktout(odp_queue_t handle, odp_pktio_t pktio, int index) { - queue_entry_t *qentry = q_int; + queue_entry_t *qentry = qentry_from_handle(handle); qentry->s.pktout.pktio = pktio; qentry->s.pktout.index = index; } -static odp_pktin_queue_t queue_get_pktin(void *q_int) +static odp_pktin_queue_t queue_get_pktin(odp_queue_t handle) { - queue_entry_t *qentry = q_int; + queue_entry_t *qentry = qentry_from_handle(handle); return qentry->s.pktin; } -static void queue_set_pktin(void *q_int, odp_pktio_t pktio, int index) +static void queue_set_pktin(odp_queue_t handle, odp_pktio_t pktio, int index) { - queue_entry_t *qentry = q_int; + queue_entry_t *qentry = qentry_from_handle(handle); qentry->s.pktin.pktio = pktio; qentry->s.pktin.index = index; } -static void queue_set_enq_deq_func(void *q_int, +static void queue_set_enq_deq_func(odp_queue_t handle, 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_entry_t *qentry = q_int; + queue_entry_t *qentry = qentry_from_handle(handle); if (enq) qentry->s.enqueue = enq; @@ -889,18 +883,6 @@ static void queue_set_enq_deq_func(void *q_int, qentry->s.dequeue_multi = deq_multi; } -static void *queue_from_ext(odp_queue_t handle) -{ - return qentry_from_handle(handle); -} - -static odp_queue_t queue_to_ext(void *q_int) -{ - queue_entry_t *qentry = q_int; - - return qentry->s.handle; -} - /* API functions */ _odp_queue_api_fn_t queue_basic_api = { .queue_create = queue_create, @@ -928,8 +910,6 @@ queue_fn_t queue_basic_fn = { .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_int_enq, .enq_multi = queue_int_enq_multi, .deq = queue_int_deq, diff --git a/platform/linux-generic/odp_queue_lf.c b/platform/linux-generic/odp_queue_lf.c index d12a994be..a28da2c73 100644 --- a/platform/linux-generic/odp_queue_lf.c +++ b/platform/linux-generic/odp_queue_lf.c @@ -162,7 +162,7 @@ static inline int next_idx(int idx) return next; } -static int queue_lf_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) +static int queue_lf_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { queue_entry_t *queue; queue_lf_t *queue_lf; @@ -172,7 +172,7 @@ static int queue_lf_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) ring_lf_node_t new_val; ring_lf_node_t *node; - queue = q_int; + queue = qentry_from_handle(handle); queue_lf = queue->s.queue_lf; new_val.s.ptr = (uintptr_t)buf_hdr; @@ -209,18 +209,18 @@ static int queue_lf_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) return -1; } -static int queue_lf_enq_multi(void *q_int, odp_buffer_hdr_t **buf_hdr, +static int queue_lf_enq_multi(odp_queue_t handle, odp_buffer_hdr_t **buf_hdr, int num) { (void)num; - if (queue_lf_enq(q_int, buf_hdr[0]) == 0) + if (queue_lf_enq(handle, buf_hdr[0]) == 0) return 1; return 0; } -static odp_buffer_hdr_t *queue_lf_deq(void *q_int) +static odp_buffer_hdr_t *queue_lf_deq(odp_queue_t handle) { queue_entry_t *queue; queue_lf_t *queue_lf; @@ -231,7 +231,7 @@ static odp_buffer_hdr_t *queue_lf_deq(void *q_int) uint64_t lowest, counter; odp_buffer_hdr_t *buf_hdr; - queue = q_int; + queue = qentry_from_handle(handle); queue_lf = queue->s.queue_lf; new_val.s.counter = 0; new_val.s.ptr = 0; @@ -287,14 +287,14 @@ static odp_buffer_hdr_t *queue_lf_deq(void *q_int) return NULL; } -static int queue_lf_deq_multi(void *q_int, odp_buffer_hdr_t **buf_hdr, +static int queue_lf_deq_multi(odp_queue_t handle, odp_buffer_hdr_t **buf_hdr, int num) { odp_buffer_hdr_t *buf; (void)num; - buf = queue_lf_deq(q_int); + buf = queue_lf_deq(handle); if (buf == NULL) return 0; diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c index 3ca865b05..5ac0c196a 100644 --- a/platform/linux-generic/odp_queue_scalable.c +++ b/platform/linux-generic/odp_queue_scalable.c @@ -54,12 +54,11 @@ typedef struct queue_table_t { static queue_table_t *queue_tbl; static _odp_ishm_pool_t *queue_shm_pool; -static void *queue_from_ext(odp_queue_t handle); -static int _queue_enq(void *handle, odp_buffer_hdr_t *buf_hdr); -static odp_buffer_hdr_t *_queue_deq(void *handle); -static int _queue_enq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], +static int _queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr); +static odp_buffer_hdr_t *_queue_deq(odp_queue_t handle); +static int _queue_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num); -static int _queue_deq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], +static int _queue_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num); static queue_entry_t *get_qentry(uint32_t queue_id) @@ -610,7 +609,7 @@ int _odp_queue_enq_sp(sched_elem_t *q, return actual; } -static int _queue_enq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], +static int _queue_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { int actual; @@ -646,7 +645,7 @@ static int _queue_enq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], return actual; } -static int _queue_enq(void *handle, odp_buffer_hdr_t *buf_hdr) +static int _queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { return odp_likely( _queue_enq_multi(handle, &buf_hdr, 1) == 1) ? 0 : -1; @@ -666,7 +665,7 @@ static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) for (i = 0; i < num; i++) buf_hdr[i] = buf_hdl_to_hdr(odp_buffer_from_event(ev[i])); - return queue->s.enqueue_multi(qentry_to_int(queue), buf_hdr, num); + return queue->s.enqueue_multi(handle, buf_hdr, num); } static int queue_enq(odp_queue_t handle, odp_event_t ev) @@ -677,7 +676,7 @@ static int queue_enq(odp_queue_t handle, odp_event_t ev) queue = qentry_from_ext(handle); buf_hdr = buf_hdl_to_hdr(odp_buffer_from_event(ev)); - return queue->s.enqueue(qentry_to_int(queue), buf_hdr); + return queue->s.enqueue(handle, buf_hdr); } /* Single-consumer dequeue. */ @@ -809,7 +808,7 @@ inline int _odp_queue_deq_mc(sched_elem_t *q, odp_event_t *evp, int num) return ret; } -static int _queue_deq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], +static int _queue_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { sched_elem_t *q; @@ -820,7 +819,7 @@ static int _queue_deq_multi(void *handle, odp_buffer_hdr_t *buf_hdr[], return _odp_queue_deq(q, buf_hdr, num); } -static odp_buffer_hdr_t *_queue_deq(void *handle) +static odp_buffer_hdr_t *_queue_deq(odp_queue_t handle) { sched_elem_t *q; odp_buffer_hdr_t *buf_hdr; @@ -842,7 +841,7 @@ static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) num = QUEUE_MULTI_MAX; queue = qentry_from_ext(handle); - return queue->s.dequeue_multi(qentry_to_int(queue), (odp_buffer_hdr_t **)ev, num); + return queue->s.dequeue_multi(handle, (odp_buffer_hdr_t **)ev, num); } static odp_event_t queue_deq(odp_queue_t handle) @@ -850,7 +849,7 @@ static odp_event_t queue_deq(odp_queue_t handle) queue_entry_t *queue; queue = qentry_from_ext(handle); - return (odp_event_t)queue->s.dequeue(qentry_to_int(queue)); + return (odp_event_t)queue->s.dequeue(handle); } static void queue_param_init(odp_queue_param_t *params) @@ -909,29 +908,29 @@ static uint64_t queue_to_u64(odp_queue_t hdl) return _odp_pri(hdl); } -static odp_pktout_queue_t queue_get_pktout(void *handle) +static odp_pktout_queue_t queue_get_pktout(odp_queue_t handle) { return qentry_from_int(handle)->s.pktout; } -static void queue_set_pktout(void *handle, odp_pktio_t pktio, int index) +static void queue_set_pktout(odp_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(void *handle) +static odp_pktin_queue_t queue_get_pktin(odp_queue_t handle) { return qentry_from_int(handle)->s.pktin; } -static void queue_set_pktin(void *handle, odp_pktio_t pktio, int index) +static void queue_set_pktin(odp_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_deq_func(void *handle, +static void queue_set_enq_deq_func(odp_queue_t handle, queue_enq_fn_t enq, queue_enq_multi_fn_t enq_multi, queue_deq_fn_t deq, @@ -950,16 +949,6 @@ static void queue_set_enq_deq_func(void *handle, qentry_from_int(handle)->s.dequeue_multi = deq_multi; } -static void *queue_from_ext(odp_queue_t handle) -{ - return (void *)handle; -} - -static odp_queue_t queue_to_ext(void *handle) -{ - return (odp_queue_t)handle; -} - /* API functions */ _odp_queue_api_fn_t queue_scalable_api = { .queue_create = queue_create, @@ -987,8 +976,6 @@ queue_fn_t queue_scalable_fn = { .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, diff --git a/platform/linux-generic/odp_queue_spsc.c b/platform/linux-generic/odp_queue_spsc.c index 3e42b0383..2dcc3d935 100644 --- a/platform/linux-generic/odp_queue_spsc.c +++ b/platform/linux-generic/odp_queue_spsc.c @@ -32,14 +32,14 @@ static inline void buffer_index_to_buf(odp_buffer_hdr_t *buf_hdr[], } } -static inline int spsc_enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], - int num) +static inline int spsc_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { queue_entry_t *queue; ring_spsc_t *ring_spsc; uint32_t buf_idx[num]; - queue = q_int; + queue = qentry_from_handle(handle); ring_spsc = &queue->s.ring_spsc; buffer_index_from_buf(buf_idx, buf_hdr, num); @@ -52,15 +52,15 @@ static inline int spsc_enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], return ring_spsc_enq_multi(ring_spsc, buf_idx, num); } -static inline int spsc_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], - int num) +static inline int spsc_deq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { queue_entry_t *queue; int num_deq; ring_spsc_t *ring_spsc; uint32_t buf_idx[num]; - queue = q_int; + queue = qentry_from_handle(handle); ring_spsc = &queue->s.ring_spsc; if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { @@ -78,17 +78,17 @@ static inline int spsc_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], return num_deq; } -static int queue_spsc_enq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], +static int queue_spsc_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { - return spsc_enq_multi(q_int, buf_hdr, num); + return spsc_enq_multi(handle, buf_hdr, num); } -static int queue_spsc_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) +static int queue_spsc_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { int ret; - ret = spsc_enq_multi(q_int, &buf_hdr, 1); + ret = spsc_enq_multi(handle, &buf_hdr, 1); if (ret == 1) return 0; @@ -96,18 +96,18 @@ static int queue_spsc_enq(void *q_int, odp_buffer_hdr_t *buf_hdr) return -1; } -static int queue_spsc_deq_multi(void *q_int, odp_buffer_hdr_t *buf_hdr[], +static int queue_spsc_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { - return spsc_deq_multi(q_int, buf_hdr, num); + return spsc_deq_multi(handle, buf_hdr, num); } -static odp_buffer_hdr_t *queue_spsc_deq(void *q_int) +static odp_buffer_hdr_t *queue_spsc_deq(odp_queue_t handle) { odp_buffer_hdr_t *buf_hdr = NULL; int ret; - ret = spsc_deq_multi(q_int, &buf_hdr, 1); + ret = spsc_deq_multi(handle, &buf_hdr, 1); if (ret == 1) return buf_hdr; diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index df63da72a..345bf2b02 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -103,7 +103,7 @@ ODP_STATIC_ASSERT((8 * sizeof(pri_mask_t)) >= MAX_SPREAD, /* Storage for stashed enqueue operation arguments */ typedef struct { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; - queue_entry_t *queue_entry; + odp_queue_t queue; int num; } ordered_stash_t; @@ -661,15 +661,15 @@ static inline void ordered_stash_release(void) int i; for (i = 0; i < sched_local.ordered.stash_num; i++) { - queue_entry_t *queue_entry; + odp_queue_t queue; odp_buffer_hdr_t **buf_hdr; int num, num_enq; - queue_entry = sched_local.ordered.stash[i].queue_entry; + queue = sched_local.ordered.stash[i].queue; buf_hdr = sched_local.ordered.stash[i].buf_hdr; num = sched_local.ordered.stash[i].num; - num_enq = queue_fn->enq_multi(queue_entry, buf_hdr, num); + num_enq = queue_fn->enq_multi(queue, buf_hdr, num); /* Drop packets that were not enqueued */ if (odp_unlikely(num_enq < num)) { @@ -744,12 +744,12 @@ static inline int copy_from_stash(odp_event_t out_ev[], unsigned int max) return i; } -static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], +static int schedule_ord_enq_multi(odp_queue_t dst_queue, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = sched_local.ordered.stash_num; - queue_entry_t *dst_queue = q_int; + queue_entry_t *dst_qentry = qentry_from_handle(dst_queue); uint32_t src_queue = sched_local.ordered.src_queue; if ((src_queue == NULL_INDEX) || sched_local.ordered.in_order) @@ -763,7 +763,7 @@ static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], } /* Pktout may drop packets, so the operation cannot be stashed. */ - if (dst_queue->s.pktout.pktio != ODP_PKTIO_INVALID || + if (dst_qentry->s.pktout.pktio != ODP_PKTIO_INVALID || odp_unlikely(stash_num >= MAX_ORDERED_STASH)) { /* If the local stash is full, wait until it is our turn and * then release the stash and do enqueue directly. */ @@ -775,7 +775,7 @@ static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], return 0; } - sched_local.ordered.stash[stash_num].queue_entry = dst_queue; + sched_local.ordered.stash[stash_num].queue = dst_queue; 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]; diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 2501a3f68..515e556df 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -171,7 +171,7 @@ typedef struct { /* Storage for stashed enqueue operation arguments */ typedef struct { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; - queue_entry_t *queue_entry; + odp_queue_t queue; int num; } ordered_stash_t; @@ -1132,15 +1132,15 @@ static inline void ordered_stash_release(void) int i; for (i = 0; i < thread_local.ordered.stash_num; i++) { - queue_entry_t *queue_entry; + odp_queue_t queue; odp_buffer_hdr_t **buf_hdr; int num, num_enq; - queue_entry = thread_local.ordered.stash[i].queue_entry; + queue = thread_local.ordered.stash[i].queue; buf_hdr = thread_local.ordered.stash[i].buf_hdr; num = thread_local.ordered.stash[i].num; - num_enq = queue_fn->enq_multi(queue_entry, buf_hdr, num); + num_enq = queue_fn->enq_multi(queue, buf_hdr, num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) @@ -1200,12 +1200,12 @@ static inline void schedule_release_context(void) schedule_release_atomic(); } -static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], +static int schedule_ord_enq_multi(odp_queue_t dst_queue, void *buf_hdr[], int num, int *ret) { int i; uint32_t stash_num = thread_local.ordered.stash_num; - queue_entry_t *dst_queue = q_int; + queue_entry_t *dst_qentry = qentry_from_handle(dst_queue); uint32_t src_queue = thread_local.ordered.src_queue; if ((src_queue == NULL_INDEX) || thread_local.ordered.in_order) @@ -1219,7 +1219,7 @@ static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], } /* Pktout may drop packets, so the operation cannot be stashed. */ - if (dst_queue->s.pktout.pktio != ODP_PKTIO_INVALID || + if (dst_qentry->s.pktout.pktio != ODP_PKTIO_INVALID || odp_unlikely(stash_num >= MAX_ORDERED_STASH)) { /* If the local stash is full, wait until it is our turn and * then release the stash and do enqueue directly. */ @@ -1231,7 +1231,7 @@ static int schedule_ord_enq_multi(void *q_int, void *buf_hdr[], return 0; } - thread_local.ordered.stash[stash_num].queue_entry = dst_queue; + thread_local.ordered.stash[stash_num].queue = dst_queue; 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]; diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c index 826747ee1..9acb997a1 100644 --- a/platform/linux-generic/odp_schedule_scalable.c +++ b/platform/linux-generic/odp_schedule_scalable.c @@ -2007,7 +2007,7 @@ static int sched_queue(uint32_t queue_index) return 0; } -static int ord_enq_multi(void *handle, void *buf_hdr[], int num, +static int ord_enq_multi(odp_queue_t handle, void *buf_hdr[], int num, int *ret) { diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index ae292051b..7932e1860 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -415,10 +415,10 @@ static int sched_queue(uint32_t qi) return 0; } -static int ord_enq_multi(void *q_int, void *buf_hdr[], int num, +static int ord_enq_multi(odp_queue_t queue, void *buf_hdr[], int num, int *ret) { - (void)q_int; + (void)queue; (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 af403b4b6..bc5bdd046 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -108,20 +108,20 @@ 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(void *queue, odp_buffer_hdr_t *buf_hdr) +static int queue_tm_reenq(odp_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, - tm_qentry)); + odp_tm_queue_t tm_queue = MAKE_ODP_TM_QUEUE(odp_queue_context(queue)); odp_packet_t pkt = packet_from_buf_hdr(buf_hdr); return odp_tm_enq(tm_queue, pkt); } -static int queue_tm_reenq_multi(void *queue ODP_UNUSED, - odp_buffer_hdr_t *buf[] ODP_UNUSED, - int num ODP_UNUSED) +static int queue_tm_reenq_multi(odp_queue_t queue, odp_buffer_hdr_t *buf[], + int num) { + (void)queue; + (void)buf; + (void)num; ODP_ABORT("Invalid call to queue_tm_reenq_multi()\n"); return 0; } @@ -3936,8 +3936,10 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm, free(tm_queue_obj); return ODP_TM_INVALID; } - tm_queue_obj->tm_qentry = queue_fn->from_ext(queue); - queue_fn->set_enq_deq_fn(tm_queue_obj->tm_qentry, + + tm_queue_obj->queue = queue; + odp_queue_context_set(queue, tm_queue_obj, sizeof(tm_queue_obj_t)); + queue_fn->set_enq_deq_fn(queue, queue_tm_reenq, queue_tm_reenq_multi, NULL, NULL); @@ -4011,7 +4013,7 @@ 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)); + odp_queue_destroy(tm_queue_obj->queue); /* First delete any associated tm_wred_node and then the tm_queue_obj * itself */ diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index faaef3ab5..3af359eb2 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -93,7 +93,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]; - void *queue; + odp_queue_t queue; odp_packet_hdr_t *pkt_hdr; odp_packet_t pkt; odp_time_t ts_val; @@ -106,7 +106,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.rxl); - queue = queue_fn->from_ext(pkt_priv(pktio_entry)->loopq); + queue = pkt_priv(pktio_entry)->loopq; nbr = queue_fn->deq_multi(queue, hdr_tbl, num); if (pktio_entry->s.config.pktin.bit.ts_all || @@ -274,7 +274,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_tbl[], int num) { odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; - void *queue; + odp_queue_t queue; int i; int ret; int nb_tx = 0; @@ -324,7 +324,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.txl); - queue = queue_fn->from_ext(pkt_priv(pktio_entry)->loopq); + queue = pkt_priv(pktio_entry)->loopq; ret = queue_fn->enq_multi(queue, hdr_tbl, nb_tx); if (ret > 0) { From patchwork Fri Aug 17 13:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144485 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp755384ljj; Fri, 17 Aug 2018 06:07:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzdMGHb/OTzgYucIrhG98tgpK6wvgv0kMA1fW63fIlQxSMx6VS6pbwgvt9TI02xILbDkIcW X-Received: by 2002:ac8:34f1:: with SMTP id x46-v6mr1452984qtb.115.1534511275727; Fri, 17 Aug 2018 06:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534511275; cv=none; d=google.com; s=arc-20160816; b=zDEPEDZWmB5QLqdRGYR5IP4h6J+NtwKLGUDFUWU4P/YVTxCyIsB//FOrZheckY/sRA Iqmyb4Kx2P1JtWAvwzHh5DXS0Ry0IXud8DT+VR2cWyQlTrlWzgI+7g0wY/VLXXn4u99F 5BdQ6WhqVBprzixgTT4tH6K/jBMGNcm8w4u8SCfD7rrLCkWfwodsC+UlhKIQdWpz7ASB 0fN6AbUSsojT2jcmRz+dBqHGmUhGfnrWEIgUtyvR4CDWCeIeVZ1qA95xyCHhrJ8ChpaK EfwEhTJMjcEAI532Ib0vEFdOOA5qOTAnW83hzX3Z1ryfYjbIFPJUMBmKwfb90SqhpIwt P29Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=lB49rLV0FxflVO03UNHIoTDNV5JaU+y+RJt1WdApkfU=; b=HiLYNoMf4FCLsM7ip6YwYHSFzhnlRNnHCNIEh4UoNCmznJfoCoytkxdOTPhek4qq6v BujPtJhlS1WN+4mKOPSJwc5VazgnWWS89DiAq6hPdYp5JEcCbzGX7cysTH31mAxWwSUu hzJuFWLzPgSLlZo6n64pJ+YKnAnnp82DbBU+lmxMbh5sZYwViG91KwaVYrFz6KaRwLVt i/FGrfJwuDq2IEUWkk3F7pXeHMRpwk33lkkqzAPOO1+RGHCtnuNzP+wTNwZla+iyXDRV qUHdinOC/+TCH2j/R8/fbsl222FIIWe6pCte8/Mz2+iVgpm+evclxbiFaHOFG0WpKJmm jY0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id 21-v6si1984198qts.164.2018.08.17.06.07.55; Fri, 17 Aug 2018 06:07:55 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5CA29685E0; Fri, 17 Aug 2018 13:07:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 92714685FF; Fri, 17 Aug 2018 13:01:11 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0647860F5B; Fri, 17 Aug 2018 13:00:28 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id A5F0060981 for ; Fri, 17 Aug 2018 13:00:18 +0000 (UTC) Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 780B743049 for ; Fri, 17 Aug 2018 16:00:13 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback11g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id MYQjyKW0xX-0DKKocR8; Fri, 17 Aug 2018 16:00:13 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-0Cqqaufh; Fri, 17 Aug 2018 16:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:05 +0000 Message-Id: <1534510807-11066-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 4/6] linux-gen: queue: remove enq/deq from queue interface X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Use inlined queue enqueue and dequeue functions instead of internal interface versions. Removed functions from internal interface. Original dequeue multi call remains for overriding dequeue calls (e.g. packet input overrides queue dequeue function but uses the original queue). Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ .../include/odp_buffer_internal.h | 5 -- .../include/odp_queue_basic_internal.h | 1 + platform/linux-generic/include/odp_queue_if.h | 8 +-- .../include/odp_queue_scalable_internal.h | 1 + platform/linux-generic/odp_crypto_null.c | 1 + platform/linux-generic/odp_crypto_openssl.c | 1 + platform/linux-generic/odp_ipsec.c | 1 + platform/linux-generic/odp_ipsec_events.c | 1 + platform/linux-generic/odp_packet_io.c | 67 ++++++------------- platform/linux-generic/odp_queue_basic.c | 30 ++++++--- platform/linux-generic/odp_queue_scalable.c | 15 +++-- platform/linux-generic/odp_queue_spsc.c | 1 + platform/linux-generic/odp_schedule_basic.c | 6 +- platform/linux-generic/odp_schedule_iquery.c | 4 +- platform/linux-generic/odp_timer.c | 1 + platform/linux-generic/pktio/loop.c | 5 +- 16 files changed, 71 insertions(+), 77 deletions(-) diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 48e74dd21..c6e1345d8 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -120,11 +120,6 @@ static inline odp_buffer_t buf_from_buf_hdr(odp_buffer_hdr_t *hdr) return (odp_buffer_t)hdr; } -static inline odp_event_t event_from_buf_hdr(odp_buffer_hdr_t *hdr) -{ - return (odp_event_t)hdr; -} - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/include/odp_queue_basic_internal.h b/platform/linux-generic/include/odp_queue_basic_internal.h index 369eb19a1..15e49772c 100644 --- a/platform/linux-generic/include/odp_queue_basic_internal.h +++ b/platform/linux-generic/include/odp_queue_basic_internal.h @@ -44,6 +44,7 @@ struct queue_entry_s { queue_deq_fn_t dequeue; queue_enq_multi_fn_t enqueue_multi; queue_deq_multi_fn_t dequeue_multi; + queue_deq_multi_fn_t orig_dequeue_multi; uint32_t index; odp_queue_t handle; diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 7c7649219..6ec7e24c2 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -46,15 +46,15 @@ typedef struct { queue_term_global_fn_t term_global; queue_init_local_fn_t init_local; queue_term_local_fn_t term_local; - 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_deq_fn_t set_enq_deq_fn; + + /* Original queue dequeue multi function (before override). May be used + * by an overriding dequeue function. */ + queue_deq_multi_fn_t orig_deq_multi; } queue_fn_t; extern const queue_fn_t *queue_fn; diff --git a/platform/linux-generic/include/odp_queue_scalable_internal.h b/platform/linux-generic/include/odp_queue_scalable_internal.h index cc5b52191..05932a36a 100644 --- a/platform/linux-generic/include/odp_queue_scalable_internal.h +++ b/platform/linux-generic/include/odp_queue_scalable_internal.h @@ -41,6 +41,7 @@ struct queue_entry_s { queue_deq_fn_t dequeue; queue_enq_multi_fn_t enqueue_multi; queue_deq_multi_fn_t dequeue_multi; + queue_deq_multi_fn_t orig_dequeue_multi; uint32_t index; odp_queue_t handle; diff --git a/platform/linux-generic/odp_crypto_null.c b/platform/linux-generic/odp_crypto_null.c index 7d01f10eb..13aae9bc3 100644 --- a/platform/linux-generic/odp_crypto_null.c +++ b/platform/linux-generic/odp_crypto_null.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Inlined API functions */ #include diff --git a/platform/linux-generic/odp_crypto_openssl.c b/platform/linux-generic/odp_crypto_openssl.c index ecab6bd08..d98c87b00 100644 --- a/platform/linux-generic/odp_crypto_openssl.c +++ b/platform/linux-generic/odp_crypto_openssl.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Inlined API functions */ #include diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 36bea6cf8..d10100f53 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/platform/linux-generic/odp_ipsec_events.c b/platform/linux-generic/odp_ipsec_events.c index e39776492..ea9ce961b 100644 --- a/platform/linux-generic/odp_ipsec_events.c +++ b/platform/linux-generic/odp_ipsec_events.c @@ -17,6 +17,7 @@ /* Inlined API functions */ #include +#include typedef struct { /* common buffer header */ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index a10aaf10c..6f99bf10c 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -625,7 +626,8 @@ static inline int pktin_recv_buf(pktio_entry_t *entry, int pktin_index, if (pkt_hdr->p.input_flags.dst_queue) { int ret; - ret = queue_fn->enq(pkt_hdr->dst_queue, buf_hdr); + ret = odp_queue_enq(pkt_hdr->dst_queue, + odp_packet_to_event(pkt)); if (ret < 0) odp_packet_free(pkt); continue; @@ -675,8 +677,7 @@ static odp_buffer_hdr_t *pktin_dequeue(odp_queue_t queue) int pktin_index = pktin_queue.index; pktio_entry_t *entry = get_pktio_entry(pktio); - buf_hdr = queue_fn->deq(queue); - if (buf_hdr != NULL) + if (queue_fn->orig_deq_multi(queue, &buf_hdr, 1) == 1) return buf_hdr; pkts = pktin_recv_buf(entry, pktin_index, hdr_tbl, QUEUE_MULTI_MAX); @@ -688,7 +689,8 @@ static odp_buffer_hdr_t *pktin_dequeue(odp_queue_t queue) int num_enq; int num = pkts - 1; - num_enq = queue_fn->enq_multi(queue, &hdr_tbl[1], num); + num_enq = odp_queue_enq_multi(queue, + (odp_event_t *)&hdr_tbl[1], num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) @@ -715,7 +717,7 @@ static int pktin_deq_multi(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr[], int pktin_index = pktin_queue.index; pktio_entry_t *entry = get_pktio_entry(pktio); - nbr = queue_fn->deq_multi(queue, buf_hdr, num); + nbr = queue_fn->orig_deq_multi(queue, buf_hdr, num); if (odp_unlikely(nbr > num)) ODP_ABORT("queue_deq_multi req: %d, returned %d\n", num, nbr); @@ -740,7 +742,7 @@ static int pktin_deq_multi(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr[], if (j) { int num_enq; - num_enq = queue_fn->enq_multi(queue, hdr_tbl, j); + num_enq = odp_queue_enq_multi(queue, (odp_event_t *)hdr_tbl, j); if (odp_unlikely(num_enq < j)) { if (odp_unlikely(num_enq < 0)) @@ -785,9 +787,14 @@ int sched_cb_pktin_poll_one(int pktio_index, pkt = packets[i]; pkt_hdr = packet_hdr(pkt); if (odp_unlikely(pkt_hdr->p.input_flags.dst_queue)) { + int num_enq; + queue = pkt_hdr->dst_queue; buf_hdr = packet_to_buf_hdr(pkt); - if (queue_fn->enq_multi(queue, &buf_hdr, 1) < 0) { + num_enq = odp_queue_enq_multi(queue, + (odp_event_t *)&buf_hdr, + 1); + if (num_enq < 0) { /* Queue full? */ odp_packet_free(pkt); __atomic_fetch_add(&entry->s.stats.in_discards, @@ -851,7 +858,8 @@ int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int index[]) } queue = entry->s.in_queue[index[idx]].queue; - num_enq = queue_fn->enq_multi(queue, hdr_tbl, num); + num_enq = odp_queue_enq_multi(queue, + (odp_event_t *)hdr_tbl, num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) @@ -1371,41 +1379,6 @@ int odp_pktio_stats_reset(odp_pktio_t pktio) return ret; } -static int abort_pktin_enqueue(odp_queue_t queue, odp_buffer_hdr_t *buf_hdr) -{ - (void)queue; - (void)buf_hdr; - ODP_ABORT("attempted enqueue to a pktin queue"); - return -1; -} - -static int abort_pktin_enq_multi(odp_queue_t queue, - odp_buffer_hdr_t *buf_hdr[], int num) -{ - (void)queue; - (void)buf_hdr; - (void)num; - ODP_ABORT("attempted enqueue to a pktin queue"); - return 0; -} - -static odp_buffer_hdr_t *abort_pktout_dequeue(odp_queue_t queue) -{ - (void)queue; - ODP_ABORT("attempted dequeue from a pktout queue"); - return NULL; -} - -static int abort_pktout_deq_multi(odp_queue_t queue, - odp_buffer_hdr_t *buf_hdr[], int num) -{ - (void)queue; - (void)buf_hdr; - (void)num; - 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) { @@ -1498,8 +1471,8 @@ int odp_pktin_queue_config(odp_pktio_t pktio, if (mode == ODP_PKTIN_MODE_QUEUE) { queue_fn->set_pktin(queue, pktio, i); queue_fn->set_enq_deq_fn(queue, - abort_pktin_enqueue, - abort_pktin_enq_multi, + NULL, + NULL, pktin_dequeue, pktin_deq_multi); } @@ -1624,8 +1597,8 @@ int odp_pktout_queue_config(odp_pktio_t pktio, queue_fn->set_enq_deq_fn(queue, pktout_enqueue, pktout_enq_multi, - abort_pktout_dequeue, - abort_pktout_deq_multi); + NULL, + NULL); entry->s.out_queue[i].queue = queue; } diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index 2b3b6dfc4..a881766a7 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -305,9 +305,9 @@ static odp_queue_t queue_create(const char *name, if (!queue->s.spsc && param->nonblocking == ODP_NONBLOCKING_LF) { - queue_lf_func_t *lf_func; + queue_lf_func_t *lf_fn; - lf_func = &queue_glb->queue_lf_func; + lf_fn = &queue_glb->queue_lf_func; queue_lf = queue_lf_create(queue); @@ -317,10 +317,11 @@ static odp_queue_t queue_create(const char *name, } queue->s.queue_lf = queue_lf; - queue->s.enqueue = lf_func->enq; - queue->s.enqueue_multi = lf_func->enq_multi; - queue->s.dequeue = lf_func->deq; - queue->s.dequeue_multi = lf_func->deq_multi; + queue->s.enqueue = lf_fn->enq; + queue->s.enqueue_multi = lf_fn->enq_multi; + queue->s.dequeue = lf_fn->deq; + queue->s.dequeue_multi = lf_fn->deq_multi; + queue->s.orig_dequeue_multi = lf_fn->deq_multi; } type = queue->s.type; @@ -697,6 +698,8 @@ static int queue_init(queue_entry_t *queue, const char *name, queue->s.enqueue_multi = queue_int_enq_multi; queue->s.dequeue_multi = queue_int_deq_multi; + queue->s.orig_dequeue_multi = queue_int_deq_multi; + ring_st_init(&queue->s.ring_st, &queue_glb->ring_data[offset], queue_size); } @@ -883,6 +886,14 @@ static void queue_set_enq_deq_func(odp_queue_t handle, qentry->s.dequeue_multi = deq_multi; } +static int queue_orig_multi(odp_queue_t handle, + odp_buffer_hdr_t **buf_hdr, int num) +{ + queue_entry_t *queue = qentry_from_handle(handle); + + return queue->s.orig_dequeue_multi(handle, buf_hdr, num); +} + /* API functions */ _odp_queue_api_fn_t queue_basic_api = { .queue_create = queue_create, @@ -910,13 +921,10 @@ queue_fn_t queue_basic_fn = { .term_global = queue_term_global, .init_local = queue_init_local, .term_local = queue_term_local, - .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, .set_pktin = queue_set_pktin, - .set_enq_deq_fn = queue_set_enq_deq_func + .set_enq_deq_fn = queue_set_enq_deq_func, + .orig_deq_multi = queue_orig_multi }; diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/odp_queue_scalable.c index 5ac0c196a..bbc57e44d 100644 --- a/platform/linux-generic/odp_queue_scalable.c +++ b/platform/linux-generic/odp_queue_scalable.c @@ -128,6 +128,7 @@ static int queue_init(queue_entry_t *queue, const char *name, queue->s.dequeue = _queue_deq; queue->s.enqueue_multi = _queue_enq_multi; queue->s.dequeue_multi = _queue_deq_multi; + queue->s.orig_dequeue_multi = _queue_deq_multi; queue->s.pktin = PKTIN_INVALID; sched_elem->node.next = NULL; @@ -949,6 +950,13 @@ static void queue_set_enq_deq_func(odp_queue_t handle, qentry_from_int(handle)->s.dequeue_multi = deq_multi; } +static int queue_orig_multi(odp_queue_t handle, + odp_buffer_hdr_t **buf_hdr, int num) +{ + return qentry_from_int(handle)->s.orig_dequeue_multi(handle, + buf_hdr, num); +} + /* API functions */ _odp_queue_api_fn_t queue_scalable_api = { .queue_create = queue_create, @@ -976,13 +984,10 @@ queue_fn_t queue_scalable_fn = { .term_global = queue_term_global, .init_local = queue_init_local, .term_local = queue_term_local, - .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_deq_fn = queue_set_enq_deq_func + .set_enq_deq_fn = queue_set_enq_deq_func, + .orig_deq_multi = queue_orig_multi }; diff --git a/platform/linux-generic/odp_queue_spsc.c b/platform/linux-generic/odp_queue_spsc.c index 2dcc3d935..0fd8d85a7 100644 --- a/platform/linux-generic/odp_queue_spsc.c +++ b/platform/linux-generic/odp_queue_spsc.c @@ -123,6 +123,7 @@ void queue_spsc_init(queue_entry_t *queue, uint32_t queue_size) queue->s.dequeue = queue_spsc_deq; queue->s.enqueue_multi = queue_spsc_enq_multi; queue->s.dequeue_multi = queue_spsc_deq_multi; + queue->s.orig_dequeue_multi = queue_spsc_deq_multi; offset = queue->s.index * (uint64_t)queue_glb->config.max_queue_size; diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index 345bf2b02..e329a8e8c 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -28,6 +28,7 @@ #include #include #include +#include /* Number of priority levels */ #define NUM_PRIO 8 @@ -669,7 +670,8 @@ static inline void ordered_stash_release(void) buf_hdr = sched_local.ordered.stash[i].buf_hdr; num = sched_local.ordered.stash[i].num; - num_enq = queue_fn->enq_multi(queue, buf_hdr, num); + num_enq = odp_queue_enq_multi(queue, + (odp_event_t *)buf_hdr, num); /* Drop packets that were not enqueued */ if (odp_unlikely(num_enq < num)) { @@ -839,7 +841,7 @@ static inline int poll_pktin(uint32_t qi, int direct_recv, q_int = qentry_from_index(qi); - ret = queue_fn->enq_multi(q_int, b_hdr, num); + ret = odp_queue_enq_multi(q_int, (odp_event_t *)b_hdr, num); /* Drop packets that were not enqueued */ if (odp_unlikely(ret < num)) { diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 515e556df..7dde77844 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Number of priority levels */ #define NUM_SCHED_PRIO 8 @@ -1140,7 +1141,8 @@ static inline void ordered_stash_release(void) buf_hdr = thread_local.ordered.stash[i].buf_hdr; num = thread_local.ordered.stash[i].num; - num_enq = queue_fn->enq_multi(queue, buf_hdr, num); + num_enq = odp_queue_enq_multi(queue, + (odp_event_t *)buf_hdr, num); if (odp_unlikely(num_enq < num)) { if (odp_unlikely(num_enq < 0)) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 716571ca0..0d2ecd271 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -56,6 +56,7 @@ #include #include #include +#include /* Inlined API functions */ #include diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 3af359eb2..2d8b843d6 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -107,7 +108,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.rxl); queue = pkt_priv(pktio_entry)->loopq; - nbr = queue_fn->deq_multi(queue, hdr_tbl, num); + nbr = odp_queue_deq_multi(queue, (odp_event_t *)hdr_tbl, num); if (pktio_entry->s.config.pktin.bit.ts_all || pktio_entry->s.config.pktin.bit.ts_ptp) { @@ -325,7 +326,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.txl); queue = pkt_priv(pktio_entry)->loopq; - ret = queue_fn->enq_multi(queue, hdr_tbl, nb_tx); + ret = odp_queue_enq_multi(queue, (odp_event_t *)hdr_tbl, nb_tx); if (ret > 0) { pktio_entry->s.stats.out_ucast_pkts += ret; From patchwork Fri Aug 17 13:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144481 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp748435ljj; Fri, 17 Aug 2018 06:02:45 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz/IIQLpWGSLV6xnDjqhC71zWAWf/+XcJXe5Lo8s5Rbdu2ptPdcceH4707ZXYbogfysW+Mm X-Received: by 2002:a0c:9408:: with SMTP id h8-v6mr31050444qvh.135.1534510965606; Fri, 17 Aug 2018 06:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534510965; cv=none; d=google.com; s=arc-20160816; b=uWCXTyHMNuQ1FwGesX7LgRmCyqM19o2PlfiM0CBi1CA8SCu+WbTpIpx2uPl1OMotjr w2GEfO4QFj0WqVZDr0Q6Jdhq5lJ1VwgxQFtSSd1cXTVvaGEAz1ssD+5FGN6BeOk1940T 3r1t2ME8j6pPOZYx5NDPn0b8cLRGshyOPcEnYV4M8RQzdhN+K7WO6bQevcPjwPi9hswj P15k4y4RDr09Cl6fiwwGLpv54beZ+mGVZ6F5FS+Cdp28K8AMgFdXWZog3gLX2WA2CVHJ /n77opl3rHg1kazvOsZBxjv4BVMS/sOFGLZUgMhywKxqksfE6L28ylv1jr11nlSSxQ0S zRUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=70s4dWWaNDWBahHVz+iXPT4mFh0HL7V/aiOMJApi2EY=; b=RFkUPLDgo1SGsRaLbyxHewBZBzcRjIqTrIK9Pj1eYcV6mu5Gqmy6hJwwj9NtemCAlo pb4jQziY5PYPT1mkFyT/xr64/8x3xluOxP94EBU8Jat19xdbnEZkjweEgIwQyJ+IAV+4 q7uV9DxPMWseQBRsGl9Vvow8fzwg14TvXGbPNvXzPzFQy03R9ZpA94NoUsJezlGl9PEV AIu+nLPjTdZiY9G6gpnSrX+PscA1Elafnln20knAMePA7TRIx8l9iUO4bPoLKahX1eSr TI+G8wkcRpfCHAtSAjaPE6343XO2KcazoR+XU1o6g4cYd/fK6/P/rb/KT3dK0UlcN3RA SaWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id y5-v6si1939270qkb.239.2018.08.17.06.02.45; Fri, 17 Aug 2018 06:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 3959D68658; Fri, 17 Aug 2018 13:02:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 32C5561849; Fri, 17 Aug 2018 13:00:39 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id CAD0B61849; Fri, 17 Aug 2018 13:00:21 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 2FE4F609AA for ; Fri, 17 Aug 2018 13:00:16 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 94D5A4087A27 for ; Fri, 17 Aug 2018 16:00:14 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id gCeAtLgRei-0Ei0tDTT; Fri, 17 Aug 2018 16:00:14 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-0Dq0rfHV; Fri, 17 Aug 2018 16:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:06 +0000 Message-Id: <1534510807-11066-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 5/6] linux-gen: queue: prepare for separate queue operations X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Prepare for separate plain and scheduled queue enqueue and dequeue operations. Plain queue enq/deq operations will be simplified and scheduled queues do not have dequeue functions (error functions instead). Enqueue/dequeue functionality is not changed yet, functions are only renamed and moved. Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ platform/linux-generic/odp_queue_basic.c | 293 ++++++++++++++--------- 1 file changed, 184 insertions(+), 109 deletions(-) diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index a881766a7..d2de677df 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -485,8 +485,8 @@ static inline void buffer_index_to_buf(odp_buffer_hdr_t *buf_hdr[], } } -static inline int enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num) +static inline int _sched_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { int sched = 0; int ret; @@ -532,17 +532,17 @@ static inline int enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], return num_enq; } -static int queue_int_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num) +static int plain_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { - return enq_multi(handle, buf_hdr, num); + return _sched_queue_enq_multi(handle, buf_hdr, num); } -static int queue_int_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) +static int plain_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { int ret; - ret = enq_multi(handle, &buf_hdr, 1); + ret = _sched_queue_enq_multi(handle, &buf_hdr, 1); if (ret == 1) return 0; @@ -550,30 +550,8 @@ static int queue_int_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) return -1; } -static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) -{ - queue_entry_t *queue = qentry_from_handle(handle); - - if (odp_unlikely(num == 0)) - return 0; - - if (num > QUEUE_MULTI_MAX) - num = QUEUE_MULTI_MAX; - - return queue->s.enqueue_multi(handle, - (odp_buffer_hdr_t **)(uintptr_t)ev, num); -} - -static int queue_enq(odp_queue_t handle, odp_event_t ev) -{ - queue_entry_t *queue = qentry_from_handle(handle); - - return queue->s.enqueue(handle, - (odp_buffer_hdr_t *)(uintptr_t)ev); -} - -static inline int plain_queue_deq(odp_queue_t handle, - odp_buffer_hdr_t *buf_hdr[], int num) +static inline int _plain_queue_deq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { int num_deq; queue_entry_t *queue; @@ -603,18 +581,18 @@ static inline int plain_queue_deq(odp_queue_t handle, return num_deq; } -static int queue_int_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], - int num) +static int plain_queue_deq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { - return plain_queue_deq(handle, buf_hdr, num); + return _plain_queue_deq_multi(handle, buf_hdr, num); } -static odp_buffer_hdr_t *queue_int_deq(odp_queue_t handle) +static odp_buffer_hdr_t *plain_queue_deq(odp_queue_t handle) { odp_buffer_hdr_t *buf_hdr = NULL; int ret; - ret = plain_queue_deq(handle, &buf_hdr, 1); + ret = _plain_queue_deq_multi(handle, &buf_hdr, 1); if (ret == 1) return buf_hdr; @@ -622,89 +600,46 @@ static odp_buffer_hdr_t *queue_int_deq(odp_queue_t handle) return NULL; } -static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) +static int error_enqueue(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) { - queue_entry_t *queue = qentry_from_handle(handle); + (void)buf_hdr; - if (num > QUEUE_MULTI_MAX) - num = QUEUE_MULTI_MAX; + ODP_ERR("Enqueue not supported (" PRIu64 ")\n", + odp_queue_to_u64(handle)); - return queue->s.dequeue_multi(handle, - (odp_buffer_hdr_t **)ev, num); + return -1; } -static odp_event_t queue_deq(odp_queue_t handle) +static int error_enqueue_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { - queue_entry_t *queue = qentry_from_handle(handle); + (void)buf_hdr; + (void)num; - return (odp_event_t)queue->s.dequeue(handle); + ODP_ERR("Enqueue multi not supported (" PRIu64 ")\n", + odp_queue_to_u64(handle)); + + return -1; } -static int queue_init(queue_entry_t *queue, const char *name, - const odp_queue_param_t *param) +static odp_buffer_hdr_t *error_dequeue(odp_queue_t handle) { - uint64_t offset; - uint32_t queue_size; - int spsc; - - 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; - - queue->s.type = queue->s.param.type; + ODP_ERR("Dequeue not supported (" PRIu64 ")\n", + odp_queue_to_u64(handle)); - queue->s.pktin = PKTIN_INVALID; - queue->s.pktout = PKTOUT_INVALID; - - /* Use default size for all small queues to quarantee performance - * level. */ - queue_size = queue_glb->config.default_queue_size; - if (param->size > queue_glb->config.default_queue_size) - queue_size = param->size; - - /* Round up if not already a power of two */ - queue_size = ROUNDUP_POWER2_U32(queue_size); - - if (queue_size > queue_glb->config.max_queue_size) { - ODP_ERR("Too large queue size %u\n", queue_size); - return -1; - } - - offset = queue->s.index * (uint64_t)queue_glb->config.max_queue_size; - - /* Single-producer / single-consumer plain queue has simple and - * lock-free implementation */ - spsc = (param->type == ODP_QUEUE_TYPE_PLAIN) && - (param->enq_mode == ODP_QUEUE_OP_MT_UNSAFE) && - (param->deq_mode == ODP_QUEUE_OP_MT_UNSAFE); - - queue->s.spsc = spsc; - queue->s.queue_lf = NULL; - - if (spsc) { - queue_spsc_init(queue, queue_size); - } else { - 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; + return NULL; +} - queue->s.orig_dequeue_multi = queue_int_deq_multi; +static int error_dequeue_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) +{ + (void)buf_hdr; + (void)num; - ring_st_init(&queue->s.ring_st, &queue_glb->ring_data[offset], - queue_size); - } + ODP_ERR("Dequeue multi not supported (" PRIu64 ")\n", + odp_queue_to_u64(handle)); - return 0; + return -1; } static void queue_param_init(odp_queue_param_t *params) @@ -758,6 +693,24 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return 0; } +static int sched_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) +{ + return _sched_queue_enq_multi(handle, buf_hdr, num); +} + +static int sched_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) +{ + int ret; + + ret = _sched_queue_enq_multi(handle, &buf_hdr, 1); + + if (ret == 1) + return 0; + else + return -1; +} + int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, int update_status) { @@ -830,6 +783,87 @@ int sched_queue_empty(uint32_t queue_index) return ret; } +static int queue_init(queue_entry_t *queue, const char *name, + const odp_queue_param_t *param) +{ + uint64_t offset; + uint32_t queue_size; + odp_queue_type_t queue_type; + int spsc; + + queue_type = param->type; + + 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 (queue_type == ODP_QUEUE_TYPE_SCHED) + queue->s.param.deq_mode = ODP_QUEUE_OP_DISABLED; + + queue->s.type = queue_type; + + queue->s.pktin = PKTIN_INVALID; + queue->s.pktout = PKTOUT_INVALID; + + /* Use default size for all small queues to quarantee performance + * level. */ + queue_size = queue_glb->config.default_queue_size; + if (param->size > queue_glb->config.default_queue_size) + queue_size = param->size; + + /* Round up if not already a power of two */ + queue_size = ROUNDUP_POWER2_U32(queue_size); + + if (queue_size > queue_glb->config.max_queue_size) { + ODP_ERR("Too large queue size %u\n", queue_size); + return -1; + } + + offset = queue->s.index * (uint64_t)queue_glb->config.max_queue_size; + + /* Single-producer / single-consumer plain queue has simple and + * lock-free implementation */ + spsc = (queue_type == ODP_QUEUE_TYPE_PLAIN) && + (param->enq_mode == ODP_QUEUE_OP_MT_UNSAFE) && + (param->deq_mode == ODP_QUEUE_OP_MT_UNSAFE); + + queue->s.spsc = spsc; + queue->s.queue_lf = NULL; + + /* Default to error functions */ + queue->s.enqueue = error_enqueue; + queue->s.enqueue_multi = error_enqueue_multi; + queue->s.dequeue = error_dequeue; + queue->s.dequeue_multi = error_dequeue_multi; + queue->s.orig_dequeue_multi = error_dequeue_multi; + + if (spsc) { + queue_spsc_init(queue, queue_size); + } else { + if (queue_type == ODP_QUEUE_TYPE_PLAIN) { + queue->s.enqueue = plain_queue_enq; + queue->s.enqueue_multi = plain_queue_enq_multi; + queue->s.dequeue = plain_queue_deq; + queue->s.dequeue_multi = plain_queue_deq_multi; + queue->s.orig_dequeue_multi = plain_queue_deq_multi; + } else { + queue->s.enqueue = sched_queue_enq; + queue->s.enqueue_multi = sched_queue_enq_multi; + } + + ring_st_init(&queue->s.ring_st, &queue_glb->ring_data[offset], + queue_size); + } + + return 0; +} + static uint64_t queue_to_u64(odp_queue_t hdl) { return _odp_pri(hdl); @@ -894,6 +928,47 @@ static int queue_orig_multi(odp_queue_t handle, return queue->s.orig_dequeue_multi(handle, buf_hdr, num); } +static int queue_api_enq_multi(odp_queue_t handle, + const odp_event_t ev[], int num) +{ + queue_entry_t *queue = qentry_from_handle(handle); + + if (odp_unlikely(num == 0)) + return 0; + + if (num > QUEUE_MULTI_MAX) + num = QUEUE_MULTI_MAX; + + return queue->s.enqueue_multi(handle, + (odp_buffer_hdr_t **)(uintptr_t)ev, num); +} + +static int queue_api_enq(odp_queue_t handle, odp_event_t ev) +{ + queue_entry_t *queue = qentry_from_handle(handle); + + return queue->s.enqueue(handle, + (odp_buffer_hdr_t *)(uintptr_t)ev); +} + +static int queue_api_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) +{ + queue_entry_t *queue = qentry_from_handle(handle); + + if (num > QUEUE_MULTI_MAX) + num = QUEUE_MULTI_MAX; + + return queue->s.dequeue_multi(handle, + (odp_buffer_hdr_t **)ev, num); +} + +static odp_event_t queue_api_deq(odp_queue_t handle) +{ + queue_entry_t *queue = qentry_from_handle(handle); + + return (odp_event_t)queue->s.dequeue(handle); +} + /* API functions */ _odp_queue_api_fn_t queue_basic_api = { .queue_create = queue_create, @@ -901,10 +976,10 @@ _odp_queue_api_fn_t queue_basic_api = { .queue_lookup = queue_lookup, .queue_capability = queue_capability, .queue_context_set = queue_context_set, - .queue_enq = queue_enq, - .queue_enq_multi = queue_enq_multi, - .queue_deq = queue_deq, - .queue_deq_multi = queue_deq_multi, + .queue_enq = queue_api_enq, + .queue_enq_multi = queue_api_enq_multi, + .queue_deq = queue_api_deq, + .queue_deq_multi = queue_api_deq_multi, .queue_type = queue_type, .queue_sched_type = queue_sched_type, .queue_sched_prio = queue_sched_prio, From patchwork Fri Aug 17 13:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 144484 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp753112ljj; Fri, 17 Aug 2018 06:05:58 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyhAEdWyB68KQROvgXZEpxENg4quHToF3fCQUrwaz9xBk8FgJkUTIUFqTITXowGFJ1Ep+sL X-Received: by 2002:a37:b102:: with SMTP id a2-v6mr31763978qkf.359.1534511158624; Fri, 17 Aug 2018 06:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534511158; cv=none; d=google.com; s=arc-20160816; b=Xckh284++zvD3heuxeDecSOz5TMm2Zd5tFhBUyMHmbrHpShAlKucTZdro4EWyL7pjc WLbsn3kjHKGZIfngJFbS5FzhqSDM09//CuNj1nA1snZcoEQnr4w84RjSeVxSPlbWsTS3 I7r+g+UlYpNnFs3Cn1ek83kvV8lbyGGNjT9JcT78zOo/Chnf8v51BFl6B4U3flAJ/v7A qyJ2rp4jQO8000IaVsptWQ3dLkJeR0DijhnthdTI36al9dEkFDb4wr5R7br7UxqMQ/sM KupT2Vzx/v4sfq8HaZmK4Ig4CSdCS0nrimYgiatUKJ31EZ9BeP6ZgcohkxCgZ/HPItHZ hT3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=rdCGDEToanNEYLlyHoGgw2iga7NDuEvmHQfkthvKPdQ=; b=WqEzJKpGp8l82RN9HPh0kUVPdeXXiBzItHhBDu+DKRcCE1kdQLXGrneZ0fwKLGWn6U FmuxdlXj1mxqCCa89luQeQW0DPjND2frtBwOfb1Pvj7gr32AhVdtKnkFFVT4OGZ1N/I0 5CzIyaHunbhLrnMa7meb5DNFjShi7NDpcTQ1CH4vH+Cp6sv2E2s7b0SWvnlkWxqUMgK9 8g4+ETQj4R0WupfqV6YffVr1/0AYKcV+rUv//LwaowwP4Jr3ZJaXevC427U6sh+fk1+u vA2ZJIzskg4hEObDx2Ee2mYwMuWBlf7LU/vgMFVC9JMgAuE4Iyo0CNdyfVE/kHv1oM8v O1oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id w127-v6si296955qkb.5.2018.08.17.06.05.58; Fri, 17 Aug 2018 06:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 3C493685E3; Fri, 17 Aug 2018 13:05:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4B6EB685E8; Fri, 17 Aug 2018 13:01:05 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 98A8B61849; Fri, 17 Aug 2018 13:00:25 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id A3DC460F5B for ; Fri, 17 Aug 2018 13:00:16 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 5F5B95105A6B for ; Fri, 17 Aug 2018 16:00:15 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FaH8QWPHBh-0Fd4IxMe; Fri, 17 Aug 2018 16:00:15 +0300 Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YdJgVOaEs5-0EqOra2G; Fri, 17 Aug 2018 16:00:14 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 17 Aug 2018 13:00:07 +0000 Message-Id: <1534510807-11066-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> References: <1534510807-11066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 675 Subject: [lng-odp] [PATCH v1 6/6] linux-gen: queue: separate plain and sched enqueue functions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Separate enqueue function implementations for plain and scheduled queues. Plain queue implementation is simplified and scheduled queue implementation does not change. Signed-off-by: Petri Savolainen --- /** Email created from pull request 675 (psavol:master-queue-inline) ** https://github.com/Linaro/odp/pull/675 ** Patch: https://github.com/Linaro/odp/pull/675.patch ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde ** Merge commit sha: a68fc608f4c460289d09e09e68f3646d1846737a **/ platform/linux-generic/odp_queue_basic.c | 126 ++++++++++++++--------- 1 file changed, 77 insertions(+), 49 deletions(-) diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index d2de677df..22a76b935 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -485,11 +485,9 @@ static inline void buffer_index_to_buf(odp_buffer_hdr_t *buf_hdr[], } } -static inline int _sched_queue_enq_multi(odp_queue_t handle, +static inline int _plain_queue_enq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { - int sched = 0; - int ret; queue_entry_t *queue; int num_enq; ring_st_t *ring_st; @@ -498,9 +496,6 @@ static inline int _sched_queue_enq_multi(odp_queue_t handle, queue = qentry_from_handle(handle); ring_st = &queue->s.ring_st; - if (sched_fn->ord_enq_multi(handle, (void **)buf_hdr, num, &ret)) - return ret; - buffer_index_from_buf(buf_idx, buf_hdr, num); LOCK(queue); @@ -513,43 +508,11 @@ static inline int _sched_queue_enq_multi(odp_queue_t handle, num_enq = ring_st_enq_multi(ring_st, buf_idx, num); - if (odp_unlikely(num_enq == 0)) { - UNLOCK(queue); - return 0; - } - - if (queue->s.status == QUEUE_STATUS_NOTSCHED) { - queue->s.status = QUEUE_STATUS_SCHED; - sched = 1; - } - UNLOCK(queue); - /* Add queue to scheduling */ - if (sched && sched_fn->sched_queue(queue->s.index)) - ODP_ABORT("schedule_queue failed\n"); - return num_enq; } -static int plain_queue_enq_multi(odp_queue_t handle, - odp_buffer_hdr_t *buf_hdr[], int num) -{ - return _sched_queue_enq_multi(handle, buf_hdr, num); -} - -static int plain_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) -{ - int ret; - - ret = _sched_queue_enq_multi(handle, &buf_hdr, 1); - - if (ret == 1) - return 0; - else - return -1; -} - static inline int _plain_queue_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { @@ -581,6 +544,24 @@ static inline int _plain_queue_deq_multi(odp_queue_t handle, return num_deq; } +static int plain_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) +{ + return _plain_queue_enq_multi(handle, buf_hdr, num); +} + +static int plain_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) +{ + int ret; + + ret = _plain_queue_enq_multi(handle, &buf_hdr, 1); + + if (ret == 1) + return 0; + else + return -1; +} + static int plain_queue_deq_multi(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr[], int num) { @@ -693,22 +674,51 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return 0; } -static int sched_queue_enq_multi(odp_queue_t handle, - odp_buffer_hdr_t *buf_hdr[], int num) -{ - return _sched_queue_enq_multi(handle, buf_hdr, num); -} - -static int sched_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) +static inline int _sched_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) { + int sched = 0; int ret; + queue_entry_t *queue; + int num_enq; + ring_st_t *ring_st; + uint32_t buf_idx[num]; - ret = _sched_queue_enq_multi(handle, &buf_hdr, 1); + queue = qentry_from_handle(handle); + ring_st = &queue->s.ring_st; - if (ret == 1) - return 0; - else + if (sched_fn->ord_enq_multi(handle, (void **)buf_hdr, num, &ret)) + return ret; + + buffer_index_from_buf(buf_idx, buf_hdr, num); + + LOCK(queue); + + if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) { + UNLOCK(queue); + ODP_ERR("Bad queue status\n"); return -1; + } + + num_enq = ring_st_enq_multi(ring_st, buf_idx, num); + + if (odp_unlikely(num_enq == 0)) { + UNLOCK(queue); + return 0; + } + + if (queue->s.status == QUEUE_STATUS_NOTSCHED) { + queue->s.status = QUEUE_STATUS_SCHED; + sched = 1; + } + + UNLOCK(queue); + + /* Add queue to scheduling */ + if (sched && sched_fn->sched_queue(queue->s.index)) + ODP_ABORT("schedule_queue failed\n"); + + return num_enq; } int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, @@ -757,6 +767,24 @@ int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num, return num_deq; } +static int sched_queue_enq_multi(odp_queue_t handle, + odp_buffer_hdr_t *buf_hdr[], int num) +{ + return _sched_queue_enq_multi(handle, buf_hdr, num); +} + +static int sched_queue_enq(odp_queue_t handle, odp_buffer_hdr_t *buf_hdr) +{ + int ret; + + ret = _sched_queue_enq_multi(handle, &buf_hdr, 1); + + if (ret == 1) + return 0; + else + return -1; +} + int sched_queue_empty(uint32_t queue_index) { queue_entry_t *queue = qentry_from_index(queue_index);