• Patrick McHardy's avatar
    Use tc_calc_xmittime() where appropriate · 476daa72
    Patrick McHardy authored
    [IPROUTE]: Use tc_calc_xmittime() where appropriate
    
    Replace expressions of the form "tc_core_usec2tick(1000000 * size/rate)"
    by tc_calc_xmittime().
    
    The CBQ case deserves an extra comment: when called with bnwd=rate,
    tc_cbq_calc_maxidle() behaves identical to tc_calc_xmittime():
    
    unsigned tc_cbq_calc_maxidle(...)
    {
    	double g = 1.0 - 1.0/(1<<ewma_log);
    	double xmt = (double)avpkt/bndw;
    
    	maxidle = xmt*(1-g);
    	if (bndw != rate && maxburst) {
    		...
    	}
    	return tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000);
    }
    
    which comes down to:
    
    maxidle	= xmt * (1 - g)
    	= xmt * (1 - (1.0 - 1.0/(1 << ewma_log))
    	= xmt * (1.0/(1 << ewma_log))
    
    so:
    
    maxidle * (1 << ewma_log) * 1000000
    	= xmt * (1.0/(1 << ewma_log)) * (1 << ewma_log) * 1000000
    	= xmt * 1000000
    	= avpkt/bndw * 1000000
    
    Which means tc_core_usec2tick(maxidle*(1<<ewma_log)*1000000) is identical
    to tc_calc_xmittime(bndw, avpkt). Use it directly since its a lot easier
    to understand its limits.
    Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
    Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
    476daa72
q_cbq.c 13.9 KB