Commit caa93b7c authored by Edward Cree's avatar Edward Cree Committed by Jakub Kicinski

ethtool: move firmware flashing flag to struct ethtool_netdev_state

Commit 31e0aa99 ("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: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
Reviewed-by: default avatarMichal Kubiak <michal.kubiak@intel.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20240703121849.652893-1-edward.cree@amd.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 76ed6264
......@@ -1107,11 +1107,13 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
* @rss_lock: Protects entries in @rss_ctx. May be taken from
* within RTNL.
* @wol_enabled: Wake-on-LAN is enabled
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
*/
struct ethtool_netdev_state {
struct xarray rss_ctx;
struct mutex rss_lock;
unsigned wol_enabled:1;
unsigned module_fw_flash_in_progress:1;
};
struct phy_device;
......
......@@ -1989,8 +1989,6 @@ enum netdev_reg_state {
*
* @threaded: napi threaded mode is enabled
*
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
*
* @net_notifier_list: List of per-net netdev notifier block
* that follow this device when it is moved
* to another network namespace.
......@@ -2376,7 +2374,6 @@ struct net_device {
bool proto_down;
bool threaded;
unsigned module_fw_flash_in_progress:1;
struct list_head net_notifier_list;
#if IS_ENABLED(CONFIG_MACSEC)
......
......@@ -91,7 +91,7 @@ static int get_module_eeprom_by_page(struct net_device *dev,
{
const struct ethtool_ops *ops = dev->ethtool_ops;
if (dev->module_fw_flash_in_progress) {
if (dev->ethtool->module_fw_flash_in_progress) {
NL_SET_ERR_MSG(extack,
"Module firmware flashing is in progress");
return -EBUSY;
......
......@@ -658,7 +658,7 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
if (!dev->ethtool_ops->get_link_ksettings)
return -EOPNOTSUPP;
if (dev->module_fw_flash_in_progress)
if (dev->ethtool->module_fw_flash_in_progress)
return -EBUSY;
memset(&link_ksettings, 0, sizeof(link_ksettings));
......@@ -1572,7 +1572,7 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr)
if (!dev->ethtool_ops->reset)
return -EOPNOTSUPP;
if (dev->module_fw_flash_in_progress)
if (dev->ethtool->module_fw_flash_in_progress)
return -EBUSY;
if (copy_from_user(&reset, useraddr, sizeof(reset)))
......@@ -2588,7 +2588,7 @@ int ethtool_get_module_info_call(struct net_device *dev,
const struct ethtool_ops *ops = dev->ethtool_ops;
struct phy_device *phydev = dev->phydev;
if (dev->module_fw_flash_in_progress)
if (dev->ethtool->module_fw_flash_in_progress)
return -EBUSY;
if (dev->sfp_bus)
......@@ -2628,7 +2628,7 @@ int ethtool_get_module_eeprom_call(struct net_device *dev,
const struct ethtool_ops *ops = dev->ethtool_ops;
struct phy_device *phydev = dev->phydev;
if (dev->module_fw_flash_in_progress)
if (dev->ethtool->module_fw_flash_in_progress)
return -EBUSY;
if (dev->sfp_bus)
......
......@@ -37,7 +37,7 @@ static int module_get_power_mode(struct net_device *dev,
if (!ops->get_module_power_mode)
return 0;
if (dev->module_fw_flash_in_progress) {
if (dev->ethtool->module_fw_flash_in_progress) {
NL_SET_ERR_MSG(extack,
"Module firmware flashing is in progress");
return -EBUSY;
......@@ -119,7 +119,7 @@ ethnl_set_module_validate(struct ethnl_req_info *req_info,
if (!tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY])
return 0;
if (req_info->dev->module_fw_flash_in_progress) {
if (req_info->dev->ethtool->module_fw_flash_in_progress) {
NL_SET_ERR_MSG(info->extack,
"Module firmware flashing is in progress");
return -EBUSY;
......@@ -226,7 +226,7 @@ static void module_flash_fw_work(struct work_struct *work)
ethtool_cmis_fw_update(&module_fw->fw_update);
module_flash_fw_work_list_del(&module_fw->list);
module_fw->fw_update.dev->module_fw_flash_in_progress = false;
module_fw->fw_update.dev->ethtool->module_fw_flash_in_progress = false;
netdev_put(module_fw->fw_update.dev, &module_fw->dev_tracker);
release_firmware(module_fw->fw_update.fw);
kfree(module_fw);
......@@ -318,7 +318,7 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name,
if (err < 0)
goto err_release_firmware;
dev->module_fw_flash_in_progress = true;
dev->ethtool->module_fw_flash_in_progress = true;
netdev_hold(dev, &module_fw->dev_tracker, GFP_KERNEL);
fw_update->dev = dev;
fw_update->ntf_params.portid = info->snd_portid;
......@@ -385,7 +385,7 @@ static int ethnl_module_fw_flash_validate(struct net_device *dev,
return -EOPNOTSUPP;
}
if (dev->module_fw_flash_in_progress) {
if (dev->ethtool->module_fw_flash_in_progress) {
NL_SET_ERR_MSG(extack, "Module firmware flashing already in progress");
return -EBUSY;
}
......
......@@ -807,7 +807,7 @@ static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,
ethnl_notify_features(ptr);
break;
case NETDEV_PRE_UP:
if (dev->module_fw_flash_in_progress) {
if (dev->ethtool->module_fw_flash_in_progress) {
NL_SET_ERR_MSG(extack, "Can't set port up while flashing module firmware");
return NOTIFY_BAD;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment