drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c- Extension
.c- Size
- 40600 bytes
- Lines
- 1497
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/ethtool.hlinux/stddef.hlinux/etherdevice.hlinux/log2.hlinux/net_tstamp.hlinux/linkmode.hotx2_common.hotx2_ptp.hcgx_fw_if.h
Detected Declarations
struct otx2_statenum link_modefunction otx2_get_drvinfofunction otx2_get_qset_stringsfunction otx2_get_stringsfunction otx2_get_qset_statsfunction otx2_get_phy_fec_statsfunction otx2_get_ethtool_statsfunction otx2_get_sset_countfunction otx2_get_channelsfunction otx2_set_channelsfunction otx2_get_pauseparamfunction otx2_set_pauseparamfunction otx2_get_ringparamfunction otx2_set_ringparamfunction otx2_get_coalescefunction otx2_set_coalescefunction otx2_get_rx_ring_countfunction otx2_get_rss_hash_optsfunction otx2_set_rss_hash_optsfunction otx2_get_rxnfcfunction otx2_set_rxnfcfunction otx2_get_rxfh_key_sizefunction otx2_get_rxfh_indir_sizefunction otx2_create_rxfhfunction otx2_modify_rxfhfunction otx2_remove_rxfhfunction otx2_set_rxfhfunction otx2_get_rxfhfunction otx2_get_msglevelfunction otx2_set_msglevelfunction otx2_get_linkfunction otx2_get_ts_infofunction otx2_get_fecparamfunction otx2_set_fecparamfunction otx2_get_fec_infofunction otx2_get_link_mode_infofunction for_each_set_bitfunction otx2_get_link_ksettingsfunction otx2_set_link_ksettingsfunction otx2_get_fec_statsfunction otx2_set_ethtool_opsfunction otx2vf_get_drvinfofunction otx2vf_get_stringsfunction otx2vf_get_ethtool_statsfunction otx2vf_get_sset_countfunction otx2vf_get_link_ksettingsfunction otx2vf_set_ethtool_ops
Annotated Snippet
struct otx2_stat {
char name[ETH_GSTRING_LEN];
unsigned int index;
};
/* HW device stats */
#define OTX2_DEV_STAT(stat) { \
.name = #stat, \
.index = offsetof(struct otx2_dev_stats, stat) / sizeof(u64), \
}
enum link_mode {
OTX2_MODE_SUPPORTED,
OTX2_MODE_ADVERTISED
};
static const struct otx2_stat otx2_dev_stats[] = {
OTX2_DEV_STAT(rx_ucast_frames),
OTX2_DEV_STAT(rx_bcast_frames),
OTX2_DEV_STAT(rx_mcast_frames),
OTX2_DEV_STAT(tx_ucast_frames),
OTX2_DEV_STAT(tx_bcast_frames),
OTX2_DEV_STAT(tx_mcast_frames),
};
/* Driver level stats */
#define OTX2_DRV_STAT(stat) { \
.name = #stat, \
.index = offsetof(struct otx2_drv_stats, stat) / sizeof(atomic_t), \
}
static const struct otx2_stat otx2_drv_stats[] = {
OTX2_DRV_STAT(rx_fcs_errs),
OTX2_DRV_STAT(rx_oversize_errs),
OTX2_DRV_STAT(rx_undersize_errs),
OTX2_DRV_STAT(rx_csum_errs),
OTX2_DRV_STAT(rx_len_errs),
OTX2_DRV_STAT(rx_other_errs),
};
static const struct otx2_stat otx2_queue_stats[] = {
{ "bytes", 0 },
{ "frames", 1 },
};
#define OTX2_FEC_MAX_INDEX 4
static const unsigned int otx2_n_dev_stats = ARRAY_SIZE(otx2_dev_stats);
static const unsigned int otx2_n_drv_stats = ARRAY_SIZE(otx2_drv_stats);
static const unsigned int otx2_n_queue_stats = ARRAY_SIZE(otx2_queue_stats);
static struct cgx_fw_data *otx2_get_fwdata(struct otx2_nic *pfvf);
static void otx2_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info)
{
struct otx2_nic *pfvf = netdev_priv(netdev);
strscpy(info->driver, DRV_NAME, sizeof(info->driver));
strscpy(info->bus_info, pci_name(pfvf->pdev), sizeof(info->bus_info));
}
static void otx2_get_qset_strings(struct otx2_nic *pfvf, u8 **data, int qset)
{
int start_qidx = qset * pfvf->hw.rx_queues;
int qidx, stats;
for (qidx = 0; qidx < pfvf->hw.rx_queues; qidx++)
for (stats = 0; stats < otx2_n_queue_stats; stats++)
ethtool_sprintf(data, "rxq%d: %s", qidx + start_qidx,
otx2_queue_stats[stats].name);
for (qidx = 0; qidx < otx2_get_total_tx_queues(pfvf); qidx++)
for (stats = 0; stats < otx2_n_queue_stats; stats++)
if (qidx >= pfvf->hw.non_qos_queues)
ethtool_sprintf(data, "txq_qos%d: %s",
qidx + start_qidx -
pfvf->hw.non_qos_queues,
otx2_queue_stats[stats].name);
else
ethtool_sprintf(data, "txq%d: %s",
qidx + start_qidx,
otx2_queue_stats[stats].name);
}
static void otx2_get_strings(struct net_device *netdev, u32 sset, u8 *data)
{
struct otx2_nic *pfvf = netdev_priv(netdev);
int stats;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/ethtool.h`, `linux/stddef.h`, `linux/etherdevice.h`, `linux/log2.h`, `linux/net_tstamp.h`, `linux/linkmode.h`, `otx2_common.h`.
- Detected declarations: `struct otx2_stat`, `enum link_mode`, `function otx2_get_drvinfo`, `function otx2_get_qset_strings`, `function otx2_get_strings`, `function otx2_get_qset_stats`, `function otx2_get_phy_fec_stats`, `function otx2_get_ethtool_stats`, `function otx2_get_sset_count`, `function otx2_get_channels`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.