drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_cmd.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_cmd.c- Extension
.c- Size
- 30842 bytes
- Lines
- 959
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dr_types.heswitch.h
Detected Declarations
function mlx5dr_cmd_query_esw_vport_contextfunction mlx5dr_cmd_query_gvmifunction mlx5dr_cmd_query_esw_capsfunction dr_cmd_query_nic_vport_roce_enfunction mlx5dr_cmd_query_devicefunction mlx5dr_cmd_query_flow_tablefunction mlx5dr_cmd_query_flow_samplerfunction mlx5dr_cmd_sync_steeringfunction mlx5dr_cmd_set_fte_modify_and_vportfunction mlx5dr_cmd_del_flow_table_entryfunction mlx5dr_cmd_alloc_modify_headerfunction mlx5dr_cmd_dealloc_modify_headerfunction mlx5dr_cmd_create_empty_flow_groupfunction mlx5dr_cmd_destroy_flow_groupfunction mlx5dr_cmd_create_flow_tablefunction mlx5dr_cmd_destroy_flow_tablefunction mlx5dr_cmd_create_reformat_ctxfunction mlx5dr_cmd_destroy_reformat_ctxfunction dr_cmd_set_definer_formatfunction mlx5dr_cmd_create_definerfunction mlx5dr_cmd_destroy_definerfunction mlx5dr_cmd_query_gidfunction mlx5dr_cmd_create_modify_header_argfunction mlx5dr_cmd_destroy_modify_header_argfunction mlx5dr_cmd_set_extended_destfunction mlx5dr_cmd_set_fte
Annotated Snippet
if (attr->table_type == MLX5_FLOW_TABLE_TYPE_NIC_RX) {
MLX5_SET64(flow_table_context, ft_mdev,
sws.sw_owner_icm_root_0, attr->icm_addr_rx);
} else if (attr->table_type == MLX5_FLOW_TABLE_TYPE_NIC_TX) {
MLX5_SET64(flow_table_context, ft_mdev,
sws.sw_owner_icm_root_0, attr->icm_addr_tx);
} else if (attr->table_type == MLX5_FLOW_TABLE_TYPE_FDB) {
MLX5_SET64(flow_table_context, ft_mdev,
sws.sw_owner_icm_root_0, attr->icm_addr_rx);
MLX5_SET64(flow_table_context, ft_mdev,
sws.sw_owner_icm_root_1, attr->icm_addr_tx);
}
}
MLX5_SET(create_flow_table_in, in, flow_table_context.decap_en,
attr->decap_en);
MLX5_SET(create_flow_table_in, in, flow_table_context.reformat_en,
attr->reformat_en);
err = mlx5_cmd_exec_inout(mdev, create_flow_table, in, out);
if (err)
return err;
*table_id = MLX5_GET(create_flow_table_out, out, table_id);
if (!attr->sw_owner && attr->table_type == MLX5_FLOW_TABLE_TYPE_FDB &&
fdb_rx_icm_addr)
*fdb_rx_icm_addr =
(u64)MLX5_GET(create_flow_table_out, out, icm_address_31_0) |
(u64)MLX5_GET(create_flow_table_out, out, icm_address_39_32) << 32 |
(u64)MLX5_GET(create_flow_table_out, out, icm_address_63_40) << 40;
return 0;
}
int mlx5dr_cmd_destroy_flow_table(struct mlx5_core_dev *mdev,
u32 table_id,
u32 table_type)
{
u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {};
MLX5_SET(destroy_flow_table_in, in, opcode,
MLX5_CMD_OP_DESTROY_FLOW_TABLE);
MLX5_SET(destroy_flow_table_in, in, table_type, table_type);
MLX5_SET(destroy_flow_table_in, in, table_id, table_id);
return mlx5_cmd_exec_in(mdev, destroy_flow_table, in);
}
int mlx5dr_cmd_create_reformat_ctx(struct mlx5_core_dev *mdev,
enum mlx5_reformat_ctx_type rt,
u8 reformat_param_0,
u8 reformat_param_1,
size_t reformat_size,
void *reformat_data,
u32 *reformat_id)
{
u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)] = {};
size_t inlen, cmd_data_sz, cmd_total_sz;
void *prctx;
void *pdata;
void *in;
int err;
cmd_total_sz = MLX5_ST_SZ_BYTES(alloc_packet_reformat_context_in);
cmd_data_sz = MLX5_FLD_SZ_BYTES(alloc_packet_reformat_context_in,
packet_reformat_context.reformat_data);
inlen = ALIGN(cmd_total_sz + reformat_size - cmd_data_sz, 4);
in = kvzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
MLX5_SET(alloc_packet_reformat_context_in, in, opcode,
MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT);
prctx = MLX5_ADDR_OF(alloc_packet_reformat_context_in, in, packet_reformat_context);
pdata = MLX5_ADDR_OF(packet_reformat_context_in, prctx, reformat_data);
MLX5_SET(packet_reformat_context_in, prctx, reformat_type, rt);
MLX5_SET(packet_reformat_context_in, prctx, reformat_param_0, reformat_param_0);
MLX5_SET(packet_reformat_context_in, prctx, reformat_param_1, reformat_param_1);
MLX5_SET(packet_reformat_context_in, prctx, reformat_data_size, reformat_size);
if (reformat_data && reformat_size)
memcpy(pdata, reformat_data, reformat_size);
err = mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out));
if (err)
goto err_free_in;
*reformat_id = MLX5_GET(alloc_packet_reformat_context_out, out, packet_reformat_id);
Annotation
- Immediate include surface: `dr_types.h`, `eswitch.h`.
- Detected declarations: `function mlx5dr_cmd_query_esw_vport_context`, `function mlx5dr_cmd_query_gvmi`, `function mlx5dr_cmd_query_esw_caps`, `function dr_cmd_query_nic_vport_roce_en`, `function mlx5dr_cmd_query_device`, `function mlx5dr_cmd_query_flow_table`, `function mlx5dr_cmd_query_flow_sampler`, `function mlx5dr_cmd_sync_steering`, `function mlx5dr_cmd_set_fte_modify_and_vport`, `function mlx5dr_cmd_del_flow_table_entry`.
- 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.