Skip to content

Commit caa93b7

Browse files
Edward Creekuba-moo
authored andcommitted
ethtool: move firmware flashing flag to struct ethtool_netdev_state
Commit 31e0aa9 ("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 <[email protected]> Signed-off-by: Edward Cree <[email protected]> Reviewed-by: Michal Kubiak <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 76ed626 commit caa93b7

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

include/linux/ethtool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,11 +1107,13 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
11071107
* @rss_lock: Protects entries in @rss_ctx. May be taken from
11081108
* within RTNL.
11091109
* @wol_enabled: Wake-on-LAN is enabled
1110+
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
11101111
*/
11111112
struct ethtool_netdev_state {
11121113
struct xarray rss_ctx;
11131114
struct mutex rss_lock;
11141115
unsigned wol_enabled:1;
1116+
unsigned module_fw_flash_in_progress:1;
11151117
};
11161118

11171119
struct phy_device;

include/linux/netdevice.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,8 +1989,6 @@ enum netdev_reg_state {
19891989
*
19901990
* @threaded: napi threaded mode is enabled
19911991
*
1992-
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
1993-
*
19941992
* @net_notifier_list: List of per-net netdev notifier block
19951993
* that follow this device when it is moved
19961994
* to another network namespace.
@@ -2376,7 +2374,6 @@ struct net_device {
23762374
bool proto_down;
23772375
bool threaded;
23782376

2379-
unsigned module_fw_flash_in_progress:1;
23802377
struct list_head net_notifier_list;
23812378

23822379
#if IS_ENABLED(CONFIG_MACSEC)

net/ethtool/eeprom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int get_module_eeprom_by_page(struct net_device *dev,
9191
{
9292
const struct ethtool_ops *ops = dev->ethtool_ops;
9393

94-
if (dev->module_fw_flash_in_progress) {
94+
if (dev->ethtool->module_fw_flash_in_progress) {
9595
NL_SET_ERR_MSG(extack,
9696
"Module firmware flashing is in progress");
9797
return -EBUSY;

net/ethtool/ioctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
658658
if (!dev->ethtool_ops->get_link_ksettings)
659659
return -EOPNOTSUPP;
660660

661-
if (dev->module_fw_flash_in_progress)
661+
if (dev->ethtool->module_fw_flash_in_progress)
662662
return -EBUSY;
663663

664664
memset(&link_ksettings, 0, sizeof(link_ksettings));
@@ -1572,7 +1572,7 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr)
15721572
if (!dev->ethtool_ops->reset)
15731573
return -EOPNOTSUPP;
15741574

1575-
if (dev->module_fw_flash_in_progress)
1575+
if (dev->ethtool->module_fw_flash_in_progress)
15761576
return -EBUSY;
15771577

15781578
if (copy_from_user(&reset, useraddr, sizeof(reset)))
@@ -2588,7 +2588,7 @@ int ethtool_get_module_info_call(struct net_device *dev,
25882588
const struct ethtool_ops *ops = dev->ethtool_ops;
25892589
struct phy_device *phydev = dev->phydev;
25902590

2591-
if (dev->module_fw_flash_in_progress)
2591+
if (dev->ethtool->module_fw_flash_in_progress)
25922592
return -EBUSY;
25932593

25942594
if (dev->sfp_bus)
@@ -2628,7 +2628,7 @@ int ethtool_get_module_eeprom_call(struct net_device *dev,
26282628
const struct ethtool_ops *ops = dev->ethtool_ops;
26292629
struct phy_device *phydev = dev->phydev;
26302630

2631-
if (dev->module_fw_flash_in_progress)
2631+
if (dev->ethtool->module_fw_flash_in_progress)
26322632
return -EBUSY;
26332633

26342634
if (dev->sfp_bus)

net/ethtool/module.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int module_get_power_mode(struct net_device *dev,
3737
if (!ops->get_module_power_mode)
3838
return 0;
3939

40-
if (dev->module_fw_flash_in_progress) {
40+
if (dev->ethtool->module_fw_flash_in_progress) {
4141
NL_SET_ERR_MSG(extack,
4242
"Module firmware flashing is in progress");
4343
return -EBUSY;
@@ -119,7 +119,7 @@ ethnl_set_module_validate(struct ethnl_req_info *req_info,
119119
if (!tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY])
120120
return 0;
121121

122-
if (req_info->dev->module_fw_flash_in_progress) {
122+
if (req_info->dev->ethtool->module_fw_flash_in_progress) {
123123
NL_SET_ERR_MSG(info->extack,
124124
"Module firmware flashing is in progress");
125125
return -EBUSY;
@@ -226,7 +226,7 @@ static void module_flash_fw_work(struct work_struct *work)
226226
ethtool_cmis_fw_update(&module_fw->fw_update);
227227

228228
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;
230230
netdev_put(module_fw->fw_update.dev, &module_fw->dev_tracker);
231231
release_firmware(module_fw->fw_update.fw);
232232
kfree(module_fw);
@@ -318,7 +318,7 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name,
318318
if (err < 0)
319319
goto err_release_firmware;
320320

321-
dev->module_fw_flash_in_progress = true;
321+
dev->ethtool->module_fw_flash_in_progress = true;
322322
netdev_hold(dev, &module_fw->dev_tracker, GFP_KERNEL);
323323
fw_update->dev = dev;
324324
fw_update->ntf_params.portid = info->snd_portid;
@@ -385,7 +385,7 @@ static int ethnl_module_fw_flash_validate(struct net_device *dev,
385385
return -EOPNOTSUPP;
386386
}
387387

388-
if (dev->module_fw_flash_in_progress) {
388+
if (dev->ethtool->module_fw_flash_in_progress) {
389389
NL_SET_ERR_MSG(extack, "Module firmware flashing already in progress");
390390
return -EBUSY;
391391
}

net/ethtool/netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,
807807
ethnl_notify_features(ptr);
808808
break;
809809
case NETDEV_PRE_UP:
810-
if (dev->module_fw_flash_in_progress) {
810+
if (dev->ethtool->module_fw_flash_in_progress) {
811811
NL_SET_ERR_MSG(extack, "Can't set port up while flashing module firmware");
812812
return NOTIFY_BAD;
813813
}

0 commit comments

Comments
 (0)