Skip to content

Commit ec12165

Browse files
jpirkodavem330
authored andcommitted
mlxsw: core_acl_flex_actions: Add trap with userdef action
Expose "Trap action with userdef". It is the same as already defined "Trap action" with a difference that it would ask the policy engine to pass arbitrary value (userdef) alongside with received packets. This would be later on used to carry cookie index. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5a2e106 commit ec12165

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,18 +747,25 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
747747
}
748748
EXPORT_SYMBOL(mlxsw_afa_block_append_vlan_modify);
749749

750-
/* Trap Action
751-
* -----------
750+
/* Trap Action / Trap With Userdef Action
751+
* --------------------------------------
752752
* The Trap action enables trapping / mirroring packets to the CPU
753753
* as well as discarding packets.
754754
* The ACL Trap / Discard separates the forward/discard control from CPU
755755
* trap control. In addition, the Trap / Discard action enables activating
756756
* SPAN (port mirroring).
757+
*
758+
* The Trap with userdef action action has the same functionality as
759+
* the Trap action with addition of user defined value that can be set
760+
* and used by higher layer applications.
757761
*/
758762

759763
#define MLXSW_AFA_TRAP_CODE 0x03
760764
#define MLXSW_AFA_TRAP_SIZE 1
761765

766+
#define MLXSW_AFA_TRAPWU_CODE 0x04
767+
#define MLXSW_AFA_TRAPWU_SIZE 2
768+
762769
enum mlxsw_afa_trap_trap_action {
763770
MLXSW_AFA_TRAP_TRAP_ACTION_NOP = 0,
764771
MLXSW_AFA_TRAP_TRAP_ACTION_TRAP = 2,
@@ -794,6 +801,15 @@ MLXSW_ITEM32(afa, trap, mirror_agent, 0x08, 29, 3);
794801
*/
795802
MLXSW_ITEM32(afa, trap, mirror_enable, 0x08, 24, 1);
796803

804+
/* user_def_val
805+
* Value for the SW usage. Can be used to pass information of which
806+
* rule has caused a trap. This may be overwritten by later traps.
807+
* This field does a set on the packet's user_def_val only if this
808+
* is the first trap_id or if the trap_id has replaced the previous
809+
* packet's trap_id.
810+
*/
811+
MLXSW_ITEM32(afa, trap, user_def_val, 0x0C, 0, 20);
812+
797813
static inline void
798814
mlxsw_afa_trap_pack(char *payload,
799815
enum mlxsw_afa_trap_trap_action trap_action,
@@ -805,6 +821,16 @@ mlxsw_afa_trap_pack(char *payload,
805821
mlxsw_afa_trap_trap_id_set(payload, trap_id);
806822
}
807823

824+
static inline void
825+
mlxsw_afa_trapwu_pack(char *payload,
826+
enum mlxsw_afa_trap_trap_action trap_action,
827+
enum mlxsw_afa_trap_forward_action forward_action,
828+
u16 trap_id, u32 user_def_val)
829+
{
830+
mlxsw_afa_trap_pack(payload, trap_action, forward_action, trap_id);
831+
mlxsw_afa_trap_user_def_val_set(payload, user_def_val);
832+
}
833+
808834
static inline void
809835
mlxsw_afa_trap_mirror_pack(char *payload, bool mirror_enable,
810836
u8 mirror_agent)

0 commit comments

Comments
 (0)