Skip to content

Commit ab6912f

Browse files
kliteynkuba-moo
authored andcommitted
net/mlx5: HWS, update flow - remove the use of dual RTCs
This patch is the first part of update flow implementation. Update flow should support rules with single STE (match STE only), as well as rules with multiple STEs (match STE plus action STEs). Supporting the rules with single STE is straightforward: we just overwrite the STE, which is an atomic operation. Supporting the rules with action STEs is a more complicated case. The existing implementation uses two action RTCs per matcher and alternates between the two for each update request. This implementation was unnecessarily complex and lead to some unhandled edge cases, so the support for rule update with multiple STEs wasn't really functional. This patch removes this code, and the next patch adds implementation of a different approach. Note that after applying this patch and before applying the next patch we still have support for update rule with single STE (only match STE w/o action STEs), but update will fail for rules with action STEs. Signed-off-by: Yevgeny Kliteynik <[email protected]> Signed-off-by: Vlad Dogaru <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9fc43b5 commit ab6912f

File tree

6 files changed

+81
-184
lines changed

6 files changed

+81
-184
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ static int hws_debug_dump_matcher(struct seq_file *f, struct mlx5hws_matcher *ma
148148
matcher->match_ste.rtc_1_id,
149149
(int)ste_1_id);
150150

151-
ste = &matcher->action_ste[0].ste;
152-
ste_pool = matcher->action_ste[0].pool;
151+
ste = &matcher->action_ste.ste;
152+
ste_pool = matcher->action_ste.pool;
153153
if (ste_pool) {
154154
ste_0_id = mlx5hws_pool_chunk_get_base_id(ste_pool, ste);
155155
if (tbl_type == MLX5HWS_TABLE_TYPE_FDB)
@@ -171,10 +171,8 @@ static int hws_debug_dump_matcher(struct seq_file *f, struct mlx5hws_matcher *ma
171171
return ret;
172172

173173
seq_printf(f, ",%d,%d,%d,%d,%d,0x%llx,0x%llx\n",
174-
matcher->action_ste[0].rtc_0_id,
175-
(int)ste_0_id,
176-
matcher->action_ste[0].rtc_1_id,
177-
(int)ste_1_id,
174+
matcher->action_ste.rtc_0_id, (int)ste_0_id,
175+
matcher->action_ste.rtc_1_id, (int)ste_1_id,
178176
0,
179177
mlx5hws_debug_icm_to_idx(icm_addr_0),
180178
mlx5hws_debug_icm_to_idx(icm_addr_1));

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#define mlx5hws_dbg(ctx, arg...) mlx5_core_dbg((ctx)->mdev, ##arg)
4040

4141
#define MLX5HWS_TABLE_TYPE_BASE 2
42-
#define MLX5HWS_ACTION_STE_IDX_ANY 0
4342

4443
static inline bool is_mem_zero(const u8 *mem, size_t size)
4544
{

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

Lines changed: 61 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
200200
enum mlx5hws_matcher_rtc_type rtc_type,
201201
bool is_mirror)
202202
{
203-
struct mlx5hws_pool_chunk *ste = &matcher->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].ste;
203+
struct mlx5hws_pool_chunk *ste = &matcher->action_ste.ste;
204204
enum mlx5hws_matcher_flow_src flow_src = matcher->attr.optimize_flow_src;
205205
bool is_match_rtc = rtc_type == HWS_MATCHER_RTC_TYPE_MATCH;
206206

@@ -217,8 +217,7 @@ static void hws_matcher_set_rtc_attr_sz(struct mlx5hws_matcher *matcher,
217217
}
218218

219219
static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
220-
enum mlx5hws_matcher_rtc_type rtc_type,
221-
u8 action_ste_selector)
220+
enum mlx5hws_matcher_rtc_type rtc_type)
222221
{
223222
struct mlx5hws_matcher_attr *attr = &matcher->attr;
224223
struct mlx5hws_cmd_rtc_create_attr rtc_attr = {0};
@@ -278,7 +277,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
278277
break;
279278

280279
case HWS_MATCHER_RTC_TYPE_STE_ARRAY:
281-
action_ste = &matcher->action_ste[action_ste_selector];
280+
action_ste = &matcher->action_ste;
282281

283282
rtc_0_id = &action_ste->rtc_0_id;
284283
rtc_1_id = &action_ste->rtc_1_id;
@@ -350,8 +349,7 @@ static int hws_matcher_create_rtc(struct mlx5hws_matcher *matcher,
350349
}
351350

352351
static void hws_matcher_destroy_rtc(struct mlx5hws_matcher *matcher,
353-
enum mlx5hws_matcher_rtc_type rtc_type,
354-
u8 action_ste_selector)
352+
enum mlx5hws_matcher_rtc_type rtc_type)
355353
{
356354
struct mlx5hws_matcher_action_ste *action_ste;
357355
struct mlx5hws_table *tbl = matcher->tbl;
@@ -367,7 +365,7 @@ static void hws_matcher_destroy_rtc(struct mlx5hws_matcher *matcher,
367365
ste = &matcher->match_ste.ste;
368366
break;
369367
case HWS_MATCHER_RTC_TYPE_STE_ARRAY:
370-
action_ste = &matcher->action_ste[action_ste_selector];
368+
action_ste = &matcher->action_ste;
371369
rtc_0_id = action_ste->rtc_0_id;
372370
rtc_1_id = action_ste->rtc_1_id;
373371
ste_pool = action_ste->pool;
@@ -458,20 +456,13 @@ static int hws_matcher_resize_init(struct mlx5hws_matcher *src_matcher)
458456
if (!resize_data)
459457
return -ENOMEM;
460458

461-
resize_data->max_stes = src_matcher->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].max_stes;
462-
463-
resize_data->action_ste[0].stc = src_matcher->action_ste[0].stc;
464-
resize_data->action_ste[0].rtc_0_id = src_matcher->action_ste[0].rtc_0_id;
465-
resize_data->action_ste[0].rtc_1_id = src_matcher->action_ste[0].rtc_1_id;
466-
resize_data->action_ste[0].pool = src_matcher->action_ste[0].max_stes ?
467-
src_matcher->action_ste[0].pool :
468-
NULL;
469-
resize_data->action_ste[1].stc = src_matcher->action_ste[1].stc;
470-
resize_data->action_ste[1].rtc_0_id = src_matcher->action_ste[1].rtc_0_id;
471-
resize_data->action_ste[1].rtc_1_id = src_matcher->action_ste[1].rtc_1_id;
472-
resize_data->action_ste[1].pool = src_matcher->action_ste[1].max_stes ?
473-
src_matcher->action_ste[1].pool :
474-
NULL;
459+
resize_data->max_stes = src_matcher->action_ste.max_stes;
460+
461+
resize_data->stc = src_matcher->action_ste.stc;
462+
resize_data->rtc_0_id = src_matcher->action_ste.rtc_0_id;
463+
resize_data->rtc_1_id = src_matcher->action_ste.rtc_1_id;
464+
resize_data->pool = src_matcher->action_ste.max_stes ?
465+
src_matcher->action_ste.pool : NULL;
475466

476467
/* Place the new resized matcher on the dst matcher's list */
477468
list_add(&resize_data->list_node, &src_matcher->resize_dst->resize_data);
@@ -504,42 +495,60 @@ static void hws_matcher_resize_uninit(struct mlx5hws_matcher *matcher)
504495
if (resize_data->max_stes) {
505496
mlx5hws_action_free_single_stc(matcher->tbl->ctx,
506497
matcher->tbl->type,
507-
&resize_data->action_ste[1].stc);
508-
mlx5hws_action_free_single_stc(matcher->tbl->ctx,
509-
matcher->tbl->type,
510-
&resize_data->action_ste[0].stc);
498+
&resize_data->stc);
511499

512-
if (matcher->tbl->type == MLX5HWS_TABLE_TYPE_FDB) {
500+
if (matcher->tbl->type == MLX5HWS_TABLE_TYPE_FDB)
513501
mlx5hws_cmd_rtc_destroy(matcher->tbl->ctx->mdev,
514-
resize_data->action_ste[1].rtc_1_id);
515-
mlx5hws_cmd_rtc_destroy(matcher->tbl->ctx->mdev,
516-
resize_data->action_ste[0].rtc_1_id);
517-
}
518-
mlx5hws_cmd_rtc_destroy(matcher->tbl->ctx->mdev,
519-
resize_data->action_ste[1].rtc_0_id);
502+
resize_data->rtc_1_id);
503+
520504
mlx5hws_cmd_rtc_destroy(matcher->tbl->ctx->mdev,
521-
resize_data->action_ste[0].rtc_0_id);
522-
if (resize_data->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].pool) {
523-
mlx5hws_pool_destroy(resize_data->action_ste[1].pool);
524-
mlx5hws_pool_destroy(resize_data->action_ste[0].pool);
525-
}
505+
resize_data->rtc_0_id);
506+
507+
if (resize_data->pool)
508+
mlx5hws_pool_destroy(resize_data->pool);
526509
}
527510

528511
kfree(resize_data);
529512
}
530513
}
531514

532-
static int
533-
hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
515+
static int hws_matcher_bind_at(struct mlx5hws_matcher *matcher)
534516
{
517+
bool is_jumbo = mlx5hws_matcher_mt_is_jumbo(matcher->mt);
535518
struct mlx5hws_cmd_stc_modify_attr stc_attr = {0};
536519
struct mlx5hws_matcher_action_ste *action_ste;
537520
struct mlx5hws_table *tbl = matcher->tbl;
538521
struct mlx5hws_pool_attr pool_attr = {0};
539522
struct mlx5hws_context *ctx = tbl->ctx;
540-
int ret;
523+
u32 required_stes;
524+
u8 max_stes = 0;
525+
int i, ret;
541526

542-
action_ste = &matcher->action_ste[action_ste_selector];
527+
if (matcher->flags & MLX5HWS_MATCHER_FLAGS_COLLISION)
528+
return 0;
529+
530+
for (i = 0; i < matcher->num_of_at; i++) {
531+
struct mlx5hws_action_template *at = &matcher->at[i];
532+
533+
ret = hws_matcher_check_and_process_at(matcher, at);
534+
if (ret) {
535+
mlx5hws_err(ctx, "Invalid at %d", i);
536+
return ret;
537+
}
538+
539+
required_stes = at->num_of_action_stes - (!is_jumbo || at->only_term);
540+
max_stes = max(max_stes, required_stes);
541+
542+
/* Future: Optimize reparse */
543+
}
544+
545+
/* There are no additional STEs required for matcher */
546+
if (!max_stes)
547+
return 0;
548+
549+
matcher->action_ste.max_stes = max_stes;
550+
551+
action_ste = &matcher->action_ste;
543552

544553
/* Allocate action STE mempool */
545554
pool_attr.table_type = tbl->type;
@@ -555,7 +564,7 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
555564
}
556565

557566
/* Allocate action RTC */
558-
ret = hws_matcher_create_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY, action_ste_selector);
567+
ret = hws_matcher_create_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY);
559568
if (ret) {
560569
mlx5hws_err(ctx, "Failed to create action RTC\n");
561570
goto free_ste_pool;
@@ -579,84 +588,29 @@ hws_matcher_bind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
579588
return 0;
580589

581590
free_rtc:
582-
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY, action_ste_selector);
591+
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY);
583592
free_ste_pool:
584593
mlx5hws_pool_destroy(action_ste->pool);
585594
return ret;
586595
}
587596

588-
static void hws_matcher_unbind_at_idx(struct mlx5hws_matcher *matcher, u8 action_ste_selector)
597+
static void hws_matcher_unbind_at(struct mlx5hws_matcher *matcher)
589598
{
590599
struct mlx5hws_matcher_action_ste *action_ste;
591600
struct mlx5hws_table *tbl = matcher->tbl;
592601

593-
action_ste = &matcher->action_ste[action_ste_selector];
602+
action_ste = &matcher->action_ste;
594603

595604
if (!action_ste->max_stes ||
596605
matcher->flags & MLX5HWS_MATCHER_FLAGS_COLLISION ||
597606
mlx5hws_matcher_is_in_resize(matcher))
598607
return;
599608

600609
mlx5hws_action_free_single_stc(tbl->ctx, tbl->type, &action_ste->stc);
601-
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY, action_ste_selector);
610+
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_STE_ARRAY);
602611
mlx5hws_pool_destroy(action_ste->pool);
603612
}
604613

605-
static int hws_matcher_bind_at(struct mlx5hws_matcher *matcher)
606-
{
607-
bool is_jumbo = mlx5hws_matcher_mt_is_jumbo(matcher->mt);
608-
struct mlx5hws_table *tbl = matcher->tbl;
609-
struct mlx5hws_context *ctx = tbl->ctx;
610-
u32 required_stes;
611-
u8 max_stes = 0;
612-
int i, ret;
613-
614-
if (matcher->flags & MLX5HWS_MATCHER_FLAGS_COLLISION)
615-
return 0;
616-
617-
for (i = 0; i < matcher->num_of_at; i++) {
618-
struct mlx5hws_action_template *at = &matcher->at[i];
619-
620-
ret = hws_matcher_check_and_process_at(matcher, at);
621-
if (ret) {
622-
mlx5hws_err(ctx, "Invalid at %d", i);
623-
return ret;
624-
}
625-
626-
required_stes = at->num_of_action_stes - (!is_jumbo || at->only_term);
627-
max_stes = max(max_stes, required_stes);
628-
629-
/* Future: Optimize reparse */
630-
}
631-
632-
/* There are no additional STEs required for matcher */
633-
if (!max_stes)
634-
return 0;
635-
636-
matcher->action_ste[0].max_stes = max_stes;
637-
matcher->action_ste[1].max_stes = max_stes;
638-
639-
ret = hws_matcher_bind_at_idx(matcher, 0);
640-
if (ret)
641-
return ret;
642-
643-
ret = hws_matcher_bind_at_idx(matcher, 1);
644-
if (ret)
645-
goto free_at_0;
646-
647-
return 0;
648-
649-
free_at_0:
650-
hws_matcher_unbind_at_idx(matcher, 0);
651-
return ret;
652-
}
653-
654-
static void hws_matcher_unbind_at(struct mlx5hws_matcher *matcher)
655-
{
656-
hws_matcher_unbind_at_idx(matcher, 1);
657-
hws_matcher_unbind_at_idx(matcher, 0);
658-
}
659-
660614
static int hws_matcher_bind_mt(struct mlx5hws_matcher *matcher)
661615
{
662616
struct mlx5hws_context *ctx = matcher->tbl->ctx;
@@ -802,7 +756,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
802756
goto unbind_at;
803757

804758
/* Allocate the RTC for the new matcher */
805-
ret = hws_matcher_create_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH, 0);
759+
ret = hws_matcher_create_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH);
806760
if (ret)
807761
goto destroy_end_ft;
808762

@@ -814,7 +768,7 @@ static int hws_matcher_create_and_connect(struct mlx5hws_matcher *matcher)
814768
return 0;
815769

816770
destroy_rtc:
817-
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH, 0);
771+
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH);
818772
destroy_end_ft:
819773
hws_matcher_destroy_end_ft(matcher);
820774
unbind_at:
@@ -828,7 +782,7 @@ static void hws_matcher_destroy_and_disconnect(struct mlx5hws_matcher *matcher)
828782
{
829783
hws_matcher_resize_uninit(matcher);
830784
hws_matcher_disconnect(matcher);
831-
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH, 0);
785+
hws_matcher_destroy_rtc(matcher, HWS_MATCHER_RTC_TYPE_MATCH);
832786
hws_matcher_destroy_end_ft(matcher);
833787
hws_matcher_unbind_at(matcher);
834788
hws_matcher_unbind_mt(matcher);
@@ -962,10 +916,9 @@ int mlx5hws_matcher_attach_at(struct mlx5hws_matcher *matcher,
962916
return ret;
963917

964918
required_stes = at->num_of_action_stes - (!is_jumbo || at->only_term);
965-
if (matcher->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].max_stes < required_stes) {
919+
if (matcher->action_ste.max_stes < required_stes) {
966920
mlx5hws_dbg(ctx, "Required STEs [%d] exceeds initial action template STE [%d]\n",
967-
required_stes,
968-
matcher->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].max_stes);
921+
required_stes, matcher->action_ste.max_stes);
969922
return -ENOMEM;
970923
}
971924

@@ -1149,8 +1102,7 @@ static int hws_matcher_resize_precheck(struct mlx5hws_matcher *src_matcher,
11491102
return -EINVAL;
11501103
}
11511104

1152-
if (src_matcher->action_ste[MLX5HWS_ACTION_STE_IDX_ANY].max_stes >
1153-
dst_matcher->action_ste[0].max_stes) {
1105+
if (src_matcher->action_ste.max_stes > dst_matcher->action_ste.max_stes) {
11541106
mlx5hws_err(ctx, "Src/dst matcher max STEs mismatch\n");
11551107
return -EINVAL;
11561108
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ struct mlx5hws_matcher_action_ste {
5252
u8 max_stes;
5353
};
5454

55-
struct mlx5hws_matcher_resize_data_node {
55+
struct mlx5hws_matcher_resize_data {
5656
struct mlx5hws_pool_chunk stc;
5757
u32 rtc_0_id;
5858
u32 rtc_1_id;
5959
struct mlx5hws_pool *pool;
60-
};
61-
62-
struct mlx5hws_matcher_resize_data {
63-
struct mlx5hws_matcher_resize_data_node action_ste[2];
6460
u8 max_stes;
6561
struct list_head list_node;
6662
};
@@ -78,7 +74,7 @@ struct mlx5hws_matcher {
7874
struct mlx5hws_matcher *col_matcher;
7975
struct mlx5hws_matcher *resize_dst;
8076
struct mlx5hws_matcher_match_ste match_ste;
81-
struct mlx5hws_matcher_action_ste action_ste[2];
77+
struct mlx5hws_matcher_action_ste action_ste;
8278
struct list_head list_node;
8379
struct list_head resize_data;
8480
};

0 commit comments

Comments
 (0)