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 A6F4AA04BC; Thu, 8 Oct 2020 11:41:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 834B51BC29; Thu, 8 Oct 2020 11:41:13 +0200 (CEST) Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) by dpdk.org (Postfix) with ESMTP id 6C21A1BBFD for ; Thu, 8 Oct 2020 11:41:11 +0200 (CEST) Received: from HKMAIL102.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 08 Oct 2020 17:41:09 +0800 Received: from HKMAIL103.nvidia.com (10.18.16.12) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 8 Oct 2020 09:41:05 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 8 Oct 2020 09:41:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXkGZdtAIC0PTTxJ5nwjpgkrsSXu1q14PrVe2hSvVjzQbkJI0gQm9xY9J93sGwUZXpdV9u/A647fRDPR68oP6s0sZgNVqCur5DxA7DlCfFTmsX1snaZ7OvxdhKIInWvCRAQuBR+jr55FdC+NMqrkjpnRaOFE18MDovUAMjIDvSajdq27ngoi2buD4kAooI39A7UgSc2YQlrObzpmNpjUyDE+Vt2Er98YlEKz0+Rb2ouZhTAMo4Sbu9zQrO1LusToAyXaVE4ZkIbtKiGoYC9SpMnNc0w/ywH5m7kXDWTBa7BqN7tIsb6TPOxHpCDl4MRQh6vK5gTOIBV74WtedG5F5w== 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=xyiaGFHbfKhwGvpe5230nMrkqrsdTBNhRHp6Jyr4j+g=; b=gFmnFCDLAvG0GBPle0SMWOf/oax4T+zdbxp9guuWt/iTTwX19xLcB8iKaKgFcEnuTySKrcSeXIBwRJeFZVX7SP3ET4TuIMneXDYqKBZnULN648rjiMsscYkPDHA6lOVhJ3gnMkkkv9LSr+SNp/8JU5i8nHlIvPWR1n8lng2YVB2ZtIax7l+9mSWCy515peMTEg7nEQgO5aC862uo5vR+BXAXZsy3/pKEVuNpS+/cUjVkmDHcHSwirzofscdZIaV2ClomqwaEVdTt8sDlH2ER3IPRiom3g9am5YceJknNRWwf4IbOOsaji9iTZCXBKbE78EnTpFWiSu2gk3mY/4D/Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from MN2PR12MB4286.namprd12.prod.outlook.com (2603:10b6:208:199::22) by MN2PR12MB4830.namprd12.prod.outlook.com (2603:10b6:208:1bc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 8 Oct 2020 09:40:42 +0000 Received: from MN2PR12MB4286.namprd12.prod.outlook.com ([fe80::61fd:a36e:cf4f:2d3f]) by MN2PR12MB4286.namprd12.prod.outlook.com ([fe80::61fd:a36e:cf4f:2d3f%9]) with mapi id 15.20.3455.023; Thu, 8 Oct 2020 09:40:42 +0000 From: Ori Kam To: Bing Zhao , NBU-Contact-Thomas Monjalon , "ferruh.yigit@intel.com" , "arybchenko@solarflare.com" , "mdr@ashroe.eu" , "nhorman@tuxdriver.com" , "bernard.iremonger@intel.com" , "beilei.xing@intel.com" , "wenzhuo.lu@intel.com" CC: "dev@dpdk.org" Thread-Topic: [PATCH v2 3/6] ethdev: add API to get hairpin peer ports list Thread-Index: AQHWnVBRZtrXPUToEUGvxUM1ebJ+z6mNawRg Date: Thu, 8 Oct 2020 09:40:42 +0000 Message-ID: References: <1601511962-21532-1-git-send-email-bingz@nvidia.com> <1602147098-9768-1-git-send-email-bingz@nvidia.com> <1602147098-9768-4-git-send-email-bingz@nvidia.com> In-Reply-To: <1602147098-9768-4-git-send-email-bingz@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [147.236.152.129] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9e779cfe-ac29-4c7e-d466-08d86b6e3971 x-ms-traffictypediagnostic: MN2PR12MB4830: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aPJ9Bvrd9qfRpk9GdyirG//IDqDuzra/mqN9Ky/gWWhJIswL8f6CEXQ7wJfqqGML2s1hPfPQBtInPPJeMH6heYTH0DIFfCrct9aNcfHQemPzbBxgdeHoiiVd+BIQHJvX8x8+hKtch9BYQZonMmlOlRZ2E8MIipYNl8/XUt2+YnNJEy4MdgtTAzsKSFI2hoMo+M12Slibt+MuXHRKBcsCzQXU9Via32M7pA7G1CbVdeuDSViaHrquQRsAGSXiIRVLmCJNG1m8tdP6hZ95RbIR6jEzPjfw64UaqUjipztecmYPIRopwYzxYbxmHvCGBtud3q101L4OKwfHe7NOC4aA+g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB4286.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(376002)(136003)(396003)(39860400002)(66446008)(316002)(33656002)(52536014)(5660300002)(110136005)(4326008)(86362001)(66476007)(66556008)(64756008)(83380400001)(9686003)(8676002)(2906002)(8936002)(55016002)(6506007)(53546011)(186003)(71200400001)(478600001)(7696005)(76116006)(66946007)(26005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: okghG5O9xT+NDWXHSxs/Lfq5aedef1EOPb9SYjINYIK8+tmVIqNlxqtKH1gzZUNdcFJ+BclV6YNoVo3eRDOLZgZljLB5UWxgW9MFAa7XiW2tuN5bT/aTAAUxf7pJiKP1ovv3JtQ0P+DZAoBn3uMoGWl143ssmjy5xe/QtHBJkYK5CP/faivkbkZnTyDs7EB0wXcanvdpozXZioy7dJBl9mEOh5DFwIuE+xAuApiAw1g3EUghZcjstM1skYuM1aCNBPc6C/ZHq62QHYOQtSJzq6jlU/2aKcVqFMEg9RlXWKeyeRHElZl0ORZi/mhDni0eFEywt5akFi7TYTHrd9Fp4DPVjremMPbPx7VJYsCSeUNhnN6/GpDZY+j1Z+za59XYx7OSDTU8Pg90vDTlvhHO1Yg0rpJY4eofGV0jAqF+g7svnkJzn91QuEqNcLdtMOzaDm6Ff+WazA8q1XDsONklgGNvU6pNhVTET6Xx6tK6FhytWnPs38TpflUX9/SU8QdlqaRKBK84qEKJJgFUF13M1soPVhq5qAkYlz1NH4/0tXG6HITwcvleJLaXkYYcq84nKkc6+zBPXYbnOUA6NhJMIENFAxPTeZ5mxNQXeoUkrrqoLSSW3WSrZA5Qe1uMPZBZndXS1TiIDGggI5+uA/T+zg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e779cfe-ac29-4c7e-d466-08d86b6e3971 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Oct 2020 09:40:42.5946 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XKDjyVGegOZ9eZpftqUNN4CnSnVGIpMf8YG7isiI38Zi+47yyf55MkTYwxIfopyvaIaBrrnLb1JSaP9q5dCvtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4830 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1602150069; bh=xyiaGFHbfKhwGvpe5230nMrkqrsdTBNhRHp6Jyr4j+g=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References: In-Reply-To:Accept-Language:Content-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-ms-office365-filtering-correlation-id: x-ms-traffictypediagnostic:x-ld-processed: x-ms-exchange-transport-forked:x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers:x-ms-exchange-senderadcheck: x-microsoft-antispam:x-microsoft-antispam-message-info: x-forefront-antispam-report:x-ms-exchange-antispam-messagedata: Content-Type:Content-Transfer-Encoding:MIME-Version: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; b=bpmYTDPZds8j00g4vqZfKcb7hqYYscM/qxCl+G3T5owgi/TnRwtxOcxheuGYdijZN CxQAe5dv8sSHeSVO365ftVnmn39mhioH0+kpEvwuI4Sevk/9WGpK3kc2l3JOiutWR3 7pebK9ra6uTQRNlCYudo8edzjhx+SKoiJbziXQjTy7b6IXurlpOLuoSu2G2Vk0vwgl N0UPRE3YVr96bWp92ufZnCAcLAygMcki5w2gCN4T0TDy/1u2ChIpnaWn7hi+32uryd 11ZsGCiILfTfwtf7lNCR7nvBhsz5BbFos8oT05zaTotvo7gGs/YwT1GTT2C5a3BjVx gI1pkXlxhrKoQ== Subject: Re: [dpdk-dev] [PATCH v2 3/6] ethdev: add API to get hairpin peer ports list 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 Bing, PSB, Best, Ori > -----Original Message----- > From: Bing Zhao > Sent: Thursday, October 8, 2020 11:52 AM > Subject: [PATCH v2 3/6] ethdev: add API to get hairpin peer ports list >=20 > After hairpin queues are configured, in general, the application will > maintain the ports topology and even the queues configuration for > hairpin. But sometimes it will not. >=20 > If there is no hot-plug, it is easy to bind and unbind hairpin among > all the ports. The application can just connect or disconnect the > hairpin egress ports to / from all the probed ingress ports. Then > all the connections could be handled properly. >=20 > But with hot-plug / hot-unplug, one port could be probed and removed > dynamically. With two ports hairpin, all the connections from and to > this port should be handled after start(bind) or before stop(unbind). > It is necessary to know the hairpin topology with this port. >=20 > This API will return the ports list with the actual peer ports number > after configuration. Either peer RX or TX ports will be gotten with > this function call. >=20 > Signed-off-by: Bing Zhao > --- > lib/librte_ethdev/rte_ethdev.c | 24 ++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++++++++++++++= + > lib/librte_ethdev/rte_ethdev_driver.h | 30 > ++++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev_version.map | 1 + > 4 files changed, 82 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index a4adeff..ea7892a 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -2208,6 +2208,30 @@ struct rte_eth_dev * > return ret; > } >=20 > +int > +rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, > + bool direction) > +{ > + struct rte_eth_dev *dev; > + int ret; > + > + if (!peer_ports) > + return -EINVAL; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(cur_port, -EINVAL); > + dev =3D &rte_eth_devices[cur_port]; > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >hairpin_get_peer_ports, > + -ENOTSUP); > + > + ret =3D (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, > + direction); > + if (ret < 0) > + RTE_ETHDEV_LOG(ERR, "Failed to get %d hairpin peer %s > ports", > + cur_port, direction ? "RX" : "TX"); > + > + return ret; > +} > + > void > rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent, > void *userdata __rte_unused) > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.h > index 94a981c..6680de2 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -2134,6 +2134,33 @@ int rte_eth_tx_queue_setup(uint16_t port_id, > uint16_t tx_queue_id, > * @warning > * @b EXPERIMENTAL: this API may change, or be removed, without prior > notice > * > + * Get all the hairpin peer RX / TX ports of the current port. > + * The caller should ensure that the array is large enough to save the p= orts > + * list. > + * > + * @param cur_port > + * The current port identifier of the Ethernet device. > + * @param peer_ports > + * Pointer to the array to save the peer ports list * > + * @param direction > + * Current port to peer port direction > + * true - current used as TX to get all peer RX ports. > + * false - current used as RX to get all peer TX ports. > + * > + * @return > + * - (0 or positive) actual peer ports number. > + * - (-EINVAL) if bad parameter. > + * - (-ENOTSUP) if hardware doesn't support. > + * - Others detailed errors from PMD drivers. > + */ > +__rte_experimental > +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_por= ts, > + bool direction); > + I think direction should be changed to int, or change the name to ingress, = also I think we should add the peer_ports array size, so in case the application didn't allocate enough space it will simply end in error. > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior > notice > + * > * Bind all hairpin TX queues of one port to the RX queues of the peer p= ort. > * It is only allowed to call this API after all hairpin queues are conf= igured > * properly and the devices of TX and peer RX are in started state. > diff --git a/lib/librte_ethdev/rte_ethdev_driver.h > b/lib/librte_ethdev/rte_ethdev_driver.h > index f8eb879..ecca9d6 100644 > --- a/lib/librte_ethdev/rte_ethdev_driver.h > +++ b/lib/librte_ethdev/rte_ethdev_driver.h > @@ -576,6 +576,34 @@ typedef int (*eth_tx_hairpin_queue_setup_t) >=20 > /** > * @internal > + * Get all hairpin TX/RX peer ports of the current device, if any. > + * > + * @param dev > + * ethdev handle of port. > + * @param peer_ports > + * array to save the ports list. > + * @param direction > + * value to decide the current to peer direction > + * true - used as TX to get all peer RX ports. > + * false - used as RX to get all peer TX ports. > + * > + * @return > + * Negative errno value on error, 0 or positive on success. > + * > + * @retval 0 > + * Success, no peer ports. > + * @retval >0 > + * Actual number of the peer ports. > + * @retval -ENOTSUP > + * Get peer ports API is not supported. > + * @retval -EINVAL > + * One of the parameters is invalid. > + */ > +typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev, > + uint16_t *peer_ports, bool direction); > + > +/** > + * @internal > * Bind all hairpin TX queues of one port to the RX queues of the peer p= ort. > * > * @param dev > @@ -761,6 +789,8 @@ struct eth_dev_ops { > /**< Set up device RX hairpin queue. */ > eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; > /**< Set up device TX hairpin queue. */ > + hairpin_get_peer_ports_t hairpin_get_peer_ports; > + /**< Get hairpin peer ports list. */ > eth_hairpin_bind_t hairpin_bind; > /**< Bind all hairpin TX queues of device to the peer port RX queues. *= / > eth_hairpin_unbind_t hairpin_unbind; > diff --git a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index 18efe4e..1019e28 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -228,6 +228,7 @@ EXPERIMENTAL { >=20 > # added in 20.11 > rte_eth_hairpin_bind; > + rte_eth_hairpin_get_peer_ports; > rte_eth_hairpin_unbind; > rte_eth_link_speed_to_str; > rte_eth_link_to_str; > -- > 1.8.3.1