drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c- Extension
.c- Size
- 7486 bytes
- Lines
- 268
- 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/ethtool.hdpaa2-switch.h
Detected Declarations
function dpaa2_switch_get_drvinfofunction dpaa2_switch_get_link_ksettingsfunction dpaa2_switch_set_link_ksettingsfunction dpaa2_switch_ethtool_get_sset_countfunction dpaa2_switch_ethtool_get_stringsfunction dpaa2_switch_ethtool_get_statsfunction dpaa2_switch_get_rmon_statsfunction dpaa2_switch_get_ctrl_statsfunction dpaa2_switch_get_eth_mac_stats
Annotated Snippet
if (err) {
netdev_err(netdev, "dpsw_if_disable err %d\n", err);
return err;
}
}
cfg.rate = link_ksettings->base.speed;
if (link_ksettings->base.autoneg == AUTONEG_ENABLE)
cfg.options |= DPSW_LINK_OPT_AUTONEG;
else
cfg.options &= ~DPSW_LINK_OPT_AUTONEG;
if (link_ksettings->base.duplex == DUPLEX_HALF)
cfg.options |= DPSW_LINK_OPT_HALF_DUPLEX;
else
cfg.options &= ~DPSW_LINK_OPT_HALF_DUPLEX;
err = dpsw_if_set_link_cfg(port_priv->ethsw_data->mc_io, 0,
port_priv->ethsw_data->dpsw_handle,
port_priv->idx,
&cfg);
if (if_running) {
ret = dpsw_if_enable(ethsw->mc_io, 0,
ethsw->dpsw_handle,
port_priv->idx);
if (ret) {
netdev_err(netdev, "dpsw_if_enable err %d\n", ret);
return ret;
}
}
return err;
}
static int
dpaa2_switch_ethtool_get_sset_count(struct net_device *netdev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
return DPAA2_SWITCH_NUM_COUNTERS + dpaa2_mac_get_sset_count();
default:
return -EOPNOTSUPP;
}
}
static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev,
u32 stringset, u8 *data)
{
const char *str;
int i;
switch (stringset) {
case ETH_SS_STATS:
for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) {
str = dpaa2_switch_ethtool_counters[i].name;
ethtool_puts(&data, str);
}
dpaa2_mac_get_strings(&data);
break;
}
}
static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev,
struct ethtool_stats *stats,
u64 *data)
{
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int i, err;
for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) {
err = dpsw_if_get_counter(port_priv->ethsw_data->mc_io, 0,
port_priv->ethsw_data->dpsw_handle,
port_priv->idx,
dpaa2_switch_ethtool_counters[i].id,
&data[i]);
if (err)
netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n",
dpaa2_switch_ethtool_counters[i].name, err);
}
mutex_lock(&port_priv->mac_lock);
if (dpaa2_switch_port_has_mac(port_priv))
dpaa2_mac_get_ethtool_stats(port_priv->mac, data + i);
mutex_unlock(&port_priv->mac_lock);
}
static void
dpaa2_switch_get_rmon_stats(struct net_device *netdev,
struct ethtool_rmon_stats *rmon_stats,
Annotation
- Immediate include surface: `linux/ethtool.h`, `dpaa2-switch.h`.
- Detected declarations: `function dpaa2_switch_get_drvinfo`, `function dpaa2_switch_get_link_ksettings`, `function dpaa2_switch_set_link_ksettings`, `function dpaa2_switch_ethtool_get_sset_count`, `function dpaa2_switch_ethtool_get_strings`, `function dpaa2_switch_ethtool_get_stats`, `function dpaa2_switch_get_rmon_stats`, `function dpaa2_switch_get_ctrl_stats`, `function dpaa2_switch_get_eth_mac_stats`.
- 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.