On Tue, Feb 22, 2022 at 11:49 PM Nithin Kumar Dabilpuram
<ndabilpu...@marvell.com> wrote:
>
> Please see inline.
>
> On 2/17/22 6:50 PM, Jerin Jacob wrote:
> > On Mon, Feb 7, 2022 at 1:00 PM Nithin Dabilpuram
> > <ndabilpu...@marvell.com> wrote:
> >>
> >> From: Satha Rao <skotesh...@marvell.com>
> >>
> >> New api to get floor values for a requested shaper rate, which can assure
> >
> > Since it is internal API, no need to mention in the comment log
> >
> >> packets should never be transmitted at a rate higher than configured.
> >>
> >> Keep the old api to get HW suggested values.
> >> And introduce new parameter to select appropriate api.
> >
> > api -> API
> >
> >>
> >> Signed-off-by: Satha Rao <skotesh...@marvell.com>
> >> ---
> >> +static uint64_t
> >> +nix_tm_shaper_rate_conv_floor(uint64_t value, uint64_t *exponent_p,
> >> +                             uint64_t *mantissa_p, uint64_t *div_exp_p)
> >> +{
> >> +       uint64_t div_exp, exponent, mantissa;
> >> +
> >> +       /* Boundary checks */
> >> +       if (value < NIX_TM_MIN_SHAPER_RATE || value > 
> >> NIX_TM_MAX_SHAPER_RATE)
> >> +               return 0;
> >> +
> >> +       if (value <= NIX_TM_SHAPER_RATE(0, 0, 0)) {
> >> +               /* Calculate rate div_exp and mantissa using
> >> +                * the following formula:
> >> +                *
> >> +                * value = (2E6 * (256 + mantissa)
> >> +                *              / ((1 << div_exp) * 256))
> >> +                */
> >> +               div_exp = 0;
> >> +               exponent = 0;
> >> +               mantissa = NIX_TM_MAX_RATE_MANTISSA;
> >> +
> >> +               while (value <= (NIX_TM_SHAPER_RATE_CONST / (1 << 
> >> div_exp)))
> >> +                       div_exp += 1;
> >> +
> >> +               while (value <= ((NIX_TM_SHAPER_RATE_CONST * (256 + 
> >> mantissa)) /
> >> +                                ((1 << div_exp) * 256)))
> >> +                       mantissa -= 1;
> >
> > Please move this as another static function.
> This is not same as the non-floor function though it looks same. The
> while loops terminate in <= in this function. Do you still need sub
> functions for these ?

No. It is fine.

> >
> >
> >> +       } else {
> >> +               /* Calculate rate exponent and mantissa using
> >> +                * the following formula:
> >> +                *
> >> +                * value = (2E6 * ((256 + mantissa) << exponent)) / 256
> >> +                *
> >> +                */
> >> +               div_exp = 0;
> >> +               exponent = NIX_TM_MAX_RATE_EXPONENT;
> >> +               mantissa = NIX_TM_MAX_RATE_MANTISSA;
> >> +
> >> +               while (value <= (NIX_TM_SHAPER_RATE_CONST * (1 << 
> >> exponent)))
> >> +                       exponent -= 1;
> >> +
> >> +               while (value <= ((NIX_TM_SHAPER_RATE_CONST *
> >> +                                 ((256 + mantissa) << exponent)) /
> >> +                                256))
> >> +                       mantissa -= 1;
> >
> > Please move this as another static function.
> Same comment as above.
> >
> >> +       }
> >> +
> >> +       if (div_exp > NIX_TM_MAX_RATE_DIV_EXP ||
> >> +           exponent > NIX_TM_MAX_RATE_EXPONENT ||
> >> +           mantissa > NIX_TM_MAX_RATE_MANTISSA)
> >> +               return 0;
> >> +
> >> +       if (div_exp_p)
> >> +               *div_exp_p = div_exp;
> >> +       if (exponent_p)
> >> +               *exponent_p = exponent;
> >> +       if (mantissa_p)
> >> +               *mantissa_p = mantissa;
> >> +
> >> +       /* Calculate real rate value */
> >> +       return NIX_TM_SHAPER_RATE(exponent, mantissa, div_exp);
> >> +}
> >> +
> >> +static uint64_t
> >> +nix_tm_shaper_rate_conv_exact(uint64_t value, uint64_t *exponent_p,
> >> +                             uint64_t *mantissa_p, uint64_t *div_exp_p)
> >>   {
> >>          uint64_t div_exp, exponent, mantissa;
> >>
> >> @@ -188,6 +251,23 @@ nix_tm_shaper_rate_conv(uint64_t value, uint64_t 
> >> *exponent_p,
> >>          return NIX_TM_SHAPER_RATE(exponent, mantissa, div_exp);
> >>   }
> >>
> >> +/* With zero accuracy we will tune parameters as defined by HW,
> >> + * non zero accuracy will keep the parameters close to lower values
> >> + * and make sure long term shaper rate will not exceed requested rate.
> >
> > long-term
> > requested -> the requested

Reply via email to