src/dpdk/drivers/net/nfp/nfp_net.c
static int
nfp_net_close(struct rte_eth_dev *dev)
{
	struct nfp_net_hw *hw;
	struct rte_pci_device *pci_dev;
	int i;

	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
		return 0;

	PMD_INIT_LOG(DEBUG, "Close");

	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	pci_dev = RTE_ETH_DEV_TO_PCI(dev);

	/*
	 * We assume that the DPDK application is stopping all the
	 * threads/queues before calling the device close function.
	 */

	nfp_net_disable_queues(dev);

	/* Clear queues */
	for (i = 0; i < dev->data->nb_tx_queues; i++) {
		nfp_net_reset_tx_queue(
			(struct nfp_net_txq *)dev->data->tx_queues[i]);
	}

	for (i = 0; i < dev->data->nb_rx_queues; i++) {
		nfp_net_reset_rx_queue(
			(struct nfp_net_rxq *)dev->data->rx_queues[i]);
	}

	/* Only free PF resources after all physical ports have been closed */
	if (pci_dev->id.device_id == PCI_DEVICE_ID_NFP4000_PF_NIC ||
	    pci_dev->id.device_id == PCI_DEVICE_ID_NFP6000_PF_NIC) {
		struct nfp_pf_dev *pf_dev;
		pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);

		/* Mark this port as unused and free device priv resources*/
		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
		pf_dev->ports[hw->idx] = NULL;
		rte_eth_dev_release_port(dev);

		for (i = 0; i < pf_dev->total_phyports; i++) {
			/* Check to see if ports are still in use */
			if (pf_dev->ports[i])
				return 0;
		}

		/* Now it is safe to free all PF resources */
		PMD_INIT_LOG(INFO, "Freeing PF resources");
		nfp_cpp_area_free(pf_dev->ctrl_area);
		nfp_cpp_area_free(pf_dev->hwqueues_area);
		free(pf_dev->hwinfo);
		free(pf_dev->sym_tbl);
		nfp_cpp_free(pf_dev->cpp);
		rte_free(pf_dev);
	}

	rte_intr_disable(&pci_dev->intr_handle);

	/* unregister callback func from eal lib */
	rte_intr_callback_unregister(&pci_dev->intr_handle,
				     nfp_net_dev_interrupt_handler,
				     (void *)dev);

	/*
	 * The ixgbe PMD driver disables the pcie master on the
	 * device. The i40e does not...
	 */

	return 0;
}
/* Reset and stop device. The device can not be restarted. */
Reset and stop device. The device can not be restarted.
Reset and stop device . The device can not be restarted .
static int
nfp_net_close(struct rte_eth_dev *dev)
{
	struct nfp_net_hw *hw;
	struct rte_pci_device *pci_dev;
	int i;
	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
		return 0;
	PMD_INIT_LOG(DEBUG, "Close");
	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
	nfp_net_disable_queues(dev);
	for (i = 0; i < dev->data->nb_tx_queues; i++) {
		nfp_net_reset_tx_queue(
			(struct nfp_net_txq *)dev->data->tx_queues[i]);
	}
	for (i = 0; i < dev->data->nb_rx_queues; i++) {
		nfp_net_reset_rx_queue(
			(struct nfp_net_rxq *)dev->data->rx_queues[i]);
	}
	if (pci_dev->id.device_id == PCI_DEVICE_ID_NFP4000_PF_NIC ||
	    pci_dev->id.device_id == PCI_DEVICE_ID_NFP6000_PF_NIC) {
		struct nfp_pf_dev *pf_dev;
		pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
		pf_dev->ports[hw->idx] = NULL;
		rte_eth_dev_release_port(dev);
		for (i = 0; i < pf_dev->total_phyports; i++) {
			if (pf_dev->ports[i])
				return 0;
		}
		PMD_INIT_LOG(INFO, "Freeing PF resources");
		nfp_cpp_area_free(pf_dev->ctrl_area);
		nfp_cpp_area_free(pf_dev->hwqueues_area);
		free(pf_dev->hwinfo);
		free(pf_dev->sym_tbl);
		nfp_cpp_free(pf_dev->cpp);
		rte_free(pf_dev);
	}
	rte_intr_disable(&pci_dev->intr_handle);
	rte_intr_callback_unregister(&pci_dev->intr_handle,
				     nfp_net_dev_interrupt_handler,
				     (void *)dev);
	return 0;
}
static int nfp_net_close ( struct rte_eth_dev * dev ) { struct nfp_net_hw * hw ; struct rte_pci_device * pci_dev ; int i ; if ( rte_eal_process_type ( ) != RTE_PROC_PRIMARY ) return 0 ; PMD_INIT_LOG ( DEBUG , " " ) ; hw = NFP_NET_DEV_PRIVATE_TO_HW ( dev -> data -> dev_private ) ; pci_dev = RTE_ETH_DEV_TO_PCI ( dev ) ; nfp_net_disable_queues ( dev ) ; for ( i = 0 ; i < dev -> data -> nb_tx_queues ; i ++ ) { nfp_net_reset_tx_queue ( ( struct nfp_net_txq * ) dev -> data -> tx_queues [ i ] ) ; } for ( i = 0 ; i < dev -> data -> nb_rx_queues ; i ++ ) { nfp_net_reset_rx_queue ( ( struct nfp_net_rxq * ) dev -> data -> rx_queues [ i ] ) ; } if ( pci_dev -> id . device_id == PCI_DEVICE_ID_NFP4000_PF_NIC || pci_dev -> id . device_id == PCI_DEVICE_ID_NFP6000_PF_NIC ) { struct nfp_pf_dev * pf_dev ; pf_dev = NFP_NET_DEV_PRIVATE_TO_PF ( dev -> data -> dev_private ) ; nn_cfg_writeb ( hw , NFP_NET_CFG_LSC , 0xff ) ; pf_dev -> ports [ hw -> idx ] = NULL ; rte_eth_dev_release_port ( dev ) ; for ( i = 0 ; i < pf_dev -> total_phyports ; i ++ ) { if ( pf_dev -> ports [ i ] ) return 0 ; } PMD_INIT_LOG ( INFO , " " ) ; nfp_cpp_area_free ( pf_dev -> ctrl_area ) ; nfp_cpp_area_free ( pf_dev -> hwqueues_area ) ; free ( pf_dev -> hwinfo ) ; free ( pf_dev -> sym_tbl ) ; nfp_cpp_free ( pf_dev -> cpp ) ; rte_free ( pf_dev ) ; } rte_intr_disable ( & pci_dev -> intr_handle ) ; rte_intr_callback_unregister ( & pci_dev -> intr_handle , nfp_net_dev_interrupt_handler , ( void * ) dev ) ; return 0 ; }
Reset and stop device.
Reset and stop device .
/*
	 * We assume that the DPDK application is stopping all the
	 * threads/queues before calling the device close function.
	 */ /* Clear queues */ /* Only free PF resources after all physical ports have been closed */ /* Mark this port as unused and free device priv resources*/ /* Check to see if ports are still in use */ /* Now it is safe to free all PF resources */ /* unregister callback func from eal lib */ /*
	 * The ixgbe PMD driver disables the pcie master on the
	 * device. The i40e does not...
	 */