* [PATCH] blackfin checksum annotations
@ 2008-04-27 5:22 Al Viro
2008-04-27 5:26 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2008-04-27 5:22 UTC (permalink / raw)
To: David Miller; +Cc: cooloney, linux-kernel
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
arch/blackfin/lib/checksum.c | 21 ++++++++++-----------
include/asm-blackfin/checksum.h | 29 ++++++++++++++---------------
2 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c
index 42768e0..5c87505 100644
--- a/arch/blackfin/lib/checksum.c
+++ b/arch/blackfin/lib/checksum.c
@@ -72,9 +72,9 @@ static unsigned short do_csum(const unsigned char *buff, int len)
* This is a version of ip_compute_csum() optimized for IP headers,
* which always checksum on 4 octet boundaries.
*/
-unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
+__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl)
{
- return ~do_csum(iph, ihl * 4);
+ return (__force __sum16)~do_csum(iph, ihl * 4);
}
/*
@@ -89,7 +89,7 @@ unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
*
* it's best to have buff aligned on a 32-bit boundary
*/
-unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
+__wsum csum_partial(const void *buff, int len, __wsum sum)
{
/*
* Just in case we get nasty checksum data...
@@ -109,22 +109,22 @@ unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
* this routine is used for miscellaneous IP-like checksums, mainly
* in icmp.c
*/
-unsigned short ip_compute_csum(const unsigned char *buff, int len)
+__sum16 ip_compute_csum(const void *buff, int len)
{
- return ~do_csum(buff, len);
+ return (__force __sum16)~do_csum(buff, len);
}
/*
* copy from fs while checksumming, otherwise like csum_partial
*/
-unsigned int
-csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
- int len, int sum, int *csum_err)
+__wsum
+csum_partial_copy_from_user(const void __user *src, void *dst,
+ int len, __wsum sum, int *csum_err)
{
if (csum_err)
*csum_err = 0;
- memcpy(dst, src, len);
+ memcpy(dst, (__force void *)src, len);
return csum_partial(dst, len, sum);
}
@@ -132,8 +132,7 @@ csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
* copy from ds while checksumming, otherwise like csum_partial
*/
-unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
- int len, int sum)
+__wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
{
memcpy(dst, src, len);
return csum_partial(dst, len, sum);
diff --git a/include/asm-blackfin/checksum.h b/include/asm-blackfin/checksum.h
index 2638f25..699fa3e 100644
--- a/include/asm-blackfin/checksum.h
+++ b/include/asm-blackfin/checksum.h
@@ -15,7 +15,7 @@
*
* it's best to have buff aligned on a 32-bit boundary
*/
-unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum);
+__wsum csum_partial(const void *buff, int len, __wsum sum);
/*
* the same as csum_partial, but copies from src while it
@@ -25,8 +25,8 @@ unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum);
* better 64-bit) boundary
*/
-unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
- int len, int sum);
+__wsum csum_partial_copy(const void *src, void *dst,
+ int len, __wsum sum);
/*
* the same as csum_partial_copy, but copies from user space.
@@ -35,20 +35,19 @@ unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
* better 64-bit) boundary
*/
-extern unsigned int csum_partial_copy_from_user(const unsigned char *src,
- unsigned char *dst, int len,
- int sum, int *csum_err);
+extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
+ int len, __wsum sum, int *csum_err);
#define csum_partial_copy_nocheck(src, dst, len, sum) \
csum_partial_copy((src), (dst), (len), (sum))
-unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl);
+__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl);
/*
* Fold a partial checksum
*/
-static inline unsigned int csum_fold(unsigned int sum)
+static inline __sum16 csum_fold(__wsum sum)
{
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
@@ -60,9 +59,9 @@ static inline unsigned int csum_fold(unsigned int sum)
* returns a 16-bit checksum, already complemented
*/
-static inline unsigned int
-csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
- unsigned short proto, unsigned int sum)
+static inline __wsum
+csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+ unsigned short proto, __wsum sum)
{
__asm__ ("%0 = %0 + %1;\n\t"
@@ -84,9 +83,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
return (sum);
}
-static inline unsigned short int
-csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
- unsigned short proto, unsigned int sum)
+static inline __sum16
+csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
+ unsigned short proto, __wsum sum)
{
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
}
@@ -96,6 +95,6 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
* in icmp.c
*/
-extern unsigned short ip_compute_csum(const unsigned char *buff, int len);
+extern __sum16 ip_compute_csum(const unsigned char *buff, int len);
#endif /* _BFIN_CHECKSUM_H */
--
1.5.3.GIT
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] blackfin checksum annotations
2008-04-27 5:22 [PATCH] blackfin checksum annotations Al Viro
@ 2008-04-27 5:26 ` David Miller
2008-04-27 5:38 ` Al Viro
2008-04-27 11:16 ` Heiko Carstens
0 siblings, 2 replies; 7+ messages in thread
From: David Miller @ 2008-04-27 5:26 UTC (permalink / raw)
To: viro; +Cc: cooloney, linux-kernel
From: Al Viro <viro@ZenIV.linux.org.uk>
Date: Sun, 27 Apr 2008 06:22:26 +0100
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Since these are networking knobs and Al tends to test his
changes, I'll apply this to the net-2.6 tree.
Thanks Al!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blackfin checksum annotations
2008-04-27 5:26 ` David Miller
@ 2008-04-27 5:38 ` Al Viro
2008-04-27 11:16 ` Heiko Carstens
1 sibling, 0 replies; 7+ messages in thread
From: Al Viro @ 2008-04-27 5:38 UTC (permalink / raw)
To: David Miller; +Cc: cooloney, linux-kernel
On Sat, Apr 26, 2008 at 10:26:44PM -0700, David Miller wrote:
> From: Al Viro <viro@ZenIV.linux.org.uk>
> Date: Sun, 27 Apr 2008 06:22:26 +0100
>
> >
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
>
> Since these are networking knobs and Al tends to test his
> changes, I'll apply this to the net-2.6 tree.
FSVOtest in this case, since I don't have the hardware... However,
all changes seen by gcc are actually
* explicit cast to unsigned short in return expression of functions
returning unsigned short
* csum_fold() return type changed from unsigned int to __sum16
(unsigned short), same as for all other architecture and as net/* expects;
expression actually returned is ((~(sum << 16)) >> 16) with sum being
unsigned 32bit, so it's (a) going to fit into the range of unsigned short
and (b) had been unsigned all along, so no sign expansion mess happened.
IOW, it should not break runtime, but... untested is untested.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] blackfin checksum annotations
2008-04-27 5:26 ` David Miller
2008-04-27 5:38 ` Al Viro
@ 2008-04-27 11:16 ` Heiko Carstens
2008-04-27 12:42 ` Al Viro
1 sibling, 1 reply; 7+ messages in thread
From: Heiko Carstens @ 2008-04-27 11:16 UTC (permalink / raw)
To: David Miller; +Cc: viro, cooloney, linux-kernel
On Sat, Apr 26, 2008 at 10:26:44PM -0700, David Miller wrote:
> From: Al Viro <viro@ZenIV.linux.org.uk>
> Date: Sun, 27 Apr 2008 06:22:26 +0100
>
> >
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
>
> Since these are networking knobs and Al tends to test his
> changes, I'll apply this to the net-2.6 tree.
I don't think such arch specific patches should go in via net-2.6.
You did that for a very similar patch for s390 and it was subtly broken:
See:
f994aae1bd8e4813d59a2ed64d17585fe42d03fc
("[NET]: S390 checksum annotations and cleanups.")
and
afbc1e994ddcf3b6fe2dc928ee8dc31a5d0c3118
("[S390] Fix TCP/UDP pseudo header checksum computation.")
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] blackfin checksum annotations
2008-04-27 11:16 ` Heiko Carstens
@ 2008-04-27 12:42 ` Al Viro
2008-04-27 13:37 ` Bryan Wu
0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2008-04-27 12:42 UTC (permalink / raw)
To: Heiko Carstens; +Cc: David Miller, cooloney, linux-kernel
On Sun, Apr 27, 2008 at 01:16:23PM +0200, Heiko Carstens wrote:
> I don't think such arch specific patches should go in via net-2.6.
> You did that for a very similar patch for s390 and it was subtly broken:
>
> See:
> f994aae1bd8e4813d59a2ed64d17585fe42d03fc
> ("[NET]: S390 checksum annotations and cleanups.")
>
> and
>
> afbc1e994ddcf3b6fe2dc928ee8dc31a5d0c3118
> ("[S390] Fix TCP/UDP pseudo header checksum computation.")
I remember, and AFAICT this one is safe - here everything stays within
C and type changes ought to be equivalent transformations. Said that,
I do _NOT_ have hardware in question and it's completely untested at
runtime.
Al, who really couldn't care less which tree that goes through - up to
davem and blackfin maintainers; both are on Cc, so...
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] blackfin checksum annotations
2008-04-27 12:42 ` Al Viro
@ 2008-04-27 13:37 ` Bryan Wu
2008-04-27 19:50 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Bryan Wu @ 2008-04-27 13:37 UTC (permalink / raw)
To: Al Viro; +Cc: Heiko Carstens, David Miller, linux-kernel
On Sun, Apr 27, 2008 at 8:42 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Sun, Apr 27, 2008 at 01:16:23PM +0200, Heiko Carstens wrote:
>
> > I don't think such arch specific patches should go in via net-2.6.
> > You did that for a very similar patch for s390 and it was subtly broken:
> >
> > See:
> > f994aae1bd8e4813d59a2ed64d17585fe42d03fc
> > ("[NET]: S390 checksum annotations and cleanups.")
> >
> > and
> >
> > afbc1e994ddcf3b6fe2dc928ee8dc31a5d0c3118
> > ("[S390] Fix TCP/UDP pseudo header checksum computation.")
>
> I remember, and AFAICT this one is safe - here everything stays within
> C and type changes ought to be equivalent transformations. Said that,
> I do _NOT_ have hardware in question and it's completely untested at
> runtime.
>
Sorry for the delay. I will test this patch on Blackfin arch. And if it is ok,
it will be merged to Blackfin git tree. As long as it is a Blackfin
arch related issue,
merging to Blackfin tree is a better way.
> Al, who really couldn't care less which tree that goes through - up to
> davem and blackfin maintainers; both are on Cc, so...
>
Thanks
-Bryan
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] blackfin checksum annotations
2008-04-27 13:37 ` Bryan Wu
@ 2008-04-27 19:50 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2008-04-27 19:50 UTC (permalink / raw)
To: cooloney; +Cc: viro, heiko.carstens, linux-kernel
From: "Bryan Wu" <cooloney@kernel.org>
Date: Sun, 27 Apr 2008 21:37:15 +0800
> Sorry for the delay. I will test this patch on Blackfin arch. And if it is ok,
> it will be merged to Blackfin git tree. As long as it is a Blackfin
> arch related issue,
> merging to Blackfin tree is a better way.
Fair enough, I'll drop it from net-2.6
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-04-27 19:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-27 5:22 [PATCH] blackfin checksum annotations Al Viro
2008-04-27 5:26 ` David Miller
2008-04-27 5:38 ` Al Viro
2008-04-27 11:16 ` Heiko Carstens
2008-04-27 12:42 ` Al Viro
2008-04-27 13:37 ` Bryan Wu
2008-04-27 19:50 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox