Laszlo,

In the UEFI Spec 2.4, page 387.
The MacAddr is a Hex Dump and is required. If IfType is 0 or 1, then the 
MacAddr must be exactly six bytes.
The IfType is an integer from 0-255 and is optional. The default is zero.

It seems the e1000 NIC uses the default value defined in Spec.

Thanks
Eric
-----Original Message-----
From: Laszlo Ersek [mailto: ]
Sent: Wednesday, September 11, 2013 3:28 AM
To: [email protected]
Cc: Peter Jones
Subject: [edk2] network IfType matching in BDS

The UEFI spec 2.4 seems to reference RFC 3232 in at least two places:

9.3.5.11 MAC Address Device Path
- IfType: Network interface type(i.e. 802.3, FDDI). See RFC 3232

21.1 Simple Network Protocol
- EFI_SIMPLE_NETWORK_MODE.IfType: The interface type of the network interface. 
See RFC 3232, section "Number Hardware Type."

RFC 3232 <https://tools.ietf.org/html/rfc3232> doesn't seem to state much more 
than that it obsoletes RFC 1700, and that the new tables should be queried 
online, at www.iana.org.

RFC 1700 <https://tools.ietf.org/html/rfc1700>, which is obsolete, lists

Number Hardware Type (hrd)                           References
------ -----------------------------------           ----------
     1 Ethernet (10Mb)                                    [JBP]
     2 Experimental Ethernet (3Mb)                        [JBP]
     3 Amateur Radio AX.25                                [PXK]
     4 Proteon ProNET Token Ring                          [JBP]
     5 Chaos                                              [GXP]
     6 IEEE 802 Networks                                  [JBP]
     7 ARCNET                                             [JBP]
     8 Hyperchannel                                       [JBP]
     9 Lanstar                                             [TU]
    10 Autonet Short Address                             [MXB1]
    11 LocalTalk                                         [JKR1]
    12 LocalNet (IBM PCNet or SYTEK LocalNET)             [JXM]
    13 Ultra link                                        [RXD2]
    14 SMDS                                              [GXC1]
    15 Frame Relay                                        [AGM]
    16 Asynchronous Transmission Mode (ATM)              [JXB2]
    17 HDLC                                               [JBP]
    18 Fibre Channel                            [Yakov Rekhter]
    19 Asynchronous Transmission Mode (ATM)      [Mark Laubach]
    20 Serial Line                                        [JBP]
    21 Asynchronous Transmission Mode (ATM)              [MXB1]

Closest to simply saying "Ethernet" is #1, that is "Ethernet (10Mb)".

I searched www.iana.org too (using the search box they offer) for "Autonet 
Short Address", which promised good selectivity. There was only one hit:

  http://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml

This lists further hardware types, but the only types containing the word 
"Ethernet" remain #1 and #2.

In parctice:

- For the virtio-net NIC, VirtioNetDxe sets IfType to 1:
  PciRoot(0x0)/Pci(0x3,0x0)/MAC(52540057E2B3,0x1)

- For the e1000 NIC, the Intel3.5 PROEFI driver (E3507X2.EFI) sets
  IfType to 0:
  PciRoot(0x0)/Pci(0x3,0x0)/MAC(52540057E2B3,0x0)

- For both NICs, the respective iPXE driver sets IfType to 1:
  PciRoot(0x0)/Pci(0x3,0x0)/MAC(52540057E2B3,0x1)


When efibootmgr generates a network boot option, it has no access to the device 
path that the UEFI SNP driver installs on the handle -- efibootmgr must make up 
a device path on its own:
- the PciRoot part is configurable on the efibootmgr command line,
- the PCI address is queried dynamically,
- so is the MAC address,
- and the IfType part is no exception.

For the last component, the SIOCGIFHWADDR ioctl() can be called, and 
'ifr_ifru.ifru_hwaddr.sa_family" will contain the IfType:

  https://github.com/vathpela/efibootmgr/commit/242ce972
  https://github.com/vathpela/efibootmgr/commit/adc05003

("ifr_ifru.ifru_hwaddr" is usually shortened as "ifr_hwaddr").

This value is one of those listed in <include/uapi/linux/if_arp.h>, for example

/* ARP protocol HARDWARE identifiers. */
#define ARPHRD_NETROM   0           /* from KA9Q: NET/ROM pseudo    */
#define ARPHRD_ETHER    1           /* Ethernet 10Mbps              */
#define ARPHRD_EETHER   2           /* Experimental Ethernet        */
#define ARPHRD_AX25     3           /* AX.25 Level 2                */
...


After the long intro, the question comes:

If efibootmgr always generates an IfType of 0x1 (dynamically of course, but the 
kernel should always return ARPHRD_ETHER for ethX), is it possible that such a 
devpath won't match the device path actually installed by the UEFI driver? (See 
the e1000 example above.)

I grepped the edk2 tree for "IfType", and I have the impression that both 
IfType values (ie. 0x0 and 0x1) will work in general *for
networking* -- that is the SNP driver for the NIC is free to install whichever 
--, but that may not be the case for booting.

BdsBootDeviceSelect()
  BdsLibConnectDevicePath(BootOption->DevicePath)
  BdsLibBootViaBootOption(..., BootOption->DevicePath, ...)
    gBS->LoadImage(..., DevicePath, ...)
    == CoreLoadImage()
      CoreLoadImageCommon()
        GetFileBufferByFilePath()
          gBS->LocateDevicePath()
          == CoreLocateDevicePath()

It seems to me that CoreLocateDevicePath() doesn't special-case the IfType 
mismatch; it will simply not find a match.

I'm sure I'm not seeing something... On one hand, IfType==0 installed by the 
PROEFI driver seems to be the exception, so one might think it's "buggy".

OTOH I'm sure PROEFI runs on zillions of UEFI boxes. Plus, efibootmgr used to 
install network boot options with IfType==0 too, and if that were a bug, users 
would have encountered it immediately.

So, what's the deal with IfType?

Thanks!
Laszlo

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT 2. 
Standardize and globalize service processes across IT 3. Implement zero-touch 
automation to replace manual, redundant tasks 
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to