From patchwork Mon Apr 7 17:06:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 337497 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5A51A1400BD for ; Tue, 8 Apr 2014 03:06:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754309AbaDGRGX (ORCPT ); Mon, 7 Apr 2014 13:06:23 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:55006 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753162AbaDGRGW (ORCPT ); Mon, 7 Apr 2014 13:06:22 -0400 Received: from localhost (unknown [75.103.3.244]) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id A3A7858C594; Mon, 7 Apr 2014 10:06:21 -0700 (PDT) Date: Mon, 07 Apr 2014 13:06:20 -0400 (EDT) Message-Id: <20140407.130620.2069601044282998492.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 From: David Miller In-Reply-To: References: X-Mailer: Mew version 6.5 on Emacs 24.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tom Herbert 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 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 --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) */