drivers/net/ethernet/microchip/lan966x/lan966x_vlan.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_vlan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_vlan.c- Extension
.c- Size
- 9998 bytes
- Lines
- 345
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
lan966x_main.h
Detected Declarations
function lan966x_vlan_get_statusfunction lan966x_vlan_wait_for_completionfunction lan966x_vlan_set_maskfunction lan966x_vlan_port_add_vlan_maskfunction lan966x_vlan_port_del_vlan_maskfunction lan966x_vlan_port_any_vlan_maskfunction lan966x_vlan_cpu_add_vlan_maskfunction lan966x_vlan_cpu_del_vlan_maskfunction lan966x_vlan_cpu_add_cpu_vlan_maskfunction lan966x_vlan_cpu_del_cpu_vlan_maskfunction lan966x_vlan_cpu_member_cpu_vlan_maskfunction lan966x_vlan_port_get_pvidfunction lan966x_vlan_port_set_vidfunction lan966x_vlan_port_remove_vidfunction lan966x_vlan_port_set_vlan_awarefunction lan966x_vlan_port_rew_hostfunction lan966x_vlan_port_applyfunction lan966x_vlan_port_add_vlanfunction CPUfunction lan966x_vlan_port_del_vlanfunction lan966x_vlan_cpu_add_vlanfunction lan966x_vlan_cpu_del_vlanfunction lan966x_vlan_init
Annotated Snippet
if (port->vid) {
dev_err(lan966x->dev,
"Port already has a native VLAN: %d\n",
port->vid);
return -EBUSY;
}
port->vid = vid;
}
/* Default ingress vlan classification */
if (pvid)
port->pvid = vid;
return 0;
}
static void lan966x_vlan_port_remove_vid(struct lan966x_port *port, u16 vid)
{
if (port->pvid == vid)
port->pvid = 0;
if (port->vid == vid)
port->vid = 0;
}
void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port,
bool vlan_aware)
{
port->vlan_aware = vlan_aware;
}
/* When the interface is in host mode, the interface should not be vlan aware
* but it should insert all the tags that it gets from the network stack.
* The tags are not in the data of the frame but actually in the skb and the ifh
* is configured already to get this tag. So what we need to do is to update the
* rewriter to insert the vlan tag for all frames which have a vlan tag
* different than 0.
*/
void lan966x_vlan_port_rew_host(struct lan966x_port *port)
{
struct lan966x *lan966x = port->lan966x;
u32 val;
/* Tag all frames except when VID=0*/
val = REW_TAG_CFG_TAG_CFG_SET(2);
/* Update only some bits in the register */
lan_rmw(val,
REW_TAG_CFG_TAG_CFG,
lan966x, REW_TAG_CFG(port->chip_port));
}
void lan966x_vlan_port_apply(struct lan966x_port *port)
{
struct lan966x *lan966x = port->lan966x;
u16 pvid;
u32 val;
pvid = lan966x_vlan_port_get_pvid(port);
/* Ingress classification (ANA_PORT_VLAN_CFG) */
/* Default vlan to classify for untagged frames (may be zero) */
val = ANA_VLAN_CFG_VLAN_VID_SET(pvid);
if (port->vlan_aware)
val |= ANA_VLAN_CFG_VLAN_AWARE_ENA_SET(1) |
ANA_VLAN_CFG_VLAN_POP_CNT_SET(1);
lan_rmw(val,
ANA_VLAN_CFG_VLAN_VID | ANA_VLAN_CFG_VLAN_AWARE_ENA |
ANA_VLAN_CFG_VLAN_POP_CNT,
lan966x, ANA_VLAN_CFG(port->chip_port));
lan_rmw(DEV_MAC_TAGS_CFG_VLAN_AWR_ENA_SET(port->vlan_aware) |
DEV_MAC_TAGS_CFG_VLAN_DBL_AWR_ENA_SET(port->vlan_aware),
DEV_MAC_TAGS_CFG_VLAN_AWR_ENA |
DEV_MAC_TAGS_CFG_VLAN_DBL_AWR_ENA,
lan966x, DEV_MAC_TAGS_CFG(port->chip_port));
/* Drop frames with multicast source address */
val = ANA_DROP_CFG_DROP_MC_SMAC_ENA_SET(1);
if (port->vlan_aware && !pvid)
/* If port is vlan-aware and tagged, drop untagged and priority
* tagged frames.
*/
val |= ANA_DROP_CFG_DROP_UNTAGGED_ENA_SET(1) |
ANA_DROP_CFG_DROP_PRIO_S_TAGGED_ENA_SET(1) |
ANA_DROP_CFG_DROP_PRIO_C_TAGGED_ENA_SET(1);
lan_wr(val, lan966x, ANA_DROP_CFG(port->chip_port));
Annotation
- Immediate include surface: `lan966x_main.h`.
- Detected declarations: `function lan966x_vlan_get_status`, `function lan966x_vlan_wait_for_completion`, `function lan966x_vlan_set_mask`, `function lan966x_vlan_port_add_vlan_mask`, `function lan966x_vlan_port_del_vlan_mask`, `function lan966x_vlan_port_any_vlan_mask`, `function lan966x_vlan_cpu_add_vlan_mask`, `function lan966x_vlan_cpu_del_vlan_mask`, `function lan966x_vlan_cpu_add_cpu_vlan_mask`, `function lan966x_vlan_cpu_del_cpu_vlan_mask`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.