From patchwork Mon Mar 20 10:03:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 21986 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id BDF224CC5; Mon, 20 Mar 2017 10:57:43 +0100 (CET) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0053.outbound.protection.outlook.com [104.47.38.53]) by dpdk.org (Postfix) with ESMTP id 83FDC2C29 for ; Mon, 20 Mar 2017 10:57:30 +0100 (CET) Received: from BN3PR03CA0064.namprd03.prod.outlook.com (10.167.1.152) by CY1PR03MB2267.namprd03.prod.outlook.com (10.166.207.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Mon, 20 Mar 2017 09:57:24 +0000 Received: from BN1BFFO11FD040.protection.gbl (2a01:111:f400:7c10::1:186) by BN3PR03CA0064.outlook.office365.com (2a01:111:e400:7a4d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.977.11 via Frontend Transport; Mon, 20 Mar 2017 09:57:24 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD040.mail.protection.outlook.com (10.58.144.103) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Mon, 20 Mar 2017 09:57:24 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.39]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2K9vJ3Z015173; Mon, 20 Mar 2017 02:57:21 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain Date: Mon, 20 Mar 2017 15:33:09 +0530 Message-ID: <1490004190-16892-1-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131344774446487754; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39850400002)(39860400002)(39450400003)(39840400002)(39400400002)(39410400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(8656002)(110136004)(38730400002)(305945005)(81166006)(8676002)(5660300001)(4326008)(36756003)(356003)(85426001)(47776003)(2906002)(86362001)(5003940100001)(106466001)(105606002)(8936002)(50986999)(77096006)(6666003)(50226002)(54906002)(33646002)(50466002)(2351001)(48376002)(6916009)(189998001)(104016004)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2267; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD040; 1:aX4RLesBFNuY6Oefyr713wVVmm9yKazHLVBQaL+I29E9ZSkFLB1q8+AfZGrnSDIn5Ss4ZqYPSA90+SDq73QUBjKPeNiK715gEHexhtD/jMT2lundHQFoCnCITuUx6HPaiVVYFXhlJZhEvI+8pGFWKM9swDHvEZbJEDP2N/+h42fgN1qx06sl5E4R3NionZrndldlZZuOgnebpdEPGffBaDYimXxkwciDAz2qV/dEdbAfs8f3rJ+hoCj5hQ8ZfCGdyXZBEaVV77XfW9IpzeMjBb00p8HNEwIbPq3qk8nPCLrU+XpWBMErVyVHZ6RCn0Iyj1CunBC9hiHvcSIWCMoEFqA2qCBFKS4pjHKYxh3sCs6WeTuzfHaVJXufIuYgFzQIH6pGlofCMA1SluZwK3XMX9948jZ4Es+2m0W1O4rvEGCsVoPTsfBe1iSnr2Eg8qIcFEosh4Ql76Vlc1nXYgiNcJZMCJCxTXUjq56lHXIQtNX/H+ncCrHoFrt/pMXezaUn4ncDc9WiKDt5905OlApcW6BVh/hIQI7tOeNuTxqZgsuV773lDhU7IbCEJ6l1EOJfjcIt4Mee2cJb4n70fZKAvsF4C3tPKGk8U8feDWA/QI8UAQSVF4FfotSVMoLO7St0nw3q87Tp/vDRCRSi1gvCeedJTqLgrnbQc7+oQS5g6WO2rqPph3HLYlUkjVZkWueRX5S7CVcz8Nmb5PeRMsiHSQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 150a8be5-14ff-4447-376d-08d46f778271 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR03MB2267; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2267; 3:ouZtrdXatUHYHzzlKDqtxTXYihRC+mgGfWpq0py7SIe70eik1PjLHNUywFO9JO9cx+q+25MzwPQb79EIsLm96ELd8fUMsNs8Sa24VcMcEmyzysELhBziURTZuiCNyXvkeXB9eP/GluZUXR1rqFYM+KOVogge9q8bRLE36VfNGsWZU7pP/K/j1OzFZ97xdxP5ZgMyEN2hYjK9DqCOBzHE332X8SyCGN2qTMM2UuIXKoJMc+8wfk+rp7xiEj5dixnGHZSFsVwcHXGR/Vb9iwwIjXpC19B8YvpoGJN10Y+64wom3C6LOSoP341bxeo3K0WahWmlMmKgzSVtzp38RyFY2E9nxSJMKbCwbADlbv8PGaYUPWpZ72JzBU/Cfqnjm1ec; 25:VLjeIKTChOVF64/mfICIOFJbkm+mnvwRFGgz0+iZaf4JJ8isKD5zKKAKlg3WySMISOnL3s8Rz4loi008RvrOKzTJ1bNEiCrNewzvEUNxM//JmwGFuYFDcoXVReMiWO2Fb6h4A4P0yLbnc59rZPXZxGxFJPgi5+J93NVIeOwz6mjtSW85HRr4DpWdKr4GkRC6ASdI8vrN36B8B/1VcBx2ureoHtz4/kMYTvlo9FhqCN2VDUNlP8vWf3rdVGmYeb0gS/pYVyeA5GTAJcsvIg+4/cNcczkSCle2Ww5O39MdLye45ZEa1jXTpXm9jOL3oMmCC3HbBda+V+Od0nW3z6izpHUH2GaY5+vJbGPHExo6xnSCqewlBkphsyXnp8az6cLttNxNaeI8G6EWf0uGG1BqCR2Rtj6DcUAO9DqFApPTStZiRiiSYeDSHiP/AQsEzVFDPUbXpntafEjwq0elgC+SXQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2267; 31:mRg4Tdbnxdkxabw+R2b0cxU/7Weg+3XJkOfYkFSzOXRNtol12yS8K0U+V7iZ6CSltKGkwkp5mxIbdGeaDwLm3jTZDkxNvTrpANsUhLuXCSHYGM3PFfs8R6Y0lYG1uN3fXGeSDShprA1iXIhhLnG1SDpNFKoCirWqk+d+lWHPoTU4/HfVuWIFNDUQWg+yN3MT40i9bExejnD5tniaM9S7oIuWpi8sxFvkvSR6forG2hEeYSGyIKwLIhcc7jgta+Tq0rxY8lEx4likkotsk4LTpQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13023025)(13015025)(5005006)(13017025)(13024025)(13018025)(8121501046)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(20161123559025)(20161123556025)(20161123561025); SRVR:CY1PR03MB2267; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2267; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2267; 4:MXfBeBW+9z0AJDGQQy6gfwrtjIvlN9kDBjG3rMpX8dVgYgrypm83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fd5J7okR0U5gNTrcY8ngEeJatYA5pBtyG6Ds+20lPcPzRYKiXaDB1+UpdV9y9fYm8fLYRQNX8nbwBwkF7ZWjRuOB4LAgTegOgPAJOi5JeNf9uiGhG99yCIw+Eaw6Ai91OqwIVRywSZnklw+kz0Jmxx3hZC0fUVFJmBBQpAPDxumtR+J6yi4enTzVD7onUBxjZmlUbGhoCsLZhNofsQmpWCM3yqy8hLW7rScK5+pdeQqLoS2OQVPFluO7Ji2A300e4sYApvZVbsXvoGFy4MiAYknGMfh6y9KqvpmnWn49NWQPlGRe4=; 5:e76NHoq9PE9Cm5gFNOuJlw3dTbHd+80dJ+JFSKlYiQU5uUXIqe6DH/drcHIln6pyQijOTiGpSnArEmE9zTKOn7xBeGWNsyhiZ0TUWTm2Z2zU0Af98B5JJusN6Zm33hzTMjqw7fg/2UxFNAXYvyYtJVYX34y3sgsgOHHkiESDOvgbvlYPukkCkYBgy9AQkiyu; 24:CCqwTyoafPcfP5w3i7rn17SCbavAZ7iqNMgxlz31AmIcZVYqMr3ak+4Wvp2vhwOJlVP66Wb+hKnAGoeUd45NAyQZq9djqGeuNzrozhYytJ4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2267; 7:v5Kh//lQN3MgeJFykq5kcvp24kitVJi2Q5q5neEpbDTDQnOBFAgf+gGVo+PI5/hgztHuN5SkI3xDCkll2J7UwHbbq46s3TlQsJwy34rLiVG279lT/+Rmai1o5VrN0sfJ4MHcnaSb6XzRO7ySEq12egZL4wRly3Wn/U94dnCAv+kyZHqyMUpXiVeQDMgFkrOKSd+uS4+B322x9jEoGVftCb5dUfXlJCrbtl1axRbEPLM4s5TOAcocfJxtd03IVhLprvNOgp+OEutgLlFpv9mkyJFi//+xFEemSLy3NU1bu60VFapCLOJsDTB/FrLoULYUP9y3AWX286XcF3VYWx7Fhg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2017 09:57:24.3523 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB2267 Subject: [dpdk-dev] [PATCH 1/2] drivers/mempool: add stack mempool handler as driver 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" CONFIG_RTE_DRIVER_MEMPOOL_STACK option added to common_base. Stack mempool handler moved from lib/librte_mempool into drivers/mempool. With this patch, the Stack mempool handler registration is optional and toggled via the configuration file. In case disabled (N), it would imply request for creating of mempool would fail. Signed-off-by: Shreyansh Jain --- config/common_base | 5 + drivers/Makefile | 1 + drivers/mempool/Makefile | 36 +++++ drivers/mempool/stack/Makefile | 55 ++++++++ drivers/mempool/stack/rte_mempool_stack.c | 147 +++++++++++++++++++++ .../mempool/stack/rte_mempool_stack_version.map | 4 + lib/librte_mempool/Makefile | 1 - lib/librte_mempool/rte_mempool_stack.c | 147 --------------------- 8 files changed, 248 insertions(+), 148 deletions(-) create mode 100644 drivers/mempool/Makefile create mode 100644 drivers/mempool/stack/Makefile create mode 100644 drivers/mempool/stack/rte_mempool_stack.c create mode 100644 drivers/mempool/stack/rte_mempool_stack_version.map delete mode 100644 lib/librte_mempool/rte_mempool_stack.c diff --git a/config/common_base b/config/common_base index 37aa1e1..3e70aa0 100644 --- a/config/common_base +++ b/config/common_base @@ -464,6 +464,11 @@ CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE=512 CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n # +# Compile Mempool drivers +# +CONFIG_RTE_DRIVER_MEMPOOL_STACK=y + +# # Compile librte_mbuf # CONFIG_RTE_LIBRTE_MBUF=y diff --git a/drivers/Makefile b/drivers/Makefile index 81c03a8..193056b 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -31,6 +31,7 @@ include $(RTE_SDK)/mk/rte.vars.mk +DIRS-y += mempool DIRS-y += net DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += crypto diff --git a/drivers/mempool/Makefile b/drivers/mempool/Makefile new file mode 100644 index 0000000..b256a34 --- /dev/null +++ b/drivers/mempool/Makefile @@ -0,0 +1,36 @@ +# BSD LICENSE +# +# Copyright(c) 2017 NXP. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of NXP nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include $(RTE_SDK)/mk/rte.vars.mk + +DIRS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += stack + +include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/mempool/stack/Makefile b/drivers/mempool/stack/Makefile new file mode 100644 index 0000000..f98eb5b --- /dev/null +++ b/drivers/mempool/stack/Makefile @@ -0,0 +1,55 @@ +# BSD LICENSE +# +# Copyright(c) 2017 NXP. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of NXP nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_mempool_stack.a + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +# Headers +CFLAGS += -I$(RTE_SDK)/lib/librte_mempool + +EXPORT_MAP := rte_mempool_stack_version.map + +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += rte_mempool_stack.c + +# this lib depends upon: +DEPDIRS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += lib/librte_eal +DEPDIRS-$(CONFIG_RTE_DRIVER_MEMPOOL_STACK) += lib/librte_mempool + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/mempool/stack/rte_mempool_stack.c b/drivers/mempool/stack/rte_mempool_stack.c new file mode 100644 index 0000000..817f77e --- /dev/null +++ b/drivers/mempool/stack/rte_mempool_stack.c @@ -0,0 +1,147 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +struct rte_mempool_stack { + rte_spinlock_t sl; + + uint32_t size; + uint32_t len; + void *objs[]; +}; + +static int +stack_alloc(struct rte_mempool *mp) +{ + struct rte_mempool_stack *s; + unsigned n = mp->size; + int size = sizeof(*s) + (n+16)*sizeof(void *); + + /* Allocate our local memory structure */ + s = rte_zmalloc_socket("mempool-stack", + size, + RTE_CACHE_LINE_SIZE, + mp->socket_id); + if (s == NULL) { + RTE_LOG(ERR, MEMPOOL, "Cannot allocate stack!\n"); + return -ENOMEM; + } + + rte_spinlock_init(&s->sl); + + s->size = n; + mp->pool_data = s; + + return 0; +} + +static int +stack_enqueue(struct rte_mempool *mp, void * const *obj_table, + unsigned n) +{ + struct rte_mempool_stack *s = mp->pool_data; + void **cache_objs; + unsigned index; + + rte_spinlock_lock(&s->sl); + cache_objs = &s->objs[s->len]; + + /* Is there sufficient space in the stack ? */ + if ((s->len + n) > s->size) { + rte_spinlock_unlock(&s->sl); + return -ENOBUFS; + } + + /* Add elements back into the cache */ + for (index = 0; index < n; ++index, obj_table++) + cache_objs[index] = *obj_table; + + s->len += n; + + rte_spinlock_unlock(&s->sl); + return 0; +} + +static int +stack_dequeue(struct rte_mempool *mp, void **obj_table, + unsigned n) +{ + struct rte_mempool_stack *s = mp->pool_data; + void **cache_objs; + unsigned index, len; + + rte_spinlock_lock(&s->sl); + + if (unlikely(n > s->len)) { + rte_spinlock_unlock(&s->sl); + return -ENOENT; + } + + cache_objs = s->objs; + + for (index = 0, len = s->len - 1; index < n; + ++index, len--, obj_table++) + *obj_table = cache_objs[len]; + + s->len -= n; + rte_spinlock_unlock(&s->sl); + return 0; +} + +static unsigned +stack_get_count(const struct rte_mempool *mp) +{ + struct rte_mempool_stack *s = mp->pool_data; + + return s->len; +} + +static void +stack_free(struct rte_mempool *mp) +{ + rte_free((void *)(mp->pool_data)); +} + +static struct rte_mempool_ops ops_stack = { + .name = "stack", + .alloc = stack_alloc, + .free = stack_free, + .enqueue = stack_enqueue, + .dequeue = stack_dequeue, + .get_count = stack_get_count +}; + +MEMPOOL_REGISTER_OPS(ops_stack); diff --git a/drivers/mempool/stack/rte_mempool_stack_version.map b/drivers/mempool/stack/rte_mempool_stack_version.map new file mode 100644 index 0000000..8591cc0 --- /dev/null +++ b/drivers/mempool/stack/rte_mempool_stack_version.map @@ -0,0 +1,4 @@ +DPDK_17.05 { + + local: *; +}; diff --git a/lib/librte_mempool/Makefile b/lib/librte_mempool/Makefile index 057a6ab..a4c089e 100644 --- a/lib/librte_mempool/Makefile +++ b/lib/librte_mempool/Makefile @@ -44,7 +44,6 @@ LIBABIVER := 2 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += rte_mempool.c SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += rte_mempool_ops.c SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += rte_mempool_ring.c -SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += rte_mempool_stack.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_MEMPOOL)-include := rte_mempool.h diff --git a/lib/librte_mempool/rte_mempool_stack.c b/lib/librte_mempool/rte_mempool_stack.c deleted file mode 100644 index 817f77e..0000000 --- a/lib/librte_mempool/rte_mempool_stack.c +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2016 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -struct rte_mempool_stack { - rte_spinlock_t sl; - - uint32_t size; - uint32_t len; - void *objs[]; -}; - -static int -stack_alloc(struct rte_mempool *mp) -{ - struct rte_mempool_stack *s; - unsigned n = mp->size; - int size = sizeof(*s) + (n+16)*sizeof(void *); - - /* Allocate our local memory structure */ - s = rte_zmalloc_socket("mempool-stack", - size, - RTE_CACHE_LINE_SIZE, - mp->socket_id); - if (s == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate stack!\n"); - return -ENOMEM; - } - - rte_spinlock_init(&s->sl); - - s->size = n; - mp->pool_data = s; - - return 0; -} - -static int -stack_enqueue(struct rte_mempool *mp, void * const *obj_table, - unsigned n) -{ - struct rte_mempool_stack *s = mp->pool_data; - void **cache_objs; - unsigned index; - - rte_spinlock_lock(&s->sl); - cache_objs = &s->objs[s->len]; - - /* Is there sufficient space in the stack ? */ - if ((s->len + n) > s->size) { - rte_spinlock_unlock(&s->sl); - return -ENOBUFS; - } - - /* Add elements back into the cache */ - for (index = 0; index < n; ++index, obj_table++) - cache_objs[index] = *obj_table; - - s->len += n; - - rte_spinlock_unlock(&s->sl); - return 0; -} - -static int -stack_dequeue(struct rte_mempool *mp, void **obj_table, - unsigned n) -{ - struct rte_mempool_stack *s = mp->pool_data; - void **cache_objs; - unsigned index, len; - - rte_spinlock_lock(&s->sl); - - if (unlikely(n > s->len)) { - rte_spinlock_unlock(&s->sl); - return -ENOENT; - } - - cache_objs = s->objs; - - for (index = 0, len = s->len - 1; index < n; - ++index, len--, obj_table++) - *obj_table = cache_objs[len]; - - s->len -= n; - rte_spinlock_unlock(&s->sl); - return 0; -} - -static unsigned -stack_get_count(const struct rte_mempool *mp) -{ - struct rte_mempool_stack *s = mp->pool_data; - - return s->len; -} - -static void -stack_free(struct rte_mempool *mp) -{ - rte_free((void *)(mp->pool_data)); -} - -static struct rte_mempool_ops ops_stack = { - .name = "stack", - .alloc = stack_alloc, - .free = stack_free, - .enqueue = stack_enqueue, - .dequeue = stack_dequeue, - .get_count = stack_get_count -}; - -MEMPOOL_REGISTER_OPS(ops_stack);