drivers/net/ethernet/calxeda/xgmac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/calxeda/xgmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/calxeda/xgmac.c- Extension
.c- Size
- 56954 bytes
- Lines
- 1928
- 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/mod_devicetable.hlinux/kernel.hlinux/circ_buf.hlinux/interrupt.hlinux/etherdevice.hlinux/platform_device.hlinux/skbuff.hlinux/ethtool.hlinux/if.hlinux/crc32.hlinux/dma-mapping.hlinux/slab.h
Detected Declarations
struct xgmac_dma_descstruct xgmac_extra_statsstruct xgmac_privstruct xgmac_statsfunction desc_set_buf_lenfunction desc_get_buf_lenfunction desc_init_rx_descfunction desc_init_tx_descfunction desc_get_ownerfunction desc_set_rx_ownerfunction desc_set_tx_ownerfunction desc_clear_tx_ownerfunction desc_get_tx_lsfunction desc_get_tx_fsfunction desc_get_buf_addrfunction desc_set_buf_addrfunction desc_set_buf_addr_and_sizefunction desc_get_rx_frame_lenfunction xgmac_dma_flush_tx_fifofunction desc_get_tx_statusfunction desc_get_rx_statusfunction xgmac_mac_enablefunction xgmac_mac_disablefunction xgmac_set_mac_addrfunction xgmac_get_mac_addrfunction xgmac_set_flow_ctrlfunction xgmac_rx_refillfunction xgmac_dma_desc_rings_initfunction xgmac_free_rx_skbufsfunction xgmac_free_tx_skbufsfunction xgmac_free_dma_desc_ringsfunction xgmac_tx_completefunction xgmac_tx_timeout_workfunction xgmac_hw_initfunction appropriatefunction xgmac_stopfunction xgmac_xmitfunction xgmac_rxfunction xgmac_pollfunction xgmac_tx_timeoutfunction xgmac_set_rx_modefunction appropriatefunction xgmac_pmt_interruptfunction xgmac_interruptfunction xgmac_poll_controllerfunction xgmac_get_stats64function xgmac_set_mac_addressfunction xgmac_set_features
Annotated Snippet
static const struct net_device_ops xgmac_netdev_ops = {
.ndo_open = xgmac_open,
.ndo_start_xmit = xgmac_xmit,
.ndo_stop = xgmac_stop,
.ndo_change_mtu = xgmac_change_mtu,
.ndo_set_rx_mode = xgmac_set_rx_mode,
.ndo_tx_timeout = xgmac_tx_timeout,
.ndo_get_stats64 = xgmac_get_stats64,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = xgmac_poll_controller,
#endif
.ndo_set_mac_address = xgmac_set_mac_address,
.ndo_set_features = xgmac_set_features,
};
static int xgmac_ethtool_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
cmd->base.autoneg = 0;
cmd->base.duplex = DUPLEX_FULL;
cmd->base.speed = 10000;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, 0);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, 0);
return 0;
}
static void xgmac_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
{
struct xgmac_priv *priv = netdev_priv(netdev);
pause->rx_pause = priv->rx_pause;
pause->tx_pause = priv->tx_pause;
}
static int xgmac_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
{
struct xgmac_priv *priv = netdev_priv(netdev);
if (pause->autoneg)
return -EINVAL;
return xgmac_set_flow_ctrl(priv, pause->rx_pause, pause->tx_pause);
}
struct xgmac_stats {
char stat_string[ETH_GSTRING_LEN];
int stat_offset;
bool is_reg;
};
#define XGMAC_STAT(m) \
{ #m, offsetof(struct xgmac_priv, xstats.m), false }
#define XGMAC_HW_STAT(m, reg_offset) \
{ #m, reg_offset, true }
static const struct xgmac_stats xgmac_gstrings_stats[] = {
XGMAC_STAT(tx_frame_flushed),
XGMAC_STAT(tx_payload_error),
XGMAC_STAT(tx_ip_header_error),
XGMAC_STAT(tx_local_fault),
XGMAC_STAT(tx_remote_fault),
XGMAC_STAT(tx_early),
XGMAC_STAT(tx_process_stopped),
XGMAC_STAT(tx_jabber),
XGMAC_STAT(rx_buf_unav),
XGMAC_STAT(rx_process_stopped),
XGMAC_STAT(rx_payload_error),
XGMAC_STAT(rx_ip_header_error),
XGMAC_STAT(rx_da_filter_fail),
XGMAC_STAT(fatal_bus_error),
XGMAC_HW_STAT(rx_watchdog, XGMAC_MMC_RXWATCHDOG),
XGMAC_HW_STAT(tx_vlan, XGMAC_MMC_TXVLANFRAME),
XGMAC_HW_STAT(rx_vlan, XGMAC_MMC_RXVLANFRAME),
XGMAC_HW_STAT(tx_pause, XGMAC_MMC_TXPAUSEFRAME),
XGMAC_HW_STAT(rx_pause, XGMAC_MMC_RXPAUSEFRAME),
};
#define XGMAC_STATS_LEN ARRAY_SIZE(xgmac_gstrings_stats)
static void xgmac_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *dummy,
u64 *data)
{
struct xgmac_priv *priv = netdev_priv(dev);
void *p = priv;
int i;
for (i = 0; i < XGMAC_STATS_LEN; i++) {
if (xgmac_gstrings_stats[i].is_reg)
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/kernel.h`, `linux/circ_buf.h`, `linux/interrupt.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `linux/skbuff.h`.
- Detected declarations: `struct xgmac_dma_desc`, `struct xgmac_extra_stats`, `struct xgmac_priv`, `struct xgmac_stats`, `function desc_set_buf_len`, `function desc_get_buf_len`, `function desc_init_rx_desc`, `function desc_init_tx_desc`, `function desc_get_owner`, `function desc_set_rx_owner`.
- 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.