summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/efi/mnp.c
diff options
context:
space:
mode:
authorMichael Brown2024-03-22 16:30:45 +0100
committerMichael Brown2024-03-25 18:58:33 +0100
commitdcad73ca5ad3e1fe011c52a24036f67ad69fadc1 (patch)
treeecb05e55a634d6d63cc46f6f3a02eb3930e30eb6 /src/drivers/net/efi/mnp.c
parent[efi] Allow for drivers to be located via child handles (diff)
downloadipxe-dcad73ca5ad3e1fe011c52a24036f67ad69fadc1.tar.gz
ipxe-dcad73ca5ad3e1fe011c52a24036f67ad69fadc1.tar.xz
ipxe-dcad73ca5ad3e1fe011c52a24036f67ad69fadc1.zip
[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>
Diffstat (limited to 'src/drivers/net/efi/mnp.c')
-rw-r--r--src/drivers/net/efi/mnp.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/drivers/net/efi/mnp.c b/src/drivers/net/efi/mnp.c
new file mode 100644
index 00000000..b79fe188
--- /dev/null
+++ b/src/drivers/net/efi/mnp.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * You can also choose to distribute this program under the terms of
+ * the Unmodified Binary Distribution Licence (as given in the file
+ * COPYING.UBDL), provided that you have satisfied its requirements.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+/** @file
+ *
+ * MNP driver
+ *
+ */
+
+#include <errno.h>
+#include <ipxe/efi/efi.h>
+#include <ipxe/efi/efi_driver.h>
+#include "snpnet.h"
+#include "mnpnet.h"
+
+/**
+ * Check to see if driver supports a device
+ *
+ * @v device EFI device handle
+ * @ret rc Return status code
+ */
+static int mnp_supported ( EFI_HANDLE device ) {
+ EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
+
+ return snpnet_supported ( device, binding );
+}
+
+/** EFI MNP driver */
+struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
+ .name = "MNP",
+ .supported = mnp_supported,
+ .start = mnpnet_start,
+ .stop = mnpnet_stop,
+};