OK there are problems.
From
https://sourceforge.net/p/edk2/mailman/message/31604654/
""In current EDKII implementation, all the network servicebinding
protocols for a
NIC device are installed together on the NIC's device handle, so you can get
all
of them when you have chosen a special NIC handle.""
Unfortunately there are PCs with UEFI implementations not following the former
rule.
i.e. HP Elitebook 2570p (single NIC)
shell> dh
...
172: DevPath (..9,0x0)/MAC(FC15B4E81CAC,0x0))Net MNPSb ARPSb DHCPv4Sb TCPv4Sb
IPv4Sb IPv4Config UDPv4Sb MTFTPv4Sb
...
184: DevPath (..00:0000:0000:0000:0000:0000))Load Net Pxebc
...
19D: DevPath (..v4(0.0.0.0,UDP,DHCP,0.0.0.0))Load Net Pxebc
...
shell> dh 172
Handle 172 (730D8A98)
Dpath (730D8E98)
ACPI Device Path for Acpi
HID PNP0A03, UID 0
Hardware Device Path for PCI
Function (0) Device (19)
Messaging Device Path for MAC
MAC (FC15B4E81CAC)
AsStr: 'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)'
Net (730C5020)
MNPSb (722D0F40)
ARPSb (722C13A0)
DHCPv4Sb (722C4220)
TCPv4Sb (722A7330)
IPv4Sb (72DF2A20)
IPv4Config (722AF638)
UDPv4Sb (722A3EA0)
MTFTPv4Sb (7229B4A0)
D79DF6B0-EF44-43BD-9797-43E93BCF5FA8 (722A6318)
...
shell> dh 184
Handle 184 (722AE898)
Dpath (722ADA18)
ACPI Device Path for Acpi
HID PNP0A03, UID 0
Hardware Device Path for PCI
Function (0) Device (19)
Messaging Device Path for MAC
MAC (FC15B4E81CAC)
Messaging Device Path for IPv6
IPv6 (Not Available)
AsStr:
'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000,UDP,DHCP,0000:0000:0000:0000:0000:0000:0000:0000)'
Load (722BB7A8)
Net (730C5020)
Pxebc (722B0110)
shell> dh 19D
Handle 19D (72284598)
Dpath (72284618)
ACPI Device Path for Acpi
HID PNP0A03, UID 0
Hardware Device Path for PCI
Function (0) Device (19)
Messaging Device Path for MAC
MAC (FC15B4E81CAC)
Messaging Device Path for IPv4
IPv4 (Local IP: 0.0.0.0:0)
(Remote IP: 0.0.0.0:0)
(Protocol: 0)
(Source IP: DHCP)
AsStr:
'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)/IPv4(0.0.0.0,UDP,DHCP,0.0.0.0)'
Load (72284728)
Net (730C5020)
Pxebc (722B0110)
The booting syslinux.efi receives DeviceHandle = 19D (IPv4); this handle has
also attached to it the Pxebc Protocol
but it does not have attached the Service Binding Protocol UDPv4Sb (in this case
under the handle 172 instead).
The HP 2570p is not really an old PC (~2013) then I can think if we continue
using the "same handle" method we will have
problems PXE booting lot of UEFI PCs.
I think when we receive the image_DeviceHandle we must save it but also parse
the associated DevicePath saving the MAC address too.
When looking for Pxebc Protocol we can use the image_DeviceHandle, next when
ServiceBinding we need to detect
all the available SB handles of the required type, parse their DevicePath and
take the one with a matching MAC.
Let me know if you see any alternative to MAC parsing considering this new info.
Best,
Patrick
On Thu, Jul 2, 2015 at 9:58 AM, Patrick Masotta <masottaus at yahoo.com> wrote:> OK there are problems. > > From > https://sourceforge.net/p/edk2/mailman/message/31604654/ > ""In current EDKII implementation, all the network servicebinding protocols for a > NIC device are installed together on the NIC's device handle, so you can get all > of them when you have chosen a special NIC handle."" > > Unfortunately there are PCs with UEFI implementations not following the former rule. > > i.e. HP Elitebook 2570p (single NIC) > > shell> dh > ... > 172: DevPath (..9,0x0)/MAC(FC15B4E81CAC,0x0))Net MNPSb ARPSb DHCPv4Sb TCPv4Sb IPv4Sb IPv4Config UDPv4Sb MTFTPv4Sb > ... > 184: DevPath (..00:0000:0000:0000:0000:0000))Load Net Pxebc > ... > 19D: DevPath (..v4(0.0.0.0,UDP,DHCP,0.0.0.0))Load Net Pxebc > ... > > shell> dh 172 > Handle 172 (730D8A98) > Dpath (730D8E98) > ACPI Device Path for Acpi > HID PNP0A03, UID 0 > Hardware Device Path for PCI > Function (0) Device (19) > Messaging Device Path for MAC > MAC (FC15B4E81CAC) > AsStr: 'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)' > Net (730C5020) > MNPSb (722D0F40) > ARPSb (722C13A0) > DHCPv4Sb (722C4220) > TCPv4Sb (722A7330) > IPv4Sb (72DF2A20) > IPv4Config (722AF638) > UDPv4Sb (722A3EA0) > MTFTPv4Sb (7229B4A0) > D79DF6B0-EF44-43BD-9797-43E93BCF5FA8 (722A6318) > ... > > shell> dh 184 > Handle 184 (722AE898) > Dpath (722ADA18) > ACPI Device Path for Acpi > HID PNP0A03, UID 0 > Hardware Device Path for PCI > Function (0) Device (19) > Messaging Device Path for MAC > MAC (FC15B4E81CAC) > Messaging Device Path for IPv6 > IPv6 (Not Available) > AsStr: 'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000,UDP,DHCP,0000:0000:0000:0000:0000:0000:0000:0000)' > Load (722BB7A8) > Net (730C5020) > Pxebc (722B0110) > > shell> dh 19D > Handle 19D (72284598) > Dpath (72284618) > ACPI Device Path for Acpi > HID PNP0A03, UID 0 > Hardware Device Path for PCI > Function (0) Device (19) > Messaging Device Path for MAC > MAC (FC15B4E81CAC) > Messaging Device Path for IPv4 > IPv4 (Local IP: 0.0.0.0:0) > (Remote IP: 0.0.0.0:0) > (Protocol: 0) > (Source IP: DHCP) > AsStr: 'PciRoot(0x0)/Pci(0x19,0x0)/MAC(FC15B4E81CAC,0x0)/IPv4(0.0.0.0,UDP,DHCP,0.0.0.0)' > Load (72284728) > Net (730C5020) > Pxebc (722B0110) > > The booting syslinux.efi receives DeviceHandle = 19D (IPv4); this handle has also attached to it the Pxebc Protocol > but it does not have attached the Service Binding Protocol UDPv4Sb (in this case under the handle 172 instead). > > The HP 2570p is not really an old PC (~2013) then I can think if we continue using the "same handle" method we will have > problems PXE booting lot of UEFI PCs. > I think when we receive the image_DeviceHandle we must save it but also parse the associated DevicePath saving the MAC address too. > When looking for Pxebc Protocol we can use the image_DeviceHandle, next when ServiceBinding we need to detect > all the available SB handles of the required type, parse their DevicePath and take the one with a matching MAC. > > Let me know if you see any alternative to MAC parsing considering this new info.Lovely, the ServiceBindings are on a handle that resembles the NIC while the Pxebc is IP-type specific. Looks like we should try to do a ServiceBinding based on Pxebc but fall back to MAC-based searching, saving all 3 handles, the image handle, Pxebc handle, and ServiceBinding handle. Presumably the UDP and TCP handles _should_ be the same... -- -Gene
>>>Lovely, the ServiceBindings are on a handle that resembles the NIC while the Pxebc is IP-type specific.? Looks like we should try to do a ServiceBinding based on Pxebc but fall back to MAC-based searching, saving all 3 handles, the image handle, Pxebc handle, and ServiceBinding handle.? Presumably the UDP and TCP handles _should_ be the same... -- -Gene <<< OK now it works. Everything is done within efi_create_binding(EFI_GUID *bguid, EFI_GUID *pguid) from image_DeviceHandle I get the right DevPath handle, I parse it and I get the MAC address. Next I LibLocateHandle(ByProtocol, bguid, NULL, &nr_handles, &handles) what gives me all the handles that include the Service Binding Protocol "bguid". For each of this handles I get the DevPath handle and I parse it looking for the matching MAC address. The bguid handle with the right MAC is used for binding. So far it works in the problematic HP 2570p but also in a Vmware 10 client with double NIC. I'll test a bit more and I'll upload the code. Best, Patrick