drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c- Extension
.c- Size
- 24896 bytes
- Lines
- 847
- 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
internal.h
Detected Declarations
function mlx5hws_rule_skipfunction hws_rule_update_copy_tagfunction hws_rule_init_dep_wqefunction hws_rule_move_get_rtcfunction hws_rule_gen_compfunction hws_rule_save_resize_infofunction mlx5hws_rule_clear_resize_infofunction hws_rule_save_delete_infofunction hws_rule_clear_delete_infofunction mlx5hws_rule_alloc_action_stefunction mlx5hws_rule_free_action_stefunction hws_rule_create_initfunction hws_rule_move_initfunction mlx5hws_rule_move_in_progressfunction hws_rule_create_hwsfunction hws_rule_destroy_failed_hwsfunction hws_rule_destroy_hwsfunction hws_rule_enqueue_precheckfunction hws_rule_enqueue_precheck_movefunction hws_rule_enqueue_precheck_createfunction hws_rule_enqueue_precheck_updatefunction mlx5hws_rule_move_hws_removefunction mlx5hws_rule_move_hws_addfunction hws_rule_ethertype_to_matcher_ipvfunction hws_rule_ip_version_to_matcher_ipvfunction hws_rule_check_outer_ip_versionfunction hws_rule_check_inner_ip_versionfunction hws_rule_check_ip_versionfunction mlx5hws_rule_createfunction mlx5hws_rule_destroyfunction mlx5hws_rule_action_update
Annotated Snippet
if (!skip_rx) {
dep_wqe->rtc_0 = matcher->match_ste.rtc_0_id;
dep_wqe->retry_rtc_0 = matcher->col_matcher ?
matcher->col_matcher->match_ste.rtc_0_id : 0;
} else {
dep_wqe->rtc_0 = 0;
dep_wqe->retry_rtc_0 = 0;
}
if (!skip_tx) {
dep_wqe->rtc_1 = matcher->match_ste.rtc_1_id;
dep_wqe->retry_rtc_1 = matcher->col_matcher ?
matcher->col_matcher->match_ste.rtc_1_id : 0;
} else {
dep_wqe->rtc_1 = 0;
dep_wqe->retry_rtc_1 = 0;
}
} else {
pr_warn("HWS: invalid tbl->type: %d\n", tbl->type);
}
}
static void hws_rule_move_get_rtc(struct mlx5hws_rule *rule,
struct mlx5hws_send_ste_attr *ste_attr)
{
struct mlx5hws_matcher *dst_matcher = rule->matcher->resize_dst;
if (rule->resize_info->rtc_0) {
ste_attr->rtc_0 = dst_matcher->match_ste.rtc_0_id;
ste_attr->retry_rtc_0 = dst_matcher->col_matcher ?
dst_matcher->col_matcher->match_ste.rtc_0_id : 0;
}
if (rule->resize_info->rtc_1) {
ste_attr->rtc_1 = dst_matcher->match_ste.rtc_1_id;
ste_attr->retry_rtc_1 = dst_matcher->col_matcher ?
dst_matcher->col_matcher->match_ste.rtc_1_id : 0;
}
}
static void hws_rule_gen_comp(struct mlx5hws_send_engine *queue,
struct mlx5hws_rule *rule,
bool err,
void *user_data,
enum mlx5hws_rule_status rule_status_on_succ)
{
enum mlx5hws_flow_op_status comp_status;
if (!err) {
comp_status = MLX5HWS_FLOW_OP_SUCCESS;
rule->status = rule_status_on_succ;
} else {
comp_status = MLX5HWS_FLOW_OP_ERROR;
rule->status = MLX5HWS_RULE_STATUS_FAILED;
}
mlx5hws_send_engine_inc_rule(queue);
mlx5hws_send_engine_gen_comp(queue, user_data, comp_status);
}
static void
hws_rule_save_resize_info(struct mlx5hws_rule *rule,
struct mlx5hws_send_ste_attr *ste_attr)
{
if (!mlx5hws_matcher_is_resizable(rule->matcher))
return;
/* resize_info might already exist (if we're in update flow) */
if (likely(!rule->resize_info)) {
rule->resize_info = kzalloc_obj(*rule->resize_info);
if (unlikely(!rule->resize_info)) {
pr_warn("HWS: resize info isn't allocated for rule\n");
return;
}
}
memcpy(rule->resize_info->ctrl_seg, ste_attr->wqe_ctrl,
sizeof(rule->resize_info->ctrl_seg));
memcpy(rule->resize_info->data_seg, ste_attr->wqe_data,
sizeof(rule->resize_info->data_seg));
}
void mlx5hws_rule_clear_resize_info(struct mlx5hws_rule *rule)
{
if (mlx5hws_matcher_is_resizable(rule->matcher) &&
rule->resize_info) {
kfree(rule->resize_info);
rule->resize_info = NULL;
}
}
Annotation
- Immediate include surface: `internal.h`.
- Detected declarations: `function mlx5hws_rule_skip`, `function hws_rule_update_copy_tag`, `function hws_rule_init_dep_wqe`, `function hws_rule_move_get_rtc`, `function hws_rule_gen_comp`, `function hws_rule_save_resize_info`, `function mlx5hws_rule_clear_resize_info`, `function hws_rule_save_delete_info`, `function hws_rule_clear_delete_info`, `function mlx5hws_rule_alloc_action_ste`.
- 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.