diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-03-23 18:02:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:38 -0400 |
commit | 577eba9e22e872574c466648b46eeb3e0d04372e (patch) | |
tree | 725d141dad7d04d5fc776429eafa82e27fc0a8d2 /lib | |
parent | 6a0962b22eccc70b8421014022c07efcf194a95e (diff) |
crc32: add self-test code for crc32c
Add self-test code for crc32c.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Cc: Bob Pearson <rpearson@systemfabricworks.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crc32.c | 363 |
1 files changed, 261 insertions, 102 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index 87678dd1141e..b0d278fb1d91 100644 --- a/lib/crc32.c +++ b/lib/crc32.c | |||
@@ -782,113 +782,265 @@ static struct crc_test { | |||
782 | u32 length; /* random 11 bit length of test */ | 782 | u32 length; /* random 11 bit length of test */ |
783 | u32 crc_le; /* expected crc32_le result */ | 783 | u32 crc_le; /* expected crc32_le result */ |
784 | u32 crc_be; /* expected crc32_be result */ | 784 | u32 crc_be; /* expected crc32_be result */ |
785 | u32 crc32c_le; /* expected crc32c_le result */ | ||
785 | } test[] = | 786 | } test[] = |
786 | { | 787 | { |
787 | {0x674bf11d, 0x00000038, 0x00000542, 0x0af6d466, 0xd8b6e4c1}, | 788 | {0x674bf11d, 0x00000038, 0x00000542, 0x0af6d466, 0xd8b6e4c1, |
788 | {0x35c672c6, 0x0000003a, 0x000001aa, 0xc6d3dfba, 0x28aaf3ad}, | 789 | 0xf6e93d6c}, |
789 | {0x496da28e, 0x00000039, 0x000005af, 0xd933660f, 0x5d57e81f}, | 790 | {0x35c672c6, 0x0000003a, 0x000001aa, 0xc6d3dfba, 0x28aaf3ad, |
790 | {0x09a9b90e, 0x00000027, 0x000001f8, 0xb45fe007, 0xf45fca9a}, | 791 | 0x0fe92aca}, |
791 | {0xdc97e5a9, 0x00000025, 0x000003b6, 0xf81a3562, 0xe0126ba2}, | 792 | {0x496da28e, 0x00000039, 0x000005af, 0xd933660f, 0x5d57e81f, |
792 | {0x47c58900, 0x0000000a, 0x000000b9, 0x8e58eccf, 0xf3afc793}, | 793 | 0x52e1ebb8}, |
793 | {0x292561e8, 0x0000000c, 0x00000403, 0xa2ba8aaf, 0x0b797aed}, | 794 | {0x09a9b90e, 0x00000027, 0x000001f8, 0xb45fe007, 0xf45fca9a, |
794 | {0x415037f6, 0x00000003, 0x00000676, 0xa17d52e8, 0x7f0fdf35}, | 795 | 0x0798af9a}, |
795 | {0x3466e707, 0x00000026, 0x00000042, 0x258319be, 0x75c484a2}, | 796 | {0xdc97e5a9, 0x00000025, 0x000003b6, 0xf81a3562, 0xe0126ba2, |
796 | {0xafd1281b, 0x00000023, 0x000002ee, 0x4428eaf8, 0x06c7ad10}, | 797 | 0x18eb3152}, |
797 | {0xd3857b18, 0x00000028, 0x000004a2, 0x5c430821, 0xb062b7cb}, | 798 | {0x47c58900, 0x0000000a, 0x000000b9, 0x8e58eccf, 0xf3afc793, |
798 | {0x1d825a8f, 0x0000002b, 0x0000050b, 0xd2c45f0c, 0xd68634e0}, | 799 | 0xd00d08c7}, |
799 | {0x5033e3bc, 0x0000000b, 0x00000078, 0xa3ea4113, 0xac6d31fb}, | 800 | {0x292561e8, 0x0000000c, 0x00000403, 0xa2ba8aaf, 0x0b797aed, |
800 | {0x94f1fb5e, 0x0000000f, 0x000003a2, 0xfbfc50b1, 0x3cfe50ed}, | 801 | 0x8ba966bc}, |
801 | {0xc9a0fe14, 0x00000009, 0x00000473, 0x5fb61894, 0x87070591}, | 802 | {0x415037f6, 0x00000003, 0x00000676, 0xa17d52e8, 0x7f0fdf35, |
802 | {0x88a034b1, 0x0000001c, 0x000005ad, 0xc1b16053, 0x46f95c67}, | 803 | 0x11d694a2}, |
803 | {0xf0f72239, 0x00000020, 0x0000026d, 0xa6fa58f3, 0xf8c2c1dd}, | 804 | {0x3466e707, 0x00000026, 0x00000042, 0x258319be, 0x75c484a2, |
804 | {0xcc20a5e3, 0x0000003b, 0x0000067a, 0x7740185a, 0x308b979a}, | 805 | 0x6ab3208d}, |
805 | {0xce589c95, 0x0000002b, 0x00000641, 0xd055e987, 0x40aae25b}, | 806 | {0xafd1281b, 0x00000023, 0x000002ee, 0x4428eaf8, 0x06c7ad10, |
806 | {0x78edc885, 0x00000035, 0x000005be, 0xa39cb14b, 0x035b0d1f}, | 807 | 0xba4603c5}, |
807 | {0x9d40a377, 0x0000003b, 0x00000038, 0x1f47ccd2, 0x197fbc9d}, | 808 | {0xd3857b18, 0x00000028, 0x000004a2, 0x5c430821, 0xb062b7cb, |
808 | {0x703d0e01, 0x0000003c, 0x000006f1, 0x88735e7c, 0xfed57c5a}, | 809 | 0xe6071c6f}, |
809 | {0x776bf505, 0x0000000f, 0x000005b2, 0x5cc4fc01, 0xf32efb97}, | 810 | {0x1d825a8f, 0x0000002b, 0x0000050b, 0xd2c45f0c, 0xd68634e0, |
810 | {0x4a3e7854, 0x00000027, 0x000004b8, 0x8d923c82, 0x0cbfb4a2}, | 811 | 0x179ec30a}, |
811 | {0x209172dd, 0x0000003b, 0x00000356, 0xb89e9c2b, 0xd7868138}, | 812 | {0x5033e3bc, 0x0000000b, 0x00000078, 0xa3ea4113, 0xac6d31fb, |
812 | {0x3ba4cc5b, 0x0000002f, 0x00000203, 0xe51601a9, 0x5b2a1032}, | 813 | 0x0903beb8}, |
813 | {0xfc62f297, 0x00000000, 0x00000079, 0x71a8e1a2, 0x5d88685f}, | 814 | {0x94f1fb5e, 0x0000000f, 0x000003a2, 0xfbfc50b1, 0x3cfe50ed, |
814 | {0x64280b8b, 0x00000016, 0x000007ab, 0x0fa7a30c, 0xda3a455f}, | 815 | 0x6a7cb4fa}, |
815 | {0x97dd724b, 0x00000033, 0x000007ad, 0x5788b2f4, 0xd7326d32}, | 816 | {0xc9a0fe14, 0x00000009, 0x00000473, 0x5fb61894, 0x87070591, |
816 | {0x61394b52, 0x00000035, 0x00000571, 0xc66525f1, 0xcabe7fef}, | 817 | 0xdb535801}, |
817 | {0x29b4faff, 0x00000024, 0x0000006e, 0xca13751e, 0x993648e0}, | 818 | {0x88a034b1, 0x0000001c, 0x000005ad, 0xc1b16053, 0x46f95c67, |
818 | {0x29bfb1dc, 0x0000000b, 0x00000244, 0x436c43f7, 0x429f7a59}, | 819 | 0x92bed597}, |
819 | {0x86ae934b, 0x00000035, 0x00000104, 0x0760ec93, 0x9cf7d0f4}, | 820 | {0xf0f72239, 0x00000020, 0x0000026d, 0xa6fa58f3, 0xf8c2c1dd, |
820 | {0xc4c1024e, 0x0000002e, 0x000006b1, 0x6516a3ec, 0x19321f9c}, | 821 | 0x192a3f1b}, |
821 | {0x3287a80a, 0x00000026, 0x00000496, 0x0b257eb1, 0x754ebd51}, | 822 | {0xcc20a5e3, 0x0000003b, 0x0000067a, 0x7740185a, 0x308b979a, |
822 | {0xa4db423e, 0x00000023, 0x0000045d, 0x9b3a66dc, 0x873e9f11}, | 823 | 0xccbaec1a}, |
823 | {0x7a1078df, 0x00000015, 0x0000014a, 0x8c2484c5, 0x6a628659}, | 824 | {0xce589c95, 0x0000002b, 0x00000641, 0xd055e987, 0x40aae25b, |
824 | {0x6048bd5b, 0x00000006, 0x0000006a, 0x897e3559, 0xac9961af}, | 825 | 0x7eabae4d}, |
825 | {0xd8f9ea20, 0x0000003d, 0x00000277, 0x60eb905b, 0xed2aaf99}, | 826 | {0x78edc885, 0x00000035, 0x000005be, 0xa39cb14b, 0x035b0d1f, |
826 | {0xea5ec3b4, 0x0000002a, 0x000004fe, 0x869965dc, 0x6c1f833b}, | 827 | 0x28c72982}, |
827 | {0x2dfb005d, 0x00000016, 0x00000345, 0x6a3b117e, 0xf05e8521}, | 828 | {0x9d40a377, 0x0000003b, 0x00000038, 0x1f47ccd2, 0x197fbc9d, |
828 | {0x5a214ade, 0x00000020, 0x000005b6, 0x467f70be, 0xcb22ccd3}, | 829 | 0xc3cd4d18}, |
829 | {0xf0ab9cca, 0x00000032, 0x00000515, 0xed223df3, 0x7f3ef01d}, | 830 | {0x703d0e01, 0x0000003c, 0x000006f1, 0x88735e7c, 0xfed57c5a, |
830 | {0x91b444f9, 0x0000002e, 0x000007f8, 0x84e9a983, 0x5676756f}, | 831 | 0xbca8f0e7}, |
831 | {0x1b5d2ddb, 0x0000002e, 0x0000012c, 0xba638c4c, 0x3f42047b}, | 832 | {0x776bf505, 0x0000000f, 0x000005b2, 0x5cc4fc01, 0xf32efb97, |
832 | {0xd824d1bb, 0x0000003a, 0x000007b5, 0x6288653b, 0x3a3ebea0}, | 833 | 0x713f60b3}, |
833 | {0x0470180c, 0x00000034, 0x000001f0, 0x9d5b80d6, 0x3de08195}, | 834 | {0x4a3e7854, 0x00000027, 0x000004b8, 0x8d923c82, 0x0cbfb4a2, |
834 | {0xffaa3a3f, 0x00000036, 0x00000299, 0xf3a82ab8, 0x53e0c13d}, | 835 | 0xebd08fd5}, |
835 | {0x6406cfeb, 0x00000023, 0x00000600, 0xa920b8e8, 0xe4e2acf4}, | 836 | {0x209172dd, 0x0000003b, 0x00000356, 0xb89e9c2b, 0xd7868138, |
836 | {0xb24aaa38, 0x0000003e, 0x000004a1, 0x657cc328, 0x5077b2c3}, | 837 | 0x64406c59}, |
837 | {0x58b2ab7c, 0x00000039, 0x000002b4, 0x3a17ee7e, 0x9dcb3643}, | 838 | {0x3ba4cc5b, 0x0000002f, 0x00000203, 0xe51601a9, 0x5b2a1032, |
838 | {0x3db85970, 0x00000006, 0x000002b6, 0x95268b59, 0xb9812c10}, | 839 | 0x7421890e}, |
839 | {0x857830c5, 0x00000003, 0x00000590, 0x4ef439d5, 0xf042161d}, | 840 | {0xfc62f297, 0x00000000, 0x00000079, 0x71a8e1a2, 0x5d88685f, |
840 | {0xe1fcd978, 0x0000003e, 0x000007d8, 0xae8d8699, 0xce0a1ef5}, | 841 | 0xe9347603}, |
841 | {0xb982a768, 0x00000016, 0x000006e0, 0x62fad3df, 0x5f8a067b}, | 842 | {0x64280b8b, 0x00000016, 0x000007ab, 0x0fa7a30c, 0xda3a455f, |
842 | {0x1d581ce8, 0x0000001e, 0x0000058b, 0xf0f5da53, 0x26e39eee}, | 843 | 0x1bef9060}, |
843 | {0x2456719b, 0x00000025, 0x00000503, 0x4296ac64, 0xd50e4c14}, | 844 | {0x97dd724b, 0x00000033, 0x000007ad, 0x5788b2f4, 0xd7326d32, |
844 | {0xfae6d8f2, 0x00000000, 0x0000055d, 0x057fdf2e, 0x2a31391a}, | 845 | 0x34720072}, |
845 | {0xcba828e3, 0x00000039, 0x000002ce, 0xe3f22351, 0x8f00877b}, | 846 | {0x61394b52, 0x00000035, 0x00000571, 0xc66525f1, 0xcabe7fef, |
846 | {0x13d25952, 0x0000000a, 0x0000072d, 0x76d4b4cc, 0x5eb67ec3}, | 847 | 0x48310f59}, |
847 | {0x0342be3f, 0x00000015, 0x00000599, 0xec75d9f1, 0x9d4d2826}, | 848 | {0x29b4faff, 0x00000024, 0x0000006e, 0xca13751e, 0x993648e0, |
848 | {0xeaa344e0, 0x00000014, 0x000004d8, 0x72a4c981, 0x2064ea06}, | 849 | 0x783a4213}, |
849 | {0xbbb52021, 0x0000003b, 0x00000272, 0x04af99fc, 0xaf042d35}, | 850 | {0x29bfb1dc, 0x0000000b, 0x00000244, 0x436c43f7, 0x429f7a59, |
850 | {0xb66384dc, 0x0000001d, 0x000007fc, 0xd7629116, 0x782bd801}, | 851 | 0x9e8efd41}, |
851 | {0x616c01b6, 0x00000022, 0x000002c8, 0x5b1dab30, 0x783ce7d2}, | 852 | {0x86ae934b, 0x00000035, 0x00000104, 0x0760ec93, 0x9cf7d0f4, |
852 | {0xce2bdaad, 0x00000016, 0x0000062a, 0x932535c8, 0x3f02926d}, | 853 | 0xfc3d34a5}, |
853 | {0x00fe84d7, 0x00000005, 0x00000205, 0x850e50aa, 0x753d649c}, | 854 | {0xc4c1024e, 0x0000002e, 0x000006b1, 0x6516a3ec, 0x19321f9c, |
854 | {0xbebdcb4c, 0x00000006, 0x0000055d, 0xbeaa37a2, 0x2d8c9eba}, | 855 | 0x17a52ae2}, |
855 | {0xd8b1a02a, 0x00000010, 0x00000387, 0x5017d2fc, 0x503541a5}, | 856 | {0x3287a80a, 0x00000026, 0x00000496, 0x0b257eb1, 0x754ebd51, |
856 | {0x3b96cad2, 0x00000036, 0x00000347, 0x1d2372ae, 0x926cd90b}, | 857 | 0x886d935a}, |
857 | {0xc94c1ed7, 0x00000005, 0x0000038b, 0x9e9fdb22, 0x144a9178}, | 858 | {0xa4db423e, 0x00000023, 0x0000045d, 0x9b3a66dc, 0x873e9f11, |
858 | {0x1aad454e, 0x00000025, 0x000002b2, 0xc3f6315c, 0x5c7a35b3}, | 859 | 0xeaaeaeb2}, |
859 | {0xa4fec9a6, 0x00000000, 0x000006d6, 0x90be5080, 0xa4107605}, | 860 | {0x7a1078df, 0x00000015, 0x0000014a, 0x8c2484c5, 0x6a628659, |
860 | {0x1bbe71e2, 0x0000001f, 0x000002fd, 0x4e504c3b, 0x284ccaf1}, | 861 | 0x8e900a4b}, |
861 | {0x4201c7e4, 0x00000002, 0x000002b7, 0x7822e3f9, 0x0cc912a9}, | 862 | {0x6048bd5b, 0x00000006, 0x0000006a, 0x897e3559, 0xac9961af, |
862 | {0x23fddc96, 0x00000003, 0x00000627, 0x8a385125, 0x07767e78}, | 863 | 0xd74662b1}, |
863 | {0xd82ba25c, 0x00000016, 0x0000063e, 0x98e4148a, 0x283330c9}, | 864 | {0xd8f9ea20, 0x0000003d, 0x00000277, 0x60eb905b, 0xed2aaf99, |
864 | {0x786f2032, 0x0000002d, 0x0000060f, 0xf201600a, 0xf561bfcd}, | 865 | 0xd26752ba}, |
865 | {0xfebe4e1f, 0x0000002a, 0x000004f2, 0x95e51961, 0xfd80dcab}, | 866 | {0xea5ec3b4, 0x0000002a, 0x000004fe, 0x869965dc, 0x6c1f833b, |
866 | {0x1a6e0a39, 0x00000008, 0x00000672, 0x8af6c2a5, 0x78dd84cb}, | 867 | 0x8b1fcd62}, |
867 | {0x56000ab8, 0x0000000e, 0x000000e5, 0x36bacb8f, 0x22ee1f77}, | 868 | {0x2dfb005d, 0x00000016, 0x00000345, 0x6a3b117e, 0xf05e8521, |
868 | {0x4717fe0c, 0x00000000, 0x000006ec, 0x8439f342, 0x5c8e03da}, | 869 | 0xf54342fe}, |
869 | {0xd5d5d68e, 0x0000003c, 0x000003a3, 0x46fff083, 0x177d1b39}, | 870 | {0x5a214ade, 0x00000020, 0x000005b6, 0x467f70be, 0xcb22ccd3, |
870 | {0xc25dd6c6, 0x00000024, 0x000006c0, 0x5ceb8eb4, 0x892b0d16}, | 871 | 0x5b95b988}, |
871 | {0xe9b11300, 0x00000023, 0x00000683, 0x07a5d59a, 0x6c6a3208}, | 872 | {0xf0ab9cca, 0x00000032, 0x00000515, 0xed223df3, 0x7f3ef01d, |
872 | {0x95cd285e, 0x00000001, 0x00000047, 0x7b3a4368, 0x0202c07e}, | 873 | 0x2e1176be}, |
873 | {0xd9245a25, 0x0000001e, 0x000003a6, 0xd33c1841, 0x1936c0d5}, | 874 | {0x91b444f9, 0x0000002e, 0x000007f8, 0x84e9a983, 0x5676756f, |
874 | {0x103279db, 0x00000006, 0x0000039b, 0xca09b8a0, 0x77d62892}, | 875 | 0x66120546}, |
875 | {0x1cba3172, 0x00000027, 0x000001c8, 0xcb377194, 0xebe682db}, | 876 | {0x1b5d2ddb, 0x0000002e, 0x0000012c, 0xba638c4c, 0x3f42047b, |
876 | {0x8f613739, 0x0000000c, 0x000001df, 0xb4b0bc87, 0x7710bd43}, | 877 | 0xf256a5cc}, |
877 | {0x1c6aa90d, 0x0000001b, 0x0000053c, 0x70559245, 0xda7894ac}, | 878 | {0xd824d1bb, 0x0000003a, 0x000007b5, 0x6288653b, 0x3a3ebea0, |
878 | {0xaabe5b93, 0x0000003d, 0x00000715, 0xcdbf42fa, 0x0c3b99e7}, | 879 | 0x4af1dd69}, |
879 | {0xf15dd038, 0x00000006, 0x000006db, 0x6e104aea, 0x8d5967f2}, | 880 | {0x0470180c, 0x00000034, 0x000001f0, 0x9d5b80d6, 0x3de08195, |
880 | {0x584dd49c, 0x00000020, 0x000007bc, 0x36b6cfd6, 0xad4e23b2}, | 881 | 0x56f0a04a}, |
881 | {0x5d8c9506, 0x00000020, 0x00000470, 0x4c62378e, 0x31d92640}, | 882 | {0xffaa3a3f, 0x00000036, 0x00000299, 0xf3a82ab8, 0x53e0c13d, |
882 | {0xb80d17b0, 0x00000032, 0x00000346, 0x22a5bb88, 0x9a7ec89f}, | 883 | 0x74f6b6b2}, |
883 | {0xdaf0592e, 0x00000023, 0x000007b0, 0x3cab3f99, 0x9b1fdd99}, | 884 | {0x6406cfeb, 0x00000023, 0x00000600, 0xa920b8e8, 0xe4e2acf4, |
884 | {0x4793cc85, 0x0000000d, 0x00000706, 0xe82e04f6, 0xed3db6b7}, | 885 | 0x085951fd}, |
885 | {0x82ebf64e, 0x00000009, 0x000007c3, 0x69d590a9, 0x9efa8499}, | 886 | {0xb24aaa38, 0x0000003e, 0x000004a1, 0x657cc328, 0x5077b2c3, |
886 | {0xb18a0319, 0x00000026, 0x000007db, 0x1cf98dcc, 0x8fa9ad6a}, | 887 | 0xc65387eb}, |
888 | {0x58b2ab7c, 0x00000039, 0x000002b4, 0x3a17ee7e, 0x9dcb3643, | ||
889 | 0x1ca9257b}, | ||
890 | {0x3db85970, 0x00000006, 0x000002b6, 0x95268b59, 0xb9812c10, | ||
891 | 0xfd196d76}, | ||
892 | {0x857830c5, 0x00000003, 0x00000590, 0x4ef439d5, 0xf042161d, | ||
893 | 0x5ef88339}, | ||
894 | {0xe1fcd978, 0x0000003e, 0x000007d8, 0xae8d8699, 0xce0a1ef5, | ||
895 | 0x2c3714d9}, | ||
896 | {0xb982a768, 0x00000016, 0x000006e0, 0x62fad3df, 0x5f8a067b, | ||
897 | 0x58576548}, | ||
898 | {0x1d581ce8, 0x0000001e, 0x0000058b, 0xf0f5da53, 0x26e39eee, | ||
899 | 0xfd7c57de}, | ||
900 | {0x2456719b, 0x00000025, 0x00000503, 0x4296ac64, 0xd50e4c14, | ||
901 | 0xd5fedd59}, | ||
902 | {0xfae6d8f2, 0x00000000, 0x0000055d, 0x057fdf2e, 0x2a31391a, | ||
903 | 0x1cc3b17b}, | ||
904 | {0xcba828e3, 0x00000039, 0x000002ce, 0xe3f22351, 0x8f00877b, | ||
905 | 0x270eed73}, | ||
906 | {0x13d25952, 0x0000000a, 0x0000072d, 0x76d4b4cc, 0x5eb67ec3, | ||
907 | 0x91ecbb11}, | ||
908 | {0x0342be3f, 0x00000015, 0x00000599, 0xec75d9f1, 0x9d4d2826, | ||
909 | 0x05ed8d0c}, | ||
910 | {0xeaa344e0, 0x00000014, 0x000004d8, 0x72a4c981, 0x2064ea06, | ||
911 | 0x0b09ad5b}, | ||
912 | {0xbbb52021, 0x0000003b, 0x00000272, 0x04af99fc, 0xaf042d35, | ||
913 | 0xf8d511fb}, | ||
914 | {0xb66384dc, 0x0000001d, 0x000007fc, 0xd7629116, 0x782bd801, | ||
915 | 0x5ad832cc}, | ||
916 | {0x616c01b6, 0x00000022, 0x000002c8, 0x5b1dab30, 0x783ce7d2, | ||
917 | 0x1214d196}, | ||
918 | {0xce2bdaad, 0x00000016, 0x0000062a, 0x932535c8, 0x3f02926d, | ||
919 | 0x5747218a}, | ||
920 | {0x00fe84d7, 0x00000005, 0x00000205, 0x850e50aa, 0x753d649c, | ||
921 | 0xde8f14de}, | ||
922 | {0xbebdcb4c, 0x00000006, 0x0000055d, 0xbeaa37a2, 0x2d8c9eba, | ||
923 | 0x3563b7b9}, | ||
924 | {0xd8b1a02a, 0x00000010, 0x00000387, 0x5017d2fc, 0x503541a5, | ||
925 | 0x071475d0}, | ||
926 | {0x3b96cad2, 0x00000036, 0x00000347, 0x1d2372ae, 0x926cd90b, | ||
927 | 0x54c79d60}, | ||
928 | {0xc94c1ed7, 0x00000005, 0x0000038b, 0x9e9fdb22, 0x144a9178, | ||
929 | 0x4c53eee6}, | ||
930 | {0x1aad454e, 0x00000025, 0x000002b2, 0xc3f6315c, 0x5c7a35b3, | ||
931 | 0x10137a3c}, | ||
932 | {0xa4fec9a6, 0x00000000, 0x000006d6, 0x90be5080, 0xa4107605, | ||
933 | 0xaa9d6c73}, | ||
934 | {0x1bbe71e2, 0x0000001f, 0x000002fd, 0x4e504c3b, 0x284ccaf1, | ||
935 | 0xb63d23e7}, | ||
936 | {0x4201c7e4, 0x00000002, 0x000002b7, 0x7822e3f9, 0x0cc912a9, | ||
937 | 0x7f53e9cf}, | ||
938 | {0x23fddc96, 0x00000003, 0x00000627, 0x8a385125, 0x07767e78, | ||
939 | 0x13c1cd83}, | ||
940 | {0xd82ba25c, 0x00000016, 0x0000063e, 0x98e4148a, 0x283330c9, | ||
941 | 0x49ff5867}, | ||
942 | {0x786f2032, 0x0000002d, 0x0000060f, 0xf201600a, 0xf561bfcd, | ||
943 | 0x8467f211}, | ||
944 | {0xfebe4e1f, 0x0000002a, 0x000004f2, 0x95e51961, 0xfd80dcab, | ||
945 | 0x3f9683b2}, | ||
946 | {0x1a6e0a39, 0x00000008, 0x00000672, 0x8af6c2a5, 0x78dd84cb, | ||
947 | 0x76a3f874}, | ||
948 | {0x56000ab8, 0x0000000e, 0x000000e5, 0x36bacb8f, 0x22ee1f77, | ||
949 | 0x863b702f}, | ||
950 | {0x4717fe0c, 0x00000000, 0x000006ec, 0x8439f342, 0x5c8e03da, | ||
951 | 0xdc6c58ff}, | ||
952 | {0xd5d5d68e, 0x0000003c, 0x000003a3, 0x46fff083, 0x177d1b39, | ||
953 | 0x0622cc95}, | ||
954 | {0xc25dd6c6, 0x00000024, 0x000006c0, 0x5ceb8eb4, 0x892b0d16, | ||
955 | 0xe85605cd}, | ||
956 | {0xe9b11300, 0x00000023, 0x00000683, 0x07a5d59a, 0x6c6a3208, | ||
957 | 0x31da5f06}, | ||
958 | {0x95cd285e, 0x00000001, 0x00000047, 0x7b3a4368, 0x0202c07e, | ||
959 | 0xa1f2e784}, | ||
960 | {0xd9245a25, 0x0000001e, 0x000003a6, 0xd33c1841, 0x1936c0d5, | ||
961 | 0xb07cc616}, | ||
962 | {0x103279db, 0x00000006, 0x0000039b, 0xca09b8a0, 0x77d62892, | ||
963 | 0xbf943b6c}, | ||
964 | {0x1cba3172, 0x00000027, 0x000001c8, 0xcb377194, 0xebe682db, | ||
965 | 0x2c01af1c}, | ||
966 | {0x8f613739, 0x0000000c, 0x000001df, 0xb4b0bc87, 0x7710bd43, | ||
967 | 0x0fe5f56d}, | ||
968 | {0x1c6aa90d, 0x0000001b, 0x0000053c, 0x70559245, 0xda7894ac, | ||
969 | 0xf8943b2d}, | ||
970 | {0xaabe5b93, 0x0000003d, 0x00000715, 0xcdbf42fa, 0x0c3b99e7, | ||
971 | 0xe4d89272}, | ||
972 | {0xf15dd038, 0x00000006, 0x000006db, 0x6e104aea, 0x8d5967f2, | ||
973 | 0x7c2f6bbb}, | ||
974 | {0x584dd49c, 0x00000020, 0x000007bc, 0x36b6cfd6, 0xad4e23b2, | ||
975 | 0xabbf388b}, | ||
976 | {0x5d8c9506, 0x00000020, 0x00000470, 0x4c62378e, 0x31d92640, | ||
977 | 0x1dca1f4e}, | ||
978 | {0xb80d17b0, 0x00000032, 0x00000346, 0x22a5bb88, 0x9a7ec89f, | ||
979 | 0x5c170e23}, | ||
980 | {0xdaf0592e, 0x00000023, 0x000007b0, 0x3cab3f99, 0x9b1fdd99, | ||
981 | 0xc0e9d672}, | ||
982 | {0x4793cc85, 0x0000000d, 0x00000706, 0xe82e04f6, 0xed3db6b7, | ||
983 | 0xc18bdc86}, | ||
984 | {0x82ebf64e, 0x00000009, 0x000007c3, 0x69d590a9, 0x9efa8499, | ||
985 | 0xa874fcdd}, | ||
986 | {0xb18a0319, 0x00000026, 0x000007db, 0x1cf98dcc, 0x8fa9ad6a, | ||
987 | 0x9dc0bb48}, | ||
887 | }; | 988 | }; |
888 | 989 | ||
889 | #include <linux/time.h> | 990 | #include <linux/time.h> |
890 | 991 | ||
891 | static int __init crc32_init(void) | 992 | static int __init crc32c_test(void) |
993 | { | ||
994 | int i; | ||
995 | int errors = 0; | ||
996 | int bytes = 0; | ||
997 | struct timespec start, stop; | ||
998 | u64 nsec; | ||
999 | unsigned long flags; | ||
1000 | |||
1001 | /* keep static to prevent cache warming code from | ||
1002 | * getting eliminated by the compiler */ | ||
1003 | static u32 crc; | ||
1004 | |||
1005 | /* pre-warm the cache */ | ||
1006 | for (i = 0; i < 100; i++) { | ||
1007 | bytes += 2*test[i].length; | ||
1008 | |||
1009 | crc ^= __crc32c_le(test[i].crc, test_buf + | ||
1010 | test[i].start, test[i].length); | ||
1011 | } | ||
1012 | |||
1013 | /* reduce OS noise */ | ||
1014 | local_irq_save(flags); | ||
1015 | local_irq_disable(); | ||
1016 | |||
1017 | getnstimeofday(&start); | ||
1018 | for (i = 0; i < 100; i++) { | ||
1019 | if (test[i].crc32c_le != __crc32c_le(test[i].crc, test_buf + | ||
1020 | test[i].start, test[i].length)) | ||
1021 | errors++; | ||
1022 | } | ||
1023 | getnstimeofday(&stop); | ||
1024 | |||
1025 | local_irq_restore(flags); | ||
1026 | local_irq_enable(); | ||
1027 | |||
1028 | nsec = stop.tv_nsec - start.tv_nsec + | ||
1029 | 1000000000 * (stop.tv_sec - start.tv_sec); | ||
1030 | |||
1031 | pr_info("crc32c: CRC_LE_BITS = %d\n", CRC_LE_BITS); | ||
1032 | |||
1033 | if (errors) | ||
1034 | pr_warn("crc32c: %d self tests failed\n", errors); | ||
1035 | else { | ||
1036 | pr_info("crc32c: self tests passed, processed %d bytes in %lld nsec\n", | ||
1037 | bytes, nsec); | ||
1038 | } | ||
1039 | |||
1040 | return 0; | ||
1041 | } | ||
1042 | |||
1043 | static int __init crc32_test(void) | ||
892 | { | 1044 | { |
893 | int i; | 1045 | int i; |
894 | int errors = 0; | 1046 | int errors = 0; |
@@ -947,10 +1099,17 @@ static int __init crc32_init(void) | |||
947 | return 0; | 1099 | return 0; |
948 | } | 1100 | } |
949 | 1101 | ||
1102 | static int __init crc32test_init(void) | ||
1103 | { | ||
1104 | crc32_test(); | ||
1105 | crc32c_test(); | ||
1106 | return 0; | ||
1107 | } | ||
1108 | |||
950 | static void __exit crc32_exit(void) | 1109 | static void __exit crc32_exit(void) |
951 | { | 1110 | { |
952 | } | 1111 | } |
953 | 1112 | ||
954 | module_init(crc32_init); | 1113 | module_init(crc32test_init); |
955 | module_exit(crc32_exit); | 1114 | module_exit(crc32_exit); |
956 | #endif /* CONFIG_CRC32_SELFTEST */ | 1115 | #endif /* CONFIG_CRC32_SELFTEST */ |