mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
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>
This commit is contained in:
parent
4875f69fec
commit
10104a1ad6
@ -21,4 +21,22 @@
|
|||||||
__wsum do_csum(const unsigned char *buff, int len);
|
__wsum do_csum(const unsigned char *buff, int len);
|
||||||
#define do_csum do_csum
|
#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 */
|
#endif /* _ASM_TILE_CHECKSUM_H */
|
||||||
|
@ -16,19 +16,6 @@
|
|||||||
#include <net/checksum.h>
|
#include <net/checksum.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
|
||||||
static inline unsigned int longto16(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
__wsum do_csum(const unsigned char *buff, int len)
|
__wsum do_csum(const unsigned char *buff, int len)
|
||||||
{
|
{
|
||||||
int odd, count;
|
int odd, count;
|
||||||
@ -94,7 +81,7 @@ __wsum do_csum(const unsigned char *buff, int len)
|
|||||||
}
|
}
|
||||||
if (len & 1)
|
if (len & 1)
|
||||||
result += *buff;
|
result += *buff;
|
||||||
result = longto16(result);
|
result = csum_long(result);
|
||||||
if (odd)
|
if (odd)
|
||||||
result = swab16(result);
|
result = swab16(result);
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user