src/dpdk/drivers/net/vmxnet3/vmxnet3_ethdev.c
static int
vmxnet3_dev_start(struct rte_eth_dev *dev)
{
	int ret;
	struct vmxnet3_hw *hw = dev->data->dev_private;

	PMD_INIT_FUNC_TRACE();

	/* Save stats before it is reset by CMD_ACTIVATE */
	vmxnet3_hw_stats_save(hw);

	ret = vmxnet3_setup_driver_shared(dev);
	if (ret != VMXNET3_SUCCESS)
		return ret;

	/* check if lsc interrupt feature is enabled */
	if (dev->data->dev_conf.intr_conf.lsc) {
		struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);

		/* Setup interrupt callback  */
		rte_intr_callback_register(&pci_dev->intr_handle,
					   vmxnet3_interrupt_handler, dev);

		if (rte_intr_enable(&pci_dev->intr_handle) < 0) {
			PMD_INIT_LOG(ERR, "interrupt enable failed");
			return -EIO;
		}
	}

	/* Exchange shared data with device */
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_DSAL,
			       VMXNET3_GET_ADDR_LO(hw->sharedPA));
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_DSAH,
			       VMXNET3_GET_ADDR_HI(hw->sharedPA));

	/* Activate device by register write */
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_ACTIVATE_DEV);
	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);

	if (ret != 0) {
		PMD_INIT_LOG(ERR, "Device activation: UNSUCCESSFUL");
		return -EINVAL;
	}

	/* Setup memory region for rx buffers */
	ret = vmxnet3_dev_setup_memreg(dev);
	if (ret == 0) {
		VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
				       VMXNET3_CMD_REGISTER_MEMREGS);
		ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
		if (ret != 0)
			PMD_INIT_LOG(DEBUG,
				     "Failed in setup memory region cmd\n");
		ret = 0;
	} else {
		PMD_INIT_LOG(DEBUG, "Failed to setup memory region\n");
	}

	if (VMXNET3_VERSION_GE_4(hw) &&
	    dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
		/* Check for additional RSS  */
		ret = vmxnet3_v4_rss_configure(dev);
		if (ret != VMXNET3_SUCCESS) {
			PMD_INIT_LOG(ERR, "Failed to configure v4 RSS");
			return ret;
		}
	}

	/* Disable interrupts */
	vmxnet3_disable_intr(hw);

	/*
	 * Load RX queues with blank mbufs and update next2fill index for device
	 * Update RxMode of the device
	 */
	ret = vmxnet3_dev_rxtx_init(dev);
	if (ret != VMXNET3_SUCCESS) {
		PMD_INIT_LOG(ERR, "Device queue init: UNSUCCESSFUL");
		return ret;
	}

	hw->adapter_stopped = FALSE;

	/* Setting proper Rx Mode and issue Rx Mode Update command */
	vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_UCAST | VMXNET3_RXM_BCAST, 1);

	if (dev->data->dev_conf.intr_conf.lsc) {
		vmxnet3_enable_intr(hw);

		/*
		 * Update link state from device since this won't be
		 * done upon starting with lsc in use. This is done
		 * only after enabling interrupts to avoid any race
		 * where the link state could change without an
		 * interrupt being fired.
		 */
		__vmxnet3_dev_link_update(dev, 0);
	}

	return VMXNET3_SUCCESS;
}
/*
 * Configure device link speed and setup link.
 * Must be called after eth_vmxnet3_dev_init. Other wise it might fail
 * It returns 0 on success.
 */
Configure device link speed and setup link.
Must be called after eth_vmxnet3_dev_init. Other wise it might fail
It returns 0 on success.
Configure device link speed and setup link . Must be called after eth_vmxnet3_dev_init . Other wise it might fail It returns 0 on success .
static int
vmxnet3_dev_start(struct rte_eth_dev *dev)
{
	int ret;
	struct vmxnet3_hw *hw = dev->data->dev_private;
	PMD_INIT_FUNC_TRACE();
	vmxnet3_hw_stats_save(hw);
	ret = vmxnet3_setup_driver_shared(dev);
	if (ret != VMXNET3_SUCCESS)
		return ret;
	if (dev->data->dev_conf.intr_conf.lsc) {
		struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
		rte_intr_callback_register(&pci_dev->intr_handle,
					   vmxnet3_interrupt_handler, dev);
		if (rte_intr_enable(&pci_dev->intr_handle) < 0) {
			PMD_INIT_LOG(ERR, "interrupt enable failed");
			return -EIO;
		}
	}
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_DSAL,
			       VMXNET3_GET_ADDR_LO(hw->sharedPA));
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_DSAH,
			       VMXNET3_GET_ADDR_HI(hw->sharedPA));
	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_ACTIVATE_DEV);
	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
	if (ret != 0) {
		PMD_INIT_LOG(ERR, "Device activation: UNSUCCESSFUL");
		return -EINVAL;
	}
	ret = vmxnet3_dev_setup_memreg(dev);
	if (ret == 0) {
		VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
				       VMXNET3_CMD_REGISTER_MEMREGS);
		ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
		if (ret != 0)
			PMD_INIT_LOG(DEBUG,
				     "Failed in setup memory region cmd\n");
		ret = 0;
	} else {
		PMD_INIT_LOG(DEBUG, "Failed to setup memory region\n");
	}
	if (VMXNET3_VERSION_GE_4(hw) &&
	    dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
		ret = vmxnet3_v4_rss_configure(dev);
		if (ret != VMXNET3_SUCCESS) {
			PMD_INIT_LOG(ERR, "Failed to configure v4 RSS");
			return ret;
		}
	}
	vmxnet3_disable_intr(hw);
	ret = vmxnet3_dev_rxtx_init(dev);
	if (ret != VMXNET3_SUCCESS) {
		PMD_INIT_LOG(ERR, "Device queue init: UNSUCCESSFUL");
		return ret;
	}
	hw->adapter_stopped = FALSE;
	vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_UCAST | VMXNET3_RXM_BCAST, 1);
	if (dev->data->dev_conf.intr_conf.lsc) {
		vmxnet3_enable_intr(hw);
		__vmxnet3_dev_link_update(dev, 0);
	}
	return VMXNET3_SUCCESS;
}
static int vmxnet3_dev_start ( struct rte_eth_dev * dev ) { int ret ; struct vmxnet3_hw * hw = dev -> data -> dev_private ; PMD_INIT_FUNC_TRACE ( ) ; vmxnet3_hw_stats_save ( hw ) ; ret = vmxnet3_setup_driver_shared ( dev ) ; if ( ret != VMXNET3_SUCCESS ) return ret ; if ( dev -> data -> dev_conf . intr_conf . lsc ) { struct rte_pci_device * pci_dev = RTE_DEV_TO_PCI ( dev -> device ) ; rte_intr_callback_register ( & pci_dev -> intr_handle , vmxnet3_interrupt_handler , dev ) ; if ( rte_intr_enable ( & pci_dev -> intr_handle ) < 0 ) { PMD_INIT_LOG ( ERR , " " ) ; return - EIO ; } } VMXNET3_WRITE_BAR1_REG ( hw , VMXNET3_REG_DSAL , VMXNET3_GET_ADDR_LO ( hw -> sharedPA ) ) ; VMXNET3_WRITE_BAR1_REG ( hw , VMXNET3_REG_DSAH , VMXNET3_GET_ADDR_HI ( hw -> sharedPA ) ) ; VMXNET3_WRITE_BAR1_REG ( hw , VMXNET3_REG_CMD , VMXNET3_CMD_ACTIVATE_DEV ) ; ret = VMXNET3_READ_BAR1_REG ( hw , VMXNET3_REG_CMD ) ; if ( ret != 0 ) { PMD_INIT_LOG ( ERR , " " ) ; return - EINVAL ; } ret = vmxnet3_dev_setup_memreg ( dev ) ; if ( ret == 0 ) { VMXNET3_WRITE_BAR1_REG ( hw , VMXNET3_REG_CMD , VMXNET3_CMD_REGISTER_MEMREGS ) ; ret = VMXNET3_READ_BAR1_REG ( hw , VMXNET3_REG_CMD ) ; if ( ret != 0 ) PMD_INIT_LOG ( DEBUG , " \n " ) ; ret = 0 ; } else { PMD_INIT_LOG ( DEBUG , " \n " ) ; } if ( VMXNET3_VERSION_GE_4 ( hw ) && dev -> data -> dev_conf . rxmode . mq_mode == ETH_MQ_RX_RSS ) { ret = vmxnet3_v4_rss_configure ( dev ) ; if ( ret != VMXNET3_SUCCESS ) { PMD_INIT_LOG ( ERR , " " ) ; return ret ; } } vmxnet3_disable_intr ( hw ) ; ret = vmxnet3_dev_rxtx_init ( dev ) ; if ( ret != VMXNET3_SUCCESS ) { PMD_INIT_LOG ( ERR , " " ) ; return ret ; } hw -> adapter_stopped = FALSE ; vmxnet3_dev_set_rxmode ( hw , VMXNET3_RXM_UCAST | VMXNET3_RXM_BCAST , 1 ) ; if ( dev -> data -> dev_conf . intr_conf . lsc ) { vmxnet3_enable_intr ( hw ) ; __vmxnet3_dev_link_update ( dev , 0 ) ; } return VMXNET3_SUCCESS ; }
Configure device link speed and setup link.
Configure device link speed and setup link .
/* Save stats before it is reset by CMD_ACTIVATE */ /* check if lsc interrupt feature is enabled */ /* Setup interrupt callback  */ /* Exchange shared data with device */ /* Activate device by register write */ /* Setup memory region for rx buffers */ /* Check for additional RSS  */ /* Disable interrupts */ /*
	 * Load RX queues with blank mbufs and update next2fill index for device
	 * Update RxMode of the device
	 */ /* Setting proper Rx Mode and issue Rx Mode Update command */ /*
		 * Update link state from device since this won't be
		 * done upon starting with lsc in use. This is done
		 * only after enabling interrupts to avoid any race
		 * where the link state could change without an
		 * interrupt being fired.
		 */