X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fbus%2Fifpga%2Fifpga_bus.c;h=dfd6b1fba9ce00cb8af25125bd335066f22e3dbc;hb=c66049221e2289e465d7be29d7d983d414d9a81f;hp=80663328aacca48d41e8494af0f825ec5aea61ed;hpb=6844d146ff397d82526a8a39b550443937f7ac12;p=dpdk.git diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index 80663328aa..dfd6b1fba9 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -73,6 +73,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 +138,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; @@ -280,14 +291,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv, /* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver; /* call the driver probe() function */ ret = drv->probe(afu_dev); - if (ret) { + if (ret) afu_dev->driver = NULL; - afu_dev->device.driver = NULL; - } + else + afu_dev->device.driver = &drv->driver; return ret; } @@ -302,16 +312,26 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) return -1; /* Check if a driver is already loaded */ - if (afu_dev->driver != NULL) - return 0; + if (rte_dev_is_probed(&afu_dev->device)) { + IFPGA_BUS_DEBUG("Device %s is already probed\n", + rte_ifpga_device_name(afu_dev)); + return -EEXIST; + } 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; } /* @@ -326,14 +346,13 @@ ifpga_probe(void) int ret = 0; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (afu_dev->device.driver) - continue; - ret = ifpga_probe_all_drivers(afu_dev); + if (ret == -EEXIST) + continue; if (ret < 0) IFPGA_BUS_ERR("failed to initialize %s device\n", rte_ifpga_device_name(afu_dev)); - } + } return ret; }