mirror of
https://github.com/ipxe/ipxe
synced 2026-04-04 03:00:20 +03:00
[efi] Add support for driving EFI_MANAGED_NETWORK_PROTOCOL devices
We want exclusive access to the network device, both for performance reasons and because we perform operations such as EAPoL that affect the entire link. We currently drive the network card via either a native hardware driver or via the SNP or NII/UNDI interfaces, both of which grant us this exclusive access. Add an alternative driver that drives the network card non-exclusively via the EFI_MANAGED_NETWORK_PROTOCOL interface. This can function as a fallback for situations where neither SNP nor NII/UNDI interfaces are functional, and also opens up the possibility of non-destructively installing a temporary network device over which to download the autoexec.ipxe script. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -23,11 +23,8 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <errno.h>
|
||||
#include <ipxe/efi/efi.h>
|
||||
#include <ipxe/efi/efi_driver.h>
|
||||
#include <ipxe/efi/efi_snp.h>
|
||||
#include <ipxe/efi/efi_utils.h>
|
||||
#include "snpnet.h"
|
||||
#include "nii.h"
|
||||
|
||||
@@ -37,53 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check to see if driver supports a device
|
||||
*
|
||||
* @v device EFI device handle
|
||||
* @v protocol Protocol GUID
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int snp_nii_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE parent;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Check that this is not a device we are providing ourselves */
|
||||
if ( find_snpdev ( device ) != NULL ) {
|
||||
DBGCP ( device, "HANDLE %s is provided by this binary\n",
|
||||
efi_handle_name ( device ) );
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/* Test for presence of protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device, protocol,
|
||||
NULL, efi_image_handle, device,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
|
||||
DBGCP ( device, "HANDLE %s is not a %s device\n",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( protocol ) );
|
||||
return -EEFI ( efirc );
|
||||
}
|
||||
|
||||
/* Check that there are no instances of this protocol further
|
||||
* up this device path.
|
||||
*/
|
||||
if ( ( rc = efi_locate_device ( device, protocol,
|
||||
&parent, 1 ) ) == 0 ) {
|
||||
DBGC2 ( device, "HANDLE %s has %s-supporting parent ",
|
||||
efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( protocol ) );
|
||||
DBGC2 ( device, "%s\n", efi_handle_name ( parent ) );
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
DBGC ( device, "HANDLE %s is a %s device\n",
|
||||
efi_handle_name ( device ), efi_guid_ntoa ( protocol ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if driver supports a device
|
||||
*
|
||||
@@ -92,7 +42,7 @@ static int snp_nii_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
*/
|
||||
static int snp_supported ( EFI_HANDLE device ) {
|
||||
|
||||
return snp_nii_supported ( device, &efi_simple_network_protocol_guid );
|
||||
return snpnet_supported ( device, &efi_simple_network_protocol_guid );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +53,7 @@ static int snp_supported ( EFI_HANDLE device ) {
|
||||
*/
|
||||
static int nii_supported ( EFI_HANDLE device ) {
|
||||
|
||||
return snp_nii_supported ( device, &efi_nii31_protocol_guid );
|
||||
return snpnet_supported ( device, &efi_nii31_protocol_guid );
|
||||
}
|
||||
|
||||
/** EFI SNP driver */
|
||||
|
||||
Reference in New Issue
Block a user