From patchwork Wed Aug 5 12:32:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 30787 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id E1B23B6F31 for ; Wed, 5 Aug 2009 22:32:27 +1000 (EST) Received: by ozlabs.org (Postfix) id D5D37DDD0C; Wed, 5 Aug 2009 22:32:27 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 514B9DDD04 for ; Wed, 5 Aug 2009 22:32:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933707AbZHEMcO (ORCPT ); Wed, 5 Aug 2009 08:32:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933610AbZHEMcN (ORCPT ); Wed, 5 Aug 2009 08:32:13 -0400 Received: from segment-124-30.sify.net ([124.30.166.146]:8046 "EHLO akhaparde.serverengines.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933564AbZHEMcN (ORCPT ); Wed, 5 Aug 2009 08:32:13 -0400 Received: by akhaparde.serverengines.com (Postfix, from userid 1000) id 0BFBB32362; Wed, 5 Aug 2009 18:02:13 +0530 (IST) Date: Wed, 5 Aug 2009 18:02:13 +0530 From: Ajit Khaparde To: davem@davemloft.net, jgarzik@pobox.com, netdev@vger.kernel.org Subject: [PATCH net-next-2.6] net: Changes to support the "-f" option of ethtool. Message-ID: <20090805123211.GB6592@serverengines.com> Reply-To: Ajit Khaparde MIME-Version: 1.0 Content-Disposition: inline X-URL: http://www.serverengines.com Organization: ServerEngines Corp User-Agent: "Ajit's Mutt" X-OS: Linux x86_64 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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; }