diff options
Diffstat (limited to 'arch/tile/include/asm/checksum.h')
-rw-r--r-- | arch/tile/include/asm/checksum.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/tile/include/asm/checksum.h b/arch/tile/include/asm/checksum.h index a120766c7264..b21a2fdec9f7 100644 --- a/arch/tile/include/asm/checksum.h +++ b/arch/tile/include/asm/checksum.h | |||
@@ -21,4 +21,22 @@ | |||
21 | __wsum do_csum(const unsigned char *buff, int len); | 21 | __wsum do_csum(const unsigned char *buff, int len); |
22 | #define do_csum do_csum | 22 | #define do_csum do_csum |
23 | 23 | ||
24 | /* | ||
25 | * Return the sum of all the 16-bit subwords in a long. | ||
26 | * This sums two subwords on a 32-bit machine, and four on 64 bits. | ||
27 | * The implementation does two vector adds to capture any overflow. | ||
28 | */ | ||
29 | static inline unsigned int csum_long(unsigned long x) | ||
30 | { | ||
31 | unsigned long ret; | ||
32 | #ifdef __tilegx__ | ||
33 | ret = __insn_v2sadu(x, 0); | ||
34 | ret = __insn_v2sadu(ret, 0); | ||
35 | #else | ||
36 | ret = __insn_sadh_u(x, 0); | ||
37 | ret = __insn_sadh_u(ret, 0); | ||
38 | #endif | ||
39 | return ret; | ||
40 | } | ||
41 | |||
24 | #endif /* _ASM_TILE_CHECKSUM_H */ | 42 | #endif /* _ASM_TILE_CHECKSUM_H */ |