drivers/crypto/rockchip/rk3288_crypto_skcipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/rockchip/rk3288_crypto_skcipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/rockchip/rk3288_crypto_skcipher.c- Extension
.c- Size
- 17107 bytes
- Lines
- 613
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/engine.hcrypto/internal/skcipher.hcrypto/scatterwalk.hlinux/device.hlinux/err.hlinux/kernel.hlinux/string.hrk3288_crypto.h
Detected Declarations
function Copyrightfunction rk_cipher_fallbackfunction rk_cipher_handle_reqfunction rk_aes_setkeyfunction rk_des_setkeyfunction rk_tdes_setkeyfunction rk_aes_ecb_encryptfunction rk_aes_ecb_decryptfunction rk_aes_cbc_encryptfunction rk_aes_cbc_decryptfunction rk_des_ecb_encryptfunction rk_des_ecb_decryptfunction rk_des_cbc_encryptfunction rk_des_cbc_decryptfunction rk_des3_ede_ecb_encryptfunction rk_des3_ede_ecb_decryptfunction rk_des3_ede_cbc_encryptfunction rk_des3_ede_cbc_decryptfunction rk_cipher_hw_initfunction crypto_dma_startfunction rk_cipher_runfunction rk_cipher_tfm_initfunction rk_cipher_tfm_exit
Annotated Snippet
if (!IS_ALIGNED(sgs->offset, sizeof(u32))) {
algt->stat_fb_align++;
return true;
}
if (!IS_ALIGNED(sgd->offset, sizeof(u32))) {
algt->stat_fb_align++;
return true;
}
stodo = min(len, sgs->length);
if (stodo % bs) {
algt->stat_fb_len++;
return true;
}
dtodo = min(len, sgd->length);
if (dtodo % bs) {
algt->stat_fb_len++;
return true;
}
if (stodo != dtodo) {
algt->stat_fb_sgdiff++;
return true;
}
len -= stodo;
sgs = sg_next(sgs);
sgd = sg_next(sgd);
}
return false;
}
static int rk_cipher_fallback(struct skcipher_request *areq)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
struct rk_cipher_ctx *op = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(areq);
struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
struct rk_crypto_tmp *algt = container_of(alg, struct rk_crypto_tmp, alg.skcipher.base);
int err;
algt->stat_fb++;
skcipher_request_set_tfm(&rctx->fallback_req, op->fallback_tfm);
skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags,
areq->base.complete, areq->base.data);
skcipher_request_set_crypt(&rctx->fallback_req, areq->src, areq->dst,
areq->cryptlen, areq->iv);
if (rctx->mode & RK_CRYPTO_DEC)
err = crypto_skcipher_decrypt(&rctx->fallback_req);
else
err = crypto_skcipher_encrypt(&rctx->fallback_req);
return err;
}
static int rk_cipher_handle_req(struct skcipher_request *req)
{
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *rkc;
struct crypto_engine *engine;
if (rk_cipher_need_fallback(req))
return rk_cipher_fallback(req);
rkc = get_rk_crypto();
engine = rkc->engine;
rctx->dev = rkc;
return crypto_transfer_skcipher_request_to_engine(engine, req);
}
static int rk_aes_setkey(struct crypto_skcipher *cipher,
const u8 *key, unsigned int keylen)
{
struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher);
struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
if (keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_192 &&
keylen != AES_KEYSIZE_256)
return -EINVAL;
ctx->keylen = keylen;
memcpy(ctx->key, key, keylen);
return crypto_skcipher_setkey(ctx->fallback_tfm, key, keylen);
}
static int rk_des_setkey(struct crypto_skcipher *cipher,
const u8 *key, unsigned int keylen)
{
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(cipher);
int err;
Annotation
- Immediate include surface: `crypto/engine.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `linux/device.h`, `linux/err.h`, `linux/kernel.h`, `linux/string.h`, `rk3288_crypto.h`.
- Detected declarations: `function Copyright`, `function rk_cipher_fallback`, `function rk_cipher_handle_req`, `function rk_aes_setkey`, `function rk_des_setkey`, `function rk_tdes_setkey`, `function rk_aes_ecb_encrypt`, `function rk_aes_ecb_decrypt`, `function rk_aes_cbc_encrypt`, `function rk_aes_cbc_decrypt`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.