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 7447BA00B9 for ; Mon, 1 Apr 2019 04:27:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 035714CA7; Mon, 1 Apr 2019 04:27:32 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 60F2F4CA6 for ; Mon, 1 Apr 2019 04:27:30 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0E406213F5; Sun, 31 Mar 2019 22:27:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 31 Mar 2019 22:27:30 -0400 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=l0n5g/zY+n 1aubvkHJDpdGI5vGF3nEdx2HsIje8GO6o=; b=LoWNIbjvvEkjfepZPHmXiB7KN/ EZ09bnJxeJykrbTsX1fiJb4PZefEGua8N7ECuqzMLUTy4NYJUTcR0Buxulg+ex7h FIntkL8TpLeGaJjMysDEMc636sVl+Z/uK+dtzDou4LeUbjMySxDXWbgAsaCMj7SJ LxT+0Q9SS+7pKLMPM= 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=l0n5g/zY+n1aubvkHJDpdGI5vGF3nEdx2HsIje8GO6o=; b=s5UY2WXb DrnzL8rbejTrVpNOvcVmEDtWycfs+t271vyFomsJ5+Q0NK5k/yAVyxEP9KwRCep0 gJJ/gpbbB2JCZTmPa/gE4dzndh6rgGxNg6ZbL66bQ3Be2GIXW81q6m7oIQtr3T/S vHJQgvlcvlEsi3BqCBX+sxbdpck9OqNZpnD21E1y2PqFwS9yI74fJdwAYDQFgfgG EDT9PZ8Xx49sG2zv2ynWq/T0VHvqkZ9pb4r1xjNyGVgaqqk84ptdj6ekoNFqMq6a mgEzUG765T0ap3efKZR55BTnBu9qlPvtmoOaS992Ou4tnKIka7cfvlRuSIP1i4Jd XAHeU3Jy5gEjXA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrleefgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhho mhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgepvd 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 0D8BA10392; Sun, 31 Mar 2019 22:27:28 -0400 (EDT) From: Thomas Monjalon To: gaetan.rivet@6wind.com, Shahaf Shuler , Yongseok Koh Cc: dev@dpdk.org Date: Mon, 1 Apr 2019 04:26:59 +0200 Message-Id: <20190401022700.1570-4-thomas@monjalon.net> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401022700.1570-1-thomas@monjalon.net> References: <20181130002716.27325-1-thomas@monjalon.net> <20190401022700.1570-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190401022659.3oL77cxsYsiHLYxspHjyDllCPeTXDJ37529GcZiRJho@z> 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 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 != 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 mlx5_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; } @@ -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 = 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 = + 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 mlx5_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 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 = 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.21.0