Re: e1000e NVM corruption issue status

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Brandeburg, Jesse <jesse.brandeburg@...>
Cc: LKML <linux-kernel@...>, Jiri Kosina <jkosina@...>, <agospoda@...>, Ronciak, John <john.ronciak@...>, Allan, Bruce W <bruce.w.allan@...>, Graham, David <david.graham@...>, <kkiel@...>, <tglx@...>, <chris.jones@...>, <arjan@...>
Date: Thursday, September 25, 2008 - 10:12 pm

e1000e: allow bad checksum

From: Jesse Brandeburg

currently if the driver notices a bad checksum it will fail to
load. This patch allows the driver load process to continue with
an invalid mac address and could allow the user to use ethtool or
another app to fix the eeprom.

copied from implementation in e1000

Signed-off-by: Jesse Brandeburg
---

drivers/net/e1000e/netdev.c | 80 +++++++++++++++++++++++++++++++++++--------
1 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 89ca272..ad026d0 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4338,6 +4338,52 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
}

/**
+ * e1000e_dump_eeprom - write the eeprom to kernel log
+ * @adapter: our adapter struct
+ *
+ * Dump the eeprom for users having checksum issues
+ **/
+static void e1000e_dump_eeprom(struct e1000_adapter *adapter)
+{
+ struct net_device *netdev = adapter->netdev;
+ struct ethtool_eeprom eeprom;
+ const struct ethtool_ops *ops = netdev->ethtool_ops;
+ u8 *data;
+ int i;
+ u16 csum_old, csum_new = 0;
+
+ eeprom.len = ops->get_eeprom_len(netdev);
+ eeprom.offset = 0;
+
+ data = kzalloc(eeprom.len, GFP_KERNEL);
+ if (!data) {
+ printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
+ " data\n");
+ return;
+ }
+
+ ops->get_eeprom(netdev, &eeprom, data);
+
+ csum_old = (data[NVM_CHECKSUM_REG * 2]) +
+ (data[NVM_CHECKSUM_REG * 2 + 1] << 8);
+ for (i = 0; i < NVM_CHECKSUM_REG * 2; i += 2)
+ csum_new += data[i] + (data[i + 1] << 8);
+ csum_new = NVM_SUM - csum_new;
+
+ printk(KERN_ERR "/*********************/\n");
+ printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
+ printk(KERN_ERR "Calculated : 0x%04x\n", csum_new);
+
+ printk(KERN_ERR "Offset Values\n");
+ printk(KERN_ERR "======== ======\n");
+ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
+
+ printk(KERN_ERR "/*********************/\n");
+
+ kfree(data);
+}
+
+/**
* e1000_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in e1000_pci_tbl
@@ -4530,31 +4576,38 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
* attempt. Let's give it a few tries
*/
for (i = 0;; i++) {
- if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
+ if (e1000_validate_nvm_checksum(hw) >= 0) {
+ /* copy the MAC address out of the NVM */
+ if (e1000e_read_mac_addr(&adapter->hw))
+ e_err("NVM Read Error reading MAC address\n");
break;
+ }
if (i == 2) {
e_err("The NVM Checksum Is Not Valid\n");
- err = -EIO;
- goto err_eeprom;
+ e1000e_dump_eeprom(adapter);
+ /*
+ * set MAC address to all zeroes to invalidate and
+ * temporary disable this device for the user. This
+ * blocks regular traffic while still permitting
+ * ethtool ioctls from reaching the hardware as well as
+ * allowing the user to run the interface after
+ * manually setting a hw addr using
+ * `ip link set address`
+ */
+ memset(hw->mac.addr, 0, netdev->addr_len);
}
}

e1000_eeprom_checks(adapter);

- /* copy the MAC address out of the NVM */
- if (e1000e_read_mac_addr(&adapter->hw))
- e_err("NVM Read Error while reading MAC address\n");
-
+ /* don't block initalization here due to bad MAC address */
memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);

if (!is_valid_ether_addr(netdev->perm_addr)) {
- e_err("Invalid MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
- netdev->perm_addr[0], netdev->perm_addr[1],
- netdev->perm_addr[2], netdev->perm_addr[3],
- netdev->perm_addr[4], netdev->perm_addr[5]);
- err = -EIO;
- goto err_eeprom;
+ DECLARE_MAC_BUF(mac);
+ e_err("Invalid MAC Address: %s\n",
+ print_mac(mac, netdev->perm_addr));
}

init_timer(&adapter->watchdog_timer);
@@ -4643,7 +4696,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
err_register:
if (!(adapter->flags & FLAG_HAS_AMT))
e1000_release_hw_control(adapter);
-err_eeprom:
if (!e1000_check_reset_block(&adapter->hw))
e1000_phy_hw_reset(&adapter->hw);
err_hw_init:
--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 9:50 pm)
Re: e1000e NVM corruption issue status, James Courtier-Dutton, (Sat Oct 18, 3:13 pm)
Re: e1000e NVM corruption issue status, Jiri Kosina, (Sat Oct 18, 6:49 pm)
Re: e1000e NVM corruption issue status, Karsten Keil, (Fri Sep 26, 3:19 am)
Re: e1000e NVM corruption issue status, Jesse Brandeburg, (Fri Sep 26, 1:44 am)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:01 pm)
Re: e1000e NVM corruption issue status, Karsten Keil, (Fri Sep 26, 10:23 am)
Re: e1000e NVM corruption issue status, Jiri Kosina, (Fri Sep 26, 2:13 am)
Re: e1000e NVM corruption issue status, Arjan van de Ven, (Fri Sep 26, 7:49 am)
Re: e1000e NVM corruption issue status, Jesse Barnes, (Fri Sep 26, 1:52 pm)
Re: e1000e NVM corruption issue status, Jesse Barnes, (Fri Sep 26, 2:23 pm)
Re: e1000e NVM corruption issue status, Tim Gardner, (Fri Sep 26, 2:53 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Fri Sep 26, 8:05 pm)
Re: e1000e NVM corruption issue status, Tim Gardner, (Sat Sep 27, 12:20 am)
Re: e1000e NVM corruption issue status, Krzysztof Halasa, (Fri Sep 26, 6:04 pm)
RE: e1000e NVM corruption issue status, Brandeburg, Jesse, (Fri Sep 26, 6:23 pm)
Re: e1000e NVM corruption issue status, Krzysztof Halasa, (Sat Sep 27, 2:45 pm)
Re: e1000e NVM corruption issue status, Jesse Barnes, (Fri Sep 26, 2:39 pm)
Re: e1000e NVM corruption issue status, Jesse Barnes, (Fri Sep 26, 2:43 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:13 pm)
Re: e1000e NVM corruption issue status, Jiri Kosina, (Mon Sep 29, 11:52 am)
Re: e1000e NVM corruption issue status, Jiri Kosina, (Mon Sep 29, 12:20 pm)
RE: e1000e NVM corruption issue status, Brandeburg, Jesse, (Mon Sep 29, 12:24 pm)
RE: e1000e NVM corruption issue status, Jiri Kosina, (Mon Sep 29, 1:18 pm)
RE: e1000e NVM corruption issue status, Jiri Kosina, (Mon Sep 29, 1:36 pm)
RE: e1000e NVM corruption issue status, Jiri Kosina, (Mon Sep 29, 6:43 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:13 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:12 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:12 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:11 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:11 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:10 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:10 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:10 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:09 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:09 pm)
Re: e1000e NVM corruption issue status, Ingo Molnar, (Fri Sep 26, 3:12 am)
Re: e1000e NVM corruption issue status, Chris Snook, (Thu Sep 25, 9:58 pm)
Re: e1000e NVM corruption issue status, Brandeburg, Jesse, (Thu Sep 25, 10:04 pm)