net/failsafe: use ownership mechanism for slaves

Fail-safe PMD sub devices management is based on ethdev port mechanism.
So, the sub-devices management structures are exposed to other DPDK
entities which may use them in parallel to fail-safe PMD.

Use the new port ownership mechanism to avoid multiple managments of
fail-safe PMD sub-devices.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
This commit is contained in:
Matan Azrad 2018-01-22 16:38:22 +00:00 committed by Thomas Monjalon
parent fac0ae546e
commit dcd0c9c32b
3 changed files with 25 additions and 0 deletions

View File

@ -196,6 +196,13 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
ret = failsafe_args_parse(dev, params);
if (ret)
goto free_subs;
ret = rte_eth_dev_owner_new(&priv->my_owner.id);
if (ret) {
ERROR("Failed to get unique owner identifier");
goto free_args;
}
snprintf(priv->my_owner.name, sizeof(priv->my_owner.name),
FAILSAFE_OWNER_NAME);
ret = failsafe_eal_init(dev);
if (ret)
goto free_args;

View File

@ -106,6 +106,22 @@ fs_bus_init(struct rte_eth_dev *dev)
INFO("Taking control of a probed sub device"
" %d named %s", i, da->name);
}
ret = rte_eth_dev_owner_set(pid, &PRIV(dev)->my_owner);
if (ret) {
INFO("sub_device %d owner set failed (%s),"
" will try again later", i, strerror(ret));
continue;
} else if (strncmp(rte_eth_devices[pid].device->name, da->name,
strlen(da->name)) != 0) {
/*
* The device probably was removed and its port id was
* reallocated before ownership set.
*/
rte_eth_dev_owner_unset(pid, PRIV(dev)->my_owner.id);
INFO("sub_device %d was probably removed before taking"
" ownership, will try again later", i);
continue;
}
ETH(sdev) = &rte_eth_devices[pid];
SUB_ID(sdev) = i;
sdev->fs_dev = dev;

View File

@ -43,6 +43,7 @@
#include <rte_interrupts.h>
#define FAILSAFE_DRIVER_NAME "Fail-safe PMD"
#define FAILSAFE_OWNER_NAME "Fail-safe"
#define PMD_FAILSAFE_MAC_KVARG "mac"
#define PMD_FAILSAFE_HOTPLUG_POLL_KVARG "hotplug_poll"
@ -167,6 +168,7 @@ struct fs_priv {
uint32_t mac_addr_pool[FAILSAFE_MAX_ETHADDR];
/* current capabilities */
struct rte_eth_dev_info infos;
struct rte_eth_dev_owner my_owner; /* Unique owner. */
struct rte_intr_handle intr_handle; /* Port interrupt handle. */
/*
* Fail-safe state machine.