drivers/crypto/cavium/nitrox/nitrox_skcipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/cavium/nitrox/nitrox_skcipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/cavium/nitrox/nitrox_skcipher.c- Extension
.c- Size
- 14125 bytes
- Lines
- 532
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/crypto.hlinux/kernel.hlinux/module.hlinux/printk.hcrypto/aes.hcrypto/skcipher.hcrypto/scatterwalk.hcrypto/ctr.hcrypto/internal/des.hcrypto/xts.hnitrox_dev.hnitrox_common.hnitrox_req.h
Detected Declarations
struct nitrox_cipherfunction flexi_cipher_typefunction free_src_sglistfunction free_dst_sglistfunction nitrox_skcipher_callbackfunction nitrox_cbc_cipher_callbackfunction nitrox_skcipher_initfunction nitrox_cbc_initfunction nitrox_skcipher_exitfunction nitrox_skcipher_setkeyfunction nitrox_aes_setkeyfunction alloc_src_sglistfunction alloc_dst_sglistfunction nitrox_skcipher_cryptfunction nitrox_cbc_decryptfunction nitrox_aes_encryptfunction nitrox_aes_decryptfunction nitrox_3des_setkeyfunction nitrox_3des_encryptfunction nitrox_3des_decryptfunction nitrox_aes_xts_setkeyfunction nitrox_aes_ctr_rfc3686_setkeyfunction nitrox_register_skciphersfunction nitrox_unregister_skciphers
Annotated Snippet
struct nitrox_cipher {
const char *name;
enum flexi_cipher value;
};
/*
* supported cipher list
*/
static const struct nitrox_cipher flexi_cipher_table[] = {
{ "null", CIPHER_NULL },
{ "cbc(des3_ede)", CIPHER_3DES_CBC },
{ "ecb(des3_ede)", CIPHER_3DES_ECB },
{ "cbc(aes)", CIPHER_AES_CBC },
{ "ecb(aes)", CIPHER_AES_ECB },
{ "cfb(aes)", CIPHER_AES_CFB },
{ "rfc3686(ctr(aes))", CIPHER_AES_CTR },
{ "xts(aes)", CIPHER_AES_XTS },
{ "cts(cbc(aes))", CIPHER_AES_CBC_CTS },
{ NULL, CIPHER_INVALID }
};
static enum flexi_cipher flexi_cipher_type(const char *name)
{
const struct nitrox_cipher *cipher = flexi_cipher_table;
while (cipher->name) {
if (!strcmp(cipher->name, name))
break;
cipher++;
}
return cipher->value;
}
static void free_src_sglist(struct skcipher_request *skreq)
{
struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
kfree(nkreq->src);
}
static void free_dst_sglist(struct skcipher_request *skreq)
{
struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
kfree(nkreq->dst);
}
static void nitrox_skcipher_callback(void *arg, int err)
{
struct skcipher_request *skreq = arg;
free_src_sglist(skreq);
free_dst_sglist(skreq);
if (err) {
pr_err_ratelimited("request failed status 0x%0x\n", err);
err = -EINVAL;
}
skcipher_request_complete(skreq, err);
}
static void nitrox_cbc_cipher_callback(void *arg, int err)
{
struct skcipher_request *skreq = arg;
struct nitrox_kcrypt_request *nkreq = skcipher_request_ctx(skreq);
struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(skreq);
int ivsize = crypto_skcipher_ivsize(cipher);
unsigned int start = skreq->cryptlen - ivsize;
if (err) {
nitrox_skcipher_callback(arg, err);
return;
}
if (nkreq->creq.ctrl.s.arg == ENCRYPT) {
scatterwalk_map_and_copy(skreq->iv, skreq->dst, start, ivsize,
0);
} else {
if (skreq->src != skreq->dst) {
scatterwalk_map_and_copy(skreq->iv, skreq->src, start,
ivsize, 0);
} else {
memcpy(skreq->iv, nkreq->iv_out, ivsize);
kfree(nkreq->iv_out);
}
}
nitrox_skcipher_callback(arg, err);
}
Annotation
- Immediate include surface: `linux/crypto.h`, `linux/kernel.h`, `linux/module.h`, `linux/printk.h`, `crypto/aes.h`, `crypto/skcipher.h`, `crypto/scatterwalk.h`, `crypto/ctr.h`.
- Detected declarations: `struct nitrox_cipher`, `function flexi_cipher_type`, `function free_src_sglist`, `function free_dst_sglist`, `function nitrox_skcipher_callback`, `function nitrox_cbc_cipher_callback`, `function nitrox_skcipher_init`, `function nitrox_cbc_init`, `function nitrox_skcipher_exit`, `function nitrox_skcipher_setkey`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.