net/bnxt: fail init when mbuf allocation fails
[dpdk.git] / drivers / net / failsafe / failsafe.c
index e3bda0d..3c754a5 100644 (file)
 
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
-       .link_speed = ETH_SPEED_NUM_10G,
-       .link_duplex = ETH_LINK_FULL_DUPLEX,
-       .link_status = ETH_LINK_UP,
-       .link_autoneg = ETH_LINK_AUTONEG,
+       .link_speed = RTE_ETH_SPEED_NUM_10G,
+       .link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+       .link_status = RTE_ETH_LINK_UP,
+       .link_autoneg = RTE_ETH_LINK_AUTONEG,
 };
 
 static int
@@ -260,17 +260,27 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
                if (i == priv->subs_tail)
                        rte_eth_random_addr(&mac->addr_bytes[0]);
        }
-       INFO("MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
-               mac->addr_bytes[0], mac->addr_bytes[1],
-               mac->addr_bytes[2], mac->addr_bytes[3],
-               mac->addr_bytes[4], mac->addr_bytes[5]);
+       INFO("MAC address is " RTE_ETHER_ADDR_PRT_FMT,
+               RTE_ETHER_ADDR_BYTES(mac));
        dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC |
                                RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
-       PRIV(dev)->intr_handle = (struct rte_intr_handle){
-               .fd = -1,
-               .type = RTE_INTR_HANDLE_EXT,
-       };
+
+       /* Allocate interrupt instance */
+       PRIV(dev)->intr_handle =
+               rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_SHARED);
+       if (PRIV(dev)->intr_handle == NULL) {
+               ERROR("Failed to allocate intr handle");
+               goto cancel_alarm;
+       }
+
+       if (rte_intr_fd_set(PRIV(dev)->intr_handle, -1))
+               goto cancel_alarm;
+
+       if (rte_intr_type_set(PRIV(dev)->intr_handle, RTE_INTR_HANDLE_EXT))
+               goto cancel_alarm;
+
        rte_eth_dev_probing_finish(dev);
+
        return 0;
 cancel_alarm:
        failsafe_hotplug_alarm_cancel(dev);
@@ -299,6 +309,7 @@ fs_rte_eth_free(const char *name)
                return 0; /* port already released */
        ret = failsafe_eth_dev_close(dev);
        rte_eth_dev_release_port(dev);
+       rte_intr_instance_free(PRIV(dev)->intr_handle);
        return ret;
 }
 
@@ -329,8 +340,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
        INFO("Initializing " FAILSAFE_DRIVER_NAME " for %s",
                        name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(rte_vdev_device_args(vdev)) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        ERROR("Failed to probe %s", name);
@@ -391,4 +401,4 @@ 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_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
+RTE_LOG_REGISTER_DEFAULT(failsafe_logtype, NOTICE)