drivers/net/ethernet/microchip/lan743x_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan743x_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan743x_main.c- Extension
.c- Size
- 114664 bytes
- Lines
- 4037
- 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/module.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/crc32.hlinux/microchipphy.hlinux/net_tstamp.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/phy_fixed.hlinux/rtnetlink.hlinux/iopoll.hlinux/crc16.hlinux/phylink.hlan743x_main.hlan743x_ethtool.h
Detected Declarations
function pci11x1x_is_a0function pci11x1x_strap_get_statusfunction is_pci11x1x_chipfunction lan743x_pci_cleanupfunction lan743x_pci_initfunction lan743x_csr_readfunction lan743x_csr_writefunction lan743x_csr_light_resetfunction lan743x_csr_wait_for_bit_atomicfunction lan743x_csr_wait_for_bitfunction lan743x_csr_initfunction lan743x_intr_software_isrfunction lan743x_tx_isrfunction lan743x_rx_isrfunction lan743x_intr_shared_isrfunction lan743x_intr_entry_isrfunction lan743x_intr_test_isrfunction lan743x_intr_register_isrfunction lan743x_intr_unregister_isrfunction lan743x_intr_get_vector_flagsfunction lan743x_intr_closefunction lan743x_intr_openfunction lan743x_dp_writefunction lan743x_mac_mii_accessfunction lan743x_mac_mii_wait_till_not_busyfunction lan743x_mdiobus_read_c22function lan743x_mdiobus_write_c22function lan743x_mac_mmd_accessfunction lan743x_mdiobus_read_c45function lan743x_mdiobus_write_c45function lan743x_sgmii_wait_till_not_busyfunction lan743x_sgmii_readfunction lan743x_sgmii_writefunction lan743x_get_lsdfunction lan743x_sgmii_mpll_setfunction lan743x_sgmii_2_5G_mode_setfunction lan743x_serdes_clock_and_aneg_updatefunction lan743x_pcs_seq_statefunction lan743x_pcs_power_resetfunction lan743x_mac_set_addressfunction lan743x_mac_rx_enable_fsefunction lan743x_mac_initfunction lan743x_mac_openfunction lan743x_mac_closefunction lan743x_mac_flow_ctrl_set_enablesfunction lan743x_mac_set_mtufunction lan743x_hw_reset_phyfunction lan743x_phy_interface_select
Annotated Snippet
static const struct net_device_ops lan743x_netdev_ops = {
.ndo_open = lan743x_netdev_open,
.ndo_stop = lan743x_netdev_close,
.ndo_start_xmit = lan743x_netdev_xmit_frame,
.ndo_eth_ioctl = lan743x_netdev_ioctl,
.ndo_set_rx_mode = lan743x_netdev_set_multicast,
.ndo_change_mtu = lan743x_netdev_change_mtu,
.ndo_get_stats64 = lan743x_netdev_get_stats64,
.ndo_set_mac_address = lan743x_netdev_set_mac_address,
.ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get,
.ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
};
static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
{
lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF);
}
static void lan743x_mdiobus_cleanup(struct lan743x_adapter *adapter)
{
mdiobus_unregister(adapter->mdiobus);
}
static void lan743x_destroy_phylink(struct lan743x_adapter *adapter)
{
phylink_destroy(adapter->phylink);
adapter->phylink = NULL;
}
static void lan743x_full_cleanup(struct lan743x_adapter *adapter)
{
unregister_netdev(adapter->netdev);
lan743x_destroy_phylink(adapter);
lan743x_mdiobus_cleanup(adapter);
lan743x_hardware_cleanup(adapter);
lan743x_pci_cleanup(adapter);
}
static void pci11x1x_set_rfe_rd_fifo_threshold(struct lan743x_adapter *adapter)
{
u16 rev = adapter->csr.id_rev & ID_REV_CHIP_REV_MASK_;
if (rev == ID_REV_CHIP_REV_PCI11X1X_B0_) {
u32 misc_ctl;
misc_ctl = lan743x_csr_read(adapter, MISC_CTL_0);
misc_ctl &= ~MISC_CTL_0_RFE_READ_FIFO_MASK_;
misc_ctl |= FIELD_PREP(MISC_CTL_0_RFE_READ_FIFO_MASK_,
RFE_RD_FIFO_TH_3_DWORDS);
lan743x_csr_write(adapter, MISC_CTL_0, misc_ctl);
}
}
static int lan743x_hardware_init(struct lan743x_adapter *adapter,
struct pci_dev *pdev)
{
struct lan743x_tx *tx;
u32 sgmii_ctl;
int index;
int ret;
adapter->is_pci11x1x = is_pci11x1x_chip(adapter);
if (adapter->is_pci11x1x) {
adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT;
pci11x1x_strap_get_status(adapter);
spin_lock_init(&adapter->eth_syslock_spinlock);
mutex_init(&adapter->sgmii_rw_lock);
pci11x1x_set_rfe_rd_fifo_threshold(adapter);
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
if (adapter->is_sgmii_en) {
sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
} else {
sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
}
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
} else {
adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
adapter->max_vector_count = LAN743X_MAX_VECTOR_COUNT;
}
adapter->intr.irq = adapter->pdev->irq;
lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF);
ret = lan743x_gpio_init(adapter);
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/crc32.h`, `linux/microchipphy.h`, `linux/net_tstamp.h`, `linux/of_mdio.h`.
- Detected declarations: `function pci11x1x_is_a0`, `function pci11x1x_strap_get_status`, `function is_pci11x1x_chip`, `function lan743x_pci_cleanup`, `function lan743x_pci_init`, `function lan743x_csr_read`, `function lan743x_csr_write`, `function lan743x_csr_light_reset`, `function lan743x_csr_wait_for_bit_atomic`, `function lan743x_csr_wait_for_bit`.
- 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.