forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'for-5.18/64bit-pi-2022-03-25' of git://git.kernel.dk/linux…
…-block Pull block layer 64-bit data integrity support from Jens Axboe: "This adds support for 64-bit data integrity in the block layer and in NVMe" * tag 'for-5.18/64bit-pi-2022-03-25' of git://git.kernel.dk/linux-block: crypto: fix crc64 testmgr digest byte order nvme: add support for enhanced metadata block: add pi for extended integrity crypto: add rocksoft 64b crc guard tag framework lib: add rocksoft model crc64 linux/kernel: introduce lower_48_bits function asm-generic: introduce be48 unaligned accessors nvme: allow integrity on extended metadata formats block: support pi with extended metadata
- Loading branch information
Showing
21 changed files
with
770 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
|
||
#include <linux/crc64.h> | ||
#include <linux/module.h> | ||
#include <crypto/internal/hash.h> | ||
#include <asm/unaligned.h> | ||
|
||
static int chksum_init(struct shash_desc *desc) | ||
{ | ||
u64 *crc = shash_desc_ctx(desc); | ||
|
||
*crc = 0; | ||
|
||
return 0; | ||
} | ||
|
||
static int chksum_update(struct shash_desc *desc, const u8 *data, | ||
unsigned int length) | ||
{ | ||
u64 *crc = shash_desc_ctx(desc); | ||
|
||
*crc = crc64_rocksoft_generic(*crc, data, length); | ||
|
||
return 0; | ||
} | ||
|
||
static int chksum_final(struct shash_desc *desc, u8 *out) | ||
{ | ||
u64 *crc = shash_desc_ctx(desc); | ||
|
||
put_unaligned_le64(*crc, out); | ||
return 0; | ||
} | ||
|
||
static int __chksum_finup(u64 crc, const u8 *data, unsigned int len, u8 *out) | ||
{ | ||
crc = crc64_rocksoft_generic(crc, data, len); | ||
put_unaligned_le64(crc, out); | ||
return 0; | ||
} | ||
|
||
static int chksum_finup(struct shash_desc *desc, const u8 *data, | ||
unsigned int len, u8 *out) | ||
{ | ||
u64 *crc = shash_desc_ctx(desc); | ||
|
||
return __chksum_finup(*crc, data, len, out); | ||
} | ||
|
||
static int chksum_digest(struct shash_desc *desc, const u8 *data, | ||
unsigned int length, u8 *out) | ||
{ | ||
return __chksum_finup(0, data, length, out); | ||
} | ||
|
||
static struct shash_alg alg = { | ||
.digestsize = sizeof(u64), | ||
.init = chksum_init, | ||
.update = chksum_update, | ||
.final = chksum_final, | ||
.finup = chksum_finup, | ||
.digest = chksum_digest, | ||
.descsize = sizeof(u64), | ||
.base = { | ||
.cra_name = CRC64_ROCKSOFT_STRING, | ||
.cra_driver_name = "crc64-rocksoft-generic", | ||
.cra_priority = 200, | ||
.cra_blocksize = 1, | ||
.cra_module = THIS_MODULE, | ||
} | ||
}; | ||
|
||
static int __init crc64_rocksoft_init(void) | ||
{ | ||
return crypto_register_shash(&alg); | ||
} | ||
|
||
static void __exit crc64_rocksoft_exit(void) | ||
{ | ||
crypto_unregister_shash(&alg); | ||
} | ||
|
||
module_init(crc64_rocksoft_init); | ||
module_exit(crc64_rocksoft_exit); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_DESCRIPTION("Rocksoft model CRC64 calculation."); | ||
MODULE_ALIAS_CRYPTO("crc64-rocksoft"); | ||
MODULE_ALIAS_CRYPTO("crc64-rocksoft-generic"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.