drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c- Extension
.c- Size
- 13042 bytes
- Lines
- 521
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
cn10k.hotx2_reg.hotx2_struct.h
Detected Declarations
function otx2_init_hw_opsfunction cn10k_lmtst_initfunction for_each_possible_cpufunction cn10k_sq_aq_initfunction cn10k_refill_pool_ptrsfunction cn10k_sqe_flushfunction cn10k_free_all_ipolicersfunction cn10k_alloc_leaf_profilefunction cn10k_alloc_matchall_ipolicerfunction cn10k_get_ingress_burst_cfgfunction cn10k_get_ingress_rate_cfgfunction cn10k_map_unmap_rq_policerfunction cn10k_free_leaf_profilefunction cn10k_free_matchall_ipolicerfunction cn10k_set_ipolicer_ratefunction cn10k_set_matchall_ipolicer_rateexport otx2_init_hw_opsexport cn10k_lmtst_init
Annotated Snippet
if (otx2_alloc_buffer(pfvf, cq, &bufptr)) {
if (num_ptrs--)
__cn10k_aura_freeptr(pfvf, cq->cq_idx, ptrs,
num_ptrs);
break;
}
cq->pool_ptrs--;
ptrs[num_ptrs] = pool->xsk_pool ?
(u64)bufptr : (u64)bufptr + OTX2_HEAD_ROOM;
num_ptrs++;
if (num_ptrs == NPA_MAX_BURST || cq->pool_ptrs == 0) {
__cn10k_aura_freeptr(pfvf, cq->cq_idx, ptrs,
num_ptrs);
num_ptrs = 1;
}
}
return cnt - cq->pool_ptrs;
}
void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx)
{
struct otx2_lmt_info *lmt_info;
struct otx2_nic *pfvf = dev;
u64 val = 0, tar_addr = 0;
lmt_info = per_cpu_ptr(pfvf->hw.lmt_info, smp_processor_id());
/* FIXME: val[0:10] LMT_ID.
* [12:15] no of LMTST - 1 in the burst.
* [19:63] data size of each LMTST in the burst except first.
*/
val = (lmt_info->lmt_id & 0x7FF);
/* Target address for LMTST flush tells HW how many 128bit
* words are present.
* tar_addr[6:4] size of first LMTST - 1 in units of 128b.
*/
tar_addr |= sq->io_addr | (((size / 16) - 1) & 0x7) << 4;
dma_wmb();
memcpy((u64 *)lmt_info->lmt_addr, sq->sqe_base, size);
cn10k_lmt_flush(val, tar_addr);
sq->head++;
sq->head &= (sq->sqe_cnt - 1);
}
int cn10k_free_all_ipolicers(struct otx2_nic *pfvf)
{
struct nix_bandprof_free_req *req;
int rc;
if (is_dev_otx2(pfvf->pdev))
return 0;
mutex_lock(&pfvf->mbox.lock);
req = otx2_mbox_alloc_msg_nix_bandprof_free(&pfvf->mbox);
if (!req) {
rc = -ENOMEM;
goto out;
}
/* Free all bandwidth profiles allocated */
req->free_all = true;
rc = otx2_sync_mbox_msg(&pfvf->mbox);
out:
mutex_unlock(&pfvf->mbox.lock);
return rc;
}
int cn10k_alloc_leaf_profile(struct otx2_nic *pfvf, u16 *leaf)
{
struct nix_bandprof_alloc_req *req;
struct nix_bandprof_alloc_rsp *rsp;
int rc;
req = otx2_mbox_alloc_msg_nix_bandprof_alloc(&pfvf->mbox);
if (!req)
return -ENOMEM;
req->prof_count[BAND_PROF_LEAF_LAYER] = 1;
rc = otx2_sync_mbox_msg(&pfvf->mbox);
if (rc)
goto out;
rsp = (struct nix_bandprof_alloc_rsp *)
otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
if (IS_ERR(rsp)) {
rc = PTR_ERR(rsp);
Annotation
- Immediate include surface: `cn10k.h`, `otx2_reg.h`, `otx2_struct.h`.
- Detected declarations: `function otx2_init_hw_ops`, `function cn10k_lmtst_init`, `function for_each_possible_cpu`, `function cn10k_sq_aq_init`, `function cn10k_refill_pool_ptrs`, `function cn10k_sqe_flush`, `function cn10k_free_all_ipolicers`, `function cn10k_alloc_leaf_profile`, `function cn10k_alloc_matchall_ipolicer`, `function cn10k_get_ingress_burst_cfg`.
- 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.
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.