drivers/crypto/marvell/octeontx2/cn10k_cpt.c
Source file repositories/reference/linux-study-clean/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/marvell/octeontx2/cn10k_cpt.c- Extension
.c- Size
- 5998 bytes
- Lines
- 224
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/soc/marvell/octeontx2/asm.hotx2_cptpf.hotx2_cptvf.hotx2_cptlf.hcn10k_cpt.hotx2_cpt_common.h
Detected Declarations
function cn10k_cpt_send_cmdfunction cn10k_cpt_lmtst_freefunction cn10k_cpt_lmtst_allocfunction cn10k_cptpf_lmtst_initfunction cn10k_cptvf_lmtst_initfunction cn10k_cpt_hw_ctx_clearfunction cn10k_cpt_hw_ctx_setfunction cn10k_cpt_hw_ctx_initfunction cn10k_cpt_ctx_flushfunction cptvf_hw_ops_get
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2021 Marvell. */
#include <linux/soc/marvell/octeontx2/asm.h>
#include "otx2_cptpf.h"
#include "otx2_cptvf.h"
#include "otx2_cptlf.h"
#include "cn10k_cpt.h"
#include "otx2_cpt_common.h"
static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
struct otx2_cptlf_info *lf);
static struct cpt_hw_ops otx2_hw_ops = {
.send_cmd = otx2_cpt_send_cmd,
.cpt_get_compcode = otx2_cpt_get_compcode,
.cpt_get_uc_compcode = otx2_cpt_get_uc_compcode,
.cpt_sg_info_create = otx2_sg_info_create,
};
static struct cpt_hw_ops cn10k_hw_ops = {
.send_cmd = cn10k_cpt_send_cmd,
.cpt_get_compcode = cn10k_cpt_get_compcode,
.cpt_get_uc_compcode = cn10k_cpt_get_uc_compcode,
.cpt_sg_info_create = otx2_sg_info_create,
};
static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
struct otx2_cptlf_info *lf)
{
void *lmtline = lf->lfs->lmt_info.base + (lf->slot * LMTLINE_SIZE);
u64 val = (lf->slot & 0x7FF);
u64 tar_addr = 0;
/* tar_addr<6:4> = Size of first LMTST - 1 in units of 128b. */
tar_addr |= (__force u64)lf->ioreg |
(((OTX2_CPT_INST_SIZE/16) - 1) & 0x7) << 4;
/*
* Make sure memory areas pointed in CPT_INST_S
* are flushed before the instruction is sent to CPT
*/
dma_wmb();
/* Copy CPT command to LMTLINE */
memcpy(lmtline, cptinst, insts_num * OTX2_CPT_INST_SIZE);
cn10k_lmt_flush(val, tar_addr);
}
void cn10k_cpt_lmtst_free(struct pci_dev *pdev, struct otx2_cptlfs_info *lfs)
{
struct otx2_lmt_info *lmt_info = &lfs->lmt_info;
if (!lmt_info->base)
return;
dma_free_attrs(&pdev->dev, lmt_info->size,
lmt_info->base - lmt_info->align,
lmt_info->iova - lmt_info->align,
DMA_ATTR_FORCE_CONTIGUOUS);
}
EXPORT_SYMBOL_NS_GPL(cn10k_cpt_lmtst_free, "CRYPTO_DEV_OCTEONTX2_CPT");
static int cn10k_cpt_lmtst_alloc(struct pci_dev *pdev,
struct otx2_cptlfs_info *lfs, u32 size)
{
struct otx2_lmt_info *lmt_info = &lfs->lmt_info;
dma_addr_t align_iova;
dma_addr_t iova;
lmt_info->base = dma_alloc_attrs(&pdev->dev, size, &iova, GFP_KERNEL,
DMA_ATTR_FORCE_CONTIGUOUS);
if (!lmt_info->base)
return -ENOMEM;
align_iova = ALIGN((u64)iova, LMTLINE_ALIGN);
lmt_info->iova = align_iova;
lmt_info->align = align_iova - iova;
lmt_info->size = size;
lmt_info->base += lmt_info->align;
return 0;
}
int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf)
{
struct pci_dev *pdev = cptpf->pdev;
u32 size;
int ret;
if (!test_bit(CN10K_LMTST, &cptpf->cap_flag)) {
cptpf->lfs.ops = &otx2_hw_ops;
Annotation
- Immediate include surface: `linux/soc/marvell/octeontx2/asm.h`, `otx2_cptpf.h`, `otx2_cptvf.h`, `otx2_cptlf.h`, `cn10k_cpt.h`, `otx2_cpt_common.h`.
- Detected declarations: `function cn10k_cpt_send_cmd`, `function cn10k_cpt_lmtst_free`, `function cn10k_cpt_lmtst_alloc`, `function cn10k_cptpf_lmtst_init`, `function cn10k_cptvf_lmtst_init`, `function cn10k_cpt_hw_ctx_clear`, `function cn10k_cpt_hw_ctx_set`, `function cn10k_cpt_hw_ctx_init`, `function cn10k_cpt_ctx_flush`, `function cptvf_hw_ops_get`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.