netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: therbert@google.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/6] net: Allow csum_add to be provided in arch
Date: Mon, 07 Apr 2014 13:06:20 -0400 (EDT)	[thread overview]
Message-ID: <20140407.130620.2069601044282998492.davem@davemloft.net> (raw)
In-Reply-To: <alpine.DEB.2.02.1404041714560.20552@tomh.mtv.corp.google.com>

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

      parent reply	other threads:[~2014-04-07 17:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140407.130620.2069601044282998492.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=therbert@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).