drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c- Extension
.c- Size
- 139339 bytes
- Lines
- 5136
- 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.
- 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
linux/etherdevice.hlinux/if_vlan.hlinux/interrupt.hlinux/ip.hlinux/crash_dump.hnet/tcp.hnet/gro.hnet/ipv6.hnet/ip6_checksum.hlinux/prefetch.hbnx2x_cmn.hbnx2x_init.hbnx2x_sp.h
Detected Declarations
function bnx2x_add_all_napi_cnicfunction bnx2x_add_all_napifunction bnx2x_calc_num_queuesfunction bnx2x_move_fpfunction bnx2x_fill_fw_strfunction bnx2x_shrink_eth_fpfunction bnx2x_free_tx_pktfunction bnx2x_tx_intfunction bnx2x_update_last_max_sgefunction bnx2x_update_sge_prodfunction CQEfunction bnx2x_tpa_startfunction bnx2x_set_gro_paramsfunction bnx2x_alloc_rx_sgefunction bnx2x_fill_frag_skbfunction bnx2x_build_skbfunction bnx2x_frag_freefunction bnx2x_gro_ip_csumfunction bnx2x_gro_ipv6_csumfunction bnx2x_gro_csumfunction bnx2x_gro_receivefunction bnx2x_tpa_stopfunction bnx2x_alloc_rx_datafunction bnx2x_csum_validatefunction bnx2x_rx_intfunction bnx2x_msix_fp_intfunction bnx2x_acquire_phy_lockfunction bnx2x_release_phy_lockfunction bnx2x_get_mf_speedfunction bnx2x_fill_report_datafunction __bnx2x_link_reportfunction __bnx2x_link_reportfunction bnx2x_set_next_page_sglfunction bnx2x_free_tpa_poolfunction bnx2x_init_rx_rings_cnicfunction for_each_rx_queue_cnicfunction bnx2x_init_rx_ringsfunction for_each_eth_queuefunction bnx2x_free_tx_skbs_queuefunction for_each_cos_in_tx_queuefunction bnx2x_free_tx_skbs_cnicfunction for_each_tx_queue_cnicfunction bnx2x_free_tx_skbsfunction for_each_eth_queuefunction bnx2x_free_rx_bdsfunction bnx2x_free_rx_skbs_cnicfunction for_each_rx_queue_cnicfunction bnx2x_free_rx_skbs
Annotated Snippet
if (unlikely(err)) {
bnx2x_fp_qstats(bp, fp)->rx_skb_alloc_failed++;
return err;
}
dma_unmap_page(&bp->pdev->dev,
dma_unmap_addr(&old_rx_pg, mapping),
SGE_PAGE_SIZE, DMA_FROM_DEVICE);
/* Add one frag and update the appropriate fields in the skb */
if (fp->mode == TPA_MODE_LRO)
skb_fill_page_desc(skb, j, old_rx_pg.page,
old_rx_pg.offset, frag_len);
else { /* GRO */
int rem;
int offset = 0;
for (rem = frag_len; rem > 0; rem -= gro_size) {
int len = rem > gro_size ? gro_size : rem;
skb_fill_page_desc(skb, frag_id++,
old_rx_pg.page,
old_rx_pg.offset + offset,
len);
if (offset)
get_page(old_rx_pg.page);
offset += len;
}
}
skb->data_len += frag_len;
skb->truesize += SGE_PAGES;
skb->len += frag_len;
frag_size -= frag_len;
}
return 0;
}
static struct sk_buff *
bnx2x_build_skb(const struct bnx2x_fastpath *fp, void *data)
{
struct sk_buff *skb;
if (fp->rx_frag_size)
skb = build_skb(data, fp->rx_frag_size);
else
skb = slab_build_skb(data);
return skb;
}
static void bnx2x_frag_free(const struct bnx2x_fastpath *fp, void *data)
{
if (fp->rx_frag_size)
skb_free_frag(data);
else
kfree(data);
}
static void *bnx2x_frag_alloc(const struct bnx2x_fastpath *fp, gfp_t gfp_mask)
{
if (fp->rx_frag_size) {
/* GFP_KERNEL allocations are used only during initialization */
if (unlikely(gfpflags_allow_blocking(gfp_mask)))
return (void *)__get_free_page(gfp_mask);
return napi_alloc_frag(fp->rx_frag_size);
}
return kmalloc(fp->rx_buf_size + NET_SKB_PAD, gfp_mask);
}
#ifdef CONFIG_INET
static void bnx2x_gro_ip_csum(struct bnx2x *bp, struct sk_buff *skb)
{
const struct iphdr *iph = ip_hdr(skb);
struct tcphdr *th;
skb_set_transport_header(skb, sizeof(struct iphdr));
th = tcp_hdr(skb);
th->check = ~tcp_v4_check(skb->len - skb_transport_offset(skb),
iph->saddr, iph->daddr, 0);
}
static void bnx2x_gro_ipv6_csum(struct bnx2x *bp, struct sk_buff *skb)
{
struct ipv6hdr *iph = ipv6_hdr(skb);
struct tcphdr *th;
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
th = tcp_hdr(skb);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/interrupt.h`, `linux/ip.h`, `linux/crash_dump.h`, `net/tcp.h`, `net/gro.h`, `net/ipv6.h`.
- Detected declarations: `function bnx2x_add_all_napi_cnic`, `function bnx2x_add_all_napi`, `function bnx2x_calc_num_queues`, `function bnx2x_move_fp`, `function bnx2x_fill_fw_str`, `function bnx2x_shrink_eth_fp`, `function bnx2x_free_tx_pkt`, `function bnx2x_tx_int`, `function bnx2x_update_last_max_sge`, `function bnx2x_update_sge_prod`.
- 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.