[coreboot-gerrit] Change in coreboot[master]: drivers/net: Add deivce index for multiple NIC cards

Gaggery Tsai (Code Review) gerrit at coreboot.org
Tue Dec 26 10:40:29 CET 2017


Gaggery Tsai has uploaded this change for review. ( https://review.coreboot.org/22984


Change subject: drivers/net: Add deivce index for multiple NIC cards
......................................................................

drivers/net: Add deivce index for multiple NIC cards

This patch adds a member device_index to r8168 chip information which
allows driver to indetify which NIC card requests MAC address.
In this implmentation, only 10 NIC cards are supported, the device
index is in the range of 0 to 9.

BUG=b:69950854
BRANCH=None
TEST=Added device_indexi = [0-9] under /drivers/net in device tree &&
     Programmed the mac address to VPD in shell
     vpd -s ethernet_mac[0-9]=<mac address> && reboot the system.
     Ensure the MAC address was fetched correctly by ifconfig command.

Change-Id: I108b9bfba39370c8906a2fa4d2b39b106e884e0c
Signed-off-by: Gaggery Tsai <gaggery.tsai at intel.com>
---
M src/drivers/net/chip.h
M src/drivers/net/r8168.c
2 files changed, 18 insertions(+), 4 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/84/22984/1

diff --git a/src/drivers/net/chip.h b/src/drivers/net/chip.h
index 8e8c02b..5d253dc 100644
--- a/src/drivers/net/chip.h
+++ b/src/drivers/net/chip.h
@@ -16,7 +16,8 @@
 
 struct drivers_net_config {
 	uint16_t customized_leds;
-	unsigned wake; /* Wake pin for ACPI _PRW */
+	unsigned wake; 				/* Wake pin for ACPI _PRW */
+	unsigned device_index;		/* Indentify device number */
 };
 
 #endif /* __DRIVERS_R8168_CHIP_H__ */
diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index 4c17017..74c8f87 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -91,13 +91,22 @@
 
 #define MACLEN 17
 
-static enum cb_err fetch_mac_string_vpd(u8 *macstrbuf)
+static enum cb_err fetch_mac_string_vpd(u8 *macstrbuf, const u8 device_index)
 {
 	struct region_device rdev;
 	void *search_address;
 	size_t search_length;
 	size_t offset;
-	char key[] = "ethernet_mac";
+	char key[] = "ethernet_mac "; /* Leave a space at tail to stuff an index */
+
+	/* TODO: Limit up to 10 (0-9) NIC MAC address from VPD at this moment
+	 *		, but will we have 10 more NIC cards?
+	 */
+
+	/* Translate index number from integer to ascii, base '0' is 0x30 */
+	key[12] = device_index + 0x30;
+
+	printk(BIOS_DEBUG, "Requesting %s from VPD.\n", key);
 
 	if (fmap_locate_area_as_rdev("RO_VPD", &rdev)) {
 		printk(BIOS_ERR, "Error: Couldn't find RO_VPD region.");
@@ -172,10 +181,14 @@
 	int i = 0;
 	/* 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;
+
+	if (!config)
+		return;
 
 	/* check the VPD for the mac address */
 	if (IS_ENABLED(CONFIG_RT8168_GET_MAC_FROM_VPD)) {
-		if (fetch_mac_string_vpd(macstrbuf) != CB_SUCCESS)
+		if (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 {

-- 
To view, visit https://review.coreboot.org/22984
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: I108b9bfba39370c8906a2fa4d2b39b106e884e0c
Gerrit-Change-Number: 22984
Gerrit-PatchSet: 1
Gerrit-Owner: Gaggery Tsai <gaggery.tsai at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171226/fd9eddc8/attachment.html>


More information about the coreboot-gerrit mailing list