Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keyz182/3189152 to your computer and use it in GitHub Desktop.
Save keyz182/3189152 to your computer and use it in GitHub Desktop.
--- a/src/drivers/net/intel.c
+++ b/src/drivers/net/intel.c
@@ -181,21 +181,41 @@ static int intel_init_eeprom ( struct intel_nic *intel ) {
static int intel_fetch_mac_eeprom ( struct intel_nic *intel,
uint8_t *hw_addr ) {
int rc;
+ uint16_t offset;
/* Initialise EEPROM */
if ( ( rc = intel_init_eeprom ( intel ) ) != 0 )
return rc;
+ if ( ( rc = nvs_read ( &intel->eeprom, 0x37 /* NVM_ALT_MAC_ADDR_PTR */,
+ &offset, sizeof(offset) ) ) != 0 ) {
+ DBGC ( intel, "INTEL %p could not read EEPROM alternate MAC"
+ "address PTR: %s\n", intel, strerror ( rc ) );
+ return rc;
+ }
+
+ if (offset == 0xffff) {
+ /* There is no Alternate MAC Address */
+ return -1;
+ }
+
+ if (intel->port == 1)
+ offset += 3; /* E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 */
+
/* Read base MAC address from EEPROM */
- if ( ( rc = nvs_read ( &intel->eeprom, INTEL_EEPROM_MAC,
+ if ( ( rc = nvs_read ( &intel->eeprom, offset,
hw_addr, ETH_ALEN ) ) != 0 ) {
DBGC ( intel, "INTEL %p could not read EEPROM base MAC "
"address: %s\n", intel, strerror ( rc ) );
return rc;
}
- /* Adjust MAC address for multi-port devices */
- hw_addr[ETH_ALEN-1] ^= intel->port;
+ if ( ! is_valid_ether_addr ( hw_addr ) ) {
+ DBGC ( intel, "INTEL %p EEPROM MAC %s Tested as invalid, skipping ",
+ intel, eth_ntoa ( hw_addr ) );
+ return -1;
+ }
+
DBGC ( intel, "INTEL %p has EEPROM MAC address %s (port %d)\n",
intel, eth_ntoa ( hw_addr ), intel->port );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment