drivers/net/ethernet/engleder/tsnep_ethtool.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/engleder/tsnep_ethtool.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/engleder/tsnep_ethtool.c
Extension
.c
Size
13601 bytes
Lines
486
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tsnep_stats {
	u64 rx_packets;
	u64 rx_bytes;
	u64 rx_dropped;
	u64 rx_multicast;
	u64 rx_alloc_failed;
	u64 rx_phy_errors;
	u64 rx_forwarded_phy_errors;
	u64 rx_invalid_frame_errors;
	u64 tx_packets;
	u64 tx_bytes;
	u64 tx_dropped;
};

#define TSNEP_STATS_COUNT (sizeof(struct tsnep_stats) / sizeof(u64))

static const char tsnep_rx_queue_stats_strings[][ETH_GSTRING_LEN] = {
	"rx_%d_packets",
	"rx_%d_bytes",
	"rx_%d_dropped",
	"rx_%d_multicast",
	"rx_%d_alloc_failed",
	"rx_%d_no_descriptor_errors",
	"rx_%d_buffer_too_small_errors",
	"rx_%d_fifo_overflow_errors",
	"rx_%d_invalid_frame_errors",
};

struct tsnep_rx_queue_stats {
	u64 rx_packets;
	u64 rx_bytes;
	u64 rx_dropped;
	u64 rx_multicast;
	u64 rx_alloc_failed;
	u64 rx_no_descriptor_errors;
	u64 rx_buffer_too_small_errors;
	u64 rx_fifo_overflow_errors;
	u64 rx_invalid_frame_errors;
};

#define TSNEP_RX_QUEUE_STATS_COUNT (sizeof(struct tsnep_rx_queue_stats) / \
				    sizeof(u64))

static const char tsnep_tx_queue_stats_strings[][ETH_GSTRING_LEN] = {
	"tx_%d_packets",
	"tx_%d_bytes",
	"tx_%d_dropped",
};

struct tsnep_tx_queue_stats {
	u64 tx_packets;
	u64 tx_bytes;
	u64 tx_dropped;
};

#define TSNEP_TX_QUEUE_STATS_COUNT (sizeof(struct tsnep_tx_queue_stats) / \
				    sizeof(u64))

static void tsnep_ethtool_get_drvinfo(struct net_device *netdev,
				      struct ethtool_drvinfo *drvinfo)
{
	struct tsnep_adapter *adapter = netdev_priv(netdev);

	strscpy(drvinfo->driver, TSNEP, sizeof(drvinfo->driver));
	strscpy(drvinfo->bus_info, dev_name(&adapter->pdev->dev),
		sizeof(drvinfo->bus_info));
}

static int tsnep_ethtool_get_regs_len(struct net_device *netdev)
{
	struct tsnep_adapter *adapter = netdev_priv(netdev);
	int len;
	int num_additional_queues;

	len = TSNEP_MAC_SIZE;

	/* first queue pair is within TSNEP_MAC_SIZE, only queues additional to
	 * the first queue pair extend the register length by TSNEP_QUEUE_SIZE
	 */
	num_additional_queues =
		max(adapter->num_tx_queues, adapter->num_rx_queues) - 1;
	len += TSNEP_QUEUE_SIZE * num_additional_queues;

	return len;
}

static void tsnep_ethtool_get_regs(struct net_device *netdev,
				   struct ethtool_regs *regs,
				   void *p)
{

Annotation

Implementation Notes