Thread (22 messages) 22 messages, 6 authors, 2016-03-05

Re: [4/9] powerpc: inline ip_fast_csum()

flat view

From: Scott Wood <oss@buserror.net>
Date: 2016-03-05 03:51:12
Also in: lkml, netdev

On Tue, Sep 22, 2015 at 04:34:25PM +0200, Christophe Leroy wrote:
quoted hunk ↗ jump to hunk
@@ -137,6 +130,45 @@ static inline __wsum csum_add(__wsum csum, __wsum addend)
 #endif
 }
 
+/*
+ * This is a version of ip_compute_csum() optimized for IP headers,
+ * which always checksum on 4 octet boundaries.  ihl is the number
+ * of 32-bit words and is always >= 5.
+ */
+static inline __wsum ip_fast_csum_nofold(const void *iph, unsigned int ihl)
+{
+	u32 *ptr = (u32 *)iph + 1;
const?
quoted hunk ↗ jump to hunk
+#ifdef __powerpc64__
+	unsigned int i;
+	u64 s = *(__force u32 *)iph;
const?
Why __force?
quoted hunk ↗ jump to hunk
+	s += (s >> 32);
+	return (__force __wsum)s;
+
+#else
+	__wsum sum, tmp;
+
+	asm("mtctr %3;"
+	    "addc %0,%4,%5;"
+	    "1:lwzu %1, 4(%2);"
+	    "adde %0,%0,%1;"
+	    "bdnz 1b;"
+	    "addze %0,%0;"
+	    : "=r"(sum), "=r"(tmp), "+b"(ptr)
+	    : "r"(ihl - 2), "r"(*(u32 *)iph), "r"(*ptr)
+	    : "ctr", "xer", "memory");
Space between " and (
Space after :
const in cast

I've fixed these up while applying.

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help