ethdev: add probing finish function
[dpdk.git] / drivers / net / failsafe / failsafe.c
index fa279cb..b35471d 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "failsafe_private.h"
 
+int failsafe_logtype;
+
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
        .link_speed = ETH_SPEED_NUM_10G,
@@ -224,7 +226,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
                                                               mac);
                        if (ret) {
                                ERROR("Failed to set default MAC address");
-                               goto free_args;
+                               goto cancel_alarm;
                        }
                }
        } else {
@@ -257,7 +259,10 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
                .fd = -1,
                .type = RTE_INTR_HANDLE_EXT,
        };
+       rte_eth_dev_probing_finish(dev);
        return 0;
+cancel_alarm:
+       failsafe_hotplug_alarm_cancel(dev);
 free_args:
        failsafe_args_free(dev);
 free_subs:
@@ -294,10 +299,25 @@ static int
 rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
 {
        const char *name;
+       struct rte_eth_dev *eth_dev;
 
        name = rte_vdev_device_name(vdev);
        INFO("Initializing " FAILSAFE_DRIVER_NAME " for %s",
                        name);
+
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(rte_vdev_device_args(vdev)) == 0) {
+               eth_dev = rte_eth_dev_attach_secondary(name);
+               if (!eth_dev) {
+                       ERROR("Failed to probe %s", name);
+                       return -1;
+               }
+               /* TODO: request info from primary to set up Rx and Tx */
+               eth_dev->dev_ops = &failsafe_ops;
+               rte_eth_dev_probing_finish(eth_dev);
+               return 0;
+       }
+
        return fs_eth_dev_create(vdev);
 }
 
@@ -318,3 +338,12 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
+
+RTE_INIT(failsafe_init_log);
+static void
+failsafe_init_log(void)
+{
+       failsafe_logtype = rte_log_register("pmd.net.failsafe");
+       if (failsafe_logtype >= 0)
+               rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
+}