drivers/net/dsa/microchip/ksz9477.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/microchip/ksz9477.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/microchip/ksz9477.c- Extension
.c- Size
- 55682 bytes
- Lines
- 2128
- 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/dsa/ksz_common.hlinux/kernel.hlinux/module.hlinux/iopoll.hlinux/platform_data/microchip-ksz.hlinux/phy.hlinux/if_bridge.hlinux/if_hsr.hlinux/if_vlan.hnet/dsa.hnet/switchdev.hksz9477_reg.hksz_common.hksz_dcb.hksz9477.h
Detected Declarations
function Copyrightfunction ksz_port_cfgfunction ksz9477_cfg32function ksz9477_port_cfg32function ksz9477_change_mtufunction ksz9477_wait_vlan_ctrl_readyfunction ksz9477_get_vlan_tablefunction ksz9477_set_vlan_tablefunction ksz9477_read_tablefunction ksz9477_write_tablefunction ksz9477_wait_alu_readyfunction ksz9477_wait_alu_sta_readyfunction port_sgmii_sfunction port_sgmii_rfunction port_sgmii_wfunction ksz9477_pcs_readfunction ksz9477_pcs_writefunction ksz9477_pcs_createfunction ksz9477_reset_switchfunction ksz9477_r_mib_cntfunction ksz9477_r_mib_pktfunction ksz9477_freeze_mibfunction ksz9477_half_duplex_monitorfunction ksz9477_errata_monitorfunction ksz9477_port_init_cntfunction ksz9477_r_phy_quirksfunction ksz9477_r_phyfunction ksz9477_phy_read16function ksz9477_w_phyfunction ksz9477_phy_write16function ksz9477_cfg_port_memberfunction ksz9477_flush_dyn_mac_tablefunction ksz9477_port_vlan_filteringfunction ksz9477_port_vlan_addfunction ksz9477_port_vlan_delfunction ksz9477_fdb_addfunction ksz9477_fdb_delfunction ksz9477_convert_alufunction ksz9477_fdb_dumpfunction ksz9477_mdb_addfunction ksz9477_mdb_delfunction ksz9477_port_mirror_addfunction ksz9477_port_mirror_delfunction ksz9477_get_interfacefunction ksz9477_phylink_get_capsfunction ksz9477_set_ageing_timefunction ksz9477_port_queue_splitfunction ksz9477_port_setup
Annotated Snippet
if (reg == MMD_SR_MII_AUTO_NEG_STATUS) {
int duplex, speed;
if (val & SR_MII_STAT_LINK_UP) {
speed = (val >> SR_MII_STAT_S) & SR_MII_STAT_M;
if (speed == SR_MII_STAT_1000_MBPS)
speed = SPEED_1000;
else if (speed == SR_MII_STAT_100_MBPS)
speed = SPEED_100;
else
speed = SPEED_10;
if (val & SR_MII_STAT_FULL_DUPLEX)
duplex = DUPLEX_FULL;
else
duplex = DUPLEX_HALF;
if (!p->link || p->speed != speed ||
p->duplex != duplex) {
u16 ctrl;
p->link = true;
p->speed = speed;
p->duplex = duplex;
port_sgmii_r(dev, port, mmd, MII_BMCR,
&ctrl);
ctrl &= BMCR_ANENABLE;
ctrl |= mii_bmcr_encode_fixed(speed,
duplex);
port_sgmii_w(dev, port, mmd, MII_BMCR,
ctrl);
}
} else {
p->link = false;
}
} else if (reg == MII_BMSR) {
p->link = !!(val & BMSR_LSTATUS);
}
}
return val;
}
static int ksz9477_pcs_write(struct mii_bus *bus, int phy, int mmd, int reg,
u16 val)
{
struct ksz_device *dev = bus->priv;
int port = ksz_get_sgmii_port(dev);
if (mmd == MDIO_MMD_VEND2) {
struct ksz_port *p = &dev->ports[port];
if (reg == MMD_SR_MII_AUTO_NEG_CTRL) {
u16 sgmii_mode = SR_MII_PCS_SGMII << SR_MII_PCS_MODE_S;
/* Need these bits for 1000BASE-X mode to work with
* AN on.
*/
if (!(val & sgmii_mode))
val |= SR_MII_SGMII_LINK_UP |
SR_MII_TX_CFG_PHY_MASTER;
/* SGMII interrupt in the port cannot be masked, so
* make sure interrupt is not enabled as it is not
* handled.
*/
val &= ~SR_MII_AUTO_NEG_COMPLETE_INTR;
} else if (reg == MII_BMCR) {
/* The MII_ADVERTISE register needs to write once
* before doing auto-negotiation for the correct
* config_word to be sent out after reset.
*/
if ((val & BMCR_ANENABLE) && !p->sgmii_adv_write) {
u16 adv;
/* The SGMII port cannot disable flow control
* so it is better to just advertise symmetric
* pause.
*/
port_sgmii_r(dev, port, mmd, MII_ADVERTISE,
&adv);
adv |= ADVERTISE_1000XPAUSE;
adv &= ~ADVERTISE_1000XPSE_ASYM;
port_sgmii_w(dev, port, mmd, MII_ADVERTISE,
adv);
p->sgmii_adv_write = 1;
} else if (val & BMCR_RESET) {
p->sgmii_adv_write = 0;
}
} else if (reg == MII_ADVERTISE) {
Annotation
- Immediate include surface: `linux/dsa/ksz_common.h`, `linux/kernel.h`, `linux/module.h`, `linux/iopoll.h`, `linux/platform_data/microchip-ksz.h`, `linux/phy.h`, `linux/if_bridge.h`, `linux/if_hsr.h`.
- Detected declarations: `function Copyright`, `function ksz_port_cfg`, `function ksz9477_cfg32`, `function ksz9477_port_cfg32`, `function ksz9477_change_mtu`, `function ksz9477_wait_vlan_ctrl_ready`, `function ksz9477_get_vlan_table`, `function ksz9477_set_vlan_table`, `function ksz9477_read_table`, `function ksz9477_write_table`.
- 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.