probe device at local process. */
| 166 | |
| 167 | /* probe device at local process. */ |
| 168 | int |
| 169 | local_dev_probe(const char *devargs, struct rte_device **new_dev) |
| 170 | { |
| 171 | struct rte_device *dev; |
| 172 | struct rte_devargs *da; |
| 173 | int ret; |
| 174 | |
| 175 | *new_dev = NULL; |
| 176 | da = calloc(1, sizeof(*da)); |
| 177 | if (da == NULL) |
| 178 | return -ENOMEM; |
| 179 | |
| 180 | ret = rte_devargs_parse(da, devargs); |
| 181 | if (ret) |
| 182 | goto err_devarg; |
| 183 | |
| 184 | if (da->bus->plug == NULL) { |
| 185 | RTE_LOG(ERR, EAL, "Function plug not supported by bus (%s)\n", |
| 186 | da->bus->name); |
| 187 | ret = -ENOTSUP; |
| 188 | goto err_devarg; |
| 189 | } |
| 190 | |
| 191 | ret = rte_devargs_insert(&da); |
| 192 | if (ret) |
| 193 | goto err_devarg; |
| 194 | |
| 195 | /* the rte_devargs will be referenced in the matching rte_device */ |
| 196 | ret = da->bus->scan(); |
| 197 | if (ret) |
| 198 | goto err_devarg; |
| 199 | |
| 200 | dev = da->bus->find_device(NULL, cmp_dev_name, da->name); |
| 201 | if (dev == NULL) { |
| 202 | RTE_LOG(ERR, EAL, "Cannot find device (%s)\n", |
| 203 | da->name); |
| 204 | ret = -ENODEV; |
| 205 | goto err_devarg; |
| 206 | } |
| 207 | /* Since there is a matching device, it is now its responsibility |
| 208 | * to manage the devargs we've just inserted. From this point |
| 209 | * those devargs shouldn't be removed manually anymore. |
| 210 | */ |
| 211 | |
| 212 | ret = dev->bus->plug(dev); |
| 213 | if (ret > 0) |
| 214 | ret = -ENOTSUP; |
| 215 | |
| 216 | if (ret && !rte_dev_is_probed(dev)) { /* if hasn't ever succeeded */ |
| 217 | RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", |
| 218 | dev->name); |
| 219 | return ret; |
| 220 | } |
| 221 | |
| 222 | *new_dev = dev; |
| 223 | return ret; |
| 224 | |
| 225 | err_devarg: |
no test coverage detected