drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
Source file repositories/reference/linux-study-clean/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c- Extension
.c- Size
- 43608 bytes
- Lines
- 1638
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
crypto/aes.hcrypto/authenc.hcrypto/cryptd.hcrypto/des.hcrypto/internal/aead.hcrypto/sha1.hcrypto/sha2.hcrypto/xts.hcrypto/scatterwalk.hlinux/sort.hlinux/module.hotx_cptvf.hotx_cptvf_algs.hotx_cptvf_reqmgr.h
Detected Declarations
struct cpt_device_descstruct cpt_device_tablefunction get_se_devicefunction validate_hmac_cipher_nullfunction otx_cpt_aead_callbackfunction output_iv_copybackfunction otx_cpt_skcipher_callbackfunction update_input_datafunction update_output_datafunction create_ctx_hdrfunction create_input_listfunction create_output_listfunction cpt_enc_decfunction otx_cpt_skcipher_encryptfunction otx_cpt_skcipher_decryptfunction otx_cpt_skcipher_xts_setkeyfunction cpt_des_setkeyfunction cpt_aes_setkeyfunction otx_cpt_skcipher_cbc_aes_setkeyfunction otx_cpt_skcipher_ecb_aes_setkeyfunction otx_cpt_skcipher_cbc_des3_setkeyfunction otx_cpt_skcipher_ecb_des3_setkeyfunction otx_cpt_enc_dec_initfunction cpt_aead_initfunction otx_cpt_aead_cbc_aes_sha1_initfunction otx_cpt_aead_cbc_aes_sha256_initfunction otx_cpt_aead_cbc_aes_sha384_initfunction otx_cpt_aead_cbc_aes_sha512_initfunction otx_cpt_aead_ecb_null_sha1_initfunction otx_cpt_aead_ecb_null_sha256_initfunction otx_cpt_aead_ecb_null_sha384_initfunction otx_cpt_aead_ecb_null_sha512_initfunction otx_cpt_aead_gcm_aes_initfunction otx_cpt_aead_exitfunction validationfunction swap_data32function swap_data64function swap_padfunction aead_hmac_initfunction otx_cpt_aead_cbc_aes_sha_setkeyfunction otx_cpt_aead_ecb_null_sha_setkeyfunction otx_cpt_aead_gcm_aes_setkeyfunction keyfunction create_aead_ctx_hdrfunction create_hmac_ctx_hdrfunction create_aead_input_listfunction create_aead_output_listfunction create_aead_null_input_list
Annotated Snippet
struct cpt_device_desc {
enum otx_cptpf_type pf_type;
struct pci_dev *dev;
int num_queues;
};
struct cpt_device_table {
atomic_t count;
struct cpt_device_desc desc[CPT_MAX_VF_NUM];
};
static struct cpt_device_table se_devices = {
.count = ATOMIC_INIT(0)
};
static struct cpt_device_table ae_devices = {
.count = ATOMIC_INIT(0)
};
static struct otx_cpt_sdesc *alloc_sdesc(struct crypto_shash *alg);
static inline int get_se_device(struct pci_dev **pdev, int *cpu_num)
{
int count, ret = 0;
count = atomic_read(&se_devices.count);
if (count < 1)
return -ENODEV;
*cpu_num = get_cpu();
if (se_devices.desc[0].pf_type == OTX_CPT_SE) {
/*
* On OcteonTX platform there is one CPT instruction queue bound
* to each VF. We get maximum performance if one CPT queue
* is available for each cpu otherwise CPT queues need to be
* shared between cpus.
*/
if (*cpu_num >= count)
*cpu_num %= count;
*pdev = se_devices.desc[*cpu_num].dev;
} else {
pr_err("Unknown PF type %d\n", se_devices.desc[0].pf_type);
ret = -EINVAL;
}
put_cpu();
return ret;
}
static inline int validate_hmac_cipher_null(struct otx_cpt_req_info *cpt_req)
{
struct otx_cpt_req_ctx *rctx;
struct aead_request *req;
struct crypto_aead *tfm;
req = container_of(cpt_req->areq, struct aead_request, base);
tfm = crypto_aead_reqtfm(req);
rctx = aead_request_ctx_dma(req);
if (memcmp(rctx->fctx.hmac.s.hmac_calc,
rctx->fctx.hmac.s.hmac_recv,
crypto_aead_authsize(tfm)) != 0)
return -EBADMSG;
return 0;
}
static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
{
struct otx_cpt_info_buffer *cpt_info = arg2;
struct crypto_async_request *areq = arg1;
struct otx_cpt_req_info *cpt_req;
struct pci_dev *pdev;
if (!cpt_info)
goto complete;
cpt_req = cpt_info->req;
if (!status) {
/*
* When selected cipher is NULL we need to manually
* verify whether calculated hmac value matches
* received hmac value
*/
if (cpt_req->req_type == OTX_CPT_AEAD_ENC_DEC_NULL_REQ &&
!cpt_req->is_enc)
status = validate_hmac_cipher_null(cpt_req);
}
pdev = cpt_info->pdev;
do_request_cleanup(pdev, cpt_info);
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/authenc.h`, `crypto/cryptd.h`, `crypto/des.h`, `crypto/internal/aead.h`, `crypto/sha1.h`, `crypto/sha2.h`, `crypto/xts.h`.
- Detected declarations: `struct cpt_device_desc`, `struct cpt_device_table`, `function get_se_device`, `function validate_hmac_cipher_null`, `function otx_cpt_aead_callback`, `function output_iv_copyback`, `function otx_cpt_skcipher_callback`, `function update_input_data`, `function update_output_data`, `function create_ctx_hdr`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.