瀏覽代碼

sfc: Clean up non-volatile memory partitioning

Move flash and EEPROM partition boundary constants into spi.h and rename
them to be consistent.

Add a comment on the partitioning.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Ben Hutchings 16 年之前
父節點
當前提交
0a95f56323
共有 4 個文件被更改,包括 24 次插入11 次删除
  1. 4 7
      drivers/net/sfc/ethtool.c
  2. 3 3
      drivers/net/sfc/falcon.c
  3. 0 1
      drivers/net/sfc/falcon_hwdefs.h
  4. 17 0
      drivers/net/sfc/spi.h

+ 4 - 7
drivers/net/sfc/ethtool.c

@@ -172,10 +172,7 @@ static struct efx_ethtool_stat efx_ethtool_stats[] = {
 /* Number of ethtool statistics */
 /* Number of ethtool statistics */
 #define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
 #define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
 
 
-/* EEPROM range with gPXE configuration */
 #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
 #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
-#define EFX_ETHTOOL_EEPROM_MIN 0x800U
-#define EFX_ETHTOOL_EEPROM_MAX 0x1800U
 
 
 /**************************************************************************
 /**************************************************************************
  *
  *
@@ -545,8 +542,8 @@ static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
 
 
 	if (!spi)
 	if (!spi)
 		return 0;
 		return 0;
-	return min(spi->size, EFX_ETHTOOL_EEPROM_MAX) -
-		min(spi->size, EFX_ETHTOOL_EEPROM_MIN);
+	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,
 static int efx_ethtool_get_eeprom(struct net_device *net_dev,
@@ -557,7 +554,7 @@ static int efx_ethtool_get_eeprom(struct net_device *net_dev,
 	size_t len;
 	size_t len;
 	int rc;
 	int rc;
 
 
-	rc = falcon_spi_read(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN,
+	rc = falcon_spi_read(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
 			     eeprom->len, &len, buf);
 			     eeprom->len, &len, buf);
 	eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
 	eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
 	eeprom->len = len;
 	eeprom->len = len;
@@ -575,7 +572,7 @@ static int efx_ethtool_set_eeprom(struct net_device *net_dev,
 	if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
 	if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
 		return -EINVAL;
 		return -EINVAL;
 
 
-	rc = falcon_spi_write(spi, eeprom->offset + EFX_ETHTOOL_EEPROM_MIN,
+	rc = falcon_spi_write(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
 			      eeprom->len, &len, buf);
 			      eeprom->len, &len, buf);
 	eeprom->len = len;
 	eeprom->len = len;
 	return rc;
 	return rc;

+ 3 - 3
drivers/net/sfc/falcon.c

@@ -2253,13 +2253,13 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
 	__le16 *word, *limit;
 	__le16 *word, *limit;
 	u32 csum;
 	u32 csum;
 
 
-	region = kmalloc(NVCONFIG_END, GFP_KERNEL);
+	region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL);
 	if (!region)
 	if (!region)
 		return -ENOMEM;
 		return -ENOMEM;
 	nvconfig = region + NVCONFIG_OFFSET;
 	nvconfig = region + NVCONFIG_OFFSET;
 
 
 	spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom;
 	spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom;
-	rc = falcon_spi_read(spi, 0, NVCONFIG_END, NULL, region);
+	rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region);
 	if (rc) {
 	if (rc) {
 		EFX_ERR(efx, "Failed to read %s\n",
 		EFX_ERR(efx, "Failed to read %s\n",
 			efx->spi_flash ? "flash" : "EEPROM");
 			efx->spi_flash ? "flash" : "EEPROM");
@@ -2283,7 +2283,7 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
 		limit = (__le16 *) (nvconfig + 1);
 		limit = (__le16 *) (nvconfig + 1);
 	} else {
 	} else {
 		word = region;
 		word = region;
-		limit = region + NVCONFIG_END;
+		limit = region + FALCON_NVCONFIG_END;
 	}
 	}
 	for (csum = 0; word < limit; ++word)
 	for (csum = 0; word < limit; ++word)
 		csum += le16_to_cpu(*word);
 		csum += le16_to_cpu(*word);

+ 0 - 1
drivers/net/sfc/falcon_hwdefs.h

@@ -1150,7 +1150,6 @@ struct falcon_nvconfig_board_v3 {
 	(((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
 	(((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
 
 
 #define NVCONFIG_OFFSET 0x300
 #define NVCONFIG_OFFSET 0x300
-#define NVCONFIG_END 0x400
 
 
 #define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
 #define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
 struct falcon_nvconfig {
 struct falcon_nvconfig {

+ 17 - 0
drivers/net/sfc/spi.h

@@ -63,4 +63,21 @@ int falcon_spi_read(const struct efx_spi_device *spi, loff_t start,
 int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
 int falcon_spi_write(const struct efx_spi_device *spi, loff_t start,
 		     size_t len, size_t *retlen, const u8 *buffer);
 		     size_t len, size_t *retlen, const u8 *buffer);
 
 
+/*
+ * SFC4000 flash is partitioned into:
+ *     0-0x400       chip and board config (see falcon_hwdefs.h)
+ *     0x400-0x8000  unused (or may contain VPD if EEPROM not present)
+ *     0x8000-end    boot code (mapped to PCI expansion ROM)
+ * SFC4000 small EEPROM (size < 0x400) is used for VPD only.
+ * SFC4000 large EEPROM (size >= 0x400) is partitioned into:
+ *     0-0x400       chip and board config
+ *     configurable  VPD
+ *     0x800-0x1800  boot config
+ * Aside from the chip and board config, all of these are optional and may
+ * be absent or truncated depending on the devices used.
+ */
+#define FALCON_NVCONFIG_END 0x400U
+#define EFX_EEPROM_BOOTCONFIG_START 0x800U
+#define EFX_EEPROM_BOOTCONFIG_END 0x1800U
+
 #endif /* EFX_SPI_H */
 #endif /* EFX_SPI_H */