| 279 | } |
| 280 | |
| 281 | int |
| 282 | rte_eth_dev_create(struct rte_device *device, const char *name, |
| 283 | size_t priv_data_size, |
| 284 | ethdev_bus_specific_init ethdev_bus_specific_init, |
| 285 | void *bus_init_params, |
| 286 | ethdev_init_t ethdev_init, void *init_params) |
| 287 | { |
| 288 | struct rte_eth_dev *ethdev; |
| 289 | int retval; |
| 290 | |
| 291 | if (*ethdev_init == NULL) |
| 292 | return -EINVAL; |
| 293 | |
| 294 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 295 | ethdev = rte_eth_dev_allocate(name); |
| 296 | if (!ethdev) |
| 297 | return -ENODEV; |
| 298 | |
| 299 | if (priv_data_size) { |
| 300 | /* try alloc private data on device-local node. */ |
| 301 | ethdev->data->dev_private = rte_zmalloc_socket( |
| 302 | name, priv_data_size, RTE_CACHE_LINE_SIZE, |
| 303 | device->numa_node); |
| 304 | |
| 305 | /* fall back to alloc on any socket on failure */ |
| 306 | if (ethdev->data->dev_private == NULL) { |
| 307 | ethdev->data->dev_private = rte_zmalloc(name, |
| 308 | priv_data_size, RTE_CACHE_LINE_SIZE); |
| 309 | |
| 310 | if (ethdev->data->dev_private == NULL) { |
| 311 | RTE_ETHDEV_LOG(ERR, "failed to allocate private data\n"); |
| 312 | retval = -ENOMEM; |
| 313 | goto probe_failed; |
| 314 | } |
| 315 | /* got memory, but not local, so issue warning */ |
| 316 | RTE_ETHDEV_LOG(WARNING, |
| 317 | "Private data for ethdev '%s' not allocated on local NUMA node %d\n", |
| 318 | device->name, device->numa_node); |
| 319 | } |
| 320 | } |
| 321 | } else { |
| 322 | ethdev = rte_eth_dev_attach_secondary(name); |
| 323 | if (!ethdev) { |
| 324 | RTE_ETHDEV_LOG(ERR, |
| 325 | "secondary process attach failed, ethdev doesn't exist\n"); |
| 326 | return -ENODEV; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | ethdev->device = device; |
| 331 | |
| 332 | if (ethdev_bus_specific_init) { |
| 333 | retval = ethdev_bus_specific_init(ethdev, bus_init_params); |
| 334 | if (retval) { |
| 335 | RTE_ETHDEV_LOG(ERR, |
| 336 | "ethdev bus specific initialisation failed\n"); |
| 337 | goto probe_failed; |
| 338 | } |
no test coverage detected