From: Ophir Munk <ophirmu@mellanox.com>
To: dev@dpdk.org, Yongseok Koh <yskoh@mellanox.com>
Cc: Asaf Penso <asafp@mellanox.com>,
Shahaf Shuler <shahafs@mellanox.com>,
Thomas Monjalon <thomas@monjalon.net>,
Olga Shern <olgas@mellanox.com>,
Ophir Munk <ophirmu@mellanox.com>
Subject: [dpdk-dev] [PATCH v3] net/mlx5: allow multiple probing for representor
Date: Fri, 19 Oct 2018 08:12:50 +0000 [thread overview]
Message-ID: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> (raw)
In-Reply-To: <1538737591-24022-1-git-send-email-ophirmu@mellanox.com>
Implement probing of a rte device multiple times, see [1].
Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag to enable multiple probing
of the PCI device by the PCI common driver.
Consecutive probing requests with a devargs string may contain
repetitive master and representors devices for which eth device should
be created only once. In case an eth device already exists - silently
ignore it.
[1]
https://patches.dpdk.org/patch/45601/
("eal: allow probing a device again")
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
v1:
Initial release
v2:
Rebase + code review updates
https://patches.dpdk.org/patch/45927/
v3:
- Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag required by PCI common driver
- Update commit message
drivers/net/mlx5/mlx5.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 2821aec..c08323c 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -696,9 +696,10 @@
*
* @return
* A valid Ethernet device object on success, NULL otherwise and rte_errno
- * is set. The following error is defined:
+ * is set. The following errors are defined:
*
* EBUSY: device is not supposed to be spawned.
+ * EEXIST: device is already spawned
*/
static struct rte_eth_dev *
mlx5_dev_spawn(struct rte_device *dpdk_dev,
@@ -747,6 +748,7 @@
struct ether_addr mac;
char name[RTE_ETH_NAME_MAX_LEN];
int own_domain_id = 0;
+ uint16_t port_id;
unsigned int i;
/* Determine if this port representor is supposed to be spawned. */
@@ -769,6 +771,17 @@
return NULL;
}
}
+ /* Build device name. */
+ if (!switch_info->representor)
+ rte_strlcpy(name, dpdk_dev->name, sizeof(name));
+ else
+ snprintf(name, sizeof(name), "%s_representor_%u",
+ dpdk_dev->name, switch_info->port_name);
+ /* check if the device is already spawned */
+ if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) {
+ rte_errno = EEXIST;
+ return NULL;
+ }
/* Prepare shared data between primary and secondary process. */
mlx5_prepare_shared_data();
errno = 0;
@@ -875,11 +888,6 @@
DEBUG("ibv_query_device_ex() failed");
goto error;
}
- if (!switch_info->representor)
- rte_strlcpy(name, dpdk_dev->name, sizeof(name));
- else
- snprintf(name, sizeof(name), "%s_representor_%u",
- dpdk_dev->name, switch_info->port_name);
DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
eth_dev = rte_eth_dev_attach_secondary(name);
@@ -1423,9 +1431,9 @@ struct mlx5_dev_spawn_data {
list[i].eth_dev = mlx5_dev_spawn
(&pci_dev->device, list[i].ibv_dev, vf, &list[i].info);
if (!list[i].eth_dev) {
- if (rte_errno != EBUSY)
+ if (rte_errno != EBUSY && rte_errno != EEXIST)
break;
- /* Device is disabled, ignore it. */
+ /* Device is disabled or already spawned. Ignore it. */
continue;
}
restore = list[i].eth_dev->data->dev_flags;
@@ -1520,7 +1528,8 @@ struct mlx5_dev_spawn_data {
},
.id_table = mlx5_pci_id_map,
.probe = mlx5_pci_probe,
- .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV,
+ .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV |
+ RTE_PCI_DRV_PROBE_AGAIN,
};
#ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS
--
1.8.3.1
next prev parent reply other threads:[~2018-10-19 8:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-03 8:01 [dpdk-dev] [PATCH] net/mlx5: allow multi probing Ophir Munk
2018-10-05 1:41 ` Yongseok Koh
2018-10-05 11:20 ` Ophir Munk
2018-10-05 11:06 ` [dpdk-dev] [PATCH v2] net/mlx5: allow multiple probing for representor Ophir Munk
2018-10-05 18:06 ` Yongseok Koh
2018-10-09 22:23 ` Ophir Munk
2018-10-19 8:12 ` Ophir Munk [this message]
2018-10-23 18:26 ` [dpdk-dev] [PATCH v4 1/3] " Ophir Munk
2018-10-23 18:26 ` [dpdk-dev] [PATCH v4 2/3] net/mlx5: release port on close Ophir Munk
2018-10-23 18:26 ` [dpdk-dev] [PATCH v4 3/3] net/mlx5: close all ports on remove Ophir Munk
2018-10-24 13:19 ` [dpdk-dev] [PATCH v4 1/3] net/mlx5: allow multiple probing for representor Shahaf Shuler
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=1539936770-24252-1-git-send-email-ophirmu@mellanox.com \
--to=ophirmu@mellanox.com \
--cc=asafp@mellanox.com \
--cc=dev@dpdk.org \
--cc=olgas@mellanox.com \
--cc=shahafs@mellanox.com \
--cc=thomas@monjalon.net \
--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).