From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 6BB3EA0679 for ; Wed, 3 Apr 2019 17:03:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B2D51B48A; Wed, 3 Apr 2019 17:03:47 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150052.outbound.protection.outlook.com [40.107.15.52]) by dpdk.org (Postfix) with ESMTP id 1ABFF1B487 for ; Wed, 3 Apr 2019 17:03:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V+GzDAnJLlGoJtDX50kEvnBYqAN9C3rRXq3FnT91dII=; b=j0xCwbKe7O/wKFpC5UxNeMy+PydNCj3nB4BRfmI993f4GCi3KxlR/PtzRveFgZKfh/pNrAMEARQOgcyszYA3f/l+iwjsSKFKtP/B2d+WdYoZNt26JpxUOOZB00y0vKyV6HKy/1IU4vNXRmQCh1fcScTFd9Zsrr4FTIPH1r+hEoQ= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.188.154) by AM4PR05MB3217.eurprd05.prod.outlook.com (10.171.186.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.17; Wed, 3 Apr 2019 15:03:45 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::11b0:de86:8d93:8b02]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::11b0:de86:8d93:8b02%3]) with mapi id 15.20.1750.021; Wed, 3 Apr 2019 15:03:45 +0000 From: Slava Ovsiienko To: Thomas Monjalon , "gaetan.rivet@6wind.com" , Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 2/4] ethdev: add siblings iterators Thread-Index: AQHU6DJ9CXwPxNxvTEGbRH4rMC+l7KYqjGdg Date: Wed, 3 Apr 2019 15:03:45 +0000 Message-ID: References: <20181130002716.27325-1-thomas@monjalon.net> <20190401022700.1570-1-thomas@monjalon.net> <20190401022700.1570-3-thomas@monjalon.net> In-Reply-To: <20190401022700.1570-3-thomas@monjalon.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-originating-ip: [95.67.35.250] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 99362b93-bc12-4d8a-84c2-08d6b845916b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM4PR05MB3217; x-ms-traffictypediagnostic: AM4PR05MB3217: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 0996D1900D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(136003)(39860400002)(396003)(199004)(189003)(13464003)(316002)(66066001)(186003)(5660300002)(6506007)(76176011)(256004)(97736004)(14444005)(7696005)(53546011)(305945005)(476003)(33656002)(14454004)(8676002)(71200400001)(446003)(11346002)(99286004)(52536014)(6116002)(71190400001)(53936002)(6436002)(68736007)(81156014)(486006)(8936002)(106356001)(26005)(110136005)(478600001)(102836004)(81166006)(105586002)(86362001)(25786009)(2906002)(7736002)(2501003)(74316002)(3846002)(229853002)(55016002)(9686003)(4326008)(6246003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3217; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: f4aOva+GYQZyaA2V2YnNZT4Bf3Glol5Z2P9eQAVsIqNktoy+OJ6n3eBSw8hpLYWsGGMbFJrCro3X4XaFz5Yv8CQpSBgoxD/Hsool9P5F/ahoZg2AIFo2K2XwWWhlh7d8neM20ECvmoty8ZPHg0dTtEUCU15SXEautMdS2ZTRseAKjy1kHC15h1nPy1kOI3P3tG3r2YzyKWafOJdtao1HCMGogrwudlogq/K0qKyNoKkLvEQCWJFMr4z3YpTENYVmQx2OlbOczQ7TPVZnXppfRa6zqWBr82+mm3G61NFKf1WGfDXlfeHVvO93UmHqJcItqa/2aCMkITutG0nRW60iH1ezWiZxm3oKKfLMHl2nticQU4a1l2grk0GOlPqsol7aNP+NkQFR3Y3LhmlWoltwVc7kZ2z0gUKxksfvPsmGY7Q= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99362b93-bc12-4d8a-84c2-08d6b845916b X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Apr 2019 15:03:45.0399 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3217 Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: add siblings iterators 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" Message-ID: <20190403150345.ErgyymBYzq59A1ETi3enr3y3dCJe85QA8GUvy2nQVMU@z> > -----Original Message----- > From: dev On Behalf Of Thomas Monjalon > Sent: Monday, April 1, 2019 5:27 > To: gaetan.rivet@6wind.com; Ferruh Yigit ; Andrew > Rybchenko > Cc: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v3 2/4] ethdev: add siblings iterators >=20 > If multiple ports share the same hardware device (rte_device), they are > siblings and can be found thanks to the new functions and loop macros. > One iterator takes a port id as reference, while the other one directly r= efers > to the parent device. >=20 > The ownership is not checked because siblings may have different owners. >=20 > Signed-off-by: Thomas Monjalon Tested-by: Viacheslav Ovsiienko > --- > v2: Reviewed-by: Andrew Rybchenko - not kept because of changes in v3 >=20 > v3: > - fix logic + re-use rte_eth_find_next() > - longer parameter names > - more and better doxygen comments > --- > lib/librte_ethdev/rte_ethdev.c | 19 +++++++ > lib/librte_ethdev/rte_ethdev.h | 63 ++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev_version.map | 2 + > 3 files changed, 84 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 33cffc498..3b125a642 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -339,6 +339,25 @@ rte_eth_find_next(uint16_t port_id) > return port_id; > } >=20 > +uint16_t __rte_experimental > +rte_eth_find_next_of(uint16_t port_id, const struct rte_device *parent) > +{ > + port_id =3D rte_eth_find_next(port_id); > + while (port_id < RTE_MAX_ETHPORTS && > + rte_eth_devices[port_id].device !=3D parent) > + port_id =3D rte_eth_find_next(port_id + 1); > + > + return port_id; > +} > + > +uint16_t __rte_experimental > +rte_eth_find_next_sibling(uint16_t port_id, uint16_t ref_port_id) { > + RTE_ETH_VALID_PORTID_OR_ERR_RET(ref_port_id, > RTE_MAX_ETHPORTS); > + return rte_eth_find_next_of(port_id, > + rte_eth_devices[ref_port_id].device); > +} > + > static void > rte_eth_dev_shared_data_prepare(void) > { > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.h > index b6023c050..3d5bacaee 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -1387,6 +1387,69 @@ uint16_t rte_eth_find_next(uint16_t port_id); > #define RTE_ETH_FOREACH_DEV(p) \ > RTE_ETH_FOREACH_DEV_OWNED_BY(p, > RTE_ETH_DEV_NO_OWNER) >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Iterates over ethdev ports of a specified device. > + * > + * @param port_id_start > + * The id of the next possible valid port. > + * @param parent > + * The generic device behind the ports to iterate. > + * @return > + * Next port id of the device, possibly port_id_start, > + * RTE_MAX_ETHPORTS if there is none. > + */ > +__rte_experimental > +uint16_t rte_eth_find_next_of(uint16_t port_id_start, > + const struct rte_device *parent); > + > +/** > + * Macro to iterate over all ethdev ports of a specified device. > + * > + * @param port_id > + * The id of the matching port being iterated. > + * @param parent > + * The rte_device pointer matching the iterated ports. > + */ > +#define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \ > + for (port_id =3D rte_eth_find_next_of(0, parent); \ > + port_id < RTE_MAX_ETHPORTS; \ > + port_id =3D rte_eth_find_next_of(port_id + 1, parent)) > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Iterates over sibling ethdev ports (i.e. sharing the same rte_device)= . > + * > + * @param port_id_start > + * The id of the next possible valid sibling port. > + * @param ref_port_id > + * The id of a reference port to compare rte_device with. > + * @return > + * Next sibling port id, possibly port_id_start or ref_port_id itself, > + * RTE_MAX_ETHPORTS if there is none. > + */ > +__rte_experimental > +uint16_t rte_eth_find_next_sibling(uint16_t port_id_start, > + uint16_t ref_port_id); > + > +/** > + * Macro to iterate over all ethdev ports sharing the same rte_device > + * as the specified port. > + * Note: the specified reference port is part of the loop iterations. > + * > + * @param port_id > + * The id of the matching port being iterated. > + * @param ref_port_id > + * The id of the port being compared. > + */ > +#define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \ > + for (port_id =3D rte_eth_find_next_sibling(0, ref_port_id); \ > + port_id < RTE_MAX_ETHPORTS; \ > + port_id =3D rte_eth_find_next_sibling(port_id + 1, ref_port_id)) >=20 > /** > * @warning > diff --git a/lib/librte_ethdev/rte_ethdev_version.map > b/lib/librte_ethdev/rte_ethdev_version.map > index 92ac3de25..b37a4167d 100644 > --- a/lib/librte_ethdev/rte_ethdev_version.map > +++ b/lib/librte_ethdev/rte_ethdev_version.map > @@ -245,6 +245,8 @@ EXPERIMENTAL { > rte_eth_dev_owner_set; > rte_eth_dev_owner_unset; > rte_eth_dev_rx_intr_ctl_q_get_fd; > + rte_eth_find_next_of; > + rte_eth_find_next_sibling; > rte_eth_switch_domain_alloc; > rte_eth_switch_domain_free; > rte_flow_conv; > -- > 2.21.0