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 <ma...@mellanox.com>
Acked-by: Gaetan Rivet <gaetan.ri...@6wind.com>
---
 drivers/net/failsafe/failsafe.c         | 7 +++++++
 drivers/net/failsafe/failsafe_eal.c     | 6 ++++++
 drivers/net/failsafe/failsafe_private.h | 2 ++
 3 files changed, 15 insertions(+)

diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index b767352..a1e1c7a 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -196,6 +196,13 @@
        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 33a5adf..5f3da06 100644
--- a/drivers/net/failsafe/failsafe_eal.c
+++ b/drivers/net/failsafe/failsafe_eal.c
@@ -106,6 +106,12 @@
                        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;
+               }
                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 4916365..b377046 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -42,6 +42,7 @@
 #include <rte_devargs.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"
@@ -145,6 +146,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. */
        /*
         * Fail-safe state machine.
         * This level will be tracking state of the EAL and eth
-- 
1.8.3.1

Reply via email to