drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c- Extension
.c- Size
- 74166 bytes
- Lines
- 2589
- 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/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/platform_device.huapi/linux/ppp_defs.hnet/ip.hnet/ipv6.hmvpp2.hmvpp2_prs.h
Detected Declarations
function Copyrightfunction __mvpp2_prs_init_from_hwfunction mvpp2_prs_init_from_hwfunction mvpp2_prs_hw_invfunction mvpp2_prs_shadow_setfunction mvpp2_prs_shadow_ri_setfunction mvpp2_prs_tcam_lu_setfunction mvpp2_prs_tcam_port_setfunction mvpp2_prs_tcam_port_map_setfunction mvpp2_prs_tcam_port_map_getfunction mvpp2_prs_tcam_data_byte_setfunction mvpp2_prs_tcam_data_byte_getfunction mvpp2_prs_tcam_data_cmpfunction mvpp2_prs_tcam_ai_updatefunction mvpp2_prs_tcam_ai_getfunction mvpp2_prs_match_etypefunction mvpp2_prs_match_vidfunction mvpp2_prs_sram_bits_setfunction mvpp2_prs_sram_bits_clearfunction mvpp2_prs_sram_ri_updatefunction mvpp2_prs_sram_ri_getfunction mvpp2_prs_sram_ai_updatefunction mvpp2_prs_sram_ai_getfunction mvpp2_prs_sram_next_lu_setfunction mvpp2_prs_sram_shift_setfunction mvpp2_prs_sram_offset_setfunction mvpp2_prs_flow_findfunction mvpp2_prs_tcam_first_freefunction mvpp2_prs_drop_fcfunction mvpp2_prs_mac_drop_all_setfunction __mvpp2_prs_mac_promisc_setfunction mvpp2_prs_mac_promisc_setfunction mvpp2_prs_dsa_tag_setfunction mvpp2_prs_dsa_tag_ethertype_setfunction mvpp2_prs_vlan_findfunction mvpp2_prs_vlan_addfunction mvpp2_prs_double_vlan_ai_free_getfunction mvpp2_prs_double_vlan_findfunction mvpp2_prs_double_vlan_addfunction mvpp2_prs_ip4_protofunction mvpp2_prs_ip4_castfunction mvpp2_prs_ip6_protofunction mvpp2_prs_ip6_castfunction mvpp2_prs_hw_port_initfunction mvpp2_prs_def_flow_initfunction mvpp2_prs_mh_initfunction mvpp2_prs_mac_initfunction mvpp2_prs_dsa_init
Annotated Snippet
if (tagged) {
/* Set tagged bit in DSA tag */
mvpp2_prs_tcam_data_byte_set(&pe, 0,
MVPP2_PRS_TCAM_DSA_TAGGED_BIT,
MVPP2_PRS_TCAM_DSA_TAGGED_BIT);
/* Set ai bits for next iteration */
if (extend)
mvpp2_prs_sram_ai_update(&pe, 1,
MVPP2_PRS_SRAM_AI_MASK);
else
mvpp2_prs_sram_ai_update(&pe, 0,
MVPP2_PRS_SRAM_AI_MASK);
/* Set result info bits to 'single vlan' */
mvpp2_prs_sram_ri_update(&pe, MVPP2_PRS_RI_VLAN_SINGLE,
MVPP2_PRS_RI_VLAN_MASK);
/* If packet is tagged continue check vid filtering */
mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_VID);
} else {
/* Shift 4 bytes for DSA tag or 8 bytes for EDSA tag*/
mvpp2_prs_sram_shift_set(&pe, shift,
MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD);
/* Set result info bits to 'no vlans' */
mvpp2_prs_sram_ri_update(&pe, MVPP2_PRS_RI_VLAN_NONE,
MVPP2_PRS_RI_VLAN_MASK);
mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_L2);
}
/* Mask all ports */
mvpp2_prs_tcam_port_map_set(&pe, 0);
}
/* Update port mask */
mvpp2_prs_tcam_port_set(&pe, port, add);
mvpp2_prs_hw_write(priv, &pe);
}
/* Set entry for dsa ethertype */
static void mvpp2_prs_dsa_tag_ethertype_set(struct mvpp2 *priv, int port,
bool add, bool tagged, bool extend)
{
struct mvpp2_prs_entry pe;
int tid, shift, port_mask;
if (extend) {
tid = tagged ? MVPP2_PE_ETYPE_EDSA_TAGGED :
MVPP2_PE_ETYPE_EDSA_UNTAGGED;
port_mask = 0;
shift = 8;
} else {
tid = tagged ? MVPP2_PE_ETYPE_DSA_TAGGED :
MVPP2_PE_ETYPE_DSA_UNTAGGED;
port_mask = MVPP2_PRS_PORT_MASK;
shift = 4;
}
if (priv->prs_shadow[tid].valid) {
/* Entry exist - update port only */
__mvpp2_prs_init_from_hw(priv, &pe, tid);
} else {
/* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
pe.index = tid;
/* Set ethertype */
mvpp2_prs_match_etype(&pe, 0, ETH_P_EDSA);
mvpp2_prs_match_etype(&pe, 2, 0);
mvpp2_prs_sram_ri_update(&pe, MVPP2_PRS_RI_DSA_MASK,
MVPP2_PRS_RI_DSA_MASK);
/* Shift ethertype + 2 byte reserved + tag*/
mvpp2_prs_sram_shift_set(&pe, 2 + MVPP2_ETH_TYPE_LEN + shift,
MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD);
/* Update shadow table */
mvpp2_prs_shadow_set(priv, pe.index, MVPP2_PRS_LU_DSA);
if (tagged) {
/* Set tagged bit in DSA tag */
mvpp2_prs_tcam_data_byte_set(&pe,
MVPP2_ETH_TYPE_LEN + 2 + 3,
MVPP2_PRS_TCAM_DSA_TAGGED_BIT,
MVPP2_PRS_TCAM_DSA_TAGGED_BIT);
/* Clear all ai bits for next iteration */
mvpp2_prs_sram_ai_update(&pe, 0,
MVPP2_PRS_SRAM_AI_MASK);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `uapi/linux/ppp_defs.h`, `net/ip.h`, `net/ipv6.h`, `mvpp2.h`.
- Detected declarations: `function Copyright`, `function __mvpp2_prs_init_from_hw`, `function mvpp2_prs_init_from_hw`, `function mvpp2_prs_hw_inv`, `function mvpp2_prs_shadow_set`, `function mvpp2_prs_shadow_ri_set`, `function mvpp2_prs_tcam_lu_set`, `function mvpp2_prs_tcam_port_set`, `function mvpp2_prs_tcam_port_map_set`, `function mvpp2_prs_tcam_port_map_get`.
- 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.