From: Matan Azrad Date: Mon, 22 Jan 2018 16:38:22 +0000 (+0000) Subject: net/failsafe: use ownership mechanism for slaves X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dcd0c9c32b8d;p=dpdk.git 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 Acked-by: Gaetan Rivet --- diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 921e6569e3..02e6035667 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -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; diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index 33a5adfc88..3994661974 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -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; diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 5d328ffc74..e23512c705 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -43,6 +43,7 @@ #include #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.