drivers/net/ethernet/intel/i40e/i40e_xsk.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/i40e/i40e_xsk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/i40e/i40e_xsk.c- Extension
.c- Size
- 19704 bytes
- Lines
- 791
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf_trace.hlinux/unroll.hnet/xdp_sock_drv.hi40e_txrx_common.hi40e_xsk.h
Detected Declarations
function i40e_clear_rx_bi_zcfunction i40e_realloc_rx_xdp_bifunction i40e_realloc_rx_bi_zcfunction for_each_set_bitfunction i40e_xsk_pool_enablefunction i40e_xsk_pool_disablefunction i40e_xsk_pool_setupfunction i40e_run_xdp_zcfunction i40e_alloc_rx_buffers_zcfunction i40e_handle_xdp_result_zcfunction i40e_clean_rx_irq_zcfunction i40e_xmit_pktfunction i40e_xmit_pkt_batchfunction i40e_fill_tx_hw_ringfunction i40e_set_rs_bitfunction i40e_xmit_zcfunction i40e_clean_xdp_tx_bufferfunction i40e_clean_xdp_tx_irqfunction i40e_xsk_wakeupfunction i40e_xsk_clean_rx_ringfunction i40e_xsk_clean_tx_ringfunction i40e_xsk_any_rx_ring_enabled
Annotated Snippet
if (!page) {
dev_kfree_skb(skb);
return NULL;
}
addr = page_to_virt(page);
memcpy(addr, skb_frag_page(frag), skb_frag_size(frag));
__skb_fill_page_desc_noacc(skinfo, skinfo->nr_frags++,
addr, 0, skb_frag_size(frag));
}
out:
xsk_buff_free(xdp);
return skb;
}
static void i40e_handle_xdp_result_zc(struct i40e_ring *rx_ring,
struct xdp_buff *xdp_buff,
union i40e_rx_desc *rx_desc,
unsigned int *rx_packets,
unsigned int *rx_bytes,
unsigned int xdp_res,
bool *failure)
{
struct sk_buff *skb;
*rx_packets = 1;
*rx_bytes = xdp_get_buff_len(xdp_buff);
if (likely(xdp_res == I40E_XDP_REDIR) || xdp_res == I40E_XDP_TX)
return;
if (xdp_res == I40E_XDP_EXIT) {
*failure = true;
return;
}
if (xdp_res == I40E_XDP_CONSUMED) {
xsk_buff_free(xdp_buff);
return;
}
if (xdp_res == I40E_XDP_PASS) {
/* NB! We are not checking for errors using
* i40e_test_staterr with
* BIT(I40E_RXD_QW1_ERROR_SHIFT). This is due to that
* SBP is *not* set in PRT_SBPVSI (default not set).
*/
skb = i40e_construct_skb_zc(rx_ring, xdp_buff);
if (!skb) {
rx_ring->rx_stats.alloc_buff_failed++;
*rx_packets = 0;
*rx_bytes = 0;
return;
}
if (eth_skb_pad(skb)) {
*rx_packets = 0;
*rx_bytes = 0;
return;
}
i40e_process_skb_fields(rx_ring, rx_desc, skb);
napi_gro_receive(&rx_ring->q_vector->napi, skb);
return;
}
/* Should never get here, as all valid cases have been handled already.
*/
WARN_ON_ONCE(1);
}
/**
* i40e_clean_rx_irq_zc - Consumes Rx packets from the hardware ring
* @rx_ring: Rx ring
* @budget: NAPI budget
*
* Returns amount of work completed
**/
int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
{
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
u16 next_to_process = rx_ring->next_to_process;
u16 next_to_clean = rx_ring->next_to_clean;
unsigned int xdp_res, xdp_xmit = 0;
struct xdp_buff *first = NULL;
u32 count = rx_ring->count;
struct bpf_prog *xdp_prog;
u32 entries_to_alloc;
bool failure = false;
Annotation
- Immediate include surface: `linux/bpf_trace.h`, `linux/unroll.h`, `net/xdp_sock_drv.h`, `i40e_txrx_common.h`, `i40e_xsk.h`.
- Detected declarations: `function i40e_clear_rx_bi_zc`, `function i40e_realloc_rx_xdp_bi`, `function i40e_realloc_rx_bi_zc`, `function for_each_set_bit`, `function i40e_xsk_pool_enable`, `function i40e_xsk_pool_disable`, `function i40e_xsk_pool_setup`, `function i40e_run_xdp_zc`, `function i40e_alloc_rx_buffers_zc`, `function i40e_handle_xdp_result_zc`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.