Hi, Michael

The CreateChild() function of different Servicebinding protocol will produce 
different child handles with special protocol. In other words, if you want to 
use EFI_MANAGED_NETWORK_PROTOCOL, you need to use 
EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL to create a MNP child handle at 
first, and if you want to use EFI_MTFTP4_PROTOCOL, you need to use 
EFI_MTFTP4_SERVICE_BINDING_PROTOCOL. 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.

And each time you want to use a network protocol (include MNP, ARP, IP, TCP, 
UDP. MTFTP, DHCP), you must always create a new child handle as below (use 
MTFTP for example, or see UEFI spec 10.6 EFI Service Binding Protocol):
1.      Get the Mtftp4ServiceBinding Protocol by calling BS.OpenProtocol() with 
EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute.
2.      Create a new ChildHandle with the Mtftp4 protocol by calling 
Mtftp4Sb.CreateChild().
Mtftp4Sb->CreateChild (Mtftp4Sb, &ChildHandle);
3.      Open the Mtftp4 protocol from this ChildHandle with 
EFI_OPEN_PROTOCOL_BY_DRIVER or EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute.
And when you usage has done, you must close the protocol then destroy the 
childhandle.
4.      Call BS.CloseProtocol() to close the Mtftp4 protocol
5.      Call Mtftp4Sb.DestroyChild() to destroy the child handle that was 
created in step2.

You should never attempt to find a Mtftp4 protocol by calling 
LocateHandleBuffer() directly, because these child handles are created and 
opened by other drivers (like PXE driver), and may be destroyed at any time.

Best Regards
Siyuan

-----Original Message-----
From: Michael Lorer [mailto:[email protected]] 
Sent: Tuesday, November 05, 2013 10:30 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [edk2] UEFI Networkstack: Chosing the right protocol if two 
network interfaces are available

Thank you very much for pointing out that I should use the xxxServiceBinding 
Protocols.
With only one NIC in the system it worked fine to go directly on  the MTFTP4 
protocol or the ManagedNetworkService protocol and it wasn't really clear to me 
what's the benefit in using the different ServiceBinding protocols.

Now I understand that I have to use the ServiceBinding protocols if I want to 
represent different driver dependencies.
I'll change my code to the new model and try to solve my problem this way.
I'll report when I'm done.

Thank you very much.
Regards,
Michael

-----Ursprüngliche Nachricht-----
Von: Laszlo Ersek [mailto:[email protected]]
Gesendet: Dienstag, 5. November 2013 15:04
An: Michael Lorer
Cc: [email protected]
Betreff: Re: AW: [edk2] UEFI Networkstack: Chosing the right protocol if two 
network interfaces are available

On 11/05/13 13:59, Michael Lorer wrote:
> Hello Laszlo,
> 
> thank you for your input.
> I just tried what you have suggested. Now I use the handle I get from 
> the first LocateHandleBuffer-function where a cable is connected on 
> the OpenProtocol()-function.
> But that's not working. OpenProtocol() returns:
> EFI_UNSUPPORTED (Handle does not support Protocol).
> 
> Any ideas on that?

Shouldn't you try to open MTFTPv4ServiceBinding on the handle that the initial 
search for ManagedNetworkServiceBinding returned (and the media present check 
let through), instead of going for MTFTPv4 immediately?

See
- 26.3 EFI MTFTPv4 Protocol
- 10.6 EFI Service Binding Protocol
in the UEFI spec.

At least for virtio-net in OVMF, ManagedNetworkServiceBinding and 
MTFTPv4ServiceBinding are both (automatically) installed:

(1) Shell> ifconfig -s eth0 dhcp

Create an IP and start to get the default address Please wait, your console may 
stop responding for a while ...
      Default: 192.168.122.54

(2) Shell> dh -p ManagedNetworkServiceBinding -d -v

(this mirrors your initial search)

98: UnknownDevice LoadFile PXEBaseCode MTFTPv4ServiceBinding
                                       ^^^^^^^^^^^^^^^^^^^^^ 
DHCPv4ServiceBinding UDPv4ServiceBinding TCPv4ServiceBinding IPv4ServiceBinding 
IPv4Config ARPServiceBinding UnknownDevice ManagedNetworkServiceBinding 
EfiVlanConfigProtocolGuid DevicePath ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400938342,0x1) SimpleNetwork

   Controller Name    : Virtio Network Device
   Device Path        : PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400938342,0x1)
   Controller Type    : BUS
   Configuration      : NO
   Diagnostics        : NO
   Managed by         :
     Drv[66]          : MNP Network Service Driver
     Drv[67]          : VLAN Configuration Driver
     Drv[6A]          : IP4 CONFIG Network Service Driver
     Drv[6B]          : IP4 Network Service Driver
   Parent Controllers :
     Parent[83]       : Virtio Network Device
   Child Controllers  :
     Child[9A]        : MNP (MAC=52-54-00-93-83-42, ProtocolType=0x806,
VlanId=0)
     Child[9B]        : MNP (Not started)
     Child[9D]        : MNP (MAC=52-54-00-93-83-42, ProtocolType=0x800,
VlanId=0)
     Child[99]        :
PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400938342,0x1)/VenHw(D79DF6B0-EF44-43BD-979
7-43E93BCF5FA8)
     Child[9C]        :
PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400938342,0x1)/VenHw(D8944553-C4DD-41F4-9B3
0-E1397CFB267B)


I guess once you have such a handle, you'd call
EFI_MTFTP4_SERVICE_BINDING_PROTOCOL.CreateChild() on it (see the implementation 
in Mtftp4ServiceBindingCreateChild(), file 
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c), and then you could 
use the output child handle (supporting MTFTPv4) for transfer.

Laszlo


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers Accelerate application 
performance with scalable programming models. Explore techniques for threading, 
error checking, porting, and tuning. Get the most from the latest Intel 
processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to