Merge branch 'mainstream'
[sliver-openvswitch.git] / datapath / linux / compat / include / linux / hash.h
1 #ifndef _LINUX_HASH_WRAPPER_H
2 #define _LINUX_HASH_WRAPPER_H
3
4 #include_next <linux/hash.h>
5
6 #include <linux/version.h>
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
8 #include <asm/hash.h>
9
10 struct fast_hash_ops {
11         u32 (*hash)(const void *data, u32 len, u32 seed);
12         u32 (*hash2)(const u32 *data, u32 len, u32 seed);
13 };
14
15 /**
16  *      arch_fast_hash - Caclulates a hash over a given buffer that can have
17  *                       arbitrary size. This function will eventually use an
18  *                       architecture-optimized hashing implementation if
19  *                       available, and trades off distribution for speed.
20  *
21  *      @data: buffer to hash
22  *      @len: length of buffer in bytes
23  *      @seed: start seed
24  *
25  *      Returns 32bit hash.
26  */
27 extern u32 arch_fast_hash(const void *data, u32 len, u32 seed);
28
29 /**
30  *      arch_fast_hash2 - Caclulates a hash over a given buffer that has a
31  *                        size that is of a multiple of 32bit words. This
32  *                        function will eventually use an architecture-
33  *                        optimized hashing implementation if available,
34  *                        and trades off distribution for speed.
35  *
36  *      @data: buffer to hash (must be 32bit padded)
37  *      @len: number of 32bit words
38  *      @seed: start seed
39  *
40  *      Returns 32bit hash.
41  */
42 extern u32 arch_fast_hash2(const u32 *data, u32 len, u32 seed);
43 #endif /* < 3.14 */
44
45 #endif /* _LINUX_HASH_WRAPPER_H */