drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c- Extension
.c- Size
- 21791 bytes
- Lines
- 782
- 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/hash.hlinux/mlx5/fs.hlinux/ip.hlinux/ipv6.hnet/rps.hen.h
Detected Declarations
struct arfs_tablestruct mlx5e_arfs_tablesstruct arfs_tuplestruct arfs_ruleenum arfs_typefunction hlist_for_each_entry_safefunction arfs_disablefunction mlx5e_arfs_disablefunction mlx5e_arfs_enablefunction arfs_destroy_tablefunction _mlx5e_cleanup_tablesfunction mlx5e_arfs_destroy_tablesfunction arfs_add_default_rulefunction arfs_create_groupsfunction arfs_create_tablefunction mlx5e_arfs_create_tablesfunction arfs_may_expire_flowfunction arfs_del_rulesfunction hlist_for_each_entry_safefunction arfs_hash_bucketfunction arfs_modify_rule_rqfunction arfs_handle_workfunction arfs_cmpfunction mlx5e_rx_flow_steer
Annotated Snippet
struct arfs_table {
struct mlx5e_flow_table ft;
struct mlx5_flow_handle *default_rule;
struct hlist_head rules_hash[ARFS_HASH_SIZE];
};
enum {
MLX5E_ARFS_STATE_ENABLED,
};
enum arfs_type {
ARFS_IPV4_TCP,
ARFS_IPV6_TCP,
ARFS_IPV4_UDP,
ARFS_IPV6_UDP,
ARFS_NUM_TYPES,
};
struct mlx5e_arfs_tables {
struct arfs_table arfs_tables[ARFS_NUM_TYPES];
/* Protect aRFS rules list */
spinlock_t arfs_lock;
int last_filter_id;
struct workqueue_struct *wq;
unsigned long state;
};
struct arfs_tuple {
__be16 etype;
u8 ip_proto;
union {
__be32 src_ipv4;
struct in6_addr src_ipv6;
};
union {
__be32 dst_ipv4;
struct in6_addr dst_ipv6;
};
__be16 src_port;
__be16 dst_port;
};
struct arfs_rule {
struct mlx5e_priv *priv;
struct work_struct arfs_work;
struct mlx5_flow_handle *rule;
struct hlist_node hlist;
int rxq;
/* Flow ID passed to ndo_rx_flow_steer */
int flow_id;
/* Filter ID returned by ndo_rx_flow_steer */
int filter_id;
struct arfs_tuple tuple;
};
#define mlx5e_for_each_arfs_rule(hn, tmp, arfs_tables, i, j) \
for (i = 0; i < ARFS_NUM_TYPES; i++) \
mlx5e_for_each_hash_arfs_rule(hn, tmp, arfs_tables[i].rules_hash, j)
#define mlx5e_for_each_hash_arfs_rule(hn, tmp, hash, j) \
for (j = 0; j < ARFS_HASH_SIZE; j++) \
hlist_for_each_entry_safe(hn, tmp, &hash[j], hlist)
static enum mlx5_traffic_types arfs_get_tt(enum arfs_type type)
{
switch (type) {
case ARFS_IPV4_TCP:
return MLX5_TT_IPV4_TCP;
case ARFS_IPV4_UDP:
return MLX5_TT_IPV4_UDP;
case ARFS_IPV6_TCP:
return MLX5_TT_IPV6_TCP;
case ARFS_IPV6_UDP:
return MLX5_TT_IPV6_UDP;
default:
return -EINVAL;
}
}
static int arfs_disable(struct mlx5e_flow_steering *fs)
{
struct mlx5_ttc_table *ttc = mlx5e_fs_get_ttc(fs, false);
int err, i;
for (i = 0; i < ARFS_NUM_TYPES; i++) {
/* Modify ttc rules destination back to their default */
err = mlx5_ttc_fwd_default_dest(ttc, arfs_get_tt(i));
if (err) {
fs_err(fs,
"%s: modify ttc[%d] default destination failed, err(%d)\n",
Annotation
- Immediate include surface: `linux/hash.h`, `linux/mlx5/fs.h`, `linux/ip.h`, `linux/ipv6.h`, `net/rps.h`, `en.h`.
- Detected declarations: `struct arfs_table`, `struct mlx5e_arfs_tables`, `struct arfs_tuple`, `struct arfs_rule`, `enum arfs_type`, `function hlist_for_each_entry_safe`, `function arfs_disable`, `function mlx5e_arfs_disable`, `function mlx5e_arfs_enable`, `function arfs_destroy_table`.
- 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.