kernel-ark/net
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
..
9p 9p: Change the name of new protocol from 9p2010.L to 9p2000.L 2010-03-13 08:57:29 -06:00
802
8021q Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2010-03-20 15:24:29 -07:00
appletalk net: appletalk: use seq_hlist_foo() helpers 2010-02-10 11:12:09 -08:00
atm atm: Use kasprintf 2010-03-21 18:34:15 -07:00
ax25 net: ax25: use seq_hlist_foo() helpers 2010-02-10 11:12:09 -08:00
bluetooth net: convert multiple drivers to use netdev_for_each_mc_addr, part7 2010-03-16 21:23:25 -07:00
bridge bridge: cleanup: remove unused assignment 2010-03-21 21:21:58 -07:00
caif net-caif: add CAIF Kconfig and Makefiles 2010-03-30 19:08:49 -07:00
can can: deny filterlist access on non-CAN interfaces 2010-02-02 07:21:34 -08:00
core rps: fix net-sysfs build for !CONFIG_RPS 2010-03-29 01:00:44 -07:00
dcb const: struct nla_policy 2010-02-18 14:30:18 -08:00
dccp net: remove trailing space in messages 2010-03-24 14:01:54 -07:00
decnet net: Add checking to rcu_dereference() primitives 2010-02-25 09:41:03 +01:00
dsa
econet
ethernet
ieee802154
ipv4 net: remove trailing space in messages 2010-03-24 14:01:54 -07:00
ipv6 ipv6 fib: Use "Sweezle" to optimize addr_bit_test(). 2010-03-30 23:28:47 -07:00
ipx net: ipx: use seq_list_foo() helpers 2010-02-10 12:31:10 -08:00
irda net: remove trailing space in messages 2010-03-24 14:01:54 -07:00
iucv
key xfrm: SP lookups signature with mark 2010-02-22 16:21:12 -08:00
lapb
llc llc: cleanup: remove dead code from llc_init() 2010-03-24 13:34:08 -07:00
mac80211 Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 2010-03-29 13:50:10 -07:00
netfilter netfilter: ctnetlink: fix reliable event delivery if message building fails 2010-03-20 14:29:03 -07:00
netlabel net: remove INIT_RCU_HEAD() usage 2010-02-17 00:03:27 -08:00
netlink netlink: use the appropriate namespace pid 2010-03-26 20:13:58 -07:00
netrom net: netrom: use seq_hlist_foo() helpers 2010-02-10 11:12:08 -08:00
packet af_packet: move strict addr_len check right before dev_[mc/unicast]_[add/del] 2010-03-03 01:04:38 -08:00
phonet phonet: use for_each_set_bit() 2010-03-15 16:00:47 -07:00
rds rds: cleanup: remove unneeded variable 2010-03-24 13:34:09 -07:00
rfkill rename new rfkill sysfs knobs 2010-03-19 15:48:25 -04:00
rose net: rose: use seq_hlist_foo() helpers 2010-02-10 11:12:08 -08:00
rxrpc
sched net_sched: minor netns related cleanup 2010-03-30 19:44:56 -07:00
sctp sctp: Use ipv6_addr_diff() in sctp_v6_addr_match_len(). 2010-03-30 23:28:47 -07:00
sunrpc net: remove trailing space in messages 2010-03-24 14:01:54 -07:00
tipc tipc: remove trailing space in messages 2010-03-24 14:01:54 -07:00
unix AF_UNIX: update locking comment 2010-02-18 14:12:06 -08:00
wanrouter
wimax wimax: remove unneeded variable 2010-03-24 13:34:09 -07:00
wireless cfg80211: Add connection quality monitoring support to nl80211 2010-03-24 16:02:37 -04:00
x25 net: backlog functions rename 2010-03-05 13:34:03 -08:00
xfrm ipsec: Fix bogus bundle flowi 2010-03-03 01:04:37 -08:00
compat.c
Kconfig net-caif: add CAIF Kconfig and Makefiles 2010-03-30 19:08:49 -07:00
Makefile net-caif: add CAIF Kconfig and Makefiles 2010-03-30 19:08:49 -07:00
nonet.c
socket.c
sysctl_net.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
TUNABLE