aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ethtool.h14
-rw-r--r--net/core/ethtool.c16
2 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 90c4a3616d94..15e4eb713694 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -362,6 +362,18 @@ struct ethtool_rxnfc {
362 __u32 rule_locs[0]; 362 __u32 rule_locs[0];
363}; 363};
364 364
365#define ETHTOOL_FLASH_MAX_FILENAME 128
366enum ethtool_flash_op_type {
367 ETHTOOL_FLASH_ALL_REGIONS = 0,
368};
369
370/* for passing firmware flashing related parameters */
371struct ethtool_flash {
372 __u32 cmd;
373 __u32 region;
374 char data[ETHTOOL_FLASH_MAX_FILENAME];
375};
376
365#ifdef __KERNEL__ 377#ifdef __KERNEL__
366 378
367struct net_device; 379struct net_device;
@@ -489,6 +501,7 @@ struct ethtool_ops {
489 int (*get_stats_count)(struct net_device *);/* use get_sset_count */ 501 int (*get_stats_count)(struct net_device *);/* use get_sset_count */
490 int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *); 502 int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *);
491 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); 503 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
504 int (*flash_device)(struct net_device *, struct ethtool_flash *);
492}; 505};
493#endif /* __KERNEL__ */ 506#endif /* __KERNEL__ */
494 507
@@ -545,6 +558,7 @@ struct ethtool_ops {
545#define ETHTOOL_GRXCLSRLALL 0x00000030 /* Get all RX classification rule */ 558#define ETHTOOL_GRXCLSRLALL 0x00000030 /* Get all RX classification rule */
546#define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */ 559#define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */
547#define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */ 560#define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */
561#define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */
548 562
549/* compatibility with older code */ 563/* compatibility with older code */
550#define SPARC_ETH_GSET ETHTOOL_GSET 564#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 44e571111d3a..4c12ddb5f5ee 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -898,6 +898,19 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
898 return actor(dev, edata.data); 898 return actor(dev, edata.data);
899} 899}
900 900
901static int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
902{
903 struct ethtool_flash efl;
904
905 if (copy_from_user(&efl, useraddr, sizeof(efl)))
906 return -EFAULT;
907
908 if (!dev->ethtool_ops->flash_device)
909 return -EOPNOTSUPP;
910
911 return dev->ethtool_ops->flash_device(dev, &efl);
912}
913
901/* The main entry point in this file. Called from net/core/dev.c */ 914/* The main entry point in this file. Called from net/core/dev.c */
902 915
903int dev_ethtool(struct net *net, struct ifreq *ifr) 916int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1111,6 +1124,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1111 case ETHTOOL_SGRO: 1124 case ETHTOOL_SGRO:
1112 rc = ethtool_set_gro(dev, useraddr); 1125 rc = ethtool_set_gro(dev, useraddr);
1113 break; 1126 break;
1127 case ETHTOOL_FLASHDEV:
1128 rc = ethtool_flash_device(dev, useraddr);
1129 break;
1114 default: 1130 default:
1115 rc = -EOPNOTSUPP; 1131 rc = -EOPNOTSUPP;
1116 } 1132 }