Skip to content

Commit c20580c

Browse files
nirdotandavem330
authored andcommitted
mlxsw: spectrum_acl: Support rule creation without action creation
Up until now, when ACL rule was created its action was created with it. It suits well for tc flower where ACL rule always needs an action, however it does not suit multicast router, where the action is created prior to setting a route, which in Spectrum-2 is actually an ACL rule. Add support for rule creation without action creation. Do it by adding afa_block argument to mlxsw_sp_acl_rule_create, which if NULL then an action would be created, also add an indication within struct mlxsw_sp_acl_rule_info that tells if the action should be destroyed when the rule is destroyed. Signed-off-by: Nir Dotan <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2507a64 commit c20580c

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ struct mlxsw_sp_acl_rule_info {
563563
unsigned int priority;
564564
struct mlxsw_afk_element_values values;
565565
struct mlxsw_afa_block *act_block;
566+
u8 action_created:1;
566567
unsigned int counter_index;
567568
};
568569

@@ -607,7 +608,8 @@ void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
607608
u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
608609

609610
struct mlxsw_sp_acl_rule_info *
610-
mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
611+
mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
612+
struct mlxsw_afa_block *afa_block);
611613
void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
612614
int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
613615
void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
@@ -651,6 +653,7 @@ struct mlxsw_sp_acl_rule *
651653
mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
652654
struct mlxsw_sp_acl_ruleset *ruleset,
653655
unsigned long cookie,
656+
struct mlxsw_afa_block *afa_block,
654657
struct netlink_ext_ack *extack);
655658
void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
656659
struct mlxsw_sp_acl_rule *rule);

drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mlxsw_sp1_acl_ctcam_region_catchall_add(struct mlxsw_sp *mlxsw_sp,
6767
mlxsw_sp_acl_ctcam_chunk_init(&region->cregion,
6868
&region->catchall.cchunk,
6969
MLXSW_SP_ACL_TCAM_CATCHALL_PRIO);
70-
rulei = mlxsw_sp_acl_rulei_create(mlxsw_sp->acl);
70+
rulei = mlxsw_sp_acl_rulei_create(mlxsw_sp->acl, NULL);
7171
if (IS_ERR(rulei)) {
7272
err = PTR_ERR(rulei);
7373
goto err_rulei_create;

drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,19 +435,27 @@ u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset)
435435
}
436436

437437
struct mlxsw_sp_acl_rule_info *
438-
mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl)
438+
mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
439+
struct mlxsw_afa_block *afa_block)
439440
{
440441
struct mlxsw_sp_acl_rule_info *rulei;
441442
int err;
442443

443444
rulei = kzalloc(sizeof(*rulei), GFP_KERNEL);
444445
if (!rulei)
445446
return NULL;
447+
448+
if (afa_block) {
449+
rulei->act_block = afa_block;
450+
return rulei;
451+
}
452+
446453
rulei->act_block = mlxsw_afa_block_create(acl->mlxsw_sp->afa);
447454
if (IS_ERR(rulei->act_block)) {
448455
err = PTR_ERR(rulei->act_block);
449456
goto err_afa_block_create;
450457
}
458+
rulei->action_created = 1;
451459
return rulei;
452460

453461
err_afa_block_create:
@@ -457,7 +465,8 @@ mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl)
457465

458466
void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei)
459467
{
460-
mlxsw_afa_block_destroy(rulei->act_block);
468+
if (rulei->action_created)
469+
mlxsw_afa_block_destroy(rulei->act_block);
461470
kfree(rulei);
462471
}
463472

@@ -623,6 +632,7 @@ struct mlxsw_sp_acl_rule *
623632
mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
624633
struct mlxsw_sp_acl_ruleset *ruleset,
625634
unsigned long cookie,
635+
struct mlxsw_afa_block *afa_block,
626636
struct netlink_ext_ack *extack)
627637
{
628638
const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
@@ -639,7 +649,7 @@ mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
639649
rule->cookie = cookie;
640650
rule->ruleset = ruleset;
641651

642-
rule->rulei = mlxsw_sp_acl_rulei_create(mlxsw_sp->acl);
652+
rule->rulei = mlxsw_sp_acl_rulei_create(mlxsw_sp->acl, afa_block);
643653
if (IS_ERR(rule->rulei)) {
644654
err = PTR_ERR(rule->rulei);
645655
goto err_rulei_create;

drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
406406
if (IS_ERR(ruleset))
407407
return PTR_ERR(ruleset);
408408

409-
rule = mlxsw_sp_acl_rule_create(mlxsw_sp, ruleset, f->cookie,
409+
rule = mlxsw_sp_acl_rule_create(mlxsw_sp, ruleset, f->cookie, NULL,
410410
f->common.extack);
411411
if (IS_ERR(rule)) {
412412
err = PTR_ERR(rule);

0 commit comments

Comments
 (0)