[NET]: SPARC64 checksum annotations and cleanups.
* sanitize prototypes, annotate * kill useless shift Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
*
|
*
|
||||||
* it's best to have buff aligned on a 32-bit boundary
|
* it's best to have buff aligned on a 32-bit boundary
|
||||||
*/
|
*/
|
||||||
extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
|
extern __wsum csum_partial(const void * buff, int len, __wsum sum);
|
||||||
|
|
||||||
/* the same as csum_partial, but copies from user space while it
|
/* the same as csum_partial, but copies from user space while it
|
||||||
* checksums
|
* checksums
|
||||||
@@ -38,52 +38,50 @@ extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned i
|
|||||||
* here even more important to align src and dst on a 32-bit (or even
|
* here even more important to align src and dst on a 32-bit (or even
|
||||||
* better 64-bit) boundary
|
* better 64-bit) boundary
|
||||||
*/
|
*/
|
||||||
extern unsigned int csum_partial_copy_nocheck(const unsigned char *src,
|
extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
|
||||||
unsigned char *dst,
|
int len, __wsum sum);
|
||||||
int len, unsigned int sum);
|
|
||||||
|
|
||||||
extern long __csum_partial_copy_from_user(const unsigned char __user *src,
|
extern long __csum_partial_copy_from_user(const void __user *src,
|
||||||
unsigned char *dst, int len,
|
void *dst, int len,
|
||||||
unsigned int sum);
|
__wsum sum);
|
||||||
|
|
||||||
static inline unsigned int
|
static inline __wsum
|
||||||
csum_partial_copy_from_user(const unsigned char __user *src,
|
csum_partial_copy_from_user(const void __user *src,
|
||||||
unsigned char *dst, int len,
|
void *dst, int len,
|
||||||
unsigned int sum, int *err)
|
__wsum sum, int *err)
|
||||||
{
|
{
|
||||||
long ret = __csum_partial_copy_from_user(src, dst, len, sum);
|
long ret = __csum_partial_copy_from_user(src, dst, len, sum);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
*err = -EFAULT;
|
*err = -EFAULT;
|
||||||
return (unsigned int) ret;
|
return (__force __wsum) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy and checksum to user
|
* Copy and checksum to user
|
||||||
*/
|
*/
|
||||||
#define HAVE_CSUM_COPY_USER
|
#define HAVE_CSUM_COPY_USER
|
||||||
extern long __csum_partial_copy_to_user(const unsigned char *src,
|
extern long __csum_partial_copy_to_user(const void *src,
|
||||||
unsigned char __user *dst, int len,
|
void __user *dst, int len,
|
||||||
unsigned int sum);
|
__wsum sum);
|
||||||
|
|
||||||
static inline unsigned int
|
static inline __wsum
|
||||||
csum_and_copy_to_user(const unsigned char *src,
|
csum_and_copy_to_user(const void *src,
|
||||||
unsigned char __user *dst, int len,
|
void __user *dst, int len,
|
||||||
unsigned int sum, int *err)
|
__wsum sum, int *err)
|
||||||
{
|
{
|
||||||
long ret = __csum_partial_copy_to_user(src, dst, len, sum);
|
long ret = __csum_partial_copy_to_user(src, dst, len, sum);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
*err = -EFAULT;
|
*err = -EFAULT;
|
||||||
return (unsigned int) ret;
|
return (__force __wsum) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
|
/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
|
||||||
* the majority of the time.
|
* the majority of the time.
|
||||||
*/
|
*/
|
||||||
extern unsigned short ip_fast_csum(__const__ unsigned char *iph,
|
extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
|
||||||
unsigned int ihl);
|
|
||||||
|
|
||||||
/* Fold a partial checksum without adding pseudo headers. */
|
/* Fold a partial checksum without adding pseudo headers. */
|
||||||
static inline unsigned short csum_fold(unsigned int sum)
|
static inline __sum16 csum_fold(__wsum sum)
|
||||||
{
|
{
|
||||||
unsigned int tmp;
|
unsigned int tmp;
|
||||||
|
|
||||||
@@ -93,16 +91,15 @@ static inline unsigned short csum_fold(unsigned int sum)
|
|||||||
" addc %1, %%g0, %1\n"
|
" addc %1, %%g0, %1\n"
|
||||||
" xnor %%g0, %1, %0\n"
|
" xnor %%g0, %1, %0\n"
|
||||||
: "=&r" (sum), "=r" (tmp)
|
: "=&r" (sum), "=r" (tmp)
|
||||||
: "0" (sum), "1" (sum<<16)
|
: "0" (sum), "1" ((__force u32)sum<<16)
|
||||||
: "cc");
|
: "cc");
|
||||||
return (sum & 0xffff);
|
return (__force __sum16)sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
|
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
|
||||||
unsigned long daddr,
|
|
||||||
unsigned int len,
|
unsigned int len,
|
||||||
unsigned short proto,
|
unsigned short proto,
|
||||||
unsigned int sum)
|
__wsum sum)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
" addcc %1, %0, %0\n"
|
" addcc %1, %0, %0\n"
|
||||||
@@ -110,7 +107,7 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
|
|||||||
" addccc %3, %0, %0\n"
|
" addccc %3, %0, %0\n"
|
||||||
" addc %0, %%g0, %0\n"
|
" addc %0, %%g0, %0\n"
|
||||||
: "=r" (sum), "=r" (saddr)
|
: "=r" (sum), "=r" (saddr)
|
||||||
: "r" (daddr), "r" ((proto<<16)+len), "0" (sum), "1" (saddr)
|
: "r" (daddr), "r" (proto + len), "0" (sum), "1" (saddr)
|
||||||
: "cc");
|
: "cc");
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@@ -119,22 +116,20 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
|
|||||||
* computes the checksum of the TCP/UDP pseudo-header
|
* computes the checksum of the TCP/UDP pseudo-header
|
||||||
* returns a 16-bit checksum, already complemented
|
* returns a 16-bit checksum, already complemented
|
||||||
*/
|
*/
|
||||||
static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
|
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
|
||||||
unsigned long daddr,
|
|
||||||
unsigned short len,
|
unsigned short len,
|
||||||
unsigned short proto,
|
unsigned short proto,
|
||||||
unsigned int sum)
|
__wsum sum)
|
||||||
{
|
{
|
||||||
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
|
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _HAVE_ARCH_IPV6_CSUM
|
#define _HAVE_ARCH_IPV6_CSUM
|
||||||
|
|
||||||
static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
|
static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
|
||||||
struct in6_addr *daddr,
|
const struct in6_addr *daddr,
|
||||||
__u32 len,
|
__u32 len, unsigned short proto,
|
||||||
unsigned short proto,
|
__wsum sum)
|
||||||
unsigned int sum)
|
|
||||||
{
|
{
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
" addcc %3, %4, %%g7\n"
|
" addcc %3, %4, %%g7\n"
|
||||||
@@ -165,7 +160,7 @@ static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */
|
/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */
|
||||||
static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
|
static inline __sum16 ip_compute_csum(const void *buff, int len)
|
||||||
{
|
{
|
||||||
return csum_fold(csum_partial(buff, len, 0));
|
return csum_fold(csum_partial(buff, len, 0));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user