net/dsa/tag_brcm.c
Source file repositories/reference/linux-study-clean/net/dsa/tag_brcm.c
File Facts
- System
- Linux kernel
- Corpus path
net/dsa/tag_brcm.c- Extension
.c- Size
- 11906 bytes
- Lines
- 419
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dsa/brcm.hlinux/etherdevice.hlinux/if_vlan.hlinux/list.hlinux/slab.htag.h
Detected Declarations
function Copyright
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Broadcom tag support
*
* Copyright (C) 2014 Broadcom Corporation
*/
#include <linux/dsa/brcm.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/list.h>
#include <linux/slab.h>
#include "tag.h"
#define BRCM_NAME "brcm"
#define BRCM_LEGACY_NAME "brcm-legacy"
#define BRCM_LEGACY_FCS_NAME "brcm-legacy-fcs"
#define BRCM_PREPEND_NAME "brcm-prepend"
/* Legacy Broadcom tag (6 bytes) */
#define BRCM_LEG_TAG_LEN 6
/* Type fields */
/* 1st byte in the tag */
#define BRCM_LEG_TYPE_HI 0x88
/* 2nd byte in the tag */
#define BRCM_LEG_TYPE_LO 0x74
/* Tag fields */
/* 3rd byte in the tag */
#define BRCM_LEG_UNICAST (0 << 5)
#define BRCM_LEG_MULTICAST (1 << 5)
#define BRCM_LEG_EGRESS (2 << 5)
#define BRCM_LEG_INGRESS (3 << 5)
#define BRCM_LEG_LEN_HI(x) (((x) >> 8) & 0x7)
/* 4th byte in the tag */
#define BRCM_LEG_LEN_LO(x) ((x) & 0xff)
/* 6th byte in the tag */
#define BRCM_LEG_PORT_ID (0xf)
/* Newer Broadcom tag (4 bytes) */
#define BRCM_TAG_LEN 4
/* Tag is constructed and deconstructed using byte by byte access
* because the tag is placed after the MAC Source Address, which does
* not make it 4-bytes aligned, so this might cause unaligned accesses
* on most systems where this is used.
*/
/* Ingress and egress opcodes */
#define BRCM_OPCODE_SHIFT 5
#define BRCM_OPCODE_MASK 0x7
/* Ingress fields */
/* 1st byte in the tag */
#define BRCM_IG_TC_SHIFT 2
#define BRCM_IG_TC_MASK 0x7
/* 2nd byte in the tag */
#define BRCM_IG_TE_MASK 0x3
#define BRCM_IG_TS_SHIFT 7
/* 3rd byte in the tag */
#define BRCM_IG_DSTMAP2_MASK 1
#define BRCM_IG_DSTMAP1_MASK 0xff
/* Egress fields */
/* 2nd byte in the tag */
#define BRCM_EG_CID_MASK 0xff
/* 3rd byte in the tag */
#define BRCM_EG_RC_MASK 0xff
#define BRCM_EG_RC_RSVD (3 << 6)
#define BRCM_EG_RC_EXCEPTION (1 << 5)
#define BRCM_EG_RC_PROT_SNOOP (1 << 4)
#define BRCM_EG_RC_PROT_TERM (1 << 3)
#define BRCM_EG_RC_SWITCH (1 << 2)
#define BRCM_EG_RC_MAC_LEARN (1 << 1)
#define BRCM_EG_RC_MIRROR (1 << 0)
#define BRCM_EG_TC_SHIFT 5
#define BRCM_EG_TC_MASK 0x7
#define BRCM_EG_PID_MASK 0x1f
#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM) || \
IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_PREPEND)
static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
struct net_device *dev,
Annotation
- Immediate include surface: `linux/dsa/brcm.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/list.h`, `linux/slab.h`, `tag.h`.
- Detected declarations: `function Copyright`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.