src/dpdk/drivers/net/atlantic/atl_ethdev.c
static int
atl_dev_start(struct rte_eth_dev *dev)
{
	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
	uint32_t intr_vector = 0;
	int status;
	int err;

	PMD_INIT_FUNC_TRACE();

	/* set adapter started */
	hw->adapter_stopped = 0;

	if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
		PMD_INIT_LOG(ERR,
		"Invalid link_speeds for port %u, fix speed not supported",
				dev->data->port_id);
		return -EINVAL;
	}

	/* disable uio/vfio intr/eventfd mapping */
	rte_intr_disable(intr_handle);

	/* reinitialize adapter
	 * this calls reset and start
	 */
	status = atl_reset_hw(hw);
	if (status != 0)
		return -EIO;

	err = hw_atl_b0_hw_init(hw, dev->data->mac_addrs->addr_bytes);

	hw_atl_b0_hw_start(hw);
	/* check and configure queue intr-vector mapping */
	if ((rte_intr_cap_multiple(intr_handle) ||
	    !RTE_ETH_DEV_SRIOV(dev).active) &&
	    dev->data->dev_conf.intr_conf.rxq != 0) {
		intr_vector = dev->data->nb_rx_queues;
		if (intr_vector > ATL_MAX_INTR_QUEUE_NUM) {
			PMD_INIT_LOG(ERR, "At most %d intr queues supported",
					ATL_MAX_INTR_QUEUE_NUM);
			return -ENOTSUP;
		}
		if (rte_intr_efd_enable(intr_handle, intr_vector)) {
			PMD_INIT_LOG(ERR, "rte_intr_efd_enable failed");
			return -1;
		}
	}

	if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
		intr_handle->intr_vec = rte_zmalloc("intr_vec",
				    dev->data->nb_rx_queues * sizeof(int), 0);
		if (intr_handle->intr_vec == NULL) {
			PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
				     " intr_vec", dev->data->nb_rx_queues);
			return -ENOMEM;
		}
	}

	/* initialize transmission unit */
	atl_tx_init(dev);

	/* This can fail when allocating mbufs for descriptor rings */
	err = atl_rx_init(dev);
	if (err) {
		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
		goto error;
	}

	PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u",
		hw->fw_ver_actual >> 24,
		(hw->fw_ver_actual >> 16) & 0xFF,
		hw->fw_ver_actual & 0xFFFF);
	PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION);

	err = atl_start_queues(dev);
	if (err < 0) {
		PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
		goto error;
	}

	err = atl_dev_set_link_up(dev);

	err = hw->aq_fw_ops->update_link_status(hw);

	if (err)
		goto error;

	dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;

	if (rte_intr_allow_others(intr_handle)) {
		/* check if lsc interrupt is enabled */
		if (dev->data->dev_conf.intr_conf.lsc != 0)
			atl_dev_lsc_interrupt_setup(dev, true);
		else
			atl_dev_lsc_interrupt_setup(dev, false);
	} else {
		rte_intr_callback_unregister(intr_handle,
					     atl_dev_interrupt_handler, dev);
		if (dev->data->dev_conf.intr_conf.lsc != 0)
			PMD_INIT_LOG(INFO, "lsc won't enable because of"
				     " no intr multiplex");
	}

	/* check if rxq interrupt is enabled */
	if (dev->data->dev_conf.intr_conf.rxq != 0 &&
	    rte_intr_dp_is_en(intr_handle))
		atl_dev_rxq_interrupt_setup(dev);

	/* enable uio/vfio intr/eventfd mapping */
	rte_intr_enable(intr_handle);

	/* resume enabled intr since hw reset */
	atl_enable_intr(dev);

	return 0;

error:
	atl_stop_queues(dev);
	return -EIO;
}
/*
 * Configure device link speed and setup link.
 * It returns 0 on success.
 */
Configure device link speed and setup link.
It returns 0 on success.
Configure device link speed and setup link . It returns 0 on success .
static int
atl_dev_start(struct rte_eth_dev *dev)
{
	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
	uint32_t intr_vector = 0;
	int status;
	int err;
	PMD_INIT_FUNC_TRACE();
	hw->adapter_stopped = 0;
	if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
		PMD_INIT_LOG(ERR,
		"Invalid link_speeds for port %u, fix speed not supported",
				dev->data->port_id);
		return -EINVAL;
	}
	rte_intr_disable(intr_handle);
	status = atl_reset_hw(hw);
	if (status != 0)
		return -EIO;
	err = hw_atl_b0_hw_init(hw, dev->data->mac_addrs->addr_bytes);
	hw_atl_b0_hw_start(hw);
	if ((rte_intr_cap_multiple(intr_handle) ||
	    !RTE_ETH_DEV_SRIOV(dev).active) &&
	    dev->data->dev_conf.intr_conf.rxq != 0) {
		intr_vector = dev->data->nb_rx_queues;
		if (intr_vector > ATL_MAX_INTR_QUEUE_NUM) {
			PMD_INIT_LOG(ERR, "At most %d intr queues supported",
					ATL_MAX_INTR_QUEUE_NUM);
			return -ENOTSUP;
		}
		if (rte_intr_efd_enable(intr_handle, intr_vector)) {
			PMD_INIT_LOG(ERR, "rte_intr_efd_enable failed");
			return -1;
		}
	}
	if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
		intr_handle->intr_vec = rte_zmalloc("intr_vec",
				    dev->data->nb_rx_queues * sizeof(int), 0);
		if (intr_handle->intr_vec == NULL) {
			PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
				     " intr_vec", dev->data->nb_rx_queues);
			return -ENOMEM;
		}
	}
	atl_tx_init(dev);
	err = atl_rx_init(dev);
	if (err) {
		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
		goto error;
	}
	PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u",
		hw->fw_ver_actual >> 24,
		(hw->fw_ver_actual >> 16) & 0xFF,
		hw->fw_ver_actual & 0xFFFF);
	PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION);
	err = atl_start_queues(dev);
	if (err < 0) {
		PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
		goto error;
	}
	err = atl_dev_set_link_up(dev);
	err = hw->aq_fw_ops->update_link_status(hw);
	if (err)
		goto error;
	dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;
	if (rte_intr_allow_others(intr_handle)) {
		if (dev->data->dev_conf.intr_conf.lsc != 0)
			atl_dev_lsc_interrupt_setup(dev, true);
		else
			atl_dev_lsc_interrupt_setup(dev, false);
	} else {
		rte_intr_callback_unregister(intr_handle,
					     atl_dev_interrupt_handler, dev);
		if (dev->data->dev_conf.intr_conf.lsc != 0)
			PMD_INIT_LOG(INFO, "lsc won't enable because of"
				     " no intr multiplex");
	}
	if (dev->data->dev_conf.intr_conf.rxq != 0 &&
	    rte_intr_dp_is_en(intr_handle))
		atl_dev_rxq_interrupt_setup(dev);
	rte_intr_enable(intr_handle);
	atl_enable_intr(dev);
	return 0;
error:
	atl_stop_queues(dev);
	return -EIO;
}
static int atl_dev_start ( struct rte_eth_dev * dev ) { struct aq_hw_s * hw = ATL_DEV_PRIVATE_TO_HW ( dev -> data -> dev_private ) ; struct rte_pci_device * pci_dev = RTE_ETH_DEV_TO_PCI ( dev ) ; struct rte_intr_handle * intr_handle = & pci_dev -> intr_handle ; uint32_t intr_vector = 0 ; int status ; int err ; PMD_INIT_FUNC_TRACE ( ) ; hw -> adapter_stopped = 0 ; if ( dev -> data -> dev_conf . link_speeds & ETH_LINK_SPEED_FIXED ) { PMD_INIT_LOG ( ERR , " " , dev -> data -> port_id ) ; return - EINVAL ; } rte_intr_disable ( intr_handle ) ; status = atl_reset_hw ( hw ) ; if ( status != 0 ) return - EIO ; err = hw_atl_b0_hw_init ( hw , dev -> data -> mac_addrs -> addr_bytes ) ; hw_atl_b0_hw_start ( hw ) ; if ( ( rte_intr_cap_multiple ( intr_handle ) || ! RTE_ETH_DEV_SRIOV ( dev ) . active ) && dev -> data -> dev_conf . intr_conf . rxq != 0 ) { intr_vector = dev -> data -> nb_rx_queues ; if ( intr_vector > ATL_MAX_INTR_QUEUE_NUM ) { PMD_INIT_LOG ( ERR , " " , ATL_MAX_INTR_QUEUE_NUM ) ; return - ENOTSUP ; } if ( rte_intr_efd_enable ( intr_handle , intr_vector ) ) { PMD_INIT_LOG ( ERR , " " ) ; return -1 ; } } if ( rte_intr_dp_is_en ( intr_handle ) && ! intr_handle -> intr_vec ) { intr_handle -> intr_vec = rte_zmalloc ( " " , dev -> data -> nb_rx_queues * sizeof ( int ) , 0 ) ; if ( intr_handle -> intr_vec == NULL ) { PMD_INIT_LOG ( ERR , " " " " , dev -> data -> nb_rx_queues ) ; return - ENOMEM ; } } atl_tx_init ( dev ) ; err = atl_rx_init ( dev ) ; if ( err ) { PMD_INIT_LOG ( ERR , " " ) ; goto error ; } PMD_INIT_LOG ( DEBUG , " " , hw -> fw_ver_actual >> 24 , ( hw -> fw_ver_actual >> 16 ) & 0xFF , hw -> fw_ver_actual & 0xFFFF ) ; PMD_INIT_LOG ( DEBUG , " " , ATL_PMD_DRIVER_VERSION ) ; err = atl_start_queues ( dev ) ; if ( err < 0 ) { PMD_INIT_LOG ( ERR , " " ) ; goto error ; } err = atl_dev_set_link_up ( dev ) ; err = hw -> aq_fw_ops -> update_link_status ( hw ) ; if ( err ) goto error ; dev -> data -> dev_link . link_status = hw -> aq_link_status . mbps != 0 ; if ( rte_intr_allow_others ( intr_handle ) ) { if ( dev -> data -> dev_conf . intr_conf . lsc != 0 ) atl_dev_lsc_interrupt_setup ( dev , true ) ; else atl_dev_lsc_interrupt_setup ( dev , false ) ; } else { rte_intr_callback_unregister ( intr_handle , atl_dev_interrupt_handler , dev ) ; if ( dev -> data -> dev_conf . intr_conf . lsc != 0 ) PMD_INIT_LOG ( INFO , " " " " ) ; } if ( dev -> data -> dev_conf . intr_conf . rxq != 0 && rte_intr_dp_is_en ( intr_handle ) ) atl_dev_rxq_interrupt_setup ( dev ) ; rte_intr_enable ( intr_handle ) ; atl_enable_intr ( dev ) ; return 0 ; error : atl_stop_queues ( dev ) ; return - EIO ; }
Configure device link speed and setup link.
Configure device link speed and setup link .
/* set adapter started */ /* disable uio/vfio intr/eventfd mapping */ /* reinitialize adapter
	 * this calls reset and start
	 */ /* check and configure queue intr-vector mapping */ /* initialize transmission unit */ /* This can fail when allocating mbufs for descriptor rings */ /* check if lsc interrupt is enabled */ /* check if rxq interrupt is enabled */ /* enable uio/vfio intr/eventfd mapping */ /* resume enabled intr since hw reset */