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

ethtool: Add reset operation

After updating firmware stored in flash, users may wish to reset the
relevant hardware and start the new firmware immediately. This should
not be completely automatic as it may be disruptive.

A selective reset may also be useful for debugging or diagnostics.

This adds a separate reset operation which takes flags indicating the
components to be reset. Drivers are allowed to reset only a subset of
those requested, and must indicate the actual subset. This allows the
use of generic component masks and some future expansion.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ben Hutchings and committed by
David S. Miller
d73d3a8c d250a5f9

+55
+32
include/linux/ethtool.h
··· 498 498 int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *); 499 499 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); 500 500 int (*flash_device)(struct net_device *, struct ethtool_flash *); 501 + int (*reset)(struct net_device *, u32 *); 501 502 }; 502 503 #endif /* __KERNEL__ */ 503 504 ··· 556 555 #define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */ 557 556 #define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */ 558 557 #define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */ 558 + #define ETHTOOL_RESET 0x00000034 /* Reset hardware */ 559 559 560 560 /* compatibility with older code */ 561 561 #define SPARC_ETH_GSET ETHTOOL_GSET ··· 686 684 #define RXH_DISCARD (1 << 31) 687 685 688 686 #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL 687 + 688 + /* Reset flags */ 689 + /* The reset() operation must clear the flags for the components which 690 + * were actually reset. On successful return, the flags indicate the 691 + * components which were not reset, either because they do not exist 692 + * in the hardware or because they cannot be reset independently. The 693 + * driver must never reset any components that were not requested. 694 + */ 695 + enum ethtool_reset_flags { 696 + /* These flags represent components dedicated to the interface 697 + * the command is addressed to. Shift any flag left by 698 + * ETH_RESET_SHARED_SHIFT to reset a shared component of the 699 + * same type. 700 + */ 701 + ETH_RESET_MGMT = 1 << 0, /* Management processor */ 702 + ETH_RESET_IRQ = 1 << 1, /* Interrupt requester */ 703 + ETH_RESET_DMA = 1 << 2, /* DMA engine */ 704 + ETH_RESET_FILTER = 1 << 3, /* Filtering/flow direction */ 705 + ETH_RESET_OFFLOAD = 1 << 4, /* Protocol offload */ 706 + ETH_RESET_MAC = 1 << 5, /* Media access controller */ 707 + ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */ 708 + ETH_RESET_RAM = 1 << 7, /* RAM shared between 709 + * multiple components */ 710 + 711 + ETH_RESET_DEDICATED = 0x0000ffff, /* All components dedicated to 712 + * this interface */ 713 + ETH_RESET_ALL = 0xffffffff, /* All components used by this 714 + * interface, even if shared */ 715 + }; 716 + #define ETH_RESET_SHARED_SHIFT 16 689 717 690 718 #endif /* _LINUX_ETHTOOL_H */
+23
net/core/ethtool.c
··· 302 302 return ret; 303 303 } 304 304 305 + static int ethtool_reset(struct net_device *dev, char __user *useraddr) 306 + { 307 + struct ethtool_value reset; 308 + int ret; 309 + 310 + if (!dev->ethtool_ops->reset) 311 + return -EOPNOTSUPP; 312 + 313 + if (copy_from_user(&reset, useraddr, sizeof(reset))) 314 + return -EFAULT; 315 + 316 + ret = dev->ethtool_ops->reset(dev, &reset.data); 317 + if (ret) 318 + return ret; 319 + 320 + if (copy_to_user(useraddr, &reset, sizeof(reset))) 321 + return -EFAULT; 322 + return 0; 323 + } 324 + 305 325 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) 306 326 { 307 327 struct ethtool_wolinfo wol = { ETHTOOL_GWOL }; ··· 1108 1088 break; 1109 1089 case ETHTOOL_FLASHDEV: 1110 1090 rc = ethtool_flash_device(dev, useraddr); 1091 + break; 1092 + case ETHTOOL_RESET: 1093 + rc = ethtool_reset(dev, useraddr); 1111 1094 break; 1112 1095 default: 1113 1096 rc = -EOPNOTSUPP;