From patchwork Mon Apr 1 02:26:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 51963 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6E26D4C8D; Mon, 1 Apr 2019 04:27:26 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 3DF9737A8 for ; Mon, 1 Apr 2019 04:27:24 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E15D4213D0; Sun, 31 Mar 2019 22:27:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 31 Mar 2019 22:27:23 -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=Y/jXyaPywd jCZAu/XY/EK4nK6mBsGnucbxHRmo+67ME=; b=BYOWvfKUPp3R0K0sMvddurV3qQ J3gUDeQxTwHSedUZU1F8d5Dvu5roV8uj5tjC70tN4hm9G/PPFAyX68FmqMGneNx7 qr511MyTQkISilA1v9Z717oNQcOpvtZnppI+z1a+3N3fwrkY/sean7hpu+W0cTwq 0pkFAylt8pyQNoE98= 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=Y/jXyaPywdjCZAu/XY/EK4nK6mBsGnucbxHRmo+67ME=; b=YspyAwsB b3JIQl84mxhksISFfSiiSFxMeEH2imqZZhSPZqqDq5RnBMdq7p18SZinsaqHoxGa Sq+5UxwAu2Knl/T01mz4QSpF3Ve9l+Ok6auN83dj2+mjWBO/XB3cKBYd6SgT+CuW dg9dLqI61vUFowHzXBnoAvud6UwDOQHMgUSGPV+iTJJ+oHbr4bFamphpmUWONFvT elhdSR3tmQwxh9thEHfmmxxU6j8Py84ycRSCTRLYGt4suhGmcaA5gBkKZ/DEVprb S3GtYsVZfhwZjad5patTS29irJO50OrGqrkj26KbYE2INaoAR9XXfUrQWoPUzYLL UAgAp3QSNQ5vJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrleefgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhho mhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgepud 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 9B4D410392; Sun, 31 Mar 2019 22:27:22 -0400 (EDT) From: Thomas Monjalon To: gaetan.rivet@6wind.com, Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org Date: Mon, 1 Apr 2019 04:26:57 +0200 Message-Id: <20190401022700.1570-2-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 Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: simplify port state comparisons 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" There are three states for an ethdev port. Checking that the port is unused looks simpler than checking it is neither attached nor removed. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Tested-by: Viacheslav Ovsiienko --- lib/librte_ethdev/rte_ethdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 10bdfb37e..33cffc498 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -330,8 +330,7 @@ uint16_t rte_eth_find_next(uint16_t port_id) { while (port_id < RTE_MAX_ETHPORTS && - rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED && - rte_eth_devices[port_id].state != RTE_ETH_DEV_REMOVED) + rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED) port_id++; if (port_id >= RTE_MAX_ETHPORTS) @@ -567,8 +566,7 @@ uint64_t rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id) { while (port_id < RTE_MAX_ETHPORTS && - ((rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED && - rte_eth_devices[port_id].state != RTE_ETH_DEV_REMOVED) || + (rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED || rte_eth_devices[port_id].data->owner.id != owner_id)) port_id++; From patchwork Mon Apr 1 02:26:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 51964 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6A4E04C9D; Mon, 1 Apr 2019 04:27:29 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 47C0C4C91 for ; Mon, 1 Apr 2019 04:27:27 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C8E4221ADA; Sun, 31 Mar 2019 22:27:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 31 Mar 2019 22:27:26 -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=UKuiSD+Ujj c2eeMVXzGHLYl/5C8iShIhuBy6awAD470=; b=rbx20xQlYhN3ULugw0+NG4KQuX YCo8M3bhT4U+1bKhCDfc3bF3c/EDeDNwMYBMe4jgDNyogqnhA/ft2dNs69KkJSyF +z5rEWN57S+j+i3sOY05GJsPBF6pC5P/EM0dQhQtmN+6KlKSlJj/QcIFi5j65XO4 PiOImtORJ0hg572As= 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=UKuiSD+Ujjc2eeMVXzGHLYl/5C8iShIhuBy6awAD470=; b=EQBAyJeK xU12QxtBPT1nacroDKDkk+L3WiVsCMuJ1Q3jU5nYNw+7RconqH4JH0kkja0p9FMX qC1TgZk/Yl8vRDTVkd1URgwrLtOa4yt3t3YsLH6d9X3sEHRv2r+N2wTEcr3BitWm 3Ex8C5vA8VHdkpb4w67ijT2AfdksYg5pVmH1HBjbjOZfdLF75baptJRytNQc+alr tQRBf4v0WNdZkkzZ0Zy6Ret66Tci5M1JftCagq7L3HJrNpcKwfQpyzpjxGFjJlml 5cNijH3y+2rrTTnb5FB7X+aWj3/PWjhAEhl6AZelwINKeIzlR/n1wuxnLtEEErcS a+c5wQAPB8iwVw== 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 DEA4C10392; Sun, 31 Mar 2019 22:27:25 -0400 (EDT) From: Thomas Monjalon To: gaetan.rivet@6wind.com, Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org Date: Mon, 1 Apr 2019 04:26:58 +0200 Message-Id: <20190401022700.1570-3-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 Subject: [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" 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 refers to the parent device. The ownership is not checked because siblings may have different owners. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Tested-by: Viacheslav Ovsiienko --- v2: Reviewed-by: Andrew Rybchenko - not kept because of changes in v3 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(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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; } +uint16_t __rte_experimental +rte_eth_find_next_of(uint16_t port_id, const struct rte_device *parent) +{ + port_id = rte_eth_find_next(port_id); + while (port_id < RTE_MAX_ETHPORTS && + rte_eth_devices[port_id].device != parent) + port_id = 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_ethdev.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) +/** + * @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 = rte_eth_find_next_of(0, parent); \ + port_id < RTE_MAX_ETHPORTS; \ + port_id = 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 = rte_eth_find_next_sibling(0, ref_port_id); \ + port_id < RTE_MAX_ETHPORTS; \ + port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id)) /** * @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; From patchwork Mon Apr 1 02:26:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 51965 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org 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 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" 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 Tested-by: Viacheslav Ovsiienko Acked-by: Yongseok Koh --- 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++; From patchwork Mon Apr 1 02:27:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 51966 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AEFE04CC3; Mon, 1 Apr 2019 04:27:34 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 716844CAF for ; Mon, 1 Apr 2019 04:27:32 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1D7FA21AC2; Sun, 31 Mar 2019 22:27:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 31 Mar 2019 22:27:32 -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=v1l3X7isGG NuEN/UFjRga+merC5xmwF5P55qowPRckk=; b=EMxpnswsmqk1v9Y+W2WP5v17CK MWN0r7FR33wI7dfJHcuU1wfMPg3f/JkEXiBk59Tc1whkHooFIWrzgK1YysqwdHJy UZ9+tq3whLFGOGs/AvH/VeYj879qdq26VnCQ2bGi5HvGAlNnkE242a69025QNYG7 Q3AZG9Nc06a761t7E= 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=v1l3X7isGGNuEN/UFjRga+merC5xmwF5P55qowPRckk=; b=B4LyFRZO pRo7ns7VcXPWYBOo46jJRbK3KtpTriWKmEMKwMhm+KM6v8U4P96/OPVmb3KZJhfT boFDB7wei2mTMNSNy03EEOWU0hYkn709vErexZfINkPR+Mb0Hc2wD4NDERh369jf s7ChAuz0lur2kC8dIDp8fEvoLZfa5b7t/UI7l1Lq+gjcWbvl4NV492IkK4e76zOk zoDFrtHS2KBARYK4F0+xO9N85/pgowtTRx8FcC2HFEdF4YQqAWuFJe9mCxb3VbnJ GU65uGh9kZMyE8MSjUZmyzzoLDeFnS2d/jUHxfYv1cbjnmauJqAaqAGX03bM2hh+ SndN7dU/VUUzmA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrleefgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhho mhgrshesmhhonhhjrghlohhnrdhnvghtnecuvehluhhsthgvrhfuihiivgepge 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 05B3010392; Sun, 31 Mar 2019 22:27:30 -0400 (EDT) From: Thomas Monjalon To: gaetan.rivet@6wind.com, Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: dev@dpdk.org Date: Mon, 1 Apr 2019 04:27:00 +0200 Message-Id: <20190401022700.1570-5-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 Subject: [dpdk-dev] [PATCH v3 4/4] app/testpmd: use port sibling iterator in device cleanup 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" When removing a rte_device on a port-based request, all the sibling ports must be marked as closed. The iterator loop can be simplified by using the dedicated macro. Signed-off-by: Thomas Monjalon Reviewed-by: Ferruh Yigit Tested-by: Viacheslav Ovsiienko --- app/test-pmd/testpmd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 40c873b97..aeaa74c98 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2370,9 +2370,7 @@ detach_port_device(portid_t port_id) return; } - for (sibling = 0; sibling < RTE_MAX_ETHPORTS; sibling++) { - if (rte_eth_devices[sibling].device != dev) - continue; + RTE_ETH_FOREACH_DEV_SIBLING(sibling, port_id) { /* reset mapping between old ports and removed device */ rte_eth_devices[sibling].device = NULL; if (ports[sibling].port_status != RTE_PORT_CLOSED) {