mlxsw: spectrum_trap: Register 802.1X packet traps with devlink
authorIdo Schimmel <idosch@nvidia.com>
Tue, 8 Nov 2022 10:47:11 +0000 (11:47 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Nov 2022 03:06:14 +0000 (19:06 -0800)
Register the previously added packet traps with devlink. This allows
user space to tune their policers and in the case of the locked port
trap, user space can set its action to "trap" in order to gain
visibility into packets that were discarded by the device due to the
locked port check failure.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/reg.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
drivers/net/ethernet/mellanox/mlxsw/trap.h

index b74f30e..7240af4 100644 (file)
@@ -6316,6 +6316,7 @@ enum mlxsw_reg_htgt_trap_group {
        MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
        MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
        MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
+       MLXSW_REG_HTGT_TRAP_GROUP_SP_EAPOL,
 
        __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
        MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
index f4bfdb6..899c954 100644 (file)
@@ -510,6 +510,9 @@ mlxsw_sp_trap_policer_items_arr[] = {
        {
                .policer = MLXSW_SP_TRAP_POLICER(20, 10240, 4096),
        },
+       {
+               .policer = MLXSW_SP_TRAP_POLICER(21, 128, 128),
+       },
 };
 
 static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = {
@@ -628,6 +631,11 @@ static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = {
                .hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
                .priority = 4,
        },
+       {
+               .group = DEVLINK_TRAP_GROUP_GENERIC(EAPOL, 21),
+               .hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_EAPOL,
+               .priority = 5,
+       },
 };
 
 static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = {
@@ -1160,6 +1168,23 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = {
                        MLXSW_SP_RXL_DISCARD(ROUTER3, L3_DISCARDS),
                },
        },
+       {
+               .trap = MLXSW_SP_TRAP_CONTROL(EAPOL, EAPOL, TRAP),
+               .listeners_arr = {
+                       MLXSW_SP_RXL_NO_MARK(EAPOL, EAPOL, TRAP_TO_CPU, true),
+               },
+       },
+       {
+               .trap = MLXSW_SP_TRAP_DROP(LOCKED_PORT, L2_DROPS),
+               .listeners_arr = {
+                       MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, FDB_MISS,
+                                     TRAP_EXCEPTION_TO_CPU, false,
+                                     SP_L2_DISCARDS, DISCARD, SP_L2_DISCARDS),
+                       MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, FDB_MISMATCH,
+                                     TRAP_EXCEPTION_TO_CPU, false,
+                                     SP_L2_DISCARDS, DISCARD, SP_L2_DISCARDS),
+               },
+       },
 };
 
 static struct mlxsw_sp_trap_policer_item *
index 8da1696..83477c8 100644 (file)
@@ -25,6 +25,8 @@ enum {
        MLXSW_TRAP_ID_IGMP_V2_LEAVE = 0x33,
        MLXSW_TRAP_ID_IGMP_V3_REPORT = 0x34,
        MLXSW_TRAP_ID_PKT_SAMPLE = 0x38,
+       MLXSW_TRAP_ID_FDB_MISS = 0x3A,
+       MLXSW_TRAP_ID_FDB_MISMATCH = 0x3B,
        MLXSW_TRAP_ID_FID_MISS = 0x3D,
        MLXSW_TRAP_ID_DECAP_ECN0 = 0x40,
        MLXSW_TRAP_ID_MTUERROR = 0x52,