<div>Oh, sorry. Got you.</div><div> </div><div>From the Linux igb driver: </div><div>/**<br /> * igb_check_alt_mac_addr - Check for alternate MAC addr<br /> * @hw: pointer to the HW structure<br /> *<br /> * Checks the nvm for an alternate MAC address. An alternate MAC address<br /> * can be setup by pre-boot software and must be treated like a permanent<br /> * address and must override the actual permanent MAC address. If an<br /> * alternate MAC address is <em>fopund</em> it is saved in the hw struct and<br /> * <em>prgrammed</em> into RAR0 and the cuntion returns success, otherwise the<br /> * function returns an error.<br /> **/</div><div> </div><div>igb_check_alt_mac_addr()</div><div>{</div><div> …</div><div> if (hw->bus.func == E1000_FUNC_1)</div><div> <strong> nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1;</strong></div><div> for (i = 0; i < ETH_ALEN; i += 2) {</div><div> offset = nvm_alt_mac_addr_offset + (i >> 1);</div><div> …</div><div> }</div><div>}</div><div>and general function:</div><div> </div><div>static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)<br />{<br /> s32 ret_val = 0;<br /><br /> /*<br /> * If there's an alternate MAC address place it in RAR0<br /> * so that it will override the Si installed default perm<br /> * address.<br /> */<br /> ret_val = igb_check_alt_mac_addr(hw);<br /> if (ret_val)<br /> goto out;<br /><br /> ret_val = igb_read_mac_addr(hw);<br /><br />out:<br /> return ret_val;<br />}<br /><br /></div><div>So, the "intel" driver in iPXE works almost correctly at this point except that for PORT_ONE it reads EEPROM from the same location instead of shifted by 6 bytes (3 words).</div><div> </div><div>Try to modify "intel_fetch_mac_eeprom()" routine:</div><div> </div><div>static int intel_fetch_mac_eeprom ( struct intel_nic *intel,<br /> uint8_t *hw_addr ) {<br /> int rc;</div><div><span style="color:#008000;"><strong> int offset = 0;</strong></span><br /><br /> /* Initialise EEPROM */<br /> if ( ( rc = intel_init_eeprom ( intel ) ) != 0 )<br /> return rc;<br /><br /> /* Read base MAC address from EEPROM */</div><div><span style="color:#008000;"><strong> if (intel->port == 1)</strong></span></div><div><span style="color:#008000;"><strong> offset = 6; /* E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 */</strong></span><br /> if ( ( rc = nvs_read ( &intel->eeprom, INTEL_EEPROM_MAC<span style="color:#008000;"><strong> + offset</strong></span>,<br /> hw_addr, ETH_ALEN ) ) != 0 ) {<br /> DBGC ( intel, "INTEL %p could not read EEPROM base MAC "<br /> "address: %s\n", intel, strerror ( rc ) );<br /> return rc;<br /> }<br /><br /> /* Adjust MAC address for multi-port devices */<br /> hw_addr[ETH_ALEN-1] ^= intel->port;<br /><br /> DBGC ( intel, "INTEL %p has EEPROM MAC address %s (port %d)\n",<br /> intel, eth_ntoa ( hw_addr ), intel->port );<br /> return 0;<br />}<br /><br /></div><div> </div><div>27.07.2012, 14:36, "Kieran Evans" <keyz182@gmail.com>:</div><blockquote type="cite"><div>My point in the previous email was that <span style="color:#333333;font-family:Consolas,"Liberation Mono",Courier,monospace;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;line-height:16px;text-transform:none;background-color:#ffffff;display:inline !important;float:none;">intel_fetch_mac_eeprom </span>is called before <span style="color:#333333;font-family:Consolas,"Liberation Mono",Courier,monospace;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;line-height:16px;text-transform:none;background-color:#ffffff;display:inline !important;float:none;">is_valid_ether_addr</span>. If there is a MAC in the EEPROM, the if statement surounding <span style="color:#333333;font-family:Consolas,"Liberation Mono",Courier,monospace;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;line-height:16px;text-transform:none;background-color:#ffffff;display:inline !important;float:none;">intel_fetch_mac_eeprom </span>retruns 0 from the <span style="color:#990000;font-family:Consolas,"Liberation Mono",Courier,monospace;font-size:12px;font-style:normal;font-variant:normal;font-weight:bold;line-height:16px;text-transform:none;background-color:#ffffff;display:inline !important;float:none;">intel_fetch_mac </span>function.<br /> <br /> This means that if there's a MAC in eeprom, the <span style="color:#333333;font-family:Consolas,"Liberation Mono",Courier,monospace;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;line-height:16px;text-transform:none;background-color:#ffffff;display:inline !important;float:none;">is_valid_ether_addr</span> function is never reached, and so the autoloaded MAC is never checked for validity. <br /> <br /> So any checks I add to is_valid_ether_addr() will never be reached.<br /> <br /> /Kieran<br /> <br /> On 27/07/2012 11:16, Anton D. Kachalov wrote:</div><blockquote cite="mid:143341343384192@webcorp7.yandex-team.ru" type="cite"><div>Kieran,</div><div> </div><div>First, driver read autoload MAC from INTEL_RAL/INTEL_RAH.</div><div>Then driver fetch MAC from EEPROM. After driver tries to validate autoloaded MAC. If it fits, it copies to "hw_addr" otherwise EEPROM MAC will be used. Usually, EEPROM of embedded NICs programmed by the motherboard vendor, because MAC address space is a vendor specific.</div><div> </div><div>Try to add two additional checks before "<span style="margin:0px;padding:0px;border:0px none;">is_valid_ether_addr()" to see which check fails:</span></div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div><span style="margin:0px;padding:0px;border:0px none;">is_multicast_ether_addr(mac.raw) must return 0<br /> </span></div><div><span style="margin:0px;padding:0px;border:0px none;">is_zero_ether_addr(mac.raw) must return 0<br /> </span></div><div> </div><div>27.07.2012, 14:06, "Kieran Evans" <a href="mailto:keyz182@gmail.com"><keyz182@gmail.com></a>:</div><blockquote type="cite"><div>Hi, unless I'm mis-reading this, or I've misunderstood, this code looks like it will always use the EEPROM MAC if it exists (i.e. the return 0 after intel_fetch_mac_eeprom is before the is_valid_ether_addr, so it'll never be reached).<br /> <br /> <br /><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">static</span> <span style="margin:0px;padding:0px;border:0px none;color:#445588;font-weight:bold;">int</span> <span style="margin:0px;padding:0px;border:0px none;color:#990000;font-weight:bold;">intel_fetch_mac</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span>struct</span> <span style="margin:0px;padding:0px;border:0px none;">intel_nic</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">*</span><span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;color:#445588;font-weight:bold;">uint8_t</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">*</span><span style="margin:0px;padding:0px;border:0px none;">hw_addr</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">{</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span>union</span> <span style="margin:0px;padding:0px;border:0px none;">intel_receive_address</span> <span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">;</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;color:#445588;font-weight:bold;">int</span> <span style="margin:0px;padding:0px;border:0px none;">rc</span><span style="margin:0px;padding:0px;border:0px none;">;</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"> </div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;color:#999988;font-style:italic;">/* Read current address from RAL0/RAH0 */</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">reg</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">low</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">=</span> <span style="margin:0px;padding:0px;border:0px none;">cpu_to_le32</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span>readl</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">-></span><span style="margin:0px;padding:0px;border:0px none;">regs</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">+</span> <span style="margin:0px;padding:0px;border:0px none;">INTEL_RAL0</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">);</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">reg</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">high</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">=</span> <span style="margin:0px;padding:0px;border:0px none;">cpu_to_le32</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">readl</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">-></span><span style="margin:0px;padding:0px;border:0px none;">regs</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">+</span> <span style="margin:0px;padding:0px;border:0px none;">INTEL _RAH0</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">);</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">DBGC</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">"INTEL %p has autoloaded MAC address %s</span><span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">\n</span><span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">"</span><span style="margin:0px;padding:0px;border:0px none;">,</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;">eth_ntoa</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">raw</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">);</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"> </div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;color:#999988;font-style:italic;">/* Try to read address from EEPROM */</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">if</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">rc</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">=</span> <span style="margin:0px;padding:0px;border:0px none;">intel_fetch_mac_eeprom</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;"> intel</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;">hw_addr</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">==</span> <span style="margin:0px;padding:0px;border:0px none;color:#009999;">0</span> <span style="margin:0px;padding:0px;border:0px none;">)</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">return</span> <span style="margin:0px;padding:0px;border:0px none;color:#009999;">0</span><span style="margin:0px;padding:0px;border:0px none;">;</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"> </div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;color:#999988;font-style:italic;">/* Use current address if valid */</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">if</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">is_valid_ether_addr</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">raw</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">)</span> <span style="margin:0px;padding:0px;border:0px none;">{</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">memcpy</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">hw_addr</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;">mac</span><span style="margin:0px;padding:0px;border:0px none;">.</span><span style="margin:0px;padding:0px;border:0px none;">raw</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;">ETH_ALEN</span> <span style="margin:0px;padding:0px;border:0px none;">);</span>< /div> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">return</span> <span style="margin:0px;padding:0px;border:0px none;color:#009999;">0</span><span style="margin:0px;padding:0px;border:0px none;">;</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">}</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"> </div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">DBGC</span> <span style="margin:0px;padding:0px;border:0px none;">(</span> <span style="margin:0px;padding:0px;border:0px none;">intel</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">"INTEL %p has no MAC address to use</span><span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">\n</span><span style="margin:0px;padding:0px;border:0px none;color:#dd1144;">"</span><span style="margin:0px;padding:0px;border:0px none;">,</span> <span style="margin:0px;padding:0px;border:0px none;">intel</span> <span style="margin:0px;padding:0px;border:0px none;">);</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">return</span> <span style="margin:0px;padding:0px;border:0px none;font-weight:bold;">-</span><span style="margin:0px;padding:0px;border:0px none;">ENOENT</span><span style="margin:0px;padding:0px;border:0px none;">;</span></div><div style="margin:0px;padding:0px 0px 0px 10px;border:0px none;"><span style="margin:0px;padding:0px;border:0px none;">}</span></div><br /> It seems like this is the correct way to do things, as if a user has burned a custom MAC into the EEPROM, then that's the one to use. I assume (though I can't find any info to back this up) that intel burns the default MAC into the eeprom too, and that's why there's MAC addresses in the EEPROM even though I never changed them. Could this issue be down to PCI device enumeration? I.e. the two ports are being enumerated in a different order by iPXE than elsewhere, so even though the auto-assigned mac is correct, when it checks the EEPROM, it's seeing a different value because it thinks port 0 is port 1 and port 1 is 0?<br /> <br /> /Kieran<br /> <br /> Also, oops, forgot to reply to the list, last time, so list email added back in.<br /> <br /> On 27/07/2012 10:40, Anton D. Kachalov wrote:</div><blockquote cite="mid:137651343382020@webcorp7.yandex-team.ru" type="cite"><pre>EEPROM macs used only when autoloaded is not complain by "is_valid_ether_addr" routine (lines 226-230). Try to add more debug messages here to track why driver going to use EEPROM's MAC instead of autloaded.
27.07.2012, 13:14, "Kieran Evans" <a href="mailto:keyz182@gmail.com"><keyz182@gmail.com></a>:
</pre><blockquote type="cite"><pre>Hmm, it seems that the autoloaded and EEPROM MACs are at odds (I'm the
only person to have touched these servers since they were purchased, and
no modification of the EEPROM has been made, no setting of alternate MAC
addresses etc).
<a href="http://dbyz.co.uk/ipxe1.png">http://dbyz.co.uk/ipxe1.png</a>
<a href="http://dbyz.co.uk/ipxe2.png">http://dbyz.co.uk/ipxe2.png</a>
After seeing that, I can think of two possible temporary workarounds,
but not sure about perminent fixes.
Workaround A: Set the MACs in EEPROM the other way around. (May then
confuse linux, so needs checking)
Workaround B: Compile iPXE with Mac loading from the EEPROM disabled
(Comment out line 223+224 of src/drivers/net/intel.c ?)
Any ideas on a more perminent workaround/fix? I'm fairly lucky as I only
have 4 servers with this NIC/Problem, so modifying the eeprom is only
half an hour of my time, but this could be a much bigger issue elsewhere.
</pre></blockquote></blockquote><br /><p>_______________________________________________<br /> ipxe-devel mailing list<br /> <a href="mailto:ipxe-devel@lists.ipxe.org">ipxe-devel@lists.ipxe.org</a><br /> <a href="https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel">https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel</a></p></blockquote><div>-- <br /> Anton D. Kachalov<br /> <br /> ITO, R&D group, Senior System Engineer<br /> Tel: <span>+7 (495) 739-70-00</span> ext.7613</div></blockquote></blockquote><div>-- <br />Anton D. Kachalov<br /><br />ITO, R&D group, Senior System Engineer<br />Tel: +7 (495) 739-70-00 ext.7613</div>