| 346 | |
| 347 | |
| 348 | static int |
| 349 | ethdev_process(const char *name, struct ethdev_config *params) |
| 350 | { |
| 351 | struct rte_eth_dev_info port_info; |
| 352 | struct rte_eth_conf port_conf; |
| 353 | struct ethdev_rss_config *rss; |
| 354 | struct rte_mempool *mempool; |
| 355 | struct ethdev *ethdev_port; |
| 356 | struct rte_ether_addr smac; |
| 357 | uint16_t port_id = 0; |
| 358 | int numa_node, rc; |
| 359 | uint32_t i; |
| 360 | |
| 361 | /* Check input params */ |
| 362 | if (!name || !name[0] || !params || !params->rx.n_queues || !params->rx.queue_size || |
| 363 | !params->tx.n_queues || !params->tx.queue_size) |
| 364 | return -EINVAL; |
| 365 | |
| 366 | rc = rte_eth_dev_get_port_by_name(name, &port_id); |
| 367 | if (rc) |
| 368 | return -EINVAL; |
| 369 | |
| 370 | if (!ethdev_port_by_id(port_id)) { |
| 371 | ethdev_port = malloc(sizeof(struct ethdev)); |
| 372 | if (!ethdev_port) |
| 373 | return -EINVAL; |
| 374 | } else { |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | rc = rte_eth_dev_info_get(port_id, &port_info); |
| 379 | if (rc) { |
| 380 | rc = -EINVAL; |
| 381 | goto exit; |
| 382 | } |
| 383 | |
| 384 | mempool = rte_mempool_lookup(params->rx.mempool_name); |
| 385 | if (!mempool) { |
| 386 | rc = -EINVAL; |
| 387 | goto exit; |
| 388 | } |
| 389 | |
| 390 | params->rx.mp = mempool; |
| 391 | |
| 392 | rss = params->rx.rss; |
| 393 | if (rss) { |
| 394 | if (!port_info.reta_size || port_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) { |
| 395 | rc = -EINVAL; |
| 396 | goto exit; |
| 397 | } |
| 398 | |
| 399 | if (!rss->n_queues || rss->n_queues >= ETHDEV_RXQ_RSS_MAX) { |
| 400 | rc = -EINVAL; |
| 401 | goto exit; |
| 402 | } |
| 403 | |
| 404 | for (i = 0; i < rss->n_queues; i++) |
| 405 | if (rss->queue_id[i] >= port_info.max_rx_queues) { |
no test coverage detected