drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c
Extension
.c
Size
12682 bytes
Lines
465
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 bcmasp_stats {
	char stat_string[ETH_GSTRING_LEN];
	enum bcmasp_stat_type type;
	u32 reg_offset;
};

#define STAT_BCMASP_SOFT_MIB(str) { \
	.stat_string = str, \
	.type = BCMASP_STAT_SOFT, \
}

#define STAT_BCMASP_OFFSET(str, _type, offset) { \
	.stat_string = str, \
	.type = _type, \
	.reg_offset = offset, \
}

#define STAT_BCMASP_RX_CTRL(str, offset) \
	STAT_BCMASP_OFFSET(str, BCMASP_STAT_RX_CTRL, offset)
#define STAT_BCMASP_RX_CTRL_PER_INTF(str, offset) \
	STAT_BCMASP_OFFSET(str, BCMASP_STAT_RX_CTRL_PER_INTF, offset)

/* Must match the order of struct bcmasp_mib_counters */
static const struct bcmasp_stats bcmasp_gstrings_stats[] = {
	/* ASP RX control */
	STAT_BCMASP_RX_CTRL_PER_INTF("Frames From Unimac",
				     ASP_RX_CTRL_UMAC_0_FRAME_COUNT),
	STAT_BCMASP_RX_CTRL_PER_INTF("Frames From Port",
				     ASP_RX_CTRL_FB_0_FRAME_COUNT),
	STAT_BCMASP_RX_CTRL_PER_INTF("RX Buffer FIFO Depth",
				     ASP_RX_CTRL_FB_RX_FIFO_DEPTH),
	STAT_BCMASP_RX_CTRL("Frames Out(Buffer)",
			    ASP_RX_CTRL_FB_OUT_FRAME_COUNT),
	STAT_BCMASP_RX_CTRL("Frames Out(Filters)",
			    ASP_RX_CTRL_FB_FILT_OUT_FRAME_COUNT),
	/* Software maintained statistics */
	STAT_BCMASP_SOFT_MIB("RX SKB Alloc Failed"),
	STAT_BCMASP_SOFT_MIB("TX DMA Failed"),
	STAT_BCMASP_SOFT_MIB("Multicast Filters Full"),
	STAT_BCMASP_SOFT_MIB("Unicast Filters Full"),
	STAT_BCMASP_SOFT_MIB("MDA Filters Combined"),
	STAT_BCMASP_SOFT_MIB("Promisc Filter Set"),
	STAT_BCMASP_SOFT_MIB("TX Realloc For Offload Failed"),
	STAT_BCMASP_SOFT_MIB("Tx Timeout Count"),
};

#define BCMASP_STATS_LEN	ARRAY_SIZE(bcmasp_gstrings_stats)

static int bcmasp_get_sset_count(struct net_device *dev, int string_set)
{
	switch (string_set) {
	case ETH_SS_STATS:
		return BCMASP_STATS_LEN;
	default:
		return -EOPNOTSUPP;
	}
}

static void bcmasp_get_strings(struct net_device *dev, u32 stringset,
			       u8 *data)
{
	const char *str;
	unsigned int i;

	switch (stringset) {
	case ETH_SS_STATS:
		for (i = 0; i < BCMASP_STATS_LEN; i++) {
			str = bcmasp_gstrings_stats[i].stat_string;
			ethtool_puts(&data, str);
		}
		break;
	default:
		return;
	}
}

static void bcmasp_update_mib_counters(struct bcmasp_intf *intf)
{
	unsigned int i;

	for (i = 0; i < BCMASP_STATS_LEN; i++) {
		const struct bcmasp_stats *s;
		u32 offset, val;
		char *p;

		s = &bcmasp_gstrings_stats[i];
		offset = s->reg_offset;
		switch (s->type) {
		case BCMASP_STAT_SOFT:
			continue;

Annotation

Implementation Notes