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 E50C2A04B0; Sat, 24 Oct 2020 17:45:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0447A493D; Sat, 24 Oct 2020 17:45:17 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70087.outbound.protection.outlook.com [40.107.7.87]) by dpdk.org (Postfix) with ESMTP id 6FFD5326C for ; Sat, 24 Oct 2020 17:45:15 +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=+4O2HdVdMaydToggn5ExE/gKxACrmB1Ao/pmiNFXUzs=; b=z9/s8Q7wJBulN1ya+35mSy9oUo7GRCmY0Pon6vQzZ1ru5sCb1l+KC57OIwZ4otAKkGyWzAPNx2PPwrQGXT/iTeAboag+ZyBusXnrEf0DoLg4jKFDbD0xhnIWS7h54CbFOppjOArlKItfe0Vw8hSV1ANnTUEbU7qh1/aVUsG192M= Received: from DB6PR0201CA0002.eurprd02.prod.outlook.com (2603:10a6:4:3f::12) by AM5PR0802MB2481.eurprd08.prod.outlook.com (2603:10a6:203:a0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.24; Sat, 24 Oct 2020 15:45:12 +0000 Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::a1) by DB6PR0201CA0002.outlook.office365.com (2603:10a6:4:3f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.19 via Frontend Transport; Sat, 24 Oct 2020 15:45:12 +0000 X-MS-Exchange-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=pass 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 DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Sat, 24 Oct 2020 15:45:12 +0000 Received: ("Tessian outbound 68da730eaaba:v64"); Sat, 24 Oct 2020 15:45:12 +0000 X-CR-MTA-TID: 64aa7808 Received: from 80f836be909b.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3A0E53EA-8205-4A5A-8148-69981D10ABB8.1; Sat, 24 Oct 2020 15:45:07 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 80f836be909b.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 24 Oct 2020 15:45:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WuSBSAscaDrDINwz+RyEp/56FrJ5Vlx+jG6tJD9JW4KWSJmZe8E3hICOIY/1vwBjzWWX+UgFe7dYFBrRGFV+6fSc6F2dKU+Zg/qkV9Sf3LwcTpCS9kw+uKmOwx6v6dsWSYBUUKKzQuHMeH+Ya/SW7Imm0iR3I+OwA8LYyAEBHv1irdlethTTPfK80W5fnJhou1GxF6wAiQGkqSOyR4xVid5zm0MiMyLqPmIVVSeK0G9ZRFN69VPxt41NhY+OBIc8uNZTZLVXiad6cIBmdFPWRlqSKrBj6l01zclLm4YnudRUUY/110gcN+UZHfj1het0T5bNhqmbmy43z1fD0cD9mA== 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=+4O2HdVdMaydToggn5ExE/gKxACrmB1Ao/pmiNFXUzs=; b=MB2eI8pZ0kwlugyQ3LOFxgwihmQqts5RVK/Y2GEznCpnM/yGyx/aP9hBREZYBYbMCxqbHoARbd13IrdV9mJlOCotO/9PRoa/qeCsWOxbG6pNjap/b5i3/zSeydR1xG19l7KVkOk0/K0N626Lp788V36TGV2gvQ8H/vKw9GRaY8z/yGr/w6+mw5RdXcdUAXppgj27aQUObrw3bbydOo23aHA3fhLrdhZh9FhQJv5aoM9pnHZVIlgFG86ceJ35hZuOjQombV+8Evpf5VGOWKEmtO5WrzsVQ4chrca3RrY/eF0hvEBZodDYbyyKfp4QKgJyQDZVGB8fs2iDJIeuVpSaeQ== 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=+4O2HdVdMaydToggn5ExE/gKxACrmB1Ao/pmiNFXUzs=; b=z9/s8Q7wJBulN1ya+35mSy9oUo7GRCmY0Pon6vQzZ1ru5sCb1l+KC57OIwZ4otAKkGyWzAPNx2PPwrQGXT/iTeAboag+ZyBusXnrEf0DoLg4jKFDbD0xhnIWS7h54CbFOppjOArlKItfe0Vw8hSV1ANnTUEbU7qh1/aVUsG192M= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB7PR08MB4219.eurprd08.prod.outlook.com (2603:10a6:10:34::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Sat, 24 Oct 2020 15:45:05 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::7814:9c1:781f:475d]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::7814:9c1:781f:475d%4]) with mapi id 15.20.3499.018; Sat, 24 Oct 2020 15:45:04 +0000 From: Honnappa Nagarahalli To: "Ananyev, Konstantin" , "dev@dpdk.org" CC: "olivier.matz@6wind.com" , "david.marchand@redhat.com" , Dharmik Thakkar , Ruifeng Wang , nd , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v3 2/5] lib/ring: add zero copy APIs Thread-Index: AQHWqUTDdPF6ZUuwPku4QZZ+V+EHuaml41Fw Date: Sat, 24 Oct 2020 15:45:04 +0000 Message-ID: References: <20200224203931.21256-1-honnappa.nagarahalli@arm.com> <20201023044343.13462-1-honnappa.nagarahalli@arm.com> <20201023044343.13462-3-honnappa.nagarahalli@arm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: F9CFD138EF16AF4D9E289763B7A48FA1.0 x-checkrecipientchecked: true Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.113.13.105] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8568646a-148d-4dc7-ec40-08d87833cb5a x-ms-traffictypediagnostic: DB7PR08MB4219:|AM5PR0802MB2481: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: pbl+Hr/x90oIM8ZKvdmpJlePVR0f2S7VcNvLcQ+bNS8uXgNoQdBHRAua9qE+29mEzRvi02TSFsk1nfJh1DsB4bkcdKkOKnUJY/i6wmi5h9EhMAQqTaVAV5V4zikPF5XsZK5B9VjCwQCgvtOJIpEpMvYwyKg/XH42HPJuh/CVDB8PhZHh48Ihcwxshk1lh+SaZu56/oGBm321NElw4O3lGThnkML7hsTO6w7VIu3q7+6I6Sdj2tyC+M9AwXr4xKUJxuXtOx0hXt8zRoiAm5xAjU+Bt+9/4Wq36nuHxa/a2Ww6tu37Gqq2Zhx9TdZTzX89 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(376002)(136003)(39860400002)(7696005)(4326008)(86362001)(478600001)(110136005)(2906002)(55016002)(316002)(71200400001)(26005)(5660300002)(6506007)(8676002)(54906003)(64756008)(66446008)(9686003)(66556008)(66946007)(186003)(52536014)(76116006)(66476007)(8936002)(83380400001)(33656002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: D0z8tFkqCCWEv05c5Cj9hjmjE6P5IhynJF0sjMZYw0D0oBMkoxrTP6+8kdQnVm01ngtJPHS+jSc3yOgWG2lvzYLtOz3UClvH71RHROJFH9KtMpq/ErxK3crU+ZSHvqYFaUpr+1mr4mfhobxvv6DI9BKUP7zSLRmmFqcdH9zdsBgXDofzXr6de4GQagyHQ+EAushkHI5FyupzpUBFxkHypLugWIO7ioUjpncmiwrMGQRrTxDfh8wJplSjz8AfPa5Jh8ft+EfAmnUIWsHS+OOcXqxGdoV4sbMcK3oUaifaubrOHyYlevC6lPEjW3bov3l3QJtW9JL2CRTA3w0r1NS8vnsRaKEL+8WePQr8Cr7RrAAma4cBXqfBazg+aEaNdjWpqf0/g100CfUtCbFJ+34NXeoDXJekU/NxiGnrOI0CToOmodWHuqH2eADKSVOOnJBRbNl2YEYyNqHq4e9Mfsr6eolVSgNe1JqmrMkFBmDu2fX/Ip+MhhFa/06c1QcPmw7PEFPvPaKrbkDVXA4aRLd+B9Pnnew6wcs6+IPBPU/kqTGEE+7lMTnV578p1USq2rT1Thh+ByZiRG9t5EtoUYbi713sehhRnNZBIepjgLFLmgQytsr5PMkInPS34zs8jCQBSLHsaeLHTUfDoBlqj4z8CQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB4219 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e8754aec-6816-45cd-407f-08d87833c6ea X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kOeFxF40RktN8IDZ3/sXlWiCvg8lR1QmCWUwHc70/y4TK0cwNStQPGfybH3GJoEVhpYgVw3JNeYf38Xf1QDBTABRRztJQg6PgvtDPGSP9KyjYL5Qr198nZ7j+dk811h7aILMRdeSAKqftOG9+5JkCF1v+Zi4mxVLrlQ0Qw7FgULcx6SJ6YvwBSKyljWqkTr0uJYs+nibffe9v6Su6kWjpRIPmsYzxPkVPMgAjvd29HoG06e8cA1F77ilpmbDsf1zaMdGcqB3M/C+WR5VAR9HU+iGdAML72qx+uozsZAUfmQawDtPt4/qEvUsMXQ9raMAV4TCRCqsJNXVmmBTBac0y7aI/XJOlbJqNAYtbMp0l61JoP2f0G/vJFzWSA3ygse/oa9/c7scEcOVu/Ky+LHWMg== 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; SFS:(4636009)(136003)(39860400002)(396003)(376002)(346002)(46966005)(52536014)(86362001)(110136005)(8936002)(33656002)(26005)(336012)(82740400003)(54906003)(81166007)(4326008)(186003)(2906002)(316002)(6506007)(47076004)(7696005)(356005)(55016002)(9686003)(478600001)(5660300002)(8676002)(70586007)(70206006)(82310400003)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2020 15:45:12.3244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8568646a-148d-4dc7-ec40-08d87833cb5a 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-AuthSource: DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2481 Subject: Re: [dpdk-dev] [PATCH v3 2/5] lib/ring: add zero copy APIs 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" Hi Konstantin, Thank you for the quick comments. Please see the responses inline. >=20 >=20 > > > > Add zero-copy APIs. These APIs provide the capability to copy the data > > to/from the ring memory directly, without having a temporary copy (for > > ex: an array of mbufs on the stack). Use cases that involve copying > > large amount of data to/from the ring can benefit from these APIs. >=20 > LGTM in general. > Few nits, see below. >=20 > > > > Signed-off-by: Honnappa Nagarahalli > > Reviewed-by: Dharmik Thakkar > > --- > > lib/librte_ring/meson.build | 1 + > > lib/librte_ring/rte_ring_elem.h | 1 + > > lib/librte_ring/rte_ring_peek_zc.h | 542 > > +++++++++++++++++++++++++++++ > > 3 files changed, 544 insertions(+) > > create mode 100644 lib/librte_ring/rte_ring_peek_zc.h >=20 > Need to update documentation: PG and RN. >=20 > > > > diff --git a/lib/librte_ring/meson.build b/lib/librte_ring/meson.build > > index 31c0b4649..36fdcb6a5 100644 > > --- a/lib/librte_ring/meson.build > > +++ b/lib/librte_ring/meson.build > > @@ -11,5 +11,6 @@ headers =3D files('rte_ring.h', > > 'rte_ring_hts_c11_mem.h', > > 'rte_ring_peek.h', > > 'rte_ring_peek_c11_mem.h', > > + 'rte_ring_peek_zc.h', > > 'rte_ring_rts.h', > > 'rte_ring_rts_c11_mem.h') > > diff --git a/lib/librte_ring/rte_ring_elem.h > > b/lib/librte_ring/rte_ring_elem.h index 938b398fc..7034d29c0 100644 > > --- a/lib/librte_ring/rte_ring_elem.h > > +++ b/lib/librte_ring/rte_ring_elem.h > > @@ -1079,6 +1079,7 @@ rte_ring_dequeue_burst_elem(struct rte_ring *r, > > void *obj_table, > > > > #ifdef ALLOW_EXPERIMENTAL_API > > #include > > +#include > > #endif > > > > #include > > diff --git a/lib/librte_ring/rte_ring_peek_zc.h > > b/lib/librte_ring/rte_ring_peek_zc.h > > new file mode 100644 > > index 000000000..9db2d343f > > --- /dev/null > > +++ b/lib/librte_ring/rte_ring_peek_zc.h > > @@ -0,0 +1,542 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * > > + * Copyright (c) 2020 Arm Limited > > + * 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_PEEK_ZC_H_ > > +#define _RTE_RING_PEEK_ZC_H_ > > + > > +/** > > + * @file > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * It is not recommended to include this file directly. > > + * Please include instead. > > + * > > + * Ring Peek Zero Copy APIs > > + * These APIs make it possible to split public enqueue/dequeue API > > + * into 3 parts: > > + * - enqueue/dequeue start > > + * - copy data to/from the ring > > + * - enqueue/dequeue finish > > + * Along with the advantages of the peek APIs, these APIs provide the > > +ability > > + * to avoid copying of the data to temporary area (for ex: array of > > +mbufs > > + * on the stack). > > + * > > + * Note that currently these APIs are available only for two sync mode= s: > > + * 1) Single Producer/Single Consumer (RTE_RING_SYNC_ST) > > + * 2) Serialized Producer/Serialized Consumer > (RTE_RING_SYNC_MT_HTS). > > + * It is user's responsibility to create/init ring with appropriate > > +sync > > + * modes selected. > > + * > > + * Following are some examples showing the API usage. > > + * 1) > > + * struct elem_obj {uint64_t a; uint32_t b, c;}; > > + * struct elem_obj *obj; > > + * > > + * // Create ring with sync type RTE_RING_SYNC_ST or > > +RTE_RING_SYNC_MT_HTS > > + * // Reserve space on the ring > > + * n =3D rte_ring_enqueue_zc_bulk_elem_start(r, sizeof(elem_obj), 1, > > +&zcd, NULL); > > + * > > + * // Produce the data directly on the ring memory > > + * obj =3D (struct elem_obj *)zcd->ptr1; > > + * obj.a =3D rte_get_a(); >=20 > As obj is a pointer, should be obj->a =3D ... > Same for b and c. Will fix. >=20 > > + * obj.b =3D rte_get_b(); > > + * obj.c =3D rte_get_c(); > > + * rte_ring_enqueue_zc_elem_finish(ring, n); > > + * > > + * 2) > > + * // Create ring with sync type RTE_RING_SYNC_ST or > > + RTE_RING_SYNC_MT_HTS > > + * // Reserve space on the ring > > + * n =3D rte_ring_enqueue_zc_burst_start(r, 32, &zcd, NULL); > > + * > > + * // Pkt I/O core polls packets from the NIC > > + * if (n =3D=3D 32) > > + * nb_rx =3D rte_eth_rx_burst(portid, queueid, zcd->ptr1, 32); > > + * else > > + * nb_rx =3D rte_eth_rx_burst(portid, queueid, zcd->ptr1, zcd->n1); >=20 > Hmm, that doesn't look exactly correct to me. > It could be that n =3D=3D 32, but we still need to do wrap-around. > Shouldn't it be: >=20 > If (n !=3D 0) { > nb_rx =3D rte_eth_rx_burst(portid, queueid, zcd->ptr1, zcd->n1); > if (nb_rx =3D=3D zcd->n1 && nb_rx !=3D n) > nb_rx +=3D rte_eth_rx_burst(portid, queueid, zcd->ptr2, n - > nb_rx); } Agree >=20 > > + * > > + * // Provide packets to the packet processing cores > > + * rte_ring_enqueue_zc_finish(r, nb_rx); > > + * > > + * Note that between _start_ and _finish_ none other thread can > > + proceed > > + * with enqueue/dequeue operation till _finish_ completes. > > + */ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#include > > + > > +/** > > + * Ring zero-copy information structure. > > + * > > + * This structure contains the pointers and length of the space > > + * reserved on the ring storage. > > + */ > > +struct rte_ring_zc_data { > > + /* Pointer to the first space in the ring */ > > + void **ptr1; >=20 > Why not just 'void *ptr1;'? > Same for ptr2. Agree >=20 > > + /* Pointer to the second space in the ring if there is wrap-around */ > > + void **ptr2; > > + /* Number of elements in the first pointer. If this is equal to > > + * the number of elements requested, then ptr2 is NULL. > > + * Otherwise, subtracting n1 from number of elements requested > > + * will give the number of elements available at ptr2. > > + */ > > + unsigned int n1; > > +} __rte_cache_aligned; > > + > > +static __rte_always_inline void > > +__rte_ring_get_elem_addr(struct rte_ring *r, uint32_t head, > > + uint32_t esize, uint32_t num, void **dst1, uint32_t *n1, void > > +**dst2) { > > + uint32_t idx, scale, nr_idx; > > + uint32_t *ring =3D (uint32_t *)&r[1]; > > + > > + /* Normalize to uint32_t */ > > + scale =3D esize / sizeof(uint32_t); > > + idx =3D head & r->mask; > > + nr_idx =3D idx * scale; > > + > > + *dst1 =3D ring + nr_idx; > > + *n1 =3D num; > > + > > + if (idx + num > r->size) { > > + *n1 =3D r->size - idx; > > + *dst2 =3D ring; > > + } >=20 > Seems like missing: > else {*dst2 =3D NULL;} I did not add it since dst2 should be accessed only if there is wrap-around= . Will call it out in the struct above. >=20 > > +} > > + > > +/** > > + * @internal This function moves prod head value. > > + */ > > +static __rte_always_inline unsigned int > > +__rte_ring_do_enqueue_zc_elem_start(struct rte_ring *r, unsigned int > esize, > > + uint32_t n, enum rte_ring_queue_behavior behavior, > > + struct rte_ring_zc_data *zcd, unsigned int *free_space) { > > + uint32_t free, head, next; > > + > > + switch (r->prod.sync_type) { > > + case RTE_RING_SYNC_ST: > > + n =3D __rte_ring_move_prod_head(r, RTE_RING_SYNC_ST, n, > > + behavior, &head, &next, &free); > > + __rte_ring_get_elem_addr(r, head, esize, n, (void **)&zcd- > >ptr1, >=20 > If you change ptr1, ptr2 to be just 'void *', then probably no extra type= -cast > will be needed here. Thanks for catching this, pointers are out of whack. >=20 > > + &zcd->n1, (void **)&zcd->ptr2); > > + break; > > + case RTE_RING_SYNC_MT_HTS: > > + n =3D __rte_ring_hts_move_prod_head(r, n, behavior, &head, > &free); > > + __rte_ring_get_elem_addr(r, head, esize, n, (void **)&zcd- > >ptr1, > > + &zcd->n1, (void **)&zcd->ptr2); > > + break; > > + case RTE_RING_SYNC_MT: > > + case RTE_RING_SYNC_MT_RTS: > > + default: > > + /* unsupported mode, shouldn't be here */ > > + RTE_ASSERT(0); > > + n =3D 0; > > + free =3D 0; > > + } >=20 > Would it make sense to move __rte_ring_get_elem_addr() here and do it > only when n !=3D 0? > I.E: >=20 > if (n !=3D 0) > __rte_ring_get_elem_addr(...); It adds an 'if' statement. We can add a return to the default case and skip= the if statement. >=20 > Same comments for _dequeue_ analog. >=20 > > + > > + if (free_space !=3D NULL) > > + *free_space =3D free - n; > > + return n; > > +} > > +