From: Thomas Monjalon <thomas@monjalon.net>
To: gaetan.rivet@6wind.com, Shahaf Shuler <shahafs@mellanox.com>,
Yongseok Koh <yskoh@mellanox.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 3/4] net/mlx5: use port sibling iterators
Date: Mon, 1 Apr 2019 04:26:59 +0200 [thread overview]
Message-ID: <20190401022700.1570-4-thomas@monjalon.net> (raw)
Message-ID: <20190401022659.3oL77cxsYsiHLYxspHjyDllCPeTXDJ37529GcZiRJho@z> (raw)
In-Reply-To: <20190401022700.1570-1-thomas@monjalon.net>
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 <thomas@monjalon.net>
---
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
next prev parent reply other threads:[~2019-04-01 2:27 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 0:27 [dpdk-dev] [PATCH] ethdev: add siblings iterator Thomas Monjalon
2018-12-11 16:31 ` Ferruh Yigit
2018-12-11 18:19 ` Thomas Monjalon
2019-02-20 22:10 ` [dpdk-dev] [PATCH v2 0/4] ethdev iterators for multi-ports device Thomas Monjalon
2019-02-20 22:10 ` [dpdk-dev] [PATCH v2 1/4] ethdev: simplify port state comparisons Thomas Monjalon
2019-02-24 17:18 ` Andrew Rybchenko
2019-02-20 22:10 ` [dpdk-dev] [PATCH v2 2/4] ethdev: add siblings iterators Thomas Monjalon
2019-02-24 17:22 ` Andrew Rybchenko
2019-02-27 10:07 ` Gaëtan Rivet
2019-02-27 10:51 ` Thomas Monjalon
2019-04-01 1:59 ` Thomas Monjalon
2019-04-01 1:59 ` Thomas Monjalon
2019-03-19 15:47 ` Ferruh Yigit
2019-03-19 15:47 ` Ferruh Yigit
2019-03-19 17:34 ` Thomas Monjalon
2019-03-19 17:34 ` Thomas Monjalon
2019-03-19 18:04 ` Ferruh Yigit
2019-03-19 18:04 ` Ferruh Yigit
2019-04-01 2:16 ` Thomas Monjalon
2019-04-01 2:16 ` Thomas Monjalon
2019-04-01 6:46 ` David Marchand
2019-04-01 6:46 ` David Marchand
2019-04-01 8:09 ` Thomas Monjalon
2019-04-01 8:09 ` Thomas Monjalon
2019-04-02 23:35 ` Ferruh Yigit
2019-04-02 23:35 ` Ferruh Yigit
2019-04-02 23:37 ` Thomas Monjalon
2019-04-02 23:37 ` Thomas Monjalon
2019-02-20 22:10 ` [dpdk-dev] [PATCH v2 3/4] net/mlx5: use port sibling iterators Thomas Monjalon
2019-02-20 22:10 ` [dpdk-dev] [PATCH v2 4/4] app/testpmd: use port sibling iterator in device cleanup Thomas Monjalon
2019-04-01 2:26 ` [dpdk-dev] [PATCH v3 0/4] ethdev iterators for multi-ports device Thomas Monjalon
2019-04-01 2:26 ` Thomas Monjalon
2019-04-01 2:26 ` [dpdk-dev] [PATCH v3 1/4] ethdev: simplify port state comparisons Thomas Monjalon
2019-04-01 2:26 ` Thomas Monjalon
2019-04-01 14:58 ` Stephen Hemminger
2019-04-01 14:58 ` Stephen Hemminger
2019-04-01 15:17 ` Thomas Monjalon
2019-04-01 15:17 ` Thomas Monjalon
2019-04-01 16:07 ` Stephen Hemminger
2019-04-01 16:07 ` Stephen Hemminger
2019-04-03 15:03 ` Slava Ovsiienko
2019-04-03 15:03 ` Slava Ovsiienko
2019-04-01 2:26 ` [dpdk-dev] [PATCH v3 2/4] ethdev: add siblings iterators Thomas Monjalon
2019-04-01 2:26 ` Thomas Monjalon
2019-04-01 7:23 ` Andrew Rybchenko
2019-04-01 7:23 ` Andrew Rybchenko
2019-04-02 23:42 ` Ferruh Yigit
2019-04-02 23:42 ` Ferruh Yigit
2019-04-02 23:48 ` Thomas Monjalon
2019-04-02 23:48 ` Thomas Monjalon
2019-04-03 15:03 ` Slava Ovsiienko
2019-04-03 15:03 ` Slava Ovsiienko
2019-04-01 2:26 ` Thomas Monjalon [this message]
2019-04-01 2:26 ` [dpdk-dev] [PATCH v3 3/4] net/mlx5: use port sibling iterators Thomas Monjalon
2019-04-03 14:19 ` Ferruh Yigit
2019-04-03 14:19 ` Ferruh Yigit
2019-04-03 18:07 ` Yongseok Koh
2019-04-03 18:07 ` Yongseok Koh
2019-04-04 11:33 ` Ferruh Yigit
2019-04-04 11:33 ` Ferruh Yigit
2019-04-03 15:04 ` Slava Ovsiienko
2019-04-03 15:04 ` Slava Ovsiienko
2019-04-01 2:27 ` [dpdk-dev] [PATCH v3 4/4] app/testpmd: use port sibling iterator in device cleanup Thomas Monjalon
2019-04-01 2:27 ` Thomas Monjalon
2019-04-02 23:43 ` Ferruh Yigit
2019-04-02 23:43 ` Ferruh Yigit
2019-04-03 15:04 ` Slava Ovsiienko
2019-04-03 15:04 ` Slava Ovsiienko
2019-04-03 16:42 ` [dpdk-dev] [PATCH v3 0/4] ethdev iterators for multi-ports device Ferruh Yigit
2019-04-03 16:42 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190401022700.1570-4-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=dev@dpdk.org \
--cc=gaetan.rivet@6wind.com \
--cc=shahafs@mellanox.com \
--cc=yskoh@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).