iPXE
|
MNP NIC driver. More...
#include <string.h>
#include <errno.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/cachedhcp.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_service.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/mnpnet.h>
#include <ipxe/efi/Protocol/ManagedNetwork.h>
Go to the source code of this file.
Data Structures | |
struct | mnp_token |
An MNP transmit or receive token. More... | |
struct | mnp_nic |
An MNP NIC. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static VOID EFIAPI | mnpnet_event (EFI_EVENT event __unused, VOID *context) |
Transmit or receive token event. More... | |
static int | mnpnet_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | mnpnet_refill_rx (struct net_device *netdev) |
Refill receive token. More... | |
static void | mnpnet_poll_tx (struct net_device *netdev) |
Poll for completed packets. More... | |
static void | mnpnet_poll_rx (struct net_device *netdev) |
Poll for received packets. More... | |
static void | mnpnet_poll (struct net_device *netdev) |
Poll for completed packets. More... | |
static int | mnpnet_open (struct net_device *netdev) |
Open network device. More... | |
static void | mnpnet_close (struct net_device *netdev) |
Close network device. More... | |
int | mnpnet_start (struct efi_device *efidev) |
Attach driver to device. More... | |
void | mnpnet_stop (struct efi_device *efidev) |
Detach driver from device. More... | |
int | mnptemp_create (EFI_HANDLE handle, struct net_device **netdev) |
Create temporary MNP network device. More... | |
void | mnptemp_destroy (struct net_device *netdev) |
Destroy temporary MNP network device. More... | |
Variables | |
static struct net_device_operations | mnpnet_operations |
MNP network device operations. More... | |
MNP NIC driver.
Definition in file mnpnet.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Transmit or receive token event.
event | Event |
context | Event context |
Definition at line 79 of file mnpnet.c.
References assert(), and token.
Referenced by mnpnet_open().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 96 of file mnpnet.c.
References mnp_token::busy, io_buffer::data, EFI_MANAGED_NETWORK_TRANSMIT_DATA::DataLength, DBGC, ECANCELED, EEFI, efi_shutdown_in_progress, EFI_MANAGED_NETWORK_FRAGMENT_DATA::FragmentBuffer, EFI_MANAGED_NETWORK_TRANSMIT_DATA::FragmentCount, EFI_MANAGED_NETWORK_FRAGMENT_DATA::FragmentLength, EFI_MANAGED_NETWORK_TRANSMIT_DATA::FragmentTable, EFI_MANAGED_NETWORK_TRANSMIT_DATA::HeaderLength, iob_len(), ll_protocol::ll_header_len, net_device::ll_protocol, mnp_nic::mnp, net_device::name, netdev, netdev_tx_defer(), EFI_MANAGED_NETWORK_COMPLETION_TOKEN::Packet, net_device::priv, rc, strerror(), mnp_token::token, _EFI_MANAGED_NETWORK_PROTOCOL::Transmit, mnp_nic::tx, mnp_nic::txbuf, mnp_nic::txdata, and EFI_MANAGED_NETWORK_COMPLETION_TOKEN::TxData.
|
static |
Refill receive token.
netdev | Network device |
Definition at line 145 of file mnpnet.c.
References DBGC, EEFI, mnp_nic::mnp, net_device::name, netdev, net_device::priv, rc, _EFI_MANAGED_NETWORK_PROTOCOL::Receive, and strerror().
Referenced by mnpnet_open(), and mnpnet_poll().
|
static |
Poll for completed packets.
netdev | Network device |
Definition at line 173 of file mnpnet.c.
References mnp_token::busy, EEFI, mnp_nic::mnp, netdev, netdev_tx_complete_err(), NULL, net_device::priv, rc, EFI_MANAGED_NETWORK_COMPLETION_TOKEN::Status, mnp_token::token, mnp_nic::tx, and mnp_nic::txbuf.
Referenced by mnpnet_poll().
|
static |
Poll for received packets.
netdev | Network device |
Definition at line 202 of file mnpnet.c.
References alloc_iob(), EFI_SYSTEM_TABLE::BootServices, mnp_token::busy, EEFI, efi_systab, ENOMEM, iob_put, len, EFI_MANAGED_NETWORK_RECEIVE_DATA::MediaHeader, memcpy(), mnp_nic::mnp, netdev, netdev_rx(), netdev_rx_err(), NULL, EFI_MANAGED_NETWORK_COMPLETION_TOKEN::Packet, EFI_MANAGED_NETWORK_RECEIVE_DATA::PacketLength, net_device::priv, rc, EFI_MANAGED_NETWORK_RECEIVE_DATA::RecycleEvent, mnp_nic::rx, EFI_MANAGED_NETWORK_COMPLETION_TOKEN::RxData, EFI_BOOT_SERVICES::SignalEvent, EFI_MANAGED_NETWORK_COMPLETION_TOKEN::Status, and mnp_token::token.
Referenced by mnpnet_poll().
|
static |
Poll for completed packets.
netdev | Network device |
Definition at line 245 of file mnpnet.c.
References efi_shutdown_in_progress, mnp_nic::mnp, mnpnet_poll_rx(), mnpnet_poll_tx(), mnpnet_refill_rx(), netdev, _EFI_MANAGED_NETWORK_PROTOCOL::Poll, and net_device::priv.
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 271 of file mnpnet.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, _EFI_MANAGED_NETWORK_PROTOCOL::Configure, EFI_BOOT_SERVICES::CreateEvent, DBGC, EEFI, efi_systab, EFI_MANAGED_NETWORK_CONFIG_DATA::EnableUnicastReceive, EVT_NOTIFY_SIGNAL, mnp_nic::mnp, mnpnet_event(), mnpnet_refill_rx(), net_device::name, netdev, NULL, net_device::priv, rc, strerror(), TPL_NOTIFY, and TRUE.
|
static |
Close network device.
netdev | Network device |
Definition at line 332 of file mnpnet.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, _EFI_MANAGED_NETWORK_PROTOCOL::Configure, ECANCELED, efi_shutdown_in_progress, efi_systab, mnp_nic::mnp, netdev, netdev_tx_complete_err(), NULL, and net_device::priv.
int mnpnet_start | ( | struct efi_device * | efidev | ) |
Attach driver to device.
efidev | EFI device |
rc | Return status code |
Definition at line 369 of file mnpnet.c.
References alloc_etherdev(), EFI_SYSTEM_TABLE::BootServices, efi_device::child, device::children, EFI_BOOT_SERVICES::CloseProtocol, EFI_SIMPLE_NETWORK_MODE::CurrentAddress, DBGC, efi_device::dev, net_device::dev, efi_device::device, EEFI, efi_device_info(), efi_handle_name(), efi_image_handle, efi_managed_network_protocol_guid, efi_managed_network_service_binding_protocol_guid, EFI_NOT_STARTED, EFI_OPEN_PROTOCOL_BY_DRIVER, EFI_OPEN_PROTOCOL_EXCLUSIVE, efi_service_add(), efi_service_del(), efi_systab, mnp_nic::efidev, efidev_set_drvdata(), ENOMEM, ENOTSUP, _EFI_MANAGED_NETWORK_PROTOCOL::GetModeData, net_device::hw_addr, ll_protocol::hw_addr_len, EFI_SIMPLE_NETWORK_MODE::HwAddressSize, INIT_LIST_HEAD, list_add, list_del, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), mnp_nic::mnp, mnpnet_operations, net_device::name, netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), NULL, EFI_BOOT_SERVICES::OpenProtocol, EFI_SIMPLE_NETWORK_MODE::PermanentAddress, net_device::priv, rc, register_netdev(), strerror(), u, and unregister_netdev().
Referenced by mnptemp_create().
void mnpnet_stop | ( | struct efi_device * | efidev | ) |
Detach driver from device.
efidev | EFI device |
Definition at line 484 of file mnpnet.c.
References EFI_SYSTEM_TABLE::BootServices, efi_device::child, EFI_BOOT_SERVICES::CloseProtocol, efi_device::device, efi_image_handle, efi_managed_network_protocol_guid, efi_managed_network_service_binding_protocol_guid, efi_service_del(), efi_shutdown_in_progress, efi_systab, mnp_nic::efidev, efidev_get_drvdata(), list_del, mnp_nic::mnp, netdev, netdev_nullify(), netdev_put(), net_device::priv, and unregister_netdev().
Referenced by mnptemp_create(), and mnptemp_destroy().
int mnptemp_create | ( | EFI_HANDLE | handle, |
struct net_device ** | netdev | ||
) |
Create temporary MNP network device.
handle | MNP service binding handle |
netdev | Network device to fill in |
rc | Return status code |
Definition at line 514 of file mnpnet.c.
References DBGC, efi_handle_name(), efidev_alloc(), efidev_free(), efidev_get_drvdata(), ENOMEM, handle, mnpnet_start(), mnpnet_stop(), netdev, rc, and strerror().
Referenced by efi_autoexec_network().
void mnptemp_destroy | ( | struct net_device * | netdev | ) |
Destroy temporary MNP network device.
netdev | Network device |
Definition at line 551 of file mnpnet.c.
References cachedhcp_recycle(), mnp_nic::efidev, efidev_free(), mnp_nic::mnp, mnpnet_stop(), netdev, and net_device::priv.
Referenced by efi_autoexec_network().
|
static |
MNP network device operations.
Definition at line 356 of file mnpnet.c.
Referenced by mnpnet_start().