drivers/net/ethernet/broadcom/bnxt/bnxt.c

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

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/bnxt/bnxt.c
Extension
.c
Size
470318 bytes
Lines
17533
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct net_device_ops bnxt_netdev_ops = {
	.ndo_open		= bnxt_open,
	.ndo_start_xmit		= bnxt_start_xmit,
	.ndo_stop		= bnxt_close,
	.ndo_get_stats64	= bnxt_get_stats64,
	.ndo_set_rx_mode_async	= bnxt_set_rx_mode,
	.ndo_eth_ioctl		= bnxt_ioctl,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= bnxt_change_mac_addr,
	.ndo_change_mtu		= bnxt_change_mtu,
	.ndo_fix_features	= bnxt_fix_features,
	.ndo_set_features	= bnxt_set_features,
	.ndo_features_check	= bnxt_features_check,
	.ndo_tx_timeout		= bnxt_tx_timeout,
#ifdef CONFIG_BNXT_SRIOV
	.ndo_get_vf_config	= bnxt_get_vf_config,
	.ndo_set_vf_mac		= bnxt_set_vf_mac,
	.ndo_set_vf_vlan	= bnxt_set_vf_vlan,
	.ndo_set_vf_rate	= bnxt_set_vf_bw,
	.ndo_set_vf_link_state	= bnxt_set_vf_link_state,
	.ndo_set_vf_spoofchk	= bnxt_set_vf_spoofchk,
	.ndo_set_vf_trust	= bnxt_set_vf_trust,
#endif
	.ndo_setup_tc           = bnxt_setup_tc,
#ifdef CONFIG_RFS_ACCEL
	.ndo_rx_flow_steer	= bnxt_rx_flow_steer,
#endif
	.ndo_bpf		= bnxt_xdp,
	.ndo_xdp_xmit		= bnxt_xdp_xmit,
	.ndo_bridge_getlink	= bnxt_bridge_getlink,
	.ndo_bridge_setlink	= bnxt_bridge_setlink,
	.ndo_hwtstamp_get	= bnxt_hwtstamp_get,
	.ndo_hwtstamp_set	= bnxt_hwtstamp_set,
};

static const struct xdp_metadata_ops bnxt_xdp_metadata_ops = {
	.xmo_rx_hash		= bnxt_xdp_rx_hash,
};

static void bnxt_get_queue_stats_rx(struct net_device *dev, int i,
				    struct netdev_queue_stats_rx *stats)
{
	struct bnxt *bp = netdev_priv(dev);
	struct bnxt_cp_ring_info *cpr;
	u64 *sw;

	if (!bp->bnapi)
		return;

	cpr = &bp->bnapi[i]->cp_ring;
	sw = cpr->stats.sw_stats;

	stats->packets = 0;
	stats->packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts);
	stats->packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts);
	stats->packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts);

	stats->bytes = 0;
	stats->bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes);
	stats->bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes);
	stats->bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes);

	stats->alloc_fail = cpr->sw_stats->rx.rx_oom_discards;
	stats->hw_gro_packets = cpr->sw_stats->rx.rx_hw_gro_packets;
	stats->hw_gro_wire_packets = cpr->sw_stats->rx.rx_hw_gro_wire_packets;
}

static void bnxt_get_queue_stats_tx(struct net_device *dev, int i,
				    struct netdev_queue_stats_tx *stats)
{
	struct bnxt *bp = netdev_priv(dev);
	struct bnxt_napi *bnapi;
	u64 *sw;

	if (!bp->tx_ring)
		return;

	bnapi = bp->tx_ring[bp->tx_ring_map[i]].bnapi;
	sw = bnapi->cp_ring.stats.sw_stats;

	stats->packets = 0;
	stats->packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts);
	stats->packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts);
	stats->packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts);

	stats->bytes = 0;
	stats->bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes);
	stats->bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes);
	stats->bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes);
}

Annotation

Implementation Notes