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

Function nfp_net_close

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

Reset and stop device. The device can not be restarted. */

Source from the content-addressed store, hash-verified

385
386/* Reset and stop device. The device can not be restarted. */
387static int
388nfp_net_close(struct rte_eth_dev *dev)
389{
390 uint8_t i;
391 uint8_t id;
392 struct nfp_net_hw *hw;
393 struct nfp_pf_dev *pf_dev;
394 struct rte_pci_device *pci_dev;
395 struct nfp_app_fw_nic *app_fw_nic;
396
397 /*
398 * In secondary process, a released eth device can be found by its name
399 * in shared memory.
400 * If the state of the eth device is RTE_ETH_DEV_UNUSED, it means the
401 * eth device has been released.
402 */
403 if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
404 if (dev->state == RTE_ETH_DEV_UNUSED)
405 return 0;
406
407 nfp_pf_secondary_uninit(dev->process_private);
408 return 0;
409 }
410
411 hw = dev->data->dev_private;
412 pf_dev = hw->pf_dev;
413 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
414 app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
415
416 /*
417 * We assume that the DPDK application is stopping all the
418 * threads/queues before calling the device close function.
419 */
420 nfp_net_disable_queues(dev);
421
422 /* Clear queues */
423 nfp_net_close_tx_queue(dev);
424 nfp_net_close_rx_queue(dev);
425
426 /* Cancel possible impending LSC work here before releasing the port */
427 rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
428
429 /* Only free PF resources after all physical ports have been closed */
430 /* Mark this port as unused and free device priv resources */
431 nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
432
433 if (pf_dev->app_fw_id != NFP_APP_FW_CORE_NIC)
434 return -EINVAL;
435
436 nfp_cleanup_port_app_fw_nic(pf_dev, hw->idx);
437
438 for (i = 0; i < app_fw_nic->total_phyports; i++) {
439 id = nfp_function_id_get(pf_dev, i);
440
441 /* Check to see if ports are still in use */
442 if (app_fw_nic->ports[id] != NULL)
443 return 0;
444 }

Callers

nothing calls this directly

Calls 13

rte_eal_process_typeFunction · 0.85
nfp_pf_secondary_uninitFunction · 0.85
nfp_net_disable_queuesFunction · 0.85
nfp_net_close_tx_queueFunction · 0.85
nfp_net_close_rx_queueFunction · 0.85
nn_cfg_writebFunction · 0.85
nfp_function_id_getFunction · 0.85
nfp_uninit_app_fw_nicFunction · 0.85
nfp_pf_uninitFunction · 0.85
rte_eal_alarm_cancelFunction · 0.50
rte_intr_disableFunction · 0.50

Tested by

no test coverage detected