drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c- Extension
.c- Size
- 75578 bytes
- Lines
- 2738
- 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/ip.hlinux/ipv6.hlinux/tcp.hlinux/bitmap.hlinux/filter.hnet/ip6_checksum.hnet/page_pool/helpers.hnet/inet_ecn.hnet/gro.hnet/udp.hnet/tcp.hnet/xdp_sock_drv.hen.hen/txrx.hen_tc.heswitch.hen_rep.hen/rep/tc.hipoib/ipoib.hen_accel/ipsec.hen_accel/macsec.hen_accel/psp_rxtx.hen_accel/ipsec_rxtx.hen_accel/ktls_txrx.hen/xdp.hen/xsk/rx.hen/health.hen/params.hdevlink.hen/devlink.h
Detected Declarations
function mlx5e_read_cqe_slotfunction mlx5e_read_enhanced_title_slotfunction mlx5e_read_title_slotfunction mlx5e_read_mini_arr_slotfunction mlx5e_cqes_update_ownerfunction mlx5e_decompress_cqefunction mlx5e_decompress_cqe_no_hashfunction mlx5e_decompress_enhanced_cqefunction mlx5e_decompress_cqes_contfunction mlx5e_decompress_cqes_startfunction mlx5e_page_alloc_fragmentedfunction mlx5e_page_release_fragmentedfunction mlx5e_mpwqe_linear_page_refillfunction mlx5e_get_rx_fragfunction mlx5e_frag_can_releasefunction mlx5e_put_rx_fragfunction mlx5e_alloc_rx_wqefunction mlx5e_free_rx_wqefunction mlx5e_xsk_free_rx_wqefunction mlx5e_dealloc_rx_wqefunction mlx5e_xsk_free_rx_wqesfunction mlx5e_free_rx_wqesfunction mlx5e_alloc_rx_wqesfunction mlx5e_refill_rx_wqesfunction mlx5e_add_skb_shared_info_fragfunction mlx5e_add_skb_fragfunction mlx5e_copy_skb_headerfunction mlx5e_free_rx_mpwqefunction mlx5e_post_rx_mpwqefunction mlx5e_alloc_rx_mpwqefunction mlx5e_build_umr_wqefunction mlx5e_dealloc_rx_mpwqefunction mlx5e_mpwqe_dealloc_linear_pagefunction mlx5e_post_rx_wqesfunction mlx5e_free_icosq_descsfunction mlx5e_poll_ico_cqfunction mlx5e_reclaim_mpwqe_pagesfunction mlx5e_post_rx_mpwqesfunction mlx5e_lro_update_tcp_hdrfunction mlx5e_lro_update_hdrfunction mlx5e_shampo_update_ipv4_udp_hdrfunction mlx5e_shampo_update_ipv6_udp_hdrfunction mlx5e_shampo_get_hd_buf_infofunction mlx5e_shampo_update_fin_psh_flagsfunction mlx5e_shampo_update_ipv4_tcp_hdrfunction mlx5e_shampo_update_ipv6_tcp_hdrfunction mlx5e_shampo_update_hdrfunction mlx5e_skb_set_hash
Annotated Snippet
if (no_xdp_xmit || !test_bit(i, wi->skip_release_bitmap)) {
struct mlx5e_frag_page *frag_page;
frag_page = &wi->alloc_units.frag_pages[i];
mlx5e_page_release_fragmented(rq->page_pool,
frag_page);
}
}
}
}
static void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq, u8 n)
{
struct mlx5_wq_ll *wq = &rq->mpwqe.wq;
do {
u16 next_wqe_index = mlx5_wq_ll_get_wqe_next_ix(wq, wq->head);
mlx5_wq_ll_push(wq, next_wqe_index);
} while (--n);
/* ensure wqes are visible to device before updating doorbell record */
dma_wmb();
mlx5_wq_ll_update_db_record(wq);
}
static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
{
struct mlx5e_mpw_info *wi = mlx5e_get_mpw_info(rq, ix);
struct mlx5e_icosq *sq = rq->icosq;
struct mlx5e_frag_page *frag_page;
struct mlx5_wq_cyc *wq = &sq->wq;
struct mlx5e_umr_wqe *umr_wqe;
u32 offset; /* 17-bit value with MTT. */
bool sync_locked;
u16 pi;
int err;
int i;
sync_locked = mlx5e_icosq_sync_lock(sq);
pi = mlx5e_icosq_get_next_pi(sq, rq->mpwqe.umr_wqebbs);
umr_wqe = mlx5_wq_cyc_get_wqe(wq, pi);
memcpy(umr_wqe, &rq->mpwqe.umr_wqe, sizeof(struct mlx5e_umr_wqe));
frag_page = &wi->alloc_units.frag_pages[0];
for (i = 0; i < rq->mpwqe.pages_per_wqe; i++, frag_page++) {
dma_addr_t addr;
err = mlx5e_page_alloc_fragmented(rq->page_pool, frag_page);
if (unlikely(err))
goto err_unmap;
addr = page_pool_get_dma_addr_netmem(frag_page->netmem);
umr_wqe->inline_mtts[i] = (struct mlx5_mtt) {
.ptag = cpu_to_be64(addr | MLX5_EN_WR),
};
}
/* Pad if needed, in case the value set to ucseg->xlt_octowords
* in mlx5e_build_umr_wqe() needed alignment.
*/
if (rq->mpwqe.pages_per_wqe & (MLX5_UMR_MTT_NUM_ENTRIES_ALIGNMENT - 1)) {
int pad = ALIGN(rq->mpwqe.pages_per_wqe, MLX5_UMR_MTT_NUM_ENTRIES_ALIGNMENT) -
rq->mpwqe.pages_per_wqe;
memset(&umr_wqe->inline_mtts[rq->mpwqe.pages_per_wqe], 0,
sizeof(*umr_wqe->inline_mtts) * pad);
}
bitmap_zero(wi->skip_release_bitmap, rq->mpwqe.pages_per_wqe);
wi->consumed_strides = 0;
umr_wqe->hdr.ctrl.opmod_idx_opcode =
cpu_to_be32((sq->pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) |
MLX5_OPCODE_UMR);
offset = (ix * rq->mpwqe.mtts_per_wqe) * sizeof(struct mlx5_mtt) / MLX5_OCTWORD;
umr_wqe->hdr.uctrl.xlt_offset = cpu_to_be16(offset);
sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) {
.wqe_type = MLX5E_ICOSQ_WQE_UMR_RX,
.num_wqebbs = rq->mpwqe.umr_wqebbs,
.umr.rq = rq,
};
sq->pc += rq->mpwqe.umr_wqebbs;
mlx5e_icosq_sync_unlock(sq, sync_locked);
Annotation
- Immediate include surface: `linux/ip.h`, `linux/ipv6.h`, `linux/tcp.h`, `linux/bitmap.h`, `linux/filter.h`, `net/ip6_checksum.h`, `net/page_pool/helpers.h`, `net/inet_ecn.h`.
- Detected declarations: `function mlx5e_read_cqe_slot`, `function mlx5e_read_enhanced_title_slot`, `function mlx5e_read_title_slot`, `function mlx5e_read_mini_arr_slot`, `function mlx5e_cqes_update_owner`, `function mlx5e_decompress_cqe`, `function mlx5e_decompress_cqe_no_hash`, `function mlx5e_decompress_enhanced_cqe`, `function mlx5e_decompress_cqes_cont`, `function mlx5e_decompress_cqes_start`.
- 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.