Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 313784
b: refs/heads/master
c: 10104a1
h: refs/heads/master
v: v3
  • Loading branch information
Chris Metcalf committed Jul 11, 2012
1 parent 0c77231 commit 533fed8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4875f69fecab08654972d6fb0d71ee2109d2538c
refs/heads/master: 10104a1ad670889adc1ae3779df968db621b5dbd
18 changes: 18 additions & 0 deletions trunk/arch/tile/include/asm/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
15 changes: 1 addition & 14 deletions trunk/arch/tile/lib/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@
#include <net/checksum.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)
{
int odd, count;
Expand Down Expand Up @@ -94,7 +81,7 @@ __wsum do_csum(const unsigned char *buff, int len)
}
if (len & 1)
result += *buff;
result = longto16(result);
result = csum_long(result);
if (odd)
result = swab16(result);
out:
Expand Down

0 comments on commit 533fed8

Please sign in to comment.