netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: [PATCH net-next-2.6 08/17] sfc: Expose Falcon BootROM config through MTD, not ethtool
Date: Thu, 02 Dec 2010 23:47:10 +0000	[thread overview]
Message-ID: <1291333630.3259.31.camel@bwh-desktop> (raw)
In-Reply-To: <1291333490.3259.23.camel@bwh-desktop>

The ethtool EEPROM interface is really meant for exposing chip
configuration, not BootROM configuration.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/ethtool.c |   59 ----------------------------------
 drivers/net/sfc/mtd.c     |   77 +++++++++++++++++++++++++++++++-------------
 2 files changed, 54 insertions(+), 82 deletions(-)

diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index edb9d16..00fb674 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -17,7 +17,6 @@
 #include "efx.h"
 #include "filter.h"
 #include "nic.h"
-#include "spi.h"
 #include "mdio_10g.h"
 
 struct ethtool_string {
@@ -629,61 +628,6 @@ static u32 efx_ethtool_get_link(struct net_device *net_dev)
 	return efx->link_state.up;
 }
 
-static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
-{
-	struct efx_nic *efx = netdev_priv(net_dev);
-	struct efx_spi_device *spi = efx->spi_eeprom;
-
-	if (!spi)
-		return 0;
-	return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
-		min(spi->size, EFX_EEPROM_BOOTCONFIG_START);
-}
-
-static int efx_ethtool_get_eeprom(struct net_device *net_dev,
-				  struct ethtool_eeprom *eeprom, u8 *buf)
-{
-	struct efx_nic *efx = netdev_priv(net_dev);
-	struct efx_spi_device *spi = efx->spi_eeprom;
-	size_t len;
-	int rc;
-
-	rc = mutex_lock_interruptible(&efx->spi_lock);
-	if (rc)
-		return rc;
-	rc = falcon_spi_read(efx, spi,
-			     eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
-			     eeprom->len, &len, buf);
-	mutex_unlock(&efx->spi_lock);
-
-	eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
-	eeprom->len = len;
-	return rc;
-}
-
-static int efx_ethtool_set_eeprom(struct net_device *net_dev,
-				  struct ethtool_eeprom *eeprom, u8 *buf)
-{
-	struct efx_nic *efx = netdev_priv(net_dev);
-	struct efx_spi_device *spi = efx->spi_eeprom;
-	size_t len;
-	int rc;
-
-	if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
-		return -EINVAL;
-
-	rc = mutex_lock_interruptible(&efx->spi_lock);
-	if (rc)
-		return rc;
-	rc = falcon_spi_write(efx, spi,
-			      eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
-			      eeprom->len, &len, buf);
-	mutex_unlock(&efx->spi_lock);
-
-	eeprom->len = len;
-	return rc;
-}
-
 static int efx_ethtool_get_coalesce(struct net_device *net_dev,
 				    struct ethtool_coalesce *coalesce)
 {
@@ -1116,9 +1060,6 @@ const struct ethtool_ops efx_ethtool_ops = {
 	.set_msglevel		= efx_ethtool_set_msglevel,
 	.nway_reset		= efx_ethtool_nway_reset,
 	.get_link		= efx_ethtool_get_link,
-	.get_eeprom_len		= efx_ethtool_get_eeprom_len,
-	.get_eeprom		= efx_ethtool_get_eeprom,
-	.set_eeprom		= efx_ethtool_set_eeprom,
 	.get_coalesce		= efx_ethtool_get_coalesce,
 	.set_coalesce		= efx_ethtool_set_coalesce,
 	.get_ringparam		= efx_ethtool_get_ringparam,
diff --git a/drivers/net/sfc/mtd.c b/drivers/net/sfc/mtd.c
index 02e54b4..d44c745 100644
--- a/drivers/net/sfc/mtd.c
+++ b/drivers/net/sfc/mtd.c
@@ -387,35 +387,66 @@ static struct efx_mtd_ops falcon_mtd_ops = {
 
 static int falcon_mtd_probe(struct efx_nic *efx)
 {
-	struct efx_spi_device *spi = efx->spi_flash;
+	struct efx_spi_device *spi;
 	struct efx_mtd *efx_mtd;
-	int rc;
+	int rc = -ENODEV;
 
 	ASSERT_RTNL();
 
-	if (!spi || spi->size <= FALCON_FLASH_BOOTCODE_START)
-		return -ENODEV;
-
-	efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
-			  GFP_KERNEL);
-	if (!efx_mtd)
-		return -ENOMEM;
-
-	efx_mtd->spi = spi;
-	efx_mtd->name = "flash";
-	efx_mtd->ops = &falcon_mtd_ops;
+	spi = efx->spi_flash;
+	if (spi && spi->size > FALCON_FLASH_BOOTCODE_START) {
+		efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
+				  GFP_KERNEL);
+		if (!efx_mtd)
+			return -ENOMEM;
+
+		efx_mtd->spi = spi;
+		efx_mtd->name = "flash";
+		efx_mtd->ops = &falcon_mtd_ops;
+
+		efx_mtd->n_parts = 1;
+		efx_mtd->part[0].mtd.type = MTD_NORFLASH;
+		efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
+		efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
+		efx_mtd->part[0].mtd.erasesize = spi->erase_size;
+		efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
+		efx_mtd->part[0].type_name = "sfc_flash_bootrom";
+
+		rc = efx_mtd_probe_device(efx, efx_mtd);
+		if (rc) {
+			kfree(efx_mtd);
+			return rc;
+		}
+	}
 
-	efx_mtd->n_parts = 1;
-	efx_mtd->part[0].mtd.type = MTD_NORFLASH;
-	efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
-	efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
-	efx_mtd->part[0].mtd.erasesize = spi->erase_size;
-	efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
-	efx_mtd->part[0].type_name = "sfc_flash_bootrom";
+	spi = efx->spi_eeprom;
+	if (spi && spi->size > EFX_EEPROM_BOOTCONFIG_START) {
+		efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
+				  GFP_KERNEL);
+		if (!efx_mtd)
+			return -ENOMEM;
+
+		efx_mtd->spi = spi;
+		efx_mtd->name = "EEPROM";
+		efx_mtd->ops = &falcon_mtd_ops;
+
+		efx_mtd->n_parts = 1;
+		efx_mtd->part[0].mtd.type = MTD_RAM;
+		efx_mtd->part[0].mtd.flags = MTD_CAP_RAM;
+		efx_mtd->part[0].mtd.size =
+			min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
+			EFX_EEPROM_BOOTCONFIG_START;
+		efx_mtd->part[0].mtd.erasesize = spi->erase_size;
+		efx_mtd->part[0].offset = EFX_EEPROM_BOOTCONFIG_START;
+		efx_mtd->part[0].type_name = "sfc_bootconfig";
+
+		rc = efx_mtd_probe_device(efx, efx_mtd);
+		if (rc) {
+			kfree(efx_mtd);
+			return rc;
+		}
+	}
 
-	rc = efx_mtd_probe_device(efx, efx_mtd);
-	if (rc)
-		kfree(efx_mtd);
 	return rc;
 }
 
-- 
1.7.3.2



-- 
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.


  parent reply	other threads:[~2010-12-02 23:47 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-02 23:44 sfc: Bug fixes and cleanup Ben Hutchings
2010-12-02 23:46 ` [PATCH net-next-2.6 01/17] sfc: Reduce log level for MCDI error response in efx_mcdi_rpc() Ben Hutchings
2010-12-03 17:08   ` David Miller
2010-12-02 23:46 ` [PATCH net-next-2.6 02/17] sfc: Fix condition for no-op in set_phy_flash_cfg() Ben Hutchings
2010-12-03 17:08   ` David Miller
2010-12-02 23:46 ` [PATCH net-next-2.6 03/17] sfc: Distinguish critical and non-critical over-temperature conditions Ben Hutchings
2010-12-03 17:08   ` David Miller
2010-12-02 23:46 ` [PATCH net-next-2.6 04/17] sfc: Read-to-clear LM87 alarm/interrupt status at start of day Ben Hutchings
2010-12-03 17:08   ` David Miller
2010-12-02 23:46 ` [PATCH net-next-2.6 05/17] sfc: Clear RXIN_SEL when soft-resetting QT2025C Ben Hutchings
2010-12-03 17:08   ` David Miller
2010-12-02 23:46 ` [PATCH net-next-2.6 06/17] sfc: Fix event based MCDI completion and MC REBOOT/CMDDONE ordering issue Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 07/17] sfc: Remove broken automatic fallback for invalid Falcon chip/board config Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` Ben Hutchings [this message]
2010-12-03 17:09   ` [PATCH net-next-2.6 08/17] sfc: Expose Falcon BootROM config through MTD, not ethtool David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 09/17] sfc: Remove unnecessary inclusion of various private header files Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 10/17] sfc: Move SPI state to struct falcon_nic_data Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 11/17] sfc: Move mdio_lock " Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 12/17] sfc: Move Falcon global event handling to falcon.c Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 13/17] sfc: Move xmac_poll_required into struct falcon_nic_data Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:47 ` [PATCH net-next-2.6 14/17] sfc: Update kernel-doc to match earlier move of Toeplitz hash key Ben Hutchings
2010-12-03 17:09   ` David Miller
2010-12-02 23:48 ` [PATCH net-next-2.6 15/17] sfc: When waking a stopped tx_queue, only lock that tx_queue Ben Hutchings
2010-12-03 17:10   ` David Miller
2010-12-02 23:48 ` [PATCH net-next-2.6 16/17] sfc: Use current MAC address, not NVRAM MAC address, for WoL filter Ben Hutchings
2010-12-03 17:10   ` David Miller
2010-12-02 23:48 ` [PATCH net-next-2.6 17/17] sfc: Store MAC address from NVRAM in net_device::perm_addr Ben Hutchings
2010-12-03 17:10   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291333630.3259.31.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).