Skip to content

Commit 9a5bbab

Browse files
Jiri Pirkokuba-moo
authored andcommitted
netdevsim: add fw_update_flash_chunk_time_ms debugfs knobs
Netdevsim emulates firmware update and it takes 5 seconds to complete. For some use cases, this is too long and unnecessary. Allow user to configure the time by exposing debugfs a knob to set chunk time. Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1bbdb81 commit 9a5bbab

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

drivers/net/netdevsim/dev.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
314314
&nsim_dev->fw_update_status);
315315
debugfs_create_u32("fw_update_overwrite_mask", 0600, nsim_dev->ddir,
316316
&nsim_dev->fw_update_overwrite_mask);
317+
debugfs_create_u32("fw_update_flash_chunk_time_ms", 0600, nsim_dev->ddir,
318+
&nsim_dev->fw_update_flash_chunk_time_ms);
317319
debugfs_create_u32("max_macs", 0600, nsim_dev->ddir,
318320
&nsim_dev->max_macs);
319321
debugfs_create_bool("test1", 0600, nsim_dev->ddir,
@@ -1015,9 +1017,9 @@ static int nsim_dev_info_get(struct devlink *devlink,
10151017
DEVLINK_INFO_VERSION_TYPE_COMPONENT);
10161018
}
10171019

1018-
#define NSIM_DEV_FLASH_SIZE 500000
1020+
#define NSIM_DEV_FLASH_SIZE 50000
10191021
#define NSIM_DEV_FLASH_CHUNK_SIZE 1000
1020-
#define NSIM_DEV_FLASH_CHUNK_TIME_MS 10
1022+
#define NSIM_DEV_FLASH_CHUNK_TIME_MS_DEFAULT 100
10211023

10221024
static int nsim_dev_flash_update(struct devlink *devlink,
10231025
struct devlink_flash_update_params *params,
@@ -1041,7 +1043,7 @@ static int nsim_dev_flash_update(struct devlink *devlink,
10411043
params->component,
10421044
i * NSIM_DEV_FLASH_CHUNK_SIZE,
10431045
NSIM_DEV_FLASH_SIZE);
1044-
msleep(NSIM_DEV_FLASH_CHUNK_TIME_MS);
1046+
msleep(nsim_dev->fw_update_flash_chunk_time_ms ?: 1);
10451047
}
10461048

10471049
if (nsim_dev->fw_update_status) {
@@ -1585,6 +1587,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
15851587
INIT_LIST_HEAD(&nsim_dev->port_list);
15861588
nsim_dev->fw_update_status = true;
15871589
nsim_dev->fw_update_overwrite_mask = 0;
1590+
nsim_dev->fw_update_flash_chunk_time_ms = NSIM_DEV_FLASH_CHUNK_TIME_MS_DEFAULT;
15881591
nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
15891592
nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
15901593
spin_lock_init(&nsim_dev->fa_cookie_lock);

drivers/net/netdevsim/netdevsim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ struct nsim_dev {
317317
struct list_head port_list;
318318
bool fw_update_status;
319319
u32 fw_update_overwrite_mask;
320+
u32 fw_update_flash_chunk_time_ms;
320321
u32 max_macs;
321322
bool test1;
322323
bool dont_allow_reload;

tools/testing/selftests/drivers/net/netdevsim/devlink.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ fw_flash_test()
4040
return
4141
fi
4242

43+
echo "10"> $DEBUGFS_DIR/fw_update_flash_chunk_time_ms
44+
4345
devlink dev flash $DL_HANDLE file $DUMMYFILE
4446
check_err $? "Failed to flash with status updates on"
4547

0 commit comments

Comments
 (0)