From patchwork Wed Feb 11 13:20:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44573 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E08621527 for ; Wed, 11 Feb 2015 13:21:29 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf2722355wib.2 for ; Wed, 11 Feb 2015 05:21:28 -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: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=gGq6HhrxiyQgF84jJ/i2JvOZrt21WURxj9rpFYG15zo=; b=fvsE5ElmLoxPELxp6RBOunPv7pk3nb6iRbNp4+WRABjsNoXoGi8U0Iq6k0CHmDiXJq SbXNOBMv4e8BTRuRwYVIwIJ3Hpn3nvJCgMQ5KQf6+yiS46oQxHWN2AAERKr5VTJ9ARIj 0eLL4sh9zyaYMjFC0n7xAfCE7MYekUuSQfbb0ODzex6XGsffxrEtz+lQPj3BGGvH/jVE 4XcZj7+WJqIC2EDqIwAPyMZrDB/MAFILjW89pEqLAhruR5yd8t6wePVDO1IHoIv3/+wN S1LxVceV5yflcNlL8G784X4Lt8PkrhrSfL3ArrgTt4yTEreZn/H28We8XEhXtkjLSEDQ 6NTg== X-Gm-Message-State: ALoCoQn83j/s4ahNqCCyv3UOcBxc2ZsDEkFKLNxX5lHy+a60RBeCgMXsNRV4EIPfbMBKjqweiyS/ X-Received: by 10.180.88.66 with SMTP id be2mr3285546wib.1.1423660888562; Wed, 11 Feb 2015 05:21:28 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.129 with SMTP id d1ls53396laf.18.gmail; Wed, 11 Feb 2015 05:21:28 -0800 (PST) X-Received: by 10.112.55.199 with SMTP id u7mr26910116lbp.74.1423660888399; Wed, 11 Feb 2015 05:21:28 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id yi9si643981lbb.13.2015.02.11.05.21.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 05:21:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labhv19 with SMTP id hv19so3193129lab.10 for ; Wed, 11 Feb 2015 05:21:28 -0800 (PST) X-Received: by 10.112.161.34 with SMTP id xp2mr2196781lbb.73.1423660888293; Wed, 11 Feb 2015 05:21:28 -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.35.133 with SMTP id h5csp1245423lbj; Wed, 11 Feb 2015 05:21:27 -0800 (PST) X-Received: by 10.140.19.14 with SMTP id 14mr14604624qgg.37.1423660886843; Wed, 11 Feb 2015 05:21:26 -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 91si835779qgg.68.2015.02.11.05.21.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Feb 2015 05:21:26 -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 1YLXEG-00084S-Ff; Wed, 11 Feb 2015 13:21:20 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YLXEB-00083l-3y for lng-odp@lists.linaro.org; Wed, 11 Feb 2015 13:21:15 +0000 Received: by mail-pa0-f42.google.com with SMTP id rd3so4016637pab.1 for ; Wed, 11 Feb 2015 05:21:09 -0800 (PST) X-Received: by 10.66.186.65 with SMTP id fi1mr4341285pac.51.1423660868222; Wed, 11 Feb 2015 05:21:08 -0800 (PST) Received: from localhost.localdomain ([210.177.145.245]) by mx.google.com with ESMTPSA id v6sm951842pdp.50.2015.02.11.05.21.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Feb 2015 05:21:07 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 11 Feb 2015 05:20:59 -0800 Message-Id: <1423660859-15433-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [RFC PATCH] api: pool: proposed pool parameters for packets 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: 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.215.45 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 Signed-off-by: Bill Fischofer --- Based on the discussions we had this afternoon, here is a proposed patch that I believe covers the concerns of all parties. The application is free to request minimum segment sizes or to leave that to the implementation or to request that packets be unsegmented. The implementation, in turn, controls the actual segment size used (if any) and will reject pool create requests that it is unable to comply with. It is also part of the API specification that any segment size used by an ODP implementation will be a minimum of 256 bytes and always be a multiple of 8 bytes in size. This also adds requested headroom and tailroom parameters to the pool create parameter list for packets. Note that this is an RFC because it is not a complete patch: The examples are not updated to reflect these changes. If this API is acceptable I'll forward a complete patch conforming to it. include/odp/api/pool.h | 51 ++++++++++++++++++++++++++++---- platform/linux-generic/odp_buffer_pool.c | 35 +++++++++++++++------- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h index b8c0f2e..c794c66 100644 --- a/include/odp/api/pool.h +++ b/include/odp/api/pool.h @@ -60,13 +60,54 @@ typedef struct odp_pool_param_t { 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; + uint32_t len; /**< Expected average packet length + in bytes. This is used by the + implementation to calculate + the amount of storage needed for + the pool. If this number is less + than the actual average packet + length then the effect will be + that the number of packets that + can be stored in the pool will be + less than num. */ + uint32_t align; /**< Minimum pkt 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; /**< Maximum number of packets + that this pool may contain. */ + uint32_t seg_size; /**< Requested minimum segment size + to be used for this pool, The + implementation is free to use + a segment size larger than this + value. Any segment size used + will always be a multiple of 8 + bytes and will never be less + than 256 bytes. If seg_size == 0, + the application has no + preference and the implementation + is free to a segment size of + its choosing, subject to the + previously noted constraints. + If seg_size >= len, the + application is requesting that + the pool be unsegmented. */ + uint32_t headroom; /**< Requested headroom for packets + allocated from this pool. This + is the minimum headroom that + will be used. The implementation + may increase this value by any + multiple of 8 for internal + reasons. */ + uint32_t tailroom; /**< Requested tailroom for packets + allocated from this pool. This + is the minimum tailroom that + will be used. The implementation + may increase this by any byte + value for internal reasons. */ } pkt; -*/ struct { uint32_t __res1; /* Keep struct identical to buf, */ uint32_t __res2; /* until pool implementation is fixed*/ diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 69acf1b..17f5bf5 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -138,6 +138,7 @@ odp_pool_t odp_pool_create(const char *name, uint32_t blk_size, buf_stride; uint32_t buf_align = params->buf.align; + uint32_t seg_size; /* Validate requested buffer alignment */ if (buf_align > ODP_CONFIG_BUFFER_ALIGN_MAX || @@ -166,18 +167,32 @@ odp_pool_t odp_pool_create(const char *name, break; case ODP_POOL_PACKET: - headroom = ODP_CONFIG_PACKET_HEADROOM; - tailroom = ODP_CONFIG_PACKET_TAILROOM; - unsegmented = params->buf.size > ODP_CONFIG_PACKET_BUF_LEN_MAX; + headroom = params->pkt.headroom; + tailroom = params->pkt.tailroom; + unsegmented = params->pkt.seg_size >= params->pkt.len; - if (unsegmented) + if (unsegmented) { blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf.size + tailroom, + headroom + params->pkt.len + tailroom, buf_align); - else - blk_size = ODP_ALIGN_ROUNDUP( - headroom + params->buf.size + tailroom, - ODP_CONFIG_PACKET_BUF_LEN_MIN); + } else { + seg_size = + ODP_ALIGN_ROUNDUP(params->pkt.seg_size, 8); + if (seg_size == 0) { + blk_size = ODP_ALIGN_ROUNDUP( + headroom + params->pkt.len + tailroom, + ODP_CONFIG_PACKET_BUF_LEN_MIN); + } else { + if (seg_size < 256) + seg_size = 256; + else + seg_size = + ODP_ALIGN_ROUNDUP(seg_size, 8); + blk_size = ODP_ALIGN_ROUNDUP( + headroom + params->pkt.len + tailroom, + seg_size); + } + } buf_stride = params->type == ODP_POOL_PACKET ? sizeof(odp_packet_hdr_stride) : @@ -279,7 +294,7 @@ odp_pool_t odp_pool_create(const char *name, pool->s.flags.unsegmented = unsegmented; pool->s.flags.zeroized = zeroized; pool->s.seg_size = unsegmented ? - blk_size : ODP_CONFIG_PACKET_BUF_LEN_MIN; + blk_size : seg_size; uint8_t *block_base_addr = pool->s.pool_base_addr;