diff mbox

[net-next,1/6] net: Allow csum_add to be provided in arch

Message ID 20140407.130620.2069601044282998492.davem@davemloft.net
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

David Miller April 7, 2014, 5:06 p.m. UTC
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.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

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) */