linux/net/ipv6
YOSHIFUJI Hideaki / 吉藤英明 02cdce53f3 ipv6 fib: Use "Sweezle" to optimize addr_bit_test().
addr_bit_test() is used in various places in IPv6 routing table
subsystem.  It checks if the given fn_bit is set,
where fn_bit counts bits from MSB in words in network-order.

 fn_bit        :   0 .... 31 32 .... 64 65 .... 95 96 ....127

fn_bit >> 5 gives offset of word, and (~fn_bit & 0x1f) gives
count from LSB in the network-endian word in question.

 fn_bit >> 5   :       0          1          2          3
 ~fn_bit & 0x1f:  31 ....  0 31 ....  0 31 ....  0 31 ....  0

Thus, the mask was generated as htonl(1 << (~fn_bit & 0x1f)).
This can be optimized by "sweezle" (See include/asm-generic/bitops/le.h).

In little-endian,
  htonl(1 << bit) = 1 << (bit ^ BITOP_BE32_SWIZZLE)
where
  BITOP_BE32_SWIZZLE is (0x1f & ~7)
So,
  htonl(1 << (~fn_bit & 0x1f)) = 1 << ((~fn_bit & 0x1f) ^ (0x1f & ~7))
                               = 1 << ((~fn_bit ^ ~7) & 0x1f)
                               = 1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)

In big-endian, BITOP_BE32_SWIZZLE is equal to 0.
  1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)
                               = 1 << ((~fn_bit) & 0x1f)
                               = htonl(1 << (~fn_bit & 0x1f))

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-03-30 23:28:47 -07:00
..
netfilter net: remove trailing space in messages 2010-03-24 14:01:54 -07:00
addrconf_core.c ipv6: Remove IPV6_ADDR_RESERVED 2010-02-26 03:59:07 -08:00
addrconf.c ipv6: Fix result generation in ipv6_get_ifaddr(). 2010-03-25 21:39:21 -07:00
addrlabel.c
af_inet6.c percpu: add __percpu sparse annotations to net 2010-02-16 23:05:38 -08:00
ah6.c xfrm: SA lookups signature with mark 2010-02-22 16:20:22 -08:00
anycast.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
datagram.c ipv6: no more dev_put() in datagram_send_ctl() 2009-11-02 03:42:41 -08:00
esp6.c xfrm: SA lookups signature with mark 2010-02-22 16:20:22 -08:00
exthdrs_core.c
exthdrs.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
fib6_rules.c ipv6: Optmize translation between IPV6_PREFER_SRC_xxx and RT6_LOOKUP_F_xxx. 2010-03-07 15:25:53 -08:00
icmp.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
inet6_connection_sock.c net: IPv6 changes 2009-10-20 18:55:45 -07:00
inet6_hashtables.c tcp: Fix a connect() race with timewait sockets 2009-12-08 20:17:51 -08:00
ip6_fib.c ipv6 fib: Use "Sweezle" to optimize addr_bit_test(). 2010-03-30 23:28:47 -07:00
ip6_flowlabel.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
ip6_input.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
ip6_output.c ipv6: Use 1280 as min MTU for ipv6 forwarding 2010-02-26 04:34:49 -08:00
ip6_tunnel.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
ip6mr.c net: ipmr/ip6mr: fix potential out-of-bounds vif_table access 2010-03-19 22:47:22 -07:00
ipcomp6.c xfrm: SA lookups signature with mark 2010-02-22 16:20:22 -08:00
ipv6_sockglue.c Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-10-27 01:03:26 -07:00
Kconfig IPv6: Fix 6RD typo 2009-10-07 14:50:30 -07:00
Makefile
mcast.c IPv6: convert mc_lock to spinlock 2010-02-17 18:48:44 -08:00
mip6.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
ndisc.c net neigh: Decouple per interface neighbour table controls from binary sysctls 2010-02-16 15:55:18 -08:00
netfilter.c net: skb->dst accessors 2009-06-03 02:51:04 -07:00
proc.c percpu: add __percpu sparse annotations to net 2010-02-16 23:05:38 -08:00
protocol.c net: constify struct inet6_protocol 2009-09-14 17:03:05 -07:00
raw.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
reassembly.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
route.c ipv6: Remove redundant dst NULL check in ip6_dst_check 2010-03-19 21:00:42 -07:00
sit.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
syncookies.c net: Add rtnetlink init_rcvwnd to set the TCP initial receive window 2009-12-23 14:13:30 -08:00
sysctl_net_ipv6.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
tcp_ipv6.c tcp: Add SNMP counters for backlog and min_ttl drops 2010-03-08 10:45:27 -08:00
tunnel6.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
udp_impl.h net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
udp.c net: backlog functions rename 2010-03-05 13:34:03 -08:00
udplite.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
xfrm6_input.c xfrm: SA lookups signature with mark 2010-02-22 16:20:22 -08:00
xfrm6_mode_beet.c
xfrm6_mode_ro.c
xfrm6_mode_transport.c
xfrm6_mode_tunnel.c net: skb->dst accessors 2009-06-03 02:51:04 -07:00
xfrm6_output.c ipv6: drop unused "dev" arg of icmpv6_send() 2010-02-18 14:30:17 -08:00
xfrm6_policy.c ipsec: Fix bogus bundle flowi 2010-03-03 01:04:37 -08:00
xfrm6_state.c
xfrm6_tunnel.c net: remove INIT_RCU_HEAD() usage 2010-02-17 00:03:27 -08:00