iPXE
snpnet.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
25 #include <errno.h>
26 #include <ipxe/iobuf.h>
27 #include <ipxe/netdevice.h>
28 #include <ipxe/ethernet.h>
29 #include <ipxe/vsprintf.h>
30 #include <ipxe/efi/efi.h>
32 #include <ipxe/efi/efi_driver.h>
33 #include <ipxe/efi/efi_utils.h>
34 #include "snpnet.h"
35 
36 /** @file
37  *
38  * SNP NIC driver
39  *
40  */
41 
42 /** An SNP NIC */
43 struct snp_nic {
44  /** EFI device */
45  struct efi_device *efidev;
46  /** Simple network protocol */
48  /** Generic device */
49  struct device dev;
50 
51  /** Maximum packet size
52  *
53  * This is calculated as the sum of MediaHeaderSize and
54  * MaxPacketSize, and may therefore be an overestimate.
55  */
56  size_t mtu;
57 
58  /** Current transmit buffer */
59  struct io_buffer *txbuf;
60  /** Current receive buffer */
61  struct io_buffer *rxbuf;
62 };
63 
64 /** Maximum number of received packets per poll */
65 #define SNP_RX_QUOTA 4
66 
67 /**
68  * Format SNP MAC address (for debugging)
69  *
70  * @v mac MAC address
71  * @v len Length of MAC address
72  * @ret text MAC address as text
73  */
74 static const char * snpnet_mac_text ( EFI_MAC_ADDRESS *mac, size_t len ) {
75  static char buf[ sizeof ( *mac ) * 3 /* "xx:" or "xx\0" */ ];
76  size_t used = 0;
77  unsigned int i;
78 
79  for ( i = 0 ; i < len ; i++ ) {
80  used += ssnprintf ( &buf[used], ( sizeof ( buf ) - used ),
81  "%s%02x", ( used ? ":" : "" ),
82  mac->Addr[i] );
83  }
84  return buf;
85 }
86 
87 /**
88  * Dump SNP mode information (for debugging)
89  *
90  * @v netdev Network device
91  */
92 static void snpnet_dump_mode ( struct net_device *netdev ) {
93  struct snp_nic *snp = netdev_priv ( netdev );
94  EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
95  size_t mac_len = mode->HwAddressSize;
96  unsigned int i;
97 
98  /* Do nothing unless debugging is enabled */
99  if ( ! DBG_EXTRA )
100  return;
101 
102  DBGC2 ( snp, "SNP %s st %d type %d hdr %d pkt %d rxflt %#x/%#x%s "
103  "nvram %d acc %d mcast %d/%d\n", netdev->name, mode->State,
104  mode->IfType, mode->MediaHeaderSize, mode->MaxPacketSize,
106  ( mode->MultipleTxSupported ? " multitx" : "" ),
107  mode->NvRamSize, mode->NvRamAccessSize,
108  mode->MCastFilterCount, mode->MaxMCastFilterCount );
109  DBGC2 ( snp, "SNP %s hw %s", netdev->name,
110  snpnet_mac_text ( &mode->PermanentAddress, mac_len ) );
111  DBGC2 ( snp, " addr %s%s",
112  snpnet_mac_text ( &mode->CurrentAddress, mac_len ),
113  ( mode->MacAddressChangeable ? "" : "(f)" ) );
114  DBGC2 ( snp, " bcast %s\n",
115  snpnet_mac_text ( &mode->BroadcastAddress, mac_len ) );
116  for ( i = 0 ; i < mode->MCastFilterCount ; i++ ) {
117  DBGC2 ( snp, "SNP %s mcast %s\n", netdev->name,
118  snpnet_mac_text ( &mode->MCastFilter[i], mac_len ) );
119  }
120  DBGC2 ( snp, "SNP %s media %s\n", netdev->name,
121  ( mode->MediaPresentSupported ?
122  ( mode->MediaPresent ? "present" : "not present" ) :
123  "presence not supported" ) );
124 }
125 
126 /**
127  * Check link state
128  *
129  * @v netdev Network device
130  */
131 static void snpnet_check_link ( struct net_device *netdev ) {
132  struct snp_nic *snp = netdev_priv ( netdev );
133  EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
134 
135  /* Do nothing unless media presence detection is supported */
136  if ( ! mode->MediaPresentSupported )
137  return;
138 
139  /* Report any link status change */
140  if ( mode->MediaPresent && ( ! netdev_link_ok ( netdev ) ) ) {
142  } else if ( ( ! mode->MediaPresent ) && netdev_link_ok ( netdev ) ) {
144  }
145 }
146 
147 /**
148  * Transmit packet
149  *
150  * @v netdev Network device
151  * @v iobuf I/O buffer
152  * @ret rc Return status code
153  */
154 static int snpnet_transmit ( struct net_device *netdev,
155  struct io_buffer *iobuf ) {
156  struct snp_nic *snp = netdev_priv ( netdev );
157  EFI_STATUS efirc;
158  int rc;
159 
160  /* Defer the packet if there is already a transmission in progress */
161  if ( snp->txbuf ) {
162  netdev_tx_defer ( netdev, iobuf );
163  return 0;
164  }
165 
166  /* Transmit packet */
167  if ( ( efirc = snp->snp->Transmit ( snp->snp, 0, iob_len ( iobuf ),
168  iobuf->data, NULL, NULL,
169  NULL ) ) != 0 ) {
170  rc = -EEFI ( efirc );
171  DBGC ( snp, "SNP %s could not transmit: %s\n",
172  netdev->name, strerror ( rc ) );
173  return rc;
174  }
175  snp->txbuf = iobuf;
176 
177  return 0;
178 }
179 
180 /**
181  * Poll for completed packets
182  *
183  * @v netdev Network device
184  */
185 static void snpnet_poll_tx ( struct net_device *netdev ) {
186  struct snp_nic *snp = netdev->priv;
187  struct io_buffer *iobuf;
188  UINT32 irq;
189  VOID *txbuf;
190  EFI_STATUS efirc;
191  int rc;
192 
193  /* Get status */
194  txbuf = NULL;
195  if ( ( efirc = snp->snp->GetStatus ( snp->snp, &irq, &txbuf ) ) != 0 ) {
196  rc = -EEFI ( efirc );
197  DBGC ( snp, "SNP %s could not get status: %s\n",
198  netdev->name, strerror ( rc ) );
199  netdev_rx_err ( netdev, NULL, rc );
200  return;
201  }
202 
203  /* Do nothing unless we have a completion */
204  if ( ! txbuf )
205  return;
206 
207  /* Sanity check */
208  if ( ! snp->txbuf ) {
209  DBGC ( snp, "SNP %s reported spurious TX completion\n",
210  netdev->name );
212  return;
213  }
214 
215  /* Complete transmission */
216  iobuf = snp->txbuf;
217  snp->txbuf = NULL;
218  netdev_tx_complete ( netdev, iobuf );
219 }
220 
221 /**
222  * Poll for received packets
223  *
224  * @v netdev Network device
225  */
226 static void snpnet_poll_rx ( struct net_device *netdev ) {
227  struct snp_nic *snp = netdev->priv;
228  UINTN len;
229  unsigned int quota;
230  EFI_STATUS efirc;
231  int rc;
232 
233  /* Retrieve up to SNP_RX_QUOTA packets */
234  for ( quota = SNP_RX_QUOTA ; quota ; quota-- ) {
235 
236  /* Allocate buffer, if required */
237  if ( ! snp->rxbuf ) {
238  snp->rxbuf = alloc_iob ( snp->mtu );
239  if ( ! snp->rxbuf ) {
240  /* Leave for next poll */
241  break;
242  }
243  }
244 
245  /* Receive packet */
246  len = iob_tailroom ( snp->rxbuf );
247  if ( ( efirc = snp->snp->Receive ( snp->snp, NULL, &len,
248  snp->rxbuf->data, NULL,
249  NULL, NULL ) ) != 0 ) {
250 
251  /* EFI_NOT_READY is just the usual "no packet"
252  * status indication; ignore it.
253  */
254  if ( efirc == EFI_NOT_READY )
255  break;
256 
257  /* Anything else is an error */
258  rc = -EEFI ( efirc );
259  DBGC ( snp, "SNP %s could not receive: %s\n",
260  netdev->name, strerror ( rc ) );
261  netdev_rx_err ( netdev, NULL, rc );
262  break;
263  }
264 
265  /* Hand off to network stack */
266  iob_put ( snp->rxbuf, len );
267  netdev_rx ( netdev, snp->rxbuf );
268  snp->rxbuf = NULL;
269  }
270 }
271 
272 /**
273  * Poll for completed packets
274  *
275  * @v netdev Network device
276  */
277 static void snpnet_poll ( struct net_device *netdev ) {
278 
279  /* Process any TX completions */
281 
282  /* Process any RX completions */
284 
285  /* Check for link state changes */
287 }
288 
289 /**
290  * Set receive filters
291  *
292  * @v netdev Network device
293  * @ret rc Return status code
294  */
295 static int snpnet_rx_filters ( struct net_device *netdev ) {
296  struct snp_nic *snp = netdev->priv;
297  UINT32 filters[] = {
298  snp->snp->Mode->ReceiveFilterMask,
308  };
309  unsigned int i;
310  EFI_STATUS efirc;
311  int rc;
312 
313  /* Try possible receive filters in turn */
314  for ( i = 0; i < ( sizeof ( filters ) / sizeof ( filters[0] ) ); i++ ) {
315  efirc = snp->snp->ReceiveFilters ( snp->snp, filters[i],
317  0, NULL );
318  if ( efirc == 0 )
319  return 0;
320  rc = -EEFI ( efirc );
321  DBGC ( snp, "SNP %s could not set receive filters %#02x (have "
322  "%#02x): %s\n", netdev->name, filters[i],
323  snp->snp->Mode->ReceiveFilterSetting, strerror ( rc ) );
324  }
325 
326  return rc;
327 }
328 
329 /**
330  * Open network device
331  *
332  * @v netdev Network device
333  * @ret rc Return status code
334  */
335 static int snpnet_open ( struct net_device *netdev ) {
336  struct snp_nic *snp = netdev->priv;
337  EFI_MAC_ADDRESS *mac = ( ( void * ) netdev->ll_addr );
338  EFI_STATUS efirc;
339  int rc;
340 
341  /* Try setting MAC address (before initialising) */
342  if ( ( efirc = snp->snp->StationAddress ( snp->snp, FALSE, mac ) ) !=0){
343  rc = -EEFI ( efirc );
344  DBGC ( snp, "SNP %s could not set station address before "
345  "initialising: %s\n", netdev->name, strerror ( rc ) );
346  /* Ignore error */
347  }
348 
349  /* Initialise NIC */
350  if ( ( efirc = snp->snp->Initialize ( snp->snp, 0, 0 ) ) != 0 ) {
351  rc = -EEFI ( efirc );
353  DBGC ( snp, "SNP %s could not initialise: %s\n",
354  netdev->name, strerror ( rc ) );
355  return rc;
356  }
357 
358  /* Try setting MAC address (after initialising) */
359  if ( ( efirc = snp->snp->StationAddress ( snp->snp, FALSE, mac ) ) !=0){
360  rc = -EEFI ( efirc );
361  DBGC ( snp, "SNP %s could not set station address after "
362  "initialising: %s\n", netdev->name, strerror ( rc ) );
363  /* Ignore error */
364  }
365 
366  /* Set receive filters */
367  if ( ( rc = snpnet_rx_filters ( netdev ) ) != 0 ) {
368  /* Ignore error */
369  }
370 
371  /* Dump mode information (for debugging) */
373 
374  return 0;
375 }
376 
377 /**
378  * Close network device
379  *
380  * @v netdev Network device
381  */
382 static void snpnet_close ( struct net_device *netdev ) {
383  struct snp_nic *snp = netdev->priv;
384  EFI_STATUS efirc;
385  int rc;
386 
387  /* Shut down NIC */
388  if ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) {
389  rc = -EEFI ( efirc );
390  DBGC ( snp, "SNP %s could not shut down: %s\n",
391  netdev->name, strerror ( rc ) );
392  /* Nothing we can do about this */
393  }
394 
395  /* Discard transmit buffer, if applicable */
396  if ( snp->txbuf ) {
398  snp->txbuf = NULL;
399  }
400 
401  /* Discard receive buffer, if applicable */
402  if ( snp->rxbuf ) {
403  free_iob ( snp->rxbuf );
404  snp->rxbuf = NULL;
405  }
406 }
407 
408 /** SNP network device operations */
410  .open = snpnet_open,
411  .close = snpnet_close,
412  .transmit = snpnet_transmit,
413  .poll = snpnet_poll,
414 };
415 
416 /**
417  * Attach driver to device
418  *
419  * @v efidev EFI device
420  * @ret rc Return status code
421  */
422 int snpnet_start ( struct efi_device *efidev ) {
424  EFI_HANDLE device = efidev->device;
426  struct net_device *netdev;
427  struct snp_nic *snp;
428  void *interface;
429  EFI_STATUS efirc;
430  int rc;
431 
432  /* Open SNP protocol */
433  if ( ( efirc = bs->OpenProtocol ( device,
438  rc = -EEFI ( efirc );
439  DBGC ( device, "SNP %s cannot open SNP protocol: %s\n",
440  efi_handle_name ( device ), strerror ( rc ) );
443  goto err_open_protocol;
444  }
445 
446  /* Allocate and initialise structure */
447  netdev = alloc_etherdev ( sizeof ( *snp ) );
448  if ( ! netdev ) {
449  rc = -ENOMEM;
450  goto err_alloc;
451  }
453  snp = netdev->priv;
454  snp->efidev = efidev;
455  snp->snp = interface;
456  mode = snp->snp->Mode;
458 
459  /* Populate underlying device information */
460  efi_device_info ( device, "SNP", &snp->dev );
461  snp->dev.driver_name = "SNP";
462  snp->dev.parent = &efidev->dev;
463  list_add ( &snp->dev.siblings, &efidev->dev.children );
464  INIT_LIST_HEAD ( &snp->dev.children );
465  netdev->dev = &snp->dev;
466 
467  /* Bring to the Started state */
468  if ( ( mode->State == EfiSimpleNetworkStopped ) &&
469  ( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
470  rc = -EEFI ( efirc );
471  DBGC ( device, "SNP %s could not start: %s\n",
472  efi_handle_name ( device ), strerror ( rc ) );
473  goto err_start;
474  }
475  if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
476  ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
477  rc = -EEFI ( efirc );
478  DBGC ( device, "SNP %s could not shut down: %s\n",
479  efi_handle_name ( device ), strerror ( rc ) );
480  goto err_shutdown;
481  }
482 
483  /* Populate network device parameters */
484  if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
485  DBGC ( device, "SNP %s has invalid hardware address length "
486  "%d\n", efi_handle_name ( device ), mode->HwAddressSize);
487  rc = -ENOTSUP;
488  goto err_hw_addr_len;
489  }
492  if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
493  DBGC ( device, "SNP %s has invalid link-layer address length "
494  "%d\n", efi_handle_name ( device ), mode->HwAddressSize);
495  rc = -ENOTSUP;
496  goto err_ll_addr_len;
497  }
498  memcpy ( netdev->ll_addr, &mode->CurrentAddress,
500  snp->mtu = ( snp->snp->Mode->MaxPacketSize +
501  snp->snp->Mode->MediaHeaderSize );
502 
503  /* Register network device */
504  if ( ( rc = register_netdev ( netdev ) ) != 0 )
505  goto err_register_netdev;
506  DBGC ( device, "SNP %s registered as %s\n",
508 
509  /* Set initial link state */
510  if ( snp->snp->Mode->MediaPresentSupported ) {
512  } else {
514  }
515 
516  return 0;
517 
519  err_register_netdev:
520  err_ll_addr_len:
521  err_hw_addr_len:
522  err_shutdown:
523  err_start:
524  list_del ( &snp->dev.siblings );
526  netdev_put ( netdev );
527  err_alloc:
530  err_open_protocol:
531  return rc;
532 }
533 
534 /**
535  * Detach driver from device
536  *
537  * @v efidev EFI device
538  */
539 void snpnet_stop ( struct efi_device *efidev ) {
541  struct net_device *netdev = efidev_get_drvdata ( efidev );
542  struct snp_nic *snp = netdev->priv;
544  EFI_STATUS efirc;
545  int rc;
546 
547  /* Unregister network device */
549 
550  /* Stop SNP protocol */
551  if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
552  rc = -EEFI ( efirc );
553  DBGC ( device, "SNP %s could not stop: %s\n",
554  efi_handle_name ( device ), strerror ( rc ) );
555  /* Nothing we can do about this */
556  }
557 
558  /* Free network device */
559  list_del ( &snp->dev.siblings );
561  netdev_put ( netdev );
562 
563  /* Close SNP protocol */
566 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:746
UINT32 NvRamSize
The size, in bytes, of the NVRAM device attached to the network interface.
#define iob_put(iobuf, len)
Definition: iobuf.h:116
static void snpnet_dump_mode(struct net_device *netdev)
Dump SNP mode information (for debugging)
Definition: snpnet.c:92
static void snpnet_poll(struct net_device *netdev)
Poll for completed packets.
Definition: snpnet.c:277
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access to a network adapter.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
Definition: netdevice.c:344
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
EFI driver interface.
UINT32 MediaHeaderSize
The size, in bytes, of the network interface's media header.
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:222
BOOLEAN MediaPresent
TRUE if media are connected to the network interface; otherwise FALSE.
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
Definition: netdevice.c:369
EFI_SIMPLE_NETWORK_PROTOCOL * snp
Simple network protocol.
Definition: snpnet.c:47
Error codes.
32-byte buffer containing a network Media Access Control address.
Definition: UefiBaseType.h:102
void snpnet_stop(struct efi_device *efidev)
Detach driver from device.
Definition: snpnet.c:539
I/O buffers.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
static int snpnet_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: snpnet.c:154
#define EPIPE
Broken pipe.
Definition: errno.h:619
printf() and friends
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:236
#define DBGC(...)
Definition: compiler.h:505
#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST
unsigned int UINT32
Definition: ProcessorBind.h:56
#define EFI_OPEN_PROTOCOL_BY_DRIVER
Definition: UefiSpec.h:1274
#define EFI_OPEN_PROTOCOL_EXCLUSIVE
Definition: UefiSpec.h:1275
BOOLEAN MediaPresentSupported
TRUE if the presence of media can be determined; otherwise FALSE.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
#define DBGC_EFI_OPENERS(...)
Definition: efi.h:260
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:21
UINT32 State
Reports the current state of the network interface.
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
struct io_buffer * rxbuf
Current receive buffer.
Definition: snpnet.c:61
#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST
EFI_MAC_ADDRESS CurrentAddress
The current HW MAC address for the network interface.
EFI utilities.
#define ECANCELED
Operation canceled.
Definition: errno.h:343
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
EFI_SIMPLE_NETWORK_MODE * Mode
Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
int snpnet_start(struct efi_device *efidev)
Attach driver to device.
Definition: snpnet.c:422
EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]
Array containing the addresses of the current multicast address receive filters.
EFI_MAC_ADDRESS BroadcastAddress
The current HW MAC address for broadcast packets.
static const char * snpnet_mac_text(EFI_MAC_ADDRESS *mac, size_t len)
Format SNP MAC address (for debugging)
Definition: snpnet.c:74
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
Definition: vsprintf.c:420
BOOLEAN MultipleTxSupported
TRUE if the network interface can transmit more than one packet at a time.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
UINT8 IfType
The interface type of the network interface.
UINT32 MaxPacketSize
The maximum size, in bytes, of the packets supported by the network interface.
#define ENOMEM
Not enough space.
Definition: errno.h:534
A hardware device.
Definition: device.h:73
void * memcpy(void *dest, const void *src, size_t len) __nonnull
FILE_LICENCE(GPL2_OR_LATER)
UINT32 ReceiveFilterSetting
The current multicast receive filter settings.
UINT32 MCastFilterCount
The current number of multicast address receive filters.
EFI_SIMPLE_NETWORK_INITIALIZE Initialize
struct io_buffer * txbuf
Current transmit buffer.
Definition: snpnet.c:59
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
Ethernet protocol.
An object interface.
Definition: interface.h:109
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:196
void * priv
Driver private data.
Definition: netdevice.h:425
EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
The EFI_SIMPLE_NETWORK_PROTOCOL provides services to initialize a network interface,...
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
static void snpnet_check_link(struct net_device *netdev)
Check link state.
Definition: snpnet.c:131
EFI_SIMPLE_NETWORK_TRANSMIT Transmit
static void snpnet_close(struct net_device *netdev)
Close network device.
Definition: snpnet.c:382
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
BOOLEAN MacAddressChangeable
TRUE if the HW MAC address can be changed.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition: efi_driver.h:83
A network device.
Definition: netdevice.h:348
An SNP NIC.
Definition: snpnet.c:43
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
struct device dev
Generic device.
Definition: snpnet.c:49
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
UINT32 NvRamAccessSize
The size that must be used for all NVRAM reads and writes.
SNP NIC driver.
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
An EFI device.
Definition: efi_driver.h:17
#define SNP_RX_QUOTA
Maximum number of received packets per poll.
Definition: snpnet.c:65
static int snpnet_open(struct net_device *netdev)
Open network device.
Definition: snpnet.c:335
static int snpnet_rx_filters(struct net_device *netdev)
Set receive filters.
Definition: snpnet.c:295
static void snpnet_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: snpnet.c:185
EFI_SIMPLE_NETWORK_START Start
#define VOID
Undeclared type.
Definition: Base.h:319
struct efi_device * efidev
EFI device.
Definition: snpnet.c:45
#define TRUE
Definition: tlan.h:46
EFI API.
Network device operations.
Definition: netdevice.h:213
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
EFI_SIMPLE_NETWORK_RECEIVE Receive
Network device management.
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:395
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
UINT32 HwAddressSize
The size, in bytes, of the network interface's HW address.
UINT32 MaxMCastFilterCount
The maximum number of multicast address receive filters supported by the driver.
void * data
Start of data.
Definition: iobuf.h:44
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct list_head children
Devices attached to this device.
Definition: device.h:83
UINT32 ReceiveFilterMask
The multicast receive filter settings supported by the network interface.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
static void snpnet_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: snpnet.c:226
#define FALSE
Definition: tlan.h:45
EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_SIMPLE_NETWORK_STOP Stop
#define DBG_EXTRA
Definition: compiler.h:319
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition: efi_driver.h:72
struct device dev
Generic device.
Definition: efi_driver.h:19
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
String functions.
static struct net_device_operations snpnet_operations
SNP network device operations.
Definition: snpnet.c:409
Definition: efi.h:55
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
size_t mtu
Maximum packet size.
Definition: snpnet.c:56
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
Definition: efi_utils.c:211
EFI_MAC_ADDRESS PermanentAddress
The permanent HW MAC address for the network interface.
A persistent I/O buffer.
Definition: iobuf.h:32