Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2615509imm; Mon, 16 Jul 2018 10:59:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdOz/jwvrOEHAyWSlYJq2slMSTu1F1T4Z97rDmcpAmvddNIpUZ85EJ9gk2RP2jZPnQqs8xi X-Received: by 2002:a63:416:: with SMTP id 22-v6mr16494330pge.229.1531763943271; Mon, 16 Jul 2018 10:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531763943; cv=none; d=google.com; s=arc-20160816; b=vlJHbDo+pq/gpgQu00we4Zn+Ijb459Ktf9Tk65vsxVLrX0Aqyr2mNqXK/v5EtYHWJw 9BRHtmEYbpSvYsFg4bCIRtIUVODt3CGAqTBR2E4uhCGsnfYNCN5VASXTg/3YvC3l+Cq6 vyEQJPX5W7wgOEz6VMa+PNhut5/q9kcOitniTfJARsNmdNidi1tqxGsaK4/hhdAP2RRc 2n+LRCXI7J8/jtlNpjAyThaUUxg0TbKImxhhuVncDQE9fI/pUQhTt74EPAzFVf2iwTqr 5uy99MF8xux2uECeaXbq0Ni4+2h1QoN/64cm+c7x/bvh0lyixaXZQJ0eXmIHEMlcowso j1CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=BYx5myUGIkmYXwGPIC699Xs5MUWpuZb/BxmaWMA5Sg4=; b=Kw6nen/E86dWP/u+oqBsZ4KJyMIDviqKtgDecmjeo7CLc17s5odHa+yeEFMTf5w5kA 4Garh90bk/QkkkHYVakrhxwkx1MQCFa6+w/PKOuyCGHO841XWbR6gEFDhi2vv4leD180 m2leAFk0pSe57+DYJwfm7ftTPZhirLnJv0u9KkRGlqcbRButLCIEaApJQZ79fByiUBI+ uVWTlmAAAphpvirTQx1HoRKACtmwLWxGaKXdnxyQkXIJVSFEZcCGtDS5GRaK46RLBxH9 kfJJw6Uzsihb7rGmuiBQ7Ze8mRO4qHXwsAdk6DNTkf+C5iNM/2dKW9zx/hKZY8WIRp5c qvFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=bClc71Ny; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26-v6si29900857pgu.191.2018.07.16.10.58.47; Mon, 16 Jul 2018 10:59:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=bClc71Ny; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729466AbeGPS0V (ORCPT + 99 others); Mon, 16 Jul 2018 14:26:21 -0400 Received: from merlin.infradead.org ([205.233.59.134]:55882 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbeGPS0V (ORCPT ); Mon, 16 Jul 2018 14:26:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BYx5myUGIkmYXwGPIC699Xs5MUWpuZb/BxmaWMA5Sg4=; b=bClc71NyuonA7etPAF3TOYDf3W A8Dz/FpsGmVZkT7r40bamadWyo7L67DC8vcolRerGYk2dT2T5+/W33bkXTvWY+Zc/wHoTc8TPwJhj cO02YjO+8rpaQtk7V3qJJtimK43NIUHh6b5kstokBMZW+xUIJioK/4UxKufLGZBPlDCw/I/QNKx6c xl7yKBqTp+oJGco4HKgmMQja1eWZF++BMo38SPj06dsehCAoraLgFr6Z3XFoZV0zel3TnyKmiNpgT 5i75i00uYNVGWVtLjHih6sK2Lzgb3eo8bExc1e/5/D0LADR5yhi8bVqWMtDvg0WsR2Dhr9AIfBY5w WDtLfvYw==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ff7kl-0003mQ-Ff; Mon, 16 Jul 2018 17:57:43 +0000 Subject: Re: [PATCH 2/4] lib: add crc64 calculation routines To: Coly Li , linux-kernel@vger.kernel.org Cc: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, Greg Kroah-Hartman , Andy Shevchenko , Michael Lyle , Kent Overstreet , "Luis R . Rodriguez" , Linus Torvalds , Thomas Gleixner , Kate Stewart References: <20180716165507.23100-1-colyli@suse.de> <20180716165507.23100-3-colyli@suse.de> From: Randy Dunlap Message-ID: Date: Mon, 16 Jul 2018 10:57:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180716165507.23100-3-colyli@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/16/2018 09:55 AM, Coly Li wrote: > > diff --git a/lib/crc64.c b/lib/crc64.c > new file mode 100644 > index 000000000000..03f078303bd3 > --- /dev/null > +++ b/lib/crc64.c > @@ -0,0 +1,71 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Normal 64bit CRC calculation. > + * > + * This is a basic crc64 implementation following ECMA-182 specification, > + * which can be found from, > + * http://www.ecma-international.org/publications/standards/Ecma-182.htm > + * > + * Dr. Ross N. Williams has a great document to introduce the idea of CRC > + * algorithm, here the CRC64 code is also inspired by the table-driven > + * algorithm and detail example from this paper. This paper can be found > + * from, > + * http://www.ross.net/crc/download/crc_v3.txt > + * > + * crc64table_le[256] is the lookup table of a table-driver 64bit CRC > + * calculation, which is generated by gen_crc64table.c in kernel build > + * time. The polynomial of crc64 arithmetic is from ECMA-182 specification > + * as well, which is defined as, > + * > + * x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 + > + * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 + > + * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 + > + * x^7 + x^4 + x + 1 > + * > + * Copyright 2018 SUSE Linux. > + * Author: Coly Li > + * > + */ > + > +#include > +#include > +#include "crc64table.h" > + > +MODULE_DESCRIPTION("CRC64 calculations"); > +MODULE_LICENSE("GPL"); > + > +__le64 crc64_le_update(__le64 crc, const void *_p, size_t len) > +{ > + size_t i, t; > + > + const unsigned char *p = _p; > + > + for (i = 0; i < len; i++) { > + t = ((crc >> 56) ^ (__le64)(*p++)) & 0xFF; > + crc = crc64table_le[t] ^ (crc << 8); > + } > + > + return crc; > +} > +EXPORT_SYMBOL_GPL(crc64_le_update); > + > +__le64 crc64_le(const void *p, size_t len) > +{ > + __le64 crc = 0x0000000000000000ULL; Hi, What's wrong with just using 0ULL ? thanks. > + > + crc = crc64_le_update(crc, p, len); > + > + return crc; > +} -- ~Randy