drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c- Extension
.c- Size
- 27205 bytes
- Lines
- 1043
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
net/xfrm.hlinux/netdevice.hlinux/bitfield.hcrypto/aead.hcrypto/gcm.hotx2_common.hotx2_struct.hcn10k_ipsec.h
Detected Declarations
function Copyrightfunction cn10k_cpt_device_set_inusefunction cn10k_cpt_device_set_availablefunction cn10k_cpt_device_set_unavailablefunction cn10k_outb_cptlf_attachfunction cn10k_outb_cptlf_detachfunction cn10k_outb_cptlf_allocfunction cn10k_outb_cptlf_freefunction cn10k_outb_cptlf_configfunction cn10k_outb_cptlf_iq_enablefunction cn10k_outb_cptlf_iq_disablefunction cn10k_outb_cptlf_iq_allocfunction cn10k_outb_cptlf_iq_freefunction cn10k_outb_cptlf_iq_initfunction cn10k_outb_cptlf_initfunction cn10k_outb_cpt_initfunction cn10k_outb_cpt_cleanfunction cn10k_cpt_inst_flushfunction cn10k_wait_for_cpt_resposefunction cn10k_outb_write_safunction cn10k_ipsec_get_hw_ctx_offsetfunction cn10k_ipsec_get_ctx_push_sizefunction cn10k_ipsec_get_aes_key_lenfunction cn10k_outb_prepare_safunction cn10k_ipsec_validate_statefunction cn10k_ipsec_inb_add_statefunction cn10k_ipsec_outb_add_statefunction cn10k_ipsec_add_statefunction cn10k_ipsec_del_statefunction cn10k_ipsec_sa_wq_handlerfunction cn10k_ipsec_ethtool_initfunction cn10k_ipsec_initfunction cn10k_ipsec_cleanfunction cn10k_ipsec_get_ip_data_lenfunction otx2_sqe_add_sg_ipsecfunction cn10k_ipsec_get_param1function cn10k_ipsec_transmitexport cn10k_ipsec_initexport cn10k_ipsec_clean
Annotated Snippet
if (timeout-- < 0) {
netdev_err(pf->netdev, "Timeout to cleanup CPT IQ\n");
break;
}
} while (1);
/* Disable executions in the LF's queue,
* the queue should be empty at this point
*/
reg_val &= ~BIT_ULL(16);
otx2_write64(pf, CN10K_CPT_LF_INPROG, reg_val);
/* Wait for instruction queue to become empty */
cnt = 0;
do {
reg_val = otx2_read64(pf, CN10K_CPT_LF_INPROG);
if (reg_val & BIT_ULL(31))
cnt = 0;
else
cnt++;
reg_val = otx2_read64(pf, CN10K_CPT_LF_Q_GRP_PTR);
nq_ptr = FIELD_GET(CPT_LF_Q_GRP_PTR_DQ_PTR, reg_val);
dq_ptr = FIELD_GET(CPT_LF_Q_GRP_PTR_DQ_PTR, reg_val);
} while ((cnt < 10) && (nq_ptr != dq_ptr));
cnt = 0;
do {
reg_val = otx2_read64(pf, CN10K_CPT_LF_INPROG);
inflight = FIELD_GET(CPT_LF_INPROG_INFLIGHT, reg_val);
grb_cnt = FIELD_GET(CPT_LF_INPROG_GRB_CNT, reg_val);
gwb_cnt = FIELD_GET(CPT_LF_INPROG_GWB_CNT, reg_val);
if (inflight == 0 && gwb_cnt < 40 &&
(grb_cnt == 0 || grb_cnt == 40))
cnt++;
else
cnt = 0;
} while (cnt < 10);
}
/* Allocate memory for CPT outbound Instruction queue.
* Instruction queue memory format is:
* -----------------------------
* | Instruction Group memory |
* | (CPT_LF_Q_SIZE[SIZE_DIV40] |
* | x 16 Bytes) |
* | |
* ----------------------------- <-- CPT_LF_Q_BASE[ADDR]
* | Flow Control (128 Bytes) |
* | |
* -----------------------------
* | Instruction Memory |
* | (CPT_LF_Q_SIZE[SIZE_DIV40] |
* | × 40 × 64 bytes) |
* | |
* -----------------------------
*/
static int cn10k_outb_cptlf_iq_alloc(struct otx2_nic *pf)
{
struct cn10k_cpt_inst_queue *iq = &pf->ipsec.iq;
iq->size = CN10K_CPT_INST_QLEN_BYTES + CN10K_CPT_Q_FC_LEN +
CN10K_CPT_INST_GRP_QLEN_BYTES + OTX2_ALIGN;
iq->real_vaddr = dma_alloc_coherent(pf->dev, iq->size,
&iq->real_dma_addr, GFP_KERNEL);
if (!iq->real_vaddr)
return -ENOMEM;
/* iq->vaddr/dma_addr points to Flow Control location */
iq->vaddr = iq->real_vaddr + CN10K_CPT_INST_GRP_QLEN_BYTES;
iq->dma_addr = iq->real_dma_addr + CN10K_CPT_INST_GRP_QLEN_BYTES;
/* Align pointers */
iq->vaddr = PTR_ALIGN(iq->vaddr, OTX2_ALIGN);
iq->dma_addr = PTR_ALIGN(iq->dma_addr, OTX2_ALIGN);
return 0;
}
static void cn10k_outb_cptlf_iq_free(struct otx2_nic *pf)
{
struct cn10k_cpt_inst_queue *iq = &pf->ipsec.iq;
if (iq->real_vaddr)
dma_free_coherent(pf->dev, iq->size, iq->real_vaddr,
iq->real_dma_addr);
iq->real_vaddr = NULL;
iq->vaddr = NULL;
}
Annotation
- Immediate include surface: `net/xfrm.h`, `linux/netdevice.h`, `linux/bitfield.h`, `crypto/aead.h`, `crypto/gcm.h`, `otx2_common.h`, `otx2_struct.h`, `cn10k_ipsec.h`.
- Detected declarations: `function Copyright`, `function cn10k_cpt_device_set_inuse`, `function cn10k_cpt_device_set_available`, `function cn10k_cpt_device_set_unavailable`, `function cn10k_outb_cptlf_attach`, `function cn10k_outb_cptlf_detach`, `function cn10k_outb_cptlf_alloc`, `function cn10k_outb_cptlf_free`, `function cn10k_outb_cptlf_config`, `function cn10k_outb_cptlf_iq_enable`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.