drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c- Extension
.c- Size
- 9717 bytes
- Lines
- 383
- 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/etherdevice.hlinux/idr.hlinux/mlx5/driver.hlinux/mlx5/mlx5_ifc.hlinux/mlx5/vport.hlinux/mlx5/fs.hmlx5_core.heswitch.hen.hen_tc.hfs_core.hesw/indir_table.hlib/fs_chains.hen/mod_hdr.h
Detected Declarations
struct mlx5_esw_indir_table_rulestruct mlx5_esw_indir_table_entrystruct mlx5_esw_indir_tablefunction mlx5_esw_indir_table_initfunction mlx5_esw_indir_table_destroyfunction mlx5_esw_indir_table_neededfunction mlx5_esw_indir_table_decap_vportfunction mlx5_esw_indir_table_rule_getfunction mlx5_esw_indir_table_rule_putfunction mlx5_create_indir_recirc_groupfunction mlx5_create_indir_fwd_groupfunction mlx5_esw_indir_table_entry_createfunction mlx5_esw_indir_table_entry_lookupfunction mlx5_esw_indir_table_put
Annotated Snippet
struct mlx5_esw_indir_table_rule {
struct mlx5_flow_handle *handle;
struct mlx5_modify_hdr *mh;
refcount_t refcnt;
};
struct mlx5_esw_indir_table_entry {
struct hlist_node hlist;
struct mlx5_flow_table *ft;
struct mlx5_flow_group *recirc_grp;
struct mlx5_flow_group *fwd_grp;
struct mlx5_flow_handle *fwd_rule;
struct mlx5_esw_indir_table_rule *recirc_rule;
int fwd_ref;
u16 vport;
};
struct mlx5_esw_indir_table {
struct mutex lock; /* protects table */
DECLARE_HASHTABLE(table, 8);
};
struct mlx5_esw_indir_table *
mlx5_esw_indir_table_init(void)
{
struct mlx5_esw_indir_table *indir = kvzalloc_obj(*indir);
if (!indir)
return ERR_PTR(-ENOMEM);
mutex_init(&indir->lock);
hash_init(indir->table);
return indir;
}
void
mlx5_esw_indir_table_destroy(struct mlx5_esw_indir_table *indir)
{
mutex_destroy(&indir->lock);
kvfree(indir);
}
bool
mlx5_esw_indir_table_needed(struct mlx5_eswitch *esw,
struct mlx5_flow_attr *attr,
u16 vport_num,
struct mlx5_core_dev *dest_mdev)
{
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
bool vf_sf_vport;
vf_sf_vport = mlx5_eswitch_is_vf_vport(esw, vport_num) ||
mlx5_esw_is_sf_vport(esw, vport_num);
/* Use indirect table for all IP traffic from UL to VF with vport
* destination when source rewrite flag is set.
*/
return esw_attr->in_rep->vport == MLX5_VPORT_UPLINK &&
vf_sf_vport &&
esw->dev == dest_mdev &&
attr->flags & MLX5_ATTR_FLAG_SRC_REWRITE;
}
u16
mlx5_esw_indir_table_decap_vport(struct mlx5_flow_attr *attr)
{
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
return esw_attr->rx_tun_attr ? esw_attr->rx_tun_attr->decap_vport : 0;
}
static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,
struct mlx5_flow_attr *attr,
struct mlx5_esw_indir_table_entry *e)
{
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
struct mlx5_fs_chains *chains = esw_chains(esw);
struct mlx5e_tc_mod_hdr_acts mod_acts = {};
struct mlx5_flow_destination dest = {};
struct mlx5_esw_indir_table_rule *rule;
struct mlx5_flow_act flow_act = {};
struct mlx5_flow_handle *handle;
int err = 0;
u32 data;
if (e->recirc_rule) {
refcount_inc(&e->recirc_rule->refcnt);
return 0;
}
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/idr.h`, `linux/mlx5/driver.h`, `linux/mlx5/mlx5_ifc.h`, `linux/mlx5/vport.h`, `linux/mlx5/fs.h`, `mlx5_core.h`, `eswitch.h`.
- Detected declarations: `struct mlx5_esw_indir_table_rule`, `struct mlx5_esw_indir_table_entry`, `struct mlx5_esw_indir_table`, `function mlx5_esw_indir_table_init`, `function mlx5_esw_indir_table_destroy`, `function mlx5_esw_indir_table_needed`, `function mlx5_esw_indir_table_decap_vport`, `function mlx5_esw_indir_table_rule_get`, `function mlx5_esw_indir_table_rule_put`, `function mlx5_create_indir_recirc_group`.
- 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.