Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.unix.programmer,comp.programming Subject: Re: weighted-fair queuing Date: Fri, 21 Oct 2011 00:51:20 +0100 Lines: 19 Message-ID: <87fwin1atj.fsf@sapphire.mobileactivedefense.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net lUcZoQWHIeNTXNnHeTqKog5+eHHUYAVs9my5kV/CTbChZpQuM= Cancel-Lock: sha1:vbgxwyFUWmpYCHU9xhhAkX9OOpc= sha1:Ipno+YxS8WcNytA+bhwJDAYNsTY= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.unix.programmer:1447 comp.programming:945 "Mark" writes: [...] > Weights that can be assigned by user from upper layer software are in range > 1-32, the max weight value in h/w is 131072, therefore I need some way to > scale down input value (1-32) to properly fit in the hardware. This looks rather as if you would need to scale it up. Given that you need to map a value in the range (1, 2^5) [2^5 ::= 2 to the fifth power] to the range (0, 2^17), an obvious idea would be static inline unsigned map_weight(unsigned weight) { return weight * (1 << 12); } (since 2^17/2^5 = 2^12, 131072 / 32 = 4096).