Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool: move firmware flashing flag to struct ethtool_netdev_state

Commit 31e0aa99dc02 ("ethtool: Veto some operations during firmware flashing process")
added a flag module_fw_flash_in_progress to struct net_device. As
this is ethtool related state, move it to the recently created
struct ethtool_netdev_state, accessed via the 'ethtool' member of
struct net_device.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20240703121849.652893-1-edward.cree@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Edward Cree and committed by
Jakub Kicinski
caa93b7c 76ed6264

+13 -14
+2
include/linux/ethtool.h
··· 1107 1107 * @rss_lock: Protects entries in @rss_ctx. May be taken from 1108 1108 * within RTNL. 1109 1109 * @wol_enabled: Wake-on-LAN is enabled 1110 + * @module_fw_flash_in_progress: Module firmware flashing is in progress. 1110 1111 */ 1111 1112 struct ethtool_netdev_state { 1112 1113 struct xarray rss_ctx; 1113 1114 struct mutex rss_lock; 1114 1115 unsigned wol_enabled:1; 1116 + unsigned module_fw_flash_in_progress:1; 1115 1117 }; 1116 1118 1117 1119 struct phy_device;
-3
include/linux/netdevice.h
··· 1989 1989 * 1990 1990 * @threaded: napi threaded mode is enabled 1991 1991 * 1992 - * @module_fw_flash_in_progress: Module firmware flashing is in progress. 1993 - * 1994 1992 * @net_notifier_list: List of per-net netdev notifier block 1995 1993 * that follow this device when it is moved 1996 1994 * to another network namespace. ··· 2374 2376 bool proto_down; 2375 2377 bool threaded; 2376 2378 2377 - unsigned module_fw_flash_in_progress:1; 2378 2379 struct list_head net_notifier_list; 2379 2380 2380 2381 #if IS_ENABLED(CONFIG_MACSEC)
+1 -1
net/ethtool/eeprom.c
··· 91 91 { 92 92 const struct ethtool_ops *ops = dev->ethtool_ops; 93 93 94 - if (dev->module_fw_flash_in_progress) { 94 + if (dev->ethtool->module_fw_flash_in_progress) { 95 95 NL_SET_ERR_MSG(extack, 96 96 "Module firmware flashing is in progress"); 97 97 return -EBUSY;
+4 -4
net/ethtool/ioctl.c
··· 658 658 if (!dev->ethtool_ops->get_link_ksettings) 659 659 return -EOPNOTSUPP; 660 660 661 - if (dev->module_fw_flash_in_progress) 661 + if (dev->ethtool->module_fw_flash_in_progress) 662 662 return -EBUSY; 663 663 664 664 memset(&link_ksettings, 0, sizeof(link_ksettings)); ··· 1572 1572 if (!dev->ethtool_ops->reset) 1573 1573 return -EOPNOTSUPP; 1574 1574 1575 - if (dev->module_fw_flash_in_progress) 1575 + if (dev->ethtool->module_fw_flash_in_progress) 1576 1576 return -EBUSY; 1577 1577 1578 1578 if (copy_from_user(&reset, useraddr, sizeof(reset))) ··· 2588 2588 const struct ethtool_ops *ops = dev->ethtool_ops; 2589 2589 struct phy_device *phydev = dev->phydev; 2590 2590 2591 - if (dev->module_fw_flash_in_progress) 2591 + if (dev->ethtool->module_fw_flash_in_progress) 2592 2592 return -EBUSY; 2593 2593 2594 2594 if (dev->sfp_bus) ··· 2628 2628 const struct ethtool_ops *ops = dev->ethtool_ops; 2629 2629 struct phy_device *phydev = dev->phydev; 2630 2630 2631 - if (dev->module_fw_flash_in_progress) 2631 + if (dev->ethtool->module_fw_flash_in_progress) 2632 2632 return -EBUSY; 2633 2633 2634 2634 if (dev->sfp_bus)
+5 -5
net/ethtool/module.c
··· 37 37 if (!ops->get_module_power_mode) 38 38 return 0; 39 39 40 - if (dev->module_fw_flash_in_progress) { 40 + if (dev->ethtool->module_fw_flash_in_progress) { 41 41 NL_SET_ERR_MSG(extack, 42 42 "Module firmware flashing is in progress"); 43 43 return -EBUSY; ··· 119 119 if (!tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY]) 120 120 return 0; 121 121 122 - if (req_info->dev->module_fw_flash_in_progress) { 122 + if (req_info->dev->ethtool->module_fw_flash_in_progress) { 123 123 NL_SET_ERR_MSG(info->extack, 124 124 "Module firmware flashing is in progress"); 125 125 return -EBUSY; ··· 226 226 ethtool_cmis_fw_update(&module_fw->fw_update); 227 227 228 228 module_flash_fw_work_list_del(&module_fw->list); 229 - module_fw->fw_update.dev->module_fw_flash_in_progress = false; 229 + module_fw->fw_update.dev->ethtool->module_fw_flash_in_progress = false; 230 230 netdev_put(module_fw->fw_update.dev, &module_fw->dev_tracker); 231 231 release_firmware(module_fw->fw_update.fw); 232 232 kfree(module_fw); ··· 318 318 if (err < 0) 319 319 goto err_release_firmware; 320 320 321 - dev->module_fw_flash_in_progress = true; 321 + dev->ethtool->module_fw_flash_in_progress = true; 322 322 netdev_hold(dev, &module_fw->dev_tracker, GFP_KERNEL); 323 323 fw_update->dev = dev; 324 324 fw_update->ntf_params.portid = info->snd_portid; ··· 385 385 return -EOPNOTSUPP; 386 386 } 387 387 388 - if (dev->module_fw_flash_in_progress) { 388 + if (dev->ethtool->module_fw_flash_in_progress) { 389 389 NL_SET_ERR_MSG(extack, "Module firmware flashing already in progress"); 390 390 return -EBUSY; 391 391 }
+1 -1
net/ethtool/netlink.c
··· 807 807 ethnl_notify_features(ptr); 808 808 break; 809 809 case NETDEV_PRE_UP: 810 - if (dev->module_fw_flash_in_progress) { 810 + if (dev->ethtool->module_fw_flash_in_progress) { 811 811 NL_SET_ERR_MSG(extack, "Can't set port up while flashing module firmware"); 812 812 return NOTIFY_BAD; 813 813 }