Duncan Laurie has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31669
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
vendorcode/google/chromeos: Support MAC address passthru policy
This change adds support for providing a MAC address that can be used by the OS network drivers to change the MAC address that a NIC uses.
The Realtek r8152 driver in the Linux kernel supports a MAC address passthru feature which can result in the dock ethernet port using the same MAC address that is assigned to the internal NIC. This is done by calling an ACPI method at _SB.AMAC() which returns a formatted string containing the MAC address for the dock to use.
The Linux kernel implementation can be found at drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read()
This is implemented specifically for Chrome OS as it relies on VPD to determine the MAC address to supply.
The policy which controls where the dock MAC address comes from is written into RW_VPD property "dock_passthru": "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" "builtin": existing dock MAC address (return nothing)
The MAC address in VPD is the standard format AA:BB:CC:DD:EE:FF and it must be converted into the string format expected by the OS which involves some string manipulation which ACPI is not great at handling.
BUG=b:123925776 TEST=this was tested on a sarien board by setting the VPD keys to their expected values and observing if the AMAC() method returns the expected string.
Change-Id: I3335e5d924155431e299844e2aaace62168294e0 Signed-off-by: Duncan Laurie dlaurie@google.com --- A src/vendorcode/google/chromeos/acpi/amac.asl 1 file changed, 85 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/31669/1
diff --git a/src/vendorcode/google/chromeos/acpi/amac.asl b/src/vendorcode/google/chromeos/acpi/amac.asl new file mode 100644 index 0000000..07a0518 --- /dev/null +++ b/src/vendorcode/google/chromeos/acpi/amac.asl @@ -0,0 +1,85 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; version 2 of + * the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * The Realtek r8152 driver in the Linux kernel supports a MAC address + * passthru feature which can result in the dock ethernet port using the + * same MAC address that is assigned to the internal NIC. This is done + * by calling an ACPI method at _SB.AMAC() which returns a formatted + * string containing the MAC address for the dock to use. + * + * The Linux kernel implementation can be found at + * drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read() + * + * For Chrome OS, the policy which controls where the dock MAC address + * comes from is written into RW_VPD property "dock_passthru": + * + * "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" + * "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" + * "builtin": existing dock MAC address (return nothing) + */ + +Scope (_SB) +{ + Method (AMAC, 0, Serialized) + { + /* Format expected by the Linux kernel r8152 driver */ + Name (MACA, "_AUXMAC_#XXXXXXXXXXXX#") + + /* Get "dock_passthru" value from RW_VPD */ + Local0 = \VPD.VPDF ("RW", "dock_passthru") + + Switch (ToString (Local0)) + { + Case ("ethernet_mac0") { + Local1 = \VPD.VPDF ("RO", "ethernet_mac0") + } + Case ("builtin") { + Return (Zero) + } + /* "dock_mac" or policy not found. */ + Default { + Local1 = \VPD.VPDF ("RO", "dock_mac") + } + } + If (!Local1) { + Return (Zero) + } + Printf ("MAC address returned from VPD: %o", Local1) + + /* Verify MAC address format is AA:BB:CC:DD:EE:FF */ + For (Local3 = 2, Local3 < 17, Local3+=3) { + If (ToString (DeRefOf (Local1[Local3])) != ":") { + Printf ("Invalid MAC address byte %o", Local3) + Return (Zero) + } + } + + /* Convert MAC address into format specified by MACA */ + Local2 = ToBuffer (MACA) + Local4 = 0 /* First MAC address byte in input buffer */ + Local5 = 9 /* First MAC address byte in output buffer */ + For (Local3 = 0, Local3 < 6, Local3++) { + Local2[Local5] = DeRefOf (Local1[Local4]) + Local2[Local5 + 1] = DeRefOf (Local1[Local4 + 1]) + Local5 += 2 + Local4 += 3 /* Skip ":" in address from VPD */ + } + + Printf ("AMAC = %o", ToString (Local2)) + Return (ToString (Local2)) + } +}
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
Patch Set 1:
Some of these VPD key names are still being debated so this might get updated.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
Patch Set 1: Code-Review+1
(1 comment)
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... File src/vendorcode/google/chromeos/acpi/amac.asl:
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 64: += Add spaces around the operator?
Lijian Zhao has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... File src/vendorcode/google/chromeos/acpi/amac.asl:
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 65: DeRefOf DerefOf
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 76: DeRefOf DerefOf
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 77: DeRefOf DerefOf
Hello Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/31669
to look at the new patch set (#2).
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
vendorcode/google/chromeos: Support MAC address passthru policy
This change adds support for providing a MAC address that can be used by the OS network drivers to change the MAC address that a NIC uses.
The Realtek r8152 driver in the Linux kernel supports a MAC address passthru feature which can result in the dock ethernet port using the same MAC address that is assigned to the internal NIC. This is done by calling an ACPI method at _SB.AMAC() which returns a formatted string containing the MAC address for the dock to use.
The Linux kernel implementation can be found at drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read()
This is implemented specifically for Chrome OS as it relies on VPD to determine the MAC address to supply.
The policy which controls where the dock MAC address comes from is written into RW_VPD property "dock_passthru": "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" "builtin": existing dock MAC address (return nothing)
The MAC address in VPD is the standard format AA:BB:CC:DD:EE:FF and it must be converted into the string format expected by the OS which involves some string manipulation which ACPI is not great at handling.
BUG=b:123925776 TEST=this was tested on a sarien board by setting the VPD keys to their expected values and observing if the AMAC() method returns the expected string.
Change-Id: I3335e5d924155431e299844e2aaace62168294e0 Signed-off-by: Duncan Laurie dlaurie@google.com --- A src/vendorcode/google/chromeos/acpi/amac.asl 1 file changed, 85 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/31669/2
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
Patch Set 2:
(4 comments)
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... File src/vendorcode/google/chromeos/acpi/amac.asl:
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 64: +=
Add spaces around the operator?
Done
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 65: DeRefOf
DerefOf
Done
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 76: DeRefOf
DerefOf
Done
https://review.coreboot.org/#/c/31669/1/src/vendorcode/google/chromeos/acpi/... PS1, Line 77: DeRefOf
DerefOf
Done
Hello Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/31669
to look at the new patch set (#3).
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
vendorcode/google/chromeos: Support MAC address passthru policy
This change adds support for providing a MAC address that can be used by the OS network drivers to change the MAC address that a NIC uses.
The Realtek r8152 driver in the Linux kernel supports a MAC address passthru feature which can result in the dock ethernet port using the same MAC address that is assigned to the internal NIC. This is done by calling an ACPI method at _SB.AMAC() which returns a formatted string containing the MAC address for the dock to use.
The Linux kernel implementation can be found at drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read()
This is implemented specifically for Chrome OS as it relies on VPD to determine the MAC address to supply.
The policy which controls where the dock MAC address comes from is written into RW_VPD property "dock_passthru": "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" "builtin": existing dock MAC address (return nothing)
The MAC address in VPD is the standard format AA:BB:CC:DD:EE:FF and it must be converted into the string format expected by the OS which involves some string manipulation which ACPI is not great at handling.
BUG=b:123925776 TEST=this was tested on a sarien board by setting the VPD keys to their expected values and observing if the AMAC() method returns the expected string.
Change-Id: I3335e5d924155431e299844e2aaace62168294e0 Signed-off-by: Duncan Laurie dlaurie@google.com --- A src/vendorcode/google/chromeos/acpi/amac.asl 1 file changed, 85 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/31669/3
Lijian Zhao has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
Patch Set 3: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/31669 )
Change subject: vendorcode/google/chromeos: Support MAC address passthru policy ......................................................................
vendorcode/google/chromeos: Support MAC address passthru policy
This change adds support for providing a MAC address that can be used by the OS network drivers to change the MAC address that a NIC uses.
The Realtek r8152 driver in the Linux kernel supports a MAC address passthru feature which can result in the dock ethernet port using the same MAC address that is assigned to the internal NIC. This is done by calling an ACPI method at _SB.AMAC() which returns a formatted string containing the MAC address for the dock to use.
The Linux kernel implementation can be found at drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read()
This is implemented specifically for Chrome OS as it relies on VPD to determine the MAC address to supply.
The policy which controls where the dock MAC address comes from is written into RW_VPD property "dock_passthru": "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" "builtin": existing dock MAC address (return nothing)
The MAC address in VPD is the standard format AA:BB:CC:DD:EE:FF and it must be converted into the string format expected by the OS which involves some string manipulation which ACPI is not great at handling.
BUG=b:123925776 TEST=this was tested on a sarien board by setting the VPD keys to their expected values and observing if the AMAC() method returns the expected string.
Change-Id: I3335e5d924155431e299844e2aaace62168294e0 Signed-off-by: Duncan Laurie dlaurie@google.com Reviewed-on: https://review.coreboot.org/c/31669 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Lijian Zhao lijian.zhao@intel.com --- A src/vendorcode/google/chromeos/acpi/amac.asl 1 file changed, 85 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Lijian Zhao: Looks good to me, approved
diff --git a/src/vendorcode/google/chromeos/acpi/amac.asl b/src/vendorcode/google/chromeos/acpi/amac.asl new file mode 100644 index 0000000..838506a --- /dev/null +++ b/src/vendorcode/google/chromeos/acpi/amac.asl @@ -0,0 +1,85 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; version 2 of + * the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * The Realtek r8152 driver in the Linux kernel supports a MAC address + * passthru feature which can result in the dock ethernet port using the + * same MAC address that is assigned to the internal NIC. This is done + * by calling an ACPI method at _SB.AMAC() which returns a formatted + * string containing the MAC address for the dock to use. + * + * The Linux kernel implementation can be found at + * drivers/net/usb/r8152.c:vendor_mac_passthru_addr_read() + * + * For Chrome OS, the policy which controls where the dock MAC address + * comes from is written into RW_VPD property "dock_passthru": + * + * "dock_mac" or empty: Use MAC address from RO_VPD value "dock_mac" + * "ethernet_mac0": Use MAC address from RO_VPD value "ethernet_mac0" + * "builtin": existing dock MAC address (return nothing) + */ + +Scope (_SB) +{ + Method (AMAC, 0, Serialized) + { + /* Format expected by the Linux kernel r8152 driver */ + Name (MACA, "_AUXMAC_#XXXXXXXXXXXX#") + + /* Get "dock_passthru" value from RW_VPD */ + Local0 = \VPD.VPDF ("RW", "dock_passthru") + + Switch (ToString (Local0)) + { + Case ("ethernet_mac0") { + Local1 = \VPD.VPDF ("RO", "ethernet_mac0") + } + Case ("builtin") { + Return (Zero) + } + /* "dock_mac" or policy not found. */ + Default { + Local1 = \VPD.VPDF ("RO", "dock_mac") + } + } + If (!Local1) { + Return (Zero) + } + Printf ("MAC address returned from VPD: %o", Local1) + + /* Verify MAC address format is AA:BB:CC:DD:EE:FF */ + For (Local3 = 2, Local3 < 17, Local3 += 3) { + If (ToString (DerefOf (Local1[Local3])) != ":") { + Printf ("Invalid MAC address byte %o", Local3) + Return (Zero) + } + } + + /* Convert MAC address into format specified by MACA */ + Local2 = ToBuffer (MACA) + Local4 = 0 /* First MAC address byte in input buffer */ + Local5 = 9 /* First MAC address byte in output buffer */ + For (Local3 = 0, Local3 < 6, Local3++) { + Local2[Local5] = DerefOf (Local1[Local4]) + Local2[Local5 + 1] = DerefOf (Local1[Local4 + 1]) + Local5 += 2 + Local4 += 3 /* Skip ":" in address from VPD */ + } + + Printf ("AMAC = %o", ToString (Local2)) + Return (ToString (Local2)) + } +}