[coreboot-gerrit] Change in coreboot[master]: drivers/net: Add checking "ethernet_mac" when the device index is 1

David Wu (Code Review) gerrit at coreboot.org
Fri May 4 09:39:45 CEST 2018


David Wu has uploaded this change for review. ( https://review.coreboot.org/26051


Change subject: drivers/net: Add checking "ethernet_mac" when the device index is 1
......................................................................

drivers/net: Add checking "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: .device_index = "1", maps to "ethernet_mac"
For multiple NICs: .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 at quantatw.com>
---
M src/drivers/net/r8168.c
1 file changed, 7 insertions(+), 2 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/26051/1

diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index 288888d..ad621df 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -67,7 +67,7 @@
 	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,12 +187,17 @@
 	/* 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)
+			/* 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");

-- 
To view, visit https://review.coreboot.org/26051
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I67fd2e999c8f9d8782f294fcafa84b8da970a3a6
Gerrit-Change-Number: 26051
Gerrit-PatchSet: 1
Gerrit-Owner: David Wu <david_wu at quantatw.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180504/4a586817/attachment.html>


More information about the coreboot-gerrit mailing list