Skip to content

Commit ef7b79b

Browse files
mark-blochkuba-moo
authored andcommitted
net/mlx5: fs, separate action and destination into distinct struct
Introduce a dedicated structure to encapsulate flow context, actions, destination count, and modification mask. This refactoring lays the groundwork for forthcoming patches that will integrate the NO APPEND software logic. Future modifications should focus solely on these specific fields. Signed-off-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8ad0e96 commit ef7b79b

File tree

5 files changed

+104
-98
lines changed

5 files changed

+104
-98
lines changed

drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ TRACE_EVENT(mlx5_fs_set_fte,
203203
fs_get_obj(__entry->fg, fte->node.parent);
204204
__entry->group_index = __entry->fg->id;
205205
__entry->index = fte->index;
206-
__entry->action = fte->action.action;
206+
__entry->action = fte->act_dests.action.action;
207207
__entry->mask_enable = __entry->fg->mask.match_criteria_enable;
208-
__entry->flow_tag = fte->flow_context.flow_tag;
209-
__entry->flow_source = fte->flow_context.flow_source;
208+
__entry->flow_tag = fte->act_dests.flow_context.flow_tag;
209+
__entry->flow_source = fte->act_dests.flow_context.flow_source;
210210
memcpy(__entry->mask_outer,
211211
MLX5_ADDR_OF(fte_match_param,
212212
&__entry->fg->mask.match_criteria,
@@ -284,7 +284,7 @@ TRACE_EVENT(mlx5_fs_add_rule,
284284
TP_fast_assign(
285285
__entry->rule = rule;
286286
fs_get_obj(__entry->fte, rule->node.parent);
287-
__entry->index = __entry->fte->dests_size - 1;
287+
__entry->index = __entry->fte->act_dests.dests_size - 1;
288288
__entry->sw_action = rule->sw_action;
289289
memcpy(__entry->destination,
290290
&rule->dest_attr,

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static int mlx5_set_extended_dest(struct mlx5_core_dev *dev,
463463
int num_encap = 0;
464464

465465
*extended_dest = false;
466-
if (!(fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST))
466+
if (!(fte->act_dests.action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST))
467467
return 0;
468468

469469
list_for_each_entry(dst, &fte->node.children, node.list) {
@@ -502,17 +502,17 @@ mlx5_cmd_set_fte_flow_meter(struct fs_fte *fte, void *in_flow_context)
502502
execute_aso[0]);
503503
MLX5_SET(execute_aso, execute_aso, valid, 1);
504504
MLX5_SET(execute_aso, execute_aso, aso_object_id,
505-
fte->action.exe_aso.object_id);
505+
fte->act_dests.action.exe_aso.object_id);
506506

507507
exe_aso_ctrl = MLX5_ADDR_OF(execute_aso, execute_aso, exe_aso_ctrl);
508508
MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, return_reg_id,
509-
fte->action.exe_aso.return_reg_id);
509+
fte->act_dests.action.exe_aso.return_reg_id);
510510
MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, aso_type,
511-
fte->action.exe_aso.type);
511+
fte->act_dests.action.exe_aso.type);
512512
MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, init_color,
513-
fte->action.exe_aso.flow_meter.init_color);
513+
fte->act_dests.action.exe_aso.flow_meter.init_color);
514514
MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, meter_id,
515-
fte->action.exe_aso.flow_meter.meter_idx);
515+
fte->act_dests.action.exe_aso.flow_meter.meter_idx);
516516
}
517517

518518
static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
@@ -541,7 +541,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
541541
else
542542
dst_cnt_size = MLX5_ST_SZ_BYTES(extended_dest_format);
543543

544-
inlen = MLX5_ST_SZ_BYTES(set_fte_in) + fte->dests_size * dst_cnt_size;
544+
inlen = MLX5_ST_SZ_BYTES(set_fte_in) + fte->act_dests.dests_size * dst_cnt_size;
545545
in = kvzalloc(inlen, GFP_KERNEL);
546546
if (!in)
547547
return -ENOMEM;
@@ -553,7 +553,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
553553
MLX5_SET(set_fte_in, in, table_id, ft->id);
554554
MLX5_SET(set_fte_in, in, flow_index, fte->index);
555555
MLX5_SET(set_fte_in, in, ignore_flow_level,
556-
!!(fte->action.flags & FLOW_ACT_IGNORE_FLOW_LEVEL));
556+
!!(fte->act_dests.action.flags & FLOW_ACT_IGNORE_FLOW_LEVEL));
557557

558558
MLX5_SET(set_fte_in, in, vport_number, ft->vport);
559559
MLX5_SET(set_fte_in, in, other_vport,
@@ -563,23 +563,23 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
563563
MLX5_SET(flow_context, in_flow_context, group_id, group_id);
564564

565565
MLX5_SET(flow_context, in_flow_context, flow_tag,
566-
fte->flow_context.flow_tag);
566+
fte->act_dests.flow_context.flow_tag);
567567
MLX5_SET(flow_context, in_flow_context, flow_source,
568-
fte->flow_context.flow_source);
568+
fte->act_dests.flow_context.flow_source);
569569
MLX5_SET(flow_context, in_flow_context, uplink_hairpin_en,
570-
!!(fte->flow_context.flags & FLOW_CONTEXT_UPLINK_HAIRPIN_EN));
570+
!!(fte->act_dests.flow_context.flags & FLOW_CONTEXT_UPLINK_HAIRPIN_EN));
571571

572572
MLX5_SET(flow_context, in_flow_context, extended_destination,
573573
extended_dest);
574574

575-
action = fte->action.action;
575+
action = fte->act_dests.action.action;
576576
if (extended_dest)
577577
action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
578578

579579
MLX5_SET(flow_context, in_flow_context, action, action);
580580

581-
if (!extended_dest && fte->action.pkt_reformat) {
582-
struct mlx5_pkt_reformat *pkt_reformat = fte->action.pkt_reformat;
581+
if (!extended_dest && fte->act_dests.action.pkt_reformat) {
582+
struct mlx5_pkt_reformat *pkt_reformat = fte->act_dests.action.pkt_reformat;
583583

584584
if (pkt_reformat->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
585585
reformat_id = mlx5_fs_dr_action_get_pkt_reformat_id(pkt_reformat);
@@ -591,46 +591,46 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
591591
goto err_out;
592592
}
593593
} else {
594-
reformat_id = fte->action.pkt_reformat->id;
594+
reformat_id = fte->act_dests.action.pkt_reformat->id;
595595
}
596596
}
597597

598598
MLX5_SET(flow_context, in_flow_context, packet_reformat_id, (u32)reformat_id);
599599

600-
if (fte->action.modify_hdr) {
601-
if (fte->action.modify_hdr->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
600+
if (fte->act_dests.action.modify_hdr) {
601+
if (fte->act_dests.action.modify_hdr->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
602602
mlx5_core_err(dev, "Can't use SW-owned modify_hdr in FW-owned table\n");
603603
err = -EOPNOTSUPP;
604604
goto err_out;
605605
}
606606

607607
MLX5_SET(flow_context, in_flow_context, modify_header_id,
608-
fte->action.modify_hdr->id);
608+
fte->act_dests.action.modify_hdr->id);
609609
}
610610

611611
MLX5_SET(flow_context, in_flow_context, encrypt_decrypt_type,
612-
fte->action.crypto.type);
612+
fte->act_dests.action.crypto.type);
613613
MLX5_SET(flow_context, in_flow_context, encrypt_decrypt_obj_id,
614-
fte->action.crypto.obj_id);
614+
fte->act_dests.action.crypto.obj_id);
615615

616616
vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan);
617617

618-
MLX5_SET(vlan, vlan, ethtype, fte->action.vlan[0].ethtype);
619-
MLX5_SET(vlan, vlan, vid, fte->action.vlan[0].vid);
620-
MLX5_SET(vlan, vlan, prio, fte->action.vlan[0].prio);
618+
MLX5_SET(vlan, vlan, ethtype, fte->act_dests.action.vlan[0].ethtype);
619+
MLX5_SET(vlan, vlan, vid, fte->act_dests.action.vlan[0].vid);
620+
MLX5_SET(vlan, vlan, prio, fte->act_dests.action.vlan[0].prio);
621621

622622
vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan_2);
623623

624-
MLX5_SET(vlan, vlan, ethtype, fte->action.vlan[1].ethtype);
625-
MLX5_SET(vlan, vlan, vid, fte->action.vlan[1].vid);
626-
MLX5_SET(vlan, vlan, prio, fte->action.vlan[1].prio);
624+
MLX5_SET(vlan, vlan, ethtype, fte->act_dests.action.vlan[1].ethtype);
625+
MLX5_SET(vlan, vlan, vid, fte->act_dests.action.vlan[1].vid);
626+
MLX5_SET(vlan, vlan, prio, fte->act_dests.action.vlan[1].prio);
627627

628628
in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context,
629629
match_value);
630630
memcpy(in_match_value, &fte->val, sizeof(fte->val));
631631

632632
in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination);
633-
if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
633+
if (fte->act_dests.action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
634634
int list_size = 0;
635635

636636
list_for_each_entry(dst, &fte->node.children, node.list) {
@@ -706,7 +706,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
706706
list_size);
707707
}
708708

709-
if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
709+
if (fte->act_dests.action.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
710710
int max_list_size = BIT(MLX5_CAP_FLOWTABLE_TYPE(dev,
711711
log_max_flow_counter,
712712
ft->type));
@@ -731,8 +731,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
731731
list_size);
732732
}
733733

734-
if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO) {
735-
if (fte->action.exe_aso.type == MLX5_EXE_ASO_FLOW_METER) {
734+
if (fte->act_dests.action.action & MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO) {
735+
if (fte->act_dests.action.exe_aso.type == MLX5_EXE_ASO_FLOW_METER) {
736736
mlx5_cmd_set_fte_flow_meter(fte, in_flow_context);
737737
} else {
738738
err = -EOPNOTSUPP;

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,12 @@ static void modify_fte(struct fs_fte *fte)
605605
dev = get_dev(&fte->node);
606606

607607
root = find_root(&ft->node);
608-
err = root->cmds->update_fte(root, ft, fg, fte->modify_mask, fte);
608+
err = root->cmds->update_fte(root, ft, fg, fte->act_dests.modify_mask, fte);
609609
if (err)
610610
mlx5_core_warn(dev,
611611
"%s can't del rule fg id=%d fte_index=%d\n",
612612
__func__, fg->id, fte->index);
613-
fte->modify_mask = 0;
613+
fte->act_dests.modify_mask = 0;
614614
}
615615

616616
static void del_sw_hw_rule(struct fs_node *node)
@@ -628,29 +628,29 @@ static void del_sw_hw_rule(struct fs_node *node)
628628
}
629629

630630
if (rule->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER) {
631-
--fte->dests_size;
632-
fte->modify_mask |=
631+
--fte->act_dests.dests_size;
632+
fte->act_dests.modify_mask |=
633633
BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION) |
634634
BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_FLOW_COUNTERS);
635-
fte->action.action &= ~MLX5_FLOW_CONTEXT_ACTION_COUNT;
635+
fte->act_dests.action.action &= ~MLX5_FLOW_CONTEXT_ACTION_COUNT;
636636
goto out;
637637
}
638638

639639
if (rule->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_PORT) {
640-
--fte->dests_size;
641-
fte->modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
642-
fte->action.action &= ~MLX5_FLOW_CONTEXT_ACTION_ALLOW;
640+
--fte->act_dests.dests_size;
641+
fte->act_dests.modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
642+
fte->act_dests.action.action &= ~MLX5_FLOW_CONTEXT_ACTION_ALLOW;
643643
goto out;
644644
}
645645

646646
if (is_fwd_dest_type(rule->dest_attr.type)) {
647-
--fte->dests_size;
648-
--fte->fwd_dests;
647+
--fte->act_dests.dests_size;
648+
--fte->act_dests.fwd_dests;
649649

650-
if (!fte->fwd_dests)
651-
fte->action.action &=
650+
if (!fte->act_dests.fwd_dests)
651+
fte->act_dests.action.action &=
652652
~MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
653-
fte->modify_mask |=
653+
fte->act_dests.modify_mask |=
654654
BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_DESTINATION_LIST);
655655
goto out;
656656
}
@@ -672,7 +672,7 @@ static void del_hw_fte(struct fs_node *node)
672672
fs_get_obj(ft, fg->node.parent);
673673

674674
trace_mlx5_fs_del_fte(fte);
675-
WARN_ON(fte->dests_size);
675+
WARN_ON(fte->act_dests.dests_size);
676676
dev = get_dev(&ft->node);
677677
root = find_root(&ft->node);
678678
if (node->active) {
@@ -784,8 +784,8 @@ static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft,
784784

785785
memcpy(fte->val, &spec->match_value, sizeof(fte->val));
786786
fte->node.type = FS_TYPE_FLOW_ENTRY;
787-
fte->action = *flow_act;
788-
fte->flow_context = spec->flow_context;
787+
fte->act_dests.action = *flow_act;
788+
fte->act_dests.flow_context = spec->flow_context;
789789

790790
tree_init_node(&fte->node, del_hw_fte, del_sw_fte);
791791

@@ -1116,7 +1116,7 @@ static int _mlx5_modify_rule_destination(struct mlx5_flow_rule *rule,
11161116
int err = 0;
11171117

11181118
fs_get_obj(fte, rule->node.parent);
1119-
if (!(fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST))
1119+
if (!(fte->act_dests.action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST))
11201120
return -EINVAL;
11211121
down_write_ref_node(&fte->node, false);
11221122
fs_get_obj(fg, fte->node.parent);
@@ -1462,7 +1462,7 @@ static void destroy_flow_handle(struct fs_fte *fte,
14621462
{
14631463
for (; --i >= 0;) {
14641464
if (refcount_dec_and_test(&handle->rule[i]->node.refcount)) {
1465-
fte->dests_size--;
1465+
fte->act_dests.dests_size--;
14661466
list_del(&handle->rule[i]->node.list);
14671467
kfree(handle->rule[i]);
14681468
}
@@ -1512,10 +1512,10 @@ create_flow_handle(struct fs_fte *fte,
15121512
else
15131513
list_add_tail(&rule->node.list, &fte->node.children);
15141514
if (dest) {
1515-
fte->dests_size++;
1515+
fte->act_dests.dests_size++;
15161516

15171517
if (is_fwd_dest_type(dest[i].type))
1518-
fte->fwd_dests++;
1518+
fte->act_dests.fwd_dests++;
15191519

15201520
type = dest[i].type ==
15211521
MLX5_FLOW_DESTINATION_TYPE_COUNTER;
@@ -1776,17 +1776,17 @@ static int check_conflicting_ftes(struct fs_fte *fte,
17761776
const struct mlx5_flow_context *flow_context,
17771777
const struct mlx5_flow_act *flow_act)
17781778
{
1779-
if (check_conflicting_actions(flow_act, &fte->action)) {
1779+
if (check_conflicting_actions(flow_act, &fte->act_dests.action)) {
17801780
mlx5_core_warn(get_dev(&fte->node),
17811781
"Found two FTEs with conflicting actions\n");
17821782
return -EEXIST;
17831783
}
17841784

17851785
if ((flow_context->flags & FLOW_CONTEXT_HAS_TAG) &&
1786-
fte->flow_context.flow_tag != flow_context->flow_tag) {
1786+
fte->act_dests.flow_context.flow_tag != flow_context->flow_tag) {
17871787
mlx5_core_warn(get_dev(&fte->node),
17881788
"FTE flow tag %u already exists with different flow tag %u\n",
1789-
fte->flow_context.flow_tag,
1789+
fte->act_dests.flow_context.flow_tag,
17901790
flow_context->flow_tag);
17911791
return -EEXIST;
17921792
}
@@ -1810,12 +1810,12 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
18101810
if (ret)
18111811
return ERR_PTR(ret);
18121812

1813-
old_action = fte->action.action;
1814-
fte->action.action |= flow_act->action;
1813+
old_action = fte->act_dests.action.action;
1814+
fte->act_dests.action.action |= flow_act->action;
18151815
handle = add_rule_fte(fte, fg, dest, dest_num,
18161816
old_action != flow_act->action);
18171817
if (IS_ERR(handle)) {
1818-
fte->action.action = old_action;
1818+
fte->act_dests.action.action = old_action;
18191819
return handle;
18201820
}
18211821
trace_mlx5_fs_set_fte(fte, false);
@@ -2269,8 +2269,8 @@ void mlx5_del_flow_rules(struct mlx5_flow_handle *handle)
22692269
fte->node.del_hw_func(&fte->node);
22702270
up_write_ref_node(&fte->node, false);
22712271
tree_put_node(&fte->node, false);
2272-
} else if (fte->dests_size) {
2273-
if (fte->modify_mask)
2272+
} else if (fte->act_dests.dests_size) {
2273+
if (fte->act_dests.modify_mask)
22742274
modify_fte(fte);
22752275
up_write_ref_node(&fte->node, false);
22762276
} else {

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,23 @@ struct mlx5_ft_underlay_qp {
230230
MLX5_BYTE_OFF(fte_match_param, \
231231
MLX5_FTE_MATCH_PARAM_RESERVED)))
232232

233+
struct fs_fte_action {
234+
int modify_mask;
235+
u32 dests_size;
236+
u32 fwd_dests;
237+
struct mlx5_flow_context flow_context;
238+
struct mlx5_flow_act action;
239+
};
240+
233241
/* Type of children is mlx5_flow_rule */
234242
struct fs_fte {
235243
struct fs_node node;
236244
struct mlx5_fs_dr_rule fs_dr_rule;
237245
u32 val[MLX5_ST_SZ_DW_MATCH_PARAM];
238-
u32 dests_size;
239-
u32 fwd_dests;
246+
struct fs_fte_action act_dests;
240247
u32 index;
241-
struct mlx5_flow_context flow_context;
242-
struct mlx5_flow_act action;
243248
enum fs_fte_status status;
244249
struct rhash_head hash;
245-
int modify_mask;
246250
};
247251

248252
/* Type of children is mlx5_flow_table/namespace */

0 commit comments

Comments
 (0)