From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 33B1EA2EDB for ; Wed, 2 Oct 2019 06:22:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7744B343C; Wed, 2 Oct 2019 06:22:07 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10042.outbound.protection.outlook.com [40.107.1.42]) by dpdk.org (Postfix) with ESMTP id A08C5324D for ; Wed, 2 Oct 2019 06:22:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kk6k9YewCvXuFRXNLRmtt/3oESv2nM8xvy1fNlzaN/k=; b=uc4YZCPRI384HLag3eeNR8z07VbCi3sSGquK8SXbGYwMdvzB3cL9gnA86qEMQHq/PLBAc6rkCMvsY/jxpRhx/deHi0xS4bhIDoYuh3HRap45RGUEOJh/6+t+aRds1IfJZeBR9MxqFxCDzTgWfcZUJkV6pPI0mwXw+I+tNpfBLR8= Received: from VE1PR08CA0031.eurprd08.prod.outlook.com (2603:10a6:803:104::44) by VI1PR08MB4560.eurprd08.prod.outlook.com (2603:10a6:803:100::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Wed, 2 Oct 2019 04:22:02 +0000 Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::202) by VE1PR08CA0031.outlook.office365.com (2603:10a6:803:104::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.20 via Frontend Transport; Wed, 2 Oct 2019 04:22:02 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=none action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Wed, 2 Oct 2019 04:22:01 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Wed, 02 Oct 2019 04:21:59 +0000 X-CR-MTA-TID: 64aa7808 Received: from 9cc883cafe9a.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.5.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8021BEAC-5710-47A0-B35C-ADF0F286F0A2.1; Wed, 02 Oct 2019 04:21:54 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2055.outbound.protection.outlook.com [104.47.5.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9cc883cafe9a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Wed, 02 Oct 2019 04:21:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M666v+VPI6YvmoHym3tCOeUZkW4jkr6rlbol7HVrQhwuIVV+iMdjRSaHQ72U3u0Tah+ajPadlmFuHlOKy1hgD7jzOVPF/1wJWyeSR0aq30y1VdNfxCxc1htOttpjuFHL2GgTifulnYggqcawvuOBol8MdQa3smnQfJUkMsogOj33MGcB0WNIqv2+wQOMGQjXs+/V+ZH4V1yaIFNl070B1JPFezOOCSkNKackis7OBcpjnov9fPEEkt0DGLW5KXnemDyj3osTFP+IEmRlaqAqL8LF8c1nyIAC+Dzun6JEWKRajOlBAqVMeGcexGpai04dQfa0DDYYeJSrb/E6q7U5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kk6k9YewCvXuFRXNLRmtt/3oESv2nM8xvy1fNlzaN/k=; b=jO03nI95dXe/bXGBXeoXdeLyD+HEJq+vMy74oR+KioY9bN9LMP97aNEaSzdECx3UZEF6dvPeaZ2SgXePVIEiFNG5i1pw2QbOVFK1uq40nuuKrW9/j4ACLqAXiBBEzyYzBX5DntcUj96zpyqbQDTEBYlrkLfl9EHhhySx8kx6K2MwBeutRiuLQfa/ezwx1MG7vn+PE6Ds6W9olOidqlppi+47eN9t0ubkgNr3oN/eVRjoYlSzhvcM+XS7vxkM2GZi8Tek1p6EmERHjg4nFT5r1mXYI9KQI3ETDQSXP5yfexF/U0rmEbQpPaShenlWVpiBrKQv9pcMJuLa3U9tOwpc0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kk6k9YewCvXuFRXNLRmtt/3oESv2nM8xvy1fNlzaN/k=; b=uc4YZCPRI384HLag3eeNR8z07VbCi3sSGquK8SXbGYwMdvzB3cL9gnA86qEMQHq/PLBAc6rkCMvsY/jxpRhx/deHi0xS4bhIDoYuh3HRap45RGUEOJh/6+t+aRds1IfJZeBR9MxqFxCDzTgWfcZUJkV6pPI0mwXw+I+tNpfBLR8= Received: from VE1PR08MB5149.eurprd08.prod.outlook.com (20.179.30.27) by VE1PR08MB5072.eurprd08.prod.outlook.com (20.179.30.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Wed, 2 Oct 2019 04:21:50 +0000 Received: from VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::8c82:8d9c:c78d:22a6]) by VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::8c82:8d9c:c78d:22a6%7]) with mapi id 15.20.2305.023; Wed, 2 Oct 2019 04:21:50 +0000 From: Honnappa Nagarahalli To: "Ananyev, Konstantin" , "olivier.matz@6wind.com" , "Wang, Yipeng1" , "Gobriel, Sameh" , "Richardson, Bruce" , "De Lara Guarch, Pablo" CC: "dev@dpdk.org" , Dharmik Thakkar , "Gavin Hu (Arm Technology China)" , "Ruifeng Wang (Arm Technology China)" , Honnappa Nagarahalli , nd , nd Thread-Topic: [dpdk-dev] [PATCH 2/5] lib/ring: add template to support different element sizes Thread-Index: AQHVeNjpHH4E8KSmr0+S7oLedx6nOw== Date: Wed, 2 Oct 2019 04:21:49 +0000 Message-ID: References: <20190828144614.25284-1-honnappa.nagarahalli@arm.com> <20190828144614.25284-3-honnappa.nagarahalli@arm.com> <2601191342CEEE43887BDE71AB977258019196E21E@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB977258019196E21E@irsmsx105.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 9c89d6b9-9990-4566-b250-1ae0ad913136.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 935854a3-4ac7-4f2b-ecb2-08d746f01275 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5072:|VE1PR08MB5072:|VI1PR08MB4560: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; x-forefront-prvs: 0178184651 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(366004)(396003)(136003)(39860400002)(51914003)(199004)(189003)(81156014)(4326008)(6436002)(71200400001)(52536014)(71190400001)(5660300002)(186003)(25786009)(30864003)(7696005)(8936002)(229853002)(81166006)(110136005)(486006)(14454004)(446003)(478600001)(476003)(99286004)(11346002)(316002)(54906003)(3846002)(6116002)(9686003)(74316002)(256004)(26005)(14444005)(2906002)(6506007)(2501003)(7736002)(305945005)(6246003)(102836004)(33656002)(76176011)(76116006)(64756008)(66446008)(55016002)(86362001)(66066001)(66946007)(66476007)(66556008)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5072; H:VE1PR08MB5149.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TMyoyIhQKG81QR+6qV7DqAPnB8L8Mbcyu3J4Ss3+2CowwP1JzbHmmGX5zHap/5DssJzUX14/Z9XMU2gM3Bfa97B0OT5HNHWdq4u2PBnZwKpZv6/GRIA9FJ1MuY5kszioSJ3lWiCd4b5/39BjwrUqRbqGdV2k/TQbcPpeTD/vrBB2mWP5oJf2rb/xyidg7V/DyT/SBvmhSrv0KT7qBF/YS+jpJv6sg8gqXBukVxslPqra+1jCiihtk5R0K7KdBMZp6Wej3aiCa8rQAjaOcmvbQ5PLqnuKYnkmkiHTPAY8EZLpIsbuaN1VyeDFWT4HfvG6P2OC2NZpYfoNimAI/5DQeUBCGmrb+8FMWPPveJY+k34KevQdkZVUD0w3zz3x1peo8fstffkiqyHYoAtHAV4z10cOYgsupUFez/OKA+AXkpE= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5072 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(376002)(136003)(396003)(51914003)(189003)(199004)(76130400001)(25786009)(186003)(70206006)(26005)(110136005)(2501003)(316002)(336012)(36906005)(54906003)(50466002)(66066001)(7736002)(305945005)(74316002)(99286004)(70586007)(476003)(7696005)(63350400001)(4326008)(6246003)(356004)(11346002)(446003)(33656002)(52536014)(2906002)(23726003)(126002)(229853002)(86362001)(486006)(3846002)(55016002)(46406003)(76176011)(9686003)(14454004)(102836004)(47776003)(97756001)(22756006)(478600001)(26826003)(81166006)(14444005)(8746002)(30864003)(81156014)(5660300002)(8936002)(6506007)(6116002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4560; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 8ad4ed9b-c12f-42b5-e2cc-08d746f00bd5 NoDisclaimer: True X-Forefront-PRVS: 0178184651 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iB0mwiAPnlHwj6tPKnKbQpjtYBDbblYB9t33TyncDzpnTlzGMzlxwY6nos9JRwMzYGTqAKQ70E3hGvs48XOIruiux8AN5lDigymaBB9HGCVCLLUUvfuxxz+YZDmeKZu0K1yi4XHH5dU/QKSELstcSZplQ736YVFcmi2oniHvWG0QAUhrTZRntvHRSSawKg3f+xVbjgNCY8/WeBWMXbPVMmY8RYc9qVYXznTaULA5e8HVrhQI16I+c93iu5/wS8KoBops/BaaObi4AuAsuueaFUHIzUPnyEBuPBifnRpIYMmsCqYTt8Xzpx6JW+YeAfxUkGsWnLusOKgJEuUt8+yuDSUXk2X3CzL4UIc8YKS04sAB29zotN0gG/YGM8+wRFPeZ5QZmsx6rm+234KjmQH1+atKyIJ9Nr29SmxCgXc6UA8= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2019 04:22:01.0486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 935854a3-4ac7-4f2b-ecb2-08d746f01275 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4560 Subject: Re: [dpdk-dev] [PATCH 2/5] lib/ring: add template to support different element sizes 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" > > Add templates to support creating ring APIs with different ring > > element sizes. > > > > Signed-off-by: Honnappa Nagarahalli > > Reviewed-by: Dharmik Thakkar > > Reviewed-by: Gavin Hu > > Reviewed-by: Ruifeng Wang > > --- > > lib/librte_ring/Makefile | 4 +- > > lib/librte_ring/meson.build | 4 +- > > lib/librte_ring/rte_ring_template.c | 46 ++++ > > lib/librte_ring/rte_ring_template.h | 330 ++++++++++++++++++++++++++++ > > 4 files changed, 382 insertions(+), 2 deletions(-) create mode > > 100644 lib/librte_ring/rte_ring_template.c > > create mode 100644 lib/librte_ring/rte_ring_template.h > > > > diff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile index > > 4c8410229..818898110 100644 > > --- a/lib/librte_ring/Makefile > > +++ b/lib/librte_ring/Makefile > > @@ -19,6 +19,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) :=3D rte_ring.c # > > install includes SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include :=3D > > rte_ring.h \ > > rte_ring_generic.h \ > > - rte_ring_c11_mem.h > > + rte_ring_c11_mem.h \ > > + rte_ring_template.h \ > > + rte_ring_template.c > > > > include $(RTE_SDK)/mk/rte.lib.mk > > diff --git a/lib/librte_ring/meson.build b/lib/librte_ring/meson.build > > index 74219840a..e4e208a7c 100644 > > --- a/lib/librte_ring/meson.build > > +++ b/lib/librte_ring/meson.build > > @@ -5,7 +5,9 @@ version =3D 2 > > sources =3D files('rte_ring.c') > > headers =3D files('rte_ring.h', > > 'rte_ring_c11_mem.h', > > - 'rte_ring_generic.h') > > + 'rte_ring_generic.h', > > + 'rte_ring_template.h', > > + 'rte_ring_template.c') > > > > # rte_ring_create_elem and rte_ring_get_memsize_elem are experimental > > allow_experimental_apis =3D true diff --git > > a/lib/librte_ring/rte_ring_template.c > > b/lib/librte_ring/rte_ring_template.c > > new file mode 100644 > > index 000000000..1ca593f95 > > --- /dev/null > > +++ b/lib/librte_ring/rte_ring_template.c > > @@ -0,0 +1,46 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright (c) 2019 Arm Limited > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "rte_ring.h" > > + > > +/* return the size of memory occupied by a ring */ ssize_t > > +__RTE_RING_CONCAT(rte_ring_get_memsize)(unsigned count) { > > + return rte_ring_get_memsize_elem(count, > RTE_RING_TMPLT_ELEM_SIZE); } > > + > > +/* create the ring */ > > +struct rte_ring * > > +__RTE_RING_CONCAT(rte_ring_create)(const char *name, unsigned count, > > + int socket_id, unsigned flags) > > +{ > > + return rte_ring_create_elem(name, count, > RTE_RING_TMPLT_ELEM_SIZE, > > + socket_id, flags); > > +} > > diff --git a/lib/librte_ring/rte_ring_template.h > > b/lib/librte_ring/rte_ring_template.h > > new file mode 100644 > > index 000000000..b9b14dfbb > > --- /dev/null > > +++ b/lib/librte_ring/rte_ring_template.h > > @@ -0,0 +1,330 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright (c) 2019 Arm Limited > > + */ > > + > > +#ifndef _RTE_RING_TEMPLATE_H_ > > +#define _RTE_RING_TEMPLATE_H_ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +/* Ring API suffix name - used to append to API names */ #ifndef > > +RTE_RING_TMPLT_API_SUFFIX #error RTE_RING_TMPLT_API_SUFFIX not > > +defined #endif > > + > > +/* Ring's element size in bits, should be a power of 2 */ #ifndef > > +RTE_RING_TMPLT_ELEM_SIZE #error RTE_RING_TMPLT_ELEM_SIZE not > defined > > +#endif > > + > > +/* Type of ring elements */ > > +#ifndef RTE_RING_TMPLT_ELEM_TYPE > > +#error RTE_RING_TMPLT_ELEM_TYPE not defined #endif > > + > > +#define _rte_fuse(a, b) a##_##b > > +#define __rte_fuse(a, b) _rte_fuse(a, b) #define __RTE_RING_CONCAT(a) > > +__rte_fuse(a, RTE_RING_TMPLT_API_SUFFIX) > > + > > +/* Calculate the memory size needed for a ring */ > > +RTE_RING_TMPLT_EXPERIMENTAL ssize_t > > +__RTE_RING_CONCAT(rte_ring_get_memsize)(unsigned count); > > + > > +/* Create a new ring named *name* in memory. */ > > +RTE_RING_TMPLT_EXPERIMENTAL struct rte_ring * > > +__RTE_RING_CONCAT(rte_ring_create)(const char *name, unsigned count, > > + int socket_id, unsigned flags); >=20 >=20 > Just an idea - probably same thing can be achieved in a different way. > Instead of all these defines - replace ENQUEUE_PTRS/DEQUEUE_PTRS macros > with static inline functions and then make all internal functions, i.e. > __rte_ring_do_dequeue() > to accept enqueue/dequeue function pointer as a parameter. > Then let say default rte_ring_mc_dequeue_bulk will do: >=20 > rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, > unsigned int n, unsigned int *available) > { > return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXE= D, > __IS_MC, available, dequeue_ptr_default); > } >=20 > Then if someone will like to define ring functions forelt_size=3D=3DX, al= l he would > need to do: > 1. define his own enqueue/dequeuer functions. > 2. do something like: > rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, > unsigned int n, unsigned int *available) > { > return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXE= D, > __IS_MC, available, dequeue_X); > } >=20 > Konstantin Thanks for the feedback/idea. The goal of this patch was to make it simple = enough to define APIs to store any element size without code duplication. W= ith this patch, the user has to write ~4 lines of code to get APIs for any = element size. I would like to keep the goal still the same. If we have to avoid the macro-fest, the main problem that needs to be addre= ssed is - how to represent different sizes of element types in a generic wa= y? IMO, we can do this by defining the element type to be a multiple of uin= t32_t (I do not think we need to go to uint16_t). For ex: rte_ring_mp_enqueue_bulk_objs(struct rte_ring *r, uint32_t *obj_table, unsigned int num_objs, unsigned int n, enum rte_ring_queue_behavior behavior, unsigned int is_sp, unsigned int *free_space) { } This approach would ensure that we have generic enough APIs and they can be= used for elements of any size. But the element itself needs to be a multip= le of 32b - I think this should not be a concern. The API suffix definitely needs to be better, any suggestions? >=20 >=20 > > + > > +/** > > + * @internal Enqueue several objects on the ring > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(__rte_ring_do_enqueue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE const *obj_table, unsigned int > n, > > + enum rte_ring_queue_behavior behavior, unsigned int is_sp, > > + unsigned int *free_space) > > +{ > > + uint32_t prod_head, prod_next; > > + uint32_t free_entries; > > + > > + n =3D __rte_ring_move_prod_head(r, is_sp, n, behavior, > > + &prod_head, &prod_next, &free_entries); > > + if (n =3D=3D 0) > > + goto end; > > + > > + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, > > + RTE_RING_TMPLT_ELEM_TYPE); > > + > > + update_tail(&r->prod, prod_head, prod_next, is_sp, 1); > > +end: > > + if (free_space !=3D NULL) > > + *free_space =3D free_entries - n; > > + return n; > > +} > > + > > +/** > > + * @internal Dequeue several objects from the ring > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(__rte_ring_do_dequeue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + enum rte_ring_queue_behavior behavior, unsigned int is_sc, > > + unsigned int *available) > > +{ > > + uint32_t cons_head, cons_next; > > + uint32_t entries; > > + > > + n =3D __rte_ring_move_cons_head(r, (int)is_sc, n, behavior, > > + &cons_head, &cons_next, &entries); > > + if (n =3D=3D 0) > > + goto end; > > + > > + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, > > + RTE_RING_TMPLT_ELEM_TYPE); > > + > > + update_tail(&r->cons, cons_head, cons_next, is_sc, 0); > > + > > +end: > > + if (available !=3D NULL) > > + *available =3D entries - n; > > + return n; > > +} > > + > > + > > +/** > > + * Enqueue several objects on the ring (multi-producers safe). > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_mp_enqueue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE const *obj_table, unsigned int n, > > + unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, __IS_MP, free_space); > > +} > > + > > +/** > > + * Enqueue several objects on a ring (NOT multi-producers safe). > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_sp_enqueue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE const *obj_table, unsigned int n, > > + unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, __IS_SP, free_space); > > +} > > + > > +/** > > + * Enqueue several objects on a ring. > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_enqueue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE const *obj_table, unsigned int n, > > + unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, r->prod.single, free_space); > > +} > > + > > +/** > > + * Enqueue one object on a ring (multi-producers safe). > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_mp_enqueue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE obj) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_mp_enqueue_bulk)(r, &obj, 1, > NULL) ? > > + 0 : -ENOBUFS; > > +} > > + > > +/** > > + * Enqueue one object on a ring (NOT multi-producers safe). > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_sp_enqueue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE obj) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_sp_enqueue_bulk)(r, &obj, 1, > NULL) ? > > + 0 : -ENOBUFS; > > +} > > + > > +/** > > + * Enqueue one object on a ring. > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_enqueue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_enqueue_bulk)(r, obj, 1, > NULL) ? > > + 0 : -ENOBUFS; > > +} > > + > > +/** > > + * Dequeue several objects from a ring (multi-consumers safe). > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_mc_dequeue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, __IS_MC, available); > > +} > > + > > +/** > > + * Dequeue several objects from a ring (NOT multi-consumers safe). > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_sc_dequeue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, __IS_SC, available); > > +} > > + > > +/** > > + * Dequeue several objects from a ring. > > + */ > > +static __rte_always_inline unsigned int > > +__RTE_RING_CONCAT(rte_ring_dequeue_bulk)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_FIXED, r->cons.single, available); > > +} > > + > > +/** > > + * Dequeue one object from a ring (multi-consumers safe). > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_mc_dequeue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_p) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_mc_dequeue_bulk)(r, obj_p, 1, > NULL) ? > > + 0 : -ENOENT; > > +} > > + > > +/** > > + * Dequeue one object from a ring (NOT multi-consumers safe). > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_sc_dequeue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_p) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_sc_dequeue_bulk)(r, obj_p, 1, > NULL) ? > > + 0 : -ENOENT; > > +} > > + > > +/** > > + * Dequeue one object from a ring. > > + */ > > +static __rte_always_inline int > > +__RTE_RING_CONCAT(rte_ring_dequeue)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_p) > > +{ > > + return __RTE_RING_CONCAT(rte_ring_dequeue_bulk)(r, obj_p, 1, > NULL) ? > > + 0 : -ENOENT; > > +} > > + > > +/** > > + * Enqueue several objects on the ring (multi-producers safe). > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_mp_enqueue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, > > + unsigned int n, unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, __IS_MP, free_space); > > +} > > + > > +/** > > + * Enqueue several objects on a ring (NOT multi-producers safe). > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_sp_enqueue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, > > + unsigned int n, unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, __IS_SP, free_space); > > +} > > + > > +/** > > + * Enqueue several objects on a ring. > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_enqueue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *free_space) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_enqueue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, r->prod.single, > free_space); > > +} > > + > > +/** > > + * Dequeue several objects from a ring (multi-consumers safe). When th= e > request > > + * objects are more than the available objects, only dequeue the actua= l > number > > + * of objects > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_mc_dequeue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, __IS_MC, available); > > +} > > + > > +/** > > + * Dequeue several objects from a ring (NOT multi-consumers safe).When > the > > + * request objects are more than the available objects, only dequeue t= he > > + * actual number of objects > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_sc_dequeue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, __IS_SC, available); > > +} > > + > > +/** > > + * Dequeue multiple objects from a ring up to a maximum number. > > + */ > > +static __rte_always_inline unsigned > > +__RTE_RING_CONCAT(rte_ring_dequeue_burst)(struct rte_ring *r, > > + RTE_RING_TMPLT_ELEM_TYPE *obj_table, unsigned int n, > > + unsigned int *available) > > +{ > > + return __RTE_RING_CONCAT(__rte_ring_do_dequeue)(r, obj_table, n, > > + RTE_RING_QUEUE_VARIABLE, > > + r->cons.single, available); > > +} > > + > > +#ifdef __cplusplus > > +} > > +#endif > > + > > +#endif /* _RTE_RING_TEMPLATE_H_ */ > > -- > > 2.17.1