MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nfp_pf_secondary_init

Function nfp_pf_secondary_init

dpdk/drivers/net/nfp/nfp_ethdev.c:1487–1601  ·  view source on GitHub ↗

* When attaching to the NFP4000/6000 PF on a secondary process there * is no need to initialise the PF again. Only minimal work is required * here. */

Source from the content-addressed store, hash-verified

1485 * here.
1486 */
1487static int
1488nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
1489{
1490 int ret = 0;
1491 struct nfp_cpp *cpp;
1492 uint8_t function_id;
1493 struct nfp_pf_dev *pf_dev;
1494 enum nfp_app_fw_id app_fw_id;
1495 char name[RTE_ETH_NAME_MAX_LEN];
1496 struct nfp_rtsym_table *sym_tbl;
1497 const struct nfp_dev_info *dev_info;
1498 char app_name[RTE_ETH_NAME_MAX_LEN];
1499
1500 if (pci_dev == NULL)
1501 return -ENODEV;
1502
1503 if (pci_dev->mem_resource[0].addr == NULL) {
1504 PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
1505 return -ENODEV;
1506 }
1507
1508 dev_info = nfp_dev_info_get(pci_dev->id.device_id);
1509 if (dev_info == NULL) {
1510 PMD_INIT_LOG(ERR, "Not supported device ID");
1511 return -ENODEV;
1512 }
1513
1514 /* Allocate memory for the PF "device" */
1515 snprintf(name, sizeof(name), "nfp_pf%d", 0);
1516 pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0);
1517 if (pf_dev == NULL) {
1518 PMD_INIT_LOG(ERR, "Can't allocate memory for the PF device");
1519 return -ENOMEM;
1520 }
1521
1522 /*
1523 * When device bound to UIO, the device could be used, by mistake,
1524 * by two DPDK apps, and the UIO driver does not avoid it. This
1525 * could lead to a serious problem when configuring the NFP CPP
1526 * interface. Here we avoid this telling to the CPP init code to
1527 * use a lock file if UIO is being used.
1528 */
1529 if (pci_dev->kdrv == RTE_PCI_KDRV_VFIO)
1530 cpp = nfp_cpp_from_nfp6000_pcie(pci_dev, dev_info, false);
1531 else
1532 cpp = nfp_cpp_from_nfp6000_pcie(pci_dev, dev_info, true);
1533
1534 if (cpp == NULL) {
1535 PMD_INIT_LOG(ERR, "A CPP handle can not be obtained");
1536 ret = -EIO;
1537 goto pf_cleanup;
1538 }
1539
1540 /*
1541 * We don't have access to the PF created in the primary process
1542 * here so we have to read the number of ports from firmware.
1543 */
1544 sym_tbl = nfp_rtsym_table_read(cpp);

Callers 1

nfp_pf_pci_probeFunction · 0.85

Calls 11

nfp_dev_info_getFunction · 0.85
snprintfFunction · 0.85
rte_zmallocFunction · 0.85
nfp_rtsym_table_readFunction · 0.85
nfp_rtsym_read_leFunction · 0.85
nfp_cpp_freeFunction · 0.85
rte_freeFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected