drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
Extension
.c
Size
18334 bytes
Lines
749
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_rx_res {
	struct mlx5_core_dev *mdev; /* primary */
	enum mlx5e_rx_res_features features;
	unsigned int max_nch;
	u32 drop_rqn;

	struct mlx5e_packet_merge_param pkt_merge_param;
	struct rw_semaphore pkt_merge_param_sem;

	struct mlx5e_rss *rss[MLX5E_MAX_NUM_RSS];
	bool rss_active;
	u32 *rss_rqns;
	u32 *rss_vhca_ids;
	unsigned int rss_nch;

	struct {
		struct mlx5e_rqt direct_rqt;
		struct mlx5e_tir direct_tir;
	} *channels;

	struct {
		struct mlx5e_rqt rqt;
		struct mlx5e_tir tir;
	} ptp;
};

/* API for rx_res_rss_* */

static u32 *get_vhca_ids(struct mlx5e_rx_res *res, int offset)
{
	bool multi_vhca = res->features & MLX5E_RX_RES_FEATURE_MULTI_VHCA;

	return multi_vhca ? res->rss_vhca_ids + offset : NULL;
}

/* Updates the indirection table SW shadow, does not update the HW resources yet
 */
void mlx5e_rx_res_rss_update_num_channels(struct mlx5e_rx_res *res, u32 nch,
					  struct net_device *netdev)
{
	u32 new_size = mlx5e_rqt_size(res->mdev, nch);
	int i;

	WARN_ON_ONCE(res->rss_active);

	/* Default context: fold/unfold user-configured table, then update size
	 * and reset to uniform when unconfigured.
	 */
	mlx5e_rss_indir_resize(res->rss[0], netdev, new_size);

	/* mlx5e_rss_indir_resize() is a no-op when the table is not
	 * user-configured. actual_table_size is updated after the resize
	 * because ethtool_rxfh_indir_resize() uses it as the old size to
	 * replicate the pattern; updating it first would make the grow a no-op.
	 * It must be updated before mlx5e_rss_set_indir_uniform() so that
	 * the uniform fill covers all new entries, not just the old ones.
	 */
	mlx5e_rss_set_indir_actual_size(res->rss[0], new_size);
	if (!netif_is_rxfh_configured(netdev))
		mlx5e_rss_set_indir_uniform(res->rss[0], nch);

	/* Non-default contexts */
	for (i = 1; i < MLX5E_MAX_NUM_RSS; i++) {
		if (res->rss[i]) {
			mlx5e_rss_ctx_resize(res->rss[i], new_size);
			mlx5e_rss_set_indir_actual_size(res->rss[i], new_size);
		}
	}
}

static int mlx5e_rx_res_rss_init_def(struct mlx5e_rx_res *res,
				     unsigned int init_nch)
{
	bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
	struct mlx5e_rss_init_params init_params;
	struct mlx5e_rss_params rss_params;
	struct mlx5e_rss *rss;

	if (WARN_ON(res->rss[0]))
		return -EINVAL;

	init_params = (struct mlx5e_rss_init_params) {
		.type = MLX5E_RSS_INIT_TIRS,
		.pkt_merge_param = &res->pkt_merge_param,
		.nch = init_nch,
		.max_nch = res->max_nch,
	};

	rss_params = (struct mlx5e_rss_params) {
		.inner_ft_support = inner_ft_support,

Annotation

Implementation Notes