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 DF8EBA0561; Sun, 19 Apr 2020 04:31:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B30451D41F; Sun, 19 Apr 2020 04:31:31 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20060.outbound.protection.outlook.com [40.107.2.60]) by dpdk.org (Postfix) with ESMTP id 739CA1D154 for ; Sun, 19 Apr 2020 04:31:11 +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=S7C6xsOg6ibdIoZ7hpoxKTgMZCO6J0A1CY6Cfq0sCwE=; b=fM2rFAxJWIaHpZO7kryPSO9ZT4VoRXdquVPeVANaKj9IMKtwK5JzX1+37usB0vL/4kz5dtlBkIyofk5PrsbZROoDx+6XTYG1byB+6HIveBXhEkLe+j5TP2nk5f2ckf2x/Mv8Er0xbkE9SHzKnJQBz+WAxm5ylB0PbNc/gPDijj4= Received: from DB6PR1001CA0028.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::14) by AM6PR08MB3719.eurprd08.prod.outlook.com (2603:10a6:20b:83::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Sun, 19 Apr 2020 02:31:09 +0000 Received: from DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:55:cafe::9b) by DB6PR1001CA0028.outlook.office365.com (2603:10a6:4:55::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.26 via Frontend Transport; Sun, 19 Apr 2020 02:31:09 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT033.mail.protection.outlook.com (10.152.20.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18 via Frontend Transport; Sun, 19 Apr 2020 02:31:09 +0000 Received: ("Tessian outbound 29c24b8a1b7a:v53"); Sun, 19 Apr 2020 02:31:09 +0000 X-CR-MTA-TID: 64aa7808 Received: from 94991e1aba57.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CEEAAB7B-8A6F-41B7-979A-8B364FDA90CC.1; Sun, 19 Apr 2020 02:31:04 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 94991e1aba57.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 19 Apr 2020 02:31:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HD+cTqPYiPwVzBkuX7gghGLwXCgGqv4KLJsImNtSm8znTyTSSjFsH97iIqCZjrndZt4JUgegqw0KyDtg2vqQ8OgGtAKx1K+vpXp+l/0guSJ8sqVUiXPU+OQE5pFTHYXf0p2l3SlEIMmfxqVy5354PAZGefhwwhBDrmHlEQEirKeTIccJ/0ksmA+LDpUC9AzsMIV7aShoYI+aBSz6PBFp2IOl++X6HcojmsnvaYoBxFgXs+GeX3e/uaVDveucmY4tS14QrSbWsgg0B3S7dJ514aD6SKP2xG2Vck/ZsY97W2VkGRUINFQ5EOJ02IkiVY1BjFS0Occ/Tgj+fULJ5lEWuw== 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=S7C6xsOg6ibdIoZ7hpoxKTgMZCO6J0A1CY6Cfq0sCwE=; b=B9Hd0guTw7UEVgbGgbZMkEEHT+5fqJgwWhQimrx3B4qCVHPnrNcOIWEROCcOu+ssbIKdsmYn/bCyqW1yt4G6iYhT4I96ySsJlmwWQ/jnFW/ZLJoAw/AFgxNMxU/yXBQMuXa44K8nlopkeAknskr2FaSc0pBPomvaaQDunp71sK7sXGnE+0KZg/271TllaYJvLvyhMwmhYVteXl070pvSbQyCjGZ8zmzvQRrFq2xZVE5Xt48F8VqabcklS2a0/yC/Wj0HfDUFbEmYsm84lNCnBty/Az5w1fBaFSjXLbW59kycz6Ln2aYdmyM1g9BW1B8jlITJZmGAAHw3KMBh7VIfRg== 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=S7C6xsOg6ibdIoZ7hpoxKTgMZCO6J0A1CY6Cfq0sCwE=; b=fM2rFAxJWIaHpZO7kryPSO9ZT4VoRXdquVPeVANaKj9IMKtwK5JzX1+37usB0vL/4kz5dtlBkIyofk5PrsbZROoDx+6XTYG1byB+6HIveBXhEkLe+j5TP2nk5f2ckf2x/Mv8Er0xbkE9SHzKnJQBz+WAxm5ylB0PbNc/gPDijj4= Received: from DBBPR08MB4646.eurprd08.prod.outlook.com (2603:10a6:10:f5::16) by DBBPR08MB4902.eurprd08.prod.outlook.com (2603:10a6:10:db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Sun, 19 Apr 2020 02:31:03 +0000 Received: from DBBPR08MB4646.eurprd08.prod.outlook.com ([fe80::1870:afc4:b90f:609d]) by DBBPR08MB4646.eurprd08.prod.outlook.com ([fe80::1870:afc4:b90f:609d%5]) with mapi id 15.20.2921.027; Sun, 19 Apr 2020 02:31:03 +0000 From: Honnappa Nagarahalli To: Konstantin Ananyev , "dev@dpdk.org" CC: "david.marchand@redhat.com" , "jielong.zjl@antfin.com" , nd , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v5 2/9] ring: prepare ring to allow new sync schemes Thread-Index: AQHWFZ8AbilctVZ0vESH0mLuCoHyJKh/K1kw Date: Sun, 19 Apr 2020 02:31:03 +0000 Message-ID: References: <20200417133639.14019-1-konstantin.ananyev@intel.com> <20200418163225.17635-1-konstantin.ananyev@intel.com> <20200418163225.17635-3-konstantin.ananyev@intel.com> In-Reply-To: <20200418163225.17635-3-konstantin.ananyev@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: c2a1d965-1d58-4e53-9ecc-9850e9630021.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [70.113.25.165] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d7431199-97be-4caa-9dba-08d7e409b842 x-ms-traffictypediagnostic: DBBPR08MB4902:|DBBPR08MB4902:|AM6PR08MB3719: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4303;OLM:4303; x-forefront-prvs: 0378F1E47A X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB4646.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(136003)(376002)(396003)(366004)(346002)(39850400004)(316002)(9686003)(66556008)(66446008)(64756008)(66476007)(66946007)(76116006)(26005)(186003)(52536014)(478600001)(6506007)(7696005)(54906003)(110136005)(81156014)(8676002)(33656002)(8936002)(5660300002)(30864003)(71200400001)(55016002)(4326008)(2906002)(86362001)(559001)(579004); DIR:OUT; SFP:1101; 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: 7NyWsE5ipsyRTIn1fiXMvlFRTsd5YTYLTLF/mGEc1q+F34B+wQWrvNumQ5QxWb/XTbIUW4xxTI7ntCxGQ1WTcdMx2mdU/MfltYMjT0+WueeFnyl6UNbUoS8c2VkugRbgFwAx8qG36iaLwPEptDQgvzQd6se8KnqlqxgHRH3Dzzi1YTT52KtvqGGv+AUxYniInTTYuzJ66cvZ65J6rvNno7W/f+FcCPlNRexgwybQcEKEXC7GE9ZK8LD31l1/E/PFav4LmaWjehmTYqp+EVHi2kgM+zzvtyiZJMtl/oZQbi9JW/w/ojPogjYuGtbOM8t3UnnrK3Gatjn9Qb+NrbbGdETsdpr5Fswtrbbc3eD4ep4xC4l6s5h63vRGueQcm94Y2iDagUEoKaZJT43XCVSkF0f5Q43B5oH/8E4s3mTHsjPP2wYXICuuYPNLxzRkmmW8 x-ms-exchange-antispam-messagedata: +ORgx87dMII5oHYU1mDEyjfEgqt16BXzhV3D1x8wxQvV4OcrqqsPAlOIcUFrkVQGRvFeO/Cde8gCu1ALHIdSFW2jIrJF95ONCuHKzU6bB8wL+clfnRbxbQ+kNMHIkfNLZnY1WrXeHZphga/pqpV51A== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4902 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(136003)(39850400004)(396003)(346002)(46966005)(52536014)(8676002)(81156014)(8936002)(33656002)(7696005)(2906002)(5660300002)(70206006)(81166007)(6506007)(70586007)(356005)(26005)(110136005)(336012)(55016002)(9686003)(86362001)(82740400003)(478600001)(186003)(30864003)(54906003)(316002)(47076004)(4326008); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 99928aa1-ec8c-4616-45a3-08d7e409b4a0 X-Forefront-PRVS: 0378F1E47A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QP8gWVCRww1C1g8KITxHiLURHmIx7ckTYYP8joNhGyM+HZFpIvlrIXxnaU0HeTI2E9h2EXCGo31mFpOVe8Mk7pQLHzY7IaQlr0a/V842IEgbXv86Z+aDEiDO6vLNJyWiCDvprG09/5omQrGRyWd1Ba91RNgXMhSUo4346ykNOFeGw2aAlUzmLw3GdylBTbMRuvanrg664JKknf2VAq3U6fBC42Qj98PbakfXHdgmiRR4RSR1E9v6ylzkxPS5c39UkkAsl8jVPoXywpP3fIL+PJdVf7Of5H93C1DaWVSRGQHp0DEPKuhS5Sr4AjlxkdY0IWLpelNTjEMHiQDL1AGiqpQkDW81xE5bHbvm8iu6UGwbqdKJSwGZBf4RAV1ycJ8ZwBK9UBBgM34oeYu65yWjal8oGGsuvCgdwSNl3RrFwpFrTPFgRhd4t3XzDMxV/8vy0G4xGA9phh+J0KvhkZ16p427LjsaPNVOUrHALECHo7vTZeFDAURaiThe1vRCzcP1PwAUp0gjRUnHThYatrShQw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2020 02:31:09.3336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7431199-97be-4caa-9dba-08d7e409b842 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: AM6PR08MB3719 Subject: Re: [dpdk-dev] [PATCH v5 2/9] ring: prepare ring to allow new sync schemes 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" >=20 > To make these preparations two main things are done: > - Change from *single* to *sync_type* to allow different > synchronisation schemes to be applied. > Mark *single* as deprecated in comments. > Add new functions to allow user to query ring sync types. > Replace direct access to *single* with appropriate function call. > - Move actual rte_ring and related structures definitions into a > separate file: . It allows to refer contents > of from without introducing a > circular dependency. >=20 > Signed-off-by: Konstantin Ananyev few nits inline, otherwise Acked-by: Honnappa Nagarahalli > --- > app/test/test_pdump.c | 6 +- > lib/librte_pdump/rte_pdump.c | 2 +- > lib/librte_port/rte_port_ring.c | 12 +-- > lib/librte_ring/Makefile | 1 + > lib/librte_ring/meson.build | 1 + > lib/librte_ring/rte_ring.c | 6 +- > lib/librte_ring/rte_ring.h | 170 ++++++++++++++------------------ > lib/librte_ring/rte_ring_core.h | 132 +++++++++++++++++++++++++ > lib/librte_ring/rte_ring_elem.h | 42 +++----- > 9 files changed, 234 insertions(+), 138 deletions(-) create mode 100644 > lib/librte_ring/rte_ring_core.h >=20 > diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c index > ad183184c..6a1180bcb 100644 > --- a/app/test/test_pdump.c > +++ b/app/test/test_pdump.c > @@ -57,8 +57,7 @@ run_pdump_client_tests(void) > if (ret < 0) > return -1; > mp->flags =3D 0x0000; > - ring_client =3D rte_ring_create("SR0", RING_SIZE, rte_socket_id(), > - RING_F_SP_ENQ | RING_F_SC_DEQ); > + ring_client =3D rte_ring_create("SR0", RING_SIZE, rte_socket_id(), 0); > if (ring_client =3D=3D NULL) { > printf("rte_ring_create SR0 failed"); > return -1; > @@ -71,9 +70,6 @@ run_pdump_client_tests(void) > } > rte_eth_dev_probing_finish(eth_dev); >=20 > - ring_client->prod.single =3D 0; > - ring_client->cons.single =3D 0; > - > printf("\n***** flags =3D RTE_PDUMP_FLAG_TX *****\n"); >=20 > for (itr =3D 0; itr < NUM_ITR; itr++) { > diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c > index 8a01ac510..f96709f95 100644 > --- a/lib/librte_pdump/rte_pdump.c > +++ b/lib/librte_pdump/rte_pdump.c > @@ -380,7 +380,7 @@ pdump_validate_ring_mp(struct rte_ring *ring, struct > rte_mempool *mp) > rte_errno =3D EINVAL; > return -1; > } > - if (ring->prod.single || ring->cons.single) { > + if (rte_ring_is_prod_single(ring) || rte_ring_is_cons_single(ring)) { > PDUMP_LOG(ERR, "ring with either SP or SC settings" > " is not valid for pdump, should have MP and MC settings\n"); > rte_errno =3D EINVAL; > diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_r= ing.c > index 47fcdd06a..52b2d8e55 100644 > --- a/lib/librte_port/rte_port_ring.c > +++ b/lib/librte_port/rte_port_ring.c > @@ -44,8 +44,8 @@ rte_port_ring_reader_create_internal(void *params, int > socket_id, > /* Check input parameters */ > if ((conf =3D=3D NULL) || > (conf->ring =3D=3D NULL) || > - (conf->ring->cons.single && is_multi) || > - (!(conf->ring->cons.single) && !is_multi)) { > + (rte_ring_is_cons_single(conf->ring) && is_multi) || > + (!rte_ring_is_cons_single(conf->ring) && !is_multi)) { > RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); > return NULL; > } > @@ -171,8 +171,8 @@ rte_port_ring_writer_create_internal(void *params, > int socket_id, > /* Check input parameters */ > if ((conf =3D=3D NULL) || > (conf->ring =3D=3D NULL) || > - (conf->ring->prod.single && is_multi) || > - (!(conf->ring->prod.single) && !is_multi) || > + (rte_ring_is_prod_single(conf->ring) && is_multi) || > + (!rte_ring_is_prod_single(conf->ring) && !is_multi) || > (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { > RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); > return NULL; > @@ -440,8 +440,8 @@ rte_port_ring_writer_nodrop_create_internal(void > *params, int socket_id, > /* Check input parameters */ > if ((conf =3D=3D NULL) || > (conf->ring =3D=3D NULL) || > - (conf->ring->prod.single && is_multi) || > - (!(conf->ring->prod.single) && !is_multi) || > + (rte_ring_is_prod_single(conf->ring) && is_multi) || > + (!rte_ring_is_prod_single(conf->ring) && !is_multi) || > (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { > RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); > return NULL; > diff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile index > 28368e6d1..6572768c9 100644 > --- a/lib/librte_ring/Makefile > +++ b/lib/librte_ring/Makefile > @@ -16,6 +16,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) :=3D rte_ring.c >=20 > # install includes > SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include :=3D rte_ring.h \ > + rte_ring_core.h \ > rte_ring_elem.h \ > rte_ring_generic.h \ > rte_ring_c11_mem.h > diff --git a/lib/librte_ring/meson.build b/lib/librte_ring/meson.build in= dex > 05402e4f0..c656781da 100644 > --- a/lib/librte_ring/meson.build > +++ b/lib/librte_ring/meson.build > @@ -3,6 +3,7 @@ >=20 > sources =3D files('rte_ring.c') > headers =3D files('rte_ring.h', > + 'rte_ring_core.h', > 'rte_ring_elem.h', > 'rte_ring_c11_mem.h', > 'rte_ring_generic.h') > diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c inde= x > 77e5de099..fa5733907 100644 > --- a/lib/librte_ring/rte_ring.c > +++ b/lib/librte_ring/rte_ring.c > @@ -106,8 +106,10 @@ rte_ring_init(struct rte_ring *r, const char *name, > unsigned count, > if (ret < 0 || ret >=3D (int)sizeof(r->name)) > return -ENAMETOOLONG; > r->flags =3D flags; > - r->prod.single =3D (flags & RING_F_SP_ENQ) ? __IS_SP : __IS_MP; > - r->cons.single =3D (flags & RING_F_SC_DEQ) ? __IS_SC : __IS_MC; > + r->prod.sync_type =3D (flags & RING_F_SP_ENQ) ? > + RTE_RING_SYNC_ST : RTE_RING_SYNC_MT; > + r->cons.sync_type =3D (flags & RING_F_SC_DEQ) ? > + RTE_RING_SYNC_ST : RTE_RING_SYNC_MT; >=20 > if (flags & RING_F_EXACT_SZ) { > r->size =3D rte_align32pow2(count + 1); diff --git > a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index > 18fc5d845..35ee4491c 100644 > --- a/lib/librte_ring/rte_ring.h > +++ b/lib/librte_ring/rte_ring.h > @@ -36,91 +36,7 @@ > extern "C" { > #endif >=20 > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -#define RTE_TAILQ_RING_NAME "RTE_RING" > - > -enum rte_ring_queue_behavior { > - RTE_RING_QUEUE_FIXED =3D 0, /* Enq/Deq a fixed number of items > from a ring */ > - RTE_RING_QUEUE_VARIABLE /* Enq/Deq as many items as possible > from ring */ > -}; > - > -#define RTE_RING_MZ_PREFIX "RG_" > -/** The maximum length of a ring name. */ -#define RTE_RING_NAMESIZE > (RTE_MEMZONE_NAMESIZE - \ > - sizeof(RTE_RING_MZ_PREFIX) + 1) > - > -/* structure to hold a pair of head/tail values and other metadata */ -s= truct > rte_ring_headtail { > - volatile uint32_t head; /**< Prod/consumer head. */ > - volatile uint32_t tail; /**< Prod/consumer tail. */ > - uint32_t single; /**< True if single prod/cons */ > -}; > - > -/** > - * An RTE ring structure. > - * > - * The producer and the consumer have a head and a tail index. The > particularity > - * of these index is that they are not between 0 and size(ring). These i= ndexes > - * are between 0 and 2^32, and we mask their value when we access the > ring[] > - * field. Thanks to this assumption, we can do subtractions between 2 in= dex > - * values in a modulo-32bit base: that's why the overflow of the indexes= is > not > - * a problem. > - */ > -struct rte_ring { > - /* > - * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI > - * compatibility requirements, it could be changed to > RTE_RING_NAMESIZE > - * next time the ABI changes > - */ > - char name[RTE_MEMZONE_NAMESIZE] __rte_cache_aligned; /**< > Name of the ring. */ > - int flags; /**< Flags supplied at creation. */ > - const struct rte_memzone *memzone; > - /**< Memzone, if any, containing the rte_ring */ > - uint32_t size; /**< Size of ring. */ > - uint32_t mask; /**< Mask (size-1) of ring. */ > - uint32_t capacity; /**< Usable size of ring */ > - > - char pad0 __rte_cache_aligned; /**< empty cache line */ > - > - /** Ring producer status. */ > - struct rte_ring_headtail prod __rte_cache_aligned; > - char pad1 __rte_cache_aligned; /**< empty cache line */ > - > - /** Ring consumer status. */ > - struct rte_ring_headtail cons __rte_cache_aligned; > - char pad2 __rte_cache_aligned; /**< empty cache line */ > -}; > - > -#define RING_F_SP_ENQ 0x0001 /**< The default enqueue is "single- > producer". */ -#define RING_F_SC_DEQ 0x0002 /**< The default dequeue is > "single-consumer". */ These do not appear in the API document anymore > -/** > - * Ring is to hold exactly requested number of entries. > - * Without this flag set, the ring size requested must be a power of 2, = and the > - * usable space will be that size - 1. With the flag, the requested size= will > - * be rounded up to the next power of two, but the usable space will be > exactly > - * that requested. Worst case, if a power-of-2 size is requested, half t= he > - * ring space will be wasted. > - */ > -#define RING_F_EXACT_SZ 0x0004 > -#define RTE_RING_SZ_MASK (0x7fffffffU) /**< Ring size mask */ > - > -/* @internal defines for passing to the enqueue dequeue worker functions= */ > -#define __IS_SP 1 -#define __IS_MP 0 -#define __IS_SC 1 -#define __IS_MC= 0 > +#include >=20 > /** > * Calculate the memory size needed for a ring @@ -420,7 +336,7 @@ > rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > RTE_RING_QUEUE_FIXED, > - __IS_MP, free_space); > + RTE_RING_SYNC_MT, free_space); > } >=20 > /** > @@ -443,9 +359,13 @@ rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * > const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > RTE_RING_QUEUE_FIXED, > - __IS_SP, free_space); > + RTE_RING_SYNC_ST, free_space); > } >=20 > +#ifdef ALLOW_EXPERIMENTAL_API > +#include > +#endif > + > /** > * Enqueue several objects on a ring. > * > @@ -470,7 +390,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * > const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > RTE_RING_QUEUE_FIXED, > - r->prod.single, free_space); > + r->prod.sync_type, free_space); > } >=20 > /** > @@ -554,7 +474,7 @@ 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_FIXED, > - __IS_MC, available); > + RTE_RING_SYNC_MT, available); > } >=20 > /** > @@ -578,7 +498,7 @@ rte_ring_sc_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_FIXED, > - __IS_SC, available); > + RTE_RING_SYNC_ST, available); > } >=20 > /** > @@ -605,7 +525,7 @@ rte_ring_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_FIXED, > - r->cons.single, available); > + r->cons.sync_type, available); > } >=20 > /** > @@ -777,6 +697,62 @@ rte_ring_get_capacity(const struct rte_ring *r) > return r->capacity; > } >=20 > +/** > + * Return sync type used by producer in the ring. > + * > + * @param r > + * A pointer to the ring structure. > + * @return > + * Producer sync type value. > + */ > +static inline enum rte_ring_sync_type > +rte_ring_get_prod_sync_type(const struct rte_ring *r) { > + return r->prod.sync_type; > +} > + > +/** > + * Check is the ring for single producer. > + * > + * @param r > + * A pointer to the ring structure. > + * @return > + * true if ring is SP, zero otherwise. > + */ > +static inline int > +rte_ring_is_prod_single(const struct rte_ring *r) { > + return (rte_ring_get_prod_sync_type(r) =3D=3D RTE_RING_SYNC_ST); } > + > +/** > + * Return sync type used by consumer in the ring. > + * > + * @param r > + * A pointer to the ring structure. > + * @return > + * Consumer sync type value. > + */ > +static inline enum rte_ring_sync_type > +rte_ring_get_cons_sync_type(const struct rte_ring *r) { > + return r->cons.sync_type; > +} > + > +/** > + * Check is the ring for single consumer. > + * > + * @param r > + * A pointer to the ring structure. > + * @return > + * true if ring is SC, zero otherwise. > + */ > +static inline int > +rte_ring_is_cons_single(const struct rte_ring *r) { > + return (rte_ring_get_cons_sync_type(r) =3D=3D RTE_RING_SYNC_ST); } > + > /** > * Dump the status of all rings on the console > * > @@ -820,7 +796,7 @@ rte_ring_mp_enqueue_burst(struct rte_ring *r, void * > const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > - RTE_RING_QUEUE_VARIABLE, __IS_MP, free_space); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, > free_space); > } >=20 > /** > @@ -843,7 +819,7 @@ rte_ring_sp_enqueue_burst(struct rte_ring *r, void * > const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > - RTE_RING_QUEUE_VARIABLE, __IS_SP, free_space); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, > free_space); > } >=20 > /** > @@ -870,7 +846,7 @@ rte_ring_enqueue_burst(struct rte_ring *r, void * > const *obj_table, > unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue(r, obj_table, n, > RTE_RING_QUEUE_VARIABLE, > - r->prod.single, free_space); > + r->prod.sync_type, free_space); > } >=20 > /** > @@ -898,7 +874,7 @@ rte_ring_mc_dequeue_burst(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_VARIABLE, __IS_MC, available); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, > available); > } >=20 > /** > @@ -923,7 +899,7 @@ rte_ring_sc_dequeue_burst(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_VARIABLE, __IS_SC, available); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, > available); > } >=20 > /** > @@ -951,7 +927,7 @@ rte_ring_dequeue_burst(struct rte_ring *r, void > **obj_table, { > return __rte_ring_do_dequeue(r, obj_table, n, > RTE_RING_QUEUE_VARIABLE, > - r->cons.single, available); > + r->cons.sync_type, available); > } >=20 > #ifdef __cplusplus > diff --git a/lib/librte_ring/rte_ring_core.h b/lib/librte_ring/rte_ring_c= ore.h I like this separation, thanks. > new file mode 100644 index 000000000..d9cef763f > --- /dev/null > +++ b/lib/librte_ring/rte_ring_core.h > @@ -0,0 +1,132 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * > + * Copyright (c) 2010-2020 Intel Corporation > + * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org > + * All rights reserved. > + * Derived from FreeBSD's bufring.h > + * Used as BSD-3 Licensed with permission from Kip Macy. > + */ > + > +#ifndef _RTE_RING_CORE_H_ > +#define _RTE_RING_CORE_H_ > + > +/** > + * @file > + * This file contains definion of RTE ring structure itself, ^^^^^^^ definition > + * init flags and some related macros. > + * For majority of DPDK entities, it is not recommended to include > + * this file directly, use include or > + * instead. > + */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define RTE_TAILQ_RING_NAME "RTE_RING" > + > +/** enqueue/dequeue behavior types */ > +enum rte_ring_queue_behavior { > + /** Enq/Deq a fixed number of items from a ring */ > + RTE_RING_QUEUE_FIXED =3D 0, > + /** Enq/Deq as many items as possible from ring */ > + RTE_RING_QUEUE_VARIABLE > +}; > + > +#define RTE_RING_MZ_PREFIX "RG_" > +/** The maximum length of a ring name. */ #define RTE_RING_NAMESIZE > +(RTE_MEMZONE_NAMESIZE - \ > + sizeof(RTE_RING_MZ_PREFIX) + 1) > + > +/** prod/cons sync types */ > +enum rte_ring_sync_type { > + RTE_RING_SYNC_MT, /**< multi-thread safe (default mode) */ > + RTE_RING_SYNC_ST, /**< single thread only */ > +}; > + > +/** > + * structures to hold a pair of head/tail values and other metadata. > + * Depending on sync_type format of that structure might be different, > + * but offset for *sync_type* and *tail* values should remain the same. > + */ > +struct rte_ring_headtail { > + volatile uint32_t head; /**< prod/consumer head. */ > + volatile uint32_t tail; /**< prod/consumer tail. */ > + RTE_STD_C11 > + union { > + /** sync type of prod/cons */ > + enum rte_ring_sync_type sync_type; > + /** deprecated - True if single prod/cons */ > + uint32_t single; > + }; > +}; > + > +/** > + * An RTE ring structure. > + * > + * The producer and the consumer have a head and a tail index. The > +particularity > + * of these index is that they are not between 0 and size(ring). These > +indexes > + * are between 0 and 2^32, and we mask their value when we access the > +ring[] > + * field. Thanks to this assumption, we can do subtractions between 2 > +index > + * values in a modulo-32bit base: that's why the overflow of the > +indexes is not > + * a problem. > + */ > +struct rte_ring { > + /* > + * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI > + * compatibility requirements, it could be changed to > RTE_RING_NAMESIZE > + * next time the ABI changes > + */ > + char name[RTE_MEMZONE_NAMESIZE] __rte_cache_aligned; > + /**< Name of the ring. */ > + int flags; /**< Flags supplied at creation. */ > + const struct rte_memzone *memzone; > + /**< Memzone, if any, containing the rte_ring */ > + uint32_t size; /**< Size of ring. */ > + uint32_t mask; /**< Mask (size-1) of ring. */ > + uint32_t capacity; /**< Usable size of ring */ > + > + char pad0 __rte_cache_aligned; /**< empty cache line */ > + > + /** Ring producer status. */ > + struct rte_ring_headtail prod __rte_cache_aligned; > + char pad1 __rte_cache_aligned; /**< empty cache line */ > + > + /** Ring consumer status. */ > + struct rte_ring_headtail cons __rte_cache_aligned; > + char pad2 __rte_cache_aligned; /**< empty cache line */ }; > + > +#define RING_F_SP_ENQ 0x0001 /**< The default enqueue is > +"single-producer". */ #define RING_F_SC_DEQ 0x0002 /**< The default > +dequeue is "single-consumer". */ > +/** > + * Ring is to hold exactly requested number of entries. > + * Without this flag set, the ring size requested must be a power of 2, > +and the > + * usable space will be that size - 1. With the flag, the requested > +size will > + * be rounded up to the next power of two, but the usable space will be > +exactly > + * that requested. Worst case, if a power-of-2 size is requested, half > +the > + * ring space will be wasted. > + */ > +#define RING_F_EXACT_SZ 0x0004 > +#define RTE_RING_SZ_MASK (0x7fffffffU) /**< Ring size mask */ > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTE_RING_CORE_H_ */ > diff --git a/lib/librte_ring/rte_ring_elem.h b/lib/librte_ring/rte_ring_e= lem.h > index 663addc73..7406c0b0f 100644 > --- a/lib/librte_ring/rte_ring_elem.h > +++ b/lib/librte_ring/rte_ring_elem.h > @@ -20,21 +20,7 @@ > extern "C" { > #endif >=20 > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -#include "rte_ring.h" > +#include >=20 > /** > * @warning > @@ -510,7 +496,7 @@ rte_ring_mp_enqueue_bulk_elem(struct rte_ring *r, > const void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, __IS_MP, free_space); > + RTE_RING_QUEUE_FIXED, RTE_RING_SYNC_MT, > free_space); > } >=20 > /** > @@ -539,7 +525,7 @@ rte_ring_sp_enqueue_bulk_elem(struct rte_ring *r, > const void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, __IS_SP, free_space); > + RTE_RING_QUEUE_FIXED, RTE_RING_SYNC_ST, > free_space); > } >=20 > /** > @@ -570,7 +556,7 @@ rte_ring_enqueue_bulk_elem(struct rte_ring *r, const > void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, r->prod.single, free_space); > + RTE_RING_QUEUE_FIXED, r->prod.sync_type, > free_space); > } >=20 > /** > @@ -675,7 +661,7 @@ rte_ring_mc_dequeue_bulk_elem(struct rte_ring *r, > void *obj_table, > unsigned int esize, unsigned int n, unsigned int *available) { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, __IS_MC, available); > + RTE_RING_QUEUE_FIXED, > RTE_RING_SYNC_MT, available); > } >=20 > /** > @@ -703,7 +689,7 @@ rte_ring_sc_dequeue_bulk_elem(struct rte_ring *r, > void *obj_table, > unsigned int esize, unsigned int n, unsigned int *available) { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, __IS_SC, available); > + RTE_RING_QUEUE_FIXED, RTE_RING_SYNC_ST, > available); > } >=20 > /** > @@ -734,7 +720,7 @@ rte_ring_dequeue_bulk_elem(struct rte_ring *r, void > *obj_table, > unsigned int esize, unsigned int n, unsigned int *available) { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_FIXED, r->cons.single, available); > + RTE_RING_QUEUE_FIXED, r->cons.sync_type, > available); > } >=20 > /** > @@ -842,7 +828,7 @@ rte_ring_mp_enqueue_burst_elem(struct rte_ring *r, > const void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_VARIABLE, __IS_MP, free_space); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, > free_space); > } >=20 > /** > @@ -871,7 +857,7 @@ rte_ring_sp_enqueue_burst_elem(struct rte_ring *r, > const void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_VARIABLE, __IS_SP, free_space); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, > free_space); > } >=20 > /** > @@ -902,7 +888,7 @@ rte_ring_enqueue_burst_elem(struct rte_ring *r, > const void *obj_table, > unsigned int esize, unsigned int n, unsigned int *free_space) { > return __rte_ring_do_enqueue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_VARIABLE, r->prod.single, > free_space); > + RTE_RING_QUEUE_VARIABLE, r->prod.sync_type, > free_space); > } >=20 > /** > @@ -934,7 +920,7 @@ rte_ring_mc_dequeue_burst_elem(struct rte_ring *r, > void *obj_table, > unsigned int esize, unsigned int n, unsigned int *available) { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_VARIABLE, __IS_MC, available); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, > available); > } >=20 > /** > @@ -963,7 +949,7 @@ rte_ring_sc_dequeue_burst_elem(struct rte_ring *r, > void *obj_table, > unsigned int esize, unsigned int n, unsigned int *available) { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > - RTE_RING_QUEUE_VARIABLE, __IS_SC, available); > + RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, > available); > } >=20 > /** > @@ -995,9 +981,11 @@ rte_ring_dequeue_burst_elem(struct rte_ring *r, > void *obj_table, { > return __rte_ring_do_dequeue_elem(r, obj_table, esize, n, > RTE_RING_QUEUE_VARIABLE, > - r->cons.single, available); > + r->cons.sync_type, available); > } >=20 > +#include > + > #ifdef __cplusplus > } > #endif > -- > 2.17.1