diff options
| author | David S. Miller <davem@davemloft.net> | 2013-12-17 23:27:44 +0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-12-17 23:27:44 +0400 |
| commit | bc4d0f615a3aa252d2ed59c1be72ad88b86db0e9 (patch) | |
| tree | 0cf8783c97908b169df7b6eb293792727bc664b4 /include/linux | |
| parent | 89e47d3b8a273b0eac21e4bf6d7fdb86b654fa16 (diff) | |
| parent | 500f80872645ac8c1d81c206004bf5b4daeaf825 (diff) | |
| download | linux-bc4d0f615a3aa252d2ed59c1be72ad88b86db0e9.tar.xz | |
Merge branch 'ovs_hash'
Francesco Fusco says:
====================
ovs: introduce arch-specific fast hashing improvements
From: Daniel Borkmann <dborkman@redhat.com>
We are introducing a fast hash function (see patch1) that can be
used in the context of OpenVSwitch to reduce the hashing footprint
(patch2). For details, please see individual patches!
v1->v2:
- Make hash generic and place it under lib
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/hash.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/linux/hash.h b/include/linux/hash.h index f09a0ae4d858..bd1754c7ecef 100644 --- a/include/linux/hash.h +++ b/include/linux/hash.h @@ -15,6 +15,7 @@ */ #include <asm/types.h> +#include <asm/hash.h> #include <linux/compiler.h> /* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */ @@ -78,4 +79,39 @@ static inline u32 hash32_ptr(const void *ptr) #endif return (u32)val; } + +struct fast_hash_ops { + u32 (*hash)(const void *data, u32 len, u32 seed); + u32 (*hash2)(const u32 *data, u32 len, u32 seed); +}; + +/** + * arch_fast_hash - Caclulates a hash over a given buffer that can have + * arbitrary size. This function will eventually use an + * architecture-optimized hashing implementation if + * available, and trades off distribution for speed. + * + * @data: buffer to hash + * @len: length of buffer in bytes + * @seed: start seed + * + * Returns 32bit hash. + */ +extern u32 arch_fast_hash(const void *data, u32 len, u32 seed); + +/** + * arch_fast_hash2 - Caclulates a hash over a given buffer that has a + * size that is of a multiple of 32bit words. This + * function will eventually use an architecture- + * optimized hashing implementation if available, + * and trades off distribution for speed. + * + * @data: buffer to hash (must be 32bit padded) + * @len: number of 32bit words + * @seed: start seed + * + * Returns 32bit hash. + */ +extern u32 arch_fast_hash2(const u32 *data, u32 len, u32 seed); + #endif /* _LINUX_HASH_H */ |
