drivers/net/ethernet/mellanox/mlx5/core/steering/hws/matcher.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/matcher.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/matcher.c
Extension
.c
Size
35639 bytes
Lines
1293
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 (tmp_matcher->attr.priority > matcher->attr.priority) {
			next = tmp_matcher;
			break;
		}
		prev = tmp_matcher;
	}

	if (next)
		/* insert before next */
		list_add_tail(&matcher->list_node, &next->list_node);
	else
		/* insert after prev */
		list_add(&matcher->list_node, &prev->list_node);

connect:
	if (next) {
		/* Connect to next RTC */
		ret = mlx5hws_table_ft_set_next_rtc(ctx,
						    matcher->end_ft_id,
						    tbl->fw_ft_type,
						    next->match_ste.rtc_0_id,
						    next->match_ste.rtc_1_id);
		if (ret) {
			mlx5hws_err(ctx, "Failed to connect new matcher to next RTC\n");
			goto remove_from_list;
		}
	} else {
		/* Connect last matcher to next miss_tbl if exists */
		ret = mlx5hws_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl);
		if (ret) {
			mlx5hws_err(ctx, "Failed connect new matcher to miss_tbl\n");
			goto remove_from_list;
		}
	}

	/* Connect to previous FT */
	ret = mlx5hws_table_ft_set_next_rtc(ctx,
					    prev ? prev->end_ft_id : tbl->ft_id,
					    tbl->fw_ft_type,
					    matcher->match_ste.rtc_0_id,
					    matcher->match_ste.rtc_1_id);
	if (ret) {
		mlx5hws_err(ctx, "Failed to connect new matcher to previous FT\n");
		goto remove_from_list;
	}

	/* Reset prev matcher FT default miss (drop refcount) */
	ret = mlx5hws_table_ft_set_default_next_ft(tbl, prev ? prev->end_ft_id : tbl->ft_id);
	if (ret) {
		mlx5hws_err(ctx, "Failed to reset matcher ft default miss\n");
		goto remove_from_list;
	}

	if (!prev) {
		/* Update tables missing to current matcher in the table */
		ret = mlx5hws_table_update_connected_miss_tables(tbl);
		if (ret) {
			mlx5hws_err(ctx, "Fatal error, failed to update connected miss table\n");
			goto remove_from_list;
		}
	}

	return 0;

remove_from_list:
	list_del_init(&matcher->list_node);
	return ret;
}

static int hws_matcher_disconnect_isolated(struct mlx5hws_matcher *matcher)
{
	struct mlx5hws_matcher *first, *last, *prev, *next;
	struct mlx5hws_table *tbl = matcher->tbl;
	struct mlx5hws_context *ctx = tbl->ctx;
	u32 end_ft_id;
	int ret;

	first = list_first_entry(&tbl->matchers_list,
				 struct mlx5hws_matcher,
				 list_node);
	last = list_last_entry(&tbl->matchers_list,
			       struct mlx5hws_matcher,
			       list_node);
	prev = list_prev_entry(matcher, list_node);
	next = list_next_entry(matcher, list_node);

	list_del_init(&matcher->list_node);

	if (first == last) {
		/* This was the only matcher in the list.

Annotation

Implementation Notes