drivers/net: Check "ethernet_mac" when the device index is 1
It is a special case for the Fizz firmware branch, when the device index is 1, it will check "ethernet_mac" first and then "ethernet_mac0". For single NIC: config.device_index = "1", maps to "ethernet_mac" For multiple NICs: config.device_index = "1", maps to "ethernet_mac0" BUG=b:77836343 BRANCH=Fizz TEST=Add device index in device tree && Program the mac address to VPD in shell vpd -s ethernet_mac=<mac address> or vpd -s ethernet-mac[0-9]=<mac address> && reboot the system. Ensure the MAC address was fetched correctly by ifconfig command. Change-Id: I67fd2e999c8f9d8782f294fcafa84b8da970a3a6 Signed-off-by: David Wu <david_wu@quantatw.com> Reviewed-on: https://review.coreboot.org/26051 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
6cc4dea9f1
commit
9a0d9e072f
|
@ -67,7 +67,7 @@ static size_t search(const char *p, const u8 *a, size_t lengthp,
|
||||||
for (j = 0; j <= lengtha - lengthp; j++) {
|
for (j = 0; j <= lengtha - lengthp; j++) {
|
||||||
for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
|
for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
|
||||||
;
|
;
|
||||||
if (i >= lengthp)
|
if (i >= lengthp && a[j - 1] == lengthp)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
return lengtha;
|
return lengtha;
|
||||||
|
@ -187,13 +187,18 @@ static void program_mac_address(struct device *dev, u16 io_base)
|
||||||
/* Default MAC Address of 00:E0:4C:00:C0:B0 */
|
/* Default MAC Address of 00:E0:4C:00:C0:B0 */
|
||||||
u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 };
|
u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 };
|
||||||
struct drivers_net_config *config = dev->chip_info;
|
struct drivers_net_config *config = dev->chip_info;
|
||||||
|
bool mac_found = false;
|
||||||
|
|
||||||
/* check the VPD for the mac address */
|
/* check the VPD for the mac address */
|
||||||
if (IS_ENABLED(CONFIG_RT8168_GET_MAC_FROM_VPD)) {
|
if (IS_ENABLED(CONFIG_RT8168_GET_MAC_FROM_VPD)) {
|
||||||
/* Current implementation is up to 10 NIC cards */
|
/* Current implementation is up to 10 NIC cards */
|
||||||
if (config && config->device_index <= MAX_DEVICE_SUPPORT) {
|
if (config && config->device_index <= MAX_DEVICE_SUPPORT) {
|
||||||
if (fetch_mac_string_vpd(macstrbuf, config->device_index)
|
/* check "ethernet_mac" first when the device index is 1 */
|
||||||
!= CB_SUCCESS)
|
if (config->device_index == 1 &&
|
||||||
|
fetch_mac_string_vpd(macstrbuf, 0) == CB_SUCCESS)
|
||||||
|
mac_found = true;
|
||||||
|
if (!mac_found && fetch_mac_string_vpd(macstrbuf,
|
||||||
|
config->device_index) != CB_SUCCESS)
|
||||||
printk(BIOS_ERR, "r8168: mac address not found in VPD,"
|
printk(BIOS_ERR, "r8168: mac address not found in VPD,"
|
||||||
" using default 00:e0:4c:00:c0:b0\n");
|
" using default 00:e0:4c:00:c0:b0\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue