From patchwork Wed Oct 14 23:02:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 54971 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id E3F0320490 for ; Wed, 14 Oct 2015 23:02:43 +0000 (UTC) Received: by wijq8 with SMTP id q8sf1532367wij.1 for ; Wed, 14 Oct 2015 16:02:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=sZX9TUWaMFArD5CaLAipFMfznTkBikdl0ASlkQvtNjA=; b=VlvOBFy5FR8qSHHVes2U5XbNv7sq7FyhdvyEwfPa6bIXy701X4kx+qGcXmImLwoOIq EEbXRWHmgzxz/GaDHhsHXUqIrI5SyTwaLjBrlJCTDe+omuh6VAw3kwZ21UwFZ4PcgWXG /pJF+PKfLs2Q/XPq0S8ZrhEFssJq0wa+l6+b3LJXkYkpow1twPLV0n2Ono7PbPDUFnus pQDzK2z3V+dCTfIC8A3N+ju4P3DPKq3AdhaX3y2W20k1amW1B6qGfVEZCZvx8IF5gGUX LzPkgOzKWiJmRQQvzeIhXmiYf8R2qfsZI7fzXWCCj/Xs0Uy9x6UOtTwzZinUtBDT3vMm Pwfg== X-Gm-Message-State: ALoCoQkXhc8ywZ1i21C7UcPS2CXwr/I4qfDmVfmnehdw9Qc49wXLRHuoEpObKVs6E2qLOTVFNhAf X-Received: by 10.180.85.133 with SMTP id h5mr1450417wiz.1.1444863763210; Wed, 14 Oct 2015 16:02:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.141.74 with SMTP id p71ls82197lfd.77.gmail; Wed, 14 Oct 2015 16:02:42 -0700 (PDT) X-Received: by 10.25.15.162 with SMTP id 34mr1855721lfp.98.1444863762910; Wed, 14 Oct 2015 16:02:42 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id h128si7117088lfe.103.2015.10.14.16.02.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 16:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpp2 with SMTP id pp2so27827617lbb.0 for ; Wed, 14 Oct 2015 16:02:41 -0700 (PDT) X-Received: by 10.112.151.106 with SMTP id up10mr2936090lbb.106.1444863761494; Wed, 14 Oct 2015 16:02:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp272004lbq; Wed, 14 Oct 2015 16:02:40 -0700 (PDT) X-Received: by 10.140.135.202 with SMTP id 193mr8001559qhh.3.1444863760261; Wed, 14 Oct 2015 16:02:40 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i129si10130201qhc.84.2015.10.14.16.02.39; Wed, 14 Oct 2015 16:02:40 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 9E52D61E70; Wed, 14 Oct 2015 23:02:39 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED 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 BE71F61E56; Wed, 14 Oct 2015 23:02:31 +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 8092761E64; Wed, 14 Oct 2015 23:02:28 +0000 (UTC) Received: from mail-oi0-f47.google.com (mail-oi0-f47.google.com [209.85.218.47]) by lists.linaro.org (Postfix) with ESMTPS id 2411861E51 for ; Wed, 14 Oct 2015 23:02:27 +0000 (UTC) Received: by oihr205 with SMTP id r205so36732112oih.3 for ; Wed, 14 Oct 2015 16:02:26 -0700 (PDT) X-Received: by 10.202.74.8 with SMTP id x8mr3498903oia.98.1444863746581; Wed, 14 Oct 2015 16:02:26 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id kw1sm5163305obb.28.2015.10.14.16.02.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Oct 2015 16:02:25 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 14 Oct 2015 18:02:20 -0500 Message-Id: <1444863741-27794-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 1/2] api: config: replace defines with apis X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move platform-specific #defines for limits from the public API to the platform directory and add public APIs for each of them. Signed-off-by: Bill Fischofer Reviewed-by: Petri Savolainen --- include/odp/api/config.h | 63 ++++++----- platform/linux-generic/include/odp/config.h | 167 +++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 26 deletions(-) diff --git a/include/odp/api/config.h b/include/odp/api/config.h index 295b10d..9cdeb0e 100644 --- a/include/odp/api/config.h +++ b/include/odp/api/config.h @@ -19,55 +19,65 @@ extern "C" { #endif /** @defgroup odp_config ODP CONFIG - * Macro for maximum number of resources in ODP. + * Platform-specific configuration limits. * @{ */ /** * Maximum number of pools + * @return The maximum number of pools supported by this platform */ -#define ODP_CONFIG_POOLS 16 +int odp_config_pools(void); /** * Maximum number of queues + * @return The maximum number of queues supported by this platform */ -#define ODP_CONFIG_QUEUES 1024 +int odp_config_queues(void); /** * Maximum number of ordered locks per queue + * @return The maximum number of ordered locks per queue supported by + * this platform. */ -#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2 +int odp_config_max_ordered_locks_per_queue(void); /** * Number of scheduling priorities + * @return The number of scheduling priorities supported by this platform */ -#define ODP_CONFIG_SCHED_PRIOS 8 +int odp_config_sched_prios(void); /** * Number of scheduling groups + * @return Number of scheduling groups supported by this platofmr */ -#define ODP_CONFIG_SCHED_GRPS 16 +int odp_config_sched_grps(void); /** * Maximum number of packet IO resources + * @return The maximum number of packet I/O resources supported by this + * platform */ -#define ODP_CONFIG_PKTIO_ENTRIES 64 +int odp_config_pktio_entries(void); /** * Minimum buffer alignment * - * This defines the minimum supported buffer alignment. Requests for values - * below this will be rounded up to this value. + * @return The minimum buffer alignment supported by this platform + * @note Requests for values below this will be rounded up to this value. */ -#define ODP_CONFIG_BUFFER_ALIGN_MIN 16 +int odp_config_buffer_align_min(void); /** * Maximum buffer alignment * * This defines the maximum supported buffer alignment. Requests for values * above this will fail. + * + * @return The maximum buffer alignment supported by this platform. */ -#define ODP_CONFIG_BUFFER_ALIGN_MAX (4*1024) +int odp_config_buffer_align_max(void); /** * Default packet headroom @@ -77,11 +87,9 @@ extern "C" { * allocated packets. Implementations may reserve a larger than minimum headroom * size e.g. due to HW or a protocol specific alignment requirement. * - * @internal In linux-generic implementation: - * The default value (66) allows a 1500-byte packet to be received into a single - * segment with Ethernet offset alignment and room for some header expansion. + * @return Default packet headroom in bytes */ -#define ODP_CONFIG_PACKET_HEADROOM 66 +int odp_config_packet_headroom(void); /** * Default packet tailroom @@ -89,10 +97,11 @@ extern "C" { * This defines the minimum number of tailroom bytes that newly created packets * have by default. The default apply to both ODP packet input and user * allocated packets. Implementations are free to add to this as desired - * without restriction. Note that most implementations will automatically - * consider any unused portion of the last segment of a packet as tailroom + * without restriction. + * + * @return The default packet tailroom in bytes */ -#define ODP_CONFIG_PACKET_TAILROOM 0 +int odp_config_packet_tailroom(void); /** * Minimum packet segment length @@ -100,8 +109,10 @@ extern "C" { * This defines the minimum packet segment buffer length in bytes. The user * defined segment length (seg_len in odp_pool_param_t) will be rounded up into * this value. + * + * @return The minimum packet seg_len supported by this platform */ -#define ODP_CONFIG_PACKET_SEG_LEN_MIN (1598) +int odp_config_packet_seg_len_min(void); /** * Maximum packet segment length @@ -109,8 +120,10 @@ extern "C" { * This defines the maximum packet segment buffer length in bytes. The user * defined segment length (seg_len in odp_pool_param_t) must not be larger than * this. + * + * @return The maximum packet seg_len supported by this platform */ -#define ODP_CONFIG_PACKET_SEG_LEN_MAX (64*1024) +int odp_config_packet_seg_len_max(void); /** * Maximum packet buffer length @@ -120,17 +133,17 @@ extern "C" { * (including default head- and tailrooms) or extend packets to sizes larger * than this limit will fail. * - * @internal In linux-generic implementation: - * - The value MUST be an integral number of segments - * - The value SHOULD be large enough to accommodate jumbo packets (9K) + * @return The maximum packet buffer length supported by this platform */ -#define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_SEG_LEN_MIN*6) +int odp_config_packet_buf_len_max(void); /** Maximum number of shared memory blocks. * * This the the number of separate SHM areas that can be reserved concurrently + * + * @return The maximum number of shm areas supported by this platform */ -#define ODP_CONFIG_SHM_BLOCKS (ODP_CONFIG_POOLS + 48) +int odp_config_shm_blocks(void); /** * @} diff --git a/platform/linux-generic/include/odp/config.h b/platform/linux-generic/include/odp/config.h index 6fecd38..a130e68 100644 --- a/platform/linux-generic/include/odp/config.h +++ b/platform/linux-generic/include/odp/config.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Linaro Limited +/* Copyright (c) 2015, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -17,6 +17,171 @@ extern "C" { #endif +/** + * Maximum number of pools + */ +#define ODP_CONFIG_POOLS 16 +static inline int odp_config_pools(void) +{ + return ODP_CONFIG_POOLS; +} + +/** + * Maximum number of queues + */ +#define ODP_CONFIG_QUEUES 1024 +static inline int odp_config_queues(void) +{ + return ODP_CONFIG_QUEUES; +} + +/** + * Number of ordered locks per queue + */ +#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2 +static inline int odp_config_max_ordered_locks_per_queue(void) +{ + return ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE; +} + +/** + * Number of scheduling priorities + */ +#define ODP_CONFIG_SCHED_PRIOS 8 +static inline int odp_config_sched_prios(void) +{ + return ODP_CONFIG_SCHED_PRIOS; +} + +/** + * Number of scheduling groups + */ +#define ODP_CONFIG_SCHED_GRPS 16 +static inline int odp_config_sched_grps(void) +{ + return ODP_CONFIG_SCHED_GRPS; +} + +/** + * Maximum number of packet IO resources + */ +#define ODP_CONFIG_PKTIO_ENTRIES 64 +static inline int odp_config_pktio_entries(void) +{ + return ODP_CONFIG_PKTIO_ENTRIES; +} + +/** + * Minimum buffer alignment + * + * This defines the minimum supported buffer alignment. Requests for values + * below this will be rounded up to this value. + */ +#define ODP_CONFIG_BUFFER_ALIGN_MIN 16 +static inline int odp_config_buffer_align_min(void) +{ + return ODP_CONFIG_BUFFER_ALIGN_MIN; +} + +/** + * Maximum buffer alignment + * + * This defines the maximum supported buffer alignment. Requests for values + * above this will fail. + */ +#define ODP_CONFIG_BUFFER_ALIGN_MAX (4 * 1024) +static inline int odp_config_buffer_align_max(void) +{ + return ODP_CONFIG_BUFFER_ALIGN_MAX; +} + +/** + * Default packet headroom + * + * This defines the minimum number of headroom bytes that newly created packets + * have by default. The default apply to both ODP packet input and user + * allocated packets. Implementations may reserve a larger than minimum headroom + * size e.g. due to HW or a protocol specific alignment requirement. + * + * @internal In linux-generic implementation: + * The default value (66) allows a 1500-byte packet to be received into a single + * segment with Ethernet offset alignment and room for some header expansion. + */ +#define ODP_CONFIG_PACKET_HEADROOM 66 +static inline int odp_config_packet_headroom(void) +{ + return ODP_CONFIG_PACKET_HEADROOM; +} + +/** + * Default packet tailroom + * + * This defines the minimum number of tailroom bytes that newly created packets + * have by default. The default apply to both ODP packet input and user + * allocated packets. Implementations are free to add to this as desired + * without restriction. Note that most implementations will automatically + * consider any unused portion of the last segment of a packet as tailroom + */ +#define ODP_CONFIG_PACKET_TAILROOM 0 +static inline int odp_config_packet_tailroom(void) +{ + return ODP_CONFIG_PACKET_TAILROOM; +} + +/** + * Minimum packet segment length + * + * This defines the minimum packet segment buffer length in bytes. The user + * defined segment length (seg_len in odp_pool_param_t) will be rounded up into + * this value. + */ +#define ODP_CONFIG_PACKET_SEG_LEN_MIN 1598 +static inline int odp_config_packet_seg_len_min(void) +{ + return ODP_CONFIG_PACKET_SEG_LEN_MIN; +} + +/** + * Maximum packet segment length + * + * This defines the maximum packet segment buffer length in bytes. The user + * defined segment length (seg_len in odp_pool_param_t) must not be larger than + * this. + */ +#define ODP_CONFIG_PACKET_SEG_LEN_MAX (64 * 1024) +static inline int odp_config_packet_seg_len_max(void) +{ + return ODP_CONFIG_PACKET_SEG_LEN_MAX; +} + +/** + * Maximum packet buffer length + * + * This defines the maximum number of bytes that can be stored into a packet + * (maximum return value of odp_packet_buf_len(void)). Attempts to allocate + * (including default head- and tailrooms) or extend packets to sizes larger + * than this limit will fail. + * + * @internal In linux-generic implementation: + * - The value MUST be an integral number of segments + * - The value SHOULD be large enough to accommodate jumbo packets (9K) + */ +#define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_SEG_LEN_MIN * 6) +static inline int odp_config_packet_buf_len_max(void) +{ + return ODP_CONFIG_PACKET_BUF_LEN_MAX; +} + +/** Maximum number of shared memory blocks. + * + * This the the number of separate SHM areas that can be reserved concurrently + */ +#define ODP_CONFIG_SHM_BLOCKS (ODP_CONFIG_POOLS + 48) +static inline int odp_config_shm_blocks(void) +{ + return ODP_CONFIG_SHM_BLOCKS; +} + #include #ifdef __cplusplus