drivers/net/dsa/lantiq/lantiq_gswip_common.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/lantiq/lantiq_gswip_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/lantiq/lantiq_gswip_common.c- Extension
.c- Size
- 47882 bytes
- Lines
- 1728
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
lantiq_gswip.hlinux/delay.hlinux/etherdevice.hlinux/if_bridge.hlinux/if_vlan.hlinux/iopoll.hlinux/module.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/phylink.hlinux/regmap.hnet/dsa.h
Detected Declarations
struct gswip_pce_table_entrystruct gswip_rmon_cnt_descfunction gswip_switch_r_timeoutfunction gswip_mii_mask_cfgfunction gswip_mdio_pollfunction gswip_mdio_wrfunction gswip_mdio_rdfunction gswip_mdiofunction gswip_pce_table_entry_readfunction gswip_pce_table_entry_writefunction gswip_add_single_port_brfunction gswip_port_set_learningfunction gswip_port_pre_bridge_flagsfunction gswip_port_bridge_flagsfunction gswip_port_setupfunction gswip_port_enablefunction gswip_port_disablefunction gswip_pce_load_microcodefunction gswip_port_commit_pvidfunction gswip_port_vlan_filteringfunction gswip_mii_delay_setupfunction gswip_setupfunction dsa_switch_for_each_cpu_portfunction gswip_teardownfunction gswip_get_tag_protocolfunction gswip_vlan_active_createfunction gswip_vlan_active_removefunction gswip_vlan_addfunction gswip_vlan_removefunction gswip_port_bridge_joinfunction gswip_port_bridge_leavefunction gswip_port_vlan_preparefunction gswip_port_vlan_addfunction gswip_port_vlan_delfunction gswip_port_fast_agefunction gswip_port_stp_state_setfunction gswip_port_fdbfunction gswip_port_fdb_addfunction gswip_port_fdb_delfunction gswip_port_fdb_dumpfunction gswip_port_max_mtufunction gswip_port_change_mtufunction gswip_phylink_get_capsfunction gswip_port_set_linkfunction gswip_port_set_speedfunction gswip_port_set_duplexfunction gswip_port_set_pausefunction gswip_phylink_mac_config
Annotated Snippet
struct gswip_pce_table_entry {
u16 index; // PCE_TBL_ADDR.ADDR = pData->table_index
u16 table; // PCE_TBL_CTRL.ADDR = pData->table
u16 key[8];
u16 val[5];
u16 mask;
u8 gmap;
bool type;
bool valid;
bool key_mode;
};
struct gswip_rmon_cnt_desc {
unsigned int size;
unsigned int offset;
const char *name;
};
#define MIB_DESC(_size, _offset, _name) {.size = _size, .offset = _offset, .name = _name}
static const struct gswip_rmon_cnt_desc gswip_rmon_cnt[] = {
/** Receive Packet Count (only packets that are accepted and not discarded). */
MIB_DESC(1, 0x1F, "RxGoodPkts"),
MIB_DESC(1, 0x23, "RxUnicastPkts"),
MIB_DESC(1, 0x22, "RxMulticastPkts"),
MIB_DESC(1, 0x21, "RxFCSErrorPkts"),
MIB_DESC(1, 0x1D, "RxUnderSizeGoodPkts"),
MIB_DESC(1, 0x1E, "RxUnderSizeErrorPkts"),
MIB_DESC(1, 0x1B, "RxOversizeGoodPkts"),
MIB_DESC(1, 0x1C, "RxOversizeErrorPkts"),
MIB_DESC(1, 0x20, "RxGoodPausePkts"),
MIB_DESC(1, 0x1A, "RxAlignErrorPkts"),
MIB_DESC(1, 0x12, "Rx64BytePkts"),
MIB_DESC(1, 0x13, "Rx127BytePkts"),
MIB_DESC(1, 0x14, "Rx255BytePkts"),
MIB_DESC(1, 0x15, "Rx511BytePkts"),
MIB_DESC(1, 0x16, "Rx1023BytePkts"),
/** Receive Size 1024-1522 (or more, if configured) Packet Count. */
MIB_DESC(1, 0x17, "RxMaxBytePkts"),
MIB_DESC(1, 0x18, "RxDroppedPkts"),
MIB_DESC(1, 0x19, "RxFilteredPkts"),
MIB_DESC(2, 0x24, "RxGoodBytes"),
MIB_DESC(2, 0x26, "RxBadBytes"),
MIB_DESC(1, 0x11, "TxAcmDroppedPkts"),
MIB_DESC(1, 0x0C, "TxGoodPkts"),
MIB_DESC(1, 0x06, "TxUnicastPkts"),
MIB_DESC(1, 0x07, "TxMulticastPkts"),
MIB_DESC(1, 0x00, "Tx64BytePkts"),
MIB_DESC(1, 0x01, "Tx127BytePkts"),
MIB_DESC(1, 0x02, "Tx255BytePkts"),
MIB_DESC(1, 0x03, "Tx511BytePkts"),
MIB_DESC(1, 0x04, "Tx1023BytePkts"),
/** Transmit Size 1024-1522 (or more, if configured) Packet Count. */
MIB_DESC(1, 0x05, "TxMaxBytePkts"),
MIB_DESC(1, 0x08, "TxSingleCollCount"),
MIB_DESC(1, 0x09, "TxMultCollCount"),
MIB_DESC(1, 0x0A, "TxLateCollCount"),
MIB_DESC(1, 0x0B, "TxExcessCollCount"),
MIB_DESC(1, 0x0D, "TxPauseCount"),
MIB_DESC(1, 0x10, "TxDroppedPkts"),
MIB_DESC(2, 0x0E, "TxGoodBytes"),
};
static u32 gswip_switch_r_timeout(struct gswip_priv *priv, u32 offset,
u32 cleared)
{
u32 val;
return regmap_read_poll_timeout(priv->gswip, offset, val,
!(val & cleared), 20, 50000);
}
static void gswip_mii_mask_cfg(struct gswip_priv *priv, u32 mask, u32 set,
int port)
{
/* MII_CFG register only exists for MII ports */
if (priv->hw_info->mii_cfg[port] == -1)
return;
regmap_write_bits(priv->mii, priv->hw_info->mii_cfg[port], mask,
set);
}
static int gswip_mdio_poll(struct gswip_priv *priv)
{
u32 ctrl;
return regmap_read_poll_timeout(priv->mdio, GSWIP_MDIO_CTRL, ctrl,
!(ctrl & GSWIP_MDIO_CTRL_BUSY), 40, 4000);
}
Annotation
- Immediate include surface: `lantiq_gswip.h`, `linux/delay.h`, `linux/etherdevice.h`, `linux/if_bridge.h`, `linux/if_vlan.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of_mdio.h`.
- Detected declarations: `struct gswip_pce_table_entry`, `struct gswip_rmon_cnt_desc`, `function gswip_switch_r_timeout`, `function gswip_mii_mask_cfg`, `function gswip_mdio_poll`, `function gswip_mdio_wr`, `function gswip_mdio_rd`, `function gswip_mdio`, `function gswip_pce_table_entry_read`, `function gswip_pce_table_entry_write`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.