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 EC858A0679 for ; Wed, 3 Apr 2019 17:04:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBAAC1B44E; Wed, 3 Apr 2019 17:04:11 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150088.outbound.protection.outlook.com [40.107.15.88]) by dpdk.org (Postfix) with ESMTP id 0F1B81B43D for ; Wed, 3 Apr 2019 17:04:11 +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=2AHcCODqcbtEKC3+WTh5wmkqiAIJ5d4InusoDbAy4qQ=; b=rUsDQ54VsCsZZZnkS/P7xRaxLQEGa+x4OXgYGNaAFzz20Xe2Y6V9R+KDKPh47fQ7HroA2rAVEPwo9CKsGjQS2jqV90XUhSSMZ4V9BpIMz6Gz9bC43pk4cDE58dJCIn+XxQG78M66gpRbO/mlBygvl9ugYY+e8MN0oXBC8fdmzqk= 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:04:05 +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:04:05 +0000 From: Slava Ovsiienko To: Thomas Monjalon , "gaetan.rivet@6wind.com" , Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 3/4] net/mlx5: use port sibling iterators Thread-Index: AQHU6DKB5DmVcWq9JU6GD1jXr4Vhv6YqjIJw Date: Wed, 3 Apr 2019 15:04:05 +0000 Message-ID: References: <20181130002716.27325-1-thomas@monjalon.net> <20190401022700.1570-1-thomas@monjalon.net> <20190401022700.1570-4-thomas@monjalon.net> In-Reply-To: <20190401022700.1570-4-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: 1c0d03d4-1b80-45b2-a207-08d6b8459dbd 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)(6636002)(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: 8OtaS7+qsC/yJoVduPWrNe1Fjqsc9TkiciuYA4pKBWGlH4xSN0kST6Ku0rJcETrm0llH17KwaelPfSkvq/bB1Ne982AEurXqHsnORAiW+AKXvNvcZbZMZtZ1AFltQhDSADnTkss4qK77XDBhhbEDYboyZKR9fIAP3zQBG1Oggf4VFDeUs1+G6RhDZqIcs6QnqXOBqiDIobHOQLszLGgaIZuNBcalOVreZLlisnhL+7ooxPd6MQgVLvDMpl62K1YAeDMlaElB/EQss3uA+9n82zGFaS9WYHRF2L81XNNztEqh4fTAo7gu7lG/DgtUEBj/ZcFDOMbDPZOA/URcLjgBBMUzrgUvWsSGjpEMtOqM+nUCU8FNWaGxeZ+bG30QDqgpL9h++z74lf9JTUyS14hC2n+iDUcVxY1nIIU7SimN5O8= 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: 1c0d03d4-1b80-45b2-a207-08d6b8459dbd X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Apr 2019 15:04:05.7358 (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 3/4] net/mlx5: use port sibling 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: <20190403150405.9dH2C68TlBFSpEi2naLIh0a-AXdDzWGsT8JzDNo1tXQ@z> > -----Original Message----- > From: dev On Behalf Of Thomas Monjalon > Sent: Monday, April 1, 2019 5:27 > To: gaetan.rivet@6wind.com; Shahaf Shuler ; > Yongseok Koh > Cc: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v3 3/4] net/mlx5: use port sibling iterators >=20 > Iterating over siblings was done with RTE_ETH_FOREACH_DEV() which skips > the owned ports. > The new iterators RTE_ETH_FOREACH_DEV_SIBLING() and > RTE_ETH_FOREACH_DEV_OF() are more appropriate and more correct. >=20 > Signed-off-by: Thomas Monjalon Tested-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5.c | 34 +++++++++++++--------------------- > drivers/net/mlx5/mlx5_ethdev.c | 6 +----- > 2 files changed, 14 insertions(+), 26 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > 1d7ca615b..3287a3d78 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -493,17 +493,15 @@ mlx5_dev_close(struct rte_eth_dev *dev) > dev->data->port_id); > if (priv->domain_id !=3D RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) > { > unsigned int c =3D 0; > - unsigned int i =3D mlx5_dev_to_port_id(dev->device, NULL, 0); > - uint16_t port_id[i]; > + uint16_t port_id; >=20 > - i =3D RTE_MIN(mlx5_dev_to_port_id(dev->device, port_id, i), i); > - while (i--) { > + RTE_ETH_FOREACH_DEV_OF(port_id, dev->device) { > struct mlx5_priv *opriv =3D > - rte_eth_devices[port_id[i]].data- > >dev_private; > + rte_eth_devices[port_id].data->dev_private; >=20 > if (!opriv || > opriv->domain_id !=3D priv->domain_id || > - &rte_eth_devices[port_id[i]] =3D=3D dev) > + &rte_eth_devices[port_id] =3D=3D dev) > continue; > ++c; > } > @@ -1147,22 +1145,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, > * Look for sibling devices in order to reuse their switch domain > * if any, otherwise allocate one. > */ > - i =3D mlx5_dev_to_port_id(dpdk_dev, NULL, 0); > - if (i > 0) { > - uint16_t port_id[i]; > + RTE_ETH_FOREACH_DEV_OF(port_id, dpdk_dev) { > + const struct mlx5_priv *opriv =3D > + rte_eth_devices[port_id].data->dev_private; >=20 > - i =3D RTE_MIN(mlx5_dev_to_port_id(dpdk_dev, port_id, i), i); > - while (i--) { > - const struct mlx5_priv *opriv =3D > - rte_eth_devices[port_id[i]].data- > >dev_private; > - > - if (!opriv || > - opriv->domain_id =3D=3D > - RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) > - continue; > - priv->domain_id =3D opriv->domain_id; > - break; > - } > + if (!opriv || > + opriv->domain_id =3D=3D > + RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) > + continue; > + priv->domain_id =3D opriv->domain_id; > + break; > } > if (priv->domain_id =3D=3D > RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) { > err =3D rte_eth_switch_domain_alloc(&priv->domain_id); > diff --git a/drivers/net/mlx5/mlx5_ethdev.c > b/drivers/net/mlx5/mlx5_ethdev.c index 7273bd940..e01b698fc 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -1398,11 +1398,7 @@ mlx5_dev_to_port_id(const struct rte_device > *dev, uint16_t *port_list, > uint16_t id; > unsigned int n =3D 0; >=20 > - RTE_ETH_FOREACH_DEV(id) { > - struct rte_eth_dev *ldev =3D &rte_eth_devices[id]; > - > - if (ldev->device !=3D dev) > - continue; > + RTE_ETH_FOREACH_DEV_OF(id, dev) { > if (n < port_list_n) > port_list[n] =3D id; > n++; > -- > 2.21.0