drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
Extension
.c
Size
22375 bytes
Lines
766
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

if (is_rx_ring(bd, i)) {
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_ucast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_mcast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_bcast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_ucast_bytes);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_mcast_bytes);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_bcast_bytes);
		}
		if (is_tx_ring(bd, i)) {
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_ucast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_mcast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_bcast_pkts);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_ucast_bytes);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_mcast_bytes);
			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_bcast_bytes);
		}
		if (!tpa_stats || !is_rx_ring(bd, i))
			continue;

		k = BNGE_NUM_RX_RING_STATS + BNGE_NUM_TX_RING_STATS;
		for (; k < BNGE_NUM_RX_RING_STATS + BNGE_NUM_TX_RING_STATS +
			   tpa_stats; j++, k++)
			buf[j] = sw_stats[k];
	}

skip_ring_stats:
	if (bn->flags & BNGE_FLAG_PORT_STATS) {
		u64 *port_stats = bn->port_stats.sw_stats;

		for (i = 0; i < BNGE_NUM_PORT_STATS; i++, j++)
			buf[j] = *(port_stats + bnge_port_stats_arr[i].offset);
	}
	if (bn->flags & BNGE_FLAG_PORT_STATS_EXT) {
		u64 *rx_port_stats_ext = bn->rx_port_stats_ext.sw_stats;
		u64 *tx_port_stats_ext = bn->tx_port_stats_ext.sw_stats;
		u32 len;

		len = min_t(u32, bn->fw_rx_stats_ext_size,
			    ARRAY_SIZE(bnge_port_stats_ext_arr));
		for (i = 0; i < len; i++, j++) {
			buf[j] = *(rx_port_stats_ext +
				   bnge_port_stats_ext_arr[i].offset);
		}
		len = min_t(u32, bn->fw_tx_stats_ext_size,
			    ARRAY_SIZE(bnge_tx_port_stats_ext_arr));
		for (i = 0; i < len; i++, j++) {
			buf[j] = *(tx_port_stats_ext +
				   bnge_tx_port_stats_ext_arr[i].offset);
		}
		if (bn->pri2cos_valid) {
			for (i = 0; i < 8; i++, j++) {
				long n = bnge_rx_bytes_pri_arr[i].base_off +
					 bn->pri2cos_idx[i];

				buf[j] = *(rx_port_stats_ext + n);
			}
			for (i = 0; i < 8; i++, j++) {
				long n = bnge_rx_pkts_pri_arr[i].base_off +
					 bn->pri2cos_idx[i];

				buf[j] = *(rx_port_stats_ext + n);
			}
			for (i = 0; i < 8; i++, j++) {
				long n = bnge_tx_bytes_pri_arr[i].base_off +
					 bn->pri2cos_idx[i];

				buf[j] = *(tx_port_stats_ext + n);
			}
			for (i = 0; i < 8; i++, j++) {
				long n = bnge_tx_pkts_pri_arr[i].base_off +
					 bn->pri2cos_idx[i];

				buf[j] = *(tx_port_stats_ext + n);
			}
		}
	}
}

static void bnge_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{
	struct bnge_net *bn = netdev_priv(dev);
	struct bnge_dev *bd = bn->bd;
	u32 i, j, num_str;
	const char *str;

	switch (stringset) {
	case ETH_SS_STATS:
		for (i = 0; i < bd->nq_nr_rings; i++) {
			if (is_rx_ring(bd, i))
				for (j = 0; j < NUM_RING_Q_HW_STATS; j++) {

Annotation

Implementation Notes