net: devlink: sync flash and dev info commands
Subsystems (4)
Jiri Pirko
maintainerv3 cover net: devlink: sync flash and dev info commands
From: Jiri Pirko <[email protected]>
Purpose of this patchset is to introduce consistency between two devlink commands:
devlink dev info
Shows versions of running default flash target and components.
devlink dev flash
Flashes default flash target or component name (if specified on cmdline).
Currently it is up to the driver what versions to expose and what flash update component names to accept. This is inconsistent. Thankfully, only netdevsim currently using components so it is still time
to sanitize this.
This patchset makes sure, that devlink.c calls into driver for component flash update only in case the driver exposes the same version name.
Example:
$ devlink dev info
netdevsim/netdevsim10:
driver netdevsim
versions:
running:
fw.mgmt 10.20.30
stored:
fw.mgmt 10.20.30
$ devlink dev flash netdevsim/netdevsim10 file somefile.bin
[fw.mgmt] Preparing to flash
[fw.mgmt] Flashing 100%
[fw.mgmt] Flash select
[fw.mgmt] Flashing done
$ devlink dev flash netdevsim/netdevsim10 file somefile.bin component fw.mgmt
[fw.mgmt] Preparing to flash
[fw.mgmt] Flashing 100%
[fw.mgmt] Flash select
[fw.mgmt] Flashing done
$ devlink dev flash netdevsim/netdevsim10 file somefile.bin component dummy
Error: selected component is not supported by this device.---v2->v3:
- see changelog of individual patches
- dropped patch to expose if version represents a component over netlink v1->v2:
- see changelog of individual patches, no code changes, just split patch
- removed patches that exposed "default flash target"
Jiri Pirko (3):
net: devlink: extend info_get() version put to indicate a flash
component
netdevsim: add version fw.mgmt info info_get() and mark as a component
net: devlink: limit flash component name to match version returned by
info_get()
drivers/net/netdevsim/dev.c | 15 +++- include/net/devlink.h | 19 ++++- net/core/devlink.c | 139 ++++++++++++++++++++++++++++++------ 3 files changed, 147 insertions(+), 26 deletions(-)
Signature · 1 line
2.37.1
Jiri Pirko
maintainerPATCH v3 1/3 net: devlink: extend info_get() version put to indicate a flash component
From: Jiri Pirko <[email protected]>
Whenever the driver is called by his info_get() op, it may put multiple version names and values to the netlink message. Extend by additional helper devlink_info_version_running/stored_put_ext() that allows to specify a version type that indicates when particular version name represents a flash component.
This is going to be used in follow-up patch calling info_get() during flash update command checking if version with this the version type exists.
---v2->v3:
- added "stored" variantv1->v2:
- split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes
--- include/net/devlink.h | 16 ++++++++++++++++ net/core/devlink.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-)
include/net/devlink.h +16 -0
@@ -1714,15 +1714,31 @@ int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name);int devlink_info_board_serial_number_put (struct devlink_info_req *req,const char *bsn); + +enum devlink_info_version_type { +DEVLINK_INFO_VERSION_TYPE_NONE , +DEVLINK_INFO_VERSION_TYPE_COMPONENT ,/* May be used as flash update +* component by name. +*/ +}; +int devlink_info_version_fixed_put (struct devlink_info_req *req,const char *version_name,const char *version_value);int devlink_info_version_stored_put (struct devlink_info_req *req,const char *version_name,const char *version_value); +int devlink_info_version_stored_put_ext (struct devlink_info_req *req, +const char *version_name, +const char *version_value, +enum devlink_info_version_type version_type);int devlink_info_version_running_put (struct devlink_info_req *req,const char *version_name,const char *version_value); +int devlink_info_version_running_put_ext (struct devlink_info_req *req, +const char *version_name, +const char *version_value, +enum devlink_info_version_type version_type);int devlink_fmsg_obj_nest_start (struct devlink_fmsg *fmsg);int devlink_fmsg_obj_nest_end (struct devlink_fmsg *fmsg);
net/core/devlink.c +30 -4
@@ -6579,7 +6579,8 @@ EXPORT_SYMBOL_GPL(devlink_info_board_serial_number_put);static int devlink_info_version_put (struct devlink_info_req *req,int attr,const char *version_name, -const char *version_value) +const char *version_value, +enum devlink_info_version_type version_type) {struct nlattr *nest;int err;
@@ -6612,7 +6613,8 @@ int devlink_info_version_fixed_put(struct devlink_info_req *req, const char *version_value) {return devlink_info_version_put (req,DEVLINK_ATTR_INFO_VERSION_FIXED , - version_name, version_value); + version_name, version_value, +DEVLINK_INFO_VERSION_TYPE_NONE ); }EXPORT_SYMBOL_GPL (devlink_info_version_fixed_put);
@@ -6621,19 +6623,43 @@ int devlink_info_version_stored_put(struct devlink_info_req *req, const char *version_value) {return devlink_info_version_put (req,DEVLINK_ATTR_INFO_VERSION_STORED , - version_name, version_value); + version_name, version_value, +DEVLINK_INFO_VERSION_TYPE_NONE ); }EXPORT_SYMBOL_GPL (devlink_info_version_stored_put); +int devlink_info_version_stored_put_ext (struct devlink_info_req *req, +const char *version_name, +const char *version_value, +enum devlink_info_version_type version_type) +{ +return devlink_info_version_put (req,DEVLINK_ATTR_INFO_VERSION_STORED , + version_name, version_value, + version_type); +} +EXPORT_SYMBOL_GPL (devlink_info_version_stored_put_ext); +int devlink_info_version_running_put (struct devlink_info_req *req,const char *version_name,const char *version_value) {return devlink_info_version_put (req,DEVLINK_ATTR_INFO_VERSION_RUNNING , - version_name, version_value); + version_name, version_value, +DEVLINK_INFO_VERSION_TYPE_NONE ); }EXPORT_SYMBOL_GPL (devlink_info_version_running_put); +int devlink_info_version_running_put_ext (struct devlink_info_req *req, +const char *version_name, +const char *version_value, +enum devlink_info_version_type version_type) +{ +return devlink_info_version_put (req,DEVLINK_ATTR_INFO_VERSION_RUNNING , + version_name, version_value, + version_type); +} +EXPORT_SYMBOL_GPL (devlink_info_version_running_put_ext); + static int devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, enum devlink_command cmd, u32 portid,
Signature · 1 line
2.37.1
Jiri Pirko
maintainerPATCH v3 2/3 netdevsim: add version fw.mgmt info info_get() and mark as a component
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Fix the only component user which is netdevsim. It uses component named "fw.mgmt" in selftests. So add this version to info_get() output with version type component.
---v2->v3:
- added "stored" versionv1->v2:
- split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes
--- drivers/net/netdevsim/dev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/netdevsim/dev.c +11 -1
@@ -984,7 +984,17 @@ static int nsim_dev_info_get(struct devlink *devlink,struct devlink_info_req *req, struct netlink_ext_ack *extack) { - return devlink_info_driver_name_put(req, DRV_NAME); + int err; + + err =devlink_info_driver_name_put (req,DRV_NAME ); +if (err) +return err; + err =devlink_info_version_stored_put_ext (req,"fw.mgmt" ,"10.20.30" , +DEVLINK_INFO_VERSION_TYPE_COMPONENT ); +if (err) +return err; +return devlink_info_version_running_put_ext (req,"fw.mgmt" ,"10.20.30" , +DEVLINK_INFO_VERSION_TYPE_COMPONENT ); }#define NSIM_DEV_FLASH_SIZE 500000
Signature · 1 line
2.37.1
Jiri Pirko
maintainerPATCH v3 3/3 net: devlink: limit flash component name to match version returned by info_get()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Limit the acceptance of component name passed to cmd_flash_update() to match one of the versions returned by info_get(), marked by version type. This makes things clearer and enforces 1:1 mapping between exposed version and accepted flash component.
Check VERSION_TYPE_COMPONENT version type during cmd_flash_update() execution by calling info_get() with different "req" context. That causes info_get() to lookup the component name instead of filling-up the netlink message.
Remove "UPDATE_COMPONENT" flag which becomes used.
---v1->v2:
- split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes
--- drivers/net/netdevsim/dev.c | 3 +- include/net/devlink.h | 3 +- net/core/devlink.c | 105 ++++++++++++++++++++++++++++++------ 3 files changed, 90 insertions(+), 21 deletions(-)
drivers/net/netdevsim/dev.c +1 -2
@@ -1322,8 +1322,7 @@ nsim_dev_devlink_trap_drop_counter_get(struct devlink *devlink,static const struct devlink_ops nsim_dev_devlink_ops = { .eswitch_mode_set = nsim_devlink_eswitch_mode_set, .eswitch_mode_get = nsim_devlink_eswitch_mode_get, - .supported_flash_update_params =DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT | -DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK , + .supported_flash_update_params =DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK , .reload_actions =BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT ), .reload_down = nsim_dev_reload_down, .reload_up = nsim_dev_reload_up,
include/net/devlink.h +1 -2
@@ -624,8 +624,7 @@ struct devlink_flash_update_params {u32 overwrite_mask; }; -#define DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT BIT(0) -#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) +#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(0)struct devlink_region ;struct devlink_info_req ;
net/core/devlink.c +88 -17
160 lines not on this page · raw message
Signature · 1 line
2.37.1
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 24 Aug 2022 14:20:08 +0200 you wrote:
From: Jiri Pirko <[email protected]>
Purpose of this patchset is to introduce consistency between two devlink commands:
devlink dev info
Shows versions of running default flash target and components.
devlink dev flash
Flashes default flash target or component name (if specified on cmdline).[...]
Here is the summary with links:
- [net-next,v3,1/3] net: devlink: extend info_get() version put to indicate a flash component
https://git.kernel.org/netdev/net-next/c/bb67012331f7 - [net-next,v3,2/3] netdevsim: add version fw.mgmt info info_get() and mark as a component https://git.kernel.org/netdev/net-next/c/0c1989754f76 - [net-next,v3,3/3] net: devlink: limit flash component name to match version returned by info_get() https://git.kernel.org/netdev/net-next/c/f94b606325c1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html