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

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

File Facts

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

switch (dest->destination_type) {
			case MLX5_FLOW_DESTINATION_TYPE_VPORT:
				if (dest->ext_flags & MLX5HWS_CMD_EXT_DEST_ESW_OWNER_VHCA_ID) {
					MLX5_SET(dest_format, in_dests,
						 destination_eswitch_owner_vhca_id_valid, 1);
					MLX5_SET(dest_format, in_dests,
						 destination_eswitch_owner_vhca_id,
						 dest->esw_owner_vhca_id);
				}
				fallthrough;
			case MLX5_FLOW_DESTINATION_TYPE_TIR:
			case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE:
				MLX5_SET(dest_format, in_dests, destination_type, ifc_dest_type);
				MLX5_SET(dest_format, in_dests, destination_id,
					 dest->destination_id);
				if (dest->ext_flags & MLX5HWS_CMD_EXT_DEST_REFORMAT) {
					MLX5_SET(dest_format, in_dests, packet_reformat, 1);
					MLX5_SET(extended_dest_format, in_dests, packet_reformat_id,
						 dest->ext_reformat_id);
				}
				break;
			case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
				MLX5_SET(dest_format, in_dests,
					 destination_type, ifc_dest_type);
				MLX5_SET(dest_format, in_dests, destination_id,
					 dest->destination_id);
				break;
			default:
				ret = -EOPNOTSUPP;
				goto out;
			}

			in_dests = in_dests + dest_entry_sz;
		}
		MLX5_SET(flow_context, in_flow_context, destination_list_size, fte_attr->dests_num);
	}

	ret = mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out));
	if (ret)
		mlx5_core_err(mdev, "Failed creating FLOW_TABLE_ENTRY\n");

out:
	kfree(in);
	return ret;
}

int mlx5hws_cmd_delete_fte(struct mlx5_core_dev *mdev,
			   u32 table_type,
			   u32 table_id)
{
	u32 in[MLX5_ST_SZ_DW(delete_fte_in)] = {};

	MLX5_SET(delete_fte_in, in, opcode, MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY);
	MLX5_SET(delete_fte_in, in, table_type, table_type);
	MLX5_SET(delete_fte_in, in, table_id, table_id);

	return mlx5_cmd_exec_in(mdev, delete_fte, in);
}

struct mlx5hws_cmd_forward_tbl *
mlx5hws_cmd_forward_tbl_create(struct mlx5_core_dev *mdev,
			       struct mlx5hws_cmd_ft_create_attr *ft_attr,
			       struct mlx5hws_cmd_set_fte_attr *fte_attr)
{
	struct mlx5hws_cmd_fg_attr fg_attr = {0};
	struct mlx5hws_cmd_forward_tbl *tbl;
	int ret;

	tbl = kzalloc_obj(*tbl);
	if (!tbl)
		return NULL;

	ret = mlx5hws_cmd_flow_table_create(mdev, ft_attr, &tbl->ft_id);
	if (ret) {
		mlx5_core_err(mdev, "Failed to create FT\n");
		goto free_tbl;
	}

	fg_attr.table_id = tbl->ft_id;
	fg_attr.table_type = ft_attr->type;

	ret = hws_cmd_flow_group_create(mdev, &fg_attr, &tbl->fg_id);
	if (ret) {
		mlx5_core_err(mdev, "Failed to create FG\n");
		goto free_ft;
	}

	ret = mlx5hws_cmd_set_fte(mdev, ft_attr->type,
				  tbl->ft_id, tbl->fg_id, fte_attr);
	if (ret) {

Annotation

Implementation Notes