drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c- Extension
.c- Size
- 40062 bytes
- Lines
- 1241
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/mlx5/driver.hlinux/mlx5/device.hlinux/mlx5/mlx5_ifc.hfs_core.hfs_cmd.hfs_ft_pool.hmlx5_core.heswitch.h
Detected Declarations
function Copyrightfunction mlx5_cmd_stub_create_flow_tablefunction mlx5_cmd_stub_destroy_flow_tablefunction mlx5_cmd_stub_modify_flow_tablefunction mlx5_cmd_stub_create_flow_groupfunction mlx5_cmd_stub_destroy_flow_groupfunction mlx5_cmd_stub_create_ftefunction mlx5_cmd_stub_update_ftefunction mlx5_cmd_stub_delete_ftefunction mlx5_cmd_stub_packet_reformat_allocfunction mlx5_cmd_stub_packet_reformat_deallocfunction mlx5_cmd_stub_modify_header_deallocfunction mlx5_cmd_stub_create_nsfunction mlx5_cmd_stub_destroy_nsfunction mlx5_cmd_stub_get_capabilitiesfunction mlx5_cmd_set_slave_root_fdbfunction mlx5_cmd_stub_destroy_match_definerfunction mlx5_cmd_stub_create_match_definerfunction mlx5_cmd_update_root_ftfunction mlx5_lag_is_shared_fdbfunction mlx5_lag_for_each_peer_mdevfunction mlx5_cmd_create_flow_tablefunction mlx5_cmd_destroy_flow_tablefunction mlx5_cmd_modify_flow_tablefunction mlx5_cmd_create_flow_groupfunction mlx5_cmd_destroy_flow_groupfunction mlx5_set_extended_destfunction list_for_each_entryfunction mlx5_cmd_set_fte_flow_meterfunction mlx5_cmd_set_ftefunction list_for_each_entryfunction list_for_each_entryfunction mlx5_cmd_create_ftefunction mlx5_cmd_update_ftefunction mlx5_cmd_delete_ftefunction mlx5_cmd_fc_bulk_allocfunction mlx5_cmd_fc_allocfunction mlx5_cmd_fc_freefunction mlx5_cmd_fc_queryfunction mlx5_cmd_fc_get_bulk_query_out_lenfunction mlx5_cmd_fc_bulk_queryfunction mlx5_cmd_packet_reformat_allocfunction mlx5_cmd_packet_reformat_deallocfunction mlx5_cmd_modify_header_allocfunction mlx5_cmd_modify_header_deallocfunction mlx5_cmd_destroy_match_definerfunction mlx5_cmd_create_match_definerfunction mlx5_cmd_get_capabilities
Annotated Snippet
mlx5_lag_is_master(dev)) {
struct mlx5_core_dev *peer_dev;
int i, j;
mlx5_lag_for_each_peer_mdev(dev, peer_dev, i) {
err = mlx5_cmd_set_slave_root_fdb(dev, peer_dev, !disconnect,
(!disconnect) ? ft->id : 0);
if (err && !disconnect) {
mlx5_lag_for_each_peer_mdev(dev, peer_dev, j) {
if (j < i)
mlx5_cmd_set_slave_root_fdb(dev, peer_dev, 1,
ns->root_ft->id);
else
break;
}
MLX5_SET(set_flow_table_root_in, in, op_mod, 0);
MLX5_SET(set_flow_table_root_in, in, table_id,
ns->root_ft->id);
mlx5_cmd_exec_in(dev, set_flow_table_root, in);
}
if (err)
break;
}
}
return err;
}
static int mlx5_cmd_create_flow_table(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_table *ft,
struct mlx5_flow_table_attr *ft_attr,
struct mlx5_flow_table *next_ft)
{
int en_encap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT);
int en_decap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
int term = !!(ft->flags & MLX5_FLOW_TABLE_TERMINATION);
u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {};
u32 in[MLX5_ST_SZ_DW(create_flow_table_in)] = {};
struct mlx5_core_dev *dev = ns->dev;
unsigned int size;
int err;
size = mlx5_ft_pool_get_avail_sz(dev, ft->type, ft_attr->max_fte);
if (!size)
return -ENOSPC;
MLX5_SET(create_flow_table_in, in, opcode,
MLX5_CMD_OP_CREATE_FLOW_TABLE);
MLX5_SET(create_flow_table_in, in, uid, ft_attr->uid);
MLX5_SET(create_flow_table_in, in, table_type, ft->type);
MLX5_SET(create_flow_table_in, in, flow_table_context.level, ft->level);
MLX5_SET(create_flow_table_in, in, flow_table_context.log_size, size ? ilog2(size) : 0);
MLX5_SET(create_flow_table_in, in, vport_number, ft->vport);
MLX5_SET(create_flow_table_in, in, other_vport,
!!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
MLX5_SET(create_flow_table_in, in, eswitch_owner_vhca_id,
ft->esw_owner_vhca_id);
MLX5_SET(create_flow_table_in, in, other_eswitch,
!!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
MLX5_SET(create_flow_table_in, in, flow_table_context.decap_en,
en_decap);
MLX5_SET(create_flow_table_in, in, flow_table_context.reformat_en,
en_encap);
MLX5_SET(create_flow_table_in, in, flow_table_context.termination_table,
term);
switch (ft->op_mod) {
case FS_FT_OP_MOD_NORMAL:
if (next_ft) {
MLX5_SET(create_flow_table_in, in,
flow_table_context.table_miss_action,
MLX5_FLOW_TABLE_MISS_ACTION_FWD);
MLX5_SET(create_flow_table_in, in,
flow_table_context.table_miss_id, next_ft->id);
} else {
MLX5_SET(create_flow_table_in, in,
flow_table_context.table_miss_action,
ft->def_miss_action);
}
break;
case FS_FT_OP_MOD_LAG_DEMUX:
MLX5_SET(create_flow_table_in, in, op_mod, 0x1);
if (next_ft)
MLX5_SET(create_flow_table_in, in,
flow_table_context.lag_master_next_table_id,
Annotation
- Immediate include surface: `linux/mlx5/driver.h`, `linux/mlx5/device.h`, `linux/mlx5/mlx5_ifc.h`, `fs_core.h`, `fs_cmd.h`, `fs_ft_pool.h`, `mlx5_core.h`, `eswitch.h`.
- Detected declarations: `function Copyright`, `function mlx5_cmd_stub_create_flow_table`, `function mlx5_cmd_stub_destroy_flow_table`, `function mlx5_cmd_stub_modify_flow_table`, `function mlx5_cmd_stub_create_flow_group`, `function mlx5_cmd_stub_destroy_flow_group`, `function mlx5_cmd_stub_create_fte`, `function mlx5_cmd_stub_update_fte`, `function mlx5_cmd_stub_delete_fte`, `function mlx5_cmd_stub_packet_reformat_alloc`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.