|
iPXE
|
SNP NIC driver. More...
#include <stdlib.h>#include <stdio.h>#include <string.h>#include <errno.h>#include <ipxe/iobuf.h>#include <ipxe/netdevice.h>#include <ipxe/ethernet.h>#include <ipxe/if_ether.h>#include <ipxe/vsprintf.h>#include <ipxe/timer.h>#include <ipxe/efi/efi.h>#include <ipxe/efi/Protocol/SimpleNetwork.h>#include <ipxe/efi/efi_driver.h>#include <ipxe/efi/efi_utils.h>#include <ipxe/efi/efi_snp.h>#include "snpnet.h"Go to the source code of this file.
Data Structures | |
| struct | snp_nic |
| An SNP NIC. More... | |
| struct | snp_insomniac_patch |
| An SNP interface patch to inhibit shutdown for insomniac devices. More... | |
Macros | |
| #define | SNP_RX_QUOTA 4 |
| Maximum number of received packets per poll. More... | |
| #define | SNP_INITIALIZE_RETRY_MAX 10 |
| Maximum initialisation retry count. More... | |
| #define | SNP_INITIALIZE_RETRY_DELAY_MS 10 |
| Delay between each initialisation retry. More... | |
| #define | SNP_RX_PAD 8 |
| Additional padding for receive buffers. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static const char * | snpnet_mac_text (EFI_MAC_ADDRESS *mac, size_t len) |
| Format SNP MAC address (for debugging) More... | |
| static void | snpnet_dump_mode (struct net_device *netdev) |
| Dump SNP mode information (for debugging) More... | |
| static void | snpnet_check_link (struct net_device *netdev) |
| Check link state. More... | |
| static int | snpnet_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
| Transmit packet. More... | |
| static void | snpnet_poll_tx (struct net_device *netdev) |
| Poll for completed packets. More... | |
| static void | snpnet_poll_rx (struct net_device *netdev) |
| Poll for received packets. More... | |
| static void | snpnet_poll (struct net_device *netdev) |
| Poll for completed packets. More... | |
| static int | snpnet_rx_filters (struct net_device *netdev) |
| Set receive filters. More... | |
| static int | snpnet_open (struct net_device *netdev) |
| Open network device. More... | |
| static void | snpnet_close (struct net_device *netdev) |
| Close network device. More... | |
| int | snpnet_supported (EFI_HANDLE device, EFI_GUID *protocol, int inhibit_wifi) |
| Check to see if driver supports a device. More... | |
| static int | snpnet_is_insomniac (EFI_HANDLE device) |
| Check if device must be insomniac. More... | |
| static EFI_STATUS EFIAPI | snpnet_do_nothing (EFI_SIMPLE_NETWORK_PROTOCOL *snp __unused) |
| Ignore shutdown attempt. More... | |
| static int | snpnet_insomniac_patch (EFI_HANDLE device, struct snp_insomniac_patch *patch) |
| Patch SNP protocol interface to prevent shutdown. More... | |
| static int | snpnet_insomniac_restore (EFI_HANDLE device, struct snp_insomniac_patch *patch) |
| Restore patched SNP protocol interface. More... | |
| int | snpnet_exclude (EFI_HANDLE device) |
| Exclude existing drivers. More... | |
| int | snpnet_start (struct efi_device *efidev) |
| Attach driver to device. More... | |
| void | snpnet_stop (struct efi_device *efidev) |
| Detach driver from device. More... | |
Variables | |
| static struct net_device_operations | snpnet_operations |
| SNP network device operations. More... | |
SNP NIC driver.
Definition in file snpnet.c.
| #define SNP_RX_QUOTA 4 |
| #define SNP_INITIALIZE_RETRY_MAX 10 |
| #define SNP_INITIALIZE_RETRY_DELAY_MS 10 |
| #define SNP_RX_PAD 8 |
Additional padding for receive buffers.
Some SNP implementations seem to require additional space in the allocated receive buffers, otherwise full-length packets will be silently dropped.
The EDK2 MnpDxe driver happens to allocate an additional 8 bytes of padding (4 for a VLAN tag, 4 for the Ethernet frame checksum). Match this behaviour since drivers are very likely to have been tested against MnpDxe.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Format SNP MAC address (for debugging)
| mac | MAC address |
| len | Length of MAC address |
| text | MAC address as text |
Definition at line 104 of file snpnet.c.
References len, mac, and ssnprintf().
Referenced by snpnet_dump_mode().
|
static |
Dump SNP mode information (for debugging)
| netdev | Network device |
Definition at line 122 of file snpnet.c.
References DBG_EXTRA, DBGC2, mode, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, net_device::name, netdev, net_device::priv, snp_nic::snp, and snpnet_mac_text().
Referenced by snpnet_open().
|
static |
Check link state.
| netdev | Network device |
Definition at line 161 of file snpnet.c.
References mode, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, netdev, netdev_link_down(), netdev_link_ok(), netdev_link_up(), net_device::priv, and snp_nic::snp.
Referenced by snpnet_poll(), and snpnet_start().
|
static |
Transmit packet.
| netdev | Network device |
| iobuf | I/O buffer |
| rc | Return status code |
Definition at line 184 of file snpnet.c.
References io_buffer::data, DBGC, ECANCELED, EEFI, efi_shutdown_in_progress, ETH_ZLEN, iob_len(), iob_pad(), net_device::name, netdev, netdev_tx_defer(), NULL, net_device::priv, rc, snp_nic::snp, strerror(), and _EFI_SIMPLE_NETWORK_PROTOCOL::Transmit.
|
static |
Poll for completed packets.
| netdev | Network device |
Definition at line 225 of file snpnet.c.
References DBGC, EEFI, EPIPE, _EFI_SIMPLE_NETWORK_PROTOCOL::GetStatus, net_device::name, netdev, netdev_rx_err(), netdev_tx_complete(), netdev_tx_err(), NULL, net_device::priv, rc, snp_nic::snp, strerror(), snp_nic::txbuf, and VOID.
Referenced by snpnet_poll().
|
static |
Poll for received packets.
| netdev | Network device |
Definition at line 266 of file snpnet.c.
References alloc_iob(), DBGC, EEFI, EFI_NOT_READY, iob_put, iob_tailroom(), len, net_device::name, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, rc, _EFI_SIMPLE_NETWORK_PROTOCOL::Receive, snp_nic::snp, SNP_RX_PAD, SNP_RX_QUOTA, and strerror().
Referenced by snpnet_poll().
|
static |
Poll for completed packets.
| netdev | Network device |
Definition at line 317 of file snpnet.c.
References efi_shutdown_in_progress, netdev, snpnet_check_link(), snpnet_poll_rx(), and snpnet_poll_tx().
|
static |
Set receive filters.
| netdev | Network device |
| rc | Return status code |
Definition at line 339 of file snpnet.c.
References DBGC, EEFI, EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST, EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST, EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST, EFI_SIMPLE_NETWORK_RECEIVE_UNICAST, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, net_device::name, netdev, NULL, net_device::priv, rc, EFI_SIMPLE_NETWORK_MODE::ReceiveFilterMask, _EFI_SIMPLE_NETWORK_PROTOCOL::ReceiveFilters, EFI_SIMPLE_NETWORK_MODE::ReceiveFilterSetting, snp_nic::snp, strerror(), and TRUE.
Referenced by snpnet_open().
|
static |
Open network device.
| netdev | Network device |
| rc | Return status code |
Definition at line 379 of file snpnet.c.
References DBGC, EEFI, EfiSimpleNetworkInitialized, FALSE, _EFI_SIMPLE_NETWORK_PROTOCOL::Initialize, net_device::ll_addr, mac, mdelay(), mode, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, net_device::name, netdev, netdev_insomniac(), net_device::priv, rc, _EFI_SIMPLE_NETWORK_PROTOCOL::Shutdown, snp_nic::snp, SNP_INITIALIZE_RETRY_DELAY_MS, SNP_INITIALIZE_RETRY_MAX, snpnet_dump_mode(), snpnet_rx_filters(), _EFI_SIMPLE_NETWORK_PROTOCOL::StationAddress, and strerror().
|
static |
Close network device.
| netdev | Network device |
Definition at line 464 of file snpnet.c.
References DBGC, ECANCELED, EEFI, efi_shutdown_in_progress, free_iob(), net_device::name, netdev, netdev_insomniac(), netdev_tx_complete_err(), NULL, net_device::priv, rc, _EFI_SIMPLE_NETWORK_PROTOCOL::Shutdown, snp_nic::snp, and strerror().
| int snpnet_supported | ( | EFI_HANDLE | device, |
| EFI_GUID * | protocol, | ||
| int | inhibit_wifi | ||
| ) |
Check to see if driver supports a device.
| device | EFI device handle |
| protocol | Protocol GUID |
| inhibit_wifi | Inhibit wireless devices |
| rc | Return status code |
Definition at line 510 of file snpnet.c.
References DBGC, DBGC2, DBGCP, efi_guid_ntoa(), efi_handle_name(), efi_locate_device(), efi_test, efi_wifi2_protocol_guid, ENOTTY, find_snpdev(), NULL, protocol, and rc.
Referenced by mnp_supported(), nii_supported(), and snp_supported().
|
static |
Check if device must be insomniac.
| device | EFI device handle |
| is_insomniac | Device must be insomniac |
Definition at line 563 of file snpnet.c.
References DBGC, efi_handle_name(), efi_test, efi_wifi2_protocol_guid, and rc.
Referenced by snpnet_exclude(), and snpnet_start().
|
static |
Ignore shutdown attempt.
| snp | SNP interface |
| efirc | EFI status code |
Definition at line 603 of file snpnet.c.
Referenced by snpnet_insomniac_patch(), and snpnet_insomniac_restore().
|
static |
Patch SNP protocol interface to prevent shutdown.
| device | EFI device handle |
| patch | Interface patch |
| rc | Return status code |
Definition at line 615 of file snpnet.c.
References DBGC, efi_handle_name(), efi_open, efi_simple_network_protocol_guid, rc, snp_insomniac_patch::shutdown, snpnet_do_nothing(), snp_insomniac_patch::stop, and strerror().
Referenced by snpnet_exclude().
|
static |
Restore patched SNP protocol interface.
| device | EFI device handle |
| patch | Interface patch to fill in |
| rc | Return status code |
Definition at line 653 of file snpnet.c.
References DBGC, EBUSY, efi_handle_name(), efi_open, efi_simple_network_protocol_guid, memset(), rc, snp_insomniac_patch::shutdown, snpnet_do_nothing(), snp_insomniac_patch::stop, and strerror().
Referenced by snpnet_exclude().
| int snpnet_exclude | ( | EFI_HANDLE | device | ) |
Exclude existing drivers.
| device | EFI device handle |
| rc | Return status code |
Definition at line 692 of file snpnet.c.
References DBGC, efi_driver_exclude(), efi_handle_name(), efi_simple_network_protocol_guid, protocol, rc, snpnet_insomniac_patch(), snpnet_insomniac_restore(), snpnet_is_insomniac(), and strerror().
| int snpnet_start | ( | struct efi_device * | efidev | ) |
Attach driver to device.
| efidev | EFI device |
| rc | Return status code |
Definition at line 727 of file snpnet.c.
References alloc_etherdev(), device::children, DBGC, DBGC_EFI_OPENERS, efi_device::dev, net_device::dev, efi_device::device, EEFI, efi_close_by_driver(), efi_device_info(), efi_handle_name(), efi_open_by_driver, efi_simple_network_protocol_guid, snp_nic::efidev, efidev_set_drvdata(), EfiSimpleNetworkInitialized, EfiSimpleNetworkStopped, ENOMEM, ENOTSUP, net_device::hw_addr, ll_protocol::hw_addr_len, INIT_LIST_HEAD, list_add, list_del, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, EFI_SIMPLE_NETWORK_MODE::MaxPacketSize, EFI_SIMPLE_NETWORK_MODE::MediaHeaderSize, EFI_SIMPLE_NETWORK_MODE::MediaPresentSupported, memcpy(), mode, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, net_device::name, netdev, netdev_init(), NETDEV_INSOMNIAC, netdev_insomniac(), netdev_link_up(), netdev_nullify(), netdev_put(), net_device::priv, rc, register_netdev(), _EFI_SIMPLE_NETWORK_PROTOCOL::Shutdown, snp_nic::snp, snpnet_check_link(), snpnet_is_insomniac(), snpnet_operations, _EFI_SIMPLE_NETWORK_PROTOCOL::Start, net_device::state, strerror(), and unregister_netdev().
| void snpnet_stop | ( | struct efi_device * | efidev | ) |
Detach driver from device.
| efidev | EFI device |
Definition at line 844 of file snpnet.c.
References DBGC, efi_device::device, EEFI, efi_close_by_driver(), efi_handle_name(), efi_shutdown_in_progress, efi_simple_network_protocol_guid, snp_nic::efidev, efidev_get_drvdata(), list_del, netdev, netdev_nullify(), netdev_put(), net_device::priv, rc, snp_nic::snp, _EFI_SIMPLE_NETWORK_PROTOCOL::Stop, strerror(), and unregister_netdev().
|
static |
SNP network device operations.
Definition at line 495 of file snpnet.c.
Referenced by snpnet_start().
1.8.15