src/dpdk/drivers/net/ice/base/ice_sched.c
static enum ice_status
ice_sched_bw_to_rl_profile(struct ice_hw *hw, u32 bw,
			   struct ice_aqc_rl_profile_elem *profile)
{
	enum ice_status status = ICE_ERR_PARAM;
	s64 bytes_per_sec, ts_rate, mv_tmp;
	bool found = false;
	s32 encode = 0;
	s64 mv = 0;
	s32 i;

	/* Bw settings range is from 0.5Mb/sec to 100Gb/sec */
	if (bw < ICE_SCHED_MIN_BW || bw > ICE_SCHED_MAX_BW)
		return status;

	/* Bytes per second from Kbps */
	bytes_per_sec = DIV_64BIT(((s64)bw * 1000), BITS_PER_BYTE);

	/* encode is 6 bits but really useful are 5 bits */
	for (i = 0; i < 64; i++) {
		u64 pow_result = BIT_ULL(i);

		ts_rate = DIV_64BIT((s64)hw->psm_clk_freq,
				    pow_result * ICE_RL_PROF_TS_MULTIPLIER);
		if (ts_rate <= 0)
			continue;

		/* Multiplier value */
		mv_tmp = DIV_64BIT(bytes_per_sec * ICE_RL_PROF_MULTIPLIER,
				   ts_rate);

		/* Round to the nearest ICE_RL_PROF_MULTIPLIER */
		mv = round_up_64bit(mv_tmp, ICE_RL_PROF_MULTIPLIER);

		/* First multiplier value greater than the given
		 * accuracy bytes
		 */
		if (mv > ICE_RL_PROF_ACCURACY_BYTES) {
			encode = i;
			found = true;
			break;
		}
	}
	if (found) {
		u16 wm;

		wm = ice_sched_calc_wakeup(hw, bw);
		profile->rl_multiply = CPU_TO_LE16(mv);
		profile->wake_up_calc = CPU_TO_LE16(wm);
		profile->rl_encode = CPU_TO_LE16(encode);
		status = ICE_SUCCESS;
	} else {
		status = ICE_ERR_DOES_NOT_EXIST;
	}

	return status;
}
/**
 * ice_sched_bw_to_rl_profile - convert BW to profile parameters
 * @hw: pointer to the HW struct
 * @bw: bandwidth in Kbps
 * @profile: profile parameters to return
 *
 * This function converts the BW to profile structure format.
 */
convert BW to profile parameters
@hw: pointer to the HW struct
@bw: bandwidth in Kbps
@profile: profile parameters to return

This function converts the BW to profile structure format.
convert BW to profile parameters @hw : pointer to the HW struct @bw : bandwidth in Kbps @profile : profile parameters to return This function converts the BW to profile structure format .
static enum ice_status
ice_sched_bw_to_rl_profile(struct ice_hw *hw, u32 bw,
			   struct ice_aqc_rl_profile_elem *profile)
{
	enum ice_status status = ICE_ERR_PARAM;
	s64 bytes_per_sec, ts_rate, mv_tmp;
	bool found = false;
	s32 encode = 0;
	s64 mv = 0;
	s32 i;
	if (bw < ICE_SCHED_MIN_BW || bw > ICE_SCHED_MAX_BW)
		return status;
	bytes_per_sec = DIV_64BIT(((s64)bw * 1000), BITS_PER_BYTE);
	for (i = 0; i < 64; i++) {
		u64 pow_result = BIT_ULL(i);
		ts_rate = DIV_64BIT((s64)hw->psm_clk_freq,
				    pow_result * ICE_RL_PROF_TS_MULTIPLIER);
		if (ts_rate <= 0)
			continue;
		mv_tmp = DIV_64BIT(bytes_per_sec * ICE_RL_PROF_MULTIPLIER,
				   ts_rate);
		mv = round_up_64bit(mv_tmp, ICE_RL_PROF_MULTIPLIER);
		if (mv > ICE_RL_PROF_ACCURACY_BYTES) {
			encode = i;
			found = true;
			break;
		}
	}
	if (found) {
		u16 wm;
		wm = ice_sched_calc_wakeup(hw, bw);
		profile->rl_multiply = CPU_TO_LE16(mv);
		profile->wake_up_calc = CPU_TO_LE16(wm);
		profile->rl_encode = CPU_TO_LE16(encode);
		status = ICE_SUCCESS;
	} else {
		status = ICE_ERR_DOES_NOT_EXIST;
	}
	return status;
}
static enum ice_status ice_sched_bw_to_rl_profile ( struct ice_hw * hw , u32 bw , struct ice_aqc_rl_profile_elem * profile ) { enum ice_status status = ICE_ERR_PARAM ; s64 bytes_per_sec , ts_rate , mv_tmp ; bool found = false ; s32 encode = 0 ; s64 mv = 0 ; s32 i ; if ( bw < ICE_SCHED_MIN_BW || bw > ICE_SCHED_MAX_BW ) return status ; bytes_per_sec = DIV_64BIT ( ( ( s64 ) bw * 1000 ) , BITS_PER_BYTE ) ; for ( i = 0 ; i < 64 ; i ++ ) { u64 pow_result = BIT_ULL ( i ) ; ts_rate = DIV_64BIT ( ( s64 ) hw -> psm_clk_freq , pow_result * ICE_RL_PROF_TS_MULTIPLIER ) ; if ( ts_rate <= 0 ) continue ; mv_tmp = DIV_64BIT ( bytes_per_sec * ICE_RL_PROF_MULTIPLIER , ts_rate ) ; mv = round_up_64bit ( mv_tmp , ICE_RL_PROF_MULTIPLIER ) ; if ( mv > ICE_RL_PROF_ACCURACY_BYTES ) { encode = i ; found = true ; break ; } } if ( found ) { u16 wm ; wm = ice_sched_calc_wakeup ( hw , bw ) ; profile -> rl_multiply = CPU_TO_LE16 ( mv ) ; profile -> wake_up_calc = CPU_TO_LE16 ( wm ) ; profile -> rl_encode = CPU_TO_LE16 ( encode ) ; status = ICE_SUCCESS ; } else { status = ICE_ERR_DOES_NOT_EXIST ; } return status ; }
ice_sched_bw_to_rl_profile - convert BW to profile parameters
 @hw: pointer to the HW struct
 @bw: bandwidth in Kbps
 @profile: profile parameters to return
ice_sched_bw_to_rl_profile - convert BW to profile parameters @hw : pointer to the HW struct @bw : bandwidth in Kbps @profile : profile parameters to return
/* Bw settings range is from 0.5Mb/sec to 100Gb/sec */ /* Bytes per second from Kbps */ /* encode is 6 bits but really useful are 5 bits */ /* Multiplier value */ /* Round to the nearest ICE_RL_PROF_MULTIPLIER */ /* First multiplier value greater than the given
		 * accuracy bytes
		 */