drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
Source file repositories/reference/linux-study-clean/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c- Extension
.c- Size
- 46187 bytes
- Lines
- 1701
- 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/gcm.hcrypto/scatterwalk.hlinux/sort.hlinux/module.hotx2_cptvf.hotx2_cptvf_algs.hotx2_cpt_reqmgr.hcn10k_cpt.h
Detected Declarations
struct cpt_device_descstruct cpt_device_tablefunction get_se_devicefunction validate_hmac_cipher_nullfunction otx2_cpt_aead_callbackfunction output_iv_copybackfunction otx2_cpt_skcipher_callbackfunction update_input_datafunction update_output_datafunction create_ctx_hdrfunction create_input_listfunction create_output_listfunction skcipher_do_fallbackfunction cpt_enc_decfunction otx2_cpt_skcipher_encryptfunction otx2_cpt_skcipher_decryptfunction otx2_cpt_skcipher_xts_setkeyfunction cpt_des_setkeyfunction cpt_aes_setkeyfunction otx2_cpt_skcipher_cbc_aes_setkeyfunction otx2_cpt_skcipher_ecb_aes_setkeyfunction otx2_cpt_skcipher_cbc_des3_setkeyfunction otx2_cpt_skcipher_ecb_des3_setkeyfunction cpt_skcipher_fallback_initfunction otx2_cpt_enc_dec_initfunction otx2_cpt_skcipher_exitfunction cpt_aead_fallback_initfunction cpt_aead_initfunction otx2_cpt_aead_cbc_aes_sha1_initfunction otx2_cpt_aead_cbc_aes_sha256_initfunction otx2_cpt_aead_cbc_aes_sha384_initfunction otx2_cpt_aead_cbc_aes_sha512_initfunction otx2_cpt_aead_ecb_null_sha1_initfunction otx2_cpt_aead_ecb_null_sha256_initfunction otx2_cpt_aead_ecb_null_sha384_initfunction otx2_cpt_aead_ecb_null_sha512_initfunction otx2_cpt_aead_gcm_aes_initfunction otx2_cpt_aead_exitfunction otx2_cpt_aead_gcm_set_authsizefunction otx2_cpt_aead_set_authsizefunction otx2_cpt_aead_null_set_authsizefunction swap_data32function swap_data64function swap_padfunction aead_hmac_initfunction otx2_cpt_aead_cbc_aes_sha_setkeyfunction otx2_cpt_aead_ecb_null_sha_setkeyfunction otx2_cpt_aead_gcm_aes_setkey
Annotated Snippet
struct cpt_device_desc {
struct pci_dev *dev;
int num_queues;
};
struct cpt_device_table {
atomic_t count;
struct cpt_device_desc desc[OTX2_CPT_MAX_LFS_NUM];
};
static struct cpt_device_table se_devices = {
.count = ATOMIC_INIT(0)
};
static struct otx2_cpt_sdesc *alloc_sdesc(struct crypto_shash *alg);
static inline int get_se_device(struct pci_dev **pdev, int *cpu_num)
{
int count;
count = atomic_read(&se_devices.count);
if (count < 1)
return -ENODEV;
*cpu_num = get_cpu();
/*
* On OcteonTX2 platform CPT instruction queue is bound to each
* local function LF, in turn LFs can be attached to PF
* or VF therefore we always use first device. 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 >= se_devices.desc[0].num_queues)
*cpu_num %= se_devices.desc[0].num_queues;
*pdev = se_devices.desc[0].dev;
put_cpu();
return 0;
}
static inline int validate_hmac_cipher_null(struct otx2_cpt_req_info *cpt_req)
{
struct otx2_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 otx2_cpt_aead_callback(int status, void *arg1, void *arg2)
{
struct otx2_cpt_inst_info *inst_info = arg2;
struct crypto_async_request *areq = arg1;
struct otx2_cpt_req_info *cpt_req;
struct pci_dev *pdev;
if (inst_info) {
cpt_req = inst_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 ==
OTX2_CPT_AEAD_ENC_DEC_NULL_REQ &&
!cpt_req->is_enc)
status = validate_hmac_cipher_null(cpt_req);
}
pdev = inst_info->pdev;
otx2_cpt_info_destroy(pdev, inst_info);
}
if (areq)
crypto_request_complete(areq, status);
}
static void output_iv_copyback(struct crypto_async_request *areq)
{
struct otx2_cpt_req_info *req_info;
struct otx2_cpt_req_ctx *rctx;
struct skcipher_request *sreq;
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 otx2_cpt_aead_callback`, `function output_iv_copyback`, `function otx2_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.