]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PKT_SCHED] CLS_U32: Use ffs() instead of C code on hash mask to get first set bit.
authorRadu Rendec <radu.rendec@ines.ro>
Sun, 11 Nov 2007 05:54:50 +0000 (21:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 11 Nov 2007 05:54:50 +0000 (21:54 -0800)
Computing the rank of the first set bit in the hash mask (for using later
in u32_hash_fold()) was done with plain C code. Using ffs() instead makes
the code more readable and improves performance (since ffs() is better
optimized in assembler).

Using the conditional operator on hash mask before applying ntohl() also
saves one ntohl() call if mask is 0.

Signed-off-by: Radu Rendec <radu.rendec@ines.ro>
Signed-off-by: Jarek Poplawski <jarkao2@o2.pl>
Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_u32.c

index 53171029439f788eabc2b7689e022ceff222d249..c3900820916425f23fbbcc93db63151a9b81305b 100644 (file)
@@ -613,17 +613,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
        n->ht_up = ht;
        n->handle = handle;
-{
-       u8 i = 0;
-       u32 mask = ntohl(s->hmask);
-       if (mask) {
-               while (!(mask & 1)) {
-                       i++;
-                       mask>>=1;
-               }
-       }
-       n->fshift = i;
-}
+       n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
 
 #ifdef CONFIG_CLS_U32_MARK
        if (tb[TCA_U32_MARK-1]) {