From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 16EAE42856;
	Wed, 29 Mar 2023 04:16:29 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A761940F18;
	Wed, 29 Mar 2023 04:16:28 +0200 (CEST)
Received: from EUR04-HE1-obe.outbound.protection.outlook.com
 (mail-he1eur04on2044.outbound.protection.outlook.com [40.107.7.44])
 by mails.dpdk.org (Postfix) with ESMTP id 0F19440EE7
 for <dev@dpdk.org>; Wed, 29 Mar 2023 04:16:27 +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=tpAABR5dmKo8SUASyVd/92K6O274m2XTaEb0Nc/MepU=;
 b=T48hMt6jEdadTg9oTRZK0FAccegf809p8qL0G6gKPE5uyweim2RDLR6rT+goKKrejI/xI+78u76HyuiwQffB9hgxgWR/4FRlDmSkxEDlH+ZuBzZqGEBjGPDsKAL/wYD8LoGytNTv+X6+CMmlOXOZFaraIb4s7uk6n4A87PxWGN4=
Received: from AM3PR07CA0130.eurprd07.prod.outlook.com (2603:10a6:207:8::16)
 by DBAPR08MB5832.eurprd08.prod.outlook.com (2603:10a6:10:1a5::15) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.41; Wed, 29 Mar
 2023 02:16:23 +0000
Received: from AM7EUR03FT010.eop-EUR03.prod.protection.outlook.com
 (2603:10a6:207:8:cafe::de) by AM3PR07CA0130.outlook.office365.com
 (2603:10a6:207:8::16) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.17 via Frontend
 Transport; Wed, 29 Mar 2023 02:16:23 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123)
 smtp.mailfrom=arm.com; dkim=pass (signature was verified)
 header.d=armh.onmicrosoft.com;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;
 pr=C
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by
 AM7EUR03FT010.mail.protection.outlook.com (100.127.141.22) with
 Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.6222.22 via Frontend Transport; Wed, 29 Mar 2023 02:16:22 +0000
Received: ("Tessian outbound 99a3040377ca:v136");
 Wed, 29 Mar 2023 02:16:22 +0000
X-CR-MTA-TID: 64aa7808
Received: from 0e4357cf8080.1
 by 64aa7808-outbound-1.mta.getcheckrecipient.com id
 F33E3410-930D-44F7-8CA2-7FA47FE8A84A.1; 
 Wed, 29 Mar 2023 02:16:14 +0000
Received: from EUR05-DB8-obe.outbound.protection.outlook.com
 by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0e4357cf8080.1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384);
 Wed, 29 Mar 2023 02:16:14 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=QvcvMdsqS+F2gXqsuEYu4IjtQIKVc5WKxOWPw0UnfDED+7aNWfnRRz5ec99G1fHblbdHfXUbaph0685cynWGU7yq6TEaO/DjVCPLrTeQ5kHQ5qR4UaU689x7PWfk/vKYEAbgAYibC1Db1VCJjsD791Rt1ejhHW+V+IC8DVcsq4rhnl4drrFAHxTr+Q6QfP2zRQp9sIkS3lHin4UmV6ntFksa3FPmDsacTAngXd0jF9XdDsZdiSe8zvv2c25DMW31FA8SQKIwCC5x0uTO4Q94dMwqZWzH31xqz8hP/ESt0eJ92GXp7sq5OPOPwPgqAXOb7mrre5MQDOxN9ag5KzJdbA==
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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=tpAABR5dmKo8SUASyVd/92K6O274m2XTaEb0Nc/MepU=;
 b=McbrdGA7T5GN1OPr6enZS9PRRCyHVap3FUSLlX7Z9FafiqdGORyzmocXGjVUFReweV5vs3KzIU0t5mGT+nKFMbqyUVM7y0pgOmmej9v+27GkWJA1tAAKoVH8XdGkc7PT+MuYtyp61mu84wYrfeDzntRTr+P2cuWS67BRlN7laR7YPYa+xg1rudjjwFw0vYz4JXA/hoYfi635K0vujlPMVGb98Op80QqGdOmB0c2P68lhnegwgDr2BmpN7pbhTGAREOuRLQkNc3JTK4AtwjjkPMNY3u2q93pOcoIHTt3KFX+qgMWG4ozeEYGoiCFtU55SyQTOFdy9qFOurOeooNEovQ==
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=tpAABR5dmKo8SUASyVd/92K6O274m2XTaEb0Nc/MepU=;
 b=T48hMt6jEdadTg9oTRZK0FAccegf809p8qL0G6gKPE5uyweim2RDLR6rT+goKKrejI/xI+78u76HyuiwQffB9hgxgWR/4FRlDmSkxEDlH+ZuBzZqGEBjGPDsKAL/wYD8LoGytNTv+X6+CMmlOXOZFaraIb4s7uk6n4A87PxWGN4=
Received: from AS8PR08MB7718.eurprd08.prod.outlook.com (2603:10a6:20b:50a::22)
 by DBAPR08MB5655.eurprd08.prod.outlook.com (2603:10a6:10:1ab::5) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.34; Wed, 29 Mar
 2023 02:16:09 +0000
Received: from AS8PR08MB7718.eurprd08.prod.outlook.com
 ([fe80::95ea:4c82:b97f:5ff6]) by AS8PR08MB7718.eurprd08.prod.outlook.com
 ([fe80::95ea:4c82:b97f:5ff6%3]) with mapi id 15.20.6222.035; Wed, 29 Mar 2023
 02:16:08 +0000
From: Feifei Wang <Feifei.Wang2@arm.com>
To: =?iso-8859-1?Q?Morten_Br=F8rup?= <mb@smartsharesystems.com>,
 "thomas@monjalon.net" <thomas@monjalon.net>, Ferruh Yigit
 <ferruh.yigit@amd.com>, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
CC: "dev@dpdk.org" <dev@dpdk.org>, "konstantin.v.ananyev@yandex.ru"
 <konstantin.v.ananyev@yandex.ru>, nd <nd@arm.com>, Honnappa Nagarahalli
 <Honnappa.Nagarahalli@arm.com>, Ruifeng Wang <Ruifeng.Wang@arm.com>, nd
 <nd@arm.com>
Subject: RE: [PATCH v4 1/3] ethdev: add API for buffer recycle mode
Thread-Topic: [PATCH v4 1/3] ethdev: add API for buffer recycle mode
Thread-Index: AQHZXXRaxSGaKtsFiEu8YH6J3TAyOa8IPfwAgAjGuRA=
Date: Wed, 29 Mar 2023 02:16:08 +0000
Message-ID: <AS8PR08MB7718DE821BB62798600E562BC8899@AS8PR08MB7718.eurprd08.prod.outlook.com>
References: <20211224164613.32569-1-feifei.wang2@arm.com>
 <20230323104330.3823251-1-feifei.wang2@arm.com>
 <20230323104330.3823251-2-feifei.wang2@arm.com>
 <98CBD80474FA8B44BF855DF32C47DC35D877FE@smartserver.smartshare.dk>
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D877FE@smartserver.smartshare.dk>
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ts-tracking-id: 4CF286229CEF404F8B726615AC97829C.0
x-checkrecipientchecked: true
Authentication-Results-Original: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=arm.com;
x-ms-traffictypediagnostic: AS8PR08MB7718:EE_|DBAPR08MB5655:EE_|AM7EUR03FT010:EE_|DBAPR08MB5832:EE_
X-MS-Office365-Filtering-Correlation-Id: 8810ba7d-9999-4fd5-a937-08db2ffb97a1
x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr
x-checkrecipientrouted: true
nodisclaimer: true
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: dyCM4+SEguZBoPVPKM1bBACOZFMgDOg5UMyF5GJtbxA5kiM8CuHnbYivwJeLIQr15q7P8lEZx5CEmdvLwT527dQthenp2LyGlpn+KMFVEs36M+rT6JhJAq5Jj6LisUEdaTyv/vmyDbwTojtn5oc6njpF1l5gcGqmL0gI2QFapR4YkAU8MZdz++aSEvr0bdAgPkR+uveFNR4wCitCpYu6X3rAv3+tWQPGXI/1Q2i3SBmaGugBcLcHCR6B6oN823wvgCZKUWcmtyuvv+TmgX1pkcz+2LqNrhqkDQ0UY9ppV+jG+nF14Fhb75xn/NxlYel8qhB3IJs3VrA4GbO7FrxpmgNmRN8PNCQWRsfsrbq7izhmzRRTyNq0C7cx4Yu2HDsuRt2NjxtGtBnauCCt4sKLBJFSdEk2qZmgSAys9bLej6PuB5QfTtqtzmzL3ySHKjFzScLcdi1nv63+Jwvv5+FtADljFY24FkEwS+oEcT1vGZddGuF9mPuVABt3W8DPYbfK7HVrKa6iRZMoRnvfbrEX62JDhvuXuf7IWwv69wA++nToinUgwz57ETtifAlllys3zAkNF4mTGWYEQPkgOUUmtPFrYLryRHDkH32NsgZRiLlsXjVw6Ayq1TYRIJnEQ8Sf4zWX4n88+2Qe7UBcaUT6AQ==
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en;
 SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7718.eurprd08.prod.outlook.com;
 PTR:; CAT:NONE;
 SFS:(13230028)(4636009)(396003)(136003)(376002)(346002)(366004)(39860400002)(451199021)(38070700005)(33656002)(86362001)(2906002)(55016003)(71200400001)(478600001)(7696005)(26005)(66574015)(6506007)(9686003)(83380400001)(76116006)(66946007)(66446008)(64756008)(8676002)(4326008)(66556008)(316002)(54906003)(66476007)(53546011)(110136005)(52536014)(122000001)(186003)(8936002)(5660300002)(41300700001)(38100700002)(23180200003);
 DIR:OUT; SFP:1101; 
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5655
Original-Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT010.eop-EUR03.prod.protection.outlook.com
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id-Prvs: 2019e9f8-cffc-414a-bed5-08db2ffb8f28
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 9O3Ak7ZKdHhmRswNHf9w80GBX60nHgE0Lb2PznFobOhuLowR6XsLBflX6ggcQrFvp01lKleavU2UWetwaGeN68xV/K4WB63boWbiSM2WUUKRY8zsKhK4b9YJ2NfXztz/L1eBSo8VeoXDdi6E8+xHvrRmIvruCdPMtU3kP4ekpTInej1OGSVdXONdsOL3/4PXa4CWA/5PCWh76ebS/1GQfFsEnigOBYYh3X2ObC5UqVtUGeHasn4I5Yb2FpMJCFXlk8uRrPIC7eSNZlEHnvHe48kgO6jzzokVZ1a7WcPP/pLk+inc3CwLoX6ZfzeiS64A1Rohinp3d1XYwT9UalqpVi8vaL5gzN+q/0eSNaVPBuHTrprlwedNOGv2Pni4W7cEhwI/d/0lV2GW0wCb/DA08e7rqIcLS0vpseaqTgoITcXpfEUg3vd7FXHO4HQd8yTEJK41F+0ZJvVBUr4G8zOdMps42owJTr/8529yAlPsYxoGI8G4GzafabcgfNpFWhVgma2zwxChfUssJH8hgFqfwdJnr/b+VNxXO3vDe3xnRhJs3ENUdnLAadr6Ba5pbjudH8wDBYMHDvohKxvbFt8HwcOEn4OuPEN+Tm3ltn4L3lqCXBLu5KI3yL/W719Kbe8OlLZcxjXjIch7q4E2W99oA3HiWNv2ID6j7XTbcC/PdEwQ4PIs+ALb/EpkeavoXc7eiUSMFKQCEJq3c8a+EliGWgBm/AW01bsEoOIgKko+uqs=
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:(13230028)(4636009)(396003)(346002)(39860400002)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(9686003)(83380400001)(55016003)(26005)(186003)(2906002)(53546011)(86362001)(36860700001)(82310400005)(356005)(82740400003)(33656002)(40480700001)(81166007)(40460700003)(336012)(6506007)(47076005)(66574015)(54906003)(8936002)(52536014)(70586007)(70206006)(110136005)(7696005)(8676002)(478600001)(5660300002)(41300700001)(4326008)(316002)(23180200003);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 02:16:22.9526 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 8810ba7d-9999-4fd5-a937-08db2ffb97a1
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: AM7EUR03FT010.eop-EUR03.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5832
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Hi, Morten

> -----Original Message-----
> From: Morten Br=F8rup <mb@smartsharesystems.com>
> Sent: Thursday, March 23, 2023 7:42 PM
> To: Feifei Wang <Feifei.Wang2@arm.com>; thomas@monjalon.net; Ferruh
> Yigit <ferruh.yigit@amd.com>; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>
> Cc: dev@dpdk.org; konstantin.v.ananyev@yandex.ru; nd <nd@arm.com>;
> Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>
> Subject: RE: [PATCH v4 1/3] ethdev: add API for buffer recycle mode
>=20
> > From: Feifei Wang [mailto:feifei.wang2@arm.com]
> > Sent: Thursday, 23 March 2023 11.43
> >
>=20
> [...]
>=20
> > +static inline uint16_t rte_eth_rx_descriptors_refill(uint16_t port_id,
> > +		uint16_t queue_id, uint16_t nb)
> > +{
> > +	struct rte_eth_fp_ops *p;
> > +	void *qd;
> > +
> > +#ifdef RTE_ETHDEV_DEBUG_RX
> > +	if (port_id >=3D RTE_MAX_ETHPORTS ||
> > +			queue_id >=3D RTE_MAX_QUEUES_PER_PORT) {
> > +		RTE_ETHDEV_LOG(ERR,
> > +			"Invalid port_id=3D%u or queue_id=3D%u\n",
> > +			port_id, queue_id);
> > +		rte_errno =3D ENODEV;
> > +		return 0;
> > +	}
> > +#endif
> > +
> > +	p =3D &rte_eth_fp_ops[port_id];
> > +	qd =3D p->rxq.data[queue_id];
> > +
> > +#ifdef RTE_ETHDEV_DEBUG_RX
> > +	if (!rte_eth_dev_is_valid_port(port_id)) {
> > +		RTE_ETHDEV_LOG(ERR, "Invalid Rx port_id=3D%u\n", port_id);
> > +		rte_errno =3D ENODEV;
> > +		return 0;
> > +
> > +	if (qd =3D=3D NULL) {
> > +		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=3D%u for
> port_id=3D%u\n",
> > +			queue_id, port_id);
> > +		rte_errno =3D ENODEV;
> > +		return 0;
> > +	}
> > +#endif
> > +
> > +	if (!p->rx_descriptors_refill)
>=20
> Compare to NULL instead: if (p->rx_descriptors_refill =3D=3D NULL)
>=20
Ack.

> > +		return 0;
> > +
> > +	return p->rx_descriptors_refill(qd, nb); }
> > +
> >  /**@{@name Rx hardware descriptor states
> >   * @see rte_eth_rx_descriptor_status
> >   */
> > @@ -6483,6 +6597,122 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t
> queue_id,
> >  	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);  }
> >
> > +/**
> > + * @internal
> > + * Tx routine for rte_eth_dev_buf_recycle().
> > + * Stash Tx used buffers into Rx buffer ring in buffer recycle mode.
> > + *
> > + * @note
> > + * This API can only be called by rte_eth_dev_buf_recycle().
> > + * After calling this API, rte_eth_rx_descriptors_refill() should be
> > + * called to refill Rx ring descriptors.
> > + *
> > + * When this functionality is not implemented in the driver, the
> > +return
> > + * buffer number is 0.
> > + *
> > + * @param port_id
> > + *   The port identifier of the Ethernet device.
> > + * @param queue_id
> > + *   The index of the transmit queue.
> > + *   The value must be in the range [0, nb_tx_queue - 1] previously
> supplied
> > + *   to rte_eth_dev_configure().
> > + * @param rxq_buf_recycle_info
> > + *   A pointer to a structure of Rx queue buffer ring information in b=
uffer
> > + *   recycle mode.
> > + *
> > + * @return
> > + *   The number buffers correct to be filled in the Rx buffer ring.
> > + *   - ENODEV: bad port or queue (only if compiled with debug).
> > + */
> > +static inline uint16_t rte_eth_tx_buf_stash(uint16_t port_id,
> > +uint16_t
> > queue_id,
> > +		struct rte_eth_rxq_buf_recycle_info *rxq_buf_recycle_info)
> {
> > +	struct rte_eth_fp_ops *p;
> > +	void *qd;
> > +
> > +#ifdef RTE_ETHDEV_DEBUG_TX
> > +	if (port_id >=3D RTE_MAX_ETHPORTS ||
> > +			queue_id >=3D RTE_MAX_QUEUES_PER_PORT) {
> > +		RTE_ETHDEV_LOG(ERR,
> > +			"Invalid port_id=3D%u or queue_id=3D%u\n",
> > +			port_id, queue_id);
> > +		rte_errno =3D ENODEV;
> > +		return 0;
> > +	}
> > +#endif
> > +
> > +	p =3D &rte_eth_fp_ops[port_id];
> > +	qd =3D p->txq.data[queue_id];
> > +
> > +#ifdef RTE_ETHDEV_DEBUG_TX
> > +	if (!rte_eth_dev_is_valid_port(port_id)) {
> > +		RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=3D%u\n", port_id);
> > +		rte_errno =3D ENODEV;
> > +		return 0;
> > +
> > +	if (qd =3D=3D NULL) {
> > +		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=3D%u for
> port_id=3D%u\n",
> > +			queue_id, port_id);
> > +		rte_erno =3D ENODEV;
> > +		return 0;
> > +	}
> > +#endif
> > +
> > +	if (p->tx_buf_stash =3D=3D NULL)
> > +		return 0;
> > +
> > +	return p->tx_buf_stash(qd, rxq_buf_recycle_info); }
> > +
> > +/**
> > + * @warning
> > + * @b EXPERIMENTAL: this API may change, or be removed, without prior
> > +notice
> > + *
> > + * Buffer recycle mode can let Tx queue directly put used buffers
> > +into Rx
> > buffer
> > + * ring. This avoids freeing buffers into mempool and allocating
> > +buffers from
> > + * mempool.
> > + *
> > + * @param rx_port_id
> > + *   Port identifying the receive side.
> > + * @param rx_queue_id
> > + *   The index of the receive queue identifying the receive side.
> > + *   The value must be in the range [0, nb_rx_queue - 1] previously
> supplied
> > + *   to rte_eth_dev_configure().
> > + * @param tx_port_id
> > + *   Port identifying the transmit side.
> > + * @param tx_queue_id
> > + *   The index of the transmit queue identifying the transmit side.
> > + *   The value must be in the range [0, nb_tx_queue - 1] previously
> supplied
> > + *   to rte_eth_dev_configure().
> > + * @param rxq_recycle_info
> > + *   A pointer to a structure of type *rte_eth_txq_rearm_data* to be f=
illed.
> > + * @return
> > + *   - (0) on success or no recycling buffer.
> > + *   - (-EINVAL) rxq_recycle_info is NULL.
> > + */
> > +__rte_experimental
> > +static inline int
> > +rte_eth_dev_buf_recycle(uint16_t rx_port_id, uint16_t rx_queue_id,
> > +		uint16_t tx_port_id, uint16_t tx_queue_id,
> > +		struct rte_eth_rxq_buf_recycle_info *rxq_buf_recycle_info)
> {
> > +	/* The number of recycling buffers. */
> > +	uint16_t nb_buf;
> > +
> > +	if (!rxq_buf_recycle_info)
> > +		return -EINVAL;
>=20
> Compare to NULL instead: if (rxq_buf_recycle_info =3D=3D NULL)
>=20
Ack.
> Alternatively: Consider RTE_ASSERT() and require rxq_buf_recycle_info to
> be valid.
>=20
Good comments. This ensure users to create a rxq_buf_recycle_info variable =
before
call this info_get API.
> > +
> > +	/* Stash Tx used buffers into Rx buffer ring */
> > +	nb_buf =3D rte_eth_tx_buf_stash(tx_port_id, tx_queue_id,
> > +				rxq_buf_recycle_info);
> > +	/* If there are recycling buffers, refill Rx queue descriptors. */
> > +	if (nb_buf)
> > +		rte_eth_rx_descriptors_refill(rx_port_id, rx_queue_id,
> > +					nb_buf);
> > +
> > +	return 0;
> > +}
> > +
> >  /**
> >   * @warning
> >   * @b EXPERIMENTAL: this API may change without prior notice diff
> > --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
> > index dcf8adab92..10f9d5cbe7 100644
> > --- a/lib/ethdev/rte_ethdev_core.h
> > +++ b/lib/ethdev/rte_ethdev_core.h
> > @@ -56,6 +56,13 @@ typedef int (*eth_rx_descriptor_status_t)(void
> > *rxq, uint16_t offset);
> >  /** @internal Check the status of a Tx descriptor */  typedef int
> > (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
> >
> > +/** @internal Stash Tx used buffers into RX ring in buffer recycle
> > +mode */ typedef uint16_t (*eth_tx_buf_stash_t)(void *txq,
> > +		struct rte_eth_rxq_buf_recycle_info *rxq_buf_recycle_info);
> > +
> > +/** @internal Refill Rx descriptors in buffer recycle mode */ typedef
> > +uint16_t (*eth_rx_descriptors_refill_t)(void *rxq, uint16_t nb);
> > +
> >  /**
> >   * @internal
> >   * Structure used to hold opaque pointers to internal ethdev Rx/Tx @@
> > -90,6 +97,8 @@ struct rte_eth_fp_ops {
> >  	eth_rx_queue_count_t rx_queue_count;
> >  	/** Check the status of a Rx descriptor. */
> >  	eth_rx_descriptor_status_t rx_descriptor_status;
> > +	/** Refill Rx descriptors in buffer recycle mode */
> > +	eth_rx_descriptors_refill_t rx_descriptors_refill;
> >  	/** Rx queues data. */
> >  	struct rte_ethdev_qdata rxq;
> >  	uintptr_t reserved1[3];
>=20
> In order to keep 64 B alignment, the reserved1 array must be reduced from=
 3
> to 2.
Agree.
>=20
> > @@ -106,6 +115,8 @@ struct rte_eth_fp_ops {
> >  	eth_tx_prep_t tx_pkt_prepare;
> >  	/** Check the status of a Tx descriptor. */
> >  	eth_tx_descriptor_status_t tx_descriptor_status;
> > +	/** Stash Tx used buffers into RX ring in buffer recycle mode */
> > +	eth_tx_buf_stash_t tx_buf_stash;
> >  	/** Tx queues data. */
> >  	struct rte_ethdev_qdata txq;
> >  	uintptr_t reserved2[3];
>=20
> In order to keep 64 B alignment, the reserved2 array must be reduced from=
 3
> to 2.
Agree.
>=20
> > diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index
> > 357d1a88c0..8a4b1dac80 100644
> > --- a/lib/ethdev/version.map
> > +++ b/lib/ethdev/version.map
> > @@ -299,6 +299,10 @@ EXPERIMENTAL {
> >  	rte_flow_action_handle_query_update;
> >  	rte_flow_async_action_handle_query_update;
> >  	rte_flow_async_create_by_index;
> > +
> > +	# added in 23.07
> > +	rte_eth_dev_buf_recycle;
> > +	rte_eth_rx_queue_buf_recycle_info_get;
> >  };
> >
> >  INTERNAL {
> > @@ -328,4 +332,6 @@ INTERNAL {
> >  	rte_eth_representor_id_get;
> >  	rte_eth_switch_domain_alloc;
> >  	rte_eth_switch_domain_free;
> > +	rte_eth_tx_buf_stash;
> > +	rte_eth_rx_descriptors_refill;
> >  };
> > --
> > 2.25.1
> >