src/dpdk/drivers/net/bnxt/bnxt_hwrm.c
int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
	void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata,
	int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic))
{
	struct bnxt_vnic_info vnic;
	int rc = 0;
	int i, num_vnic_ids;
	uint16_t *vnic_ids;
	size_t vnic_id_sz;
	size_t sz;

	/* First query all VNIC ids */
	vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
	vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
			RTE_CACHE_LINE_SIZE);
	if (vnic_ids == NULL)
		return -ENOMEM;

	for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
		rte_mem_lock_page(((char *)vnic_ids) + sz);

	num_vnic_ids = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);

	if (num_vnic_ids < 0)
		return num_vnic_ids;

	/* Retrieve VNIC, update bd_stall then update */

	for (i = 0; i < num_vnic_ids; i++) {
		memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
		vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
		rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf);
		if (rc)
			break;
		if (vnic.mru <= 4)	/* Indicates unallocated */
			continue;

		vnic_cb(&vnic, cbdata);

		rc = hwrm_cb(bp, &vnic);
		if (rc)
			break;
	}

	rte_free(vnic_ids);

	return rc;
}
/*
 * This function queries the VNIC IDs  for a specified VF. It then calls
 * the vnic_cb to update the necessary field in vnic_info with cbdata.
 * Then it calls the hwrm_cb function to program this new vnic configuration.
 */
This function queries the VNIC IDs  for a specified VF. It then calls
the vnic_cb to update the necessary field in vnic_info with cbdata.
Then it calls the hwrm_cb function to program this new vnic configuration.
This function queries the VNIC IDs for a specified VF . It then calls the vnic_cb to update the necessary field in vnic_info with cbdata . Then it calls the hwrm_cb function to program this new vnic configuration .
int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
	void (*vnic_cb)(struct bnxt_vnic_info *, void *), void *cbdata,
	int (*hwrm_cb)(struct bnxt *bp, struct bnxt_vnic_info *vnic))
{
	struct bnxt_vnic_info vnic;
	int rc = 0;
	int i, num_vnic_ids;
	uint16_t *vnic_ids;
	size_t vnic_id_sz;
	size_t sz;
	vnic_id_sz = bp->pf->total_vnics * sizeof(*vnic_ids);
	vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
			RTE_CACHE_LINE_SIZE);
	if (vnic_ids == NULL)
		return -ENOMEM;
	for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
		rte_mem_lock_page(((char *)vnic_ids) + sz);
	num_vnic_ids = bnxt_hwrm_func_vf_vnic_query(bp, vf, vnic_ids);
	if (num_vnic_ids < 0)
		return num_vnic_ids;
	for (i = 0; i < num_vnic_ids; i++) {
		memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
		vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
		rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf);
		if (rc)
			break;
		if (vnic.mru <= 4)	
			continue;
		vnic_cb(&vnic, cbdata);
		rc = hwrm_cb(bp, &vnic);
		if (rc)
			break;
	}
	rte_free(vnic_ids);
	return rc;
}
int bnxt_hwrm_func_vf_vnic_query_and_config ( struct bnxt * bp , uint16_t vf , void ( * vnic_cb ) ( struct bnxt_vnic_info * , void * ) , void * cbdata , int ( * hwrm_cb ) ( struct bnxt * bp , struct bnxt_vnic_info * vnic ) ) { struct bnxt_vnic_info vnic ; int rc = 0 ; int i , num_vnic_ids ; uint16_t * vnic_ids ; size_t vnic_id_sz ; size_t sz ; vnic_id_sz = bp -> pf -> total_vnics * sizeof ( * vnic_ids ) ; vnic_ids = rte_malloc ( " " , vnic_id_sz , RTE_CACHE_LINE_SIZE ) ; if ( vnic_ids == NULL ) return - ENOMEM ; for ( sz = 0 ; sz < vnic_id_sz ; sz += getpagesize ( ) ) rte_mem_lock_page ( ( ( char * ) vnic_ids ) + sz ) ; num_vnic_ids = bnxt_hwrm_func_vf_vnic_query ( bp , vf , vnic_ids ) ; if ( num_vnic_ids < 0 ) return num_vnic_ids ; for ( i = 0 ; i < num_vnic_ids ; i ++ ) { memset ( & vnic , 0 , sizeof ( struct bnxt_vnic_info ) ) ; vnic . fw_vnic_id = rte_le_to_cpu_16 ( vnic_ids [ i ] ) ; rc = bnxt_hwrm_vnic_qcfg ( bp , & vnic , bp -> pf -> first_vf_id + vf ) ; if ( rc ) break ; if ( vnic . mru <= 4 ) continue ; vnic_cb ( & vnic , cbdata ) ; rc = hwrm_cb ( bp , & vnic ) ; if ( rc ) break ; } rte_free ( vnic_ids ) ; return rc ; }
This function queries the VNIC IDs  for a specified VF.
This function queries the VNIC IDs for a specified VF .
/* First query all VNIC ids */ /* Retrieve VNIC, update bd_stall then update */ /* Indicates unallocated */