drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c- Extension
.c- Size
- 120394 bytes
- Lines
- 4397
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/module.hlinux/pci.hrvu_struct.hrvu_reg.hrvu.hnpc.hcgx.hnpc_profile.hrvu_npc_hash.hcn20k/npc.hrvu_npc.hcn20k/reg.h
Detected Declarations
function is_npc_intf_txfunction is_npc_intf_rxfunction is_npc_interface_validfunction rvu_npc_get_tx_nibble_cfgfunction rvu_npc_set_pkindfunction rvu_npc_get_pkindfunction npc_config_ts_kpuactionfunction npc_get_ucast_mcam_indexfunction npc_get_nixlf_mcam_indexfunction npc_get_bankfunction is_mcam_entry_enabledfunction npc_enable_mcam_entryfunction npc_clear_mcam_entryfunction npc_get_keywordfunction npc_fill_entrywordfunction npc_get_default_entry_actionfunction npc_fixup_vf_rulefunction npc_config_mcam_entryfunction npc_read_mcam_entryfunction npc_copy_mcam_entryfunction npc_get_mcam_actionfunction npc_set_mcam_actionfunction rvu_get_cpt_chan_maskfunction rvu_npc_install_ucast_entryfunction rvu_npc_install_promisc_entryfunction is_pf_cgxmappedfunction rvu_npc_enable_promisc_entryfunction rvu_npc_install_bcast_match_entryfunction rvu_npc_install_allmulti_entryfunction rvu_npc_enable_allmulti_entryfunction npc_update_vf_flow_entryfunction list_for_each_entryfunction npc_update_rx_action_with_alg_idxfunction rvu_npc_update_flowkey_alg_idxfunction npc_enadis_default_mce_entryfunction npc_enadis_default_entriesfunction rvu_npc_disable_default_entriesfunction rvu_npc_enable_mcam_by_entry_indexfunction list_for_each_entry_safefunction rvu_npc_enable_default_entriesfunction rvu_npc_disable_mcam_entriesfunction rvu_npc_free_mcam_entriesfunction npc_program_mkex_rxfunction npc_program_mkex_txfunction npc_program_mkex_profilefunction npc_fwdb_prfl_img_mapfunction npc_load_mkex_profilefunction npc_config_kpuaction
Annotated Snippet
if (is_lbk_vf(rvu, pcifunc)) {
if (promisc == USHRT_MAX)
return -EINVAL;
return promisc;
}
if (is_cgx_vf(rvu, pcifunc)) {
if (ucast == USHRT_MAX)
return -EINVAL;
return ucast;
}
switch (type) {
case NIXLF_BCAST_ENTRY:
if (bcast == USHRT_MAX)
return -EINVAL;
return bcast;
case NIXLF_ALLMULTI_ENTRY:
if (mcast == USHRT_MAX)
return -EINVAL;
return mcast;
case NIXLF_PROMISC_ENTRY:
if (promisc == USHRT_MAX)
return -EINVAL;
return promisc;
case NIXLF_UCAST_ENTRY:
if (ucast == USHRT_MAX)
return -EINVAL;
return ucast;
default:
return -EINVAL;
}
}
/* Check if this is for a PF */
pf = rvu_get_pf(rvu->pdev, pcifunc);
if (pf && !(pcifunc & RVU_PFVF_FUNC_MASK)) {
/* Reserved entries exclude PF0 */
pf--;
index = mcam->pf_offset + (pf * RSVD_MCAM_ENTRIES_PER_PF);
/* Broadcast address matching entry should be first so
* that the packet can be replicated to all VFs.
*/
if (type == NIXLF_BCAST_ENTRY)
return index;
else if (type == NIXLF_ALLMULTI_ENTRY)
return index + 1;
else if (type == NIXLF_PROMISC_ENTRY)
return index + 2;
}
return npc_get_ucast_mcam_index(mcam, pcifunc, nixlf);
}
int npc_get_bank(struct npc_mcam *mcam, int index)
{
struct rvu_hwinfo *hw = container_of(mcam, struct rvu_hwinfo, mcam);
int bank = index / mcam->banksize;
struct rvu *rvu = hw->rvu;
if (is_cn20k(rvu->pdev))
return bank;
/* 0,1 & 2,3 banks are combined for this keysize */
if (mcam->keysize == NPC_MCAM_KEY_X2)
return bank ? 2 : 0;
return bank;
}
bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam,
int blkaddr, int index)
{
int bank = npc_get_bank(mcam, index);
u64 cfg;
index &= (mcam->banksize - 1);
if (is_cn20k(rvu->pdev))
cfg = rvu_read64(rvu, blkaddr,
NPC_AF_CN20K_MCAMEX_BANKX_CFG_EXT(index,
bank));
else
cfg = rvu_read64(rvu, blkaddr,
NPC_AF_MCAMEX_BANKX_CFG(index, bank));
return (cfg & 1);
}
void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/module.h`, `linux/pci.h`, `rvu_struct.h`, `rvu_reg.h`, `rvu.h`, `npc.h`, `cgx.h`.
- Detected declarations: `function is_npc_intf_tx`, `function is_npc_intf_rx`, `function is_npc_interface_valid`, `function rvu_npc_get_tx_nibble_cfg`, `function rvu_npc_set_pkind`, `function rvu_npc_get_pkind`, `function npc_config_ts_kpuaction`, `function npc_get_ucast_mcam_index`, `function npc_get_nixlf_mcam_index`, `function npc_get_bank`.
- Atlas domain: Driver Families / drivers/net.
- 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.