68 #define SNP_RX_QUOTA 4 71 #define SNP_INITIALIZE_RETRY_MAX 10 74 #define SNP_INITIALIZE_RETRY_DELAY_MS 10 97 static char buf[
sizeof ( *mac ) * 3 ];
101 for ( i = 0 ; i <
len ; i++ ) {
102 used +=
ssnprintf ( &buf[used], (
sizeof ( buf ) - used ),
103 "%s%02x", ( used ?
":" :
"" ),
124 DBGC2 (
snp,
"SNP %s st %d type %d hdr %d pkt %d rxflt %#x/%#x%s " 145 "presence not supported" ) );
203 DBGC (
snp,
"SNP %s could not transmit: %s\n",
227 if ( ( efirc = snp->
snp->
GetStatus ( snp->
snp, &irq, &txbuf ) ) != 0 ) {
229 DBGC ( snp,
"SNP %s could not get status: %s\n",
240 if ( ! snp->
txbuf ) {
241 DBGC ( snp,
"SNP %s reported spurious TX completion\n",
269 if ( !
snp->rxbuf ) {
271 if ( !
snp->rxbuf ) {
291 DBGC (
snp,
"SNP %s could not receive: %s\n",
350 for ( i = 0; i < (
sizeof ( filters ) /
sizeof ( filters[0] ) ); i++ ) {
357 DBGC (
snp,
"SNP %s could not set receive filters %#02x (have " 382 DBGC (
snp,
"SNP %s could not set station address before " 388 for ( retry = 0 ; ; ) {
395 DBGC (
snp,
"SNP %s could not initialise: %s\n",
410 DBGC (
snp,
"SNP %s retrying initialisation (retry %d)\n",
423 DBGC (
snp,
"SNP %s could not shut down: %s\n",
432 DBGC (
snp,
"SNP %s could not set station address after " 462 DBGC (
snp,
"SNP %s could not shut down: %s\n",
503 DBGCP (
device,
"HANDLE %s is provided by this binary\n",
515 return -
EEFI ( efirc );
522 &parent, 1 ) ) == 0 ) {
523 DBGC2 (
device,
"HANDLE %s has %s-supporting parent ",
558 DBGC (
device,
"SNP %s cannot open SNP protocol: %s\n",
562 goto err_open_protocol;
580 snp->dev.driver_name =
"SNP";
588 ( ( efirc =
snp->snp->
Start (
snp->snp ) ) != 0 ) ) {
590 DBGC (
device,
"SNP %s could not start: %s\n",
597 DBGC (
device,
"SNP %s could not shut down: %s\n",
604 DBGC (
device,
"SNP %s has invalid hardware address length " 607 goto err_hw_addr_len;
612 DBGC (
device,
"SNP %s has invalid link-layer address length " 615 goto err_ll_addr_len;
624 goto err_register_netdev;
671 ( ( efirc =
snp->snp->
Stop (
snp->snp ) ) != 0 ) ) {
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
struct arbelprm_rc_send_wqe rc
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
UINT32 NvRamSize
The size, in bytes, of the NVRAM device attached to the network interface.
#define iob_put(iobuf, len)
static void snpnet_dump_mode(struct net_device *netdev)
Dump SNP mode information (for debugging)
static void snpnet_poll(struct net_device *netdev)
Poll for completed packets.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access to a network adapter.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
#define SNP_RX_PAD
Additional padding for receive buffers.
uint8_t ll_addr_len
Link-layer address length.
UINT32 MediaHeaderSize
The size, in bytes, of the network interface's media header.
int(* open)(struct net_device *netdev)
Open network device.
BOOLEAN MediaPresent
TRUE if media are connected to the network interface; otherwise FALSE.
#define list_add(new, head)
Add a new entry to the head of a list.
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
128 bit buffer containing a unique identifier value.
EFI_SIMPLE_NETWORK_PROTOCOL * snp
Simple network protocol.
int snpnet_supported(EFI_HANDLE device, EFI_GUID *protocol)
Check to see if driver supports a device.
32-byte buffer containing a network Media Access Control address.
void snpnet_stop(struct efi_device *efidev)
Detach driver from device.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static int snpnet_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
#define EPIPE
Broken pipe.
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST
#define EFI_OPEN_PROTOCOL_BY_DRIVER
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
BOOLEAN MediaPresentSupported
TRUE if the presence of media can be determined; otherwise FALSE.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
#define DBGC_EFI_OPENERS(...)
EFI_HANDLE device
EFI device handle.
UINT32 State
Reports the current state of the network interface.
uint8_t mac[ETH_ALEN]
MAC address.
EFI_CLOSE_PROTOCOL CloseProtocol
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
struct io_buffer * rxbuf
Current receive buffer.
#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST
EFI_MAC_ADDRESS CurrentAddress
The current HW MAC address for the network interface.
#define ECANCELED
Operation canceled.
#define ENOTSUP
Operation not supported.
EFI_SIMPLE_NETWORK_MODE * Mode
Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
int snpnet_start(struct efi_device *efidev)
Attach driver to device.
EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]
Array containing the addresses of the current multicast address receive filters.
EFI_MAC_ADDRESS BroadcastAddress
The current HW MAC address for broadcast packets.
static const char * snpnet_mac_text(EFI_MAC_ADDRESS *mac, size_t len)
Format SNP MAC address (for debugging)
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
BOOLEAN MultipleTxSupported
TRUE if the network interface can transmit more than one packet at a time.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
#define list_del(list)
Delete an entry from a list.
UINT8 IfType
The interface type of the network interface.
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL
UINT32 MaxPacketSize
The maximum size, in bytes, of the packets supported by the network interface.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
FILE_LICENCE(GPL2_OR_LATER)
UINT32 ReceiveFilterSetting
The current multicast receive filter settings.
UINT32 MCastFilterCount
The current number of multicast address receive filters.
EFI_SIMPLE_NETWORK_INITIALIZE Initialize
struct io_buffer * txbuf
Current transmit buffer.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
uint8_t hw_addr_len
Hardware address length.
void * priv
Driver private data.
EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
The EFI_SIMPLE_NETWORK_PROTOCOL provides services to initialize a network interface,...
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
static struct net_device * netdev
static void snpnet_check_link(struct net_device *netdev)
Check link state.
EFI_SIMPLE_NETWORK_TRANSMIT Transmit
static void snpnet_close(struct net_device *netdev)
Close network device.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
BOOLEAN MacAddressChangeable
TRUE if the HW MAC address can be changed.
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
char * strerror(int errno)
Retrieve string representation of error number.
#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
struct device dev
Generic device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
UINT32 NvRamAccessSize
The size that must be used for all NVRAM reads and writes.
UINT64 UINTN
Unsigned value of native width.
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
#define SNP_RX_QUOTA
Maximum number of received packets per poll.
static int snpnet_open(struct net_device *netdev)
Open network device.
static int snpnet_rx_filters(struct net_device *netdev)
Set receive filters.
static void snpnet_poll_tx(struct net_device *netdev)
Poll for completed packets.
#define SNP_INITIALIZE_RETRY_MAX
Maximum initialisation retry count.
int efi_locate_device(EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip)
Locate parent device supporting a given protocol.
EFI_SIMPLE_NETWORK_START Start
#define VOID
Undeclared type.
struct efi_device * efidev
EFI device.
Network device operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
EFI_SIMPLE_NETWORK_RECEIVE Receive
Network device management.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
struct efi_snp_device * find_snpdev(EFI_HANDLE handle)
Find SNP device by EFI device handle.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
char name[NETDEV_NAME_LEN]
Name of this network device.
#define ENOTTY
Inappropriate I/O control operation.
UINT32 HwAddressSize
The size, in bytes, of the network interface's HW address.
UINT32 MaxMCastFilterCount
The maximum number of multicast address receive filters supported by the driver.
void * data
Start of data.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct list_head children
Devices attached to this device.
UINT32 ReceiveFilterMask
The multicast receive filter settings supported by the network interface.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static void snpnet_poll_rx(struct net_device *netdev)
Poll for received packets.
#define SNP_INITIALIZE_RETRY_DELAY_MS
Delay between each initialisation retry.
EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
uint16_t protocol
Protocol ID.
EFI_SIMPLE_NETWORK_STOP Stop
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
struct device dev
Generic device.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
static struct net_device_operations snpnet_operations
SNP network device operations.
struct ll_protocol * ll_protocol
Link-layer protocol.
size_t mtu
Maximum packet size.
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
EFI_MAC_ADDRESS PermanentAddress
The permanent HW MAC address for the network interface.
int efi_shutdown_in_progress
EFI shutdown is in progress.