openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/route/qdisc/tbf.c
int rtnl_qdisc_tbf_set_limit_by_latency(struct rtnl_qdisc* qdisc, int latency)
{
    struct rtnl_tbf* tbf;
    double limit, limit2;

    if (!(tbf = rtnl_tc_data(TC_CAST(qdisc))))
        BUG();

    if (!(tbf->qt_mask & TBF_ATTR_RATE))
        return -NLE_MISSING_ATTR;

    limit = calc_limit(&tbf->qt_rate, latency, tbf->qt_rate_bucket);

    if (tbf->qt_mask & TBF_ATTR_PEAKRATE)
    {
        limit2 =
            calc_limit(&tbf->qt_peakrate, latency, tbf->qt_peakrate_bucket);

        if (limit2 < limit)
            limit = limit2;
    }

    rtnl_qdisc_tbf_set_limit(qdisc, (int)limit);

    return 0;
}
/**
 * Set limit of TBF qdisc by latency.
 * @arg qdisc		TBF qdisc to be modified.
 * @arg latency		Latency in micro seconds.
 *
 * Calculates and sets the limit based on the desired latency and the
 * configured rate and peak rate. In order for this operation to succeed,
 * the rate and if required the peak rate must have been set in advance.
 *
 * @f[
 *   limit_n = \frac{{rate_n} \times {latency}}{10^6}+{bucketsize}_n
 * @f]
 * @f[
 *   limit = min(limit_{rate},limit_{peak})
 * @f]
 *
 * @return 0 on success or a negative error code.
 */
Set limit of TBF qdisc by latency.
@arg qdisc           TBF qdisc to be modified.
@arg latency         Latency in micro seconds.

Calculates and sets the limit based on the desired latency and the
configured rate and peak rate. In order for this operation to succeed,
the rate and if required the peak rate must have been set in advance.



@return 0 on success or a negative error code.
Set limit of TBF qdisc by latency . @arg qdisc TBF qdisc to be modified . @arg latency Latency in micro seconds . Calculates and sets the limit based on the desired latency and the configured rate and peak rate . In order for this operation to succeed the rate and if required the peak rate must have been set in advance . @return 0 on success or a negative error code .
int rtnl_qdisc_tbf_set_limit_by_latency(struct rtnl_qdisc* qdisc, int latency)
{
    struct rtnl_tbf* tbf;
    double limit, limit2;
    if (!(tbf = rtnl_tc_data(TC_CAST(qdisc))))
        BUG();
    if (!(tbf->qt_mask & TBF_ATTR_RATE))
        return -NLE_MISSING_ATTR;
    limit = calc_limit(&tbf->qt_rate, latency, tbf->qt_rate_bucket);
    if (tbf->qt_mask & TBF_ATTR_PEAKRATE)
    {
        limit2 =
            calc_limit(&tbf->qt_peakrate, latency, tbf->qt_peakrate_bucket);
        if (limit2 < limit)
            limit = limit2;
    }
    rtnl_qdisc_tbf_set_limit(qdisc, (int)limit);
    return 0;
}
int rtnl_qdisc_tbf_set_limit_by_latency ( struct rtnl_qdisc * qdisc , int latency ) { struct rtnl_tbf * tbf ; double limit , limit2 ; if ( ! ( tbf = rtnl_tc_data ( TC_CAST ( qdisc ) ) ) ) BUG ( ) ; if ( ! ( tbf -> qt_mask & TBF_ATTR_RATE ) ) return - NLE_MISSING_ATTR ; limit = calc_limit ( & tbf -> qt_rate , latency , tbf -> qt_rate_bucket ) ; if ( tbf -> qt_mask & TBF_ATTR_PEAKRATE ) { limit2 = calc_limit ( & tbf -> qt_peakrate , latency , tbf -> qt_peakrate_bucket ) ; if ( limit2 < limit ) limit = limit2 ; } rtnl_qdisc_tbf_set_limit ( qdisc , ( int ) limit ) ; return 0 ; }
Set limit of TBF qdisc by latency.
Set limit of TBF qdisc by latency .