]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: core: Extend MLXSW_RXL_DIS to register disabled trap group
authorJiri Pirko <jiri@mellanox.com>
Mon, 24 Feb 2020 07:35:53 +0000 (08:35 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Feb 2020 19:55:07 +0000 (11:55 -0800)
Extend the mlxsw_listener struct to contain trap group for disabled
traps too. Rename the original "trap_group" item to "en_trap_group" as
it represents enabled state. Let both groups be the same for MLXSW_RXL
however extend MLXSW_RXL_DIS to register separate groups for enable and
disable.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c

index 2a451f7e1fead2723c95fbe2245d8c7487f857e2..3da2a4bde2b8b72b6c7d27981328dcd0d9e1caea 100644 (file)
@@ -1645,6 +1645,7 @@ static void mlxsw_core_listener_unregister(struct mlxsw_core *mlxsw_core,
 int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
                             const struct mlxsw_listener *listener, void *priv)
 {
+       enum mlxsw_reg_htgt_trap_group trap_group;
        enum mlxsw_reg_hpkt_action action;
        char hpkt_pl[MLXSW_REG_HPKT_LEN];
        int err;
@@ -1656,8 +1657,10 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
 
        action = listener->enabled_on_register ? listener->en_action :
                                                 listener->dis_action;
+       trap_group = listener->enabled_on_register ? listener->en_trap_group :
+                                                    listener->dis_trap_group;
        mlxsw_reg_hpkt_pack(hpkt_pl, action, listener->trap_id,
-                           listener->trap_group, listener->is_ctrl);
+                           trap_group, listener->is_ctrl);
        err = mlxsw_reg_write(mlxsw_core,  MLXSW_REG(hpkt), hpkt_pl);
        if (err)
                goto err_trap_set;
@@ -1678,7 +1681,7 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core,
 
        if (!listener->is_event) {
                mlxsw_reg_hpkt_pack(hpkt_pl, listener->dis_action,
-                                   listener->trap_id, listener->trap_group,
+                                   listener->trap_id, listener->dis_trap_group,
                                    listener->is_ctrl);
                mlxsw_reg_write(mlxsw_core, MLXSW_REG(hpkt), hpkt_pl);
        }
@@ -1691,6 +1694,7 @@ int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core,
                              const struct mlxsw_listener *listener,
                              bool enabled)
 {
+       enum mlxsw_reg_htgt_trap_group trap_group;
        enum mlxsw_reg_hpkt_action action;
        char hpkt_pl[MLXSW_REG_HPKT_LEN];
        int err;
@@ -1700,8 +1704,10 @@ int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core,
                return -EINVAL;
 
        action = enabled ? listener->en_action : listener->dis_action;
+       trap_group = enabled ? listener->en_trap_group :
+                              listener->dis_trap_group;
        mlxsw_reg_hpkt_pack(hpkt_pl, action, listener->trap_id,
-                           listener->trap_group, listener->is_ctrl);
+                           trap_group, listener->is_ctrl);
        err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(hpkt), hpkt_pl);
        if (err)
                return err;
index b1c2ad214191aeb671ea7c1194f4fff082e6d57b..00e44e778aca7b568eae2a6b0f7e00bdf5e8ea1b 100644 (file)
@@ -78,7 +78,8 @@ struct mlxsw_listener {
        };
        enum mlxsw_reg_hpkt_action en_action; /* Action when enabled */
        enum mlxsw_reg_hpkt_action dis_action; /* Action when disabled */
-       u8 trap_group;
+       u8 en_trap_group; /* Trap group when enabled */
+       u8 dis_trap_group; /* Trap group when disabled */
        u8 is_ctrl:1, /* should go via control buffer or not */
           is_event:1,
           enabled_on_register:1; /* Trap should be enabled when listener
@@ -86,45 +87,46 @@ struct mlxsw_listener {
                                   */
 };
 
-#define __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,        \
-                   _dis_action, _enabled_on_register)                  \
-       {                                                               \
-               .trap_id = MLXSW_TRAP_ID_##_trap_id,                    \
-               .rx_listener =                                          \
-               {                                                       \
-                       .func = _func,                                  \
-                       .local_port = MLXSW_PORT_DONT_CARE,             \
-                       .trap_id = MLXSW_TRAP_ID_##_trap_id,            \
-               },                                                      \
-               .en_action = MLXSW_REG_HPKT_ACTION_##_en_action,        \
-               .dis_action = MLXSW_REG_HPKT_ACTION_##_dis_action,      \
-               .trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group,  \
-               .is_ctrl = _is_ctrl,                                    \
-               .enabled_on_register = _enabled_on_register,            \
+#define __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,     \
+                   _dis_action, _enabled_on_register, _dis_trap_group)         \
+       {                                                                       \
+               .trap_id = MLXSW_TRAP_ID_##_trap_id,                            \
+               .rx_listener =                                                  \
+               {                                                               \
+                       .func = _func,                                          \
+                       .local_port = MLXSW_PORT_DONT_CARE,                     \
+                       .trap_id = MLXSW_TRAP_ID_##_trap_id,                    \
+               },                                                              \
+               .en_action = MLXSW_REG_HPKT_ACTION_##_en_action,                \
+               .dis_action = MLXSW_REG_HPKT_ACTION_##_dis_action,              \
+               .en_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_en_trap_group,    \
+               .dis_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_dis_trap_group,  \
+               .is_ctrl = _is_ctrl,                                            \
+               .enabled_on_register = _enabled_on_register,                    \
        }
 
 #define MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,          \
                  _dis_action)                                                  \
        __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,         \
-                   _dis_action, true)
-
-#define MLXSW_RXL_DIS(_func, _trap_id, _en_action, _is_ctrl, _trap_group,      \
-                     _dis_action)                                              \
-       __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _trap_group,         \
-                   _dis_action, false)
-
-#define MLXSW_EVENTL(_func, _trap_id, _trap_group)                     \
-       {                                                               \
-               .trap_id = MLXSW_TRAP_ID_##_trap_id,                    \
-               .event_listener =                                       \
-               {                                                       \
-                       .func = _func,                                  \
-                       .trap_id = MLXSW_TRAP_ID_##_trap_id,            \
-               },                                                      \
-               .en_action = MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,         \
-               .trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group,  \
-               .is_event = true,                                       \
-               .enabled_on_register = true,                            \
+                   _dis_action, true, _trap_group)
+
+#define MLXSW_RXL_DIS(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,   \
+                     _dis_action, _dis_trap_group)                             \
+       __MLXSW_RXL(_func, _trap_id, _en_action, _is_ctrl, _en_trap_group,      \
+                   _dis_action, false, _dis_trap_group)
+
+#define MLXSW_EVENTL(_func, _trap_id, _trap_group)                             \
+       {                                                                       \
+               .trap_id = MLXSW_TRAP_ID_##_trap_id,                            \
+               .event_listener =                                               \
+               {                                                               \
+                       .func = _func,                                          \
+                       .trap_id = MLXSW_TRAP_ID_##_trap_id,                    \
+               },                                                              \
+               .en_action = MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,                 \
+               .en_trap_group = MLXSW_REG_HTGT_TRAP_GROUP_##_trap_group,       \
+               .is_event = true,                                               \
+               .enabled_on_register = true,                                    \
        }
 
 int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
index afd3f28ec9f62c279ede944ae3b46a6e534517f3..f36d61ce59b29f7a285d5656b3a78178e9bdd6e7 100644 (file)
@@ -120,7 +120,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
 #define MLXSW_SP_RXL_DISCARD(_id, _group_id)                                 \
        MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, DISCARD_##_id,               \
                      TRAP_EXCEPTION_TO_CPU, false, SP_##_group_id,           \
-                     SET_FW_DEFAULT)
+                     SET_FW_DEFAULT, SP_##_group_id)
 
 #define MLXSW_SP_RXL_EXCEPTION(_id, _group_id, _action)                              \
        MLXSW_RXL(mlxsw_sp_rx_exception_listener, _id,                        \