drivers/net/ethernet/sun/sungem.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sun/sungem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sun/sungem.c- Extension
.c- Size
- 77416 bytes
- Lines
- 3026
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/types.hlinux/fcntl.hlinux/interrupt.hlinux/ioport.hlinux/in.hlinux/sched.hlinux/string.hlinux/delay.hlinux/errno.hlinux/pci.hlinux/dma-mapping.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/mii.hlinux/ethtool.hlinux/crc32.hlinux/random.hlinux/workqueue.hlinux/if_vlan.hlinux/bitops.hlinux/mm.hlinux/gfp.hlinux/of.hasm/io.hasm/byteorder.hlinux/uaccess.hasm/irq.hasm/idprom.hasm/prom.h
Detected Declarations
function __sungem_phy_readfunction _sungem_phy_readfunction sungem_phy_readfunction __sungem_phy_writefunction _sungem_phy_writefunction sungem_phy_writefunction gem_enable_intsfunction gem_disable_intsfunction gem_get_cellfunction gem_put_cellfunction gem_netif_stopfunction gem_netif_startfunction gem_schedule_resetfunction gem_handle_mif_eventfunction gem_pcs_interruptfunction gem_txmac_interruptfunction gem_rxmac_resetfunction gem_rxmac_interruptfunction gem_mac_interruptfunction gem_mif_interruptfunction gem_pci_interruptfunction nowfunction gem_txfunction gem_post_rxdsfunction gem_rxfunction gem_pollfunction gem_interruptfunction gem_tx_timeoutfunction gem_intmefunction gem_start_xmitfunction gem_pcs_resetfunction gem_pcs_reinit_advfunction gem_resetfunction gem_start_dmafunction gem_stop_dmafunction gem_begin_auto_negotiationfunction gem_set_link_modesfunction gem_mdio_link_not_upfunction gem_link_timerfunction gem_clean_ringsfunction gem_init_ringsfunction gem_init_phyfunction gem_init_dmafunction gem_setup_multicastfunction netdev_for_each_mc_addrfunction gem_init_macfunction gem_init_pause_thresholdsfunction thresholds
Annotated Snippet
static const struct net_device_ops gem_netdev_ops = {
.ndo_open = gem_open,
.ndo_stop = gem_close,
.ndo_start_xmit = gem_start_xmit,
.ndo_get_stats = gem_get_stats,
.ndo_set_rx_mode = gem_set_multicast,
.ndo_eth_ioctl = gem_ioctl,
.ndo_tx_timeout = gem_tx_timeout,
.ndo_change_mtu = gem_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = gem_set_mac_address,
};
static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned long gemreg_base, gemreg_len;
struct net_device *dev;
struct gem *gp;
int err, pci_using_dac;
printk_once(KERN_INFO "%s", version);
/* Apple gmac note: during probe, the chip is powered up by
* the arch code to allow the code below to work (and to let
* the chip be probed on the config space. It won't stay powered
* up until the interface is brought up however, so we can't rely
* on register configuration done at this point.
*/
err = pci_enable_device(pdev);
if (err) {
pr_err("Cannot enable MMIO operation, aborting\n");
return err;
}
pci_set_master(pdev);
/* Configure DMA attributes. */
/* All of the GEM documentation states that 64-bit DMA addressing
* is fully supported and should work just fine. However the
* front end for RIO based GEMs is different and only supports
* 32-bit addressing.
*
* For now we assume the various PPC GEMs are 32-bit only as well.
*/
if (pdev->vendor == PCI_VENDOR_ID_SUN &&
pdev->device == PCI_DEVICE_ID_SUN_GEM &&
!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
pci_using_dac = 1;
} else {
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
pr_err("No usable DMA configuration, aborting\n");
goto err_disable_device;
}
pci_using_dac = 0;
}
gemreg_base = pci_resource_start(pdev, 0);
gemreg_len = pci_resource_len(pdev, 0);
if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
pr_err("Cannot find proper PCI device base address, aborting\n");
err = -ENODEV;
goto err_disable_device;
}
dev = alloc_etherdev(sizeof(*gp));
if (!dev) {
err = -ENOMEM;
goto err_disable_device;
}
SET_NETDEV_DEV(dev, &pdev->dev);
gp = netdev_priv(dev);
err = pci_request_regions(pdev, DRV_NAME);
if (err) {
pr_err("Cannot obtain PCI resources, aborting\n");
goto err_out_free_netdev;
}
gp->pdev = pdev;
gp->dev = dev;
gp->msg_enable = DEFAULT_MSG;
timer_setup(&gp->link_timer, gem_link_timer, 0);
INIT_WORK(&gp->reset_task, gem_reset_task);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/fcntl.h`, `linux/interrupt.h`, `linux/ioport.h`, `linux/in.h`, `linux/sched.h`.
- Detected declarations: `function __sungem_phy_read`, `function _sungem_phy_read`, `function sungem_phy_read`, `function __sungem_phy_write`, `function _sungem_phy_write`, `function sungem_phy_write`, `function gem_enable_ints`, `function gem_disable_ints`, `function gem_get_cell`, `function gem_put_cell`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.