drivers/net/ethernet/realtek/rtase/rtase_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/realtek/rtase/rtase_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/realtek/rtase/rtase_main.c- Extension
.c- Size
- 59623 bytes
- Lines
- 2407
- 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.
- 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/crc32.hlinux/dma-mapping.hlinux/etherdevice.hlinux/if_vlan.hlinux/in.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/ip.hlinux/ipv6.hlinux/mdio.hlinux/module.hlinux/netdevice.hlinux/pci.hlinux/pm_runtime.hlinux/prefetch.hlinux/rtnetlink.hlinux/tcp.hasm/irq.hnet/ip6_checksum.hnet/netdev_queues.hnet/page_pool/helpers.hnet/pkt_cls.hrtase.h
Detected Declarations
struct rtase_countersfunction rtase_w8function rtase_w16function rtase_w32function rtase_r8function rtase_r16function rtase_r32function rtase_free_descfunction rtase_alloc_descfunction rtase_unmap_tx_skbfunction rtase_tx_clear_rangefunction rtase_tx_clearfunction rtase_mark_to_asicfunction rtase_tx_availfunction tx_handlerfunction rtase_tx_desc_initfunction rtase_map_to_asicfunction rtase_make_unusable_by_asicfunction rtase_alloc_rx_data_buffunction rtase_rx_ring_fillfunction rtase_mark_as_last_descriptorfunction rtase_rx_ring_clearfunction rtase_fragmented_framefunction rtase_rx_csumfunction rtase_rx_vlan_skbfunction rtase_rx_skbfunction rx_handlerfunction rtase_rx_desc_initfunction rtase_rx_clearfunction rtase_init_ringfunction rtase_interrupt_mitigationfunction rtase_tally_counter_addr_fillfunction rtase_tally_counter_clearfunction rtase_desc_addr_fillfunction rtase_hw_set_featuresfunction rtase_hw_set_rx_packet_filterfunction netdev_for_each_mc_addrfunction rtase_irq_dis_and_clearfunction rtase_poll_timeoutfunction rtase_nic_resetfunction rtase_hw_resetfunction rtase_set_rx_queuefunction rtase_set_tx_queuefunction rtase_hw_configfunction rtase_nic_enablefunction rtase_enable_hw_interruptfunction rtase_hw_startfunction rtase_interrupt
Annotated Snippet
static const struct net_device_ops rtase_netdev_ops = {
.ndo_open = rtase_open,
.ndo_stop = rtase_close,
.ndo_start_xmit = rtase_start_xmit,
.ndo_set_rx_mode = rtase_set_rx_mode,
.ndo_set_mac_address = rtase_set_mac_address,
.ndo_change_mtu = rtase_change_mtu,
.ndo_tx_timeout = rtase_tx_timeout,
.ndo_get_stats64 = rtase_get_stats64,
.ndo_setup_tc = rtase_setup_tc,
.ndo_fix_features = rtase_fix_features,
.ndo_set_features = rtase_set_features,
};
static void rtase_get_mac_address(struct net_device *dev)
{
struct rtase_private *tp = netdev_priv(dev);
u8 mac_addr[ETH_ALEN] __aligned(2) = {};
u32 i;
for (i = 0; i < ETH_ALEN; i++)
mac_addr[i] = rtase_r8(tp, RTASE_MAC0 + i);
if (!is_valid_ether_addr(mac_addr)) {
eth_hw_addr_random(dev);
netdev_warn(dev, "Random ether addr %pM\n", dev->dev_addr);
} else {
eth_hw_addr_set(dev, mac_addr);
ether_addr_copy(dev->perm_addr, dev->dev_addr);
}
rtase_rar_set(tp, dev->dev_addr);
}
static int rtase_get_settings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
u32 supported = SUPPORTED_MII | SUPPORTED_Pause | SUPPORTED_Asym_Pause;
const struct rtase_private *tp = netdev_priv(dev);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
switch (tp->hw_ver) {
case RTASE_HW_VER_906X_7XA:
case RTASE_HW_VER_906X_7XC:
cmd->base.speed = SPEED_5000;
break;
case RTASE_HW_VER_907XD_V1:
case RTASE_HW_VER_907XD_VA:
cmd->base.speed = SPEED_10000;
break;
}
cmd->base.duplex = DUPLEX_FULL;
cmd->base.port = PORT_MII;
cmd->base.autoneg = AUTONEG_DISABLE;
return 0;
}
static void rtase_get_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *pause)
{
const struct rtase_private *tp = netdev_priv(dev);
u16 value = rtase_r16(tp, RTASE_CPLUS_CMD);
pause->autoneg = AUTONEG_DISABLE;
pause->tx_pause = !!(value & RTASE_FORCE_TXFLOW_EN);
pause->rx_pause = !!(value & RTASE_FORCE_RXFLOW_EN);
}
static int rtase_set_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *pause)
{
const struct rtase_private *tp = netdev_priv(dev);
u16 value = rtase_r16(tp, RTASE_CPLUS_CMD);
if (pause->autoneg)
return -EOPNOTSUPP;
value &= ~(RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN);
if (pause->tx_pause)
value |= RTASE_FORCE_TXFLOW_EN;
if (pause->rx_pause)
value |= RTASE_FORCE_RXFLOW_EN;
rtase_w16(tp, RTASE_CPLUS_CMD, value);
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/dma-mapping.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/in.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct rtase_counters`, `function rtase_w8`, `function rtase_w16`, `function rtase_w32`, `function rtase_r8`, `function rtase_r16`, `function rtase_r32`, `function rtase_free_desc`, `function rtase_alloc_desc`, `function rtase_unmap_tx_skb`.
- 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.