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.
- 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
internal.h
Detected Declarations
function hws_cmd_dest_type_to_ifc_dest_typefunction hws_cmd_general_obj_destroyfunction mlx5hws_cmd_flow_table_createfunction mlx5hws_cmd_flow_table_modifyfunction mlx5hws_cmd_flow_table_queryfunction mlx5hws_cmd_flow_table_destroyfunction hws_cmd_flow_group_createfunction hws_cmd_flow_group_destroyfunction mlx5hws_cmd_set_ftefunction mlx5hws_cmd_delete_ftefunction mlx5hws_cmd_forward_tbl_createfunction mlx5hws_cmd_forward_tbl_destroyfunction mlx5hws_cmd_set_attr_connect_miss_tblfunction mlx5hws_cmd_rtc_createfunction mlx5hws_cmd_rtc_destroyfunction mlx5hws_cmd_stc_createfunction mlx5hws_cmd_stc_destroyfunction hws_cmd_stc_modify_set_stc_paramfunction mlx5hws_cmd_stc_modifyfunction mlx5hws_cmd_arg_createfunction mlx5hws_cmd_arg_destroyfunction mlx5hws_cmd_header_modify_pattern_createfunction mlx5hws_cmd_header_modify_pattern_destroyfunction mlx5hws_cmd_ste_createfunction mlx5hws_cmd_ste_destroyfunction mlx5hws_cmd_definer_createfunction mlx5hws_cmd_definer_destroyfunction mlx5hws_cmd_packet_reformat_createfunction mlx5hws_cmd_packet_reformat_destroyfunction mlx5hws_cmd_sq_modify_rdyfunction mlx5hws_cmd_generate_wqefunction mlx5hws_cmd_query_capsfunction mlx5hws_cmd_query_gvmi
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
- Immediate include surface: `internal.h`.
- Detected declarations: `function hws_cmd_dest_type_to_ifc_dest_type`, `function hws_cmd_general_obj_destroy`, `function mlx5hws_cmd_flow_table_create`, `function mlx5hws_cmd_flow_table_modify`, `function mlx5hws_cmd_flow_table_query`, `function mlx5hws_cmd_flow_table_destroy`, `function hws_cmd_flow_group_create`, `function hws_cmd_flow_group_destroy`, `function mlx5hws_cmd_set_fte`, `function mlx5hws_cmd_delete_fte`.
- 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.