From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 1A3441E34 for ; Wed, 20 Feb 2019 23:11:13 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0F0BF2321F; Wed, 20 Feb 2019 17:11:12 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Feb 2019 17:11:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=LNhuHS6pjy 5zm/5BUM+XLRuE5NJaWznkhgdfQ6ZlqR4=; b=d79nFMhf6z4iep4Gka4JVg2qbi 1eHlzzX82BemZutvjueGXVyg89sTJbfFD/0dDhFAAceG1nj+LAwv80W+ZlkFyiVb UcfJfqS6Jzn4TLNnQ+f1p7GNHAw8LczMfnHemaD9aE9mWoml4U1Zt64NhhjdfYkF 4QE4unG96qpKCANbQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=LNhuHS6pjy5zm/5BUM+XLRuE5NJaWznkhgdfQ6ZlqR4=; b=wI2K8szN t82WFQH0ODJaZJvMjOt9guuw43bZoX8JYoPjbbV9GkewKqjJMKWRCVWSgpwn+6I3 N+uTOE+twkkske52b07uOAyreFy+0q3pKwc/4d7SVafsEx94pJ9PFVK3dCjB9zl+ HEP+58u1KZ3J0unhBCcGC1+i+y1Ip5pnfe8KE7KYPZ5RcoOTYx1oWb4h3o1RESx7 JDoJudTsSHjcUu0oSt7MdTjGPhrdontzDhvrFkBXHQPEeuebf266wVTSgkfdiEAv wpW0SibiNoAvnxjgbwzeMRbQD2ShQrz2YLKivfBiriBjztaIzADzfq2qyshudo5k 6T/8H2uEpnAUtA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrtdeigdduheekucdltddurdegtdelrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhht necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc fkphepjeejrddufeegrddvtdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpeht hhhomhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 0B18E10310; Wed, 20 Feb 2019 17:11:10 -0500 (EST) From: Thomas Monjalon To: Shahaf Shuler , Yongseok Koh Cc: dev@dpdk.org Date: Wed, 20 Feb 2019 23:10:50 +0100 Message-Id: <20190220221051.7928-4-thomas@monjalon.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220221051.7928-1-thomas@monjalon.net> References: <20181130002716.27325-1-thomas@monjalon.net> <20190220221051.7928-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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: , X-List-Received-Date: Wed, 20 Feb 2019 22:11:13 -0000 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. Signed-off-by: Thomas Monjalon --- drivers/net/mlx5/mlx5.c | 34 +++++++++++++--------------------- drivers/net/mlx5/mlx5_ethdev.c | 6 +----- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index a913a5955f..6ed1ea0d5b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -330,17 +330,15 @@ mlx5_dev_close(struct rte_eth_dev *dev) dev->data->port_id); if (priv->domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) { unsigned int c = 0; - unsigned int i = mlx5_dev_to_port_id(dev->device, NULL, 0); - uint16_t port_id[i]; + uint16_t port_id; - i = 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 priv *opriv = - rte_eth_devices[port_id[i]].data->dev_private; + rte_eth_devices[port_id].data->dev_private; if (!opriv || opriv->domain_id != priv->domain_id || - &rte_eth_devices[port_id[i]] == dev) + &rte_eth_devices[port_id] == dev) continue; ++c; } @@ -1001,22 +999,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 = 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 priv *opriv = + rte_eth_devices[port_id].data->dev_private; - i = RTE_MIN(mlx5_dev_to_port_id(dpdk_dev, port_id, i), i); - while (i--) { - const struct priv *opriv = - rte_eth_devices[port_id[i]].data->dev_private; - - if (!opriv || - opriv->domain_id == - RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) - continue; - priv->domain_id = opriv->domain_id; - break; - } + if (!opriv || + opriv->domain_id == + RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) + continue; + priv->domain_id = opriv->domain_id; + break; } if (priv->domain_id == RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) { err = 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 d178ed6a18..039582a321 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1300,11 +1300,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list, uint16_t id; unsigned int n = 0; - RTE_ETH_FOREACH_DEV(id) { - struct rte_eth_dev *ldev = &rte_eth_devices[id]; - - if (ldev->device != dev) - continue; + RTE_ETH_FOREACH_DEV_OF(id, dev) { if (n < port_list_n) port_list[n] = id; n++; -- 2.20.1