drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c- Extension
.c- Size
- 26587 bytes
- Lines
- 1020
- 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/fs.hen.hen/params.hen/xsk/pool.hen/fs_ethtool.h
Detected Declarations
struct mlx5e_ethtool_tablestruct mlx5e_ethtool_steeringstruct mlx5e_ethtool_rulefunction flow_type_maskfunction put_flow_tablefunction mask_specfunction set_ip4function set_ip6function set_tcpfunction set_udpfunction parse_tcp4function parse_udp4function parse_ip4function parse_ip6function parse_tcp6function parse_udp6function parse_etherfunction set_cvlanfunction set_dmacfunction set_flow_attrsfunction add_rule_to_listfunction list_for_each_entryfunction outer_header_zerofunction flow_get_tirnfunction add_ethtool_flow_rulefunction del_ethtool_rulefunction list_for_each_entryfunction validate_ethterfunction validate_tcpudp4function validate_ip4function validate_ip6function validate_tcpudp6function validate_vlanfunction validate_flowfunction mlx5e_ethtool_flow_replacefunction mlx5e_ethtool_flow_removefunction mlx5e_ethtool_get_flowfunction list_for_each_entryfunction mlx5e_ethtool_get_all_flowsfunction mlx5e_ethtool_allocfunction mlx5e_ethtool_freefunction mlx5e_ethtool_cleanup_steeringfunction mlx5e_ethtool_init_steeringfunction flow_type_to_traffic_typefunction mlx5e_ethtool_set_rxfh_fieldsfunction mlx5e_ethtool_get_rxfh_fieldsfunction mlx5e_ethtool_set_rxnfcfunction mlx5e_ethtool_get_rxnfc
Annotated Snippet
struct mlx5e_ethtool_table {
struct mlx5_flow_table *ft;
int num_rules;
};
#define ETHTOOL_NUM_L3_L4_FTS 7
#define ETHTOOL_NUM_L2_FTS 4
struct mlx5e_ethtool_steering {
struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
struct list_head rules;
int tot_num_rules;
};
static int flow_type_to_traffic_type(u32 flow_type);
static u32 flow_type_mask(u32 flow_type)
{
return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
}
struct mlx5e_ethtool_rule {
struct list_head list;
struct ethtool_rx_flow_spec flow_spec;
struct mlx5_flow_handle *rule;
struct mlx5e_ethtool_table *eth_ft;
struct mlx5e_rss *rss;
};
static void put_flow_table(struct mlx5e_ethtool_table *eth_ft)
{
if (!--eth_ft->num_rules) {
mlx5_destroy_flow_table(eth_ft->ft);
eth_ft->ft = NULL;
}
}
#define MLX5E_ETHTOOL_L3_L4_PRIO 0
#define MLX5E_ETHTOOL_L2_PRIO (MLX5E_ETHTOOL_L3_L4_PRIO + ETHTOOL_NUM_L3_L4_FTS)
#define MLX5E_ETHTOOL_NUM_ENTRIES 64000
#define MLX5E_ETHTOOL_NUM_GROUPS 10
static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,
struct ethtool_rx_flow_spec *fs,
int num_tuples)
{
struct mlx5e_ethtool_steering *ethtool = mlx5e_fs_get_ethtool(priv->fs);
struct mlx5_flow_table_attr ft_attr = {};
struct mlx5e_ethtool_table *eth_ft;
struct mlx5_flow_namespace *ns;
struct mlx5_flow_table *ft;
int max_tuples;
int table_size;
int prio;
switch (flow_type_mask(fs->flow_type)) {
case TCP_V4_FLOW:
case UDP_V4_FLOW:
case TCP_V6_FLOW:
case UDP_V6_FLOW:
case IP_USER_FLOW:
case IPV6_USER_FLOW:
max_tuples = ETHTOOL_NUM_L3_L4_FTS;
prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
eth_ft = ðtool->l3_l4_ft[prio];
break;
case ETHER_FLOW:
max_tuples = ETHTOOL_NUM_L2_FTS;
prio = max_tuples - num_tuples;
eth_ft = ðtool->l2_ft[prio];
prio += MLX5E_ETHTOOL_L2_PRIO;
break;
default:
return ERR_PTR(-EINVAL);
}
eth_ft->num_rules++;
if (eth_ft->ft)
return eth_ft;
ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_ETHTOOL);
if (!ns)
return ERR_PTR(-EOPNOTSUPP);
table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev,
flow_table_properties_nic_receive.log_max_ft_size)),
MLX5E_ETHTOOL_NUM_ENTRIES);
ft_attr.prio = prio;
Annotation
- Immediate include surface: `linux/mlx5/fs.h`, `en.h`, `en/params.h`, `en/xsk/pool.h`, `en/fs_ethtool.h`.
- Detected declarations: `struct mlx5e_ethtool_table`, `struct mlx5e_ethtool_steering`, `struct mlx5e_ethtool_rule`, `function flow_type_mask`, `function put_flow_table`, `function mask_spec`, `function set_ip4`, `function set_ip6`, `function set_tcp`, `function set_udp`.
- 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.