drivers/net/ethernet/atheros/alx/ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/atheros/alx/ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/atheros/alx/ethtool.c- Extension
.c- Size
- 8860 bytes
- Lines
- 335
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/ip.hlinux/tcp.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/mdio.hlinux/interrupt.hasm/byteorder.halx.hreg.hhw.h
Detected Declarations
function alx_get_supported_speedsfunction alx_get_link_ksettingsfunction alx_set_link_ksettingsfunction alx_get_pauseparamfunction alx_set_pauseparamfunction alx_get_msglevelfunction alx_set_msglevelfunction alx_get_ethtool_statsfunction alx_get_stringsfunction alx_get_sset_count
Annotated Snippet
if (hw->flowctrl & ALX_FC_RX) {
advertising |= ADVERTISED_Pause;
if (!(hw->flowctrl & ALX_FC_TX))
advertising |= ADVERTISED_Asym_Pause;
} else if (hw->flowctrl & ALX_FC_TX) {
advertising |= ADVERTISED_Asym_Pause;
}
}
mutex_lock(&alx->mtx);
cmd->base.speed = hw->link_speed;
cmd->base.duplex = hw->duplex;
mutex_unlock(&alx->mtx);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
advertising);
return 0;
}
static int alx_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *cmd)
{
struct alx_priv *alx = netdev_priv(netdev);
struct alx_hw *hw = &alx->hw;
u32 adv_cfg;
u32 advertising;
int ret;
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
if (cmd->base.autoneg == AUTONEG_ENABLE) {
if (advertising & ~alx_get_supported_speeds(hw))
return -EINVAL;
adv_cfg = advertising | ADVERTISED_Autoneg;
} else {
adv_cfg = alx_speed_to_ethadv(cmd->base.speed,
cmd->base.duplex);
if (!adv_cfg || adv_cfg == ADVERTISED_1000baseT_Full)
return -EINVAL;
}
hw->adv_cfg = adv_cfg;
mutex_lock(&alx->mtx);
ret = alx_setup_speed_duplex(hw, adv_cfg, hw->flowctrl);
mutex_unlock(&alx->mtx);
return ret;
}
static void alx_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
{
struct alx_priv *alx = netdev_priv(netdev);
struct alx_hw *hw = &alx->hw;
mutex_lock(&alx->mtx);
pause->autoneg = !!(hw->flowctrl & ALX_FC_ANEG &&
hw->adv_cfg & ADVERTISED_Autoneg);
pause->tx_pause = !!(hw->flowctrl & ALX_FC_TX);
pause->rx_pause = !!(hw->flowctrl & ALX_FC_RX);
mutex_unlock(&alx->mtx);
}
static int alx_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
{
struct alx_priv *alx = netdev_priv(netdev);
struct alx_hw *hw = &alx->hw;
int err = 0;
bool reconfig_phy = false;
u8 fc = 0;
if (pause->tx_pause)
fc |= ALX_FC_TX;
if (pause->rx_pause)
fc |= ALX_FC_RX;
if (pause->autoneg)
fc |= ALX_FC_ANEG;
mutex_lock(&alx->mtx);
/* restart auto-neg for auto-mode */
Annotation
- Immediate include surface: `linux/pci.h`, `linux/ip.h`, `linux/tcp.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/mdio.h`, `linux/interrupt.h`.
- Detected declarations: `function alx_get_supported_speeds`, `function alx_get_link_ksettings`, `function alx_set_link_ksettings`, `function alx_get_pauseparam`, `function alx_set_pauseparam`, `function alx_get_msglevel`, `function alx_set_msglevel`, `function alx_get_ethtool_stats`, `function alx_get_strings`, `function alx_get_sset_count`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.