History

netdevsim: add support for flash_update overwrite mask

The devlink interface recently gained support for a new "overwrite mask" parameter that allows specifying how various sub-sections of a flash component are modified when updating. Add support for this to netdevsim, to enable easily testing the interface. Make the allowed overwrite mask values controllable via a debugfs parameter. This enables testing a flow where the driver rejects an unsupportable overwrite mask.

Jacob Keller committed 6 years ago

Commit cbb58361 parent 5d5b4123 files · +28 −1Browse files

Unified · Split

3 files
  1. drivers/net/netdevsim/dev.c +9 −1
  2. drivers/net/netdevsim/netdevsim.h +1 −0
  3. tools/testing/selftests/drivers/net/netdevsim/devlink.sh +18 −0
drivers/net/netdevsim/dev.c+9−1
@@ -203,6 +203,8 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) · 202 unmodified lines
203 return PTR_ERR(nsim_dev->ports_ddir);203 return PTR_ERR(nsim_dev->ports_ddir);
204 debugfs_create_bool("fw_update_status", 0600, nsim_dev->ddir,204 debugfs_create_bool("fw_update_status", 0600, nsim_dev->ddir,
205 &nsim_dev->fw_update_status);205 &nsim_dev->fw_update_status);
206 debugfs_create_u32("fw_update_overwrite_mask", 0600, nsim_dev->ddir,
207 &nsim_dev->fw_update_overwrite_mask);
206 debugfs_create_u32("max_macs", 0600, nsim_dev->ddir,208 debugfs_create_u32("max_macs", 0600, nsim_dev->ddir,
207 &nsim_dev->max_macs);209 &nsim_dev->max_macs);
208 debugfs_create_bool("test1", 0600, nsim_dev->ddir,210 debugfs_create_bool("test1", 0600, nsim_dev->ddir,
@@ -749,6 +751,9 @@ static int nsim_dev_flash_update(struct devlink *devlink, · 540 unmodified lines
749 struct nsim_dev *nsim_dev = devlink_priv(devlink);751 struct nsim_dev *nsim_dev = devlink_priv(devlink);
750 int i;752 int i;
751 753
754 if ((params->overwrite_mask & ~nsim_dev->fw_update_overwrite_mask) != 0)
755 return -EOPNOTSUPP;
756
752 if (nsim_dev->fw_update_status) {757 if (nsim_dev->fw_update_status) {
753 devlink_flash_update_begin_notify(devlink);758 devlink_flash_update_begin_notify(devlink);
754 devlink_flash_update_status_notify(devlink,759 devlink_flash_update_status_notify(devlink,
@@ -879,7 +884,8 @@ nsim_dev_devlink_trap_policer_counter_get(struct devlink *devlink, · 124 unmodified lines
879}884}
880 885
881static const struct devlink_ops nsim_dev_devlink_ops = {886static const struct devlink_ops nsim_dev_devlink_ops = {
882 .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT,887 .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT |
888 DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK,
883 .reload_down = nsim_dev_reload_down,889 .reload_down = nsim_dev_reload_down,
884 .reload_up = nsim_dev_reload_up,890 .reload_up = nsim_dev_reload_up,
885 .info_get = nsim_dev_info_get,891 .info_get = nsim_dev_info_get,
@@ -994,6 +1000,7 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev, · 108 unmodified lines
994 INIT_LIST_HEAD(&nsim_dev->port_list);1000 INIT_LIST_HEAD(&nsim_dev->port_list);
995 mutex_init(&nsim_dev->port_list_lock);1001 mutex_init(&nsim_dev->port_list_lock);
996 nsim_dev->fw_update_status = true;1002 nsim_dev->fw_update_status = true;
1003 nsim_dev->fw_update_overwrite_mask = 0;
997 1004
998 nsim_dev->fib_data = nsim_fib_create(devlink, extack);1005 nsim_dev->fib_data = nsim_fib_create(devlink, extack);
999 if (IS_ERR(nsim_dev->fib_data))1006 if (IS_ERR(nsim_dev->fib_data))
@@ -1052,6 +1059,7 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) · 52 unmodified lines
1052 INIT_LIST_HEAD(&nsim_dev->port_list);1059 INIT_LIST_HEAD(&nsim_dev->port_list);
1053 mutex_init(&nsim_dev->port_list_lock);1060 mutex_init(&nsim_dev->port_list_lock);
1054 nsim_dev->fw_update_status = true;1061 nsim_dev->fw_update_status = true;
1062 nsim_dev->fw_update_overwrite_mask = 0;
1055 nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;1063 nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
1056 nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;1064 nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
1057 spin_lock_init(&nsim_dev->fa_cookie_lock);1065 spin_lock_init(&nsim_dev->fa_cookie_lock);
drivers/net/netdevsim/netdevsim.h+1−0
@@ -196,6 +196,7 @@ struct nsim_dev { · 195 unmodified lines
196 struct list_head port_list;196 struct list_head port_list;
197 struct mutex port_list_lock; /* protects port list */197 struct mutex port_list_lock; /* protects port list */
198 bool fw_update_status;198 bool fw_update_status;
199 u32 fw_update_overwrite_mask;
199 u32 max_macs;200 u32 max_macs;
200 bool test1;201 bool test1;
201 bool dont_allow_reload;202 bool dont_allow_reload;
tools/testing/selftests/drivers/net/netdevsim/devlink.sh+18−0
@@ -26,6 +26,24 @@ fw_flash_test() · 25 unmodified lines
26 devlink dev flash $DL_HANDLE file dummy component fw.mgmt26 devlink dev flash $DL_HANDLE file dummy component fw.mgmt
27 check_err $? "Failed to flash with component attribute"27 check_err $? "Failed to flash with component attribute"
28 28
29 devlink dev flash $DL_HANDLE file dummy overwrite settings
30 check_fail $? "Flash with overwrite settings should be rejected"
31
32 echo "1"> $DEBUGFS_DIR/fw_update_overwrite_mask
33 check_err $? "Failed to change allowed overwrite mask"
34
35 devlink dev flash $DL_HANDLE file dummy overwrite settings
36 check_err $? "Failed to flash with settings overwrite enabled"
37
38 devlink dev flash $DL_HANDLE file dummy overwrite identifiers
39 check_fail $? "Flash with overwrite settings should be identifiers"
40
41 echo "3"> $DEBUGFS_DIR/fw_update_overwrite_mask
42 check_err $? "Failed to change allowed overwrite mask"
43
44 devlink dev flash $DL_HANDLE file dummy overwrite identifiers overwrite settings
45 check_err $? "Failed to flash with settings and identifiers overwrite enabled"
46
29 echo "n"> $DEBUGFS_DIR/fw_update_status47 echo "n"> $DEBUGFS_DIR/fw_update_status
30 check_err $? "Failed to disable status updates"48 check_err $? "Failed to disable status updates"
31 49