iPXE
Data Structures | Functions | Variables
efi_snp.c File Reference
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/vlan.h>
#include <ipxe/iobuf.h>
#include <ipxe/in.h>
#include <ipxe/version.h>
#include <ipxe/console.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_strings.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/efi_watchdog.h>
#include <ipxe/efi/efi_snp.h>
#include <usr/autoboot.h>
#include <config/general.h>

Go to the source code of this file.

Data Structures

union  PXE_CPB_ANY
 Union type for command parameter blocks. More...
 
union  PXE_DB_ANY
 Union type for data blocks. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static LIST_HEAD (efi_snp_devices)
 List of SNP devices. More...
 
static void efi_snp_set_state (struct efi_snp_device *snpdev)
 Set EFI SNP mode state. More...
 
static void efi_snp_set_mode (struct efi_snp_device *snpdev)
 Set EFI SNP mode based on iPXE net device parameters. More...
 
static void efi_snp_flush (struct efi_snp_device *snpdev)
 Flush transmit ring and receive queue. More...
 
static void efi_snp_poll (struct efi_snp_device *snpdev)
 Poll net device and count received packets. More...
 
static EFI_STATUS EFIAPI efi_snp_start (EFI_SIMPLE_NETWORK_PROTOCOL *snp)
 Change SNP state from "stopped" to "started". More...
 
static EFI_STATUS EFIAPI efi_snp_stop (EFI_SIMPLE_NETWORK_PROTOCOL *snp)
 Change SNP state from "started" to "stopped". More...
 
static EFI_STATUS EFIAPI efi_snp_initialize (EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN extra_rx_bufsize, UINTN extra_tx_bufsize)
 Open the network device. More...
 
static EFI_STATUS EFIAPI efi_snp_reset (EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ext_verify)
 Reset the network device. More...
 
static EFI_STATUS EFIAPI efi_snp_shutdown (EFI_SIMPLE_NETWORK_PROTOCOL *snp)
 Shut down the network device. More...
 
static EFI_STATUS EFIAPI efi_snp_receive_filters (EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 enable, UINT32 disable, BOOLEAN mcast_reset, UINTN mcast_count, EFI_MAC_ADDRESS *mcast)
 Manage receive filters. More...
 
static EFI_STATUS EFIAPI efi_snp_station_address (EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, EFI_MAC_ADDRESS *new)
 Set station address. More...
 
static EFI_STATUS EFIAPI efi_snp_statistics (EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, UINTN *stats_len, EFI_NETWORK_STATISTICS *stats)
 Get (or reset) statistics. More...
 
static EFI_STATUS EFIAPI efi_snp_mcast_ip_to_mac (EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ipv6, EFI_IP_ADDRESS *ip, EFI_MAC_ADDRESS *mac)
 Convert multicast IP address to MAC address. More...
 
static EFI_STATUS EFIAPI efi_snp_nvdata (EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN read, UINTN offset, UINTN len, VOID *data)
 Read or write non-volatile storage. More...
 
static EFI_STATUS EFIAPI efi_snp_get_status (EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 *interrupts, VOID **txbuf)
 Read interrupt status and TX recycled buffer status. More...
 
static EFI_STATUS EFIAPI efi_snp_transmit (EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN ll_header_len, UINTN len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
 Start packet transmission. More...
 
static EFI_STATUS EFIAPI efi_snp_receive (EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN *ll_header_len, UINTN *len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
 Receive packet. More...
 
static VOID EFIAPI efi_snp_wait_for_packet (EFI_EVENT event __unused, VOID *context)
 Poll event. More...
 
static uint8_t efi_undi_checksum (void *data, size_t len)
 Calculate UNDI byte checksum. More...
 
static unsigned int efi_undi_ifnum (struct efi_snp_device *snpdev)
 Get UNDI SNP device interface number. More...
 
static struct efi_snp_deviceefi_undi_snpdev (unsigned int ifnum)
 Identify UNDI SNP device. More...
 
static PXE_STATCODE efi_undi_statcode (EFI_STATUS efirc)
 Convert EFI status code to UNDI status code. More...
 
static EFI_STATUS efi_undi_get_state (struct efi_snp_device *snpdev, PXE_CDB *cdb)
 Get state. More...
 
static EFI_STATUS efi_undi_start (struct efi_snp_device *snpdev)
 Start. More...
 
static EFI_STATUS efi_undi_stop (struct efi_snp_device *snpdev)
 Stop. More...
 
static EFI_STATUS efi_undi_get_init_info (struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_DB_GET_INIT_INFO *db)
 Get initialisation information. More...
 
static EFI_STATUS efi_undi_initialize (struct efi_snp_device *snpdev, PXE_CDB *cdb)
 Initialise. More...
 
static EFI_STATUS efi_undi_reset (struct efi_snp_device *snpdev)
 Reset. More...
 
static EFI_STATUS efi_undi_shutdown (struct efi_snp_device *snpdev)
 Shutdown. More...
 
static EFI_STATUS efi_undi_receive_filters (struct efi_snp_device *snpdev, PXE_CDB *cdb)
 Get/set receive filters. More...
 
static EFI_STATUS efi_undi_station_address (struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_CPB_STATION_ADDRESS *cpb, PXE_DB_STATION_ADDRESS *db)
 Get/set station address. More...
 
static EFI_STATUS efi_undi_get_status (struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_DB_GET_STATUS *db)
 Get interrupt status. More...
 
static EFI_STATUS efi_undi_fill_header (struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_CPB_ANY *cpb)
 Fill header. More...
 
static EFI_STATUS efi_undi_transmit (struct efi_snp_device *snpdev, PXE_CPB_TRANSMIT *cpb)
 Transmit. More...
 
static EFI_STATUS efi_undi_receive (struct efi_snp_device *snpdev, PXE_CPB_RECEIVE *cpb, PXE_DB_RECEIVE *db)
 Receive. More...
 
static EFIAPI VOID efi_undi_issue (UINT64 cdb_phys)
 UNDI entry point. More...
 
static EFI_STATUS EFIAPI efi_snp_get_driver_name (EFI_COMPONENT_NAME2_PROTOCOL *name2, CHAR8 *language __unused, CHAR16 **driver_name)
 Look up driver name. More...
 
static EFI_STATUS EFIAPI efi_snp_get_controller_name (EFI_COMPONENT_NAME2_PROTOCOL *name2, EFI_HANDLE device __unused, EFI_HANDLE child __unused, CHAR8 *language __unused, CHAR16 **controller_name)
 Look up controller name. More...
 
static EFI_STATUS EFIAPI efi_snp_load_file (EFI_LOAD_FILE_PROTOCOL *load_file, EFI_DEVICE_PATH_PROTOCOL *path __unused, BOOLEAN booting, UINTN *len __unused, VOID *data __unused)
 Load file. More...
 
static struct efi_snp_deviceefi_snp_demux (struct net_device *netdev)
 Locate SNP device corresponding to network device. More...
 
static int efi_snp_probe (struct net_device *netdev)
 Create SNP device. More...
 
static void efi_snp_notify (struct net_device *netdev)
 Handle SNP device or link state change. More...
 
static void efi_snp_remove (struct net_device *netdev)
 Destroy SNP device. More...
 
struct efi_snp_devicefind_snpdev (EFI_HANDLE handle)
 Find SNP device by EFI device handle. More...
 
struct efi_snp_devicelast_opened_snpdev (void)
 Get most recently opened SNP device. More...
 
void efi_snp_add_claim (int delta)
 Add to SNP claimed/released count. More...
 

Variables

static int efi_snp_claimed
 Network devices are currently claimed for use by iPXE. More...
 
static EFI_TPL efi_snp_old_tpl
 TPL prior to network devices being claimed. More...
 
static EFI_SIMPLE_NETWORK_PROTOCOL efi_snp_device_snp
 SNP interface. More...
 
static PXE_SW_UNDI efi_snp_undi
 UNDI interface. More...
 
static EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL efi_snp_device_nii
 Network Identification Interface (NII) More...
 
static EFI_LOAD_FILE_PROTOCOL efi_snp_load_file_protocol
 Load file protocol. More...
 
struct net_driver efi_snp_driver __net_driver
 SNP driver. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ LIST_HEAD()

static LIST_HEAD ( efi_snp_devices  )
static

List of SNP devices.

◆ efi_snp_set_state()

static void efi_snp_set_state ( struct efi_snp_device snpdev)
static

Set EFI SNP mode state.

Parameters
snpSNP interface

Definition at line 89 of file efi_snp.c.

89  {
90  struct net_device *netdev = snpdev->netdev;
91  EFI_SIMPLE_NETWORK_MODE *mode = &snpdev->mode;
92 
93  /* Calculate state */
94  if ( ! snpdev->started ) {
95  /* Start() method not called; report as Stopped */
97  } else if ( ! netdev_is_open ( netdev ) ) {
98  /* Network device not opened; report as Started */
100  } else if ( efi_snp_claimed ) {
101  /* Network device opened but claimed for use by iPXE; report
102  * as Started to inhibit receive polling.
103  */
105  } else {
106  /* Network device opened and available for use via SNP; report
107  * as Initialized.
108  */
110  }
111 }
int started
Started flag.
Definition: efi_snp.h:41
UINT32 State
Reports the current state of the network interface.
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:348
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39

References efi_snp_claimed, EfiSimpleNetworkInitialized, EfiSimpleNetworkStarted, EfiSimpleNetworkStopped, efi_snp_device::mode, efi_snp_device::netdev, netdev, netdev_is_open(), efi_snp_device::started, and EFI_SIMPLE_NETWORK_MODE::State.

Referenced by efi_snp_add_claim(), efi_snp_initialize(), efi_snp_notify(), efi_snp_reset(), efi_snp_shutdown(), efi_snp_start(), and efi_snp_stop().

◆ efi_snp_set_mode()

static void efi_snp_set_mode ( struct efi_snp_device snpdev)
static

Set EFI SNP mode based on iPXE net device parameters.

Parameters
snpSNP interface

Definition at line 118 of file efi_snp.c.

118  {
119  struct net_device *netdev = snpdev->netdev;
120  EFI_SIMPLE_NETWORK_MODE *mode = &snpdev->mode;
122  unsigned int ll_addr_len = ll_protocol->ll_addr_len;
123 
124  mode->HwAddressSize = ll_addr_len;
126  mode->MaxPacketSize = netdev->mtu;
130  assert ( ll_addr_len <= sizeof ( mode->CurrentAddress ) );
134  mode->IfType = ntohs ( ll_protocol->ll_proto );
135  mode->MacAddressChangeable = TRUE;
136  mode->MediaPresentSupported = TRUE;
137  mode->MediaPresent = ( netdev_link_ok ( netdev ) ? TRUE : FALSE );
138 }
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
UINT32 MediaHeaderSize
The size, in bytes, of the network interface's media header.
BOOLEAN MediaPresent
TRUE if media are connected to the network interface; otherwise FALSE.
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:409
#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:383
BOOLEAN MediaPresentSupported
TRUE if the presence of media can be determined; otherwise FALSE.
#define ntohs(value)
Definition: byteswap.h:136
void(* init_addr)(const void *hw_addr, void *ll_addr)
Initialise link-layer address.
Definition: netdevice.h:150
A link-layer protocol.
Definition: netdevice.h:114
EFI_MAC_ADDRESS CurrentAddress
The current HW MAC address for the network interface.
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
EFI_MAC_ADDRESS BroadcastAddress
The current HW MAC address for broadcast packets.
UINT8 IfType
The interface type of the network interface.
UINT32 MaxPacketSize
The maximum size, in bytes, of the packets supported by the network interface.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
BOOLEAN MacAddressChangeable
TRUE if the HW MAC address can be changed.
#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST
A network device.
Definition: netdevice.h:348
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
#define TRUE
Definition: tlan.h:46
#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST
UINT32 HwAddressSize
The size, in bytes, of the network interface's HW address.
UINT32 ReceiveFilterMask
The multicast receive filter settings supported by the network interface.
#define FALSE
Definition: tlan.h:45
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
EFI_MAC_ADDRESS PermanentAddress
The permanent HW MAC address for the network interface.

References assert(), EFI_SIMPLE_NETWORK_MODE::BroadcastAddress, EFI_SIMPLE_NETWORK_MODE::CurrentAddress, EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST, EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST, EFI_SIMPLE_NETWORK_RECEIVE_UNICAST, FALSE, net_device::hw_addr, EFI_SIMPLE_NETWORK_MODE::HwAddressSize, EFI_SIMPLE_NETWORK_MODE::IfType, ll_protocol::init_addr, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_broadcast, ll_protocol::ll_header_len, ll_protocol::ll_proto, net_device::ll_protocol, EFI_SIMPLE_NETWORK_MODE::MacAddressChangeable, EFI_SIMPLE_NETWORK_MODE::MaxPacketSize, EFI_SIMPLE_NETWORK_MODE::MediaHeaderSize, EFI_SIMPLE_NETWORK_MODE::MediaPresent, EFI_SIMPLE_NETWORK_MODE::MediaPresentSupported, memcpy(), efi_snp_device::mode, net_device::mtu, efi_snp_device::netdev, netdev, netdev_link_ok(), ntohs, EFI_SIMPLE_NETWORK_MODE::PermanentAddress, EFI_SIMPLE_NETWORK_MODE::ReceiveFilterMask, and TRUE.

Referenced by efi_snp_probe().

◆ efi_snp_flush()

static void efi_snp_flush ( struct efi_snp_device snpdev)
static

Flush transmit ring and receive queue.

Parameters
snpdevSNP device

Definition at line 145 of file efi_snp.c.

145  {
146  struct io_buffer *iobuf;
147  struct io_buffer *tmp;
148 
149  /* Reset transmit completion ring */
150  snpdev->tx_prod = 0;
151  snpdev->tx_cons = 0;
152 
153  /* Discard any queued receive buffers */
154  list_for_each_entry_safe ( iobuf, tmp, &snpdev->rx, list ) {
155  list_del ( &iobuf->list );
156  free_iob ( iobuf );
157  }
158 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
unsigned int tx_cons
Transmit completion ring consumer counter.
Definition: efi_snp.h:49
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
uint8_t * tmp
Definition: entropy.h:156
struct list_head rx
Receive queue.
Definition: efi_snp.h:51
unsigned int tx_prod
Transmit completion ring producer counter.
Definition: efi_snp.h:47
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:39
A persistent I/O buffer.
Definition: iobuf.h:32

References free_iob(), io_buffer::list, list_del, list_for_each_entry_safe, efi_snp_device::rx, tmp, efi_snp_device::tx_cons, and efi_snp_device::tx_prod.

Referenced by efi_snp_reset(), and efi_snp_shutdown().

◆ efi_snp_poll()

static void efi_snp_poll ( struct efi_snp_device snpdev)
static

Poll net device and count received packets.

Parameters
snpdevSNP device

Definition at line 165 of file efi_snp.c.

165  {
167  struct io_buffer *iobuf;
168 
169  /* Poll network device */
170  netdev_poll ( snpdev->netdev );
171 
172  /* Retrieve any received packets */
173  while ( ( iobuf = netdev_rx_dequeue ( snpdev->netdev ) ) ) {
174  list_add_tail ( &iobuf->list, &snpdev->rx );
176  bs->SignalEvent ( &snpdev->snp.WaitForPacket );
177  }
178 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
EFI_SIGNAL_EVENT SignalEvent
Definition: UefiSpec.h:1863
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
void netdev_poll(struct net_device *netdev)
Poll for completed and received packets on network device.
Definition: netdevice.c:523
EFI Boot Services Table.
Definition: UefiSpec.h:1836
struct list_head rx
Receive queue.
Definition: efi_snp.h:51
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:39
EFI_SYSTEM_TABLE * efi_systab
EFI_EVENT WaitForPacket
Event used with WaitForEvent() to wait for a packet to be received.
#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
unsigned int interrupts
Pending interrupt status.
Definition: efi_snp.h:43
struct io_buffer * netdev_rx_dequeue(struct net_device *netdev)
Remove packet from device's receive queue.
Definition: netdevice.c:538
A persistent I/O buffer.
Definition: iobuf.h:32

References EFI_SYSTEM_TABLE::BootServices, EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT, efi_systab, efi_snp_device::interrupts, io_buffer::list, list_add_tail, efi_snp_device::netdev, netdev_poll(), netdev_rx_dequeue(), efi_snp_device::rx, EFI_BOOT_SERVICES::SignalEvent, efi_snp_device::snp, and _EFI_SIMPLE_NETWORK_PROTOCOL::WaitForPacket.

Referenced by efi_snp_get_status(), efi_snp_receive(), and efi_snp_wait_for_packet().

◆ efi_snp_start()

static EFI_STATUS EFIAPI efi_snp_start ( EFI_SIMPLE_NETWORK_PROTOCOL snp)
static

Change SNP state from "stopped" to "started".

Parameters
snpSNP interface
Return values
efircEFI status code

Definition at line 187 of file efi_snp.c.

187  {
188  struct efi_snp_device *snpdev =
189  container_of ( snp, struct efi_snp_device, snp );
190 
191  DBGC ( snpdev, "SNPDEV %p START\n", snpdev );
192 
193  /* Fail if net device is currently claimed for use by iPXE */
194  if ( efi_snp_claimed )
195  return EFI_NOT_READY;
196 
197  snpdev->started = 1;
198  efi_snp_set_state ( snpdev );
199  return 0;
200 }
int started
Started flag.
Definition: efi_snp.h:41
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
An SNP device.
Definition: efi_snp.h:27
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126

References container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, efi_snp_set_state(), efi_snp_device::snp, and efi_snp_device::started.

Referenced by efi_undi_start().

◆ efi_snp_stop()

static EFI_STATUS EFIAPI efi_snp_stop ( EFI_SIMPLE_NETWORK_PROTOCOL snp)
static

Change SNP state from "started" to "stopped".

Parameters
snpSNP interface
Return values
efircEFI status code

Definition at line 209 of file efi_snp.c.

209  {
210  struct efi_snp_device *snpdev =
211  container_of ( snp, struct efi_snp_device, snp );
212 
213  DBGC ( snpdev, "SNPDEV %p STOP\n", snpdev );
214 
215  /* Fail if net device is currently claimed for use by iPXE */
216  if ( efi_snp_claimed )
217  return EFI_NOT_READY;
218 
219  snpdev->started = 0;
220  efi_snp_set_state ( snpdev );
221 
222  return 0;
223 }
int started
Started flag.
Definition: efi_snp.h:41
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
An SNP device.
Definition: efi_snp.h:27
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126

References container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, efi_snp_set_state(), efi_snp_device::snp, and efi_snp_device::started.

Referenced by efi_undi_stop().

◆ efi_snp_initialize()

static EFI_STATUS EFIAPI efi_snp_initialize ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
UINTN  extra_rx_bufsize,
UINTN  extra_tx_bufsize 
)
static

Open the network device.

Parameters
snpSNP interface
extra_rx_bufsizeExtra RX buffer size, in bytes
extra_tx_bufsizeExtra TX buffer size, in bytes
Return values
efircEFI status code

Definition at line 234 of file efi_snp.c.

235  {
237  struct efi_snp_device *snpdev =
238  container_of ( snp, struct efi_snp_device, snp );
239  EFI_TPL saved_tpl;
240  int rc;
241 
242  DBGC ( snpdev, "SNPDEV %p INITIALIZE (%ld extra RX, %ld extra TX)\n",
243  snpdev, ( ( unsigned long ) extra_rx_bufsize ),
244  ( ( unsigned long ) extra_tx_bufsize ) );
245 
246  /* Fail if net device is currently claimed for use by iPXE */
247  if ( efi_snp_claimed ) {
248  rc = -EAGAIN;
249  goto err_claimed;
250  }
251 
252  /* Raise TPL */
253  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
254 
255  /* Open network device */
256  if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) {
257  DBGC ( snpdev, "SNPDEV %p could not open %s: %s\n",
258  snpdev, snpdev->netdev->name, strerror ( rc ) );
259  goto err_open;
260  }
261  efi_snp_set_state ( snpdev );
262 
263  err_open:
264  bs->RestoreTPL ( saved_tpl );
265  err_claimed:
266  return EFIRC ( rc );
267 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
int netdev_open(struct net_device *netdev)
Open network device.
Definition: netdevice.c:767
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149

References EFI_SYSTEM_TABLE::BootServices, container_of, DBGC, EAGAIN, efi_snp_claimed, efi_snp_set_state(), efi_systab, EFIRC, net_device::name, efi_snp_device::netdev, netdev_open(), EFI_BOOT_SERVICES::RaiseTPL, rc, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::snp, strerror(), and TPL_CALLBACK.

Referenced by efi_undi_initialize().

◆ efi_snp_reset()

static EFI_STATUS EFIAPI efi_snp_reset ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
BOOLEAN  ext_verify 
)
static

Reset the network device.

Parameters
snpSNP interface
ext_verifyExtended verification required
Return values
efircEFI status code

Definition at line 277 of file efi_snp.c.

277  {
279  struct efi_snp_device *snpdev =
280  container_of ( snp, struct efi_snp_device, snp );
281  EFI_TPL saved_tpl;
282  int rc;
283 
284  DBGC ( snpdev, "SNPDEV %p RESET (%s extended verification)\n",
285  snpdev, ( ext_verify ? "with" : "without" ) );
286 
287  /* Fail if net device is currently claimed for use by iPXE */
288  if ( efi_snp_claimed ) {
289  rc = -EAGAIN;
290  goto err_claimed;
291  }
292 
293  /* Raise TPL */
294  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
295 
296  /* Close network device */
297  netdev_close ( snpdev->netdev );
298  efi_snp_set_state ( snpdev );
299  efi_snp_flush ( snpdev );
300 
301  /* Reopen network device */
302  if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) {
303  DBGC ( snpdev, "SNPDEV %p could not reopen %s: %s\n",
304  snpdev, snpdev->netdev->name, strerror ( rc ) );
305  goto err_open;
306  }
307  efi_snp_set_state ( snpdev );
308 
309  err_open:
310  bs->RestoreTPL ( saved_tpl );
311  err_claimed:
312  return EFIRC ( rc );
313 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
static void efi_snp_flush(struct efi_snp_device *snpdev)
Flush transmit ring and receive queue.
Definition: efi_snp.c:145
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
void netdev_close(struct net_device *netdev)
Close network device.
Definition: netdevice.c:801
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
int netdev_open(struct net_device *netdev)
Open network device.
Definition: netdevice.c:767
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149

References EFI_SYSTEM_TABLE::BootServices, container_of, DBGC, EAGAIN, efi_snp_claimed, efi_snp_flush(), efi_snp_set_state(), efi_systab, EFIRC, net_device::name, efi_snp_device::netdev, netdev_close(), netdev_open(), EFI_BOOT_SERVICES::RaiseTPL, rc, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::snp, strerror(), and TPL_CALLBACK.

Referenced by efi_undi_reset().

◆ efi_snp_shutdown()

static EFI_STATUS EFIAPI efi_snp_shutdown ( EFI_SIMPLE_NETWORK_PROTOCOL snp)
static

Shut down the network device.

Parameters
snpSNP interface
Return values
efircEFI status code

Definition at line 322 of file efi_snp.c.

322  {
324  struct efi_snp_device *snpdev =
325  container_of ( snp, struct efi_snp_device, snp );
326  EFI_TPL saved_tpl;
327 
328  DBGC ( snpdev, "SNPDEV %p SHUTDOWN\n", snpdev );
329 
330  /* Fail if net device is currently claimed for use by iPXE */
331  if ( efi_snp_claimed )
332  return EFI_NOT_READY;
333 
334  /* Raise TPL */
335  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
336 
337  /* Close network device */
338  netdev_close ( snpdev->netdev );
339  efi_snp_set_state ( snpdev );
340  efi_snp_flush ( snpdev );
341 
342  /* Restore TPL */
343  bs->RestoreTPL ( saved_tpl );
344 
345  return 0;
346 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
static void efi_snp_flush(struct efi_snp_device *snpdev)
Flush transmit ring and receive queue.
Definition: efi_snp.c:145
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
void netdev_close(struct net_device *netdev)
Close network device.
Definition: netdevice.c:801
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846

References EFI_SYSTEM_TABLE::BootServices, container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, efi_snp_flush(), efi_snp_set_state(), efi_systab, efi_snp_device::netdev, netdev_close(), EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::snp, and TPL_CALLBACK.

Referenced by efi_undi_shutdown().

◆ efi_snp_receive_filters()

static EFI_STATUS EFIAPI efi_snp_receive_filters ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
UINT32  enable,
UINT32  disable,
BOOLEAN  mcast_reset,
UINTN  mcast_count,
EFI_MAC_ADDRESS mcast 
)
static

Manage receive filters.

Parameters
snpSNP interface
enableReceive filters to enable
disableReceive filters to disable
mcast_resetReset multicast filters
mcast_countNumber of multicast filters
mcastMulticast filters
Return values
efircEFI status code

Definition at line 360 of file efi_snp.c.

362  {
363  struct efi_snp_device *snpdev =
364  container_of ( snp, struct efi_snp_device, snp );
365  unsigned int i;
366 
367  DBGC ( snpdev, "SNPDEV %p RECEIVE_FILTERS %08x&~%08x%s %ld mcast\n",
368  snpdev, enable, disable, ( mcast_reset ? " reset" : "" ),
369  ( ( unsigned long ) mcast_count ) );
370  for ( i = 0 ; i < mcast_count ; i++ ) {
371  DBGC2_HDA ( snpdev, i, &mcast[i],
372  snpdev->netdev->ll_protocol->ll_addr_len );
373  }
374 
375  /* Lie through our teeth, otherwise MNP refuses to accept us.
376  *
377  * Return success even if the SNP device is currently claimed
378  * for use by iPXE, since otherwise Windows Deployment
379  * Services refuses to attempt to receive further packets via
380  * our EFI PXE Base Code protocol.
381  */
382  return 0;
383 }
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define DBGC(...)
Definition: compiler.h:505
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define DBGC2_HDA(...)
Definition: compiler.h:523
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
An SNP device.
Definition: efi_snp.h:27
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References container_of, DBGC, DBGC2_HDA, ll_protocol::ll_addr_len, net_device::ll_protocol, efi_snp_device::netdev, and efi_snp_device::snp.

◆ efi_snp_station_address()

static EFI_STATUS EFIAPI efi_snp_station_address ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
BOOLEAN  reset,
EFI_MAC_ADDRESS new 
)
static

Set station address.

Parameters
snpSNP interface
resetReset to permanent address
newNew station address
Return values
efircEFI status code

Definition at line 394 of file efi_snp.c.

395  {
396  struct efi_snp_device *snpdev =
397  container_of ( snp, struct efi_snp_device, snp );
398  struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
399 
400  DBGC ( snpdev, "SNPDEV %p STATION_ADDRESS %s\n", snpdev,
401  ( reset ? "reset" : ll_protocol->ntoa ( new ) ) );
402 
403  /* Fail if net device is currently claimed for use by iPXE */
404  if ( efi_snp_claimed )
405  return EFI_NOT_READY;
406 
407  /* Set the MAC address */
408  if ( reset )
409  new = &snpdev->mode.PermanentAddress;
410  memcpy ( snpdev->netdev->ll_addr, new, ll_protocol->ll_addr_len );
411 
412  /* MAC address changes take effect only on netdev_open() */
413  if ( netdev_is_open ( snpdev->netdev ) ) {
414  DBGC ( snpdev, "SNPDEV %p MAC address changed while net "
415  "device open\n", snpdev );
416  }
417 
418  return 0;
419 }
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define DBGC(...)
Definition: compiler.h:505
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
An SNP device.
Definition: efi_snp.h:27
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
Definition: netdevice.h:163
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
EFI_MAC_ADDRESS PermanentAddress
The permanent HW MAC address for the network interface.

References container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), efi_snp_device::mode, efi_snp_device::netdev, netdev_is_open(), ll_protocol::ntoa, EFI_SIMPLE_NETWORK_MODE::PermanentAddress, and efi_snp_device::snp.

Referenced by efi_undi_station_address().

◆ efi_snp_statistics()

static EFI_STATUS EFIAPI efi_snp_statistics ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
BOOLEAN  reset,
UINTN stats_len,
EFI_NETWORK_STATISTICS stats 
)
static

Get (or reset) statistics.

Parameters
snpSNP interface
resetReset statistics
stats_lenSize of statistics table
statsStatistics table
Return values
efircEFI status code

Definition at line 431 of file efi_snp.c.

432  {
433  struct efi_snp_device *snpdev =
434  container_of ( snp, struct efi_snp_device, snp );
435  EFI_NETWORK_STATISTICS stats_buf;
436 
437  DBGC ( snpdev, "SNPDEV %p STATISTICS%s", snpdev,
438  ( reset ? " reset" : "" ) );
439 
440  /* Fail if net device is currently claimed for use by iPXE */
441  if ( efi_snp_claimed )
442  return EFI_NOT_READY;
443 
444  /* Gather statistics */
445  memset ( &stats_buf, 0, sizeof ( stats_buf ) );
446  stats_buf.TxGoodFrames = snpdev->netdev->tx_stats.good;
447  stats_buf.TxDroppedFrames = snpdev->netdev->tx_stats.bad;
448  stats_buf.TxTotalFrames = ( snpdev->netdev->tx_stats.good +
449  snpdev->netdev->tx_stats.bad );
450  stats_buf.RxGoodFrames = snpdev->netdev->rx_stats.good;
451  stats_buf.RxDroppedFrames = snpdev->netdev->rx_stats.bad;
452  stats_buf.RxTotalFrames = ( snpdev->netdev->rx_stats.good +
453  snpdev->netdev->rx_stats.bad );
454  if ( *stats_len > sizeof ( stats_buf ) )
455  *stats_len = sizeof ( stats_buf );
456  if ( stats )
457  memcpy ( stats, &stats_buf, *stats_len );
458 
459  /* Reset statistics if requested to do so */
460  if ( reset ) {
461  memset ( &snpdev->netdev->tx_stats, 0,
462  sizeof ( snpdev->netdev->tx_stats ) );
463  memset ( &snpdev->netdev->rx_stats, 0,
464  sizeof ( snpdev->netdev->rx_stats ) );
465  }
466 
467  return 0;
468 }
#define DBGC(...)
Definition: compiler.h:505
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device_stats tx_stats
TX statistics.
Definition: netdevice.h:417
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
UINT64 RxGoodFrames
Number of valid frames received and copied into receive buffers.
Definition: SimpleNetwork.h:57
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
UINT64 TxTotalFrames
Transmit statistics.
UINT64 RxDroppedFrames
Valid frames that were dropped because receive buffers were full.
Definition: SimpleNetwork.h:74
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
UINT64 RxTotalFrames
Total number of frames received.
Definition: SimpleNetwork.h:52
struct net_device_stats rx_stats
RX statistics.
Definition: netdevice.h:419
unsigned int bad
Count of error completions.
Definition: netdevice.h:291
An SNP device.
Definition: efi_snp.h:27
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
unsigned int good
Count of successful completions.
Definition: netdevice.h:289
Simple Network Protocol data structures.
Definition: SimpleNetwork.h:47
void * memset(void *dest, int character, size_t len) __nonnull

References net_device_stats::bad, container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, net_device_stats::good, memcpy(), memset(), efi_snp_device::netdev, net_device::rx_stats, EFI_NETWORK_STATISTICS::RxDroppedFrames, EFI_NETWORK_STATISTICS::RxGoodFrames, EFI_NETWORK_STATISTICS::RxTotalFrames, efi_snp_device::snp, net_device::tx_stats, EFI_NETWORK_STATISTICS::TxDroppedFrames, EFI_NETWORK_STATISTICS::TxGoodFrames, and EFI_NETWORK_STATISTICS::TxTotalFrames.

◆ efi_snp_mcast_ip_to_mac()

static EFI_STATUS EFIAPI efi_snp_mcast_ip_to_mac ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
BOOLEAN  ipv6,
EFI_IP_ADDRESS ip,
EFI_MAC_ADDRESS mac 
)
static

Convert multicast IP address to MAC address.

Parameters
snpSNP interface
ipv6Address is IPv6
ipIP address
macMAC address
Return values
efircEFI status code

Definition at line 480 of file efi_snp.c.

481  {
482  struct efi_snp_device *snpdev =
483  container_of ( snp, struct efi_snp_device, snp );
484  struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
485  const char *ip_str;
486  int rc;
487 
488  ip_str = ( ipv6 ? "(IPv6)" /* FIXME when we have inet6_ntoa() */ :
489  inet_ntoa ( *( ( struct in_addr * ) ip ) ) );
490  DBGC ( snpdev, "SNPDEV %p MCAST_IP_TO_MAC %s\n", snpdev, ip_str );
491 
492  /* Fail if net device is currently claimed for use by iPXE */
493  if ( efi_snp_claimed )
494  return EFI_NOT_READY;
495 
496  /* Try to hash the address */
497  if ( ( rc = ll_protocol->mc_hash ( ( ipv6 ? AF_INET6 : AF_INET ),
498  ip, mac ) ) != 0 ) {
499  DBGC ( snpdev, "SNPDEV %p could not hash %s: %s\n",
500  snpdev, ip_str, strerror ( rc ) );
501  return EFIRC ( rc );
502  }
503 
504  return 0;
505 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define AF_INET6
IPv6 Internet addresses.
Definition: socket.h:64
#define DBGC(...)
Definition: compiler.h:505
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
IP address structure.
Definition: in.h:39
An SNP device.
Definition: efi_snp.h:27
IP4_t ip
Destination IP address.
Definition: pxe_api.h:58
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
Definition: ipv4.c:658
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
int(* mc_hash)(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
Definition: netdevice.h:172
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References AF_INET, AF_INET6, container_of, DBGC, EFI_NOT_READY, efi_snp_claimed, EFIRC, inet_ntoa(), ip, net_device::ll_protocol, mac, ll_protocol::mc_hash, efi_snp_device::netdev, rc, efi_snp_device::snp, and strerror().

◆ efi_snp_nvdata()

static EFI_STATUS EFIAPI efi_snp_nvdata ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
BOOLEAN  read,
UINTN  offset,
UINTN  len,
VOID data 
)
static

Read or write non-volatile storage.

Parameters
snpSNP interface
readOperation is a read
offsetStarting offset within NVRAM
lenLength of data buffer
dataData buffer
Return values
efircEFI status code

Definition at line 518 of file efi_snp.c.

519  {
520  struct efi_snp_device *snpdev =
521  container_of ( snp, struct efi_snp_device, snp );
522 
523  DBGC ( snpdev, "SNPDEV %p NVDATA %s %lx+%lx\n", snpdev,
524  ( read ? "read" : "write" ), ( ( unsigned long ) offset ),
525  ( ( unsigned long ) len ) );
526  if ( ! read )
527  DBGC2_HDA ( snpdev, offset, data, len );
528 
529  /* Fail if net device is currently claimed for use by iPXE */
530  if ( efi_snp_claimed )
531  return EFI_NOT_READY;
532 
533  return EFI_UNSUPPORTED;
534 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define DBGC(...)
Definition: compiler.h:505
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define DBGC2_HDA(...)
Definition: compiler.h:523
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
device device nvs read
Definition: threewire.h:60
An SNP device.
Definition: efi_snp.h:27
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References container_of, data, DBGC, DBGC2_HDA, EFI_NOT_READY, efi_snp_claimed, EFI_UNSUPPORTED, len, offset, read, and efi_snp_device::snp.

◆ efi_snp_get_status()

static EFI_STATUS EFIAPI efi_snp_get_status ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
UINT32 interrupts,
VOID **  txbuf 
)
static

Read interrupt status and TX recycled buffer status.

Parameters
snpSNP interface
interruptsInterrupt status, or NULL
txbufRecycled transmit buffer address, or NULL
Return values
efircEFI status code

Definition at line 545 of file efi_snp.c.

546  {
548  struct efi_snp_device *snpdev =
549  container_of ( snp, struct efi_snp_device, snp );
550  EFI_TPL saved_tpl;
551 
552  DBGC2 ( snpdev, "SNPDEV %p GET_STATUS", snpdev );
553 
554  /* Fail if net device is currently claimed for use by iPXE */
555  if ( efi_snp_claimed ) {
556  DBGC2 ( snpdev, "\n" );
557  return EFI_NOT_READY;
558  }
559 
560  /* Raise TPL */
561  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
562 
563  /* Poll the network device */
564  efi_snp_poll ( snpdev );
565 
566  /* Interrupt status. In practice, this seems to be used only
567  * to detect TX completions.
568  */
569  if ( interrupts ) {
570  *interrupts = snpdev->interrupts;
571  DBGC2 ( snpdev, " INTS:%02x", *interrupts );
572  snpdev->interrupts = 0;
573  }
574 
575  /* TX completions */
576  if ( txbuf ) {
577  if ( snpdev->tx_prod != snpdev->tx_cons ) {
578  *txbuf = snpdev->tx[snpdev->tx_cons++ % EFI_SNP_NUM_TX];
579  } else {
580  *txbuf = NULL;
581  }
582  DBGC2 ( snpdev, " TX:%p", *txbuf );
583  }
584 
585  /* Restore TPL */
586  bs->RestoreTPL ( saved_tpl );
587 
588  DBGC2 ( snpdev, "\n" );
589  return 0;
590 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
#define EFI_SNP_NUM_TX
SNP transmit completion ring size.
Definition: efi_snp.h:24
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
unsigned int tx_cons
Transmit completion ring consumer counter.
Definition: efi_snp.h:49
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
VOID * tx[EFI_SNP_NUM_TX]
Transmit completion ring.
Definition: efi_snp.h:45
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
unsigned int tx_prod
Transmit completion ring producer counter.
Definition: efi_snp.h:47
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
#define DBGC2(...)
Definition: compiler.h:522
static void efi_snp_poll(struct efi_snp_device *snpdev)
Poll net device and count received packets.
Definition: efi_snp.c:165
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int interrupts
Pending interrupt status.
Definition: efi_snp.h:43

References EFI_SYSTEM_TABLE::BootServices, container_of, DBGC2, EFI_NOT_READY, efi_snp_claimed, EFI_SNP_NUM_TX, efi_snp_poll(), efi_systab, efi_snp_device::interrupts, NULL, EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::snp, TPL_CALLBACK, efi_snp_device::tx, efi_snp_device::tx_cons, and efi_snp_device::tx_prod.

Referenced by efi_undi_get_status().

◆ efi_snp_transmit()

static EFI_STATUS EFIAPI efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
UINTN  ll_header_len,
UINTN  len,
VOID data,
EFI_MAC_ADDRESS ll_src,
EFI_MAC_ADDRESS ll_dest,
UINT16 net_proto 
)
static

Start packet transmission.

Parameters
snpSNP interface
ll_header_lenLink-layer header length, if to be filled in
lenLength of data buffer
dataData buffer
ll_srcLink-layer source address, if specified
ll_destLink-layer destination address, if specified
net_protoNetwork-layer protocol (in host order)
Return values
efircEFI status code

Definition at line 605 of file efi_snp.c.

608  {
610  struct efi_snp_device *snpdev =
611  container_of ( snp, struct efi_snp_device, snp );
612  struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
613  struct io_buffer *iobuf;
614  size_t payload_len;
615  unsigned int tx_fill;
616  EFI_TPL saved_tpl;
617  int rc;
618 
619  DBGC2 ( snpdev, "SNPDEV %p TRANSMIT %p+%lx", snpdev, data,
620  ( ( unsigned long ) len ) );
621  if ( ll_header_len ) {
622  if ( ll_src ) {
623  DBGC2 ( snpdev, " src %s",
624  ll_protocol->ntoa ( ll_src ) );
625  }
626  if ( ll_dest ) {
627  DBGC2 ( snpdev, " dest %s",
628  ll_protocol->ntoa ( ll_dest ) );
629  }
630  if ( net_proto ) {
631  DBGC2 ( snpdev, " proto %04x", *net_proto );
632  }
633  }
634  DBGC2 ( snpdev, "\n" );
635 
636  /* Fail if net device is currently claimed for use by iPXE */
637  if ( efi_snp_claimed ) {
638  rc = -EAGAIN;
639  goto err_claimed;
640  }
641 
642  /* Raise TPL */
643  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
644 
645  /* Sanity checks */
646  if ( ll_header_len ) {
647  if ( ll_header_len != ll_protocol->ll_header_len ) {
648  DBGC ( snpdev, "SNPDEV %p TX invalid header length "
649  "%ld\n", snpdev,
650  ( ( unsigned long ) ll_header_len ) );
651  rc = -EINVAL;
652  goto err_sanity;
653  }
654  if ( len < ll_header_len ) {
655  DBGC ( snpdev, "SNPDEV %p invalid packet length %ld\n",
656  snpdev, ( ( unsigned long ) len ) );
657  rc = -EINVAL;
658  goto err_sanity;
659  }
660  if ( ! ll_dest ) {
661  DBGC ( snpdev, "SNPDEV %p TX missing destination "
662  "address\n", snpdev );
663  rc = -EINVAL;
664  goto err_sanity;
665  }
666  if ( ! net_proto ) {
667  DBGC ( snpdev, "SNPDEV %p TX missing network "
668  "protocol\n", snpdev );
669  rc = -EINVAL;
670  goto err_sanity;
671  }
672  if ( ! ll_src )
673  ll_src = &snpdev->mode.CurrentAddress;
674  }
675 
676  /* Allocate buffer */
677  payload_len = ( len - ll_protocol->ll_header_len );
678  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + ( ( payload_len > IOB_ZLEN ) ?
679  payload_len : IOB_ZLEN ) );
680  if ( ! iobuf ) {
681  DBGC ( snpdev, "SNPDEV %p TX could not allocate %ld-byte "
682  "buffer\n", snpdev, ( ( unsigned long ) len ) );
683  rc = -ENOMEM;
684  goto err_alloc_iob;
685  }
686  iob_reserve ( iobuf, ( MAX_LL_HEADER_LEN -
688  memcpy ( iob_put ( iobuf, len ), data, len );
689 
690  /* Create link-layer header, if specified */
691  if ( ll_header_len ) {
692  iob_pull ( iobuf, ll_protocol->ll_header_len );
693  if ( ( rc = ll_protocol->push ( snpdev->netdev,
694  iobuf, ll_dest, ll_src,
695  htons ( *net_proto ) )) != 0 ){
696  DBGC ( snpdev, "SNPDEV %p TX could not construct "
697  "header: %s\n", snpdev, strerror ( rc ) );
698  goto err_ll_push;
699  }
700  }
701 
702  /* Transmit packet */
703  if ( ( rc = netdev_tx ( snpdev->netdev, iob_disown ( iobuf ) ) ) != 0){
704  DBGC ( snpdev, "SNPDEV %p TX could not transmit: %s\n",
705  snpdev, strerror ( rc ) );
706  goto err_tx;
707  }
708 
709  /* Record in transmit completion ring. If we run out of
710  * space, report the failure even though we have already
711  * transmitted the packet.
712  *
713  * This allows us to report completions only for packets for
714  * which we had reported successfully initiating transmission,
715  * while continuing to support clients that never poll for
716  * transmit completions.
717  */
718  tx_fill = ( snpdev->tx_prod - snpdev->tx_cons );
719  if ( tx_fill >= EFI_SNP_NUM_TX ) {
720  DBGC ( snpdev, "SNPDEV %p TX completion ring full\n", snpdev );
721  rc = -ENOBUFS;
722  goto err_ring_full;
723  }
724  snpdev->tx[ snpdev->tx_prod++ % EFI_SNP_NUM_TX ] = data;
726 
727  /* Restore TPL */
728  bs->RestoreTPL ( saved_tpl );
729 
730  return 0;
731 
732  err_ring_full:
733  err_tx:
734  err_ll_push:
735  free_iob ( iobuf );
736  err_alloc_iob:
737  err_sanity:
738  bs->RestoreTPL ( saved_tpl );
739  err_claimed:
740  return EFIRC ( rc );
741 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define DBGC(...)
Definition: compiler.h:505
#define EFI_SNP_NUM_TX
SNP transmit completion ring size.
Definition: efi_snp.h:24
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
A link-layer protocol.
Definition: netdevice.h:114
EFI_MAC_ADDRESS CurrentAddress
The current HW MAC address for the network interface.
int(* push)(struct net_device *netdev, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto)
Add link-layer header.
Definition: netdevice.h:127
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int tx_cons
Transmit completion ring consumer counter.
Definition: efi_snp.h:49
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
VOID * tx[EFI_SNP_NUM_TX]
Transmit completion ring.
Definition: efi_snp.h:45
#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
Definition: netdevice.c:290
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
unsigned int tx_prod
Transmit completion ring producer counter.
Definition: efi_snp.h:47
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
#define IOB_ZLEN
Minimum I/O buffer length.
Definition: iobuf.h:23
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
Definition: netdevice.h:163
EFI_SYSTEM_TABLE * efi_systab
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
#define htons(value)
Definition: byteswap.h:135
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
unsigned int interrupts
Pending interrupt status.
Definition: efi_snp.h:43
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob(), EFI_SYSTEM_TABLE::BootServices, container_of, EFI_SIMPLE_NETWORK_MODE::CurrentAddress, data, DBGC, DBGC2, EAGAIN, EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT, efi_snp_claimed, EFI_SNP_NUM_TX, efi_systab, EFIRC, EINVAL, ENOBUFS, ENOMEM, free_iob(), htons, efi_snp_device::interrupts, iob_disown, iob_pull, iob_put, iob_reserve, IOB_ZLEN, len, ll_protocol::ll_header_len, net_device::ll_protocol, MAX_LL_HEADER_LEN, memcpy(), efi_snp_device::mode, efi_snp_device::netdev, netdev_tx(), ll_protocol::ntoa, ll_protocol::push, EFI_BOOT_SERVICES::RaiseTPL, rc, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::snp, strerror(), TPL_CALLBACK, efi_snp_device::tx, efi_snp_device::tx_cons, and efi_snp_device::tx_prod.

Referenced by efi_undi_transmit().

◆ efi_snp_receive()

static EFI_STATUS EFIAPI efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL snp,
UINTN ll_header_len,
UINTN len,
VOID data,
EFI_MAC_ADDRESS ll_src,
EFI_MAC_ADDRESS ll_dest,
UINT16 net_proto 
)
static

Receive packet.

Parameters
snpSNP interface
ll_header_lenLink-layer header length, if to be filled in
lenLength of data buffer
dataData buffer
ll_srcLink-layer source address, if specified
ll_destLink-layer destination address, if specified
net_protoNetwork-layer protocol (in host order)
Return values
efircEFI status code

Definition at line 756 of file efi_snp.c.

759  {
761  struct efi_snp_device *snpdev =
762  container_of ( snp, struct efi_snp_device, snp );
763  struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
764  struct io_buffer *iobuf;
765  const void *iob_ll_dest;
766  const void *iob_ll_src;
767  uint16_t iob_net_proto;
768  unsigned int iob_flags;
769  size_t copy_len;
770  EFI_TPL saved_tpl;
771  int rc;
772 
773  DBGC2 ( snpdev, "SNPDEV %p RECEIVE %p(+%lx)", snpdev, data,
774  ( ( unsigned long ) *len ) );
775 
776  /* Fail if net device is currently claimed for use by iPXE */
777  if ( efi_snp_claimed ) {
778  rc = -EAGAIN;
779  goto err_claimed;
780  }
781 
782  /* Raise TPL */
783  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
784 
785  /* Poll the network device */
786  efi_snp_poll ( snpdev );
787 
788  /* Check for an available packet */
789  iobuf = list_first_entry ( &snpdev->rx, struct io_buffer, list );
790  if ( ! iobuf ) {
791  DBGC2 ( snpdev, "\n" );
792  rc = -EAGAIN;
793  goto out_no_packet;
794  }
795  DBGC2 ( snpdev, "+%zx\n", iob_len ( iobuf ) );
796 
797  /* Dequeue packet */
798  list_del ( &iobuf->list );
799 
800  /* Return packet to caller, truncating to buffer length */
801  copy_len = iob_len ( iobuf );
802  if ( copy_len > *len )
803  copy_len = *len;
804  memcpy ( data, iobuf->data, copy_len );
805  *len = iob_len ( iobuf );
806 
807  /* Attempt to decode link-layer header */
808  if ( ( rc = ll_protocol->pull ( snpdev->netdev, iobuf, &iob_ll_dest,
809  &iob_ll_src, &iob_net_proto,
810  &iob_flags ) ) != 0 ) {
811  DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
812  snpdev, strerror ( rc ) );
813  goto out_bad_ll_header;
814  }
815 
816  /* Return link-layer header parameters to caller, if required */
817  if ( ll_header_len )
818  *ll_header_len = ll_protocol->ll_header_len;
819  if ( ll_src )
820  memcpy ( ll_src, iob_ll_src, ll_protocol->ll_addr_len );
821  if ( ll_dest )
822  memcpy ( ll_dest, iob_ll_dest, ll_protocol->ll_addr_len );
823  if ( net_proto )
824  *net_proto = ntohs ( iob_net_proto );
825 
826  /* Check buffer length */
827  rc = ( ( copy_len == *len ) ? 0 : -ERANGE );
828 
829  out_bad_ll_header:
830  free_iob ( iobuf );
831  out_no_packet:
832  bs->RestoreTPL ( saved_tpl );
833  err_claimed:
834  return EFIRC ( rc );
835 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
#define ERANGE
Result too large.
Definition: errno.h:639
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318
struct list_head rx
Receive queue.
Definition: efi_snp.h:51
int(* pull)(struct net_device *netdev, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags)
Remove link-layer header.
Definition: netdevice.h:141
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:39
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
static void efi_snp_poll(struct efi_snp_device *snpdev)
Poll net device and count received packets.
Definition: efi_snp.c:165
EFI_SYSTEM_TABLE * efi_systab
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
A persistent I/O buffer.
Definition: iobuf.h:32

References EFI_SYSTEM_TABLE::BootServices, container_of, data, io_buffer::data, DBGC, DBGC2, EAGAIN, efi_snp_claimed, efi_snp_poll(), efi_systab, EFIRC, ERANGE, free_iob(), iob_len(), len, io_buffer::list, list_del, list_first_entry, ll_protocol::ll_addr_len, ll_protocol::ll_header_len, net_device::ll_protocol, memcpy(), efi_snp_device::netdev, ntohs, ll_protocol::pull, EFI_BOOT_SERVICES::RaiseTPL, rc, EFI_BOOT_SERVICES::RestoreTPL, efi_snp_device::rx, efi_snp_device::snp, strerror(), and TPL_CALLBACK.

Referenced by efi_undi_receive().

◆ efi_snp_wait_for_packet()

static VOID EFIAPI efi_snp_wait_for_packet ( EFI_EVENT event  __unused,
VOID context 
)
static

Poll event.

Parameters
eventEvent
contextEvent context

Definition at line 843 of file efi_snp.c.

844  {
846  struct efi_snp_device *snpdev = context;
847  EFI_TPL saved_tpl;
848 
849  DBGCP ( snpdev, "SNPDEV %p WAIT_FOR_PACKET\n", snpdev );
850 
851  /* Do nothing unless the net device is open */
852  if ( ! netdev_is_open ( snpdev->netdev ) )
853  return;
854 
855  /* Do nothing if net device is currently claimed for use by iPXE */
856  if ( efi_snp_claimed )
857  return;
858 
859  /* Raise TPL */
860  saved_tpl = bs->RaiseTPL ( TPL_CALLBACK );
861 
862  /* Poll the network device */
863  efi_snp_poll ( snpdev );
864 
865  /* Restore TPL */
866  bs->RestoreTPL ( saved_tpl );
867 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:47
static void efi_snp_poll(struct efi_snp_device *snpdev)
Poll net device and count received packets.
Definition: efi_snp.c:165
#define DBGCP(...)
Definition: compiler.h:539
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846

References EFI_SYSTEM_TABLE::BootServices, DBGCP, efi_snp_claimed, efi_snp_poll(), efi_systab, efi_snp_device::netdev, netdev_is_open(), EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RestoreTPL, and TPL_CALLBACK.

Referenced by efi_snp_probe().

◆ efi_undi_checksum()

static uint8_t efi_undi_checksum ( void *  data,
size_t  len 
)
static

Calculate UNDI byte checksum.

Parameters
dataData
lenLength of data
Return values
sumChecksum

Definition at line 918 of file efi_snp.c.

918  {
919  uint8_t *bytes = data;
920  uint8_t sum = 0;
921 
922  while ( len-- )
923  sum += *bytes++;
924  return sum;
925 }
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint8_t bytes[64]
Definition: ib_mad.h:16

References bytes, data, and len.

Referenced by efi_snp_probe().

◆ efi_undi_ifnum()

static unsigned int efi_undi_ifnum ( struct efi_snp_device snpdev)
static

Get UNDI SNP device interface number.

Parameters
snpdevSNP device
Return values
ifnumUNDI interface number

Definition at line 933 of file efi_snp.c.

933  {
934 
935  /* iPXE network device indexes are one-based (leaving zero
936  * meaning "unspecified"). UNDI interface numbers are
937  * zero-based.
938  */
939  return ( snpdev->netdev->index - 1 );
940 }
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
unsigned int index
Index of this network device.
Definition: netdevice.h:356

References net_device::index, and efi_snp_device::netdev.

Referenced by efi_snp_probe(), and efi_undi_snpdev().

◆ efi_undi_snpdev()

static struct efi_snp_device* efi_undi_snpdev ( unsigned int  ifnum)
static

Identify UNDI SNP device.

Parameters
ifnumInterface number
Return values
snpdevSNP device, or NULL if not found

Definition at line 948 of file efi_snp.c.

948  {
949  struct efi_snp_device *snpdev;
950 
951  list_for_each_entry ( snpdev, &efi_snp_devices, list ) {
952  if ( efi_undi_ifnum ( snpdev ) == ifnum )
953  return snpdev;
954  }
955  return NULL;
956 }
static unsigned int efi_undi_ifnum(struct efi_snp_device *snpdev)
Get UNDI SNP device interface number.
Definition: efi_snp.c:933
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An SNP device.
Definition: efi_snp.h:27
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29

References efi_undi_ifnum(), efi_snp_device::list, list_for_each_entry, and NULL.

Referenced by efi_undi_issue().

◆ efi_undi_statcode()

static PXE_STATCODE efi_undi_statcode ( EFI_STATUS  efirc)
static

Convert EFI status code to UNDI status code.

Parameters
efircEFI status code
Return values
statcodeUNDI status code

Definition at line 964 of file efi_snp.c.

964  {
965 
966  switch ( efirc ) {
971  case EFI_NOT_READY: return PXE_STATCODE_NO_DATA;
972  default:
974  }
975 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define EFI_PROTOCOL_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:144
#define EFI_OUT_OF_RESOURCES
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:129
#define PXE_STATCODE_DEVICE_FAILURE
Definition: UefiPxe.h:622
#define PXE_STATCODE_UNSUPPORTED
Definition: UefiPxe.h:624
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
#define EFI_INVALID_PARAMETER
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:122
#define PXE_STATCODE_NO_DATA
Definition: UefiPxe.h:631
#define PXE_STATCODE_BUFFER_FULL
Definition: UefiPxe.h:625
#define PXE_STATCODE_INVALID_CDB
Definition: UefiPxe.h:613
#define PXE_STATCODE_INVALID_PARAMETER
Definition: UefiPxe.h:626

References EFI_INVALID_PARAMETER, EFI_NOT_READY, EFI_OUT_OF_RESOURCES, EFI_PROTOCOL_ERROR, EFI_UNSUPPORTED, PXE_STATCODE_BUFFER_FULL, PXE_STATCODE_DEVICE_FAILURE, PXE_STATCODE_INVALID_CDB, PXE_STATCODE_INVALID_PARAMETER, PXE_STATCODE_NO_DATA, and PXE_STATCODE_UNSUPPORTED.

Referenced by efi_undi_issue().

◆ efi_undi_get_state()

static EFI_STATUS efi_undi_get_state ( struct efi_snp_device snpdev,
PXE_CDB cdb 
)
static

Get state.

Parameters
snpdevSNP device
cdbCommand description block
Return values
efircEFI status code

Definition at line 984 of file efi_snp.c.

985  {
986  EFI_SIMPLE_NETWORK_MODE *mode = &snpdev->mode;
987 
988  DBGC ( snpdev, "UNDI %p GET STATE\n", snpdev );
989 
990  /* Return current state */
993  } else if ( mode->State == EfiSimpleNetworkStarted ) {
995  } else {
997  }
998 
999  return 0;
1000 }
#define PXE_STATFLAGS_GET_STATE_STARTED
Definition: UefiPxe.h:432
#define DBGC(...)
Definition: compiler.h:505
UINT32 State
Reports the current state of the network interface.
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890
#define PXE_STATFLAGS_GET_STATE_STOPPED
Definition: UefiPxe.h:433
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
#define PXE_STATFLAGS_GET_STATE_INITIALIZED
Definition: UefiPxe.h:431

References DBGC, EfiSimpleNetworkInitialized, EfiSimpleNetworkStarted, efi_snp_device::mode, PXE_STATFLAGS_GET_STATE_INITIALIZED, PXE_STATFLAGS_GET_STATE_STARTED, PXE_STATFLAGS_GET_STATE_STOPPED, EFI_SIMPLE_NETWORK_MODE::State, and s_pxe_cdb::StatFlags.

Referenced by efi_undi_issue().

◆ efi_undi_start()

static EFI_STATUS efi_undi_start ( struct efi_snp_device snpdev)
static

Start.

Parameters
snpdevSNP device
Return values
efircEFI status code

Definition at line 1008 of file efi_snp.c.

1008  {
1009  EFI_STATUS efirc;
1010 
1011  DBGC ( snpdev, "UNDI %p START\n", snpdev );
1012 
1013  /* Start SNP device */
1014  if ( ( efirc = efi_snp_start ( &snpdev->snp ) ) != 0 )
1015  return efirc;
1016 
1017  return 0;
1018 }
static EFI_STATUS EFIAPI efi_snp_start(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Change SNP state from "stopped" to "started".
Definition: efi_snp.c:187
#define DBGC(...)
Definition: compiler.h:505
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35

References DBGC, efi_snp_start(), and efi_snp_device::snp.

Referenced by efi_undi_issue().

◆ efi_undi_stop()

static EFI_STATUS efi_undi_stop ( struct efi_snp_device snpdev)
static

Stop.

Parameters
snpdevSNP device
Return values
efircEFI status code

Definition at line 1026 of file efi_snp.c.

1026  {
1027  EFI_STATUS efirc;
1028 
1029  DBGC ( snpdev, "UNDI %p STOP\n", snpdev );
1030 
1031  /* Stop SNP device */
1032  if ( ( efirc = efi_snp_stop ( &snpdev->snp ) ) != 0 )
1033  return efirc;
1034 
1035  return 0;
1036 }
#define DBGC(...)
Definition: compiler.h:505
static EFI_STATUS EFIAPI efi_snp_stop(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Change SNP state from "started" to "stopped".
Definition: efi_snp.c:209
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35

References DBGC, efi_snp_stop(), and efi_snp_device::snp.

Referenced by efi_undi_issue().

◆ efi_undi_get_init_info()

static EFI_STATUS efi_undi_get_init_info ( struct efi_snp_device snpdev,
PXE_CDB cdb,
PXE_DB_GET_INIT_INFO db 
)
static

Get initialisation information.

Parameters
snpdevSNP device
cdbCommand description block
dbData block
Return values
efircEFI status code

Definition at line 1046 of file efi_snp.c.

1048  {
1049  struct net_device *netdev = snpdev->netdev;
1051 
1052  DBGC ( snpdev, "UNDI %p GET INIT INFO\n", snpdev );
1053 
1054  /* Populate structure */
1055  memset ( db, 0, sizeof ( *db ) );
1056  db->FrameDataLen = ( netdev->max_pkt_len - ll_protocol->ll_header_len );
1057  db->MediaHeaderLen = ll_protocol->ll_header_len;
1058  db->HWaddrLen = ll_protocol->ll_addr_len;
1059  db->IFtype = ntohs ( ll_protocol->ll_proto );
1062 
1063  return 0;
1064 }
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
static struct net_device * netdev
Definition: gdbudp.c:52
#define PXE_STATFLAGS_CABLE_DETECT_SUPPORTED
Definition: UefiPxe.h:446
A network device.
Definition: netdevice.h:348
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED
Definition: UefiPxe.h:450
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
static struct dmfe_private * db
Definition: dmfe.c:177
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:403
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
void * memset(void *dest, int character, size_t len) __nonnull

References db, DBGC, ll_protocol::ll_addr_len, ll_protocol::ll_header_len, ll_protocol::ll_proto, net_device::ll_protocol, net_device::max_pkt_len, memset(), efi_snp_device::netdev, netdev, ntohs, PXE_STATFLAGS_CABLE_DETECT_SUPPORTED, PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED, and s_pxe_cdb::StatFlags.

Referenced by efi_undi_issue().

◆ efi_undi_initialize()

static EFI_STATUS efi_undi_initialize ( struct efi_snp_device snpdev,
PXE_CDB cdb 
)
static

Initialise.

Parameters
snpdevSNP device
cdbCommand description block
efircEFI status code

Definition at line 1073 of file efi_snp.c.

1074  {
1075  struct net_device *netdev = snpdev->netdev;
1076  EFI_STATUS efirc;
1077 
1078  DBGC ( snpdev, "UNDI %p INITIALIZE\n", snpdev );
1079 
1080  /* Reset SNP device */
1081  if ( ( efirc = efi_snp_initialize ( &snpdev->snp, 0, 0 ) ) != 0 )
1082  return efirc;
1083 
1084  /* Report link state */
1085  if ( ! netdev_link_ok ( netdev ) )
1087 
1088  return 0;
1089 }
static EFI_STATUS EFIAPI efi_snp_initialize(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN extra_rx_bufsize, UINTN extra_tx_bufsize)
Open the network device.
Definition: efi_snp.c:234
#define DBGC(...)
Definition: compiler.h:505
#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA
UNDI Initialize.
Definition: UefiPxe.h:455
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
A network device.
Definition: netdevice.h:348
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890

References DBGC, efi_snp_initialize(), efi_snp_device::netdev, netdev, netdev_link_ok(), PXE_STATFLAGS_INITIALIZED_NO_MEDIA, efi_snp_device::snp, and s_pxe_cdb::StatFlags.

Referenced by efi_undi_issue().

◆ efi_undi_reset()

static EFI_STATUS efi_undi_reset ( struct efi_snp_device snpdev)
static

Reset.

Parameters
snpdevSNP device
efircEFI status code

Definition at line 1097 of file efi_snp.c.

1097  {
1098  EFI_STATUS efirc;
1099 
1100  DBGC ( snpdev, "UNDI %p RESET\n", snpdev );
1101 
1102  /* Reset SNP device */
1103  if ( ( efirc = efi_snp_reset ( &snpdev->snp, 0 ) ) != 0 )
1104  return efirc;
1105 
1106  return 0;
1107 }
#define DBGC(...)
Definition: compiler.h:505
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
static EFI_STATUS EFIAPI efi_snp_reset(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ext_verify)
Reset the network device.
Definition: efi_snp.c:277

References DBGC, efi_snp_reset(), and efi_snp_device::snp.

Referenced by efi_undi_issue().

◆ efi_undi_shutdown()

static EFI_STATUS efi_undi_shutdown ( struct efi_snp_device snpdev)
static

Shutdown.

Parameters
snpdevSNP device
efircEFI status code

Definition at line 1115 of file efi_snp.c.

1115  {
1116  EFI_STATUS efirc;
1117 
1118  DBGC ( snpdev, "UNDI %p SHUTDOWN\n", snpdev );
1119 
1120  /* Reset SNP device */
1121  if ( ( efirc = efi_snp_shutdown ( &snpdev->snp ) ) != 0 )
1122  return efirc;
1123 
1124  return 0;
1125 }
#define DBGC(...)
Definition: compiler.h:505
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
static EFI_STATUS EFIAPI efi_snp_shutdown(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Shut down the network device.
Definition: efi_snp.c:322
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35

References DBGC, efi_snp_shutdown(), and efi_snp_device::snp.

Referenced by efi_undi_issue().

◆ efi_undi_receive_filters()

static EFI_STATUS efi_undi_receive_filters ( struct efi_snp_device snpdev,
PXE_CDB cdb 
)
static

Get/set receive filters.

Parameters
snpdevSNP device
cdbCommand description block
efircEFI status code

Definition at line 1134 of file efi_snp.c.

1135  {
1136 
1137  DBGC ( snpdev, "UNDI %p RECEIVE FILTERS\n", snpdev );
1138 
1139  /* Mark everything as supported */
1144 
1145  return 0;
1146 }
#define DBGC(...)
Definition: compiler.h:505
#define PXE_STATFLAGS_RECEIVE_FILTER_UNICAST
UNDI Receive Filters.
Definition: UefiPxe.h:492
#define PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST
If set, all multicast packets will be received.
Definition: UefiPxe.h:513
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890
#define PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST
If set, broadcast packets will be received.
Definition: UefiPxe.h:497
#define PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS
If set, all packets will be received.
Definition: UefiPxe.h:508

References DBGC, PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST, PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST, PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS, PXE_STATFLAGS_RECEIVE_FILTER_UNICAST, and s_pxe_cdb::StatFlags.

Referenced by efi_undi_issue().

◆ efi_undi_station_address()

static EFI_STATUS efi_undi_station_address ( struct efi_snp_device snpdev,
PXE_CDB cdb,
PXE_CPB_STATION_ADDRESS cpb,
PXE_DB_STATION_ADDRESS db 
)
static

Get/set station address.

Parameters
snpdevSNP device
cdbCommand description block
cpbCommand parameter block
efircEFI status code

Definition at line 1156 of file efi_snp.c.

1159  {
1160  struct net_device *netdev = snpdev->netdev;
1162  void *mac;
1163  int reset;
1164  EFI_STATUS efirc;
1165 
1166  DBGC ( snpdev, "UNDI %p STATION ADDRESS\n", snpdev );
1167 
1168  /* Update address if applicable */
1169  reset = ( cdb->OpFlags & PXE_OPFLAGS_STATION_ADDRESS_RESET );
1170  mac = ( cpb ? &cpb->StationAddr : NULL );
1171  if ( ( reset || mac ) &&
1172  ( ( efirc = efi_snp_station_address ( &snpdev->snp, reset,
1173  mac ) ) != 0 ) )
1174  return efirc;
1175 
1176  /* Fill in current addresses, if applicable */
1177  if ( db ) {
1178  memset ( db, 0, sizeof ( *db ) );
1179  memcpy ( &db->StationAddr, netdev->ll_addr,
1181  memcpy ( &db->BroadcastAddr, netdev->ll_broadcast,
1183  memcpy ( &db->PermanentAddr, netdev->hw_addr,
1185  }
1186 
1187  return 0;
1188 }
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
PXE_OPFLAGS OpFlags
Definition: UefiPxe.h:884
#define DBGC(...)
Definition: compiler.h:505
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:383
static EFI_STATUS EFIAPI efi_snp_station_address(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, EFI_MAC_ADDRESS *new)
Set station address.
Definition: efi_snp.c:394
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
PXE_MAC_ADDR StationAddr
If supplied and supported, the current station MAC address will be changed.
Definition: UefiPxe.h:1347
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:196
static struct net_device * netdev
Definition: gdbudp.c:52
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
A network device.
Definition: netdevice.h:348
#define PXE_OPFLAGS_STATION_ADDRESS_RESET
Definition: UefiPxe.h:324
static struct dmfe_private * db
Definition: dmfe.c:177
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
void * memset(void *dest, int character, size_t len) __nonnull

References db, DBGC, efi_snp_station_address(), net_device::hw_addr, ll_protocol::hw_addr_len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_broadcast, net_device::ll_protocol, mac, memcpy(), memset(), efi_snp_device::netdev, netdev, NULL, s_pxe_cdb::OpFlags, PXE_OPFLAGS_STATION_ADDRESS_RESET, efi_snp_device::snp, and s_pxe_cpb_station_address::StationAddr.

Referenced by efi_undi_issue().

◆ efi_undi_get_status()

static EFI_STATUS efi_undi_get_status ( struct efi_snp_device snpdev,
PXE_CDB cdb,
PXE_DB_GET_STATUS db 
)
static

Get interrupt status.

Parameters
snpdevSNP device
cdbCommand description block
dbData block
efircEFI status code

Definition at line 1198 of file efi_snp.c.

1199  {
1200  UINT32 interrupts;
1201  VOID *txbuf;
1202  struct io_buffer *rxbuf;
1203  EFI_STATUS efirc;
1204 
1205  DBGC2 ( snpdev, "UNDI %p GET STATUS\n", snpdev );
1206 
1207  /* Get status */
1208  if ( ( efirc = efi_snp_get_status ( &snpdev->snp, &interrupts,
1209  &txbuf ) ) != 0 )
1210  return efirc;
1211 
1212  /* Report status */
1213  memset ( db, 0, sizeof ( *db ) );
1214  if ( interrupts & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT )
1216  if ( interrupts & EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT )
1218  if ( txbuf ) {
1219  db->TxBuffer[0] = ( ( intptr_t ) txbuf );
1220  } else {
1222  /* The specification states clearly that UNDI drivers
1223  * should set TXBUF_QUEUE_EMPTY if all completed
1224  * buffer addresses are written into the returned data
1225  * block. However, SnpDxe chooses to interpret
1226  * TXBUF_QUEUE_EMPTY as a synonym for
1227  * NO_TXBUFS_WRITTEN, thereby rendering it entirely
1228  * pointless. Work around this UEFI stupidity, as per
1229  * usual.
1230  */
1231  if ( snpdev->tx_prod == snpdev->tx_cons )
1232  cdb->StatFlags |=
1234  }
1235  rxbuf = list_first_entry ( &snpdev->rx, struct io_buffer, list );
1236  if ( rxbuf )
1237  db->RxFrameLen = iob_len ( rxbuf );
1238  if ( ! netdev_link_ok ( snpdev->netdev ) )
1240 
1241  return 0;
1242 }
#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN
This flag is set if no transmitted buffer addresses were written into the DB.
Definition: UefiPxe.h:578
unsigned int UINT32
Definition: ProcessorBind.h:56
unsigned long intptr_t
Definition: stdint.h:21
#define PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY
This flag is set if the transmitted buffer queue is empty.
Definition: UefiPxe.h:572
#define PXE_STATFLAGS_GET_STATUS_RECEIVE
If set, at least one receive interrupt occurred.
Definition: UefiPxe.h:551
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
unsigned int tx_cons
Transmit completion ring consumer counter.
Definition: efi_snp.h:49
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA
This flag is set if there is no media detected.
Definition: UefiPxe.h:583
#define VOID
Undeclared type.
Definition: Base.h:319
struct list_head rx
Receive queue.
Definition: efi_snp.h:51
unsigned int tx_prod
Transmit completion ring producer counter.
Definition: efi_snp.h:47
static struct dmfe_private * db
Definition: dmfe.c:177
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:39
#define DBGC2(...)
Definition: compiler.h:522
static EFI_STATUS EFIAPI efi_snp_get_status(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 *interrupts, VOID **txbuf)
Read interrupt status and TX recycled buffer status.
Definition: efi_snp.c:545
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890
#define PXE_STATFLAGS_GET_STATUS_TRANSMIT
If set, at least one transmit interrupt occurred.
Definition: UefiPxe.h:556
#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32

References db, DBGC2, EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT, EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT, efi_snp_get_status(), iob_len(), io_buffer::list, list_first_entry, memset(), efi_snp_device::netdev, netdev_link_ok(), PXE_STATFLAGS_GET_STATUS_NO_MEDIA, PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN, PXE_STATFLAGS_GET_STATUS_RECEIVE, PXE_STATFLAGS_GET_STATUS_TRANSMIT, PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY, efi_snp_device::rx, efi_snp_device::snp, s_pxe_cdb::StatFlags, efi_snp_device::tx_cons, efi_snp_device::tx_prod, and VOID.

Referenced by efi_undi_issue().

◆ efi_undi_fill_header()

static EFI_STATUS efi_undi_fill_header ( struct efi_snp_device snpdev,
PXE_CDB cdb,
PXE_CPB_ANY cpb 
)
static

Fill header.

Parameters
snpdevSNP device
cdbCommand description block
cpbCommand parameter block
efircEFI status code

Definition at line 1252 of file efi_snp.c.

1253  {
1254  struct net_device *netdev = snpdev->netdev;
1256  PXE_CPB_FILL_HEADER *whole = &cpb->fill_header;
1258  VOID *data;
1259  void *dest;
1260  void *src;
1261  uint16_t proto;
1262  struct io_buffer iobuf;
1263  int rc;
1264 
1265  /* SnpDxe will (pointlessly) use PXE_CPB_FILL_HEADER_FRAGMENTED
1266  * even though we choose to explicitly not claim support for
1267  * fragments via PXE_ROMID_IMP_FRAG_SUPPORTED.
1268  */
1270  data = ( ( void * ) ( intptr_t ) fragged->FragDesc[0].FragAddr);
1271  dest = &fragged->DestAddr;
1272  src = &fragged->SrcAddr;
1273  proto = fragged->Protocol;
1274  } else {
1275  data = ( ( void * ) ( intptr_t ) whole->MediaHeader );
1276  dest = &whole->DestAddr;
1277  src = &whole->SrcAddr;
1278  proto = whole->Protocol;
1279  }
1280 
1281  /* Construct link-layer header */
1282  iob_populate ( &iobuf, data, 0, ll_protocol->ll_header_len );
1283  iob_reserve ( &iobuf, ll_protocol->ll_header_len );
1284  if ( ( rc = ll_protocol->push ( netdev, &iobuf, dest, src,
1285  proto ) ) != 0 )
1286  return EFIRC ( rc );
1287 
1288  return 0;
1289 }
PXE_UINT16 Protocol
Protocol type.
Definition: UefiPxe.h:1603
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
PXE_MAC_ADDR SrcAddr
Source and destination MAC addresses.
Definition: UefiPxe.h:1620
PXE_OPFLAGS OpFlags
Definition: UefiPxe.h:884
static void iob_populate(struct io_buffer *iobuf, void *data, size_t len, size_t max_len)
Create a temporary I/O buffer.
Definition: iobuf.h:186
unsigned long intptr_t
Definition: stdint.h:21
PXE_MAC_ADDR DestAddr
Definition: UefiPxe.h:1585
PXE_MAC_ADDR SrcAddr
Source and destination MAC addresses.
Definition: UefiPxe.h:1584
A link-layer protocol.
Definition: netdevice.h:114
int(* push)(struct net_device *netdev, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto)
Add link-layer header.
Definition: netdevice.h:127
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
PXE_CPB_FILL_HEADER_FRAGMENTED fill_header_fragmented
Definition: efi_snp.c:898
PXE_MEDIA_PROTOCOL Protocol
Protocol type.
Definition: UefiPxe.h:1633
static struct net_device * netdev
Definition: gdbudp.c:52
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
#define PXE_OPFLAGS_FILL_HEADER_FRAGMENTED
Definition: UefiPxe.h:382
A network device.
Definition: netdevice.h:348
PXE_CPB_FILL_HEADER fill_header
Definition: efi_snp.c:897
#define VOID
Undeclared type.
Definition: Base.h:319
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
struct s_pxe_cpb_fill_header_fragmented::@517 FragDesc[MAX_XMIT_FRAGMENTS]
Array of packet fragment descriptors.
PXE_UINT64 MediaHeader
Address of first byte of media header.
Definition: UefiPxe.h:1591
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
PXE_UINT64 FragAddr
Address of this packet fragment.
Definition: UefiPxe.h:1658
A persistent I/O buffer.
Definition: iobuf.h:32

References data, dest, s_pxe_cpb_fill_header::DestAddr, s_pxe_cpb_fill_header_fragmented::DestAddr, EFIRC, PXE_CPB_ANY::fill_header, PXE_CPB_ANY::fill_header_fragmented, s_pxe_cpb_fill_header_fragmented::FragAddr, s_pxe_cpb_fill_header_fragmented::FragDesc, iob_populate(), iob_reserve, ll_protocol::ll_header_len, net_device::ll_protocol, s_pxe_cpb_fill_header::MediaHeader, efi_snp_device::netdev, netdev, s_pxe_cdb::OpFlags, s_pxe_cpb_fill_header::Protocol, s_pxe_cpb_fill_header_fragmented::Protocol, ll_protocol::push, PXE_OPFLAGS_FILL_HEADER_FRAGMENTED, rc, src, s_pxe_cpb_fill_header::SrcAddr, s_pxe_cpb_fill_header_fragmented::SrcAddr, and VOID.

Referenced by efi_undi_issue().

◆ efi_undi_transmit()

static EFI_STATUS efi_undi_transmit ( struct efi_snp_device snpdev,
PXE_CPB_TRANSMIT cpb 
)
static

Transmit.

Parameters
snpdevSNP device
cpbCommand parameter block
efircEFI status code

Definition at line 1298 of file efi_snp.c.

1299  {
1300  VOID *data = ( ( void * ) ( intptr_t ) cpb->FrameAddr );
1301  EFI_STATUS efirc;
1302 
1303  DBGC2 ( snpdev, "UNDI %p TRANSMIT\n", snpdev );
1304 
1305  /* Transmit packet */
1306  if ( ( efirc = efi_snp_transmit ( &snpdev->snp, 0, cpb->DataLen,
1307  data, NULL, NULL, NULL ) ) != 0 )
1308  return efirc;
1309 
1310  return 0;
1311 }
PXE_UINT32 DataLen
Length of the data portion of the frame buffer in bytes.
Definition: UefiPxe.h:1684
unsigned long intptr_t
Definition: stdint.h:21
PXE_UINT64 FrameAddr
Address of first byte of frame buffer.
Definition: UefiPxe.h:1678
static EFI_STATUS EFIAPI efi_snp_transmit(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN ll_header_len, UINTN len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
Start packet transmission.
Definition: efi_snp.c:605
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
#define VOID
Undeclared type.
Definition: Base.h:319
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References data, s_pxe_cpb_transmit::DataLen, DBGC2, efi_snp_transmit(), s_pxe_cpb_transmit::FrameAddr, NULL, efi_snp_device::snp, and VOID.

Referenced by efi_undi_issue().

◆ efi_undi_receive()

static EFI_STATUS efi_undi_receive ( struct efi_snp_device snpdev,
PXE_CPB_RECEIVE cpb,
PXE_DB_RECEIVE db 
)
static

Receive.

Parameters
snpdevSNP device
cpbCommand parameter block
efircEFI status code

Definition at line 1320 of file efi_snp.c.

1322  {
1323  struct net_device *netdev = snpdev->netdev;
1325  VOID *data = ( ( void * ) ( intptr_t ) cpb->BufferAddr );
1326  UINTN hdr_len;
1327  UINTN len = cpb->BufferLen;
1330  UINT16 proto;
1331  EFI_STATUS efirc;
1332 
1333  DBGC2 ( snpdev, "UNDI %p RECEIVE\n", snpdev );
1334 
1335  /* Receive packet */
1336  if ( ( efirc = efi_snp_receive ( &snpdev->snp, &hdr_len, &len, data,
1337  &src, &dest, &proto ) ) != 0 )
1338  return efirc;
1339 
1340  /* Describe frame */
1341  memset ( db, 0, sizeof ( *db ) );
1342  memcpy ( &db->SrcAddr, &src, ll_protocol->ll_addr_len );
1343  memcpy ( &db->DestAddr, &dest, ll_protocol->ll_addr_len );
1344  db->FrameLen = len;
1345  db->Protocol = proto;
1346  db->MediaHeaderLen = ll_protocol->ll_header_len;
1348 
1349  return 0;
1350 }
PXE_UINT32 BufferLen
Length of receive buffer.
Definition: UefiPxe.h:1748
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
32-byte buffer containing a network Media Access Control address.
Definition: UefiBaseType.h:102
unsigned long intptr_t
Definition: stdint.h:21
A link-layer protocol.
Definition: netdevice.h:114
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static EFI_STATUS EFIAPI efi_snp_receive(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN *ll_header_len, UINTN *len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
Receive packet.
Definition: efi_snp.c:756
static struct net_device * netdev
Definition: gdbudp.c:52
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
unsigned short UINT16
Definition: ProcessorBind.h:58
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
PXE_UINT64 BufferAddr
Address of first byte of receive buffer.
Definition: UefiPxe.h:1741
A network device.
Definition: netdevice.h:348
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
#define VOID
Undeclared type.
Definition: Base.h:319
static struct dmfe_private * db
Definition: dmfe.c:177
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define PXE_FRAME_TYPE_PROMISCUOUS
Definition: UefiPxe.h:673
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
void * memset(void *dest, int character, size_t len) __nonnull

References s_pxe_cpb_receive::BufferAddr, s_pxe_cpb_receive::BufferLen, data, db, DBGC2, dest, efi_snp_receive(), len, ll_protocol::ll_addr_len, ll_protocol::ll_header_len, net_device::ll_protocol, memcpy(), memset(), efi_snp_device::netdev, netdev, PXE_FRAME_TYPE_PROMISCUOUS, efi_snp_device::snp, src, and VOID.

Referenced by efi_undi_issue().

◆ efi_undi_issue()

static EFIAPI VOID efi_undi_issue ( UINT64  cdb_phys)
static

UNDI entry point.

Definition at line 1353 of file efi_snp.c.

1353  {
1354  PXE_CDB *cdb = ( ( void * ) ( intptr_t ) cdb_phys );
1355  PXE_CPB_ANY *cpb = ( ( void * ) ( intptr_t ) cdb->CPBaddr );
1356  PXE_DB_ANY *db = ( ( void * ) ( intptr_t ) cdb->DBaddr );
1357  struct efi_snp_device *snpdev;
1358  EFI_STATUS efirc;
1359 
1360  /* Identify device */
1361  snpdev = efi_undi_snpdev ( cdb->IFnum );
1362  if ( ! snpdev ) {
1363  DBGC ( cdb, "UNDI invalid interface number %d\n", cdb->IFnum );
1366  return;
1367  }
1368 
1369  /* Fail if net device is currently claimed for use by iPXE */
1370  if ( efi_snp_claimed ) {
1371  cdb->StatCode = PXE_STATCODE_BUSY;
1373  return;
1374  }
1375 
1376  /* Handle opcode */
1379  switch ( cdb->OpCode ) {
1380 
1381  case PXE_OPCODE_GET_STATE:
1382  efirc = efi_undi_get_state ( snpdev, cdb );
1383  break;
1384 
1385  case PXE_OPCODE_START:
1386  efirc = efi_undi_start ( snpdev );
1387  break;
1388 
1389  case PXE_OPCODE_STOP:
1390  efirc = efi_undi_stop ( snpdev );
1391  break;
1392 
1394  efirc = efi_undi_get_init_info ( snpdev, cdb,
1395  &db->get_init_info );
1396  break;
1397 
1398  case PXE_OPCODE_INITIALIZE:
1399  efirc = efi_undi_initialize ( snpdev, cdb );
1400  break;
1401 
1402  case PXE_OPCODE_RESET:
1403  efirc = efi_undi_reset ( snpdev );
1404  break;
1405 
1406  case PXE_OPCODE_SHUTDOWN:
1407  efirc = efi_undi_shutdown ( snpdev );
1408  break;
1409 
1411  efirc = efi_undi_receive_filters ( snpdev, cdb );
1412  break;
1413 
1415  efirc = efi_undi_station_address ( snpdev, cdb,
1416  &cpb->station_address,
1417  &db->station_address );
1418  break;
1419 
1420  case PXE_OPCODE_GET_STATUS:
1421  efirc = efi_undi_get_status ( snpdev, cdb, &db->get_status );
1422  break;
1423 
1425  efirc = efi_undi_fill_header ( snpdev, cdb, cpb );
1426  break;
1427 
1428  case PXE_OPCODE_TRANSMIT:
1429  efirc = efi_undi_transmit ( snpdev, &cpb->transmit );
1430  break;
1431 
1432  case PXE_OPCODE_RECEIVE:
1433  efirc = efi_undi_receive ( snpdev, &cpb->receive,
1434  &db->receive );
1435  break;
1436 
1437  default:
1438  DBGC ( snpdev, "UNDI %p unsupported opcode %#04x\n",
1439  snpdev, cdb->OpCode );
1440  efirc = EFI_UNSUPPORTED;
1441  break;
1442  }
1443 
1444  /* Convert EFI status code to UNDI status code */
1445  if ( efirc != 0 ) {
1448  cdb->StatCode = efi_undi_statcode ( efirc );
1449  }
1450 }
static EFI_STATUS efi_undi_shutdown(struct efi_snp_device *snpdev)
Shutdown.
Definition: efi_snp.c:1115
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
static PXE_STATCODE efi_undi_statcode(EFI_STATUS efirc)
Convert EFI status code to UNDI status code.
Definition: efi_snp.c:964
static EFI_STATUS efi_undi_get_state(struct efi_snp_device *snpdev, PXE_CDB *cdb)
Get state.
Definition: efi_snp.c:984
#define PXE_OPCODE_SHUTDOWN
Change the UNDI operational state from Initialized to Started.
Definition: UefiPxe.h:129
PXE_STATCODE StatCode
Definition: UefiPxe.h:889
static EFI_STATUS efi_undi_receive_filters(struct efi_snp_device *snpdev, PXE_CDB *cdb)
Get/set receive filters.
Definition: efi_snp.c:1134
static EFI_STATUS efi_undi_transmit(struct efi_snp_device *snpdev, PXE_CPB_TRANSMIT *cpb)
Transmit.
Definition: efi_snp.c:1298
#define DBGC(...)
Definition: compiler.h:505
#define PXE_STATFLAGS_COMMAND_FAILED
Definition: UefiPxe.h:424
#define PXE_OPCODE_INITIALIZE
Changed UNDI operational state from Started to Initialized.
Definition: UefiPxe.h:119
static EFI_STATUS efi_undi_get_init_info(struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_DB_GET_INIT_INFO *db)
Get initialisation information.
Definition: efi_snp.c:1046
#define PXE_STATCODE_BUSY
Definition: UefiPxe.h:615
unsigned long intptr_t
Definition: stdint.h:21
#define PXE_OPCODE_FILL_HEADER
Fill media header in packet for transmit.
Definition: UefiPxe.h:169
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
PXE_CPB_RECEIVE receive
Definition: efi_snp.c:900
static EFI_STATUS efi_undi_stop(struct efi_snp_device *snpdev)
Stop.
Definition: efi_snp.c:1026
#define PXE_OPCODE_STATION_ADDRESS
Read & change station MAC address.
Definition: UefiPxe.h:144
static EFI_STATUS efi_undi_station_address(struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_CPB_STATION_ADDRESS *cpb, PXE_DB_STATION_ADDRESS *db)
Get/set station address.
Definition: efi_snp.c:1156
static EFI_STATUS efi_undi_reset(struct efi_snp_device *snpdev)
Reset.
Definition: efi_snp.c:1097
#define PXE_OPCODE_RESET
Re-initialize the NIC H/W.
Definition: UefiPxe.h:124
#define PXE_OPCODE_TRANSMIT
Transmit packet(s).
Definition: UefiPxe.h:174
#define PXE_STATFLAGS_STATUS_MASK
Common StatFlags that can be returned by all commands.
Definition: UefiPxe.h:422
PXE_CPB_STATION_ADDRESS station_address
Definition: efi_snp.c:896
PXE_UINT64 CPBaddr
Definition: UefiPxe.h:887
static EFI_STATUS efi_undi_receive(struct efi_snp_device *snpdev, PXE_CPB_RECEIVE *cpb, PXE_DB_RECEIVE *db)
Receive.
Definition: efi_snp.c:1320
static struct efi_snp_device * efi_undi_snpdev(unsigned int ifnum)
Identify UNDI SNP device.
Definition: efi_snp.c:948
Union type for data blocks.
Definition: efi_snp.c:904
An SNP device.
Definition: efi_snp.h:27
PXE_CPB_TRANSMIT transmit
Definition: efi_snp.c:899
#define PXE_OPCODE_STOP
Change UNDI operational state from Started to Stopped.
Definition: UefiPxe.h:104
#define PXE_OPCODE_GET_STATUS
Get & clear interrupt status.
Definition: UefiPxe.h:164
static struct dmfe_private * db
Definition: dmfe.c:177
static EFI_STATUS efi_undi_fill_header(struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_CPB_ANY *cpb)
Fill header.
Definition: efi_snp.c:1252
static EFI_STATUS efi_undi_get_status(struct efi_snp_device *snpdev, PXE_CDB *cdb, PXE_DB_GET_STATUS *db)
Get interrupt status.
Definition: efi_snp.c:1198
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
PXE_STATFLAGS StatFlags
Definition: UefiPxe.h:890
#define PXE_OPCODE_RECEIVE
Receive packet.
Definition: UefiPxe.h:179
#define PXE_OPCODE_RECEIVE_FILTERS
Read & change state of packet receive filters.
Definition: UefiPxe.h:139
#define PXE_STATCODE_INVALID_CDB
Definition: UefiPxe.h:613
#define PXE_OPCODE_GET_STATE
Return UNDI operational state.
Definition: UefiPxe.h:94
#define PXE_OPCODE_GET_INIT_INFO
Get UNDI initialization information.
Definition: UefiPxe.h:109
static EFI_STATUS efi_undi_initialize(struct efi_snp_device *snpdev, PXE_CDB *cdb)
Initialise.
Definition: efi_snp.c:1073
PXE_UINT16 IFnum
Definition: UefiPxe.h:891
#define PXE_OPCODE_START
Change UNDI operational state from Stopped to Started.
Definition: UefiPxe.h:99
PXE_OPCODE OpCode
Definition: UefiPxe.h:883
#define PXE_STATFLAGS_COMMAND_COMPLETE
Definition: UefiPxe.h:423
Union type for command parameter blocks.
Definition: efi_snp.c:895
PXE_UINT64 DBaddr
Definition: UefiPxe.h:888
#define PXE_STATCODE_SUCCESS
Common StatCodes returned by all UNDI commands, UNDI protocol functions and BC protocol functions.
Definition: UefiPxe.h:611
static EFI_STATUS efi_undi_start(struct efi_snp_device *snpdev)
Start.
Definition: efi_snp.c:1008

References s_pxe_cdb::CPBaddr, db, s_pxe_cdb::DBaddr, DBGC, efi_snp_claimed, efi_undi_fill_header(), efi_undi_get_init_info(), efi_undi_get_state(), efi_undi_get_status(), efi_undi_initialize(), efi_undi_receive(), efi_undi_receive_filters(), efi_undi_reset(), efi_undi_shutdown(), efi_undi_snpdev(), efi_undi_start(), efi_undi_statcode(), efi_undi_station_address(), efi_undi_stop(), efi_undi_transmit(), EFI_UNSUPPORTED, s_pxe_cdb::IFnum, s_pxe_cdb::OpCode, PXE_OPCODE_FILL_HEADER, PXE_OPCODE_GET_INIT_INFO, PXE_OPCODE_GET_STATE, PXE_OPCODE_GET_STATUS, PXE_OPCODE_INITIALIZE, PXE_OPCODE_RECEIVE, PXE_OPCODE_RECEIVE_FILTERS, PXE_OPCODE_RESET, PXE_OPCODE_SHUTDOWN, PXE_OPCODE_START, PXE_OPCODE_STATION_ADDRESS, PXE_OPCODE_STOP, PXE_OPCODE_TRANSMIT, PXE_STATCODE_BUSY, PXE_STATCODE_INVALID_CDB, PXE_STATCODE_SUCCESS, PXE_STATFLAGS_COMMAND_COMPLETE, PXE_STATFLAGS_COMMAND_FAILED, PXE_STATFLAGS_STATUS_MASK, PXE_CPB_ANY::receive, s_pxe_cdb::StatCode, s_pxe_cdb::StatFlags, PXE_CPB_ANY::station_address, and PXE_CPB_ANY::transmit.

Referenced by efi_snp_probe().

◆ efi_snp_get_driver_name()

static EFI_STATUS EFIAPI efi_snp_get_driver_name ( EFI_COMPONENT_NAME2_PROTOCOL name2,
CHAR8 *language  __unused,
CHAR16 **  driver_name 
)
static

Look up driver name.

Parameters
name2Component name protocol
languageLanguage to use
driver_nameDriver name to fill in
Return values
efircEFI status code

Definition at line 1505 of file efi_snp.c.

1506  {
1507  struct efi_snp_device *snpdev =
1508  container_of ( name2, struct efi_snp_device, name2 );
1509 
1510  *driver_name = snpdev->driver_name;
1511  return 0;
1512 }
EFI_COMPONENT_NAME2_PROTOCOL name2
Component name protocol.
Definition: efi_snp.h:55
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An SNP device.
Definition: efi_snp.h:27
wchar_t driver_name[16]
Driver name.
Definition: efi_snp.h:71

References container_of, efi_snp_device::driver_name, and efi_snp_device::name2.

Referenced by efi_snp_probe().

◆ efi_snp_get_controller_name()

static EFI_STATUS EFIAPI efi_snp_get_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL name2,
EFI_HANDLE device  __unused,
EFI_HANDLE child  __unused,
CHAR8 *language  __unused,
CHAR16 **  controller_name 
)
static

Look up controller name.

Parameters
name2Component name protocol
deviceDevice
childChild device, or NULL
languageLanguage to use
driver_nameDevice name to fill in
Return values
efircEFI status code

Definition at line 1525 of file efi_snp.c.

1529  {
1530  struct efi_snp_device *snpdev =
1531  container_of ( name2, struct efi_snp_device, name2 );
1532 
1533  *controller_name = snpdev->controller_name;
1534  return 0;
1535 }
EFI_COMPONENT_NAME2_PROTOCOL name2
Component name protocol.
Definition: efi_snp.h:55
wchar_t controller_name[64]
Controller name.
Definition: efi_snp.h:73
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An SNP device.
Definition: efi_snp.h:27

References container_of, efi_snp_device::controller_name, and efi_snp_device::name2.

Referenced by efi_snp_probe().

◆ efi_snp_load_file()

static EFI_STATUS EFIAPI efi_snp_load_file ( EFI_LOAD_FILE_PROTOCOL load_file,
EFI_DEVICE_PATH_PROTOCOL *path  __unused,
BOOLEAN  booting,
UINTN *len  __unused,
VOID *data  __unused 
)
static

Load file.

Parameters
loadfileLoad file protocol
pathFile path
bootingLoading as part of a boot attempt
Return values
efircEFI status code

Definition at line 1553 of file efi_snp.c.

1556  {
1557  struct efi_snp_device *snpdev =
1559  struct net_device *netdev = snpdev->netdev;
1560  int rc;
1561 
1562  /* Fail unless this is a boot attempt */
1563  if ( ! booting ) {
1564  DBGC ( snpdev, "SNPDEV %p cannot load non-boot file\n",
1565  snpdev );
1566  return EFI_UNSUPPORTED;
1567  }
1568 
1569  /* Claim network devices for use by iPXE */
1570  efi_snp_claim();
1571 
1572  /* Start watchdog holdoff timer */
1574 
1575  /* Boot from network device */
1576  if ( ( rc = ipxe ( netdev ) ) != 0 )
1577  goto err_ipxe;
1578 
1579  /* Reset console */
1580  console_reset();
1581 
1582  err_ipxe:
1584  efi_snp_release();
1585  return EFIRC ( rc );
1586 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
Definition: efi_snp.h:88
int ipxe(struct net_device *netdev)
Main iPXE flow of execution.
Definition: autoboot.c:567
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void efi_watchdog_start(void)
Start EFI watchdog holdoff timer.
Definition: efi_watchdog.h:17
static struct net_device * netdev
Definition: gdbudp.c:52
static void efi_watchdog_stop(void)
Stop EFI watchdog holdoff timer.
Definition: efi_watchdog.h:26
A network device.
Definition: netdevice.h:348
An SNP device.
Definition: efi_snp.h:27
static void efi_snp_release(void)
Release network devices for use via SNP.
Definition: efi_snp.h:96
static void console_reset(void)
Reset console.
Definition: console.h:214
EFI_LOAD_FILE_PROTOCOL load_file
Load file protocol handle.
Definition: efi_snp.h:57
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149

References console_reset(), container_of, DBGC, efi_snp_claim(), efi_snp_release(), EFI_UNSUPPORTED, efi_watchdog_start(), efi_watchdog_stop(), EFIRC, ipxe(), efi_snp_device::load_file, efi_snp_device::netdev, netdev, and rc.

◆ efi_snp_demux()

static struct efi_snp_device* efi_snp_demux ( struct net_device netdev)
static

Locate SNP device corresponding to network device.

Parameters
netdevNetwork device
Return values
snpSNP device, or NULL if not found

Definition at line 1606 of file efi_snp.c.

1606  {
1607  struct efi_snp_device *snpdev;
1608 
1609  list_for_each_entry ( snpdev, &efi_snp_devices, list ) {
1610  if ( snpdev->netdev == netdev )
1611  return snpdev;
1612  }
1613  return NULL;
1614 }
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
static struct net_device * netdev
Definition: gdbudp.c:52
An SNP device.
Definition: efi_snp.h:27
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29

References efi_snp_device::list, list_for_each_entry, efi_snp_device::netdev, netdev, and NULL.

Referenced by efi_snp_notify(), efi_snp_remove(), and last_opened_snpdev().

◆ efi_snp_probe()

static int efi_snp_probe ( struct net_device netdev)
static

Create SNP device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 1622 of file efi_snp.c.

1622  {
1624  struct efi_device *efidev;
1625  struct efi_snp_device *snpdev;
1626  EFI_DEVICE_PATH_PROTOCOL *path_end;
1627  MAC_ADDR_DEVICE_PATH *macpath;
1628  VLAN_DEVICE_PATH *vlanpath;
1629  size_t path_prefix_len = 0;
1630  unsigned int ifcnt;
1631  unsigned int tag;
1632  void *interface;
1633  EFI_STATUS efirc;
1634  int rc;
1635 
1636  /* Find parent EFI device */
1637  efidev = efidev_parent ( netdev->dev );
1638  if ( ! efidev ) {
1639  DBG ( "SNP skipping non-EFI device %s\n", netdev->name );
1640  rc = 0;
1641  goto err_no_efidev;
1642  }
1643 
1644  /* Allocate the SNP device */
1645  snpdev = zalloc ( sizeof ( *snpdev ) );
1646  if ( ! snpdev ) {
1647  rc = -ENOMEM;
1648  goto err_alloc_snp;
1649  }
1650  snpdev->netdev = netdev_get ( netdev );
1651  snpdev->efidev = efidev;
1652  INIT_LIST_HEAD ( &snpdev->rx );
1653 
1654  /* Sanity check */
1655  if ( netdev->ll_protocol->ll_addr_len > sizeof ( EFI_MAC_ADDRESS ) ) {
1656  DBGC ( snpdev, "SNPDEV %p cannot support link-layer address "
1657  "length %d for %s\n", snpdev,
1659  rc = -ENOTSUP;
1660  goto err_ll_addr_len;
1661  }
1662 
1663  /* Populate the SNP structure */
1664  memcpy ( &snpdev->snp, &efi_snp_device_snp, sizeof ( snpdev->snp ) );
1665  snpdev->snp.Mode = &snpdev->mode;
1666  if ( ( efirc = bs->CreateEvent ( EVT_NOTIFY_WAIT, TPL_NOTIFY,
1667  efi_snp_wait_for_packet, snpdev,
1668  &snpdev->snp.WaitForPacket ) ) != 0 ){
1669  rc = -EEFI ( efirc );
1670  DBGC ( snpdev, "SNPDEV %p could not create event: %s\n",
1671  snpdev, strerror ( rc ) );
1672  goto err_create_event;
1673  }
1674 
1675  /* Populate the SNP mode structure */
1677  efi_snp_set_mode ( snpdev );
1678 
1679  /* Populate the NII structure */
1680  memcpy ( &snpdev->nii, &efi_snp_device_nii, sizeof ( snpdev->nii ) );
1681  snpdev->nii.Id = ( ( intptr_t ) &efi_snp_undi );
1682  snpdev->nii.IfNum = efi_undi_ifnum ( snpdev );
1684  ifcnt = ( ( efi_snp_undi.IFcntExt << 8 ) | efi_snp_undi.IFcnt );
1685  if ( ifcnt < snpdev->nii.IfNum )
1686  ifcnt = snpdev->nii.IfNum;
1687  efi_snp_undi.IFcnt = ( ifcnt & 0xff );
1688  efi_snp_undi.IFcntExt = ( ifcnt >> 8 );
1690  sizeof ( efi_snp_undi ) );
1691 
1692  /* Populate the component name structure */
1693  efi_snprintf ( snpdev->driver_name,
1694  ( sizeof ( snpdev->driver_name ) /
1695  sizeof ( snpdev->driver_name[0] ) ),
1696  "%s %s", product_short_name, netdev->dev->driver_name );
1697  efi_snprintf ( snpdev->controller_name,
1698  ( sizeof ( snpdev->controller_name ) /
1699  sizeof ( snpdev->controller_name[0] ) ),
1700  "%s %s (%s, %s)", product_short_name,
1702  netdev_addr ( netdev ) );
1705  snpdev->name2.SupportedLanguages = "en";
1706 
1707  /* Populate the load file protocol structure */
1709  sizeof ( snpdev->load_file ) );
1710 
1711  /* Populate the device name */
1712  efi_snprintf ( snpdev->name, ( sizeof ( snpdev->name ) /
1713  sizeof ( snpdev->name[0] ) ),
1714  "%s", netdev->name );
1715 
1716  /* Allocate the new device path */
1717  path_prefix_len = efi_devpath_len ( efidev->path );
1718  snpdev->path = zalloc ( path_prefix_len + sizeof ( *macpath ) +
1719  sizeof ( *vlanpath ) + sizeof ( *path_end ) );
1720  if ( ! snpdev->path ) {
1721  rc = -ENOMEM;
1722  goto err_alloc_device_path;
1723  }
1724 
1725  /* Populate the device path */
1726  memcpy ( snpdev->path, efidev->path, path_prefix_len );
1727  macpath = ( ( ( void * ) snpdev->path ) + path_prefix_len );
1728  memset ( macpath, 0, sizeof ( *macpath ) );
1729  macpath->Header.Type = MESSAGING_DEVICE_PATH;
1730  macpath->Header.SubType = MSG_MAC_ADDR_DP;
1731  macpath->Header.Length[0] = sizeof ( *macpath );
1732  memcpy ( &macpath->MacAddress, netdev->ll_addr,
1734  macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
1735  if ( ( tag = vlan_tag ( netdev ) ) ) {
1736  vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
1737  memset ( vlanpath, 0, sizeof ( *vlanpath ) );
1738  vlanpath->Header.Type = MESSAGING_DEVICE_PATH;
1739  vlanpath->Header.SubType = MSG_VLAN_DP;
1740  vlanpath->Header.Length[0] = sizeof ( *vlanpath );
1741  vlanpath->VlanId = tag;
1742  path_end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
1743  } else {
1744  path_end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
1745  }
1746  memset ( path_end, 0, sizeof ( *path_end ) );
1747  path_end->Type = END_DEVICE_PATH_TYPE;
1749  path_end->Length[0] = sizeof ( *path_end );
1750 
1751  /* Install the SNP */
1752  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
1753  &snpdev->handle,
1756  &efi_nii_protocol_guid, &snpdev->nii,
1757  &efi_nii31_protocol_guid, &snpdev->nii,
1760  NULL ) ) != 0 ) {
1761  rc = -EEFI ( efirc );
1762  DBGC ( snpdev, "SNPDEV %p could not install protocols: %s\n",
1763  snpdev, strerror ( rc ) );
1764  goto err_install_protocol_interface;
1765  }
1766 
1767  /* SnpDxe will repeatedly start up and shut down our NII/UNDI
1768  * interface (in order to obtain the MAC address) before
1769  * discovering that it cannot install another SNP on the same
1770  * handle. This causes the underlying network device to be
1771  * unexpectedly closed.
1772  *
1773  * Prevent this by opening our own NII (and NII31) protocol
1774  * instances to prevent SnpDxe from attempting to bind to
1775  * them.
1776  */
1777  if ( ( efirc = bs->OpenProtocol ( snpdev->handle,
1779  efi_image_handle, snpdev->handle,
1782  rc = -EEFI ( efirc );
1783  DBGC ( snpdev, "SNPDEV %p could not open NII protocol: %s\n",
1784  snpdev, strerror ( rc ) );
1785  goto err_open_nii;
1786  }
1787  if ( ( efirc = bs->OpenProtocol ( snpdev->handle,
1789  efi_image_handle, snpdev->handle,
1792  rc = -EEFI ( efirc );
1793  DBGC ( snpdev, "SNPDEV %p could not open NII31 protocol: %s\n",
1794  snpdev, strerror ( rc ) );
1795  goto err_open_nii31;
1796  }
1797 
1798  /* Add as child of EFI parent device */
1799  if ( ( rc = efi_child_add ( efidev->device, snpdev->handle ) ) != 0 ) {
1800  DBGC ( snpdev, "SNPDEV %p could not become child of %s: %s\n",
1801  snpdev, efi_handle_name ( efidev->device ),
1802  strerror ( rc ) );
1803  goto err_efi_child_add;
1804  }
1805 
1806  /* Install HII */
1807  if ( ( rc = efi_snp_hii_install ( snpdev ) ) != 0 ) {
1808  DBGC ( snpdev, "SNPDEV %p could not install HII: %s\n",
1809  snpdev, strerror ( rc ) );
1810  /* HII fails on several platforms. It's
1811  * non-essential, so treat this as a non-fatal
1812  * error.
1813  */
1814  }
1815 
1816  /* Add to list of SNP devices */
1817  list_add ( &snpdev->list, &efi_snp_devices );
1818 
1819  /* Close device path */
1822 
1823  DBGC ( snpdev, "SNPDEV %p installed for %s as device %s\n",
1824  snpdev, netdev->name, efi_handle_name ( snpdev->handle ) );
1825  return 0;
1826 
1827  list_del ( &snpdev->list );
1828  if ( snpdev->package_list )
1829  efi_snp_hii_uninstall ( snpdev );
1830  efi_child_del ( efidev->device, snpdev->handle );
1831  err_efi_child_add:
1833  efi_image_handle, snpdev->handle );
1834  err_open_nii31:
1835  bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid,
1836  efi_image_handle, snpdev->handle );
1837  err_open_nii:
1839  snpdev->handle,
1842  &efi_nii_protocol_guid, &snpdev->nii,
1843  &efi_nii31_protocol_guid, &snpdev->nii,
1846  NULL );
1847  err_install_protocol_interface:
1848  free ( snpdev->path );
1849  err_alloc_device_path:
1850  bs->CloseEvent ( snpdev->snp.WaitForPacket );
1851  err_create_event:
1852  err_ll_addr_len:
1853  netdev_put ( netdev );
1854  free ( snpdev );
1855  err_alloc_snp:
1856  err_no_efidev:
1857  return rc;
1858 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:212
const char product_short_name[]
Product short name string.
Definition: version.c:75
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii
The network interface identifier.
Definition: efi_snp.h:53
UINT8 IfType
Network interface type(i.e.
Definition: DevicePath.h:554
EFI_COMPONENT_NAME2_PROTOCOL name2
Component name protocol.
Definition: efi_snp.h:55
32-byte buffer containing a network Media Access Control address.
Definition: UefiBaseType.h:102
EFI_MAC_ADDRESS MacAddress
The MAC address for a network interface padded with 0s.
Definition: DevicePath.h:550
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:236
#define DBGC(...)
Definition: compiler.h:505
static PXE_SW_UNDI efi_snp_undi
UNDI interface.
Definition: efi_snp.c:1457
char name[40]
Name.
Definition: device.h:75
#define EFI_OPEN_PROTOCOL_BY_DRIVER
Definition: UefiSpec.h:1274
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1915
#define MSG_MAC_ADDR_DP
MAC Address Device Path SubType.
Definition: DevicePath.h:544
size_t efi_devpath_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_utils.c:59
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
Definition: UefiSpec.h:1275
EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName
EFI_CLOSE_EVENT CloseEvent
Definition: UefiSpec.h:1864
static unsigned int efi_undi_ifnum(struct efi_snp_device *snpdev)
Get UNDI SNP device interface number.
Definition: efi_snp.c:933
#define ntohs(value)
Definition: byteswap.h:136
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:546
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
UINT32 State
Reports the current state of the network interface.
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
int efi_child_add(EFI_HANDLE parent, EFI_HANDLE child)
Add EFI device as child of another EFI device.
Definition: efi_utils.c:124
unsigned long intptr_t
Definition: stdint.h:21
wchar_t controller_name[64]
Controller name.
Definition: efi_snp.h:73
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition: netdevice.h:521
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:35
#define TPL_NOTIFY
Definition: UefiSpec.h:592
static EFI_SIMPLE_NETWORK_PROTOCOL efi_snp_device_snp
SNP interface.
Definition: efi_snp.c:870
void efi_snp_hii_uninstall(struct efi_snp_device *snpdev)
Uninstall HII protocol and package for SNP device.
Definition: efi_snp_hii.c:779
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
UINT64 Id
The address of the first byte of the identifying structure for this network interface.
static EFI_STATUS EFIAPI efi_snp_get_driver_name(EFI_COMPONENT_NAME2_PROTOCOL *name2, CHAR8 *language __unused, CHAR16 **driver_name)
Look up driver name.
Definition: efi_snp.c:1505
EFI_SIMPLE_NETWORK_MODE * Mode
Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
void efi_child_del(EFI_HANDLE parent, EFI_HANDLE child)
Remove EFI device as child of another EFI device.
Definition: efi_utils.c:158
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int efi_snp_hii_install(struct efi_snp_device *snpdev)
Install HII protocol and packages for SNP device.
Definition: efi_snp_hii.c:655
EFI_HII_PACKAGE_LIST_HEADER * package_list
HII package list.
Definition: efi_snp.h:61
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
An object interface.
Definition: interface.h:109
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
static struct net_device * netdev
Definition: gdbudp.c:52
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:104
EFI_CREATE_EVENT CreateEvent
Definition: UefiSpec.h:1860
UINT16 VlanId
VLAN identifier (0-4094).
Definition: DevicePath.h:916
static EFI_LOAD_FILE_PROTOCOL efi_snp_load_file_protocol
Load file protocol.
Definition: efi_snp.c:1589
const char * driver_name
Driver name.
Definition: device.h:77
wchar_t name[sizeof(((struct net_device *) NULL) ->name)]
Device name.
Definition: efi_snp.h:69
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
static EFIAPI VOID efi_undi_issue(UINT64 cdb_phys)
UNDI entry point.
Definition: efi_snp.c:1353
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
static void efi_snp_set_mode(struct efi_snp_device *snpdev)
Set EFI SNP mode based on iPXE net device parameters.
Definition: efi_snp.c:118
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
An SNP device.
Definition: efi_snp.h:27
PXE_UINT8 Fudge
makes 8-bit cksum zero.
Definition: UefiPxe.h:819
struct efi_device * efidev
The underlying EFI device.
Definition: efi_snp.h:33
#define EVT_NOTIFY_WAIT
Definition: UefiSpec.h:393
An EFI device.
Definition: efi_driver.h:17
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition: netdevice.h:544
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:124
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
static uint8_t efi_undi_checksum(void *data, size_t len)
Calculate UNDI byte checksum.
Definition: efi_snp.c:918
struct list_head rx
Receive queue.
Definition: efi_snp.h:51
static EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL efi_snp_device_nii
Network Identification Interface (NII)
Definition: efi_snp.c:1480
wchar_t driver_name[16]
Driver name.
Definition: efi_snp.h:71
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
EFI_GUID efi_nii_protocol_guid
Network interface identifier protocol GUID (old version)
Definition: efi_guid.c:208
#define MSG_VLAN_DP
VLAN Device Path SubType.
Definition: DevicePath.h:910
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
__weak unsigned int vlan_tag(struct net_device *netdev __unused)
Get the VLAN tag (when VLAN support is not present)
Definition: netdevice.c:1124
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:912
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
CHAR8 * SupportedLanguages
A Null-terminated ASCII string array that contains one or more supported language codes.
PXE_UINT8 IFcntExt
physical connector count upper byte.
Definition: UefiPxe.h:824
EFI_LOAD_FILE_PROTOCOL load_file
Load file protocol handle.
Definition: efi_snp.h:57
PXE_UINT64 EntryPoint
API entry point.
Definition: UefiPxe.h:827
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Definition: DevicePath.h:59
PXE_UINT8 IFcnt
physical connector count lower byte.
Definition: UefiPxe.h:821
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:74
UINT16 IfNum
The network interface number that is being identified by this Network Interface Identifier Protocol.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
EFI_GUID efi_load_file_protocol_guid
Load file protocol GUID.
Definition: efi_guid.c:176
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
Definition: efi_snp.h:75
uint64_t tag
Identity tag.
Definition: edd.h:30
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
static VOID EFIAPI efi_snp_wait_for_packet(EFI_EVENT event __unused, VOID *context)
Poll event.
Definition: efi_snp.c:843
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
EFI_EVENT WaitForPacket
Event used with WaitForEvent() to wait for a packet to be received.
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
static EFI_STATUS EFIAPI efi_snp_get_controller_name(EFI_COMPONENT_NAME2_PROTOCOL *name2, EFI_HANDLE device __unused, EFI_HANDLE child __unused, CHAR8 *language __unused, CHAR16 **controller_name)
Look up controller name.
Definition: efi_snp.c:1525
void * memset(void *dest, int character, size_t len) __nonnull

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, EFI_BOOT_SERVICES::CloseProtocol, efi_snp_device::controller_name, EFI_BOOT_SERVICES::CreateEvent, DBG, DBGC, net_device::dev, efi_device::device, efi_snp_device::driver_name, device::driver_name, EEFI, efi_child_add(), efi_child_del(), efi_component_name2_protocol_guid, efi_device_path_protocol_guid, efi_devpath_len(), efi_handle_name(), efi_image_handle, efi_load_file_protocol_guid, efi_nii31_protocol_guid, efi_nii_protocol_guid, EFI_OPEN_PROTOCOL_BY_DRIVER, EFI_OPEN_PROTOCOL_EXCLUSIVE, efi_simple_network_protocol_guid, efi_snp_device_nii, efi_snp_device_snp, efi_snp_get_controller_name(), efi_snp_get_driver_name(), efi_snp_hii_install(), efi_snp_hii_uninstall(), efi_snp_load_file_protocol, efi_snp_set_mode(), efi_snp_undi, efi_snp_wait_for_packet(), efi_snprintf(), efi_systab, efi_undi_checksum(), efi_undi_ifnum(), efi_undi_issue(), efi_snp_device::efidev, efidev_parent(), EfiSimpleNetworkStopped, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, ENOMEM, ENOTSUP, s_pxe_sw_undi::EntryPoint, EVT_NOTIFY_WAIT, free, s_pxe_sw_undi::Fudge, _EFI_COMPONENT_NAME2_PROTOCOL::GetControllerName, _EFI_COMPONENT_NAME2_PROTOCOL::GetDriverName, efi_snp_device::handle, MAC_ADDR_DEVICE_PATH::Header, VLAN_DEVICE_PATH::Header, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::Id, s_pxe_sw_undi::IFcnt, s_pxe_sw_undi::IFcntExt, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::IfNum, MAC_ADDR_DEVICE_PATH::IfType, INIT_LIST_HEAD, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, EFI_DEVICE_PATH_PROTOCOL::Length, efi_snp_device::list, list_add, list_del, net_device::ll_addr, ll_protocol::ll_addr_len, ll_protocol::ll_proto, net_device::ll_protocol, efi_snp_device::load_file, MAC_ADDR_DEVICE_PATH::MacAddress, memcpy(), memset(), MESSAGING_DEVICE_PATH, efi_snp_device::mode, _EFI_SIMPLE_NETWORK_PROTOCOL::Mode, MSG_MAC_ADDR_DP, MSG_VLAN_DP, efi_snp_device::name, device::name, net_device::name, efi_snp_device::name2, efi_snp_device::netdev, netdev, netdev_addr(), netdev_get(), netdev_put(), efi_snp_device::nii, ntohs, NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_snp_device::package_list, efi_device::path, efi_snp_device::path, product_short_name, rc, efi_snp_device::rx, efi_snp_device::snp, EFI_SIMPLE_NETWORK_MODE::State, strerror(), EFI_DEVICE_PATH_PROTOCOL::SubType, _EFI_COMPONENT_NAME2_PROTOCOL::SupportedLanguages, tag, TPL_NOTIFY, EFI_DEVICE_PATH_PROTOCOL::Type, EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, vlan_tag(), VLAN_DEVICE_PATH::VlanId, _EFI_SIMPLE_NETWORK_PROTOCOL::WaitForPacket, and zalloc().

◆ efi_snp_notify()

static void efi_snp_notify ( struct net_device netdev)
static

Handle SNP device or link state change.

Parameters
netdevNetwork device

Definition at line 1865 of file efi_snp.c.

1865  {
1866  struct efi_snp_device *snpdev;
1867 
1868  /* Locate SNP device */
1869  snpdev = efi_snp_demux ( netdev );
1870  if ( ! snpdev ) {
1871  DBG ( "SNP skipping non-SNP device %s\n", netdev->name );
1872  return;
1873  }
1874 
1875  /* Update link state */
1876  snpdev->mode.MediaPresent =
1877  ( netdev_link_ok ( netdev ) ? TRUE : FALSE );
1878  DBGC ( snpdev, "SNPDEV %p link is %s\n", snpdev,
1879  ( snpdev->mode.MediaPresent ? "up" : "down" ) );
1880 
1881  /* Update mode state */
1882  efi_snp_set_state ( snpdev );
1883 }
BOOLEAN MediaPresent
TRUE if media are connected to the network interface; otherwise FALSE.
#define DBGC(...)
Definition: compiler.h:505
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
An SNP device.
Definition: efi_snp.h:27
#define TRUE
Definition: tlan.h:46
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
#define FALSE
Definition: tlan.h:45
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
EFI_SIMPLE_NETWORK_MODE mode
The SNP "mode" (parameters)
Definition: efi_snp.h:39
static struct efi_snp_device * efi_snp_demux(struct net_device *netdev)
Locate SNP device corresponding to network device.
Definition: efi_snp.c:1606

References DBG, DBGC, efi_snp_demux(), efi_snp_set_state(), FALSE, EFI_SIMPLE_NETWORK_MODE::MediaPresent, efi_snp_device::mode, net_device::name, netdev, netdev_link_ok(), and TRUE.

◆ efi_snp_remove()

static void efi_snp_remove ( struct net_device netdev)
static

Destroy SNP device.

Parameters
netdevNetwork device

Definition at line 1890 of file efi_snp.c.

1890  {
1892  struct efi_snp_device *snpdev;
1893 
1894  /* Locate SNP device */
1895  snpdev = efi_snp_demux ( netdev );
1896  if ( ! snpdev ) {
1897  DBG ( "SNP skipping non-SNP device %s\n", netdev->name );
1898  return;
1899  }
1900 
1901  /* Uninstall the SNP */
1902  list_del ( &snpdev->list );
1903  if ( snpdev->package_list )
1904  efi_snp_hii_uninstall ( snpdev );
1905  efi_child_del ( snpdev->efidev->device, snpdev->handle );
1906  bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid,
1907  efi_image_handle, snpdev->handle );
1909  efi_image_handle, snpdev->handle );
1911  snpdev->handle,
1914  &efi_nii_protocol_guid, &snpdev->nii,
1915  &efi_nii31_protocol_guid, &snpdev->nii,
1918  NULL );
1919  free ( snpdev->path );
1920  bs->CloseEvent ( snpdev->snp.WaitForPacket );
1921  netdev_put ( snpdev->netdev );
1922  free ( snpdev );
1923 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:212
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii
The network interface identifier.
Definition: efi_snp.h:53
EFI_COMPONENT_NAME2_PROTOCOL name2
Component name protocol.
Definition: efi_snp.h:55
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:236
EFI_CLOSE_EVENT CloseEvent
Definition: UefiSpec.h:1864
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:35
void efi_snp_hii_uninstall(struct efi_snp_device *snpdev)
Uninstall HII protocol and package for SNP device.
Definition: efi_snp_hii.c:779
struct net_device * netdev
The underlying iPXE network device.
Definition: efi_snp.h:31
void efi_child_del(EFI_HANDLE parent, EFI_HANDLE child)
Remove EFI device as child of another EFI device.
Definition: efi_utils.c:158
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
EFI_HII_PACKAGE_LIST_HEADER * package_list
HII package list.
Definition: efi_snp.h:61
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
static struct net_device * netdev
Definition: gdbudp.c:52
EFI_SIMPLE_NETWORK_PROTOCOL snp
The SNP structure itself.
Definition: efi_snp.h:37
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
An SNP device.
Definition: efi_snp.h:27
struct efi_device * efidev
The underlying EFI device.
Definition: efi_snp.h:33
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:124
EFI_GUID efi_nii_protocol_guid
Network interface identifier protocol GUID (old version)
Definition: efi_guid.c:208
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
EFI_LOAD_FILE_PROTOCOL load_file
Load file protocol handle.
Definition: efi_snp.h:57
EFI_SYSTEM_TABLE * efi_systab
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
EFI_GUID efi_load_file_protocol_guid
Load file protocol GUID.
Definition: efi_guid.c:176
EFI_DEVICE_PATH_PROTOCOL * path
The device path.
Definition: efi_snp.h:75
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static struct efi_snp_device * efi_snp_demux(struct net_device *netdev)
Locate SNP device corresponding to network device.
Definition: efi_snp.c:1606
EFI_EVENT WaitForPacket
Event used with WaitForEvent() to wait for a packet to be received.
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, EFI_BOOT_SERVICES::CloseProtocol, DBG, efi_device::device, efi_child_del(), efi_component_name2_protocol_guid, efi_device_path_protocol_guid, efi_image_handle, efi_load_file_protocol_guid, efi_nii31_protocol_guid, efi_nii_protocol_guid, efi_simple_network_protocol_guid, efi_snp_demux(), efi_snp_hii_uninstall(), efi_systab, efi_snp_device::efidev, free, efi_snp_device::handle, efi_snp_device::list, list_del, efi_snp_device::load_file, net_device::name, efi_snp_device::name2, efi_snp_device::netdev, netdev, netdev_put(), efi_snp_device::nii, NULL, efi_snp_device::package_list, efi_snp_device::path, efi_snp_device::snp, EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, and _EFI_SIMPLE_NETWORK_PROTOCOL::WaitForPacket.

◆ find_snpdev()

struct efi_snp_device* find_snpdev ( EFI_HANDLE  handle)

Find SNP device by EFI device handle.

Parameters
handleEFI device handle
Return values
snpdevSNP device, or NULL

Definition at line 1939 of file efi_snp.c.

1939  {
1940  struct efi_snp_device *snpdev;
1941 
1942  list_for_each_entry ( snpdev, &efi_snp_devices, list ) {
1943  if ( snpdev->handle == handle )
1944  return snpdev;
1945  }
1946  return NULL;
1947 }
EFI_HANDLE handle
EFI device handle.
Definition: efi_snp.h:35
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
An SNP device.
Definition: efi_snp.h:27
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29

References handle, efi_snp_device::handle, efi_snp_device::list, list_for_each_entry, and NULL.

Referenced by nii_supported(), and snp_supported().

◆ last_opened_snpdev()

struct efi_snp_device* last_opened_snpdev ( void  )

Get most recently opened SNP device.

Return values
snpdevMost recently opened SNP device, or NULL

Definition at line 1954 of file efi_snp.c.

1954  {
1955  struct net_device *netdev;
1956 
1958  if ( ! netdev )
1959  return NULL;
1960 
1961  return efi_snp_demux ( netdev );
1962 }
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
Definition: netdevice.c:973
A network device.
Definition: netdevice.h:348
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static struct efi_snp_device * efi_snp_demux(struct net_device *netdev)
Locate SNP device corresponding to network device.
Definition: efi_snp.c:1606

References efi_snp_demux(), last_opened_netdev(), netdev, and NULL.

Referenced by efi_block_hook(), and efi_image_exec().

◆ efi_snp_add_claim()

void efi_snp_add_claim ( int  delta)

Add to SNP claimed/released count.

Parameters
deltaClaim count change

Definition at line 1969 of file efi_snp.c.

1969  {
1971  struct efi_snp_device *snpdev;
1972 
1973  /* Raise TPL if we are about to claim devices */
1974  if ( ! efi_snp_claimed )
1976 
1977  /* Claim SNP devices */
1978  efi_snp_claimed += delta;
1979  assert ( efi_snp_claimed >= 0 );
1980 
1981  /* Update SNP mode state for each interface */
1982  list_for_each_entry ( snpdev, &efi_snp_devices, list )
1983  efi_snp_set_state ( snpdev );
1984 
1985  /* Restore TPL if we have released devices */
1986  if ( ! efi_snp_claimed )
1987  bs->RestoreTPL ( efi_snp_old_tpl );
1988 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
static void efi_snp_set_state(struct efi_snp_device *snpdev)
Set EFI SNP mode state.
Definition: efi_snp.c:89
static int efi_snp_claimed
Network devices are currently claimed for use by iPXE.
Definition: efi_snp.c:46
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
EFI Boot Services Table.
Definition: UefiSpec.h:1836
An SNP device.
Definition: efi_snp.h:27
#define TPL_CALLBACK
Definition: UefiSpec.h:591
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
static EFI_TPL efi_snp_old_tpl
TPL prior to network devices being claimed.
Definition: efi_snp.c:49
struct list_head list
List of SNP devices.
Definition: efi_snp.h:29

References assert(), EFI_SYSTEM_TABLE::BootServices, efi_snp_claimed, efi_snp_old_tpl, efi_snp_set_state(), efi_systab, efi_snp_device::list, list_for_each_entry, EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RestoreTPL, and TPL_CALLBACK.

Referenced by efi_snp_claim(), and efi_snp_release().

Variable Documentation

◆ efi_snp_claimed

int efi_snp_claimed
static

◆ efi_snp_old_tpl

EFI_TPL efi_snp_old_tpl
static

TPL prior to network devices being claimed.

Definition at line 49 of file efi_snp.c.

Referenced by efi_snp_add_claim().

◆ efi_snp_device_snp

EFI_SIMPLE_NETWORK_PROTOCOL efi_snp_device_snp
static
Initial value:
= {
.Start = efi_snp_start,
.Stop = efi_snp_stop,
.Initialize = efi_snp_initialize,
.Reset = efi_snp_reset,
.Shutdown = efi_snp_shutdown,
.ReceiveFilters = efi_snp_receive_filters,
.StationAddress = efi_snp_station_address,
.Statistics = efi_snp_statistics,
.MCastIpToMac = efi_snp_mcast_ip_to_mac,
.NvData = efi_snp_nvdata,
.GetStatus = efi_snp_get_status,
.Transmit = efi_snp_transmit,
.Receive = efi_snp_receive,
}
static EFI_STATUS EFIAPI efi_snp_initialize(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN extra_rx_bufsize, UINTN extra_tx_bufsize)
Open the network device.
Definition: efi_snp.c:234
static EFI_STATUS EFIAPI efi_snp_start(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Change SNP state from "stopped" to "started".
Definition: efi_snp.c:187
static EFI_STATUS EFIAPI efi_snp_station_address(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, EFI_MAC_ADDRESS *new)
Set station address.
Definition: efi_snp.c:394
static EFI_STATUS EFIAPI efi_snp_receive_filters(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 enable, UINT32 disable, BOOLEAN mcast_reset, UINTN mcast_count, EFI_MAC_ADDRESS *mcast)
Manage receive filters.
Definition: efi_snp.c:360
static EFI_STATUS EFIAPI efi_snp_nvdata(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN read, UINTN offset, UINTN len, VOID *data)
Read or write non-volatile storage.
Definition: efi_snp.c:518
static EFI_STATUS EFIAPI efi_snp_receive(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN *ll_header_len, UINTN *len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
Receive packet.
Definition: efi_snp.c:756
#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
static EFI_STATUS EFIAPI efi_snp_stop(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Change SNP state from "started" to "stopped".
Definition: efi_snp.c:209
static EFI_STATUS EFIAPI efi_snp_mcast_ip_to_mac(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ipv6, EFI_IP_ADDRESS *ip, EFI_MAC_ADDRESS *mac)
Convert multicast IP address to MAC address.
Definition: efi_snp.c:480
static EFI_STATUS EFIAPI efi_snp_transmit(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINTN ll_header_len, UINTN len, VOID *data, EFI_MAC_ADDRESS *ll_src, EFI_MAC_ADDRESS *ll_dest, UINT16 *net_proto)
Start packet transmission.
Definition: efi_snp.c:605
static EFI_STATUS EFIAPI efi_snp_statistics(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, UINTN *stats_len, EFI_NETWORK_STATISTICS *stats)
Get (or reset) statistics.
Definition: efi_snp.c:431
static EFI_STATUS EFIAPI efi_snp_shutdown(EFI_SIMPLE_NETWORK_PROTOCOL *snp)
Shut down the network device.
Definition: efi_snp.c:322
static EFI_STATUS EFIAPI efi_snp_get_status(EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 *interrupts, VOID **txbuf)
Read interrupt status and TX recycled buffer status.
Definition: efi_snp.c:545
static EFI_STATUS EFIAPI efi_snp_reset(EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ext_verify)
Reset the network device.
Definition: efi_snp.c:277

SNP interface.

Definition at line 870 of file efi_snp.c.

Referenced by efi_snp_probe().

◆ efi_snp_undi

PXE_SW_UNDI efi_snp_undi
static
Initial value:
= {
.Signature = PXE_ROMID_SIGNATURE,
.Len = sizeof ( efi_snp_undi ),
.MajorVer = PXE_ROMID_MAJORVER,
.MinorVer = PXE_ROMID_MINORVER,
.Implementation = ( PXE_ROMID_IMP_SW_VIRT_ADDR |
.BusCnt = 1,
.BusType[0] = PXE_BUSTYPE ( 'i', 'P', 'X', 'E' ),
}
#define PXE_ROMID_MAJORVER
UNDI command interface revision.
Definition: UefiPxe.h:853
#define PXE_ROMID_SIGNATURE
Signature of !PXE structure.
Definition: UefiPxe.h:841
#define PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED
Definition: UefiPxe.h:879
#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED
Definition: UefiPxe.h:875
#define PXE_BUSTYPE(a, b, c, d)
Definition: UefiPxe.h:28
static PXE_SW_UNDI efi_snp_undi
UNDI interface.
Definition: efi_snp.c:1457
#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE
Definition: UefiPxe.h:872
UINT8_t Rev
PCI revision.
Definition: pxe_api.h:62
#define PXE_ROMID_MINORVER
Definition: UefiPxe.h:854
#define PXE_ROMID_IMP_SW_VIRT_ADDR
Definition: UefiPxe.h:860
#define PXE_ROMID_REV
!PXE structure format revision
Definition: UefiPxe.h:846
#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED
Definition: UefiPxe.h:874
#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED
Definition: UefiPxe.h:873
#define PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED
Definition: UefiPxe.h:878

UNDI interface.

Must be aligned on a 16-byte boundary, for no particularly good reason.

Definition at line 1457 of file efi_snp.c.

Referenced by efi_snp_probe().

◆ efi_snp_device_nii

EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL efi_snp_device_nii
static
Initial value:
= {
.StringId = "UNDI",
.MajorVer = 3,
.MinorVer = 1,
.Ipv6Supported = TRUE,
}
#define TRUE
Definition: tlan.h:46
#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION

Network Identification Interface (NII)

Definition at line 1480 of file efi_snp.c.

Referenced by efi_snp_probe().

◆ efi_snp_load_file_protocol

EFI_LOAD_FILE_PROTOCOL efi_snp_load_file_protocol
static
Initial value:
= {
.LoadFile = efi_snp_load_file,
}
static EFI_STATUS EFIAPI efi_snp_load_file(EFI_LOAD_FILE_PROTOCOL *load_file, EFI_DEVICE_PATH_PROTOCOL *path __unused, BOOLEAN booting, UINTN *len __unused, VOID *data __unused)
Load file.
Definition: efi_snp.c:1553

Load file protocol.

Definition at line 1589 of file efi_snp.c.

Referenced by efi_snp_probe().

◆ __net_driver

struct net_driver efi_snp_driver __net_driver
Initial value:
= {
.name = "SNP",
.probe = efi_snp_probe,
.notify = efi_snp_notify,
.remove = efi_snp_remove,
}
static void efi_snp_notify(struct net_device *netdev)
Handle SNP device or link state change.
Definition: efi_snp.c:1865
static void efi_snp_remove(struct net_device *netdev)
Destroy SNP device.
Definition: efi_snp.c:1890
static int efi_snp_probe(struct net_device *netdev)
Create SNP device.
Definition: efi_snp.c:1622

SNP driver.

Definition at line 1926 of file efi_snp.c.