mlxsw: core_acl_flex_actions: Work around hardware limitation
authorIdo Schimmel <idosch@mellanox.com>
Wed, 15 Jul 2020 08:27:27 +0000 (11:27 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Jul 2020 01:10:00 +0000 (18:10 -0700)
commitd25b8f6ebcc451b56faedc2dc666f74628fb1ffc
tree22bebbfc1baca1fa1fad5d45128b993518cc6e80
parentbf038f03728ee2880168aa127f5f871fea6d22ab
mlxsw: core_acl_flex_actions: Work around hardware limitation

In the policy engine, each ACL rule points to an action block where the
ACL actions are stored. Each action block consists of one or more action
sets. Each action set holds one or more individual actions, up to a
maximum queried from the device. For example:

                        Action set #1               Action set #2

+----------+          +--------------+            +--------------+
| ACL rule +---------->  Action #1   |      +----->  Action #4   |
+----------+          +--------------+      |     +--------------+
                      |  Action #2   |      |     |  Action #5   |
                      +--------------+      |     +--------------+
                      |  Action #3   +------+     |              |
                      +--------------+            +--------------+

                      <---------+ Action block +----------------->

The hardware has a limitation that prevents a policing action
(MLXSW_AFA_POLCNT_CODE when used with a policer, not a counter) from
being configured in the same action set with a trap action (i.e.,
MLXSW_AFA_TRAP_CODE or MLXSW_AFA_TRAPWU_CODE). Note that the latter used
to implement multiple actions: 'trap', 'mirred', 'drop'.

Work around this limitation by teaching mlxsw_afa_block_append_action()
to create a new action set not only when there is no more room left in
the current set, but also when there is a conflict between previously
mentioned actions.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c