src/dpdk/drivers/net/hinic/hinic_pmd_ethdev.c
static int hinic_dev_start(struct rte_eth_dev *dev)
{
	int rc;
	char *name;
	struct hinic_nic_dev *nic_dev;

	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	name = dev->data->name;

	/* reset rx and tx queue */
	hinic_reset_rx_queue(dev);
	hinic_reset_tx_queue(dev);

	/* get func rx buf size */
	hinic_get_func_rx_buf_size(nic_dev);

	/* init txq and rxq context */
	rc = hinic_init_qp_ctxts(nic_dev->hwdev);
	if (rc) {
		PMD_DRV_LOG(ERR, "Initialize qp context failed, dev_name: %s",
			    name);
		goto init_qp_fail;
	}

	/* rss template */
	rc = hinic_config_mq_mode(dev, TRUE);
	if (rc) {
		PMD_DRV_LOG(ERR, "Configure mq mode failed, dev_name: %s",
			    name);
		goto cfg_mq_mode_fail;
	}

	/* set default mtu */
	rc = hinic_set_port_mtu(nic_dev->hwdev, nic_dev->mtu_size);
	if (rc) {
		PMD_DRV_LOG(ERR, "Set mtu_size[%d] failed, dev_name: %s",
			    nic_dev->mtu_size, name);
		goto set_mtu_fail;
	}

	/* configure rss rx_mode and other rx or tx default feature */
	rc = hinic_rxtx_configure(dev);
	if (rc) {
		PMD_DRV_LOG(ERR, "Configure tx and rx failed, dev_name: %s",
			    name);
		goto cfg_rxtx_fail;
	}

	/* reactive pf status, so that uP report asyn event */
	hinic_set_pf_status(nic_dev->hwdev->hwif, HINIC_PF_STATUS_ACTIVE_FLAG);

	/* open virtual port and ready to start packet receiving */
	rc = hinic_set_vport_enable(nic_dev->hwdev, true);
	if (rc) {
		PMD_DRV_LOG(ERR, "Enable vport failed, dev_name:%s", name);
		goto en_vport_fail;
	}

	/* open physical port and start packet receiving */
	rc = hinic_set_port_enable(nic_dev->hwdev, true);
	if (rc) {
		PMD_DRV_LOG(ERR, "Enable physical port failed, dev_name: %s",
			    name);
		goto en_port_fail;
	}

	/* update eth_dev link status */
	if (dev->data->dev_conf.intr_conf.lsc != 0)
		(void)hinic_link_update(dev, 0);

	rte_bit_relaxed_set32(HINIC_DEV_START, &nic_dev->dev_status);

	return 0;

en_port_fail:
	(void)hinic_set_vport_enable(nic_dev->hwdev, false);

en_vport_fail:
	hinic_set_pf_status(nic_dev->hwdev->hwif, HINIC_PF_STATUS_INIT);

	/* Flush tx && rx chip resources in case of set vport fake fail */
	(void)hinic_flush_qp_res(nic_dev->hwdev);
	rte_delay_ms(100);

	hinic_remove_rxtx_configure(dev);

cfg_rxtx_fail:
set_mtu_fail:
cfg_mq_mode_fail:
	hinic_free_qp_ctxts(nic_dev->hwdev);

init_qp_fail:
	hinic_free_all_rx_mbuf(dev);
	hinic_free_all_tx_mbuf(dev);

	return rc;
}
/**
 * DPDK callback to start the device.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 *
 * @return
 *   0 on success, negative errno value on failure.
 */
DPDK callback to start the device.
@param dev
Pointer to Ethernet device structure.

@return
0 on success, negative errno value on failure.
DPDK callback to start the device . @param dev Pointer to Ethernet device structure . @return 0 on success negative errno value on failure .
static int hinic_dev_start(struct rte_eth_dev *dev)
{
	int rc;
	char *name;
	struct hinic_nic_dev *nic_dev;
	nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	name = dev->data->name;
	hinic_reset_rx_queue(dev);
	hinic_reset_tx_queue(dev);
	hinic_get_func_rx_buf_size(nic_dev);
	rc = hinic_init_qp_ctxts(nic_dev->hwdev);
	if (rc) {
		PMD_DRV_LOG(ERR, "Initialize qp context failed, dev_name: %s",
			    name);
		goto init_qp_fail;
	}
	rc = hinic_config_mq_mode(dev, TRUE);
	if (rc) {
		PMD_DRV_LOG(ERR, "Configure mq mode failed, dev_name: %s",
			    name);
		goto cfg_mq_mode_fail;
	}
	rc = hinic_set_port_mtu(nic_dev->hwdev, nic_dev->mtu_size);
	if (rc) {
		PMD_DRV_LOG(ERR, "Set mtu_size[%d] failed, dev_name: %s",
			    nic_dev->mtu_size, name);
		goto set_mtu_fail;
	}
	rc = hinic_rxtx_configure(dev);
	if (rc) {
		PMD_DRV_LOG(ERR, "Configure tx and rx failed, dev_name: %s",
			    name);
		goto cfg_rxtx_fail;
	}
	hinic_set_pf_status(nic_dev->hwdev->hwif, HINIC_PF_STATUS_ACTIVE_FLAG);
	rc = hinic_set_vport_enable(nic_dev->hwdev, true);
	if (rc) {
		PMD_DRV_LOG(ERR, "Enable vport failed, dev_name:%s", name);
		goto en_vport_fail;
	}
	rc = hinic_set_port_enable(nic_dev->hwdev, true);
	if (rc) {
		PMD_DRV_LOG(ERR, "Enable physical port failed, dev_name: %s",
			    name);
		goto en_port_fail;
	}
	if (dev->data->dev_conf.intr_conf.lsc != 0)
		(void)hinic_link_update(dev, 0);
	rte_bit_relaxed_set32(HINIC_DEV_START, &nic_dev->dev_status);
	return 0;
en_port_fail:
	(void)hinic_set_vport_enable(nic_dev->hwdev, false);
en_vport_fail:
	hinic_set_pf_status(nic_dev->hwdev->hwif, HINIC_PF_STATUS_INIT);
	(void)hinic_flush_qp_res(nic_dev->hwdev);
	rte_delay_ms(100);
	hinic_remove_rxtx_configure(dev);
cfg_rxtx_fail:
set_mtu_fail:
cfg_mq_mode_fail:
	hinic_free_qp_ctxts(nic_dev->hwdev);
init_qp_fail:
	hinic_free_all_rx_mbuf(dev);
	hinic_free_all_tx_mbuf(dev);
	return rc;
}
static int hinic_dev_start ( struct rte_eth_dev * dev ) { int rc ; char * name ; struct hinic_nic_dev * nic_dev ; nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV ( dev ) ; name = dev -> data -> name ; hinic_reset_rx_queue ( dev ) ; hinic_reset_tx_queue ( dev ) ; hinic_get_func_rx_buf_size ( nic_dev ) ; rc = hinic_init_qp_ctxts ( nic_dev -> hwdev ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , name ) ; goto init_qp_fail ; } rc = hinic_config_mq_mode ( dev , TRUE ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , name ) ; goto cfg_mq_mode_fail ; } rc = hinic_set_port_mtu ( nic_dev -> hwdev , nic_dev -> mtu_size ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , nic_dev -> mtu_size , name ) ; goto set_mtu_fail ; } rc = hinic_rxtx_configure ( dev ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , name ) ; goto cfg_rxtx_fail ; } hinic_set_pf_status ( nic_dev -> hwdev -> hwif , HINIC_PF_STATUS_ACTIVE_FLAG ) ; rc = hinic_set_vport_enable ( nic_dev -> hwdev , true ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , name ) ; goto en_vport_fail ; } rc = hinic_set_port_enable ( nic_dev -> hwdev , true ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " " , name ) ; goto en_port_fail ; } if ( dev -> data -> dev_conf . intr_conf . lsc != 0 ) ( void ) hinic_link_update ( dev , 0 ) ; rte_bit_relaxed_set32 ( HINIC_DEV_START , & nic_dev -> dev_status ) ; return 0 ; en_port_fail : ( void ) hinic_set_vport_enable ( nic_dev -> hwdev , false ) ; en_vport_fail : hinic_set_pf_status ( nic_dev -> hwdev -> hwif , HINIC_PF_STATUS_INIT ) ; ( void ) hinic_flush_qp_res ( nic_dev -> hwdev ) ; rte_delay_ms ( 100 ) ; hinic_remove_rxtx_configure ( dev ) ; cfg_rxtx_fail : set_mtu_fail : cfg_mq_mode_fail : hinic_free_qp_ctxts ( nic_dev -> hwdev ) ; init_qp_fail : hinic_free_all_rx_mbuf ( dev ) ; hinic_free_all_tx_mbuf ( dev ) ; return rc ; }
DPDK callback to start the device.
DPDK callback to start the device .
/* reset rx and tx queue */ /* get func rx buf size */ /* init txq and rxq context */ /* rss template */ /* set default mtu */ /* configure rss rx_mode and other rx or tx default feature */ /* reactive pf status, so that uP report asyn event */ /* open virtual port and ready to start packet receiving */ /* open physical port and start packet receiving */ /* update eth_dev link status */ /* Flush tx && rx chip resources in case of set vport fake fail */