From: Jesse Brandeburg <jesse.brandeburg@intel.com>
To: linux-kernel@vger.kernel.org
Cc: linux-netdev@vger.kernel.org, kkeil@suse.de, agospoda@redhat.com,
arjan@linux.intel.com, david.graham@intel.com,
bruce.w.allan@intel.com, jkosina@suse.cz, john.ronciak@intel.com,
tglx@linutronix.de, chris.jones@canonical.com,
tim.gardner@intel.com, airlied@gmail.com,
Jesse Brandeburg <jesse.brandeburg@intel.com>
Subject: [RFC PATCH 08/12] e1000e: allow bad checksum
Date: Mon, 29 Sep 2008 20:19:58 -0700 [thread overview]
Message-ID: <20080930031957.22950.5669.stgit@jbrandeb-bw.jf.intel.com> (raw)
In-Reply-To: <20080930030825.22950.18891.stgit@jbrandeb-bw.jf.intel.com>
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 <jesse.brandeburg@intel.com>
---
drivers/net/e1000e/netdev.c | 81 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 9aa3c79..48b0ded 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
@@ -4527,31 +4573,39 @@ 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);
+ break;
}
}
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);
@@ -4640,7 +4694,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:
next prev parent reply other threads:[~2008-09-30 3:22 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-30 3:19 [RFC PATCH 00/12] e1000e debug and protection patches Jesse Brandeburg
2008-09-30 3:19 ` [RFC PATCH 01/12] x86: export set_memory_ro and set_memory_rw Jesse Brandeburg
2008-09-30 7:07 ` Ingo Molnar
2008-09-30 3:19 ` [RFC PATCH 02/12] On Tue, 23 Sep 2008, David Miller wrote: Jesse Brandeburg
2008-10-02 22:23 ` Jesse Barnes
2008-10-03 20:46 ` David Miller
2008-10-03 21:29 ` Jesse Barnes
2008-10-03 21:45 ` Jiri Kosina
2008-10-03 23:28 ` Jesse Brandeburg
2008-10-03 23:30 ` Jesse Brandeburg
2008-10-04 10:21 ` Jiri Kosina
2008-10-04 11:02 ` Thomas Gleixner
2008-10-05 1:24 ` Jesse Brandeburg
2008-10-05 8:51 ` Thomas Gleixner
2008-10-05 15:05 ` Arjan van de Ven
2008-10-05 15:55 ` Thomas Gleixner
2008-10-05 16:02 ` Arjan van de Ven
2008-10-05 16:16 ` Thomas Gleixner
2008-10-05 17:01 ` Arjan van de Ven
2008-10-07 23:19 ` David Miller
2008-09-30 3:19 ` [RFC PATCH 03/12] e1000e: reset swflag after resetting hardware Jesse Brandeburg
2008-09-30 3:19 ` [RFC PATCH 04/12] e1000e: do not ever sleep in interrupt context Jesse Brandeburg
2008-09-30 3:19 ` [RFC PATCH 05/12] e1000e: fix lockdep issues Jesse Brandeburg
2008-09-30 3:19 ` [RFC PATCH 06/12] e1000e: drop stats lock Jesse Brandeburg
2008-09-30 3:19 ` [RFC PATCH 07/12] e1000e: debug contention on NVM SWFLAG Jesse Brandeburg
2008-10-02 14:28 ` Jiri Kosina
2008-10-02 15:03 ` Olaf Kirch
2008-10-02 16:27 ` Brandeburg, Jesse
2008-10-02 17:33 ` Olaf Kirch
2008-10-02 18:58 ` Thomas Gleixner
2008-10-02 19:07 ` Olaf Kirch
2008-10-02 19:08 ` Olaf Kirch
2008-10-02 18:02 ` Thomas Gleixner
2008-10-02 23:42 ` [PATCH] e1000e: prevent concurrent access to NVRAM Thomas Gleixner
2008-10-03 0:19 ` Jesse Brandeburg
2008-10-03 0:28 ` Thomas Gleixner
2008-09-30 3:19 ` Jesse Brandeburg [this message]
2008-09-30 8:38 ` [RFC PATCH 08/12] e1000e: allow bad checksum Jiri Kosina
2008-09-30 3:20 ` [RFC PATCH 09/12] e1000e: dump eeprom to dmesg for ich8/9 Jesse Brandeburg
2008-09-30 3:20 ` [RFC PATCH 10/12] e1000e: Use set_memory_ro()/set_memory_rw() to protect flash memory Jesse Brandeburg
2008-09-30 3:20 ` [RFC PATCH 11/12] e1000e: write protect ICHx NVM to prevent malicious write/erase Jesse Brandeburg
2008-09-30 12:40 ` Jiri Kosina
2008-09-30 15:47 ` Allan, Bruce W
2008-10-01 13:29 ` Jiri Kosina
2008-10-01 19:13 ` Allan, Bruce W
2008-09-30 3:20 ` [RFC PATCH 12/12] update version Jesse Brandeburg
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=20080930031957.22950.5669.stgit@jbrandeb-bw.jf.intel.com \
--to=jesse.brandeburg@intel.com \
--cc=agospoda@redhat.com \
--cc=airlied@gmail.com \
--cc=arjan@linux.intel.com \
--cc=bruce.w.allan@intel.com \
--cc=chris.jones@canonical.com \
--cc=david.graham@intel.com \
--cc=jkosina@suse.cz \
--cc=john.ronciak@intel.com \
--cc=kkeil@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tim.gardner@intel.com \
/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
all inboxes | Powered by JetHome®