netdevsim: Add support for setting of packet trap group parameters
authorIdo Schimmel <idosch@mellanox.com>
Mon, 30 Mar 2020 19:38:23 +0000 (22:38 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2020 00:54:58 +0000 (17:54 -0700)
Add a dummy callback to set trap group parameters. Return an error when
the 'fail_trap_group_set' debugfs file is set in order to exercise error
paths and verify that error is propagated to user space when should.

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

index bda603cfe66a0e6c09af9ebdd1d2392d07bd4c86..1fe2a93ad382fe856361f222cdcfd3aa502fef95 100644 (file)
@@ -215,6 +215,9 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
                            &nsim_dev->fail_reload);
        debugfs_create_file("trap_flow_action_cookie", 0600, nsim_dev->ddir,
                            nsim_dev, &nsim_dev_trap_fa_cookie_fops);
+       debugfs_create_bool("fail_trap_group_set", 0600,
+                           nsim_dev->ddir,
+                           &nsim_dev->fail_trap_group_set);
        debugfs_create_bool("fail_trap_policer_set", 0600,
                            nsim_dev->ddir,
                            &nsim_dev->fail_trap_policer_set);
@@ -813,6 +816,19 @@ nsim_dev_devlink_trap_action_set(struct devlink *devlink,
        return 0;
 }
 
+static int
+nsim_dev_devlink_trap_group_set(struct devlink *devlink,
+                               const struct devlink_trap_group *group,
+                               const struct devlink_trap_policer *policer)
+{
+       struct nsim_dev *nsim_dev = devlink_priv(devlink);
+
+       if (nsim_dev->fail_trap_group_set)
+               return -EINVAL;
+
+       return 0;
+}
+
 static int
 nsim_dev_devlink_trap_policer_set(struct devlink *devlink,
                                  const struct devlink_trap_policer *policer,
@@ -854,6 +870,7 @@ static const struct devlink_ops nsim_dev_devlink_ops = {
        .flash_update = nsim_dev_flash_update,
        .trap_init = nsim_dev_devlink_trap_init,
        .trap_action_set = nsim_dev_devlink_trap_action_set,
+       .trap_group_set = nsim_dev_devlink_trap_group_set,
        .trap_policer_set = nsim_dev_devlink_trap_policer_set,
        .trap_policer_counter_get = nsim_dev_devlink_trap_policer_counter_get,
 };
index 3d37df5057e86b692168c9e484c64ca3b19470fd..4ded54a21e1e854ad4a8ddb4e3c01b503c33a7d0 100644 (file)
@@ -180,6 +180,7 @@ struct nsim_dev {
        struct nsim_dev_health health;
        struct flow_action_cookie *fa_cookie;
        spinlock_t fa_cookie_lock; /* protects fa_cookie */
+       bool fail_trap_group_set;
        bool fail_trap_policer_set;
        bool fail_trap_policer_counter_get;
 };