From patchwork Wed Feb 20 22:10:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 50398 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 09EE1288C; Wed, 20 Feb 2019 23:11:15 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id C701B1E34 for ; Wed, 20 Feb 2019 23:11:11 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id AC7DB2FF0; Wed, 20 Feb 2019 17:11:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Feb 2019 17:11:11 -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=g4CkDtIqkM BWsModce2uVuQLyE8IL25kpw0P6odjEsc=; b=C8hx4ItGxwuOHqPKbq4iqBh3lC FfwFoTZNa6Rq0ABQzCv9Hum0a3vIwWdKfoIh371fgbM+NpQ5jn+D9lvWXdD7rIB4 +0RInbARWNqUADemhCYLOlapsXqaiHTszOKZbJt6beY+OxVb4Xf5l1qrhs9ImunT EgKtu4uVUoPmvHeds= 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=g4CkDtIqkMBWsModce2uVuQLyE8IL25kpw0P6odjEsc=; b=r7BNwhYL I29C0NCfxe7qZYtakI8bvOpxBlsgvoefNeKCRCRi8odPTIuixZiaqc9/EofFLDJ6 X9kK22Bwws8L/ljTLG5kQWeqqg/h0V17NSelj1suo/uJlsQp2Ovw9W1vbheMCQp/ 5Grga+3Bl/mY4/gSTXl6dJplryWhcpCxwsRue6tM3YHHtJQJpFoI837cCfAfdjQs FlfTw5PvLTW5jD5PxDF4MUQP91+5xm38Df+N4zZbVTkK/4AoWedDicigacOkmwWG RQr7sk/yE0Ihw55FxXyxI2Sv61G2XVZEh2e/vUGj9gQQYLzSpqx2z7Oh4xC9p88h emz09kcrvs2hyg== 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 1133A10319; Wed, 20 Feb 2019 17:11:08 -0500 (EST) From: Thomas Monjalon To: Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org Date: Wed, 20 Feb 2019 23:10:48 +0100 Message-Id: <20190220221051.7928-2-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 Subject: [dpdk-dev] [PATCH v2 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 --- 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 0d192a24b2..b3b2fb1dba 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -331,8 +331,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) @@ -558,8 +557,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 Wed Feb 20 22:10:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 50399 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 44BF52B87; Wed, 20 Feb 2019 23:11:16 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 52BC71E34 for ; Wed, 20 Feb 2019 23:11:12 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5E93831F0; Wed, 20 Feb 2019 17:11:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Feb 2019 17:11:11 -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=LQVWCBTkxF aKkcRlAWa/VqUPT5+gNtjDOgJHAmnCeC0=; b=EkqFoMAKAOWz/+hnb+sVRMax+t 2nFfQ5yD0QGQjfjmxdm87GfwEZBA9Qw0AD66Cfq4mNv7gYtc36AUAu5K3HAxwxJd wofye7vzGpTONlTgK6uIZGHMGoh37XWR5u3/iwv5K6C/xsZu6nsXAKABreBT/iY3 UuvJGtFkWRbA4Dn+U= 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=LQVWCBTkxFaKkcRlAWa/VqUPT5+gNtjDOgJHAmnCeC0=; b=BAkmQSIw xpKRJibtiJgWx7AE8gEJo7JBT3sI4S2RZkrqc1hjVZPmGCsh6BJ/Xp6Nie/wzs9r iwWr8Vgnf/uCeN6CIC0B4TzililC9q0Vee0a8BID58b8Nb2McZVlTJIrqbIxh8l3 i9PNnpvEsK/wrf4aontfWIIrMm25iZ3pxheYPFvRMI9kMrQc72N/ks3RfW3YFbDW VYI/Mp5Cfomfn1R0dAnLQ49ed0dCQoNDUsLpMQvpjNLOSLl8qnVYDBON40kvdHf3 Qw9UmNs8Ub1xnvUGDCpqqCkU+CITfrhYvXxs5bdV7fsOqc/BcJvF3XAPJSOfk/sv GvG3IWk0IKhnnQ== 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 E117E10336; Wed, 20 Feb 2019 17:11:09 -0500 (EST) From: Thomas Monjalon To: Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org Date: Wed, 20 Feb 2019 23:10:49 +0100 Message-Id: <20190220221051.7928-3-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 Subject: [dpdk-dev] [PATCH v2 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 --- lib/librte_ethdev/rte_ethdev.c | 20 +++++++++++ lib/librte_ethdev/rte_ethdev.h | 46 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 3 files changed, 68 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b3b2fb1dba..42154787f8 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -340,6 +340,26 @@ 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) +{ + while (port_id < RTE_MAX_ETHPORTS && + rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED && + rte_eth_devices[port_id].device != parent) + port_id++; + + if (port_id >= RTE_MAX_ETHPORTS) + return RTE_MAX_ETHPORTS; + + return port_id; +} + +uint16_t __rte_experimental +rte_eth_find_next_sibling(uint16_t port_id, uint16_t ref) +{ + return rte_eth_find_next_of(port_id, rte_eth_devices[ref].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 a3c864a134..a7c5c36277 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1383,6 +1383,52 @@ 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) +/** + * 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, 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 sharing the same rte_device + * as the specified port. + * Note: the specified port is part of the loop iterations. + */ +#define RTE_ETH_FOREACH_DEV_OF(p, parent) \ + for (p = rte_eth_find_next_of(0, parent); \ + p < RTE_MAX_ETHPORTS; \ + p = rte_eth_find_next_of(p + 1, parent)) + +/** + * 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 + * The id of a reference port to compare rte_device with. + * @return + * Next sibling port id (or ref 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); + +/** + * Macro to iterate over all ethdev ports sharing the same rte_device + * as the specified port. + * Note: the specified port is part of the loop iterations. + */ +#define RTE_ETH_FOREACH_DEV_SIBLING(p, ref) \ + for (p = rte_eth_find_next_sibling(0, ref); \ + p < RTE_MAX_ETHPORTS; \ + p = rte_eth_find_next_sibling(p + 1, ref)) /** * @warning diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 92ac3de250..b37a4167d7 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 Wed Feb 20 22:10:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 50400 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 8F32E2BA7; Wed, 20 Feb 2019 23:11:17 +0100 (CET) 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 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: , 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 --- 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++; From patchwork Wed Feb 20 22:10:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 50401 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 AEED02BBE; Wed, 20 Feb 2019 23:11:18 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 6AC8025B3 for ; Wed, 20 Feb 2019 23:11:14 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 458CA2FF0; Wed, 20 Feb 2019 17:11:13 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Feb 2019 17:11:13 -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=JRyOe0bfOC eXZg3DM+J45rO9x1FpXWLRUhhCiMy/UVM=; b=QTQ9/pfOJRoiUVnmuD/Zvz1kJl nQQ8w8jteJVTJho/1Xc72j6nxaCo6i6vpiQovWrE/sbmazqB6lF1JVM05MxPCFtj 3GIrFMosilUPNcr4dB7KfFYHru30yAWoFGpTt5HxIUsTv+cViZGxjHG2bEjOp9Fi NqUwgPQYP2MnInuNk= 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=JRyOe0bfOCeXZg3DM+J45rO9x1FpXWLRUhhCiMy/UVM=; b=5KETk9oN msQMx1ECG/vMKXroNwZtadna9304t5w1FUWa83+WQ8aat8m933vDN3GrQBsMAzZ+ kGFrKUKlhU2/ZqhkRG82DmzGvb4kGwO/caFMRJy/LJQqFe9tV46AL98q31ZCQH0L vy8ffw00tA5xhnwGw2VA4N5MBoXAElUVG0QK0k0ea+o9UhyMI5g5v7VLHu0+uHhi livou03i8Vvs/clzJZyomGmhf3sD6uoMJ4Hb54i7lfZq0s/yRyt+L+az+TyxMpAa rhRc0mLFFeQUujMEiZDqzUAsKjcCbLQS7ya8fCuRz90QqJ6612CZhnEf7qn+8eGF hJUFbJVn9vEEcQ== 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 F3AA610328; Wed, 20 Feb 2019 17:11:11 -0500 (EST) From: Thomas Monjalon To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: dev@dpdk.org Date: Wed, 20 Feb 2019 23:10:51 +0100 Message-Id: <20190220221051.7928-5-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 Subject: [dpdk-dev] [PATCH v2 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 --- 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 98c1baa8b1..fcc479aa39 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2361,9 +2361,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) {