OSDN Git Service

netdevsim: Register control traps
authorIdo Schimmel <idosch@mellanox.com>
Fri, 29 May 2020 18:36:44 +0000 (21:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Jun 2020 18:49:23 +0000 (11:49 -0700)
Register two control traps with devlink. The existing selftest at
tools/testing/selftests/drivers/net/netdevsim/devlink_trap.sh iterates
over all registered traps and checks that the action of non-drop traps
cannot be changed. Up until now only exception traps were tested, now
control traps will be tested as well.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/dev.c

index 09d947e..ec6b6f7 100644 (file)
@@ -431,6 +431,10 @@ enum {
        DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id,                            \
                             DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id,       \
                             NSIM_TRAP_METADATA)
+#define NSIM_TRAP_CONTROL(_id, _group_id, _action)                           \
+       DEVLINK_TRAP_GENERIC(CONTROL, _action, _id,                           \
+                            DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id,       \
+                            NSIM_TRAP_METADATA)
 #define NSIM_TRAP_DRIVER_EXCEPTION(_id, _group_id)                           \
        DEVLINK_TRAP_DRIVER(EXCEPTION, TRAP, NSIM_TRAP_ID_##_id,              \
                            NSIM_TRAP_NAME_##_id,                             \
@@ -461,6 +465,7 @@ static const struct devlink_trap_group nsim_trap_groups_arr[] = {
        DEVLINK_TRAP_GROUP_GENERIC(L3_EXCEPTIONS, 1),
        DEVLINK_TRAP_GROUP_GENERIC(BUFFER_DROPS, 2),
        DEVLINK_TRAP_GROUP_GENERIC(ACL_DROPS, 3),
+       DEVLINK_TRAP_GROUP_GENERIC(MC_SNOOPING, 3),
 };
 
 static const struct devlink_trap nsim_traps_arr[] = {
@@ -478,6 +483,8 @@ static const struct devlink_trap nsim_traps_arr[] = {
                           DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
        NSIM_TRAP_DROP_EXT(EGRESS_FLOW_ACTION_DROP, ACL_DROPS,
                           DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
+       NSIM_TRAP_CONTROL(IGMP_QUERY, MC_SNOOPING, MIRROR),
+       NSIM_TRAP_CONTROL(IGMP_V1_REPORT, MC_SNOOPING, TRAP),
 };
 
 #define NSIM_TRAP_L4_DATA_LEN 100