drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c- Extension
.c- Size
- 20400 bytes
- Lines
- 814
- 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/mlx5_ifc.hlinux/mlx5/fs.hlib/fs_chains.hfs_ft_pool.hen/mapping.hfs_core.hen_tc.h
Detected Declarations
struct mlx5_fs_chainsstruct fs_chainstruct prio_keystruct priofunction mlx5_chains_prios_supportedfunction mlx5_chains_ignore_flow_level_supportedfunction mlx5_chains_backwards_supportedfunction mlx5_chains_get_chain_rangefunction mlx5_chains_get_nf_ft_chainfunction mlx5_chains_get_prio_rangefunction mlx5_chains_get_level_rangefunction mlx5_chains_set_end_ftfunction mlx5_chains_create_tablefunction create_chain_restorefunction destroy_chain_restorefunction mlx5_chains_create_chainfunction mlx5_chains_destroy_chainfunction mlx5_chains_get_chainfunction mlx5_chains_add_miss_rulefunction mlx5_chains_update_prio_prevsfunction mlx5_chains_put_chainfunction mlx5_chains_create_priofunction mlx5_chains_destroy_priofunction mlx5_chains_get_tablefunction mlx5_chains_put_tablefunction mlx5_chains_get_tc_end_ftfunction mlx5_chains_create_global_tablefunction mlx5_chains_destroy_global_tablefunction mlx5_chains_initfunction mlx5_chains_cleanupfunction mlx5_chains_createfunction mlx5_chains_destroyfunction mlx5_chains_get_chain_mappingfunction mlx5_chains_put_chain_mappingfunction mlx5_chains_print_info
Annotated Snippet
struct mlx5_fs_chains {
struct mlx5_core_dev *dev;
struct rhashtable chains_ht;
struct rhashtable prios_ht;
/* Protects above chains_ht and prios_ht */
struct mutex lock;
struct mlx5_flow_table *chains_default_ft;
struct mlx5_flow_table *chains_end_ft;
struct mapping_ctx *chains_mapping;
enum mlx5_flow_namespace_type ns;
u32 group_num;
u32 flags;
int fs_base_prio;
int fs_base_level;
};
struct fs_chain {
struct rhash_head node;
u32 chain;
int ref;
int id;
struct mlx5_fs_chains *chains;
struct list_head prios_list;
struct mlx5_flow_handle *restore_rule;
struct mlx5_modify_hdr *miss_modify_hdr;
};
struct prio_key {
u32 chain;
u32 prio;
u32 level;
};
struct prio {
struct rhash_head node;
struct list_head list;
struct prio_key key;
int ref;
struct fs_chain *chain;
struct mlx5_flow_table *ft;
struct mlx5_flow_table *next_ft;
struct mlx5_flow_group *miss_group;
struct mlx5_flow_handle *miss_rule;
};
static const struct rhashtable_params chain_params = {
.head_offset = offsetof(struct fs_chain, node),
.key_offset = offsetof(struct fs_chain, chain),
.key_len = sizeof_field(struct fs_chain, chain),
.automatic_shrinking = true,
};
static const struct rhashtable_params prio_params = {
.head_offset = offsetof(struct prio, node),
.key_offset = offsetof(struct prio, key),
.key_len = sizeof_field(struct prio, key),
.automatic_shrinking = true,
};
bool mlx5_chains_prios_supported(struct mlx5_fs_chains *chains)
{
return chains->flags & MLX5_CHAINS_AND_PRIOS_SUPPORTED;
}
bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains)
{
return chains->flags & MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED;
}
bool mlx5_chains_backwards_supported(struct mlx5_fs_chains *chains)
{
return mlx5_chains_prios_supported(chains) &&
mlx5_chains_ignore_flow_level_supported(chains);
}
u32 mlx5_chains_get_chain_range(struct mlx5_fs_chains *chains)
{
if (!mlx5_chains_prios_supported(chains))
return 1;
if (mlx5_chains_ignore_flow_level_supported(chains))
Annotation
- Immediate include surface: `linux/mlx5/driver.h`, `linux/mlx5/mlx5_ifc.h`, `linux/mlx5/fs.h`, `lib/fs_chains.h`, `fs_ft_pool.h`, `en/mapping.h`, `fs_core.h`, `en_tc.h`.
- Detected declarations: `struct mlx5_fs_chains`, `struct fs_chain`, `struct prio_key`, `struct prio`, `function mlx5_chains_prios_supported`, `function mlx5_chains_ignore_flow_level_supported`, `function mlx5_chains_backwards_supported`, `function mlx5_chains_get_chain_range`, `function mlx5_chains_get_nf_ft_chain`, `function mlx5_chains_get_prio_range`.
- 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.