* [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs
@ 2025-07-20 21:27 Jiri Pirko
2025-07-21 15:20 ` Simon Horman
2025-07-21 23:04 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Jiri Pirko @ 2025-07-20 21:27 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni, andrew+netdev, horms
From: Jiri Pirko <jiri@nvidia.com>
Netdevsim emulates firmware update and it takes 5 seconds to complete.
For some usecases, this is too long and unnecessary. Allow user to
configure the time by exposing debugfs knobs to set flash size, chunk
size and chunk time.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v1->v2:
- added sanitiazation of the tunables before using them
---
drivers/net/netdevsim/dev.c | 42 ++++++++++++++-----
drivers/net/netdevsim/netdevsim.h | 3 ++
.../drivers/net/netdevsim/devlink.sh | 4 ++
3 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 01c7edb28d96..c9a99eb6f5d5 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -314,6 +314,12 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
&nsim_dev->fw_update_status);
debugfs_create_u32("fw_update_overwrite_mask", 0600, nsim_dev->ddir,
&nsim_dev->fw_update_overwrite_mask);
+ debugfs_create_u32("fw_update_flash_size", 0600, nsim_dev->ddir,
+ &nsim_dev->fw_update_flash_size);
+ debugfs_create_u32("fw_update_flash_chunk_size", 0600, nsim_dev->ddir,
+ &nsim_dev->fw_update_flash_chunk_size);
+ debugfs_create_u32("fw_update_flash_chunk_time_ms", 0600, nsim_dev->ddir,
+ &nsim_dev->fw_update_flash_chunk_time_ms);
debugfs_create_u32("max_macs", 0600, nsim_dev->ddir,
&nsim_dev->max_macs);
debugfs_create_bool("test1", 0600, nsim_dev->ddir,
@@ -1015,15 +1021,14 @@ static int nsim_dev_info_get(struct devlink *devlink,
DEVLINK_INFO_VERSION_TYPE_COMPONENT);
}
-#define NSIM_DEV_FLASH_SIZE 500000
-#define NSIM_DEV_FLASH_CHUNK_SIZE 1000
-#define NSIM_DEV_FLASH_CHUNK_TIME_MS 10
-
static int nsim_dev_flash_update(struct devlink *devlink,
struct devlink_flash_update_params *params,
struct netlink_ext_ack *extack)
{
struct nsim_dev *nsim_dev = devlink_priv(devlink);
+ u32 flash_size = nsim_dev->fw_update_flash_size;
+ u32 flash_chunk_size = nsim_dev->fw_update_flash_chunk_size;
+ u32 flash_chunk_time_ms = nsim_dev->fw_update_flash_chunk_time_ms;
int i;
if ((params->overwrite_mask & ~nsim_dev->fw_update_overwrite_mask) != 0)
@@ -1035,20 +1040,30 @@ static int nsim_dev_flash_update(struct devlink *devlink,
params->component, 0, 0);
}
- for (i = 0; i < NSIM_DEV_FLASH_SIZE / NSIM_DEV_FLASH_CHUNK_SIZE; i++) {
+ /* Sanitize flash sizes and time. */
+ if (!flash_chunk_size)
+ flash_chunk_size = 1;
+ if (flash_chunk_size > flash_size)
+ flash_chunk_size = flash_size;
+ else if (flash_size % flash_chunk_size)
+ flash_size = flash_size / flash_chunk_size * flash_chunk_size;
+ if (!flash_chunk_time_ms)
+ flash_chunk_time_ms = 1;
+
+ for (i = 0; i < flash_size / flash_chunk_size; i++) {
if (nsim_dev->fw_update_status)
devlink_flash_update_status_notify(devlink, "Flashing",
params->component,
- i * NSIM_DEV_FLASH_CHUNK_SIZE,
- NSIM_DEV_FLASH_SIZE);
- msleep(NSIM_DEV_FLASH_CHUNK_TIME_MS);
+ i * flash_chunk_size,
+ flash_size);
+ msleep(flash_chunk_time_ms);
}
if (nsim_dev->fw_update_status) {
devlink_flash_update_status_notify(devlink, "Flashing",
params->component,
- NSIM_DEV_FLASH_SIZE,
- NSIM_DEV_FLASH_SIZE);
+ flash_size,
+ flash_size);
devlink_flash_update_timeout_notify(devlink, "Flash select",
params->component, 81);
devlink_flash_update_status_notify(devlink, "Flashing done",
@@ -1567,6 +1582,10 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
return err;
}
+#define NSIM_DEV_FLASH_SIZE_DEFAULT 500000
+#define NSIM_DEV_FLASH_CHUNK_SIZE_DEFAULT 1000
+#define NSIM_DEV_FLASH_CHUNK_TIME_MS_DEFAULT 10
+
int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev;
@@ -1585,6 +1604,9 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
INIT_LIST_HEAD(&nsim_dev->port_list);
nsim_dev->fw_update_status = true;
nsim_dev->fw_update_overwrite_mask = 0;
+ nsim_dev->fw_update_flash_size = NSIM_DEV_FLASH_SIZE_DEFAULT;
+ nsim_dev->fw_update_flash_chunk_size = NSIM_DEV_FLASH_CHUNK_SIZE_DEFAULT;
+ nsim_dev->fw_update_flash_chunk_time_ms = NSIM_DEV_FLASH_CHUNK_TIME_MS_DEFAULT;
nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
spin_lock_init(&nsim_dev->fa_cookie_lock);
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index 8eeeb9256077..78a0f07e4088 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -317,6 +317,9 @@ struct nsim_dev {
struct list_head port_list;
bool fw_update_status;
u32 fw_update_overwrite_mask;
+ u32 fw_update_flash_size;
+ u32 fw_update_flash_chunk_size;
+ u32 fw_update_flash_chunk_time_ms;
u32 max_macs;
bool test1;
bool dont_allow_reload;
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index a102803ff74f..92cc5cbb7d83 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -40,6 +40,10 @@ fw_flash_test()
return
fi
+ echo "1024"> $DEBUGFS_DIR/fw_update_flash_size
+ echo "128"> $DEBUGFS_DIR/fw_update_flash_chunk_size
+ echo "10"> $DEBUGFS_DIR/fw_update_flash_chunk_time_ms
+
devlink dev flash $DL_HANDLE file $DUMMYFILE
check_err $? "Failed to flash with status updates on"
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs
2025-07-20 21:27 [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs Jiri Pirko
@ 2025-07-21 15:20 ` Simon Horman
2025-07-21 23:04 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-07-21 15:20 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, edumazet, kuba, pabeni, andrew+netdev
On Sun, Jul 20, 2025 at 11:27:34PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
>
> Netdevsim emulates firmware update and it takes 5 seconds to complete.
> For some usecases, this is too long and unnecessary. Allow user to
> configure the time by exposing debugfs knobs to set flash size, chunk
> size and chunk time.
>
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> v1->v2:
> - added sanitiazation of the tunables before using them
Thanks for the update.
This version looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs
2025-07-20 21:27 [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs Jiri Pirko
2025-07-21 15:20 ` Simon Horman
@ 2025-07-21 23:04 ` Jakub Kicinski
2025-07-22 8:55 ` Jiri Pirko
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-07-21 23:04 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, edumazet, pabeni, andrew+netdev, horms
On Sun, 20 Jul 2025 23:27:34 +0200 Jiri Pirko wrote:
> Netdevsim emulates firmware update and it takes 5 seconds to complete.
> For some usecases, this is too long and unnecessary. Allow user to
> configure the time by exposing debugfs knobs to set flash size, chunk
> size and chunk time.
FWIW I also find the long delays annoying when running the test
manually. But do we need knobs for all the constants? Maybe cut
down the size to something more reasonable and expose just one
knob to control the length of the msleep()?
--
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs
2025-07-21 23:04 ` Jakub Kicinski
@ 2025-07-22 8:55 ` Jiri Pirko
0 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2025-07-22 8:55 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, davem, edumazet, pabeni, andrew+netdev, horms
Tue, Jul 22, 2025 at 01:04:57AM +0200, kuba@kernel.org wrote:
>On Sun, 20 Jul 2025 23:27:34 +0200 Jiri Pirko wrote:
>> Netdevsim emulates firmware update and it takes 5 seconds to complete.
>> For some usecases, this is too long and unnecessary. Allow user to
>> configure the time by exposing debugfs knobs to set flash size, chunk
>> size and chunk time.
>
>FWIW I also find the long delays annoying when running the test
>manually. But do we need knobs for all the constants? Maybe cut
>down the size to something more reasonable and expose just one
>knob to control the length of the msleep()?
Sure.
>--
>pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-22 8:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-20 21:27 [PATCH net-next v2] netdevsim: add couple of fw_update_flash_* debugfs knobs Jiri Pirko
2025-07-21 15:20 ` Simon Horman
2025-07-21 23:04 ` Jakub Kicinski
2025-07-22 8:55 ` Jiri Pirko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).