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.

Dependency Surface

Detected Declarations

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

Implementation Notes