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

Function nfp_pf_init

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

Source from the content-addressed store, hash-verified

1226}
1227
1228static int
1229nfp_pf_init(struct rte_pci_device *pci_dev)
1230{
1231 int ret = 0;
1232 uint64_t addr;
1233 uint32_t cpp_id;
1234 uint8_t function_id;
1235 struct nfp_cpp *cpp;
1236 struct nfp_pf_dev *pf_dev;
1237 struct nfp_hwinfo *hwinfo;
1238 enum nfp_app_fw_id app_fw_id;
1239 char name[RTE_ETH_NAME_MAX_LEN];
1240 struct nfp_rtsym_table *sym_tbl;
1241 char app_name[RTE_ETH_NAME_MAX_LEN];
1242 struct nfp_eth_table *nfp_eth_table;
1243 const struct nfp_dev_info *dev_info;
1244
1245 if (pci_dev == NULL)
1246 return -ENODEV;
1247
1248 if (pci_dev->mem_resource[0].addr == NULL) {
1249 PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
1250 return -ENODEV;
1251 }
1252
1253 dev_info = nfp_dev_info_get(pci_dev->id.device_id);
1254 if (dev_info == NULL) {
1255 PMD_INIT_LOG(ERR, "Not supported device ID");
1256 return -ENODEV;
1257 }
1258
1259 /* Allocate memory for the PF "device" */
1260 function_id = (pci_dev->addr.function) & 0x07;
1261 snprintf(name, sizeof(name), "nfp_pf%u", function_id);
1262 pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0);
1263 if (pf_dev == NULL) {
1264 PMD_INIT_LOG(ERR, "Can't allocate memory for the PF device");
1265 return -ENOMEM;
1266 }
1267
1268 /*
1269 * When device bound to UIO, the device could be used, by mistake,
1270 * by two DPDK apps, and the UIO driver does not avoid it. This
1271 * could lead to a serious problem when configuring the NFP CPP
1272 * interface. Here we avoid this telling to the CPP init code to
1273 * use a lock file if UIO is being used.
1274 */
1275 if (pci_dev->kdrv == RTE_PCI_KDRV_VFIO)
1276 cpp = nfp_cpp_from_nfp6000_pcie(pci_dev, dev_info, false);
1277 else
1278 cpp = nfp_cpp_from_nfp6000_pcie(pci_dev, dev_info, true);
1279
1280 if (cpp == NULL) {
1281 PMD_INIT_LOG(ERR, "A CPP handle can not be obtained");
1282 ret = -EIO;
1283 goto pf_cleanup;
1284 }
1285

Callers 1

nfp_pf_pci_probeFunction · 0.85

Calls 15

nfp_dev_info_getFunction · 0.85
snprintfFunction · 0.85
rte_zmallocFunction · 0.85
nfp_hwinfo_readFunction · 0.85
nfp_eth_read_portsFunction · 0.85
nfp_net_force_port_downFunction · 0.85
nfp_fw_setupFunction · 0.85
nfp_rtsym_table_readFunction · 0.85
nfp_rtsym_read_leFunction · 0.85
nfp_qcp_queue_offsetFunction · 0.85

Tested by

no test coverage detected