summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Cree <ecree.xilinx@gmail.com>2024-07-03 13:18:49 +0100
committerJakub Kicinski <kuba@kernel.org>2024-07-04 15:45:15 -0700
commitcaa93b7c25945d302689de07bd404655db93ae6e (patch)
tree8fe0394c9d1648d6ece7c3751ee30c29a3803428
parent76ed626479ebe0227728eff16bb44544ebd98920 (diff)
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>
-rw-r--r--include/linux/ethtool.h2
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--net/ethtool/eeprom.c2
-rw-r--r--net/ethtool/ioctl.c8
-rw-r--r--net/ethtool/module.c10
-rw-r--r--net/ethtool/netlink.c2
6 files changed, 13 insertions, 14 deletions
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index f74bb0cf8ed1..3a99238ef895 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -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;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3c719f0d5f5a..93558645c6d0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -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)
diff --git a/net/ethtool/eeprom.c b/net/ethtool/eeprom.c
index f36811b3ecf1..3b8209e930fd 100644
--- a/net/ethtool/eeprom.c
+++ b/net/ethtool/eeprom.c
@@ -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;
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 46f0497ae6bc..d72b0fec89af 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -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)
diff --git a/net/ethtool/module.c b/net/ethtool/module.c
index 6b7448df08d5..aba78436d350 100644
--- a/net/ethtool/module.c
+++ b/net/ethtool/module.c
@@ -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;
}
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 81fe2e5b95f6..cb1eea00e349 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -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;
}