| 396 | } |
| 397 | |
| 398 | int |
| 399 | roc_nix_dev_init(struct roc_nix *roc_nix) |
| 400 | { |
| 401 | enum roc_nix_rss_reta_sz reta_sz; |
| 402 | struct plt_pci_device *pci_dev; |
| 403 | struct roc_nix_list *nix_list; |
| 404 | uint16_t max_sqb_count; |
| 405 | uint64_t blkaddr; |
| 406 | struct dev *dev; |
| 407 | struct nix *nix; |
| 408 | int rc; |
| 409 | |
| 410 | if (roc_nix == NULL || roc_nix->pci_dev == NULL) |
| 411 | return NIX_ERR_PARAM; |
| 412 | |
| 413 | reta_sz = roc_nix->reta_sz; |
| 414 | if (reta_sz != 0 && reta_sz != 64 && reta_sz != 128 && reta_sz != 256) |
| 415 | return NIX_ERR_PARAM; |
| 416 | |
| 417 | if (reta_sz == 0) |
| 418 | reta_sz = ROC_NIX_RSS_RETA_SZ_64; |
| 419 | |
| 420 | max_sqb_count = roc_nix->max_sqb_count; |
| 421 | max_sqb_count = PLT_MIN(max_sqb_count, NIX_MAX_SQB); |
| 422 | max_sqb_count = PLT_MAX(max_sqb_count, NIX_MIN_SQB); |
| 423 | roc_nix->max_sqb_count = max_sqb_count; |
| 424 | |
| 425 | PLT_STATIC_ASSERT(sizeof(struct nix) <= ROC_NIX_MEM_SZ); |
| 426 | nix = roc_nix_to_nix_priv(roc_nix); |
| 427 | pci_dev = roc_nix->pci_dev; |
| 428 | dev = &nix->dev; |
| 429 | |
| 430 | nix_list = roc_idev_nix_list_get(); |
| 431 | if (nix_list == NULL) |
| 432 | return -EINVAL; |
| 433 | |
| 434 | TAILQ_INSERT_TAIL(nix_list, roc_nix, next); |
| 435 | |
| 436 | if (nix->dev.drv_inited) |
| 437 | return 0; |
| 438 | |
| 439 | if (dev->mbox_active) |
| 440 | goto skip_dev_init; |
| 441 | |
| 442 | memset(nix, 0, sizeof(*nix)); |
| 443 | |
| 444 | /* Since 0 is a valid BPID, use -1 to represent invalid value. */ |
| 445 | memset(nix->bpid, -1, sizeof(nix->bpid)); |
| 446 | |
| 447 | /* Initialize device */ |
| 448 | rc = dev_init(dev, pci_dev); |
| 449 | if (rc) { |
| 450 | plt_err("Failed to init roc device"); |
| 451 | goto fail; |
| 452 | } |
| 453 | |
| 454 | skip_dev_init: |
| 455 | dev->roc_nix = roc_nix; |
no test coverage detected