drivers/net/ethernet/broadcom/tg3.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/tg3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/tg3.c- Extension
.c- Size
- 483310 bytes
- Lines
- 18437
- 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/moduleparam.hlinux/stringify.hlinux/kernel.hlinux/sched/signal.hlinux/types.hlinux/compiler.hlinux/slab.hlinux/delay.hlinux/in.hlinux/interrupt.hlinux/ioport.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/ethtool.hlinux/mdio.hlinux/mii.hlinux/phy.hlinux/brcmphy.hlinux/if.hlinux/if_vlan.hlinux/ip.hlinux/tcp.hlinux/workqueue.hlinux/prefetch.hlinux/dma-mapping.hlinux/firmware.hlinux/ssb/ssb_driver_gige.hlinux/hwmon.hlinux/hwmon-sysfs.h
Detected Declarations
struct tg3_fiber_aneginfostruct subsys_tbl_entfunction Copyrightfunction _tg3_flag_setfunction _tg3_flag_clearfunction tg3_write32function tg3_read32function tg3_ape_write32function tg3_ape_read32function tg3_write_indirect_reg32function tg3_write_flush_reg32function tg3_read_indirect_reg32function tg3_write_indirect_mboxfunction tg3_read_indirect_mboxfunction _tw32_flushfunction tw32_mailbox_flushfunction tg3_write32_tx_mboxfunction tg3_read32_mbox_5906function tg3_write32_mbox_5906function tg3_write_memfunction tg3_read_memfunction tg3_ape_lock_initfunction tg3_ape_lockfunction tg3_ape_unlockfunction tg3_ape_event_lockfunction tg3_ape_wait_for_eventfunction tg3_ape_scratchpad_readfunction tg3_ape_send_eventfunction tg3_ape_driver_state_changefunction tg3_send_ape_heartbeatfunction tg3_disable_intsfunction tg3_enable_intsfunction tg3_has_workfunction tg3_int_reenablefunction tg3_switch_clocksfunction __tg3_readphyfunction tg3_readphyfunction __tg3_writephyfunction tg3_writephyfunction tg3_phy_cl45_writefunction tg3_phy_cl45_readfunction tg3_phydsp_readfunction tg3_phydsp_writefunction tg3_phy_auxctl_readfunction tg3_phy_auxctl_writefunction tg3_phy_toggle_auxctl_smdspfunction tg3_phy_shdw_writefunction tg3_bmcr_reset
Annotated Snippet
static const struct net_device_ops tg3_netdev_ops = {
.ndo_open = tg3_open,
.ndo_stop = tg3_close,
.ndo_start_xmit = tg3_start_xmit,
.ndo_get_stats64 = tg3_get_stats64,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = tg3_set_rx_mode,
.ndo_set_mac_address = tg3_set_mac_addr,
.ndo_eth_ioctl = tg3_ioctl,
.ndo_tx_timeout = tg3_tx_timeout,
.ndo_change_mtu = tg3_change_mtu,
.ndo_fix_features = tg3_fix_features,
.ndo_set_features = tg3_set_features,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = tg3_poll_controller,
#endif
.ndo_hwtstamp_get = tg3_hwtstamp_get,
.ndo_hwtstamp_set = tg3_hwtstamp_set,
};
static void tg3_get_eeprom_size(struct tg3 *tp)
{
u32 cursize, val, magic;
tp->nvram_size = EEPROM_CHIP_SIZE;
if (tg3_nvram_read(tp, 0, &magic) != 0)
return;
if ((magic != TG3_EEPROM_MAGIC) &&
((magic & TG3_EEPROM_MAGIC_FW_MSK) != TG3_EEPROM_MAGIC_FW) &&
((magic & TG3_EEPROM_MAGIC_HW_MSK) != TG3_EEPROM_MAGIC_HW))
return;
/*
* Size the chip by reading offsets at increasing powers of two.
* When we encounter our validation signature, we know the addressing
* has wrapped around, and thus have our chip size.
*/
cursize = 0x10;
while (cursize < tp->nvram_size) {
if (tg3_nvram_read(tp, cursize, &val) != 0)
return;
if (val == magic)
break;
cursize <<= 1;
}
tp->nvram_size = cursize;
}
static void tg3_get_nvram_size(struct tg3 *tp)
{
u32 val;
if (tg3_flag(tp, NO_NVRAM) || tg3_nvram_read(tp, 0, &val) != 0)
return;
/* Selfboot format */
if (val != TG3_EEPROM_MAGIC) {
tg3_get_eeprom_size(tp);
return;
}
if (tg3_nvram_read(tp, 0xf0, &val) == 0) {
if (val != 0) {
/* This is confusing. We want to operate on the
* 16-bit value at offset 0xf2. The tg3_nvram_read()
* call will read from NVRAM and byteswap the data
* according to the byteswapping settings for all
* other register accesses. This ensures the data we
* want will always reside in the lower 16-bits.
* However, the data in NVRAM is in LE format, which
* means the data from the NVRAM read will always be
* opposite the endianness of the CPU. The 16-bit
* byteswap then brings the data to CPU endianness.
*/
tp->nvram_size = swab16((u16)(val & 0x0000ffff)) * 1024;
return;
}
}
tp->nvram_size = TG3_NVRAM_SIZE_512KB;
}
static void tg3_get_nvram_info(struct tg3 *tp)
{
u32 nvcfg1;
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/stringify.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/types.h`, `linux/compiler.h`, `linux/slab.h`.
- Detected declarations: `struct tg3_fiber_aneginfo`, `struct subsys_tbl_ent`, `function Copyright`, `function _tg3_flag_set`, `function _tg3_flag_clear`, `function tg3_write32`, `function tg3_read32`, `function tg3_ape_write32`, `function tg3_ape_read32`, `function tg3_write_indirect_reg32`.
- 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.