drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c- Extension
.c- Size
- 6708 bytes
- Lines
- 273
- 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.
- 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
rqt.hlinux/mlx5/transobj.h
Detected Declarations
function verify_num_vhca_idsfunction rqt_verify_vhca_idsfunction mlx5e_rss_params_indir_init_uniformfunction fill_rqn_listfunction mlx5e_rqt_initfunction mlx5e_rqt_init_directfunction mlx5e_bits_invertfunction mlx5e_calc_indir_rqnsfunction mlx5e_rqt_init_indirfunction mlx5e_rqt_sizefunction mlx5e_rqt_destroyfunction mlx5e_rqt_redirectfunction mlx5e_rqt_redirect_directfunction mlx5e_rqt_redirect_indir
Annotated Snippet
if (vhca_ids[j] == vhca_ids[i]) {
is_unique = false;
break;
}
}
if (is_unique)
unique_count++;
}
/* Verify that number of unique vhca_ids doesn't exceed
* max_num_vhca_id
*/
return unique_count <= max_num_vhca_id;
}
static bool rqt_verify_vhca_ids(struct mlx5_core_dev *mdev, u32 *vhca_ids,
unsigned int size)
{
if (!vhca_ids)
return true;
if (!MLX5_CAP_GEN(mdev, cross_vhca_rqt))
return false;
if (!verify_num_vhca_ids(mdev, vhca_ids, size))
return false;
return true;
}
void mlx5e_rss_params_indir_init_uniform(struct mlx5e_rss_params_indir *indir,
unsigned int num_channels)
{
unsigned int i;
for (i = 0; i < indir->actual_table_size; i++)
indir->table[i] = i % num_channels;
}
static void fill_rqn_list(void *rqtc, u32 *rqns, u32 *vhca_ids, unsigned int size)
{
unsigned int i;
if (vhca_ids) {
MLX5_SET(rqtc, rqtc, rq_vhca_id_format, 1);
for (i = 0; i < size; i++) {
MLX5_SET(rqtc, rqtc, rq_vhca[i].rq_num, rqns[i]);
MLX5_SET(rqtc, rqtc, rq_vhca[i].rq_vhca_id, vhca_ids[i]);
}
} else {
for (i = 0; i < size; i++)
MLX5_SET(rqtc, rqtc, rq_num[i], rqns[i]);
}
}
static int mlx5e_rqt_init(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev,
u16 max_size, u32 *init_rqns, u32 *init_vhca_ids, u16 init_size)
{
int entry_sz;
void *rqtc;
int inlen;
int err;
u32 *in;
if (!rqt_verify_vhca_ids(mdev, init_vhca_ids, init_size))
return -EOPNOTSUPP;
rqt->mdev = mdev;
rqt->size = max_size;
entry_sz = init_vhca_ids ? MLX5_ST_SZ_BYTES(rq_vhca) : MLX5_ST_SZ_BYTES(rq_num);
inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + entry_sz * init_size;
in = kvzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
rqtc = MLX5_ADDR_OF(create_rqt_in, in, rqt_context);
MLX5_SET(rqtc, rqtc, rqt_max_size, rqt->size);
MLX5_SET(rqtc, rqtc, rqt_actual_size, init_size);
fill_rqn_list(rqtc, init_rqns, init_vhca_ids, init_size);
err = mlx5_core_create_rqt(rqt->mdev, in, inlen, &rqt->rqtn);
kvfree(in);
return err;
}
int mlx5e_rqt_init_direct(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev,
bool indir_enabled, u32 init_rqn, u32 indir_table_size)
{
Annotation
- Immediate include surface: `rqt.h`, `linux/mlx5/transobj.h`.
- Detected declarations: `function verify_num_vhca_ids`, `function rqt_verify_vhca_ids`, `function mlx5e_rss_params_indir_init_uniform`, `function fill_rqn_list`, `function mlx5e_rqt_init`, `function mlx5e_rqt_init_direct`, `function mlx5e_bits_invert`, `function mlx5e_calc_indir_rqns`, `function mlx5e_rqt_init_indir`, `function mlx5e_rqt_size`.
- 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.