summaryrefslogtreecommitdiff
path: root/src/drivers/net
diff options
context:
space:
mode:
authorDavid Wu <david_wu@quantatw.com>2018-05-04 15:37:37 +0800
committerPatrick Georgi <pgeorgi@google.com>2018-05-15 11:14:54 +0000
commit9a0d9e072fdb4994de7c46e50dace126fe6ce6a0 (patch)
treef9cfe20729944c6b1e8d2701df114ef863561614 /src/drivers/net
parent6cc4dea9f178ef7d89d3cc34692d2f7424af7399 (diff)
downloadcoreboot-9a0d9e072fdb4994de7c46e50dace126fe6ce6a0.tar.xz
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>
Diffstat (limited to 'src/drivers/net')
-rw-r--r--src/drivers/net/r8168.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index 288888d4a8..5280cb67ec 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -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 (i = 0; i < lengthp && p[i] == a[i + j]; i++)
;
- if (i >= lengthp)
+ if (i >= lengthp && a[j - 1] == lengthp)
return j;
}
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 */
u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 };
struct drivers_net_config *config = dev->chip_info;
+ bool mac_found = false;
/* check the VPD for the mac address */
if (IS_ENABLED(CONFIG_RT8168_GET_MAC_FROM_VPD)) {
/* Current implementation is up to 10 NIC cards */
if (config && config->device_index <= MAX_DEVICE_SUPPORT) {
- if (fetch_mac_string_vpd(macstrbuf, config->device_index)
- != CB_SUCCESS)
+ /* check "ethernet_mac" first when the device index is 1 */
+ 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,"
" using default 00:e0:4c:00:c0:b0\n");
} else {