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.

Dependency Surface

Detected Declarations

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

Implementation Notes