[efi] Add an EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL interface
[people/mcb30/gpxe.git] / src / interface / efi / efi_snp.c
index 9f92666..a3eace3 100644 (file)
@@ -30,6 +30,7 @@
 #include <gpxe/efi/Protocol/PciIo.h>
 #include <gpxe/efi/Protocol/SimpleNetwork.h>
 #include <gpxe/efi/Protocol/ComponentName2.h>
+#include <gpxe/efi/Protocol/NetworkInterfaceIdentifier.h>
 #include <config/general.h>
 
 /** @file
@@ -62,6 +63,8 @@ struct efi_snp_device {
        unsigned int rx_count_interrupts;
        /** Outstanding RX packet count (via WaitForPacket event) */
        unsigned int rx_count_events;
+       /** The network interface identifier */
+       EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
        /** Device name */
        wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
        /** The device path
@@ -88,6 +91,18 @@ static EFI_GUID efi_component_name2_protocol_guid
 static EFI_GUID efi_device_path_protocol_guid
        = EFI_DEVICE_PATH_PROTOCOL_GUID;
 
+/** Efi network interface identifier GUID */
+static EFI_GUID efi_nii_protocol_guid = {
+       /* No, this isn't the GUID defined as
+        * EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID in
+        * Protocol/NetworkInterfaceIdentifier.h.  That GUID gets
+        * ignored by the EFI network stack.  You have to use this one
+        * instead.
+        */
+       0x1ACED566, 0x76ED, 0x4218,
+       { 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 }
+};
+
 /** EFI PCI I/O protocol GUID */
 static EFI_GUID efi_pci_io_protocol_guid
        = EFI_PCI_IO_PROTOCOL_GUID;
@@ -936,6 +951,12 @@ efi_snp_driver_start ( EFI_DRIVER_BINDING_PROTOCOL *driver,
        snpdev->mode.State = EfiSimpleNetworkStopped;
        efi_snp_set_mode ( snpdev );
 
+       /* Populate the NII structure */
+       snpdev->nii.Revision =
+               EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION;
+       strncpy ( snpdev->nii.StringId, "gPXE",
+                 sizeof ( snpdev->nii.StringId ) );
+
        /* Populate the device name */
        for ( i = 0 ; i < sizeof ( netdev->name ) ; i++ ) {
                /* Damn Unicode names */
@@ -965,6 +986,7 @@ efi_snp_driver_start ( EFI_DRIVER_BINDING_PROTOCOL *driver,
                        &snpdev->handle,
                        &efi_simple_network_protocol_guid, &snpdev->snp,
                        &efi_device_path_protocol_guid, &snpdev->path,
+                       &efi_nii_protocol_guid, &snpdev->nii,
                        NULL ) ) != 0 ) {
                DBGC ( snpdev, "SNPDEV %p could not install protocols: "
                       "%s\n", snpdev, efi_strerror ( efirc ) );
@@ -979,6 +1001,7 @@ efi_snp_driver_start ( EFI_DRIVER_BINDING_PROTOCOL *driver,
                        snpdev->handle,
                        &efi_simple_network_protocol_guid, &snpdev->snp,
                        &efi_device_path_protocol_guid, &snpdev->path,
+                       &efi_nii_protocol_guid, &snpdev->nii,
                        NULL );
  err_install_protocol_interface:
        bs->CloseEvent ( snpdev->snp.WaitForPacket );
@@ -1027,6 +1050,7 @@ efi_snp_driver_stop ( EFI_DRIVER_BINDING_PROTOCOL *driver,
                        snpdev->handle,
                        &efi_simple_network_protocol_guid, &snpdev->snp,
                        &efi_device_path_protocol_guid, &snpdev->path,
+                       &efi_nii_protocol_guid, &snpdev->nii,
                        NULL );
        bs->CloseEvent ( snpdev->snp.WaitForPacket );
        netdev_put ( snpdev->netdev );