drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c- Extension
.c- Size
- 66742 bytes
- Lines
- 2257
- 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.
- 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/bitfield.hrvu_struct.hrvu_reg.hrvu.hnpc.hrvu_npc_fs.hrvu_npc_hash.hcn20k/reg.hcn20k/npc.h
Detected Declarations
function npc_is_feature_supportedfunction npc_set_kw_masksfunction npc_is_field_presentfunction npc_is_samefunction npc_set_layer_mdatafunction npc_check_overlap_fieldsfunction npc_check_overlapfunction npc_check_fieldfunction npc_scan_exact_resultfunction npc_cn20k_scan_parse_resultfunction npc_scan_parse_resultfunction npc_handle_multi_layer_fieldsfunction npc_scan_ldatafunction npc_set_featuresfunction npc_scan_kexfunction for_each_set_bitfunction for_each_set_bitfunction npc_scan_verify_kexfunction npc_flow_steering_initfunction npc_check_unsupported_flowsfunction npc_update_entryfunction npc_update_ipv6_flowfunction npc_update_vlan_featuresfunction npc_update_flowfunction rvu_mcam_add_rulefunction rvu_mcam_remove_counter_from_rulefunction rvu_mcam_add_counter_to_rulefunction npc_mcast_update_action_indexfunction npc_populate_mcam_mdatafunction npc_update_rx_entryfunction npc_update_tx_entryfunction npc_install_flowfunction rvu_npc_free_entry_for_flow_installfunction rvu_npc_alloc_entry_for_flow_installfunction rvu_mbox_handler_npc_install_flowfunction is_zero_ether_addrfunction npc_delete_flowfunction rvu_mbox_handler_npc_delete_flowfunction list_for_each_entry_safefunction npc_update_dmac_valuefunction npc_mcam_enable_flowsfunction npc_mcam_disable_flowsfunction npc_install_mcam_drop_rulefunction rvu_mbox_handler_npc_get_field_status
Annotated Snippet
if (etype_ether->kw_mask[i] != etype_tag1->kw_mask[i]) {
dev_err(rvu->dev, "mkex: Etype pos is different for untagged and tagged pkts.\n");
goto vlan_tci;
}
}
key_fields[NPC_ETYPE] = *etype_tag1;
}
if (etype_ether->nr_kws && etype_tag2->nr_kws) {
for (i = 0; i < max_kw; i++) {
if (etype_ether->kw_mask[i] != etype_tag2->kw_mask[i]) {
dev_err(rvu->dev, "mkex: Etype pos is different for untagged and double tagged pkts.\n");
goto vlan_tci;
}
}
key_fields[NPC_ETYPE] = *etype_tag2;
}
if (etype_tag1->nr_kws && etype_tag2->nr_kws) {
for (i = 0; i < max_kw; i++) {
if (etype_tag1->kw_mask[i] != etype_tag2->kw_mask[i]) {
dev_err(rvu->dev, "mkex: Etype pos is different for tagged and double tagged pkts.\n");
goto vlan_tci;
}
}
key_fields[NPC_ETYPE] = *etype_tag2;
}
/* check none of higher layers overwrite Ethertype */
start_lid = key_fields[NPC_ETYPE].layer_mdata.lid + 1;
if (npc_check_overlap(rvu, blkaddr, NPC_ETYPE, start_lid, intf)) {
dev_err(rvu->dev, "mkex: Ethertype is overwritten by higher layers.\n");
goto vlan_tci;
}
*features |= BIT_ULL(NPC_ETYPE);
vlan_tci:
/* if key profile does not extract outer vlan tci at all */
if (!vlan_tag1->nr_kws && !vlan_tag2->nr_kws) {
dev_err(rvu->dev, "mkex: Outer vlan tci is not extracted.\n");
goto done;
}
/* if key profile extracts outer vlan tci from one layer */
if (vlan_tag1->nr_kws && !vlan_tag2->nr_kws)
key_fields[NPC_OUTER_VID] = *vlan_tag1;
if (!vlan_tag1->nr_kws && vlan_tag2->nr_kws)
key_fields[NPC_OUTER_VID] = *vlan_tag2;
/* if key profile extracts outer vlan tci from multiple layers */
if (vlan_tag1->nr_kws && vlan_tag2->nr_kws) {
for (i = 0; i < max_kw; i++) {
if (vlan_tag1->kw_mask[i] != vlan_tag2->kw_mask[i]) {
dev_err(rvu->dev, "mkex: Out vlan tci pos is different for tagged and double tagged pkts.\n");
goto done;
}
}
key_fields[NPC_OUTER_VID] = *vlan_tag2;
}
/* check none of higher layers overwrite outer vlan tci */
start_lid = key_fields[NPC_OUTER_VID].layer_mdata.lid + 1;
if (npc_check_overlap(rvu, blkaddr, NPC_OUTER_VID, start_lid, intf)) {
dev_err(rvu->dev, "mkex: Outer vlan tci is overwritten by higher layers.\n");
goto done;
}
*features |= BIT_ULL(NPC_OUTER_VID);
/* If key profile extracts inner vlan tci */
if (vlan_tag3->nr_kws) {
key_fields[NPC_INNER_VID] = *vlan_tag3;
*features |= BIT_ULL(NPC_INNER_VID);
}
done:
return;
}
static void npc_scan_ldata(struct rvu *rvu, int blkaddr, u8 lid,
u8 lt, u64 cfg, u8 intf)
{
struct npc_mcam_kex_hash *mkex_hash = rvu->kpu.mkex_hash;
struct npc_mcam *mcam = &rvu->hw->mcam;
u8 hdr, key, nr_bytes, bit_offset;
u8 la_ltype, la_start;
/* starting KW index and starting bit position */
int start_kwi, offset;
if (is_cn20k(rvu->pdev))
nr_bytes = FIELD_GET(NPC_CN20K_BYTESM, cfg) + 1;
else
nr_bytes = FIELD_GET(NPC_BYTESM, cfg) + 1;
hdr = FIELD_GET(NPC_HDR_OFFSET, cfg);
key = FIELD_GET(NPC_KEY_OFFSET, cfg);
Annotation
- Immediate include surface: `linux/bitfield.h`, `rvu_struct.h`, `rvu_reg.h`, `rvu.h`, `npc.h`, `rvu_npc_fs.h`, `rvu_npc_hash.h`, `cn20k/reg.h`.
- Detected declarations: `function npc_is_feature_supported`, `function npc_set_kw_masks`, `function npc_is_field_present`, `function npc_is_same`, `function npc_set_layer_mdata`, `function npc_check_overlap_fields`, `function npc_check_overlap`, `function npc_check_field`, `function npc_scan_exact_result`, `function npc_cn20k_scan_parse_result`.
- 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.