From patchwork Wed Aug 28 14:46:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 172391 Delivered-To: patch@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp1015958ocp; Wed, 28 Aug 2019 07:46:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqcQXxxTOxybQI4GV7uKUgFG2CJvNFU8hyOjtP15pWXbm55U4zH3YCODR+uHsctgBjGiim X-Received: by 2002:a17:907:2091:: with SMTP id pv17mr3500141ejb.157.1567003591920; Wed, 28 Aug 2019 07:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567003591; cv=none; d=google.com; s=arc-20160816; b=boZtfmMxWVxBSbt1cNilzymLQLMNJSK8HY0FDGqfti4TiJrHlTJPlWj6AzaVzo6ph1 lCrKya7dgzgId0w36WqV5XkJqs+DuictTX+Psx92GWwNp648wmXaDLCPfGZKSsmS2RYw 9DHzcQYb8Xqu1/TEShRyuP6pRAJ6BmzVLCM8SxcJbGZ2x9rh6sF6Ow5ZWp5K1x4XMbqf MngoBtexq//Kn7dgmUU01WiRWjLXM2u7AhWCmQoQGubwKxaYNEJPn1U4C7iXThZ3z2+7 2F8g9KGjYqOY5rVy+USwQQ1ssBeMkVzV/Cfgxk2h+7e9Of0sV0gsCO0jUsjhf13Lb1we 1kGw== 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:message-id:date:cc:to :from; bh=DiGvEp+RnLd+PYJ5FkHZt5Fu7zXVIRADOnPj6GG0p7E=; b=WPwe/TBizH4po3CLhX+yD40ijun7yakfRmdVl1FiioZLfso3ovThmasjIIhdH5KwAs ujQsQRh87s615IoQclyJO5o4Ys8UNXDrTr70+Ah6nFJuF7iaXSLlMlibnPjz/MJQoJ2D UsXNARTaVfRj9/t8jamil9hEnpPD9RjWNN2HEc+dmp0Esoe3CzKwijhuR6n1NdWqGR1K 1SdqcEo3FleAkK6xpe3iYbbNMKoXJGQPO5XgJ/nI0s9Lvl0T6mc8/4fVz379uWEapV1H qaoJKLGo2JKmNOlUlho6h1aQLf8u2eUyAlqyjlT+ttEoBUoxb/WHrHCHWaNFobqOWojL Y/bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id b1si1328567eju.178.2019.08.28.07.46.31; Wed, 28 Aug 2019 07:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 666E954AE; Wed, 28 Aug 2019 16:46:30 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 24BB62952 for ; Wed, 28 Aug 2019 16:46:29 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7363A28; Wed, 28 Aug 2019 07:46:28 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 67E0F3F246; Wed, 28 Aug 2019 07:46:28 -0700 (PDT) From: Honnappa Nagarahalli To: olivier.matz@6wind.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, honnappa.nagarahalli@arm.com Cc: dev@dpdk.org, dharmik.thakkar@arm.com, gavin.hu@arm.com, ruifeng.wang@arm.com, nd@arm.com Date: Wed, 28 Aug 2019 09:46:09 -0500 Message-Id: <20190828144614.25284-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 0/5] lib/ring: templates to support custom element size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The current rte_ring hard-codes the type of the ring element to 'void *', hence the size of the element is hard-coded to 32b/64b. Since the ring element type is not an input to rte_ring APIs, it results in couple of issues: 1) If an application requires to store an element which is not 64b, it needs to writes its own ring APIs similar to rte_event_ring APIs. This creates additional burden on the programmers, who simply end up making work-arounds and often waste memory. 2) If there are multiple libraries that store elements of the same type, currently they would have to write their own rte_ring APIs. This results in code duplication. This patch consists of 4 parts: 1) New APIs to support configurable ring element size These will help reduce code duplication in the templates. I think these can be made internal (do not expose to DPDK applications, but expose to DPDK libraries), feedback needed. 2) rte_ring templates The templates provide an easy way to add new APIs for different ring element types/sizes which can be used by multiple libraries. These also allow for creating APIs to store elements of custom types (for ex: a structure) The template needs 4 parameters: a) RTE_RING_TMPLT_API_SUFFIX - This is used as a suffix to the rte_ring APIs. For ex: if RTE_RING_TMPLT_API_SUFFIX is '32b', the API name will be rte_ring_create_32b b) RTE_RING_TMPLT_ELEM_SIZE - Size of the ring element in bytes. For ex: sizeof(uint32_t) c) RTE_RING_TMPLT_ELEM_TYPE - Type of the ring element. For ex: uint32_t. If a common ring library does not use a standard data type, it should create its own type by defining a structure with standard data type. For ex: for an elment size of 96b, one could define a structure struct s_96b { uint32_t a[3]; } The common library can use this structure to define RTE_RING_TMPLT_ELEM_TYPE. The application using this common ring library should define its element type as a union with the above structure. union app_element_type { struct s_96b v; struct app_element { uint16_t a; uint16_t b; uint32_t c; uint32_t d; } } d) RTE_RING_TMPLT_EXPERIMENTAL - Indicates if the new APIs being defined are experimental. Should be set to empty to remove the experimental tag. The ring library consists of some APIs that are defined as inline functions and some APIs that are non-inline functions. The non-inline functions are in rte_ring_template.c. However, this file needs to be included in other .c files. Any feedback on how to handle this is appreciated. Note that the templates help create the APIs that are dependent on the element size (for ex: rte_ring_create, enqueue/dequeue etc). Other APIs that do NOT depend on the element size do not need to be part of the template (for ex: rte_ring_dump, rte_ring_count, rte_ring_free_count etc). 3) APIs for 32b ring element size This uses the templates to create APIs to enqueue/dequeue elements of size 32b. 4) rte_hash libray is changed to use 32b ring APIs The 32b APIs are used in rte_hash library to store the free slot index and free bucket index. This patch results in following checkpatch issue: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' The patch is following the rules in the existing code. Please let me know if this needs to be fixed. Honnappa Nagarahalli (5): lib/ring: apis to support configurable element size lib/ring: add template to support different element sizes tools/checkpatch: relax constraints on __rte_experimental lib/ring: add ring APIs to support 32b ring elements lib/hash: use ring with 32b element size to save memory devtools/checkpatches.sh | 11 +- lib/librte_hash/rte_cuckoo_hash.c | 55 ++--- lib/librte_hash/rte_cuckoo_hash.h | 2 +- lib/librte_ring/Makefile | 9 +- lib/librte_ring/meson.build | 11 +- lib/librte_ring/rte_ring.c | 34 ++- lib/librte_ring/rte_ring.h | 72 ++++++ lib/librte_ring/rte_ring_32.c | 19 ++ lib/librte_ring/rte_ring_32.h | 36 +++ lib/librte_ring/rte_ring_template.c | 46 ++++ lib/librte_ring/rte_ring_template.h | 330 +++++++++++++++++++++++++++ lib/librte_ring/rte_ring_version.map | 4 + 12 files changed, 582 insertions(+), 47 deletions(-) create mode 100644 lib/librte_ring/rte_ring_32.c create mode 100644 lib/librte_ring/rte_ring_32.h create mode 100644 lib/librte_ring/rte_ring_template.c create mode 100644 lib/librte_ring/rte_ring_template.h -- 2.17.1