drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c- Extension
.c- Size
- 70334 bytes
- Lines
- 2246
- 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.
- 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
dr_types.hdr_ste.h
Detected Declarations
enum dr_action_domainenum dr_action_valid_statefunction mlx5dr_action_supp_fwd_fdb_multi_ftfunction dr_action_reformat_to_action_typefunction dr_actions_applyfunction dr_action_get_action_domainfunction dr_action_validate_and_get_next_statefunction dr_action_handle_cs_recalcfunction dr_action_modify_ttl_adjustfunction dr_action_print_sequencefunction dr_action_get_dest_fw_tbl_addrfunction dr_action_get_dest_sw_tbl_addrfunction dr_action_get_dest_tbl_addrfunction mlx5dr_actions_build_ste_arrfunction dr_action_create_genericfunction mlx5dr_action_create_dest_table_numfunction mlx5dr_action_create_dest_tablefunction dr_action_range_definer_fillfunction dr_action_create_range_definerfunction dr_action_destroy_range_definerfunction mlx5dr_action_create_dest_match_rangefunction mlx5dr_action_create_mult_dest_tblfunction mlx5dr_action_create_dest_flow_fw_tablefunction mlx5dr_action_create_flow_counterfunction mlx5dr_action_create_flow_samplerfunction dr_action_verify_reformat_paramsfunction dr_action_create_reformat_actionfunction mlx5dr_action_create_packet_reformatfunction dr_action_modify_sw_to_hw_addfunction dr_action_modify_sw_to_hw_setfunction dr_action_modify_sw_to_hw_copyfunction dr_action_modify_sw_to_hwfunction dr_action_modify_check_set_field_limitationfunction dr_action_modify_check_add_field_limitationfunction dr_action_modify_check_copy_field_limitationfunction dr_action_modify_check_field_limitationfunction dr_action_modify_check_is_ttl_modifyfunction dr_actions_convert_modify_headerfunction dr_action_create_modify_actionfunction mlx5dr_action_create_modify_headerfunction mlx5dr_action_create_dest_vportfunction mlx5dr_action_create_asofunction mlx5dr_action_get_pkt_reformat_idfunction mlx5dr_action_destroy
Annotated Snippet
if (dest_action->dest_tbl->is_fw_tbl) {
*final_icm_addr = dest_action->dest_tbl->fw_tbl.rx_icm_addr;
} else {
mlx5dr_dbg(dmn,
"Destination FT should be terminating when modify TTL is used\n");
return -EINVAL;
}
break;
case DR_ACTION_TYP_VPORT:
/* If destination is vport we will get the FW flow table
* that recalculates the CS and forwards to the vport.
*/
ret = mlx5dr_domain_get_recalc_cs_ft_addr(dest_action->vport->dmn,
dest_action->vport->caps->num,
final_icm_addr);
if (ret) {
mlx5dr_err(dmn, "Failed to get FW cs recalc flow table\n");
return ret;
}
break;
default:
break;
}
return 0;
}
static void dr_action_modify_ttl_adjust(struct mlx5dr_domain *dmn,
struct mlx5dr_ste_actions_attr *attr,
bool rx_rule,
bool *recalc_cs_required)
{
*recalc_cs_required = false;
/* if device supports csum recalculation - no adjustment needed */
if (mlx5dr_ste_supp_ttl_cs_recalc(&dmn->info.caps))
return;
/* no adjustment needed on TX rules */
if (!rx_rule)
return;
if (!MLX5_CAP_ESW_FLOWTABLE(dmn->mdev, fdb_ipv4_ttl_modify)) {
/* Ignore the modify TTL action.
* It is always kept as last HW action.
*/
attr->modify_actions--;
return;
}
if (dmn->type == MLX5DR_DOMAIN_TYPE_FDB)
/* Due to a HW bug on some devices, modifying TTL on RX flows
* will cause an incorrect checksum calculation. In such cases
* we will use a FW table to recalculate the checksum.
*/
*recalc_cs_required = true;
}
static void dr_action_print_sequence(struct mlx5dr_domain *dmn,
struct mlx5dr_action *actions[],
int last_idx)
{
int i;
for (i = 0; i <= last_idx; i++)
mlx5dr_err(dmn, "< %s (%d) > ",
dr_action_id_to_str(actions[i]->action_type),
actions[i]->action_type);
}
static int dr_action_get_dest_fw_tbl_addr(struct mlx5dr_matcher *matcher,
struct mlx5dr_action_dest_tbl *dest_tbl,
bool is_rx_rule,
u64 *final_icm_addr)
{
struct mlx5dr_cmd_query_flow_table_details output;
struct mlx5dr_domain *dmn = matcher->tbl->dmn;
int ret;
if (!dest_tbl->fw_tbl.rx_icm_addr) {
ret = mlx5dr_cmd_query_flow_table(dmn->mdev,
dest_tbl->fw_tbl.type,
dest_tbl->fw_tbl.id,
&output);
if (ret) {
mlx5dr_err(dmn,
"Failed mlx5_cmd_query_flow_table ret: %d\n",
ret);
Annotation
- Immediate include surface: `dr_types.h`, `dr_ste.h`.
- Detected declarations: `enum dr_action_domain`, `enum dr_action_valid_state`, `function mlx5dr_action_supp_fwd_fdb_multi_ft`, `function dr_action_reformat_to_action_type`, `function dr_actions_apply`, `function dr_action_get_action_domain`, `function dr_action_validate_and_get_next_state`, `function dr_action_handle_cs_recalc`, `function dr_action_modify_ttl_adjust`, `function dr_action_print_sequence`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.