drivers/net/dsa/netc/netc_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/netc/netc_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/netc/netc_ethtool.c- Extension
.c- Size
- 9064 bytes
- Lines
- 292
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool_netlink.hnetc_switch.h
Detected Declarations
function netc_port_pause_statsfunction netc_port_get_pause_statsfunction netc_port_rmon_statsfunction netc_port_get_rmon_statsfunction netc_port_ctrl_statsfunction netc_port_get_eth_ctrl_statsfunction netc_port_mac_statsfunction netc_port_get_eth_mac_statsfunction netc_port_get_sset_countfunction netc_port_get_stringsfunction netc_port_get_ethtool_stats
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
* NXP NETC switch driver
* Copyright 2025-2026 NXP
*/
#include <linux/ethtool_netlink.h>
#include "netc_switch.h"
static const struct ethtool_rmon_hist_range netc_rmon_ranges[] = {
{ 64, 64 },
{ 65, 127 },
{ 128, 255 },
{ 256, 511 },
{ 512, 1023 },
{ 1024, 1522 },
{ 1523, NETC_MAX_FRAME_LEN },
{ }
};
static const struct netc_port_stat netc_port_counters[] = {
{ NETC_PTGSLACR, "port gate late arrival frames" },
{ NETC_PSDFTCR, "port SDF transmit frames" },
{ NETC_PSDFDDCR, "port SDF drop duplicate frames" },
{ NETC_PRXDCR, "port rx discard frames" },
{ NETC_PRXDCRRR, "port rx discard read-reset" },
{ NETC_PRXDCRR0, "port rx discard reason 0" },
{ NETC_PRXDCRR1, "port rx discard reason 1" },
{ NETC_PTXDCR, "port tx discard frames" },
{ NETC_BPDCR, "bridge port discard frames" },
};
static const struct netc_port_stat netc_emac_counters[] = {
{ NETC_PM_ROCT(0), "eMAC rx octets" },
{ NETC_PM_RVLAN(0), "eMAC rx VLAN frames" },
{ NETC_PM_RERR(0), "eMAC rx frame errors" },
{ NETC_PM_RUCA(0), "eMAC rx unicast frames" },
{ NETC_PM_RDRP(0), "eMAC rx dropped packets" },
{ NETC_PM_RPKT(0), "eMAC rx packets" },
{ NETC_PM_TOCT(0), "eMAC tx octets" },
{ NETC_PM_TVLAN(0), "eMAC tx VLAN frames" },
{ NETC_PM_TFCS(0), "eMAC tx FCS errors" },
{ NETC_PM_TUCA(0), "eMAC tx unicast frames" },
{ NETC_PM_TPKT(0), "eMAC tx packets" },
{ NETC_PM_TUND(0), "eMAC tx undersized packets" },
{ NETC_PM_TIOCT(0), "eMAC tx invalid octets" },
};
static const struct netc_port_stat netc_pmac_counters[] = {
{ NETC_PM_ROCT(1), "pMAC rx octets" },
{ NETC_PM_RVLAN(1), "pMAC rx VLAN frames" },
{ NETC_PM_RERR(1), "pMAC rx frame errors" },
{ NETC_PM_RUCA(1), "pMAC rx unicast frames" },
{ NETC_PM_RDRP(1), "pMAC rx dropped packets" },
{ NETC_PM_RPKT(1), "pMAC rx packets" },
{ NETC_PM_TOCT(1), "pMAC tx octets" },
{ NETC_PM_TVLAN(1), "pMAC tx VLAN frames" },
{ NETC_PM_TFCS(1), "pMAC tx FCS errors" },
{ NETC_PM_TUCA(1), "pMAC tx unicast frames" },
{ NETC_PM_TPKT(1), "pMAC tx packets" },
{ NETC_PM_TUND(1), "pMAC tx undersized packets" },
{ NETC_PM_TIOCT(1), "pMAC tx invalid octets" },
};
static void netc_port_pause_stats(struct netc_port *np, int mac,
struct ethtool_pause_stats *stats)
{
if (mac && !np->caps.pmac)
return;
stats->tx_pause_frames = netc_port_rd64(np, NETC_PM_TXPF(mac));
stats->rx_pause_frames = netc_port_rd64(np, NETC_PM_RXPF(mac));
}
void netc_port_get_pause_stats(struct dsa_switch *ds, int port,
struct ethtool_pause_stats *pause_stats)
{
struct netc_port *np = NETC_PORT(ds, port);
struct net_device *ndev;
switch (pause_stats->src) {
case ETHTOOL_MAC_STATS_SRC_EMAC:
netc_port_pause_stats(np, 0, pause_stats);
break;
case ETHTOOL_MAC_STATS_SRC_PMAC:
netc_port_pause_stats(np, 1, pause_stats);
break;
case ETHTOOL_MAC_STATS_SRC_AGGREGATE:
ndev = dsa_to_port(ds, port)->user;
Annotation
- Immediate include surface: `linux/ethtool_netlink.h`, `netc_switch.h`.
- Detected declarations: `function netc_port_pause_stats`, `function netc_port_get_pause_stats`, `function netc_port_rmon_stats`, `function netc_port_get_rmon_stats`, `function netc_port_ctrl_stats`, `function netc_port_get_eth_ctrl_stats`, `function netc_port_mac_stats`, `function netc_port_get_eth_mac_stats`, `function netc_port_get_sset_count`, `function netc_port_get_strings`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.