src/dpdk/drivers/net/i40e/rte_pmd_i40e.c
static int
i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
{
	struct rte_eth_dev *dev = &rte_eth_devices[port];
	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	uint8_t *buff;
	struct rte_pmd_i40e_profile_list *p_list;
	struct rte_pmd_i40e_profile_info *pinfo, *p;
	uint32_t i;
	int ret;
	static const uint32_t group_mask = 0x00ff0000;

	pinfo = (struct rte_pmd_i40e_profile_info *)(profile_info_sec +
			     sizeof(struct i40e_profile_section_header));
	if (pinfo->track_id == 0) {
		PMD_DRV_LOG(INFO, "Read-only profile.");
		return 0;
	}
	buff = rte_zmalloc("pinfo_list",
			   (I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4),
			   0);
	if (!buff) {
		PMD_DRV_LOG(ERR, "failed to allocate memory");
		return -1;
	}

	ret = i40e_aq_get_ddp_list(
		hw, (void *)buff,
		(I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4),
		0, NULL);
	if (ret) {
		PMD_DRV_LOG(ERR, "Failed to get profile info list.");
		rte_free(buff);
		return -1;
	}
	p_list = (struct rte_pmd_i40e_profile_list *)buff;
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if (pinfo->track_id == p->track_id) {
			PMD_DRV_LOG(INFO, "Profile exists.");
			rte_free(buff);
			return 1;
		}
	}
	/* profile with group id 0xff is compatible with any other profile */
	if ((pinfo->track_id & group_mask) == group_mask) {
		rte_free(buff);
		return 0;
	}
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if ((p->track_id & group_mask) == 0) {
			PMD_DRV_LOG(INFO, "Profile of the group 0 exists.");
			rte_free(buff);
			return 2;
		}
	}
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if ((p->track_id & group_mask) == group_mask)
			continue;
		if ((pinfo->track_id & group_mask) !=
		    (p->track_id & group_mask)) {
			PMD_DRV_LOG(INFO, "Profile of different group exists.");
			rte_free(buff);
			return 3;
		}
	}

	rte_free(buff);
	return 0;
}
/* Check if the profile info exists */
Check if the profile info exists
Check if the profile info exists
static int
i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
{
	struct rte_eth_dev *dev = &rte_eth_devices[port];
	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
	uint8_t *buff;
	struct rte_pmd_i40e_profile_list *p_list;
	struct rte_pmd_i40e_profile_info *pinfo, *p;
	uint32_t i;
	int ret;
	static const uint32_t group_mask = 0x00ff0000;
	pinfo = (struct rte_pmd_i40e_profile_info *)(profile_info_sec +
			     sizeof(struct i40e_profile_section_header));
	if (pinfo->track_id == 0) {
		PMD_DRV_LOG(INFO, "Read-only profile.");
		return 0;
	}
	buff = rte_zmalloc("pinfo_list",
			   (I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4),
			   0);
	if (!buff) {
		PMD_DRV_LOG(ERR, "failed to allocate memory");
		return -1;
	}
	ret = i40e_aq_get_ddp_list(
		hw, (void *)buff,
		(I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4),
		0, NULL);
	if (ret) {
		PMD_DRV_LOG(ERR, "Failed to get profile info list.");
		rte_free(buff);
		return -1;
	}
	p_list = (struct rte_pmd_i40e_profile_list *)buff;
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if (pinfo->track_id == p->track_id) {
			PMD_DRV_LOG(INFO, "Profile exists.");
			rte_free(buff);
			return 1;
		}
	}
	if ((pinfo->track_id & group_mask) == group_mask) {
		rte_free(buff);
		return 0;
	}
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if ((p->track_id & group_mask) == 0) {
			PMD_DRV_LOG(INFO, "Profile of the group 0 exists.");
			rte_free(buff);
			return 2;
		}
	}
	for (i = 0; i < p_list->p_count; i++) {
		p = &p_list->p_info[i];
		if ((p->track_id & group_mask) == group_mask)
			continue;
		if ((pinfo->track_id & group_mask) !=
		    (p->track_id & group_mask)) {
			PMD_DRV_LOG(INFO, "Profile of different group exists.");
			rte_free(buff);
			return 3;
		}
	}
	rte_free(buff);
	return 0;
}
static int i40e_check_profile_info ( uint16_t port , uint8_t * profile_info_sec ) { struct rte_eth_dev * dev = & rte_eth_devices [ port ] ; struct i40e_hw * hw = I40E_DEV_PRIVATE_TO_HW ( dev -> data -> dev_private ) ; uint8_t * buff ; struct rte_pmd_i40e_profile_list * p_list ; struct rte_pmd_i40e_profile_info * pinfo , * p ; uint32_t i ; int ret ; static const uint32_t group_mask = 0x00ff0000 ; pinfo = ( struct rte_pmd_i40e_profile_info * ) ( profile_info_sec + sizeof ( struct i40e_profile_section_header ) ) ; if ( pinfo -> track_id == 0 ) { PMD_DRV_LOG ( INFO , " " ) ; return 0 ; } buff = rte_zmalloc ( " " , ( I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4 ) , 0 ) ; if ( ! buff ) { PMD_DRV_LOG ( ERR , " " ) ; return -1 ; } ret = i40e_aq_get_ddp_list ( hw , ( void * ) buff , ( I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4 ) , 0 , NULL ) ; if ( ret ) { PMD_DRV_LOG ( ERR , " " ) ; rte_free ( buff ) ; return -1 ; } p_list = ( struct rte_pmd_i40e_profile_list * ) buff ; for ( i = 0 ; i < p_list -> p_count ; i ++ ) { p = & p_list -> p_info [ i ] ; if ( pinfo -> track_id == p -> track_id ) { PMD_DRV_LOG ( INFO , " " ) ; rte_free ( buff ) ; return 1 ; } } if ( ( pinfo -> track_id & group_mask ) == group_mask ) { rte_free ( buff ) ; return 0 ; } for ( i = 0 ; i < p_list -> p_count ; i ++ ) { p = & p_list -> p_info [ i ] ; if ( ( p -> track_id & group_mask ) == 0 ) { PMD_DRV_LOG ( INFO , " " ) ; rte_free ( buff ) ; return 2 ; } } for ( i = 0 ; i < p_list -> p_count ; i ++ ) { p = & p_list -> p_info [ i ] ; if ( ( p -> track_id & group_mask ) == group_mask ) continue ; if ( ( pinfo -> track_id & group_mask ) != ( p -> track_id & group_mask ) ) { PMD_DRV_LOG ( INFO , " " ) ; rte_free ( buff ) ; return 3 ; } } rte_free ( buff ) ; return 0 ; }
Check if the profile info exists
Check if the profile info exists
/* profile with group id 0xff is compatible with any other profile */