drivers/net/ethernet/mellanox/mlx5/core/en/params.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/params.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/params.c- Extension
.c- Size
- 43414 bytes
- Lines
- 1330
- 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
en/params.hen/txrx.hen/port.hen_accel/en_accel.hen_accel/ipsec.hen_accel/psp.hlinux/dim.hnet/page_pool/types.hnet/xdp_sock_drv.hnet/netdev_queues.h
Detected Declarations
function mlx5e_mpwrq_min_page_shiftfunction mlx5e_mpwrq_page_shiftfunction mlx5e_mpwrq_umr_modefunction mlx5e_mpwrq_umr_entry_sizefunction mlx5e_mpwrq_log_wqe_szfunction mlx5e_mpwrq_pages_per_wqefunction mlx5e_mpwrq_umr_wqe_szfunction mlx5e_mpwrq_umr_wqebbsfunction mlx5e_mpwrq_mtts_per_wqefunction mlx5e_mpwrq_max_num_entriesfunction mlx5e_mpwrq_max_log_rq_sizefunction mlx5e_mpwrq_max_log_rq_pktsfunction mlx5e_get_linear_rq_headroomfunction mlx5e_rx_get_linear_sz_xskfunction mlx5e_rx_get_linear_sz_skbfunction mlx5e_rx_get_linear_stride_szfunction mlx5e_mpwqe_log_pkts_per_wqefunction mlx5e_rx_is_linear_skbfunction mlx5e_verify_rx_mpwqe_stridesfunction mlx5e_verify_params_rx_mpwqe_stridesfunction mlx5e_rx_mpwqe_is_linear_skbfunction mlx5e_mpwqe_get_log_rq_sizefunction mlx5e_shampo_get_log_pkt_per_rsrvfunction mlx5e_mpwqe_get_log_stride_sizefunction mlx5e_mpwqe_get_log_num_stridesfunction mlx5e_mpwqe_get_min_wqe_bulkfunction mlx5e_get_rq_headroomfunction mlx5e_mpwrq_max_page_sizefunction mlx5e_calc_sq_stop_roomfunction mlx5e_validate_paramsfunction slow_pci_heuristicfunction mlx5e_mpwrq_validate_regularfunction mlx5e_mpwrq_validate_xskfunction mlx5e_init_rq_type_paramsfunction mlx5e_set_rq_typefunction mlx5e_build_rq_paramsfunction mlx5e_build_create_cq_paramfunction mlx5e_max_nonlinear_mtufunction mlx5e_rx_compute_wqe_bulk_paramsfunction mlx5e_build_rq_frags_infofunction mlx5e_get_rqwq_log_stridefunction mlx5e_build_common_cq_paramfunction mlx5e_shampo_get_log_cq_sizefunction mlx5e_build_rx_cq_paramfunction rq_end_pad_modefunction mlx5e_mpwqe_build_rq_paramfunction mlx5e_build_rq_paramfunction mlx5e_build_drop_rq_param
Annotated Snippet
if (byte_count > max_mtu) {
mlx5_core_err(mdev, "MTU %u is too big for non-linear legacy RQ (max %d)\n",
params->sw_mtu, max_mtu);
return -EINVAL;
}
}
i = 0;
while (buf_size < byte_count) {
int frag_size = byte_count - buf_size;
if (i == 0)
frag_size = min(frag_size, first_frag_size_max);
else if (i < MLX5E_MAX_RX_FRAGS - 1)
frag_size = min(frag_size, frag_size_max);
info->arr[i].frag_size = frag_size;
buf_size += frag_size;
if (params->xdp_prog) {
/* XDP multi buffer expects fragments of the same size. */
info->arr[i].frag_stride = frag_size_max;
} else {
if (i == 0) {
/* Ensure that headroom and tailroom are included. */
frag_size += headroom;
frag_size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
}
info->arr[i].frag_stride = roundup_pow_of_two(frag_size);
}
i++;
}
info->num_frags = i;
/* The last fragment of WQE with index 2*N may share the page with the
* first fragment of WQE with index 2*N+1 in certain cases. If WQE 2*N+1
* is not completed yet, WQE 2*N must not be allocated, as it's
* responsible for allocating a new page.
*/
if (frag_size_max == PAGE_SIZE) {
/* No WQE can start in the middle of a page. */
info->wqe_index_mask = 0;
} else {
/* PAGE_SIZEs starting from 8192 don't use 2K-sized fragments,
* because there would be more than MLX5E_MAX_RX_FRAGS of them.
*/
WARN_ON(PAGE_SIZE != 2 * DEFAULT_FRAG_SIZE);
/* Odd number of fragments allows to pack the last fragment of
* the previous WQE and the first fragment of the next WQE into
* the same page.
* As long as DEFAULT_FRAG_SIZE is 2048, and MLX5E_MAX_RX_FRAGS
* is 4, the last fragment can be bigger than the rest only if
* it's the fourth one, so WQEs consisting of 3 fragments will
* always share a page.
* When a page is shared, WQE bulk size is 2, otherwise just 1.
*/
info->wqe_index_mask = info->num_frags % 2;
}
out:
/* Bulking optimization to skip allocation until a large enough number
* of WQEs can be allocated in a row. Bulking also influences how well
* deferred page release works.
*/
mlx5e_rx_compute_wqe_bulk_params(params, info);
mlx5_core_dbg(mdev, "%s: wqe_bulk = %u, wqe_bulk_refill_unit = %u\n",
__func__, info->wqe_bulk, info->refill_unit);
info->log_num_frags = order_base_2(info->num_frags);
*xdp_frag_size = info->num_frags > 1 && params->xdp_prog ? PAGE_SIZE : 0;
return 0;
}
static u8 mlx5e_get_rqwq_log_stride(u8 wq_type, int ndsegs)
{
int sz = sizeof(struct mlx5_wqe_data_seg) * ndsegs;
switch (wq_type) {
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
sz += sizeof(struct mlx5e_rx_wqe_ll);
break;
default: /* MLX5_WQ_TYPE_CYCLIC */
sz += sizeof(struct mlx5e_rx_wqe_cyc);
}
Annotation
- Immediate include surface: `en/params.h`, `en/txrx.h`, `en/port.h`, `en_accel/en_accel.h`, `en_accel/ipsec.h`, `en_accel/psp.h`, `linux/dim.h`, `net/page_pool/types.h`.
- Detected declarations: `function mlx5e_mpwrq_min_page_shift`, `function mlx5e_mpwrq_page_shift`, `function mlx5e_mpwrq_umr_mode`, `function mlx5e_mpwrq_umr_entry_size`, `function mlx5e_mpwrq_log_wqe_sz`, `function mlx5e_mpwrq_pages_per_wqe`, `function mlx5e_mpwrq_umr_wqe_sz`, `function mlx5e_mpwrq_umr_wqebbs`, `function mlx5e_mpwrq_mtts_per_wqe`, `function mlx5e_mpwrq_max_num_entries`.
- 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.