drivers/net/ethernet/mellanox/mlx5/core/en/rss.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/rss.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/rss.c- Extension
.c- Size
- 18114 bytes
- Lines
- 743
- 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
linux/ethtool.hrss.h
Detected Declarations
struct mlx5e_rssfunction mlx5e_rss_get_default_tt_configfunction mlx5e_rss_get_inner_ft_supportfunction mlx5e_rss_set_indir_actual_sizefunction ethtool_rxfh_ctxs_resizefunction mlx5e_rss_indir_resizefunction mlx5e_rss_params_indir_initfunction mlx5e_rss_params_indir_cleanupfunction mlx5e_rss_copyfunction mlx5e_rss_params_initfunction mlx5e_rss_get_tt_configfunction mlx5e_rss_create_tirfunction mlx5e_rss_destroy_tirfunction mlx5e_rss_create_tirsfunction mlx5e_rss_destroy_tirsfunction mlx5e_rss_update_tirfunction mlx5e_rss_update_tirsfunction mlx5e_rss_init_no_tirsfunction mlx5e_rss_initfunction mlx5e_rss_cleanupfunction mlx5e_rss_refcnt_incfunction mlx5e_rss_refcnt_decfunction mlx5e_rss_refcnt_readfunction mlx5e_rss_get_tirnfunction mlx5e_rss_get_rqtnfunction mlx5e_rss_valid_tirfunction mlx5e_rss_obtain_tirnfunction mlx5e_rss_applyfunction mlx5e_rss_enablefunction mlx5e_rss_disablefunction mlx5e_rss_packet_merge_set_paramfunction mlx5e_rss_get_rxfhfunction mlx5e_rss_set_rxfhfunction mlx5e_rss_get_hashfunction mlx5e_rss_get_hash_fieldsfunction mlx5e_rss_set_hash_fieldsfunction mlx5e_rss_set_indir_uniform
Annotated Snippet
struct mlx5e_rss {
struct mlx5e_rss_params_hash hash;
struct mlx5e_rss_params_indir indir;
u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_tir *tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_tir *inner_tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_rqt rqt;
struct mlx5_core_dev *mdev; /* primary */
struct mlx5e_rss_params params;
bool enabled;
refcount_t refcnt;
};
bool mlx5e_rss_get_inner_ft_support(struct mlx5e_rss *rss)
{
return rss->params.inner_ft_support;
}
u32 *mlx5e_rss_get_indir_table(struct mlx5e_rss *rss)
{
return rss->indir.table;
}
void mlx5e_rss_set_indir_actual_size(struct mlx5e_rss *rss, u32 size)
{
rss->indir.actual_table_size = size;
}
/* Handles non-default contexts, replicate existing pattern into new entries,
* matching what ethtool_rxfh_ctxs_resize() does.
*/
void mlx5e_rss_ctx_resize(struct mlx5e_rss *rss, u32 new_size)
{
u32 old_size = rss->indir.actual_table_size;
u32 i;
for (i = old_size; i < new_size; i++)
rss->indir.table[i] = rss->indir.table[i % old_size];
}
void mlx5e_rss_indir_resize(struct mlx5e_rss *rss, struct net_device *netdev,
u32 new_size)
{
ethtool_rxfh_indir_resize(netdev, rss->indir.table,
rss->indir.actual_table_size, new_size);
}
int mlx5e_rss_params_indir_init(struct mlx5e_rss_params_indir *indir,
u32 actual_table_size, u32 max_table_size)
{
indir->table = kvmalloc_objs(*indir->table, max_table_size);
if (!indir->table)
return -ENOMEM;
indir->max_table_size = max_table_size;
indir->actual_table_size = actual_table_size;
return 0;
}
void mlx5e_rss_params_indir_cleanup(struct mlx5e_rss_params_indir *indir)
{
kvfree(indir->table);
}
static int mlx5e_rss_copy(struct mlx5e_rss *to, const struct mlx5e_rss *from)
{
u32 *dst_indir_table;
if (to->indir.actual_table_size != from->indir.actual_table_size ||
to->indir.max_table_size != from->indir.max_table_size) {
mlx5e_rss_warn(to->mdev,
"Failed to copy RSS due to size mismatch, src (actual %u, max %u) != dst (actual %u, max %u)\n",
from->indir.actual_table_size, from->indir.max_table_size,
to->indir.actual_table_size, to->indir.max_table_size);
return -EINVAL;
}
dst_indir_table = to->indir.table;
*to = *from;
to->indir.table = dst_indir_table;
memcpy(to->indir.table, from->indir.table,
from->indir.actual_table_size * sizeof(*from->indir.table));
return 0;
}
static struct mlx5e_rss *mlx5e_rss_init_copy(const struct mlx5e_rss *from)
{
struct mlx5e_rss *rss;
int err;
Annotation
- Immediate include surface: `linux/ethtool.h`, `rss.h`.
- Detected declarations: `struct mlx5e_rss`, `function mlx5e_rss_get_default_tt_config`, `function mlx5e_rss_get_inner_ft_support`, `function mlx5e_rss_set_indir_actual_size`, `function ethtool_rxfh_ctxs_resize`, `function mlx5e_rss_indir_resize`, `function mlx5e_rss_params_indir_init`, `function mlx5e_rss_params_indir_cleanup`, `function mlx5e_rss_copy`, `function mlx5e_rss_params_init`.
- 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.