netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool.
@ 2009-08-05 12:32 Ajit Khaparde
  2009-08-05 12:37 ` Ajit Khaparde
  0 siblings, 1 reply; 5+ messages in thread
From: Ajit Khaparde @ 2009-08-05 12:32 UTC (permalink / raw)
  To: davem, jgarzik, netdev

This patch adds kernel support for the new "-f" option in ethtool,
This will allow a firmware image to be flashed to a network device.

Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
---
 include/linux/ethtool.h |    3 +++
 net/core/ethtool.c      |   13 +++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 90c4a36..9b92f44 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -489,6 +489,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 *);
 };
 #endif /* __KERNEL__ */
 
@@ -545,6 +546,8 @@ 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
+					    * (ethtool_value). */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 44e5711..0524201 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -898,6 +898,16 @@ 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)
+{
+	int err;
+
+	if (!dev->ethtool_ops->flash_device)
+		return -EOPNOTSUPP;
+
+	return dev->ethtool_ops->flash_device(dev);
+}
+
 /* The main entry point in this file.  Called from net/core/dev.c */
 
 int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1111,6 +1121,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);
+		break;
 	default:
 		rc = -EOPNOTSUPP;
 	}
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool.
  2009-08-05 12:32 [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool Ajit Khaparde
@ 2009-08-05 12:37 ` Ajit Khaparde
  2009-08-05 13:06   ` Ben Hutchings
  0 siblings, 1 reply; 5+ messages in thread
From: Ajit Khaparde @ 2009-08-05 12:37 UTC (permalink / raw)
  To: davem, jgarzik, netdev

The patch intends to use the request_firmware() interface to pick the
firmware image file. 
I had missed this in the original post. Thanks.

On 05/08/09 18:02 +0530, Ajit Khaparde wrote:
> This patch adds kernel support for the new "-f" option in ethtool,
> This will allow a firmware image to be flashed to a network device.
> 
> Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
> ---
>  include/linux/ethtool.h |    3 +++
>  net/core/ethtool.c      |   13 +++++++++++++
>  2 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index 90c4a36..9b92f44 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -489,6 +489,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 *);
>  };
>  #endif /* __KERNEL__ */
>  
> @@ -545,6 +546,8 @@ 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
> +					    * (ethtool_value). */
>  
>  /* compatibility with older code */
>  #define SPARC_ETH_GSET		ETHTOOL_GSET
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index 44e5711..0524201 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -898,6 +898,16 @@ 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)
> +{
> +	int err;
> +
> +	if (!dev->ethtool_ops->flash_device)
> +		return -EOPNOTSUPP;
> +
> +	return dev->ethtool_ops->flash_device(dev);
> +}
> +
>  /* The main entry point in this file.  Called from net/core/dev.c */
>  
>  int dev_ethtool(struct net *net, struct ifreq *ifr)
> @@ -1111,6 +1121,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);
> +		break;
>  	default:
>  		rc = -EOPNOTSUPP;
>  	}
> -- 
> 1.6.0.4
> 
> --
> 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] 5+ messages in thread

* Re: [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool.
  2009-08-05 12:37 ` Ajit Khaparde
@ 2009-08-05 13:06   ` Ben Hutchings
  2009-08-05 20:17     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2009-08-05 13:06 UTC (permalink / raw)
  To: Ajit Khaparde; +Cc: davem, jgarzik, netdev

On Wed, 2009-08-05 at 18:07 +0530, Ajit Khaparde wrote:
> The patch intends to use the request_firmware() interface to pick the
> firmware image file. 
> I had missed this in the original post. Thanks.
[...]

Thanks for the clarification.

request_firmware() is meant for loading firmware that is stored in
volatile memory (RAM) on the device and therefore needs to be installed
on the host.

When the firmware is stored in flash on the device, updates only need to
be used once, and there should be no need to install them on the host.
So request_firmware() does not seem suitable.

I believe the ethtool EEPROM commands were meant for updating firmware
on NICs.  Although they assume random access and so are unsuitable for
flash-based firmware, they might be a better model for adding flash
update commands.  However, this command set is already available through
the MTD device class, which is what we use for firmware update as far as
possible.  Not only does this allow for an arbitrary number of separate
firmware partitions per network device, but it can be used in an
out-of-tree driver for older kernel versions.

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] 5+ messages in thread

* Re: [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool.
  2009-08-05 13:06   ` Ben Hutchings
@ 2009-08-05 20:17     ` David Miller
  2009-08-10  9:04       ` Ajit Khaparde
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2009-08-05 20:17 UTC (permalink / raw)
  To: bhutchings; +Cc: ajitk, jgarzik, netdev

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Wed, 05 Aug 2009 14:06:07 +0100

> request_firmware() is meant for loading firmware that is stored in
> volatile memory (RAM) on the device and therefore needs to be installed
> on the host.
> 
> When the firmware is stored in flash on the device, updates only need to
> be used once, and there should be no need to install them on the host.
> So request_firmware() does not seem suitable.
> 
> I believe the ethtool EEPROM commands were meant for updating firmware
> on NICs.  Although they assume random access and so are unsuitable for
> flash-based firmware, they might be a better model for adding flash
> update commands.  However, this command set is already available through
> the MTD device class, which is what we use for firmware update as far as
> possible.  Not only does this allow for an arbitrary number of separate
> firmware partitions per network device, but it can be used in an
> out-of-tree driver for older kernel versions.

I mostly agree with this.  Either use MTD or create an ethtool
operation that explicitly specifies the file to flash onto the
chip.  If you want, I suppose you can take no explicit file
specification to mean "whatever firmware was loaded into the
chip by the driver and is running right now"


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool.
  2009-08-05 20:17     ` David Miller
@ 2009-08-10  9:04       ` Ajit Khaparde
  0 siblings, 0 replies; 5+ messages in thread
From: Ajit Khaparde @ 2009-08-10  9:04 UTC (permalink / raw)
  To: David Miller; +Cc: bhutchings, jgarzik, netdev

On 05/08/09 13:17 -0700, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Wed, 05 Aug 2009 14:06:07 +0100
> 
> > request_firmware() is meant for loading firmware that is stored in
> > volatile memory (RAM) on the device and therefore needs to be installed
> > on the host.
> > 
> > When the firmware is stored in flash on the device, updates only need to
> > be used once, and there should be no need to install them on the host.
> > So request_firmware() does not seem suitable.
> > 
> > I believe the ethtool EEPROM commands were meant for updating firmware
> > on NICs.  Although they assume random access and so are unsuitable for
> > flash-based firmware, they might be a better model for adding flash
> > update commands.  However, this command set is already available through
> > the MTD device class, which is what we use for firmware update as far as
> > possible.  Not only does this allow for an arbitrary number of separate
> > firmware partitions per network device, but it can be used in an
> > out-of-tree driver for older kernel versions.
> 
> I mostly agree with this.  Either use MTD or create an ethtool
> operation that explicitly specifies the file to flash onto the
> chip.  If you want, I suppose you can take no explicit file
> specification to mean "whatever firmware was loaded into the
> chip by the driver and is running right now"
Thanks. I will go with the ethtool option which would also take the 
filename and flash it onto the chip using the request_firmware() path.

-Ajit
> 
> --
> 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] 5+ messages in thread

end of thread, other threads:[~2009-08-10  9:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-05 12:32 [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool Ajit Khaparde
2009-08-05 12:37 ` Ajit Khaparde
2009-08-05 13:06   ` Ben Hutchings
2009-08-05 20:17     ` David Miller
2009-08-10  9:04       ` 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).