drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c
Extension
.c
Size
12646 bytes
Lines
498
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

if (ret) {
			mlx5hws_err(tbl->ctx, "Failed to get default fdb miss\n");
			goto free_ft_obj;
		}
		ret = hws_table_connect_to_default_miss_tbl(tbl, *ft_id);
		if (ret) {
			mlx5hws_err(tbl->ctx, "Failed connecting to default miss tbl\n");
			goto down_miss_tbl;
		}
	}

	return 0;

down_miss_tbl:
	hws_table_down_default_fdb_miss_tbl(tbl);
free_ft_obj:
	mlx5hws_cmd_flow_table_destroy(mdev, ft_attr.type, *ft_id);
	return ret;
}

void mlx5hws_table_destroy_default_ft(struct mlx5hws_table *tbl,
				      u32 ft_id)
{
	mlx5hws_cmd_flow_table_destroy(tbl->ctx->mdev, tbl->fw_ft_type, ft_id);
	hws_table_down_default_fdb_miss_tbl(tbl);
}

static int hws_table_init_check_hws_support(struct mlx5hws_context *ctx,
					    struct mlx5hws_table *tbl)
{
	if (!(ctx->flags & MLX5HWS_CONTEXT_FLAG_HWS_SUPPORT)) {
		mlx5hws_err(ctx, "HWS not supported, cannot create mlx5hws_table\n");
		return -EOPNOTSUPP;
	}

	return 0;
}

static int hws_table_init(struct mlx5hws_table *tbl)
{
	struct mlx5hws_context *ctx = tbl->ctx;
	int ret;

	ret = hws_table_init_check_hws_support(ctx, tbl);
	if (ret)
		return ret;

	if (mlx5hws_table_get_fw_ft_type(tbl->type, (u8 *)&tbl->fw_ft_type)) {
		pr_warn("HWS: invalid table type %d\n", tbl->type);
		return -EOPNOTSUPP;
	}

	mutex_lock(&ctx->ctrl_lock);
	ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev,
					      tbl,
					      tbl->uid,
					      &tbl->ft_id);
	if (ret) {
		mlx5hws_err(tbl->ctx, "Failed to create flow table object\n");
		mutex_unlock(&ctx->ctrl_lock);
		return ret;
	}

	ret = mlx5hws_action_get_default_stc(ctx, tbl->type);
	if (ret)
		goto tbl_destroy;

	INIT_LIST_HEAD(&tbl->matchers_list);
	INIT_LIST_HEAD(&tbl->default_miss.head);

	mutex_unlock(&ctx->ctrl_lock);

	return 0;

tbl_destroy:
	mlx5hws_table_destroy_default_ft(tbl, tbl->ft_id);
	mutex_unlock(&ctx->ctrl_lock);
	return ret;
}

static void hws_table_uninit(struct mlx5hws_table *tbl)
{
	mutex_lock(&tbl->ctx->ctrl_lock);
	mlx5hws_action_put_default_stc(tbl->ctx, tbl->type);
	mlx5hws_table_destroy_default_ft(tbl, tbl->ft_id);
	mutex_unlock(&tbl->ctx->ctrl_lock);
}

struct mlx5hws_table *mlx5hws_table_create(struct mlx5hws_context *ctx,
					   struct mlx5hws_table_attr *attr)

Annotation

Implementation Notes