drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c- Extension
.c- Size
- 84396 bytes
- Lines
- 3480
- 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/byteorder.hlinux/dma-mapping.hlinux/dmapool.hlinux/delay.hlinux/errno.hlinux/kernel.hlinux/list.hlinux/pci.hlinux/netdevice.hnet/netdev_lock.hnet/netdev_queues.hnet/netdev_rx_queue.hlinux/etherdevice.hlinux/if.hnet/ip.hlinux/skbuff.hnet/page_pool/helpers.hbnge.hbnge_hwrm_lib.hbnge_ethtool.hbnge_rmem.hbnge_txrx.h
Detected Declarations
function bnge_free_stats_memfunction bnge_alloc_stats_memfunction bnge_free_ring_statsfunction bnge_fill_masksfunction bnge_copy_hw_masksfunction bnge_init_statsfunction bnge_free_port_ext_statsfunction bnge_free_port_statsfunction bnge_alloc_ring_statsfunction bnge_alloc_port_ext_statsfunction bnge_alloc_port_statsfunction __bnge_queue_sp_workfunction bnge_queue_sp_workfunction bnge_timerfunction bnge_add_one_ctrfunction __bnge_accumulate_statsfunction bnge_accumulate_statsfunction bnge_accumulate_all_statsfunction bnge_sp_taskfunction bnge_free_nq_desc_arrfunction bnge_free_cp_desc_arrfunction bnge_alloc_nq_desc_arrfunction bnge_alloc_cp_desc_arrfunction bnge_free_nq_arraysfunction bnge_alloc_nq_arraysfunction bnge_free_nq_treefunction alloc_one_cp_ringfunction bnge_alloc_nq_treefunction bnge_separate_head_poolfunction bnge_free_one_rx_ring_bufsfunction bnge_free_one_agg_ring_bufsfunction bnge_free_one_tpa_info_datafunction bnge_free_one_rx_ring_pair_bufsfunction bnge_free_rx_ring_pair_bufsfunction bnge_free_tx_skbsfunction bnge_free_all_rings_bufsfunction bnge_free_tpa_infofunction bnge_alloc_tpa_infofunction bnge_free_rx_ringsfunction bnge_alloc_rx_page_poolfunction bnge_enable_rx_page_poolfunction bnge_alloc_rx_agg_bmapfunction bnge_alloc_rx_ringsfunction bnge_free_tx_ringsfunction bnge_alloc_tx_ringsfunction bnge_free_vnic_attributesfunction bnge_alloc_vnic_attributesfunction bnge_alloc_vnics
Annotated Snippet
static const struct net_device_ops bnge_netdev_ops = {
.ndo_open = bnge_open,
.ndo_stop = bnge_close,
.ndo_start_xmit = bnge_start_xmit,
.ndo_get_stats64 = bnge_get_stats64,
.ndo_features_check = bnge_features_check,
};
static void bnge_init_mac_addr(struct bnge_dev *bd)
{
eth_hw_addr_set(bd->netdev, bd->pf.mac_addr);
}
static void bnge_set_tpa_flags(struct bnge_dev *bd)
{
struct bnge_net *bn = netdev_priv(bd->netdev);
bn->priv_flags &= ~BNGE_NET_EN_TPA;
if (bd->netdev->features & NETIF_F_LRO)
bn->priv_flags |= BNGE_NET_EN_LRO;
else if (bd->netdev->features & NETIF_F_GRO_HW)
bn->priv_flags |= BNGE_NET_EN_GRO;
}
static void bnge_init_l2_fltr_tbl(struct bnge_net *bn)
{
int i;
for (i = 0; i < BNGE_L2_FLTR_HASH_SIZE; i++)
INIT_HLIST_HEAD(&bn->l2_fltr_hash_tbl[i]);
get_random_bytes(&bn->hash_seed, sizeof(bn->hash_seed));
}
void bnge_set_ring_params(struct bnge_dev *bd)
{
struct bnge_net *bn = netdev_priv(bd->netdev);
u32 ring_size, rx_size, rx_space, max_rx_cmpl;
u32 agg_factor = 0, agg_ring_size = 0;
/* 8 for CRC and VLAN */
rx_size = SKB_DATA_ALIGN(bn->netdev->mtu + ETH_HLEN + NET_IP_ALIGN + 8);
rx_space = rx_size + ALIGN(NET_SKB_PAD, 8) +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
ring_size = bn->rx_ring_size;
bn->rx_agg_ring_size = 0;
bn->rx_agg_nr_pages = 0;
if (bn->priv_flags & BNGE_NET_EN_TPA)
agg_factor = min_t(u32, 4, 65536 / BNGE_RX_PAGE_SIZE);
bn->priv_flags &= ~BNGE_NET_EN_JUMBO;
if (rx_space > PAGE_SIZE) {
u32 jumbo_factor;
bn->priv_flags |= BNGE_NET_EN_JUMBO;
jumbo_factor = PAGE_ALIGN(bn->netdev->mtu - 40) >> PAGE_SHIFT;
if (jumbo_factor > agg_factor)
agg_factor = jumbo_factor;
}
if (agg_factor) {
if (ring_size > BNGE_MAX_RX_DESC_CNT_JUM_ENA) {
ring_size = BNGE_MAX_RX_DESC_CNT_JUM_ENA;
netdev_warn(bn->netdev, "RX ring size reduced from %d to %d due to jumbo ring\n",
bn->rx_ring_size, ring_size);
bn->rx_ring_size = ring_size;
}
agg_ring_size = ring_size * agg_factor;
bn->rx_agg_nr_pages = bnge_adjust_pow_two(agg_ring_size,
RX_DESC_CNT);
if (bn->rx_agg_nr_pages > MAX_RX_AGG_PAGES) {
u32 tmp = agg_ring_size;
bn->rx_agg_nr_pages = MAX_RX_AGG_PAGES;
agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1;
netdev_warn(bn->netdev, "RX agg ring size %d reduced to %d.\n",
tmp, agg_ring_size);
}
bn->rx_agg_ring_size = agg_ring_size;
bn->rx_agg_ring_mask = (bn->rx_agg_nr_pages * RX_DESC_CNT) - 1;
rx_size = max3(BNGE_DEFAULT_RX_COPYBREAK,
bn->rx_copybreak,
bn->netdev->cfg_pending->hds_thresh);
rx_size = SKB_DATA_ALIGN(rx_size + NET_IP_ALIGN);
rx_space = rx_size + NET_SKB_PAD +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
Annotation
- Immediate include surface: `asm/byteorder.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/delay.h`, `linux/errno.h`, `linux/kernel.h`, `linux/list.h`, `linux/pci.h`.
- Detected declarations: `function bnge_free_stats_mem`, `function bnge_alloc_stats_mem`, `function bnge_free_ring_stats`, `function bnge_fill_masks`, `function bnge_copy_hw_masks`, `function bnge_init_stats`, `function bnge_free_port_ext_stats`, `function bnge_free_port_stats`, `function bnge_alloc_ring_stats`, `function bnge_alloc_port_ext_stats`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.