Skip to content

Commit af17abf

Browse files
committed
[efi] Include NII driver within "snp" and "snponly" build targets
End users almost certainly don't care whether the underlying interface is SNP or NII/UNDI. Try to minimise surprise and unnecessary documentation by including the NII driver whenever the SNP driver is requested. Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent feb3a0f commit af17abf

File tree

4 files changed

+195
-106
lines changed

4 files changed

+195
-106
lines changed

src/drivers/net/efi/nii.c

+4-43
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ FILE_LICENCE ( GPL2_OR_LATER );
2828
#include <ipxe/umalloc.h>
2929
#include <ipxe/efi/efi.h>
3030
#include <ipxe/efi/efi_driver.h>
31-
#include <ipxe/efi/efi_snp.h>
3231
#include <ipxe/efi/efi_pci.h>
3332
#include <ipxe/efi/efi_utils.h>
33+
#include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
3434
#include <ipxe/efi/IndustryStandard/Acpi10.h>
35+
#include "nii.h"
3536

3637
/** @file
3738
*
@@ -955,45 +956,13 @@ static struct net_device_operations nii_operations = {
955956
.poll = nii_poll,
956957
};
957958

958-
/**
959-
* Check to see if driver supports a device
960-
*
961-
* @v device EFI device handle
962-
* @ret rc Return status code
963-
*/
964-
static int nii_supported ( EFI_HANDLE device ) {
965-
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
966-
EFI_STATUS efirc;
967-
968-
/* Check that this is not a device we are providing ourselves */
969-
if ( find_snpdev ( device ) != NULL ) {
970-
DBGCP ( device, "NII %p %s is provided by this binary\n",
971-
device, efi_handle_name ( device ) );
972-
return -ENOTTY;
973-
}
974-
975-
/* Test for presence of NII protocol */
976-
if ( ( efirc = bs->OpenProtocol ( device,
977-
&efi_nii31_protocol_guid,
978-
NULL, efi_image_handle, device,
979-
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
980-
DBGCP ( device, "NII %p %s is not an NII device\n",
981-
device, efi_handle_name ( device ) );
982-
return -EEFI ( efirc );
983-
}
984-
DBGC ( device, "NII %p %s is an NII device\n",
985-
device, efi_handle_name ( device ) );
986-
987-
return 0;
988-
}
989-
990959
/**
991960
* Attach driver to device
992961
*
993962
* @v efidev EFI device
994963
* @ret rc Return status code
995964
*/
996-
static int nii_start ( struct efi_device *efidev ) {
965+
int nii_start ( struct efi_device *efidev ) {
997966
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
998967
EFI_HANDLE device = efidev->device;
999968
struct net_device *netdev;
@@ -1106,7 +1075,7 @@ static int nii_start ( struct efi_device *efidev ) {
11061075
*
11071076
* @v efidev EFI device
11081077
*/
1109-
static void nii_stop ( struct efi_device *efidev ) {
1078+
void nii_stop ( struct efi_device *efidev ) {
11101079
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
11111080
struct net_device *netdev = efidev_get_drvdata ( efidev );
11121081
struct nii_nic *nii = netdev->priv;
@@ -1130,11 +1099,3 @@ static void nii_stop ( struct efi_device *efidev ) {
11301099
netdev_nullify ( netdev );
11311100
netdev_put ( netdev );
11321101
}
1133-
1134-
/** EFI NII driver */
1135-
struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
1136-
.name = "NII",
1137-
.supported = nii_supported,
1138-
.start = nii_start,
1139-
.stop = nii_stop,
1140-
};

src/drivers/net/efi/nii.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef _NII_H
2+
#define _NII_H
3+
4+
/** @file
5+
*
6+
* NII driver
7+
*
8+
*/
9+
10+
FILE_LICENCE ( GPL2_OR_LATER );
11+
12+
struct efi_device;
13+
14+
extern int nii_start ( struct efi_device *efidev );
15+
extern void nii_stop ( struct efi_device *efidev );
16+
17+
#endif /* _NII_H */

src/drivers/net/efi/snp.c

+41
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
2424
#include <ipxe/efi/efi_driver.h>
2525
#include <ipxe/efi/efi_snp.h>
2626
#include "snpnet.h"
27+
#include "nii.h"
2728

2829
/** @file
2930
*
@@ -63,10 +64,50 @@ static int snp_supported ( EFI_HANDLE device ) {
6364
return 0;
6465
}
6566

67+
/**
68+
* Check to see if driver supports a device
69+
*
70+
* @v device EFI device handle
71+
* @ret rc Return status code
72+
*/
73+
static int nii_supported ( EFI_HANDLE device ) {
74+
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
75+
EFI_STATUS efirc;
76+
77+
/* Check that this is not a device we are providing ourselves */
78+
if ( find_snpdev ( device ) != NULL ) {
79+
DBGCP ( device, "NII %p %s is provided by this binary\n",
80+
device, efi_handle_name ( device ) );
81+
return -ENOTTY;
82+
}
83+
84+
/* Test for presence of NII protocol */
85+
if ( ( efirc = bs->OpenProtocol ( device,
86+
&efi_nii31_protocol_guid,
87+
NULL, efi_image_handle, device,
88+
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
89+
DBGCP ( device, "NII %p %s is not an NII device\n",
90+
device, efi_handle_name ( device ) );
91+
return -EEFI ( efirc );
92+
}
93+
DBGC ( device, "NII %p %s is an NII device\n",
94+
device, efi_handle_name ( device ) );
95+
96+
return 0;
97+
}
98+
6699
/** EFI SNP driver */
67100
struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
68101
.name = "SNP",
69102
.supported = snp_supported,
70103
.start = snpnet_start,
71104
.stop = snpnet_stop,
72105
};
106+
107+
/** EFI NII driver */
108+
struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
109+
.name = "NII",
110+
.supported = nii_supported,
111+
.start = nii_start,
112+
.stop = nii_stop,
113+
};

0 commit comments

Comments
 (0)