Beispiel #1
0
/* Adjust for the fact that psched_ticks aren't always usecs
   (based on kernel PSCHED_CLOCK configuration */
static int get_ticks(__u32 *ticks, const char *str)
{
    unsigned t;

    if(get_usecs(&t, str))
        return -1;

    *ticks = tc_core_usec2tick(t);
    return 0;
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
			     int ewma_log, unsigned minburst)
{
	double g = 1.0 - 1.0/(1<<ewma_log);
	double offtime = (double)avpkt/rate - (double)avpkt/bndw;

	if (minburst == 0)
		return 0;
	if (minburst == 1)
		offtime *= pow(g, -(double)minburst) - 1;
	else
		offtime *= 1 + (pow(g, -(double)(minburst-1)) - 1)/(1-g);
	return tc_core_usec2tick(offtime*1000000);
}
unsigned tc_cbq_calc_maxidle(unsigned bndw, unsigned rate, unsigned avpkt,
			     int ewma_log, unsigned maxburst)
{
	double maxidle;
	double g = 1.0 - 1.0/(1<<ewma_log);
	double xmt = (double)avpkt/bndw;

	maxidle = xmt*(1-g);
	if (bndw != rate && maxburst) {
		double vxmt = (double)avpkt/rate - xmt;
		vxmt *= (pow(g, -(double)maxburst) - 1);
		if (vxmt > maxidle)
			maxidle = vxmt;
	}
	return tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000);
}
Beispiel #4
0
unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
    return tc_core_usec2tick(1000000*((double)size/rate));
}