aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-01-07 19:56:59 -0500
committerChris Mason <chris.mason@oracle.com>2009-01-07 19:56:59 -0500
commit755efdc3c4d3b42d5ffcef0f4d6e5b37ecd3bf21 (patch)
treeb3eadbdf6d472189a7221080b7e44f2ff0f0ef7b /fs
parent709ac06a148a33493d3e2f9391bb746b067d96d6 (diff)
Btrfs: Drop the hardware crc32c asm code
This is already in the arch specific directories in mainline and shouldn't be copied into btrfs. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/crc32c.h97
1 files changed, 3 insertions, 94 deletions
diff --git a/fs/btrfs/crc32c.h b/fs/btrfs/crc32c.h
index 1eaf11d334fd..6e1b3de36700 100644
--- a/fs/btrfs/crc32c.h
+++ b/fs/btrfs/crc32c.h
@@ -18,103 +18,12 @@
18 18
19#ifndef __BTRFS_CRC32C__ 19#ifndef __BTRFS_CRC32C__
20#define __BTRFS_CRC32C__ 20#define __BTRFS_CRC32C__
21#include <asm/byteorder.h>
22#include <linux/crc32c.h> 21#include <linux/crc32c.h>
23#include <linux/version.h>
24 22
25/* #define CONFIG_BTRFS_HW_SUM 1 */
26
27#ifdef CONFIG_BTRFS_HW_SUM
28#ifdef CONFIG_X86
29/* 23/*
30 * Using hardware provided CRC32 instruction to accelerate the CRC32 disposal. 24 * this file used to do more for selecting the HW version of crc32c,
31 * CRC32C polynomial:0x1EDC6F41(BE)/0x82F63B78(LE) 25 * perhaps it will one day again soon.
32 * CRC32 is a new instruction in Intel SSE4.2, the reference can be found at:
33 * http://www.intel.com/products/processor/manuals/
34 * Intel(R) 64 and IA-32 Architectures Software Developer's Manual
35 * Volume 2A: Instruction Set Reference, A-M
36 */
37
38#include <asm/cpufeature.h>
39#include <asm/processor.h>
40
41#define X86_FEATURE_XMM4_2 (4*32+20) /* Streaming SIMD Extensions-4.2 */
42#define cpu_has_xmm4_2 boot_cpu_has(X86_FEATURE_XMM4_2)
43
44#ifdef CONFIG_X86_64
45#define REX_PRE "0x48, "
46#define SCALE_F 8
47#else
48#define REX_PRE
49#define SCALE_F 4
50#endif
51
52static inline u32 btrfs_crc32c_le_hw_byte(u32 crc, unsigned char const *data,
53 size_t length)
54{
55 while (length--) {
56 __asm__ __volatile__(
57 ".byte 0xf2, 0xf, 0x38, 0xf0, 0xf1"
58 :"=S"(crc)
59 :"0"(crc), "c"(*data)
60 );
61 data++;
62 }
63
64 return crc;
65}
66
67static inline u32 __pure btrfs_crc32c_le_hw(u32 crc, unsigned char const *p,
68 size_t len)
69{
70 unsigned int iquotient = len / SCALE_F;
71 unsigned int iremainder = len % SCALE_F;
72#ifdef CONFIG_X86_64
73 u64 *ptmp = (u64 *)p;
74#else
75 u32 *ptmp = (u32 *)p;
76#endif
77
78 while (iquotient--) {
79 __asm__ __volatile__(
80 ".byte 0xf2, " REX_PRE "0xf, 0x38, 0xf1, 0xf1;"
81 :"=S"(crc)
82 :"0"(crc), "c"(*ptmp)
83 );
84 ptmp++;
85 }
86
87 if (iremainder)
88 crc = btrfs_crc32c_le_hw_byte(crc, (unsigned char *)ptmp,
89 iremainder);
90
91 return crc;
92}
93#endif /* CONFIG_BTRFS_HW_SUM */
94
95static inline u32 __btrfs_crc32c(u32 crc, unsigned char const *address,
96 size_t len)
97{
98#ifdef CONFIG_BTRFS_HW_SUM
99 if (cpu_has_xmm4_2)
100 return btrfs_crc32c_le_hw(crc, address, len);
101#endif
102 return crc32c_le(crc, address, len);
103}
104
105#else
106
107#define __btrfs_crc32c(seed, data, length) crc32c(seed, data, length)
108
109#endif /* CONFIG_X86 */
110
111/**
112 * implementation of crc32c_le() changed in linux-2.6.23,
113 * has of v0.13 btrfs-progs is using the latest version.
114 * We must workaround older implementations of crc32c_le()
115 * found on older kernel versions.
116 */ 26 */
117#define btrfs_crc32c(seed, data, length) \ 27#define btrfs_crc32c(seed, data, length) crc32c(seed, data, length)
118 __btrfs_crc32c(seed, (unsigned char const *)data, length)
119#endif 28#endif
120 29