drivers/net/ethernet/micrel/ksz884x.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/micrel/ksz884x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/micrel/ksz884x.c- Extension
.c- Size
- 173933 bytes
- Lines
- 6878
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/hex.hlinux/ioport.hlinux/pci.hlinux/proc_fs.hlinux/mii.hlinux/platform_device.hlinux/ethtool.hlinux/etherdevice.hlinux/in.hlinux/ip.hlinux/if_vlan.hlinux/crc32.hlinux/sched.hlinux/slab.hlinux/micrel_phy.h
Detected Declarations
struct ksz_desc_rx_statstruct ksz_desc_tx_statstruct ksz_desc_rx_bufstruct ksz_desc_tx_bufstruct ksz_hw_descstruct ksz_sw_descstruct ksz_dma_bufstruct ksz_descstruct ksz_desc_infostruct ksz_mac_tablestruct ksz_vlan_tablestruct ksz_port_mibstruct ksz_port_cfgstruct ksz_switchstruct ksz_port_infostruct ksz_hwstruct ksz_portstruct ksz_timer_infostruct ksz_shared_memstruct ksz_counter_infostruct dev_infostruct dev_privstruct platform_infofunction hw_ack_intrfunction hw_dis_intrfunction hw_set_intrfunction hw_ena_intrfunction hw_dis_intr_bitfunction hw_turn_off_intrfunction hw_turn_on_intrfunction hw_read_intrfunction hw_restore_intrfunction hw_block_intrfunction reset_descfunction release_descfunction get_rx_pktfunction set_rx_buffunction set_rx_lenfunction get_tx_pktfunction set_tx_buffunction set_tx_lenfunction sw_r_tablefunction sw_w_table_64function sw_w_table_64function sw_r_vlan_tablefunction port_r_mib_cntfunction port_r_mib_pktfunction port_r_cnt
Annotated Snippet
static const struct net_device_ops netdev_ops = {
.ndo_init = netdev_init,
.ndo_open = netdev_open,
.ndo_stop = netdev_close,
.ndo_get_stats = netdev_query_statistics,
.ndo_start_xmit = netdev_tx,
.ndo_tx_timeout = netdev_tx_timeout,
.ndo_change_mtu = netdev_change_mtu,
.ndo_set_features = netdev_set_features,
.ndo_set_mac_address = netdev_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = netdev_ioctl,
.ndo_set_rx_mode = netdev_set_rx_mode,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = netdev_netpoll,
#endif
};
static void netdev_free(struct net_device *dev)
{
if (dev->watchdog_timeo)
unregister_netdev(dev);
free_netdev(dev);
}
struct platform_info {
struct dev_info dev_info;
struct net_device *netdev[SWITCH_PORT_NUM];
};
static int net_device_present;
static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port)
{
int i;
int j;
int got_num;
int num;
i = j = num = got_num = 0;
while (j < ETH_ALEN) {
if (macaddr[i]) {
int digit;
got_num = 1;
digit = hex_to_bin(macaddr[i]);
if (digit >= 0)
num = num * 16 + digit;
else if (':' == macaddr[i])
got_num = 2;
else
break;
} else if (got_num)
got_num = 2;
else
break;
if (2 == got_num) {
if (MAIN_PORT == port) {
hw_priv->hw.override_addr[j++] = (u8) num;
hw_priv->hw.override_addr[5] +=
hw_priv->hw.id;
} else {
hw_priv->hw.ksz_switch->other_addr[j++] =
(u8) num;
hw_priv->hw.ksz_switch->other_addr[5] +=
hw_priv->hw.id;
}
num = got_num = 0;
}
i++;
}
if (ETH_ALEN == j) {
if (MAIN_PORT == port)
hw_priv->hw.mac_override = 1;
}
}
#define KS884X_DMA_MASK (~0x0UL)
static void read_other_addr(struct ksz_hw *hw)
{
int i;
u16 data[3];
struct ksz_switch *sw = hw->ksz_switch;
for (i = 0; i < 3; i++)
data[i] = eeprom_read(hw, i + EEPROM_DATA_OTHER_MAC_ADDR);
if ((data[0] || data[1] || data[2]) && data[0] != 0xffff) {
sw->other_addr[5] = (u8) data[0];
Annotation
- Immediate include surface: `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/hex.h`, `linux/ioport.h`, `linux/pci.h`, `linux/proc_fs.h`.
- Detected declarations: `struct ksz_desc_rx_stat`, `struct ksz_desc_tx_stat`, `struct ksz_desc_rx_buf`, `struct ksz_desc_tx_buf`, `struct ksz_hw_desc`, `struct ksz_sw_desc`, `struct ksz_dma_buf`, `struct ksz_desc`, `struct ksz_desc_info`, `struct ksz_mac_table`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.