* [PATCH net-next 1/6] net: Allow csum_add to be provided in arch
@ 2014-04-05 0:26 Tom Herbert
2014-04-05 1:34 ` Eric Dumazet
2014-04-07 17:06 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Tom Herbert @ 2014-04-05 0:26 UTC (permalink / raw)
To: davem, netdev
csum_add is really nothing more then add-with-carry which
can be implemented efficiently in some architectures.
Allow architecture to define this protected by HAVE_ARCH_CSUM_ADD.
Provide csum_add in for x86.
Signed-off-by: Tom Herbert <therbert@google.com>
---
arch/x86/include/asm/checksum_64.h | 7 +++++++
include/net/checksum.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/arch/x86/include/asm/checksum_64.h b/arch/x86/include/asm/checksum_64.h
index e6fd8a0..3581761 100644
--- a/arch/x86/include/asm/checksum_64.h
+++ b/arch/x86/include/asm/checksum_64.h
@@ -188,4 +188,11 @@ static inline unsigned add32_with_carry(unsigned a, unsigned b)
return a;
}
+#define HAVE_ARCH_CSUM_ADD
+static inline __wsum csum_add(__wsum csum, __wsum addend)
+{
+ return (__force __wsum)add32_with_carry((__force unsigned)csum,
+ (__force unsigned)addend);
+}
+
#endif /* _ASM_X86_CHECKSUM_64_H */
diff --git a/include/net/checksum.h b/include/net/checksum.h
index a28f4e0..87cb190 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -57,12 +57,14 @@ static __inline__ __wsum csum_and_copy_to_user
}
#endif
+#ifndef HAVE_ARCH_CSUM_ADD
static inline __wsum csum_add(__wsum csum, __wsum addend)
{
u32 res = (__force u32)csum;
res += (__force u32)addend;
return (__force __wsum)(res + (res < (__force u32)addend));
}
+#endif
static inline __wsum csum_sub(__wsum csum, __wsum addend)
{
--
1.9.1.423.g4596e3a
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next 1/6] net: Allow csum_add to be provided in arch
2014-04-05 0:26 [PATCH net-next 1/6] net: Allow csum_add to be provided in arch Tom Herbert
@ 2014-04-05 1:34 ` Eric Dumazet
2014-04-07 17:06 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2014-04-05 1:34 UTC (permalink / raw)
To: Tom Herbert; +Cc: davem, netdev
On Fri, 2014-04-04 at 17:26 -0700, Tom Herbert wrote:
> csum_add is really nothing more then add-with-carry which
> can be implemented efficiently in some architectures.
> Allow architecture to define this protected by HAVE_ARCH_CSUM_ADD.
>
> Provide csum_add in for x86.
[ net-next is closed during merge window ]
Not x86, but x86_64 only.
Note add32_with_carry(a, b) is suboptimal, as it forces
a and b in registers.
b could be a memory or a register operand.
diff --git a/arch/x86/include/asm/checksum_64.h b/arch/x86/include/asm/checksum_64.h
index e6fd8a026c7b..29f130d3c344 100644
--- a/arch/x86/include/asm/checksum_64.h
+++ b/arch/x86/include/asm/checksum_64.h
@@ -184,7 +184,7 @@ static inline unsigned add32_with_carry(unsigned a, unsigned b)
asm("addl %2,%0\n\t"
"adcl $0,%0"
: "=r" (a)
- : "0" (a), "r" (b));
+ : "0" (a), "rm" (b));
return a;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next 1/6] net: Allow csum_add to be provided in arch
2014-04-05 0:26 [PATCH net-next 1/6] net: Allow csum_add to be provided in arch Tom Herbert
2014-04-05 1:34 ` Eric Dumazet
@ 2014-04-07 17:06 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-04-07 17:06 UTC (permalink / raw)
To: therbert; +Cc: netdev
From: Tom Herbert <therbert@google.com>
Date: Fri, 4 Apr 2014 17:26:46 -0700 (PDT)
> csum_add is really nothing more then add-with-carry which
> can be implemented efficiently in some architectures.
> Allow architecture to define this protected by HAVE_ARCH_CSUM_ADD.
>
> Provide csum_add in for x86.
>
> Signed-off-by: Tom Herbert <therbert@google.com>
The Sparc version looks like this, feel free to integrate it into this
patch.
diff --git a/arch/sparc/include/asm/checksum_32.h b/arch/sparc/include/asm/checksum_32.h
index bdbda14..3297436 100644
--- a/arch/sparc/include/asm/checksum_32.h
+++ b/arch/sparc/include/asm/checksum_32.h
@@ -238,4 +238,15 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
return csum_fold(csum_partial(buff, len, 0));
}
+#define HAVE_ARCH_CSUM_ADD
+static inline __wsum csum_add(__wsum csum, __wsum addend)
+{
+ __asm__ __volatile__(
+" addcc %0, %1, %0\n"
+" addx %0, %%g0, %0"
+ : "=r" (csum)
+ : "r" (addend), "0" (csum));
+ return csum;
+}
+
#endif /* !(__SPARC_CHECKSUM_H) */
diff --git a/arch/sparc/include/asm/checksum_64.h b/arch/sparc/include/asm/checksum_64.h
index 019b961..38b24a3 100644
--- a/arch/sparc/include/asm/checksum_64.h
+++ b/arch/sparc/include/asm/checksum_64.h
@@ -164,4 +164,15 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
return csum_fold(csum_partial(buff, len, 0));
}
+#define HAVE_ARCH_CSUM_ADD
+static inline __wsum csum_add(__wsum csum, __wsum addend)
+{
+ __asm__ __volatile__(
+" addcc %0, %1, %0\n"
+" addc %0, %%g0, %0"
+ : "=r" (csum)
+ : "r" (addend), "0" (csum));
+ return csum;
+}
+
#endif /* !(__SPARC64_CHECKSUM_H) */
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-07 17:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-05 0:26 [PATCH net-next 1/6] net: Allow csum_add to be provided in arch Tom Herbert
2014-04-05 1:34 ` Eric Dumazet
2014-04-07 17:06 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).