drivers/net/dsa/bcm_sf2.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/bcm_sf2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/bcm_sf2.c- Extension
.c- Size
- 42364 bytes
- Lines
- 1646
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/list.hlinux/module.hlinux/netdevice.hlinux/interrupt.hlinux/platform_device.hlinux/phy.hlinux/phy_fixed.hlinux/phylink.hlinux/mii.hlinux/clk.hlinux/of.hlinux/of_irq.hlinux/of_address.hlinux/of_net.hlinux/of_mdio.hnet/dsa.hlinux/ethtool.hlinux/if_bridge.hlinux/brcmphy.hlinux/etherdevice.hlinux/platform_data/b53.hbcm_sf2.hbcm_sf2_regs.hb53/b53_priv.hb53/b53_regs.h
Detected Declarations
struct bcm_sf2_of_datafunction Copyrightfunction bcm_sf2_reg_led_basefunction bcm_sf2_port_override_offsetfunction bcm_sf2_num_active_portsfunction bcm_sf2_recalc_clockfunction bcm_sf2_imp_setupfunction bcm_sf2_gphy_enable_setfunction bcm_sf2_port_intr_enablefunction bcm_sf2_port_intr_disablefunction bcm_sf2_port_setupfunction bcm_sf2_port_disablefunction bcm_sf2_sw_indir_rwfunction bcm_sf2_sw_mdio_readfunction bcm_sf2_sw_mdio_writefunction bcm_sf2_switch_0_isrfunction bcm_sf2_switch_1_isrfunction bcm_sf2_sw_rstfunction bcm_sf2_crossbar_setupfunction bcm_sf2_intr_disablefunction bcm_sf2_identify_portsfunction for_each_available_child_of_nodefunction bcm_sf2_mdio_registerfunction bcm_sf2_mdio_unregisterfunction bcm_sf2_sw_get_phy_flagsfunction bcm_sf2_sw_get_capsfunction bcm_sf2_sw_mac_configfunction bcm_sf2_sw_mac_link_setfunction bcm_sf2_sw_mac_link_downfunction bcm_sf2_sw_mac_link_upfunction bcm_sf2_sw_fixed_statefunction bcm_sf2_enable_acbfunction bcm_sf2_sw_suspendfunction bcm_sf2_sw_resumefunction bcm_sf2_sw_get_wolfunction bcm_sf2_sw_set_wolfunction bcm_sf2_sw_setupfunction bcm_sf2_sw_teardownfunction bcm_sf2_core_read8function bcm_sf2_core_read16function bcm_sf2_core_read32function bcm_sf2_core_read64function bcm_sf2_core_write8function bcm_sf2_core_write16function bcm_sf2_core_write32function bcm_sf2_core_write64function bcm_sf2_sw_get_stringsfunction bcm_sf2_sw_get_ethtool_stats
Annotated Snippet
struct bcm_sf2_of_data {
u32 type;
const u16 *reg_offsets;
unsigned int core_reg_align;
unsigned int num_cfp_rules;
unsigned int num_crossbar_int_ports;
unsigned int num_crossbar_ext_bits;
};
static const u16 bcm_sf2_4908_reg_offsets[] = {
[REG_SWITCH_CNTRL] = 0x00,
[REG_SWITCH_STATUS] = 0x04,
[REG_DIR_DATA_WRITE] = 0x08,
[REG_DIR_DATA_READ] = 0x0c,
[REG_SWITCH_REVISION] = 0x10,
[REG_PHY_REVISION] = 0x14,
[REG_SPHY_CNTRL] = 0x24,
[REG_CROSSBAR] = 0xc8,
[REG_RGMII_11_CNTRL] = 0x014c,
[REG_LED_0_CNTRL] = 0x40,
[REG_LED_1_CNTRL] = 0x4c,
[REG_LED_2_CNTRL] = 0x58,
[REG_LED_3_CNTRL] = 0x64,
[REG_LED_4_CNTRL] = 0x88,
[REG_LED_5_CNTRL] = 0xa0,
[REG_LED_AGGREGATE_CTRL] = 0xb8,
};
static const struct bcm_sf2_of_data bcm_sf2_4908_data = {
.type = BCM4908_DEVICE_ID,
.core_reg_align = 0,
.reg_offsets = bcm_sf2_4908_reg_offsets,
.num_cfp_rules = 256,
.num_crossbar_int_ports = 2,
.num_crossbar_ext_bits = 2,
};
/* Register offsets for the SWITCH_REG_* block */
static const u16 bcm_sf2_7445_reg_offsets[] = {
[REG_SWITCH_CNTRL] = 0x00,
[REG_SWITCH_STATUS] = 0x04,
[REG_DIR_DATA_WRITE] = 0x08,
[REG_DIR_DATA_READ] = 0x0C,
[REG_SWITCH_REVISION] = 0x18,
[REG_PHY_REVISION] = 0x1C,
[REG_SPHY_CNTRL] = 0x2C,
[REG_RGMII_0_CNTRL] = 0x34,
[REG_RGMII_1_CNTRL] = 0x40,
[REG_RGMII_2_CNTRL] = 0x4c,
[REG_LED_0_CNTRL] = 0x90,
[REG_LED_1_CNTRL] = 0x94,
[REG_LED_2_CNTRL] = 0x98,
};
static const struct bcm_sf2_of_data bcm_sf2_7445_data = {
.type = BCM7445_DEVICE_ID,
.core_reg_align = 0,
.reg_offsets = bcm_sf2_7445_reg_offsets,
.num_cfp_rules = 256,
};
static const u16 bcm_sf2_7278_reg_offsets[] = {
[REG_SWITCH_CNTRL] = 0x00,
[REG_SWITCH_STATUS] = 0x04,
[REG_DIR_DATA_WRITE] = 0x08,
[REG_DIR_DATA_READ] = 0x0c,
[REG_SWITCH_REVISION] = 0x10,
[REG_PHY_REVISION] = 0x14,
[REG_SPHY_CNTRL] = 0x24,
[REG_RGMII_0_CNTRL] = 0xe0,
[REG_RGMII_1_CNTRL] = 0xec,
[REG_RGMII_2_CNTRL] = 0xf8,
[REG_LED_0_CNTRL] = 0x40,
[REG_LED_1_CNTRL] = 0x4c,
[REG_LED_2_CNTRL] = 0x58,
};
static const struct bcm_sf2_of_data bcm_sf2_7278_data = {
.type = BCM7278_DEVICE_ID,
.core_reg_align = 1,
.reg_offsets = bcm_sf2_7278_reg_offsets,
.num_cfp_rules = 128,
};
static const struct of_device_id bcm_sf2_of_match[] = {
{ .compatible = "brcm,bcm4908-switch",
.data = &bcm_sf2_4908_data
},
{ .compatible = "brcm,bcm7445-switch-v4.0",
Annotation
- Immediate include surface: `linux/list.h`, `linux/module.h`, `linux/netdevice.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/phy.h`, `linux/phy_fixed.h`, `linux/phylink.h`.
- Detected declarations: `struct bcm_sf2_of_data`, `function Copyright`, `function bcm_sf2_reg_led_base`, `function bcm_sf2_port_override_offset`, `function bcm_sf2_num_active_ports`, `function bcm_sf2_recalc_clock`, `function bcm_sf2_imp_setup`, `function bcm_sf2_gphy_enable_set`, `function bcm_sf2_port_intr_enable`, `function bcm_sf2_port_intr_disable`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.