src/dpdk/drivers/net/ice/base/ice_sched.c
static struct ice_aqc_rl_profile_info *
ice_sched_add_rl_profile(struct ice_hw *hw, enum ice_rl_type rl_type,
			 u32 bw, u8 layer_num)
{
	struct ice_aqc_rl_profile_info *rl_prof_elem;
	u16 profiles_added = 0, num_profiles = 1;
	struct ice_aqc_rl_profile_elem *buf;
	enum ice_status status;
	u8 profile_type;

	if (layer_num >= ICE_AQC_TOPO_MAX_LEVEL_NUM)
		return NULL;
	switch (rl_type) {
	case ICE_MIN_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_CIR;
		break;
	case ICE_MAX_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_EIR;
		break;
	case ICE_SHARED_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_SRL;
		break;
	default:
		return NULL;
	}

	if (!hw)
		return NULL;
	LIST_FOR_EACH_ENTRY(rl_prof_elem, &hw->rl_prof_list[layer_num],
			    ice_aqc_rl_profile_info, list_entry)
		if ((rl_prof_elem->profile.flags & ICE_AQC_RL_PROFILE_TYPE_M) ==
		    profile_type && rl_prof_elem->bw == bw)
			/* Return existing profile ID info */
			return rl_prof_elem;

	/* Create new profile ID */
	rl_prof_elem = (struct ice_aqc_rl_profile_info *)
		ice_malloc(hw, sizeof(*rl_prof_elem));

	if (!rl_prof_elem)
		return NULL;

	status = ice_sched_bw_to_rl_profile(hw, bw, &rl_prof_elem->profile);
	if (status != ICE_SUCCESS)
		goto exit_add_rl_prof;

	rl_prof_elem->bw = bw;
	/* layer_num is zero relative, and fw expects level from 1 to 9 */
	rl_prof_elem->profile.level = layer_num + 1;
	rl_prof_elem->profile.flags = profile_type;
	rl_prof_elem->profile.max_burst_size = CPU_TO_LE16(hw->max_burst_size);

	/* Create new entry in HW DB */
	buf = &rl_prof_elem->profile;
	status = ice_aq_add_rl_profile(hw, num_profiles, buf, sizeof(*buf),
				       &profiles_added, NULL);
	if (status || profiles_added != num_profiles)
		goto exit_add_rl_prof;

	/* Good entry - add in the list */
	rl_prof_elem->prof_id_ref = 0;
	LIST_ADD(&rl_prof_elem->list_entry, &hw->rl_prof_list[layer_num]);
	return rl_prof_elem;

exit_add_rl_prof:
	ice_free(hw, rl_prof_elem);
	return NULL;
}
/**
 * ice_sched_add_rl_profile - add RL profile
 * @hw: pointer to the hardware structure
 * @rl_type: type of rate limit BW - min, max, or shared
 * @bw: bandwidth in Kbps - Kilo bits per sec
 * @layer_num: specifies in which layer to create profile
 *
 * This function first checks the existing list for corresponding BW
 * parameter. If it exists, it returns the associated profile otherwise
 * it creates a new rate limit profile for requested BW, and adds it to
 * the HW DB and local list. It returns the new profile or null on error.
 * The caller needs to hold the scheduler lock.
 */
add RL profile
@hw: pointer to the hardware structure
@rl_type: type of rate limit BW - min, max, or shared
@bw: bandwidth in Kbps - Kilo bits per sec
@layer_num: specifies in which layer to create profile

This function first checks the existing list for corresponding BW
parameter. If it exists, it returns the associated profile otherwise
it creates a new rate limit profile for requested BW, and adds it to
the HW DB and local list. It returns the new profile or null on error.
The caller needs to hold the scheduler lock.
add RL profile @hw : pointer to the hardware structure @rl_type : type of rate limit BW - min max or shared @bw : bandwidth in Kbps - Kilo bits per sec @layer_num : specifies in which layer to create profile This function first checks the existing list for corresponding BW parameter . If it exists it returns the associated profile otherwise it creates a new rate limit profile for requested BW and adds it to the HW DB and local list . It returns the new profile or null on error . The caller needs to hold the scheduler lock .
static struct ice_aqc_rl_profile_info *
ice_sched_add_rl_profile(struct ice_hw *hw, enum ice_rl_type rl_type,
			 u32 bw, u8 layer_num)
{
	struct ice_aqc_rl_profile_info *rl_prof_elem;
	u16 profiles_added = 0, num_profiles = 1;
	struct ice_aqc_rl_profile_elem *buf;
	enum ice_status status;
	u8 profile_type;
	if (layer_num >= ICE_AQC_TOPO_MAX_LEVEL_NUM)
		return NULL;
	switch (rl_type) {
	case ICE_MIN_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_CIR;
		break;
	case ICE_MAX_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_EIR;
		break;
	case ICE_SHARED_BW:
		profile_type = ICE_AQC_RL_PROFILE_TYPE_SRL;
		break;
	default:
		return NULL;
	}
	if (!hw)
		return NULL;
	LIST_FOR_EACH_ENTRY(rl_prof_elem, &hw->rl_prof_list[layer_num],
			    ice_aqc_rl_profile_info, list_entry)
		if ((rl_prof_elem->profile.flags & ICE_AQC_RL_PROFILE_TYPE_M) ==
		    profile_type && rl_prof_elem->bw == bw)
			return rl_prof_elem;
	rl_prof_elem = (struct ice_aqc_rl_profile_info *)
		ice_malloc(hw, sizeof(*rl_prof_elem));
	if (!rl_prof_elem)
		return NULL;
	status = ice_sched_bw_to_rl_profile(hw, bw, &rl_prof_elem->profile);
	if (status != ICE_SUCCESS)
		goto exit_add_rl_prof;
	rl_prof_elem->bw = bw;
	rl_prof_elem->profile.level = layer_num + 1;
	rl_prof_elem->profile.flags = profile_type;
	rl_prof_elem->profile.max_burst_size = CPU_TO_LE16(hw->max_burst_size);
	buf = &rl_prof_elem->profile;
	status = ice_aq_add_rl_profile(hw, num_profiles, buf, sizeof(*buf),
				       &profiles_added, NULL);
	if (status || profiles_added != num_profiles)
		goto exit_add_rl_prof;
	rl_prof_elem->prof_id_ref = 0;
	LIST_ADD(&rl_prof_elem->list_entry, &hw->rl_prof_list[layer_num]);
	return rl_prof_elem;
exit_add_rl_prof:
	ice_free(hw, rl_prof_elem);
	return NULL;
}
static struct ice_aqc_rl_profile_info * ice_sched_add_rl_profile ( struct ice_hw * hw , enum ice_rl_type rl_type , u32 bw , u8 layer_num ) { struct ice_aqc_rl_profile_info * rl_prof_elem ; u16 profiles_added = 0 , num_profiles = 1 ; struct ice_aqc_rl_profile_elem * buf ; enum ice_status status ; u8 profile_type ; if ( layer_num >= ICE_AQC_TOPO_MAX_LEVEL_NUM ) return NULL ; switch ( rl_type ) { case ICE_MIN_BW : profile_type = ICE_AQC_RL_PROFILE_TYPE_CIR ; break ; case ICE_MAX_BW : profile_type = ICE_AQC_RL_PROFILE_TYPE_EIR ; break ; case ICE_SHARED_BW : profile_type = ICE_AQC_RL_PROFILE_TYPE_SRL ; break ; default : return NULL ; } if ( ! hw ) return NULL ; LIST_FOR_EACH_ENTRY ( rl_prof_elem , & hw -> rl_prof_list [ layer_num ] , ice_aqc_rl_profile_info , list_entry ) if ( ( rl_prof_elem -> profile . flags & ICE_AQC_RL_PROFILE_TYPE_M ) == profile_type && rl_prof_elem -> bw == bw ) return rl_prof_elem ; rl_prof_elem = ( struct ice_aqc_rl_profile_info * ) ice_malloc ( hw , sizeof ( * rl_prof_elem ) ) ; if ( ! rl_prof_elem ) return NULL ; status = ice_sched_bw_to_rl_profile ( hw , bw , & rl_prof_elem -> profile ) ; if ( status != ICE_SUCCESS ) goto exit_add_rl_prof ; rl_prof_elem -> bw = bw ; rl_prof_elem -> profile . level = layer_num + 1 ; rl_prof_elem -> profile . flags = profile_type ; rl_prof_elem -> profile . max_burst_size = CPU_TO_LE16 ( hw -> max_burst_size ) ; buf = & rl_prof_elem -> profile ; status = ice_aq_add_rl_profile ( hw , num_profiles , buf , sizeof ( * buf ) , & profiles_added , NULL ) ; if ( status || profiles_added != num_profiles ) goto exit_add_rl_prof ; rl_prof_elem -> prof_id_ref = 0 ; LIST_ADD ( & rl_prof_elem -> list_entry , & hw -> rl_prof_list [ layer_num ] ) ; return rl_prof_elem ; exit_add_rl_prof : ice_free ( hw , rl_prof_elem ) ; return NULL ; }
ice_sched_add_rl_profile - add RL profile
 @hw: pointer to the hardware structure
 @rl_type: type of rate limit BW - min, max, or shared
 @bw: bandwidth in Kbps - Kilo bits per sec
 @layer_num: specifies in which layer to create profile
ice_sched_add_rl_profile - add RL profile @hw : pointer to the hardware structure @rl_type : type of rate limit BW - min max or shared @bw : bandwidth in Kbps - Kilo bits per sec @layer_num : specifies in which layer to create profile
/* Return existing profile ID info */ /* Create new profile ID */ /* layer_num is zero relative, and fw expects level from 1 to 9 */ /* Create new entry in HW DB */ /* Good entry - add in the list */