diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-04-28 15:41:39 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2012-07-11 16:04:57 -0400 |
commit | 10104a1ad670889adc1ae3779df968db621b5dbd (patch) | |
tree | 1a5aa6b3ae5c669b818bf076f748a8a54d27f88f /arch/tile/include | |
parent | 4875f69fecab08654972d6fb0d71ee2109d2538c (diff) | |
download | linux-3.10-10104a1ad670889adc1ae3779df968db621b5dbd.tar.gz linux-3.10-10104a1ad670889adc1ae3779df968db621b5dbd.tar.bz2 linux-3.10-10104a1ad670889adc1ae3779df968db621b5dbd.zip |
arch/tile: break out the "csum a long" function to <asm/checksum.h>
This makes it available to the tilegx network driver.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/include')
-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 a120766c726..b21a2fdec9f 100644 --- a/arch/tile/include/asm/checksum.h +++ b/arch/tile/include/asm/checksum.h @@ -21,4 +21,22 @@ __wsum do_csum(const unsigned char *buff, int len); #define do_csum do_csum +/* + * Return the sum of all the 16-bit subwords in a long. + * This sums two subwords on a 32-bit machine, and four on 64 bits. + * The implementation does two vector adds to capture any overflow. + */ +static inline unsigned int csum_long(unsigned long x) +{ + unsigned long ret; +#ifdef __tilegx__ + ret = __insn_v2sadu(x, 0); + ret = __insn_v2sadu(ret, 0); +#else + ret = __insn_sadh_u(x, 0); + ret = __insn_sadh_u(ret, 0); +#endif + return ret; +} + #endif /* _ASM_TILE_CHECKSUM_H */ |