Pārlūkot izejas kodu

[efi] Add EFI_COMPONENT_NAME2_PROTOCOL instance for each SNP device

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 gadus atpakaļ
vecāks
revīzija
7cf6c6bfed
2 mainītis faili ar 75 papildinājumiem un 0 dzēšanām
  1. 7
    0
      src/include/ipxe/efi/efi_snp.h
  2. 68
    0
      src/interface/efi/efi_snp.c

+ 7
- 0
src/include/ipxe/efi/efi_snp.h Parādīt failu

@@ -12,6 +12,7 @@
12 12
 #include <ipxe/efi/efi.h>
13 13
 #include <ipxe/efi/Protocol/SimpleNetwork.h>
14 14
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
15
+#include <ipxe/efi/Protocol/ComponentName2.h>
15 16
 #include <ipxe/efi/Protocol/DevicePath.h>
16 17
 #include <ipxe/efi/Protocol/HiiConfigAccess.h>
17 18
 #include <ipxe/efi/Protocol/HiiDatabase.h>
@@ -46,6 +47,8 @@ struct efi_snp_device {
46 47
 	unsigned int rx_count_events;
47 48
 	/** The network interface identifier */
48 49
 	EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
50
+	/** Component name protocol */
51
+	EFI_COMPONENT_NAME2_PROTOCOL name2;
49 52
 	/** HII configuration access protocol */
50 53
 	EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
51 54
 	/** HII package list */
@@ -54,6 +57,10 @@ struct efi_snp_device {
54 57
 	EFI_HII_HANDLE hii_handle;
55 58
 	/** Device name */
56 59
 	wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
60
+	/** Driver name */
61
+	wchar_t driver_name[16];
62
+	/** Controller name */
63
+	wchar_t controller_name[32];
57 64
 	/** The device path
58 65
 	 *
59 66
 	 * This field is variable in size and must appear at the end

+ 68
- 0
src/interface/efi/efi_snp.c Parādīt failu

@@ -56,6 +56,10 @@ static EFI_GUID efi_nii31_protocol_guid = {
56 56
 	{ 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 }
57 57
 };
58 58
 
59
+/** EFI component name protocol */
60
+static EFI_GUID efi_component_name2_protocol_guid
61
+	= EFI_COMPONENT_NAME2_PROTOCOL_GUID;
62
+
59 63
 /** List of SNP devices */
60 64
 static LIST_HEAD ( efi_snp_devices );
61 65
 
@@ -701,6 +705,54 @@ static EFI_SIMPLE_NETWORK_PROTOCOL efi_snp_device_snp = {
701 705
 	.Receive	= efi_snp_receive,
702 706
 };
703 707
 
708
+/******************************************************************************
709
+ *
710
+ * Component name protocol
711
+ *
712
+ ******************************************************************************
713
+ */
714
+
715
+/**
716
+ * Look up driver name
717
+ *
718
+ * @v name2		Component name protocol
719
+ * @v language		Language to use
720
+ * @v driver_name	Driver name to fill in
721
+ * @ret efirc		EFI status code
722
+ */
723
+static EFI_STATUS EFIAPI
724
+efi_snp_get_driver_name ( EFI_COMPONENT_NAME2_PROTOCOL *name2,
725
+			  CHAR8 *language __unused, CHAR16 **driver_name ) {
726
+	struct efi_snp_device *snpdev =
727
+		container_of ( name2, struct efi_snp_device, name2 );
728
+
729
+	*driver_name = snpdev->driver_name;
730
+	return 0;
731
+}
732
+
733
+/**
734
+ * Look up controller name
735
+ *
736
+ * @v name2     		Component name protocol
737
+ * @v device		Device
738
+ * @v child		Child device, or NULL
739
+ * @v language		Language to use
740
+ * @v driver_name	Device name to fill in
741
+ * @ret efirc		EFI status code
742
+ */
743
+static EFI_STATUS EFIAPI
744
+efi_snp_get_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *name2,
745
+			      EFI_HANDLE device __unused,
746
+			      EFI_HANDLE child __unused,
747
+			      CHAR8 *language __unused,
748
+			      CHAR16 **controller_name ) {
749
+	struct efi_snp_device *snpdev =
750
+		container_of ( name2, struct efi_snp_device, name2 );
751
+
752
+	*controller_name = snpdev->controller_name;
753
+	return 0;
754
+}
755
+
704 756
 /******************************************************************************
705 757
  *
706 758
  * iPXE network driver
@@ -794,6 +846,19 @@ static int efi_snp_probe ( struct net_device *netdev ) {
794 846
 	strncpy ( snpdev->nii.StringId, "iPXE",
795 847
 		  sizeof ( snpdev->nii.StringId ) );
796 848
 
849
+	/* Populate the component name structure */
850
+	efi_snprintf ( snpdev->driver_name,
851
+		       ( sizeof ( snpdev->driver_name ) /
852
+			 sizeof ( snpdev->driver_name[0] ) ), "%s",
853
+		       netdev->dev->driver_name );
854
+	efi_snprintf ( snpdev->controller_name,
855
+		       ( sizeof ( snpdev->controller_name ) /
856
+			 sizeof ( snpdev->controller_name[0] ) ), "%s (%s)",
857
+		       netdev->name, netdev_addr ( netdev ) );
858
+	snpdev->name2.GetDriverName = efi_snp_get_driver_name;
859
+	snpdev->name2.GetControllerName = efi_snp_get_controller_name;
860
+	snpdev->name2.SupportedLanguages = "en";
861
+
797 862
 	/* Populate the device name */
798 863
 	efi_snprintf ( snpdev->name, ( sizeof ( snpdev->name ) /
799 864
 				       sizeof ( snpdev->name[0] ) ),
@@ -822,6 +887,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
822 887
 			&efi_device_path_protocol_guid, &snpdev->path,
823 888
 			&efi_nii_protocol_guid, &snpdev->nii,
824 889
 			&efi_nii31_protocol_guid, &snpdev->nii,
890
+			&efi_component_name2_protocol_guid, &snpdev->name2,
825 891
 			NULL ) ) != 0 ) {
826 892
 		DBGC ( snpdev, "SNPDEV %p could not install protocols: "
827 893
 		       "%s\n", snpdev, efi_strerror ( efirc ) );
@@ -862,6 +928,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
862 928
 			&efi_device_path_protocol_guid, &snpdev->path,
863 929
 			&efi_nii_protocol_guid, &snpdev->nii,
864 930
 			&efi_nii31_protocol_guid, &snpdev->nii,
931
+			&efi_component_name2_protocol_guid, &snpdev->name2,
865 932
 			NULL );
866 933
  err_install_protocol_interface:
867 934
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
@@ -922,6 +989,7 @@ static void efi_snp_remove ( struct net_device *netdev ) {
922 989
 			&efi_device_path_protocol_guid, &snpdev->path,
923 990
 			&efi_nii_protocol_guid, &snpdev->nii,
924 991
 			&efi_nii31_protocol_guid, &snpdev->nii,
992
+			&efi_component_name2_protocol_guid, &snpdev->name2,
925 993
 			NULL );
926 994
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
927 995
 	netdev_put ( snpdev->netdev );

Notiek ielāde…
Atcelt
Saglabāt