summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2011-02-06 23:47:15 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2011-02-06 23:47:15 +0000
commit21c01657aec0fb1c59da7f68798c6121189a789d (patch)
treee3c48addde162268d7fd82ab9eec67fffc7084a9
parentc2001eec5487d17ec1b19f75883f9663f682981b (diff)
cap the max size of the eeprom to 16k, as per the linux and freebsd
drivers. fix found by jonathan matthew and tested on an "Intel PRO/1000 (82576)" rev 0x01 which didnt work before this change. tested by jsg on the following chips: "Intel PRO/1000MT (82540EP)" rev 0x03 "Intel PRO/1000MT (82541GI)" rev 0x05 "Intel PRO/1000 MT (82574L)" rev 0x00 "Intel EP80579 LAN" rev 0x01 "Intel PRO/1000 PT (82572EI)" rev 0x06 "Intel PRO/1000 (82576)" rev 0x01 "Intel 82578DM" rev 0x06 "Intel I340-T4 (82580)" rev 0x01 some style issues are still being discussed which can be fixed in tree if necessary. ok jsg@
-rw-r--r--sys/dev/pci/if_em_hw.c12
-rw-r--r--sys/dev/pci/if_em_hw.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/pci/if_em_hw.c b/sys/dev/pci/if_em_hw.c
index b007600b646..20d9ce86f80 100644
--- a/sys/dev/pci/if_em_hw.c
+++ b/sys/dev/pci/if_em_hw.c
@@ -31,7 +31,7 @@
*******************************************************************************/
-/* $OpenBSD: if_em_hw.c,v 1.58 2010/09/19 13:10:21 yasuoka Exp $ */
+/* $OpenBSD: if_em_hw.c,v 1.59 2011/02/06 23:47:14 dlg Exp $ */
/*
* if_em_hw.c Shared functions for accessing and configuring the MAC
*/
@@ -5353,8 +5353,14 @@ em_init_eeprom_params(struct em_hw *hw)
E1000_EECD_SIZE_EX_SHIFT);
}
- eeprom->word_size = 1 <<
- (eeprom_size + EEPROM_WORD_SIZE_SHIFT);
+ /* EEPROM access above 16k is unsupported */
+ if (eeprom_size + EEPROM_WORD_SIZE_SHIFT >
+ EEPROM_WORD_SIZE_SHIFT_MAX) {
+ eeprom->word_size = 1 << EEPROM_WORD_SIZE_SHIFT_MAX;
+ } else {
+ eeprom->word_size = 1 <<
+ (eeprom_size + EEPROM_WORD_SIZE_SHIFT);
+ }
}
return ret_val;
}
diff --git a/sys/dev/pci/if_em_hw.h b/sys/dev/pci/if_em_hw.h
index d094b887d25..e2770c0c3fa 100644
--- a/sys/dev/pci/if_em_hw.h
+++ b/sys/dev/pci/if_em_hw.h
@@ -31,7 +31,7 @@
*******************************************************************************/
-/* $OpenBSD: if_em_hw.h,v 1.46 2010/09/19 13:10:21 yasuoka Exp $ */
+/* $OpenBSD: if_em_hw.h,v 1.47 2011/02/06 23:47:14 dlg Exp $ */
/* $FreeBSD: if_em_hw.h,v 1.15 2005/05/26 23:32:02 tackerman Exp $ */
/* if_em_hw.h
@@ -2353,6 +2353,7 @@ struct em_host_command_info {
/* EEPROM Size definitions */
#define EEPROM_WORD_SIZE_SHIFT 6
+#define EEPROM_WORD_SIZE_SHIFT_MAX 14
#define EEPROM_SIZE_SHIFT 10
#define EEPROM_SIZE_MASK 0x1C00