ethtool: Add a new ethtool option to flash a firmware image from the specified file to a device.
Subsystems (2)
RFC PATCH v4 1/1 ethtool: Add a new ethtool option to flash a firmware image from the specified file to a device.
This patch adds a new "-f" option to the ethtool utility
to flash a firmware image specified by a file, to a network device. The filename is passed to the network driver which will flash the image on the chip using the request_firmware path.
The region "on the chip" to be flashed can be specified by an option. It is upto the device driver to enumerate the region number passed by ethtool, to the region to be flashed.
The default behavior is to flash all the regions on the chip.
Usage:
ethtool -f <interface name> <filename of firmware image>
ethtool -f <interface name> <filename of firmware image> [ REGION-NUMBER-TO-FLASH ]
--- ethtool-copy.h | 13 +++++++++++++ ethtool.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletions(-)
ethtool-copy.h +13 -0
@@ -272,6 +272,18 @@ struct ethtool_perm_addr {__u8 data[0 ]; }; +#define ETHTOOL_FLASH_MAX_FILENAME 128 +enum ethtool_flash_op_type { +ETHTOOL_FLASH_ALL_REGIONS =0 , +}; + +/* for passing firmware flashing related parameters */ +struct ethtool_flash { +__u32 cmd; +__u32 region; +char data[ETHTOOL_FLASH_MAX_FILENAME ]; +}; +/* boolean flags controlling per-interface behavior characteristics. * When reading, the flag indicates whether or not a certain behavior * is enabled/present. When writing, the flag indicates whether
@@ -338,6 +350,7 @@ struct ethtool_rxnfc {#define ETHTOOL_SRXFH 0x0000002a/* Set RX flow hash configuration */ #define ETHTOOL_GGRO 0x0000002b/* Get GRO enable (ethtool_value) */ #define ETHTOOL_SGRO 0x0000002c/* Set GRO enable (ethtool_value) */ +#define ETHTOOL_FLASHDEV 0x00000033/* Flash firmware to device */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET
ethtool.c +54 -1
109 lines not on this page · raw message
Signature · 1 line
1.6.0.4
Quoted 4 lines · Ajit Khaparde
This patch adds a new "-f" option to the ethtool utility
to flash a firmware image specified by a file, to a network device. The filename is passed to the network driver which will flash the image on the chip using therequest_firmwarepath.
[...]
ethtool.c static int rx_fhash_get = 0; · line 312
Quoted 5 lines
ethtool.c +1
-0@@ -304,6 +309,9 @@ static int rx_fhash_get = 0;static int rx_fhash_set =0 ;static u32 rx_fhash_val =0 ;static int rx_fhash_changed =0 ; +static char flash_file[ETHTOOL_FLASH_MAX_FILENAME ];
It would be much simpler to make this a pointer...
Quoted 5 lines
ethtool.c +2
-0+static int flash =-1 ; +static int flash_region =0 ; static enum { ONLINE=0, OFFLINE,
[...]
ethtool.c static void parse_cmdline(int argc, char **argp) · line 529
Quoted 6 lines
ethtool.c +2
-0@@ -516,6 +525,10 @@ static void parse_cmdline(int argc, char **argp)if (phys_id_time <0 )show_usage (1 );break ; + }else if (mode ==MODE_FLASHDEV ) { +sprintf (flash_file,"%s" , argp[i]);
...and to change this to "flash_file = argp[i];"...
Quoted 5 lines
ethtool.c +2
-0+ flash =1 ; +break ; }/* fallthrough */ default :
[...]
Quoted 9 lines
ethtool.c +5
-0@@ -2398,6 +2419,38 @@ static int do_grxclass(int fd, struct ifreq *ifr)return 0 ; } +static int do_flash (int fd,struct ifreq *ifr) +{ +struct ethtool_flash efl; +int err; +
ethtool.c static int do_grxclass(int fd, struct ifreq *ifr) · line 2436
Quoted 10 lines
ethtool.c +10
-0+if (flash <0 ) { +fprintf (stdout,"Missing filename argument\n" ); +show_usage (1 ); +return 98 ; + } + +if (strlen (flash_file) >ETHTOOL_FLASH_MAX_FILENAME -1 ) { +fprintf (stdout,"Filename too long\n" ); +return 99 ; + }
[...]
...and then this length check would work properly.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.