drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c- Extension
.c- Size
- 15197 bytes
- Lines
- 593
- 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.
- 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/netdevice.hnet/gro.hnet/page_pool/helpers.hhinic3_hwdev.hhinic3_nic_dev.hhinic3_nic_io.hhinic3_rx.h
Detected Declarations
function hinic3_rxq_clean_statsfunction hinic3_rxq_stats_initfunction hinic3_alloc_rxqsfunction hinic3_free_rxqsfunction rx_alloc_mapped_pagefunction rq_associate_cqesfunction rq_wqe_buf_setfunction hinic3_rx_fill_buffersfunction hinic3_alloc_rx_buffersfunction hinic3_free_rx_buffersfunction hinic3_add_rx_fragfunction packaging_skbfunction hinic3_get_sge_numfunction hinic3_pull_tailfunction hinic3_rx_csumfunction hinic3_lro_set_gso_paramsfunction recv_one_pktfunction hinic3_alloc_rxqs_resfunction hinic3_free_rxqs_resfunction hinic3_configure_rxqsfunction hinic3_rx_poll
Annotated Snippet
if (rx_info->page) {
page_pool_put_full_page(rqres->page_pool,
rx_info->page, false);
rx_info->page = NULL;
}
}
}
static void hinic3_add_rx_frag(struct hinic3_rxq *rxq,
struct hinic3_rx_info *rx_info,
struct sk_buff *skb, u32 size)
{
struct page *page;
u8 *va;
page = rx_info->page;
va = (u8 *)page_address(page) + rx_info->page_offset;
net_prefetch(va);
page_pool_dma_sync_for_cpu(rxq->page_pool, page, rx_info->page_offset,
rxq->buf_len);
if (size <= HINIC3_RX_HDR_SIZE && !skb_is_nonlinear(skb)) {
memcpy(__skb_put(skb, size), va,
ALIGN(size, sizeof(long)));
page_pool_put_full_page(rxq->page_pool, page, false);
return;
}
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
rx_info->page_offset, size, rxq->buf_len);
skb_mark_for_recycle(skb);
}
static void packaging_skb(struct hinic3_rxq *rxq, struct sk_buff *skb,
u32 sge_num, u32 pkt_len)
{
struct hinic3_rx_info *rx_info;
u32 temp_pkt_len = pkt_len;
u32 temp_sge_num = sge_num;
u32 sw_ci;
u32 size;
sw_ci = rxq->cons_idx & rxq->q_mask;
while (temp_sge_num) {
rx_info = &rxq->rx_info[sw_ci];
sw_ci = (sw_ci + 1) & rxq->q_mask;
if (unlikely(temp_pkt_len > rxq->buf_len)) {
size = rxq->buf_len;
temp_pkt_len -= rxq->buf_len;
} else {
size = temp_pkt_len;
}
hinic3_add_rx_frag(rxq, rx_info, skb, size);
/* clear contents of buffer_info */
rx_info->page = NULL;
temp_sge_num--;
}
}
static u32 hinic3_get_sge_num(struct hinic3_rxq *rxq, u32 pkt_len)
{
u32 sge_num;
sge_num = pkt_len >> rxq->buf_len_shift;
sge_num += (pkt_len & (rxq->buf_len - 1)) ? 1 : 0;
return sge_num;
}
static struct sk_buff *hinic3_fetch_rx_buffer(struct hinic3_rxq *rxq,
u32 pkt_len)
{
struct sk_buff *skb;
u32 sge_num;
skb = napi_alloc_skb(&rxq->irq_cfg->napi, HINIC3_RX_HDR_SIZE);
if (unlikely(!skb))
return NULL;
sge_num = hinic3_get_sge_num(rxq, pkt_len);
net_prefetchw(skb->data);
packaging_skb(rxq, skb, sge_num, pkt_len);
rxq->cons_idx += sge_num;
rxq->delta += sge_num;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/netdevice.h`, `net/gro.h`, `net/page_pool/helpers.h`, `hinic3_hwdev.h`, `hinic3_nic_dev.h`, `hinic3_nic_io.h`.
- Detected declarations: `function hinic3_rxq_clean_stats`, `function hinic3_rxq_stats_init`, `function hinic3_alloc_rxqs`, `function hinic3_free_rxqs`, `function rx_alloc_mapped_page`, `function rq_associate_cqes`, `function rq_wqe_buf_set`, `function hinic3_rx_fill_buffers`, `function hinic3_alloc_rx_buffers`, `function hinic3_free_rx_buffers`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.