drivers/net/ethernet/broadcom/bnge/bnge_txrx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_txrx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_txrx.c- Extension
.c- Size
- 43858 bytes
- Lines
- 1670
- 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.
- 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.
- 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.
- 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.hlinux/etherdevice.hlinux/if.hnet/ip.hnet/tcp.hnet/gro.hlinux/skbuff.hnet/page_pool/helpers.hlinux/if_vlan.hnet/udp_tunnel.hnet/dst_metadata.hnet/netdev_queues.hbnge.hbnge_hwrm.hbnge_hwrm_lib.hbnge_netdev.hbnge_rmem.hbnge_txrx.h
Detected Declarations
function bnge_msixfunction bnge_reuse_rx_agg_bufsfunction bnge_agg_bufs_validfunction bnge_discard_rxfunction __bnge_rx_agg_netmemsfunction bnge_sched_reset_rxrfunction bnge_sched_reset_txrfunction bnge_tpa_alloc_agg_idxfunction bnge_free_agg_idxfunction bnge_lookup_agg_idxfunction bnge_tpa_metadatafunction bnge_tpa_metadata_v2function bnge_tpa_startfunction bnge_abort_tpafunction bnge_tpa_aggfunction bnge_reuse_rx_datafunction bnge_deliver_skbfunction bnge_gro_tunnelfunction bnge_rss_ext_opfunction bnge_rx_pktfunction bnge_force_rx_discardfunction __bnge_tx_intfunction bnge_tx_intfunction bnge_for_each_napi_txfunction __bnge_poll_work_donefunction bnge_async_event_processfunction bnge_hwrm_update_tokenfunction bnge_hwrm_handlerfunction __bnge_poll_workfunction __bnge_poll_cqs_donefunction __bnge_poll_cqsfunction bnge_napi_pollfunction bnge_xmit_get_cfa_actionfunction bnge_txr_db_kickfunction bnge_get_gso_hdr_lenfunction bnge_start_xmitfunction bnge_features_check
Annotated Snippet
if (bnge_alloc_rx_netmem(bn, rxr, prod, GFP_ATOMIC) != 0) {
skb->len -= frag_len;
skb->data_len -= frag_len;
skb->truesize -= BNGE_RX_PAGE_SIZE;
--shinfo->nr_frags;
cons_rx_buf->netmem = netmem;
/* Update prod since possibly some netmems have been
* allocated already.
*/
rxr->rx_agg_prod = prod;
bnge_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa);
return 0;
}
page_pool_dma_sync_netmem_for_cpu(rxr->page_pool, netmem, 0,
BNGE_RX_PAGE_SIZE);
total_frag_len += frag_len;
prod = NEXT_RX_AGG(prod);
}
rxr->rx_agg_prod = prod;
return total_frag_len;
}
static struct sk_buff *bnge_rx_agg_netmems_skb(struct bnge_net *bn,
struct bnge_cp_ring_info *cpr,
struct sk_buff *skb, u16 idx,
u32 agg_bufs, bool tpa)
{
u32 total_frag_len;
total_frag_len = __bnge_rx_agg_netmems(bn, cpr, idx, agg_bufs,
tpa, skb);
if (!total_frag_len) {
skb_mark_for_recycle(skb);
dev_kfree_skb(skb);
return NULL;
}
return skb;
}
static void bnge_sched_reset_rxr(struct bnge_net *bn,
struct bnge_rx_ring_info *rxr)
{
if (!rxr->bnapi->in_reset) {
rxr->bnapi->in_reset = true;
/* TODO: Initiate reset task */
}
rxr->rx_next_cons = 0xffff;
}
static void bnge_sched_reset_txr(struct bnge_net *bn,
struct bnge_tx_ring_info *txr,
u16 curr)
{
struct bnge_napi *bnapi = txr->bnapi;
if (bnapi->tx_fault)
return;
netdev_err(bn->netdev, "Invalid Tx completion (ring:%d tx_hw_cons:%u cons:%u prod:%u curr:%u)",
txr->txq_index, txr->tx_hw_cons,
txr->tx_cons, txr->tx_prod, curr);
WARN_ON_ONCE(1);
bnapi->tx_fault = 1;
/* TODO: Initiate reset task */
}
static u16 bnge_tpa_alloc_agg_idx(struct bnge_rx_ring_info *rxr, u16 agg_id)
{
struct bnge_tpa_idx_map *map = rxr->rx_tpa_idx_map;
u16 idx = agg_id & MAX_TPA_MASK;
if (test_bit(idx, map->agg_idx_bmap)) {
idx = find_first_zero_bit(map->agg_idx_bmap, MAX_TPA);
if (idx >= MAX_TPA)
return INVALID_HW_RING_ID;
}
__set_bit(idx, map->agg_idx_bmap);
map->agg_id_tbl[agg_id] = idx;
return idx;
}
static void bnge_free_agg_idx(struct bnge_rx_ring_info *rxr, u16 idx)
{
struct bnge_tpa_idx_map *map = rxr->rx_tpa_idx_map;
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_msix`, `function bnge_reuse_rx_agg_bufs`, `function bnge_agg_bufs_valid`, `function bnge_discard_rx`, `function __bnge_rx_agg_netmems`, `function bnge_sched_reset_rxr`, `function bnge_sched_reset_txr`, `function bnge_tpa_alloc_agg_idx`, `function bnge_free_agg_idx`, `function bnge_lookup_agg_idx`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.