drivers: remove direct access to interrupt handle
[dpdk.git] / drivers / bus / ifpga / ifpga_bus.c
index 5f23ed8..cbc6809 100644 (file)
@@ -24,6 +24,7 @@
 #include <rte_kvargs.h>
 #include <rte_alarm.h>
 #include <rte_string_fns.h>
+#include <rte_debug.h>
 
 #include "rte_rawdev.h"
 #include "rte_rawdev_pmd.h"
@@ -31,8 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
-
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
  */
@@ -73,6 +72,19 @@ ifpga_find_afu_dev(const struct rte_rawdev *rdev,
        return NULL;
 }
 
+struct rte_afu_device *
+rte_ifpga_find_afu_by_name(const char *name)
+{
+       struct rte_afu_device *afu_dev = NULL;
+
+       TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) {
+               if (afu_dev &&
+                       !strcmp(afu_dev->device.name, name))
+                       return afu_dev;
+       }
+       return NULL;
+}
+
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
        IFPGA_ARG_NAME,
@@ -125,15 +137,13 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
                                     IFPGA_AFU_BTS);
                        goto end;
                }
+               afu_pr_conf.pr_enable = 1;
        } else {
-               IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
-                         IFPGA_AFU_BTS);
-               goto end;
+               afu_pr_conf.pr_enable = 0;
        }
 
        afu_pr_conf.afu_id.uuid.uuid_low = 0;
        afu_pr_conf.afu_id.uuid.uuid_high = 0;
-       afu_pr_conf.pr_enable = path?1:0;
 
        if (ifpga_find_afu_dev(rawdev, &afu_pr_conf.afu_id))
                goto end;
@@ -151,8 +161,16 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
        afu_dev->id.uuid.uuid_high = 0;
        afu_dev->id.port      = afu_pr_conf.afu_id.port;
 
+       /* Allocate interrupt instance */
+       afu_dev->intr_handle =
+               rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
+       if (afu_dev->intr_handle == NULL) {
+               IFPGA_BUS_ERR("Failed to allocate intr handle");
+               goto end;
+       }
+
        if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get)
-               rawdev->dev_ops->dev_info_get(rawdev, afu_dev);
+               rawdev->dev_ops->dev_info_get(rawdev, afu_dev, sizeof(*afu_dev));
 
        if (rawdev->dev_ops &&
                rawdev->dev_ops->dev_start &&
@@ -179,8 +197,10 @@ end:
                rte_kvargs_free(kvlist);
        if (path)
                free(path);
-       if (afu_dev)
+       if (afu_dev) {
+               rte_intr_instance_free(afu_dev->intr_handle);
                free(afu_dev);
+       }
 
        return NULL;
 }
@@ -308,12 +328,19 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
        }
 
        TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
-               if (ifpga_probe_one_driver(drv, afu_dev)) {
-                       ret = -1;
-                       break;
-               }
+               ret = ifpga_probe_one_driver(drv, afu_dev);
+               if (ret < 0)
+                       /* negative value is an error */
+                       return ret;
+               if (ret > 0)
+                       /* positive value means driver doesn't support it */
+                       continue;
+               return 0;
        }
-       return ret;
+       if ((ret > 0) && (afu_dev->driver == NULL))
+               return 0;
+       else
+               return ret;
 }
 
 /*
@@ -379,6 +406,7 @@ ifpga_unplug(struct rte_device *dev)
        TAILQ_REMOVE(&ifpga_afu_dev_list, afu_dev, next);
 
        rte_devargs_remove(dev->devargs);
+       rte_intr_instance_free(afu_dev->intr_handle);
        free(afu_dev);
        return 0;
 
@@ -455,10 +483,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-       ifpga_bus_logtype = rte_log_register("bus.ifpga");
-       if (ifpga_bus_logtype >= 0)
-               rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER_DEFAULT(ifpga_bus_logtype, NOTICE);