src/dpdk/drivers/net/bnxt/bnxt_ethdev.c
static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
{
	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
	struct bnxt *bp = eth_dev->data->dev_private;
	int rc = 0;

	bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE;

	if (bnxt_vf_pciid(pci_dev->id.device_id))
		bp->flags |= BNXT_FLAG_VF;

	if (bnxt_p5_device(pci_dev->id.device_id))
		bp->flags |= BNXT_FLAG_CHIP_P5;

	if (pci_dev->id.device_id == BROADCOM_DEV_ID_58802 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58804 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58808 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF)
		bp->flags |= BNXT_FLAG_STINGRAY;

	if (BNXT_TRUFLOW_EN(bp)) {
		/* extra mbuf field is required to store CFA code from mark */
		static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = {
			.name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME,
			.size = sizeof(bnxt_cfa_code_dynfield_t),
			.align = __alignof__(bnxt_cfa_code_dynfield_t),
		};
		bnxt_cfa_code_dynfield_offset =
			rte_mbuf_dynfield_register(&bnxt_cfa_code_dynfield_desc);
		if (bnxt_cfa_code_dynfield_offset < 0) {
			PMD_DRV_LOG(ERR,
			    "Failed to register mbuf field for TruFlow mark\n");
			return -rte_errno;
		}
	}

	rc = bnxt_map_pci_bars(eth_dev);
	if (rc) {
		PMD_DRV_LOG(ERR,
			    "Failed to initialize board rc: %x\n", rc);
		return rc;
	}

	rc = bnxt_alloc_pf_info(bp);
	if (rc)
		return rc;

	rc = bnxt_alloc_link_info(bp);
	if (rc)
		return rc;

	rc = bnxt_alloc_parent_info(bp);
	if (rc)
		return rc;

	rc = bnxt_alloc_hwrm_resources(bp);
	if (rc) {
		PMD_DRV_LOG(ERR,
			    "Failed to allocate hwrm resource rc: %x\n", rc);
		return rc;
	}
	rc = bnxt_alloc_leds_info(bp);
	if (rc)
		return rc;

	rc = bnxt_alloc_cos_queues(bp);
	if (rc)
		return rc;

	rc = bnxt_init_locks(bp);
	if (rc)
		return rc;

	rc = bnxt_alloc_switch_domain(bp);
	if (rc)
		return rc;

	return rc;
}
/* Allocate and initialize various fields in bnxt struct that
 * need to be allocated/destroyed only once in the lifetime of the driver
 */
Allocate and initialize various fields in bnxt struct that
need to be allocated/destroyed only once in the lifetime of the driver
Allocate and initialize various fields in bnxt struct that need to be allocated / destroyed only once in the lifetime of the driver
static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
{
	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
	struct bnxt *bp = eth_dev->data->dev_private;
	int rc = 0;
	bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE;
	if (bnxt_vf_pciid(pci_dev->id.device_id))
		bp->flags |= BNXT_FLAG_VF;
	if (bnxt_p5_device(pci_dev->id.device_id))
		bp->flags |= BNXT_FLAG_CHIP_P5;
	if (pci_dev->id.device_id == BROADCOM_DEV_ID_58802 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58804 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58808 ||
	    pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF)
		bp->flags |= BNXT_FLAG_STINGRAY;
	if (BNXT_TRUFLOW_EN(bp)) {
		static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = {
			.name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME,
			.size = sizeof(bnxt_cfa_code_dynfield_t),
			.align = __alignof__(bnxt_cfa_code_dynfield_t),
		};
		bnxt_cfa_code_dynfield_offset =
			rte_mbuf_dynfield_register(&bnxt_cfa_code_dynfield_desc);
		if (bnxt_cfa_code_dynfield_offset < 0) {
			PMD_DRV_LOG(ERR,
			    "Failed to register mbuf field for TruFlow mark\n");
			return -rte_errno;
		}
	}
	rc = bnxt_map_pci_bars(eth_dev);
	if (rc) {
		PMD_DRV_LOG(ERR,
			    "Failed to initialize board rc: %x\n", rc);
		return rc;
	}
	rc = bnxt_alloc_pf_info(bp);
	if (rc)
		return rc;
	rc = bnxt_alloc_link_info(bp);
	if (rc)
		return rc;
	rc = bnxt_alloc_parent_info(bp);
	if (rc)
		return rc;
	rc = bnxt_alloc_hwrm_resources(bp);
	if (rc) {
		PMD_DRV_LOG(ERR,
			    "Failed to allocate hwrm resource rc: %x\n", rc);
		return rc;
	}
	rc = bnxt_alloc_leds_info(bp);
	if (rc)
		return rc;
	rc = bnxt_alloc_cos_queues(bp);
	if (rc)
		return rc;
	rc = bnxt_init_locks(bp);
	if (rc)
		return rc;
	rc = bnxt_alloc_switch_domain(bp);
	if (rc)
		return rc;
	return rc;
}
static int bnxt_drv_init ( struct rte_eth_dev * eth_dev ) { struct rte_pci_device * pci_dev = RTE_ETH_DEV_TO_PCI ( eth_dev ) ; struct bnxt * bp = eth_dev -> data -> dev_private ; int rc = 0 ; bp -> flags &= ~ BNXT_FLAG_RX_VECTOR_PKT_MODE ; if ( bnxt_vf_pciid ( pci_dev -> id . device_id ) ) bp -> flags |= BNXT_FLAG_VF ; if ( bnxt_p5_device ( pci_dev -> id . device_id ) ) bp -> flags |= BNXT_FLAG_CHIP_P5 ; if ( pci_dev -> id . device_id == BROADCOM_DEV_ID_58802 || pci_dev -> id . device_id == BROADCOM_DEV_ID_58804 || pci_dev -> id . device_id == BROADCOM_DEV_ID_58808 || pci_dev -> id . device_id == BROADCOM_DEV_ID_58802_VF ) bp -> flags |= BNXT_FLAG_STINGRAY ; if ( BNXT_TRUFLOW_EN ( bp ) ) { static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = { . name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME , . size = sizeof ( bnxt_cfa_code_dynfield_t ) , . align = __alignof__ ( bnxt_cfa_code_dynfield_t ) , } ; bnxt_cfa_code_dynfield_offset = rte_mbuf_dynfield_register ( & bnxt_cfa_code_dynfield_desc ) ; if ( bnxt_cfa_code_dynfield_offset < 0 ) { PMD_DRV_LOG ( ERR , " \n " ) ; return - rte_errno ; } } rc = bnxt_map_pci_bars ( eth_dev ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " \n " , rc ) ; return rc ; } rc = bnxt_alloc_pf_info ( bp ) ; if ( rc ) return rc ; rc = bnxt_alloc_link_info ( bp ) ; if ( rc ) return rc ; rc = bnxt_alloc_parent_info ( bp ) ; if ( rc ) return rc ; rc = bnxt_alloc_hwrm_resources ( bp ) ; if ( rc ) { PMD_DRV_LOG ( ERR , " \n " , rc ) ; return rc ; } rc = bnxt_alloc_leds_info ( bp ) ; if ( rc ) return rc ; rc = bnxt_alloc_cos_queues ( bp ) ; if ( rc ) return rc ; rc = bnxt_init_locks ( bp ) ; if ( rc ) return rc ; rc = bnxt_alloc_switch_domain ( bp ) ; if ( rc ) return rc ; return rc ; }
Allocate and initialize various fields in bnxt struct that
 need to be allocated/destroyed only once in the lifetime of the driver
Allocate and initialize various fields in bnxt struct that need to be allocated / destroyed only once in the lifetime of the driver
/* extra mbuf field is required to store CFA code from mark */