drivers/net/ethernet/sun/sunhme.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sun/sunhme.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sun/sunhme.c- Extension
.c- Size
- 80878 bytes
- Lines
- 2902
- 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/bitops.hlinux/crc32.hlinux/delay.hlinux/dma-mapping.hlinux/errno.hlinux/etherdevice.hlinux/ethtool.hlinux/fcntl.hlinux/in.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/kernel.hlinux/mii.hlinux/mm.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/of_device.hlinux/pci.hlinux/platform_device.hlinux/random.hlinux/skbuff.hlinux/slab.hlinux/string.hlinux/types.hlinux/uaccess.hasm/byteorder.hasm/dma.hasm/irq.hasm/auxio.h
Detected Declarations
struct hme_tx_logentfunction tx_add_logfunction tx_dump_logfunction sbus_hme_write32function sbus_hme_read32function sbus_hme_write_rxdfunction sbus_hme_write_txdfunction sbus_hme_read_desc32function pci_hme_write32function pci_hme_read32function pci_hme_write_rxdfunction pci_hme_write_txdfunction pci_hme_read_desc32function hme_read_desc32function BB_PUT_BITfunction BB_GET_BITfunction BB_GET_BIT2function happy_meal_bb_readfunction happy_meal_bb_writefunction happy_meal_tcvr_readfunction happy_meal_tcvr_writefunction whatfunction display_link_modefunction display_forced_link_modefunction set_happy_link_modesfunction is_lucent_phyfunction happy_meal_begin_auto_negotiationfunction happy_meal_timerfunction happy_meal_tx_resetfunction happy_meal_rx_resetfunction happy_meal_stopfunction happy_meal_get_countersfunction happy_meal_tcvr_resetfunction happy_meal_transceiver_checkfunction happy_meal_clean_ringsfunction happy_meal_init_ringsfunction happy_meal_initfunction netdev_for_each_mc_addrfunction happy_meal_set_initial_advertisementfunction happy_meal_is_not_so_happyfunction happy_meal_txfunction happy_meal_rxfunction happy_meal_interruptfunction happy_meal_openfunction happy_meal_closefunction happy_meal_tx_timeoutfunction unmap_partial_tx_skbfunction happy_meal_start_xmit
Annotated Snippet
static const struct net_device_ops hme_netdev_ops = {
.ndo_open = happy_meal_open,
.ndo_stop = happy_meal_close,
.ndo_start_xmit = happy_meal_start_xmit,
.ndo_tx_timeout = happy_meal_tx_timeout,
.ndo_get_stats = happy_meal_get_stats,
.ndo_set_rx_mode = happy_meal_set_multicast,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
#ifdef CONFIG_PCI
static int is_quattro_p(struct pci_dev *pdev)
{
struct pci_dev *busdev = pdev->bus->self;
struct pci_dev *this_pdev;
int n_hmes;
if (!busdev || busdev->vendor != PCI_VENDOR_ID_DEC ||
busdev->device != PCI_DEVICE_ID_DEC_21153)
return 0;
n_hmes = 0;
list_for_each_entry(this_pdev, &pdev->bus->devices, bus_list) {
if (this_pdev->vendor == PCI_VENDOR_ID_SUN &&
this_pdev->device == PCI_DEVICE_ID_SUN_HAPPYMEAL)
n_hmes++;
}
if (n_hmes != 4)
return 0;
return 1;
}
/* Fetch MAC address from vital product data of PCI ROM. */
static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr)
{
int this_offset;
for (this_offset = 0x20; this_offset < len; this_offset++) {
void __iomem *p = rom_base + this_offset;
if (readb(p + 0) != 0x90 ||
readb(p + 1) != 0x00 ||
readb(p + 2) != 0x09 ||
readb(p + 3) != 0x4e ||
readb(p + 4) != 0x41 ||
readb(p + 5) != 0x06)
continue;
this_offset += 6;
p += 6;
if (index == 0) {
for (int i = 0; i < 6; i++)
dev_addr[i] = readb(p + i);
return 1;
}
index--;
}
return 0;
}
static void __maybe_unused get_hme_mac_nonsparc(struct pci_dev *pdev,
unsigned char *dev_addr)
{
void __iomem *p;
size_t size;
p = pci_map_rom(pdev, &size);
if (p) {
int index = 0;
int found;
if (is_quattro_p(pdev))
index = PCI_SLOT(pdev->devfn);
found = readb(p) == 0x55 &&
readb(p + 1) == 0xaa &&
find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr);
pci_unmap_rom(pdev, p);
if (found)
return;
}
/* Sun MAC prefix then 3 random bytes. */
dev_addr[0] = 0x08;
dev_addr[1] = 0x00;
dev_addr[2] = 0x20;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/crc32.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/errno.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/fcntl.h`.
- Detected declarations: `struct hme_tx_logent`, `function tx_add_log`, `function tx_dump_log`, `function sbus_hme_write32`, `function sbus_hme_read32`, `function sbus_hme_write_rxd`, `function sbus_hme_write_txd`, `function sbus_hme_read_desc32`, `function pci_hme_write32`, `function pci_hme_read32`.
- 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.