drivers/crypto/amcc/crypto4xx_alg.c
Source file repositories/reference/linux-study-clean/drivers/crypto/amcc/crypto4xx_alg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/amcc/crypto4xx_alg.c- Extension
.c- Size
- 17172 bytes
- Lines
- 602
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/interrupt.hlinux/spinlock_types.hlinux/scatterlist.hlinux/dma-mapping.hcrypto/algapi.hcrypto/aead.hcrypto/aes.hcrypto/gcm.hcrypto/sha1.hcrypto/ctr.hcrypto/skcipher.hcrypto4xx_reg_def.hcrypto4xx_core.hcrypto4xx_sa.h
Detected Declarations
function Copyrightfunction set_dynamic_sa_command_1function crypto4xx_cryptfunction crypto4xx_encrypt_noiv_blockfunction crypto4xx_encrypt_iv_streamfunction crypto4xx_decrypt_noiv_blockfunction crypto4xx_decrypt_iv_streamfunction crypto4xx_encrypt_iv_blockfunction crypto4xx_decrypt_iv_blockfunction crypto4xx_setkey_aesfunction crypto4xx_setkey_aes_cbcfunction crypto4xx_setkey_aes_ecbfunction crypto4xx_setkey_rfc3686function crypto4xx_rfc3686_encryptfunction crypto4xx_rfc3686_decryptfunction crypto4xx_ctr_cryptfunction testsfunction crypto4xx_sk_setup_fallbackfunction crypto4xx_setkey_aes_ctrfunction crypto4xx_encrypt_ctrfunction crypto4xx_decrypt_ctrfunction crypto4xx_aead_need_fallbackfunction crypto4xx_aead_fallbackfunction crypto4xx_aead_setup_fallbackfunction crypto4xx_setkey_aes_ccmfunction crypto4xx_crypt_aes_ccmfunction crypto4xx_encrypt_aes_ccmfunction crypto4xx_decrypt_aes_ccmfunction crypto4xx_setauthsize_aeadfunction crypto4xx_aes_gcm_validate_keylenfunction crypto4xx_compute_gcm_hash_key_swfunction crypto4xx_setkey_aes_gcmfunction crypto4xx_crypt_aes_gcmfunction crypto4xx_encrypt_aes_gcmfunction crypto4xx_decrypt_aes_gcm
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* AMCC SoC PPC4xx Crypto Driver
*
* Copyright (c) 2008 Applied Micro Circuits Corporation.
* All rights reserved. James Hsiao <jhsiao@amcc.com>
*
* This file implements the Linux crypto algorithms.
*/
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/spinlock_types.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
#include <crypto/algapi.h>
#include <crypto/aead.h>
#include <crypto/aes.h>
#include <crypto/gcm.h>
#include <crypto/sha1.h>
#include <crypto/ctr.h>
#include <crypto/skcipher.h>
#include "crypto4xx_reg_def.h"
#include "crypto4xx_core.h"
#include "crypto4xx_sa.h"
static void set_dynamic_sa_command_0(struct dynamic_sa_ctl *sa, u32 save_h,
u32 save_iv, u32 ld_h, u32 ld_iv,
u32 hdr_proc, u32 h, u32 c, u32 pad_type,
u32 op_grp, u32 op, u32 dir)
{
sa->sa_command_0.w = 0;
sa->sa_command_0.bf.save_hash_state = save_h;
sa->sa_command_0.bf.save_iv = save_iv;
sa->sa_command_0.bf.load_hash_state = ld_h;
sa->sa_command_0.bf.load_iv = ld_iv;
sa->sa_command_0.bf.hdr_proc = hdr_proc;
sa->sa_command_0.bf.hash_alg = h;
sa->sa_command_0.bf.cipher_alg = c;
sa->sa_command_0.bf.pad_type = pad_type & 3;
sa->sa_command_0.bf.extend_pad = pad_type >> 2;
sa->sa_command_0.bf.op_group = op_grp;
sa->sa_command_0.bf.opcode = op;
sa->sa_command_0.bf.dir = dir;
}
static void set_dynamic_sa_command_1(struct dynamic_sa_ctl *sa, u32 cm,
u32 hmac_mc, u32 cfb, u32 esn,
u32 sn_mask, u32 mute, u32 cp_pad,
u32 cp_pay, u32 cp_hdr)
{
sa->sa_command_1.w = 0;
sa->sa_command_1.bf.crypto_mode31 = (cm & 4) >> 2;
sa->sa_command_1.bf.crypto_mode9_8 = cm & 3;
sa->sa_command_1.bf.feedback_mode = cfb;
sa->sa_command_1.bf.sa_rev = 1;
sa->sa_command_1.bf.hmac_muting = hmac_mc;
sa->sa_command_1.bf.extended_seq_num = esn;
sa->sa_command_1.bf.seq_num_mask = sn_mask;
sa->sa_command_1.bf.mutable_bit_proc = mute;
sa->sa_command_1.bf.copy_pad = cp_pad;
sa->sa_command_1.bf.copy_payload = cp_pay;
sa->sa_command_1.bf.copy_hdr = cp_hdr;
}
static inline int crypto4xx_crypt(struct skcipher_request *req,
const unsigned int ivlen, bool decrypt,
bool check_blocksize)
{
struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
__le32 iv[AES_IV_SIZE / 4];
if (check_blocksize && !IS_ALIGNED(req->cryptlen, AES_BLOCK_SIZE))
return -EINVAL;
if (ivlen)
crypto4xx_memcpy_to_le32(iv, req->iv, ivlen);
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
req->cryptlen, iv, ivlen, decrypt ? ctx->sa_in : ctx->sa_out,
ctx->sa_len, 0, NULL);
}
int crypto4xx_encrypt_noiv_block(struct skcipher_request *req)
{
return crypto4xx_crypt(req, 0, false, true);
}
int crypto4xx_encrypt_iv_stream(struct skcipher_request *req)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/spinlock_types.h`, `linux/scatterlist.h`, `linux/dma-mapping.h`, `crypto/algapi.h`, `crypto/aead.h`, `crypto/aes.h`.
- Detected declarations: `function Copyright`, `function set_dynamic_sa_command_1`, `function crypto4xx_crypt`, `function crypto4xx_encrypt_noiv_block`, `function crypto4xx_encrypt_iv_stream`, `function crypto4xx_decrypt_noiv_block`, `function crypto4xx_decrypt_iv_stream`, `function crypto4xx_encrypt_iv_block`, `function crypto4xx_decrypt_iv_block`, `function crypto4xx_setkey_aes`.
- 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.