From patchwork Thu Jan 15 15:40:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43214 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 185FC240BA for ; Thu, 15 Jan 2015 15:42:05 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e49sf2326236eek.3 for ; Thu, 15 Jan 2015 07:42:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references: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=FYHC9prBkHQUiuPDs1CdpfQRIRT8icKQYYtVY5HlXFo=; b=PuHapgFKc/Qx9XxOYJr7/jSGFglyvTptufaWVKD61b04iSh4Tt1yj2+GpSH0dlRsCR bFGAe9Omk09BHUBO2vBdSFnQFG2DNhweBle+zPuKqzo/Zs5gBswGSjS8GC1DFHUo7fO4 D6trfgDDH3vjIsZC84PAo6OEhIaoo7ATMqebspUi14FU6hkDBC2wAmm0cE1C4vVGtsw6 qM11YYitrTjaSNAsmzBVOJZSjCnHHFFsOVtWzSJbCTFESqqKUo+d49nP8fmfsUYXX685 cafVvgbADyALr8X5kFg/Xx4h4NejDulqwi9poiDKFU3sZRX0xG4r/U/jJN/Z3d7xHNgg IWkA== X-Gm-Message-State: ALoCoQnOD/QEft/uFGF/cX1sCEY4qV0oz7VdmUhQx5h3buXi+xR541K7EDRCBonjb88bo2bXcFhj X-Received: by 10.112.13.161 with SMTP id i1mr91341lbc.20.1421336524159; Thu, 15 Jan 2015 07:42:04 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.7 with SMTP id f7ls259039laa.100.gmail; Thu, 15 Jan 2015 07:42:04 -0800 (PST) X-Received: by 10.112.72.197 with SMTP id f5mr10347682lbv.21.1421336524003; Thu, 15 Jan 2015 07:42:04 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id h11si379201lbn.62.2015.01.15.07.42.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 07:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gd6so14339637lab.3 for ; Thu, 15 Jan 2015 07:42:03 -0800 (PST) X-Received: by 10.112.52.229 with SMTP id w5mr10575883lbo.52.1421336523847; Thu, 15 Jan 2015 07:42:03 -0800 (PST) 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.9.200 with SMTP id c8csp22072lbb; Thu, 15 Jan 2015 07:42:02 -0800 (PST) X-Received: by 10.140.19.139 with SMTP id 11mr6406526qgh.14.1421336521806; Thu, 15 Jan 2015 07:42:01 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id r2si2308762qah.79.2015.01.15.07.42.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 Jan 2015 07:42:01 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBmYZ-0007Xl-3c; Thu, 15 Jan 2015 15:41:59 +0000 Received: from mail-qa0-f46.google.com ([209.85.216.46]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBmYC-0007R5-MP for lng-odp@lists.linaro.org; Thu, 15 Jan 2015 15:41:36 +0000 Received: by mail-qa0-f46.google.com with SMTP id j7so11517385qaq.5 for ; Thu, 15 Jan 2015 07:41:31 -0800 (PST) X-Received: by 10.224.104.10 with SMTP id m10mr16904210qao.3.1421336491521; Thu, 15 Jan 2015 07:41:31 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id g12sm1563340qay.44.2015.01.15.07.41.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 07:41:30 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Thu, 15 Jan 2015 17:40:21 +0200 Message-Id: <1421336423-19382-14-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421336423-19382-1-git-send-email-petri.savolainen@linaro.org> References: <1421336423-19382-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 13/15] api: pool: Rename pool params and remove buffer types X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@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.215.44 as permitted sender) smtp.mail=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 * Renamed odp_buffer_pool_param_t to odp_pool_param_t * Moved buffer pool parameters into "buf" struct * Left other structs for other types (pkt and tmo) to be added and implemented * Pool type field is common to all pool types * Removed buffer types and use ODP_EVENT_XXX for pool types instead Signed-off-by: Petri Savolainen --- example/generator/odp_generator.c | 10 +-- example/ipsec/odp_ipsec.c | 28 ++++---- example/l2fwd/odp_l2fwd.c | 10 +-- example/packet/odp_pktio.c | 10 +-- example/timer/odp_timer_test.c | 10 +-- platform/linux-generic/include/api/odp_pool.h | 71 +++++++++++--------- .../linux-generic/include/odp_buffer_inlines.h | 2 +- .../linux-generic/include/odp_buffer_internal.h | 6 +- .../include/odp_buffer_pool_internal.h | 6 +- platform/linux-generic/odp_buffer_pool.c | 76 +++++++++++----------- platform/linux-generic/odp_event.c | 11 +--- platform/linux-generic/odp_packet.c | 12 ++-- platform/linux-generic/odp_schedule.c | 10 +-- platform/linux-generic/odp_timer.c | 2 +- test/performance/odp_scheduling.c | 10 +-- 15 files changed, 135 insertions(+), 139 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index dfc5d2b..68126d9 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -546,7 +546,7 @@ int main(int argc, char *argv[]) int first_cpu; int cpu_count; odp_shm_t shm; - odp_buffer_pool_param_t params; + odp_pool_param_t params; /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { @@ -609,10 +609,10 @@ int main(int argc, char *argv[]) printf("First CPU: %i\n\n", first_cpu); /* Create packet pool */ - params.buf_size = SHM_PKT_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; - params.buf_type = ODP_BUFFER_TYPE_PACKET; + params.buf.size = SHM_PKT_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; + params.type = ODP_EVENT_PACKET; pool = odp_buffer_pool_create("packet_pool", ODP_SHM_NULL, ¶ms); diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index faef46d..3ac8629 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -366,7 +366,7 @@ static void ipsec_init_pre(void) { odp_queue_param_t qparam; - odp_buffer_pool_param_t params; + odp_pool_param_t params; /* * Create queues @@ -399,10 +399,10 @@ void ipsec_init_pre(void) } /* Create output buffer pool */ - params.buf_size = SHM_OUT_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_PKT_POOL_BUF_COUNT; - params.buf_type = ODP_BUFFER_TYPE_PACKET; + params.buf.size = SHM_OUT_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_PKT_POOL_BUF_COUNT; + params.type = ODP_EVENT_PACKET; out_pool = odp_buffer_pool_create("out_pool", ODP_SHM_NULL, ¶ms); @@ -1176,7 +1176,7 @@ main(int argc, char *argv[]) int cpu_count; int stream_count; odp_shm_t shm; - odp_buffer_pool_param_t params; + odp_pool_param_t params; /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { @@ -1236,10 +1236,10 @@ main(int argc, char *argv[]) printf("First CPU: %i\n\n", first_cpu); /* Create packet buffer pool */ - params.buf_size = SHM_PKT_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_PKT_POOL_BUF_COUNT; - params.buf_type = ODP_BUFFER_TYPE_PACKET; + params.buf.size = SHM_PKT_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_PKT_POOL_BUF_COUNT; + params.type = ODP_EVENT_PACKET; pkt_pool = odp_buffer_pool_create("packet_pool", ODP_SHM_NULL, ¶ms); @@ -1250,10 +1250,10 @@ main(int argc, char *argv[]) } /* Create context buffer pool */ - params.buf_size = SHM_CTX_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_CTX_POOL_BUF_COUNT; - params.buf_type = ODP_BUFFER_TYPE_RAW; + params.buf.size = SHM_CTX_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_CTX_POOL_BUF_COUNT; + params.type = ODP_EVENT_BUFFER; ctx_pool = odp_buffer_pool_create("ctx_pool", ODP_SHM_NULL, ¶ms); diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 195d329..b5386e8 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) int cpu_count; int num_workers; odp_shm_t shm; - odp_buffer_pool_param_t params; + odp_pool_param_t params; /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { @@ -356,10 +356,10 @@ int main(int argc, char *argv[]) printf("First cpu: %i\n\n", first_cpu); /* Create packet pool */ - params.buf_size = SHM_PKT_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; - params.buf_type = ODP_BUFFER_TYPE_PACKET; + params.buf.size = SHM_PKT_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; + params.type = ODP_EVENT_PACKET; pool = odp_buffer_pool_create("packet pool", ODP_SHM_NULL, ¶ms); diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 2251aad..7670dc4 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) int i; int first_cpu; int cpu_count; - odp_buffer_pool_param_t params; + odp_pool_param_t params; args = calloc(1, sizeof(args_t)); if (args == NULL) { @@ -330,10 +330,10 @@ int main(int argc, char *argv[]) printf("First CPU: %i\n\n", first_cpu); /* Create packet pool */ - params.buf_size = SHM_PKT_POOL_BUF_SIZE; - params.buf_align = 0; - params.num_bufs = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; - params.buf_type = ODP_BUFFER_TYPE_PACKET; + params.buf.size = SHM_PKT_POOL_BUF_SIZE; + params.buf.align = 0; + params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; + params.type = ODP_EVENT_PACKET; pool = odp_buffer_pool_create("packet_pool", ODP_SHM_NULL, ¶ms); diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 944ef9e..897179b 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) int first_cpu; uint64_t cycles, ns; odp_queue_param_t param; - odp_buffer_pool_param_t params; + odp_pool_param_t params; odp_timer_pool_param_t tparams; odp_timer_pool_info_t tpinfo; @@ -369,10 +369,10 @@ int main(int argc, char *argv[]) /* * Create buffer pool for timeouts */ - params.buf_size = 0; - params.buf_align = 0; - params.num_bufs = MSG_NUM_BUFS; - params.buf_type = ODP_BUFFER_TYPE_TIMEOUT; + params.buf.size = 0; + params.buf.align = 0; + params.buf.num = MSG_NUM_BUFS; + params.type = ODP_EVENT_TIMEOUT; pool = odp_buffer_pool_create("msg_pool", ODP_SHM_NULL, ¶ms); diff --git a/platform/linux-generic/include/api/odp_pool.h b/platform/linux-generic/include/api/odp_pool.h index 30a805f..657cee7 100644 --- a/platform/linux-generic/include/api/odp_pool.h +++ b/platform/linux-generic/include/api/odp_pool.h @@ -23,37 +23,48 @@ extern "C" { #include #include #include +#include /** @addtogroup odp_buffer - * Operations on a buffer pool. + * Operations on a pool. * @{ */ /** Maximum queue name lenght in chars */ -#define ODP_BUFFER_POOL_NAME_LEN 32 +#define ODP_POOL_NAME_LEN 32 /** - * Buffer pool parameters - * Used to communicate buffer pool creation options. + * Pool parameters + * Used to communicate pool creation options. */ -typedef struct odp_buffer_pool_param_t { - uint32_t buf_size; /**< Buffer size in bytes. The maximum - number of bytes application will - store in each buffer. For packets, this - is the maximum packet data length, and - configured headroom and tailroom will be - added to this number */ - uint32_t buf_align; /**< Minimum buffer alignment in bytes. - Valid values are powers of two. Use 0 - for default alignment. Default will - always be a multiple of 8. */ - uint32_t num_bufs; /**< Number of buffers in the pool */ - int buf_type; /**< Buffer type */ -} odp_buffer_pool_param_t; - -#define ODP_BUFFER_TYPE_RAW 1 /**< Raw buffer, no additional metadata */ -#define ODP_BUFFER_TYPE_PACKET 2 /**< Packet buffer */ -#define ODP_BUFFER_TYPE_TIMEOUT 3 /**< Timeout buffer */ +typedef struct odp_pool_param_t { + union { + struct { + uint32_t size; /**< Buffer size in bytes. The + maximum number of bytes + application will store in each + buffer. */ + uint32_t align; /**< Minimum buffer alignment in bytes. + Valid values are powers of two. + Use 0 for default alignment. + Default will always be a multiple + of 8. */ + uint32_t num; /**< Number of buffers in the pool */ + } buf; +/* Reserved for packet and timeout specific params + struct { + uint32_t seg_size; + uint32_t seg_align; + uint32_t num; + } pkt; + struct { + } tmo; +*/ + }; + + int type; /**< Event type */ + +} odp_pool_param_t; /** * Create a buffer pool @@ -78,7 +89,7 @@ typedef struct odp_buffer_pool_param_t { odp_buffer_pool_t odp_buffer_pool_create(const char *name, odp_shm_t shm, - odp_buffer_pool_param_t *params); + odp_pool_param_t *params); /** * Destroy a buffer pool previously created by odp_buffer_pool_create() @@ -117,13 +128,13 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char *name); * Used to get information about a buffer pool. */ typedef struct odp_buffer_pool_info_t { - const char *name; /**< pool name */ - odp_shm_t shm; /**< handle of shared memory area - supplied by application to - contain buffer pool, or - ODP_SHM_INVALID if this pool is - managed by ODP */ - odp_buffer_pool_param_t params; /**< pool parameters */ + const char *name; /**< pool name */ + odp_shm_t shm; /**< handle of shared memory area + supplied by application to + contain buffer pool, or + ODP_SHM_INVALID if this pool is + managed by ODP */ + odp_pool_param_t params; /**< pool parameters */ } odp_buffer_pool_info_t; /** diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h index ee264a6..000e673 100644 --- a/platform/linux-generic/include/odp_buffer_inlines.h +++ b/platform/linux-generic/include/odp_buffer_inlines.h @@ -116,7 +116,7 @@ static inline odp_buffer_hdr_t *validate_buf(odp_buffer_t buf) /* A valid buffer index must be on stride, and must be in range */ if ((handle.index % buf_stride != 0) || - ((uint32_t)(handle.index / buf_stride) >= pool->s.params.num_bufs)) + ((uint32_t)(handle.index / buf_stride) >= pool->s.params.buf.num)) return NULL; buf_hdr = (odp_buffer_hdr_t *)(void *) diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index c3784ba..14c32c1 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -28,6 +28,7 @@ extern "C" { #include #include #include +#include #define ODP_BITSIZE(x) \ @@ -163,11 +164,6 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool, size_t size); */ int _odp_buffer_type(odp_buffer_t buf); -#define _ODP_BUFFER_TYPE_INVALID (-1) /**< Buffer type invalid */ -#define _ODP_BUFFER_TYPE_ANY 0 /**< Buffer that can hold any other - buffer type */ - - #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h b/platform/linux-generic/include/odp_buffer_pool_internal.h index b0e696e..4ace3c3 100644 --- a/platform/linux-generic/include/odp_buffer_pool_internal.h +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h @@ -84,8 +84,8 @@ struct pool_entry_s { odp_spinlock_t lock ODP_ALIGNED_CACHE; #endif - char name[ODP_BUFFER_POOL_NAME_LEN]; - odp_buffer_pool_param_t params; + char name[ODP_POOL_NAME_LEN]; + odp_pool_param_t params; _odp_buffer_pool_init_t init_params; odp_buffer_pool_t pool_hdl; uint32_t pool_id; @@ -239,7 +239,7 @@ static inline void ret_buf(struct pool_entry_s *pool, odp_buffer_hdr_t *buf) buf->allocator = ODP_FREEBUF; /* Mark buffer free */ - if (!buf->flags.hdrdata && buf->type != ODP_BUFFER_TYPE_RAW) { + if (!buf->flags.hdrdata && buf->type != ODP_EVENT_BUFFER) { while (buf->segcount > 0) { if (buffer_is_secure(buf) || pool_is_secure(pool)) memset(buf->addr[buf->segcount - 1], diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index d243045..53f468c 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -101,7 +101,7 @@ int odp_buffer_pool_init_global(void) odp_buffer_pool_t odp_buffer_pool_create(const char *name, odp_shm_t shm, - odp_buffer_pool_param_t *params) + odp_pool_param_t *params) { odp_buffer_pool_t pool_hdl = ODP_BUFFER_POOL_INVALID; pool_entry_t *pool; @@ -131,7 +131,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, 0; uint32_t blk_size, buf_stride; - uint32_t buf_align = params->buf_align; + uint32_t buf_align = params->buf.align; /* Validate requested buffer alignment */ if (buf_align > ODP_CONFIG_BUFFER_ALIGN_MAX || @@ -145,36 +145,35 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, buf_align = ODP_CONFIG_BUFFER_ALIGN_MIN; /* Calculate space needed for buffer blocks and metadata */ - switch (params->buf_type) { - case ODP_BUFFER_TYPE_RAW: - case ODP_BUFFER_TYPE_TIMEOUT: - blk_size = params->buf_size; + switch (params->type) { + case ODP_EVENT_BUFFER: + case ODP_EVENT_TIMEOUT: + blk_size = params->buf.size; /* Optimize small raw buffers */ - if (blk_size > ODP_MAX_INLINE_BUF || params->buf_align != 0) + if (blk_size > ODP_MAX_INLINE_BUF || params->buf.align != 0) blk_size = ODP_ALIGN_ROUNDUP(blk_size, buf_align); - buf_stride = params->buf_type == ODP_BUFFER_TYPE_RAW ? + buf_stride = params->type == ODP_EVENT_BUFFER ? sizeof(odp_buffer_hdr_stride) : sizeof(odp_timeout_hdr_stride); break; - case ODP_BUFFER_TYPE_PACKET: - case _ODP_BUFFER_TYPE_ANY: + case ODP_EVENT_PACKET: headroom = ODP_CONFIG_PACKET_HEADROOM; tailroom = ODP_CONFIG_PACKET_TAILROOM; - unsegmented = params->buf_size > ODP_CONFIG_PACKET_BUF_LEN_MAX; + unsegmented = params->buf.size > ODP_CONFIG_PACKET_BUF_LEN_MAX; if (unsegmented) blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf_size + tailroom, + headroom + params->buf.size + tailroom, buf_align); else blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf_size + tailroom, + headroom + params->buf.size + tailroom, ODP_CONFIG_PACKET_BUF_LEN_MIN); - buf_stride = params->buf_type == ODP_BUFFER_TYPE_PACKET ? + buf_stride = params->type == ODP_EVENT_PACKET ? sizeof(odp_packet_hdr_stride) : sizeof(odp_any_hdr_stride); break; @@ -184,7 +183,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, } /* Validate requested number of buffers against addressable limits */ - if (params->num_bufs > + if (params->buf.num > (ODP_BUFFER_MAX_BUFFERS / (buf_stride / ODP_CACHE_LINE_SIZE))) return ODP_BUFFER_POOL_INVALID; @@ -207,8 +206,8 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, pool->s.name[0] = 0; } else { strncpy(pool->s.name, name, - ODP_BUFFER_POOL_NAME_LEN - 1); - pool->s.name[ODP_BUFFER_POOL_NAME_LEN - 1] = 0; + ODP_POOL_NAME_LEN - 1); + pool->s.name[ODP_POOL_NAME_LEN - 1] = 0; pool->s.flags.has_name = 1; } @@ -221,13 +220,13 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, block_size = 0; pool->s.buf_align = blk_size == 0 ? 0 : sizeof(void *); } else { - block_size = params->num_bufs * blk_size; + block_size = params->buf.num * blk_size; pool->s.buf_align = buf_align; } pad_size = ODP_CACHE_LINE_SIZE_ROUNDUP(block_size) - block_size; - mdata_size = params->num_bufs * buf_stride; - udata_size = params->num_bufs * udata_stride; + mdata_size = params->buf.num * buf_stride; + udata_size = params->buf.num * udata_stride; pool->s.pool_size = ODP_PAGE_SIZE_ROUNDUP(block_size + pad_size + @@ -310,7 +309,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, tmp->flags.zeroized = zeroized; tmp->size = 0; odp_atomic_store_u32(&tmp->ref_count, 0); - tmp->type = params->buf_type; + tmp->type = params->type; tmp->pool_hdl = pool->s.pool_hdl; tmp->udata_addr = (void *)udat; tmp->udata_size = init_params->udata_size; @@ -365,8 +364,8 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, pool->s.tailroom = tailroom; /* Watermarks are hard-coded for now to control caching */ - pool->s.high_wm = params->num_bufs / 2; - pool->s.low_wm = params->num_bufs / 4; + pool->s.high_wm = params->buf.num / 2; + pool->s.low_wm = params->buf.num / 4; pool_hdl = pool->s.pool_hdl; break; @@ -408,10 +407,10 @@ int odp_buffer_pool_info(odp_buffer_pool_t pool_hdl, info->name = pool->s.name; info->shm = pool->s.flags.user_supplied_shm ? pool->s.pool_shm : ODP_SHM_INVALID; - info->params.buf_size = pool->s.params.buf_size; - info->params.buf_align = pool->s.params.buf_align; - info->params.num_bufs = pool->s.params.num_bufs; - info->params.buf_type = pool->s.params.buf_type; + info->params.buf.size = pool->s.params.buf.size; + info->params.buf.align = pool->s.params.buf.align; + info->params.buf.num = pool->s.params.buf.num; + info->params.type = pool->s.params.type; return 0; } @@ -437,7 +436,7 @@ int odp_buffer_pool_destroy(odp_buffer_pool_t pool_hdl) flush_cache(&local_cache[pool_id], &pool->s); /* Call fails if pool has allocated buffers */ - if (odp_atomic_load_u32(&pool->s.bufcount) < pool->s.params.num_bufs) { + if (odp_atomic_load_u32(&pool->s.bufcount) < pool->s.params.buf.num) { POOL_UNLOCK(&pool->s.lock); return -1; } @@ -494,7 +493,7 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl, size_t size) /* By default, buffers inherit their pool's zeroization setting */ buf->buf.flags.zeroized = pool->s.flags.zeroized; - if (buf->buf.type == ODP_BUFFER_TYPE_PACKET) { + if (buf->buf.type == ODP_EVENT_PACKET) { packet_init(pool, &buf->pkt, size); if (pool->s.init_params.buf_init != NULL) @@ -509,7 +508,7 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl, size_t size) odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool_hdl) { return buffer_alloc(pool_hdl, - odp_pool_to_entry(pool_hdl)->s.params.buf_size); + odp_pool_to_entry(pool_hdl)->s.params.buf.size); } void odp_buffer_free(odp_buffer_t buf) @@ -558,11 +557,10 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) ODP_DBG(" name %s\n", pool->s.flags.has_name ? pool->s.name : "Unnamed Pool"); ODP_DBG(" pool type %s\n", - pool->s.params.buf_type == ODP_BUFFER_TYPE_RAW ? "raw" : - (pool->s.params.buf_type == ODP_BUFFER_TYPE_PACKET ? "packet" : - (pool->s.params.buf_type == ODP_BUFFER_TYPE_TIMEOUT ? "timeout" : - (pool->s.params.buf_type == _ODP_BUFFER_TYPE_ANY ? "any" : - "unknown")))); + pool->s.params.type == ODP_EVENT_BUFFER ? "buffer" : + (pool->s.params.type == ODP_EVENT_PACKET ? "packet" : + (pool->s.params.type == ODP_EVENT_TIMEOUT ? "timeout" : + "unknown"))); ODP_DBG(" pool storage %sODP managed\n", pool->s.flags.user_supplied_shm ? "application provided, " : ""); @@ -578,14 +576,14 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) ODP_DBG(" pool mdata base %p\n", pool->s.pool_mdata_addr); ODP_DBG(" udata size %zu\n", pool->s.init_params.udata_size); ODP_DBG(" headroom %u\n", pool->s.headroom); - ODP_DBG(" buf size %zu\n", pool->s.params.buf_size); + ODP_DBG(" buf size %zu\n", pool->s.params.buf.size); ODP_DBG(" tailroom %u\n", pool->s.tailroom); ODP_DBG(" buf align %u requested, %u used\n", - pool->s.params.buf_align, pool->s.buf_align); - ODP_DBG(" num bufs %u\n", pool->s.params.num_bufs); + pool->s.params.buf.align, pool->s.buf_align); + ODP_DBG(" num bufs %u\n", pool->s.params.buf.num); ODP_DBG(" bufs available %u %s\n", bufcount, pool->s.low_wm_assert ? " **low wm asserted**" : ""); - ODP_DBG(" bufs in use %u\n", pool->s.params.num_bufs - bufcount); + ODP_DBG(" bufs in use %u\n", pool->s.params.buf.num - bufcount); ODP_DBG(" buf allocs %lu\n", bufallocs); ODP_DBG(" buf frees %lu\n", buffrees); ODP_DBG(" buf empty %lu\n", bufempty); diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index f3e70b9..c4291f8 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -15,14 +15,5 @@ int odp_event_type(odp_event_t event) buf = odp_buffer_from_event(event); - switch (_odp_buffer_type(buf)) { - case ODP_BUFFER_TYPE_RAW: - return ODP_EVENT_BUFFER; - case ODP_BUFFER_TYPE_PACKET: - return ODP_EVENT_PACKET; - case ODP_BUFFER_TYPE_TIMEOUT: - return ODP_EVENT_TIMEOUT; - default: - return ODP_EVENT_TYPE_INVALID; - } + return _odp_buffer_type(buf); } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3ce6f47..6c4bb25 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -29,17 +29,17 @@ odp_packet_t odp_packet_alloc(odp_buffer_pool_t pool_hdl, uint32_t len) { pool_entry_t *pool = odp_pool_to_entry(pool_hdl); - if (pool->s.params.buf_type != ODP_BUFFER_TYPE_PACKET) + if (pool->s.params.type != ODP_EVENT_PACKET) return ODP_PACKET_INVALID; /* Handle special case for zero-length packets */ if (len == 0) { odp_packet_t pkt = (odp_packet_t)buffer_alloc(pool_hdl, - pool->s.params.buf_size); + pool->s.params.buf.size); if (pkt != ODP_PACKET_INVALID) pull_tail(odp_packet_hdr(pkt), - pool->s.params.buf_size); + pool->s.params.buf.size); return pkt; } @@ -581,7 +581,7 @@ int odp_packet_is_valid(odp_packet_t pkt) { odp_buffer_hdr_t *buf = validate_buf((odp_buffer_t)pkt); - return (buf != NULL && buf->type == ODP_BUFFER_TYPE_PACKET); + return (buf != NULL && buf->type == ODP_EVENT_PACKET); } /* @@ -627,11 +627,11 @@ odp_packet_t _odp_packet_alloc(odp_buffer_pool_t pool_hdl) { pool_entry_t *pool = odp_pool_to_entry(pool_hdl); - if (pool->s.params.buf_type != ODP_BUFFER_TYPE_PACKET) + if (pool->s.params.type != ODP_EVENT_PACKET) return ODP_PACKET_INVALID; return (odp_packet_t)buffer_alloc(pool_hdl, - pool->s.params.buf_size); + pool->s.params.buf.size); } /** diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 9ca08b7..9e7aed1 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -85,7 +85,7 @@ int odp_schedule_init_global(void) odp_shm_t shm; odp_buffer_pool_t pool; int i, j; - odp_buffer_pool_param_t params; + odp_pool_param_t params; ODP_DBG("Schedule init ... "); @@ -100,10 +100,10 @@ int odp_schedule_init_global(void) return -1; } - params.buf_size = sizeof(queue_desc_t); - params.buf_align = 0; - params.num_bufs = SCHED_POOL_SIZE/sizeof(queue_desc_t); - params.buf_type = ODP_BUFFER_TYPE_RAW; + params.buf.size = sizeof(queue_desc_t); + params.buf.align = 0; + params.buf.num = SCHED_POOL_SIZE/sizeof(queue_desc_t); + params.type = ODP_EVENT_BUFFER; pool = odp_buffer_pool_create("odp_sched_pool", ODP_SHM_NULL, ¶ms); diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 6a89cc2..bc8b0da 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -557,7 +557,7 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) #endif if (odp_likely(tmo_buf != ODP_BUFFER_INVALID)) { /* Fill in metadata fields in system timeout buffer */ - if (_odp_buffer_type(tmo_buf) == ODP_BUFFER_TYPE_TIMEOUT) { + if (_odp_buffer_type(tmo_buf) == ODP_EVENT_TIMEOUT) { /* Convert from buffer to timeout hdr */ odp_timeout_hdr_t *tmo_hdr = timeout_hdr_from_buf(tmo_buf); diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index e12da56..c979e1c 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -828,7 +828,7 @@ int main(int argc, char *argv[]) int first_cpu; odp_shm_t shm; test_globals_t *globals; - odp_buffer_pool_param_t params; + odp_pool_param_t params; printf("\nODP example starts\n\n"); @@ -911,10 +911,10 @@ int main(int argc, char *argv[]) * Create message pool */ - params.buf_size = sizeof(test_message_t); - params.buf_align = 0; - params.num_bufs = MSG_POOL_SIZE/sizeof(test_message_t); - params.buf_type = ODP_BUFFER_TYPE_RAW; + params.buf.size = sizeof(test_message_t); + params.buf.align = 0; + params.buf.num = MSG_POOL_SIZE/sizeof(test_message_t); + params.type = ODP_EVENT_BUFFER; pool = odp_buffer_pool_create("msg_pool", ODP_SHM_NULL, ¶ms);