* [RFC][PATCH][v4] net/ethtool: Add support for the ethtool feature to flash firmware image from a specified file.
@ 2009-08-20 17:16 Ajit Khaparde
2009-08-20 17:24 ` Ben Hutchings
0 siblings, 1 reply; 3+ messages in thread
From: Ajit Khaparde @ 2009-08-20 17:16 UTC (permalink / raw)
To: davem, jgarzik, netdev
This patch adds support to flash a firmware image to a device using ethtool.
The driver gets the filename of the firmware image and flashes the image
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.
Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
---
include/linux/ethtool.h | 14 ++++++++++++++
net/core/ethtool.c | 17 +++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 90c4a36..7614267 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -362,6 +362,18 @@ struct ethtool_rxnfc {
__u32 rule_locs[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];
+};
+
#ifdef __KERNEL__
struct net_device;
@@ -489,6 +501,7 @@ struct ethtool_ops {
int (*get_stats_count)(struct net_device *);/* use get_sset_count */
int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *);
int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
+ int (*flash_device)(struct net_device *, u8 *);
};
#endif /* __KERNEL__ */
@@ -545,6 +558,7 @@ struct ethtool_ops {
#define ETHTOOL_GRXCLSRLALL 0x00000030 /* Get all RX classification rule */
#define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */
#define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */
+#define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 44e5711..fbcd9f7 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -898,6 +898,20 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
return actor(dev, edata.data);
}
+static int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
+{
+ int err;
+ struct ethtool_flash efl;
+
+ if (copy_from_user(&efl, useraddr, sizeof(efl)))
+ return -EFAULT;
+
+ if (!dev->ethtool_ops->flash_device)
+ return -EOPNOTSUPP;
+
+ return dev->ethtool_ops->flash_device(dev, &efl);
+}
+
/* The main entry point in this file. Called from net/core/dev.c */
int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1111,6 +1125,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_SGRO:
rc = ethtool_set_gro(dev, useraddr);
break;
+ case ETHTOOL_FLASHDEV:
+ rc = ethtool_flash_device(dev, useraddr);
+ break;
default:
rc = -EOPNOTSUPP;
}
--
1.6.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH][v4] net/ethtool: Add support for the ethtool feature to flash firmware image from a specified file.
2009-08-20 17:16 [RFC][PATCH][v4] net/ethtool: Add support for the ethtool feature to flash firmware image from a specified file Ajit Khaparde
@ 2009-08-20 17:24 ` Ben Hutchings
2009-08-20 17:44 ` Ajit Khaparde
0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2009-08-20 17:24 UTC (permalink / raw)
To: Ajit Khaparde; +Cc: davem, jgarzik, netdev
On Thu, 2009-08-20 at 22:46 +0530, Ajit Khaparde wrote:
[...]
> @@ -489,6 +501,7 @@ struct ethtool_ops {
> int (*get_stats_count)(struct net_device *);/* use get_sset_count */
> int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *);
> int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
> + int (*flash_device)(struct net_device *, u8 *);
[...]
The second parameter type should be struct ethtool_flash * not u8 *.
The compiler warning should make this easy to spot...
Ben.
--
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH][v4] net/ethtool: Add support for the ethtool feature to flash firmware image from a specified file.
2009-08-20 17:24 ` Ben Hutchings
@ 2009-08-20 17:44 ` Ajit Khaparde
0 siblings, 0 replies; 3+ messages in thread
From: Ajit Khaparde @ 2009-08-20 17:44 UTC (permalink / raw)
To: Ben Hutchings; +Cc: davem, jgarzik, netdev
On 20/08/09 18:24 +0100, Ben Hutchings wrote:
> On Thu, 2009-08-20 at 22:46 +0530, Ajit Khaparde wrote:
> [...]
> > @@ -489,6 +501,7 @@ struct ethtool_ops {
> > int (*get_stats_count)(struct net_device *);/* use get_sset_count */
> > int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, void *);
> > int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
> > + int (*flash_device)(struct net_device *, u8 *);
> [...]
>
> The second parameter type should be struct ethtool_flash * not u8 *.
> The compiler warning should make this easy to spot...
Thanks for the catch. My bad. To get over my slow net connection today, I did
a make with the -j option, before I cut the patch. I missed the
warning between the other messages.
Thanks
-Ajit
>
> Ben.
>
> --
> 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.
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-20 17:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-20 17:16 [RFC][PATCH][v4] net/ethtool: Add support for the ethtool feature to flash firmware image from a specified file Ajit Khaparde
2009-08-20 17:24 ` Ben Hutchings
2009-08-20 17:44 ` Ajit Khaparde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).