]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/Snp.h
1. Use the PciIo->GetBarAttributes to find the logical bar index of the memory mapped...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.h
CommitLineData
2883b67e 1/** @file\r
4cda7726 2 Declaration of strctures and functions for SnpDxe driver.\r
2883b67e 3\r
c4a7d208 4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials are licensed\r
c777c357 6and made available under the terms and conditions of the BSD License which\r
7accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
2883b67e 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
2883b67e 13**/\r
4cda7726 14#ifndef _SNP_H_\r
15#define _SNP_H_\r
2883b67e 16\r
17\r
f3816027 18#include <Uefi.h>\r
2883b67e 19\r
20#include <Protocol/SimpleNetwork.h>\r
21#include <Protocol/PciIo.h>\r
22#include <Protocol/NetworkInterfaceIdentifier.h>\r
23#include <Protocol/DevicePath.h>\r
24\r
0428a6cb 25#include <Guid/EventGroup.h>\r
26\r
2883b67e 27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/BaseLib.h>\r
32#include <Library/UefiLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
216f7970 34#include <Library/PrintLib.h>\r
2883b67e 35\r
2248bd60 36#include <IndustryStandard/Pci.h>\r
c4a7d208 37#include <IndustryStandard/Acpi.h>\r
2883b67e 38\r
39#define FOUR_GIGABYTES (UINT64) 0x100000000ULL\r
40\r
41\r
f3f2e05d 42#define SNP_DRIVER_SIGNATURE SIGNATURE_32 ('s', 'n', 'd', 's')\r
2883b67e 43#define MAX_MAP_LENGTH 100\r
44\r
45#define PCI_BAR_IO_MASK 0x00000003\r
46#define PCI_BAR_IO_MODE 0x00000001\r
47\r
48#define PCI_BAR_MEM_MASK 0x0000000F\r
49#define PCI_BAR_MEM_MODE 0x00000000\r
50#define PCI_BAR_MEM_64BIT 0x00000004\r
51\r
4cda7726 52typedef\r
53EFI_STATUS\r
9c9f5859 54(EFIAPI *ISSUE_UNDI32_COMMAND) (\r
4cda7726 55 UINT64 Cdb\r
56 );\r
c777c357 57\r
2883b67e 58typedef struct {\r
59 UINT32 Signature;\r
4cda7726 60 EFI_LOCK Lock;\r
2883b67e 61\r
4cda7726 62 EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
63 EFI_SIMPLE_NETWORK_MODE Mode;\r
2883b67e 64\r
4cda7726 65 EFI_HANDLE DeviceHandle;\r
66 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
2883b67e 67\r
68 //\r
69 // Local instance data needed by SNP driver\r
70 //\r
71 // Pointer to S/W UNDI API entry point\r
72 // This will be NULL for H/W UNDI\r
73 //\r
4cda7726 74 ISSUE_UNDI32_COMMAND IssueUndi32Command;\r
2883b67e 75\r
4cda7726 76 BOOLEAN IsSwUndi;\r
2883b67e 77\r
78 //\r
79 // undi interface number, if one undi manages more nics\r
80 //\r
4cda7726 81 PXE_IFNUM IfNum;\r
2883b67e 82\r
83 //\r
84 // Allocated tx/rx buffer that was passed to UNDI Initialize.\r
85 //\r
4cda7726 86 UINT32 TxRxBufferSize;\r
87 VOID *TxRxBuffer;\r
2883b67e 88 //\r
89 // mappable buffers for receive and fill header for undi3.0\r
90 // these will be used if the user buffers are above 4GB limit (instead of\r
91 // mapping the user buffers)\r
92 //\r
4cda7726 93 UINT8 *ReceiveBufffer;\r
94 VOID *ReceiveBufferUnmap;\r
95 UINT8 *FillHeaderBuffer;\r
96 VOID *FillHeaderBufferUnmap;\r
2883b67e 97\r
4cda7726 98 EFI_PCI_IO_PROTOCOL *PciIo;\r
2883b67e 99 UINT8 IoBarIndex;\r
100 UINT8 MemoryBarIndex;\r
101\r
102 //\r
103 // Buffers for command descriptor block, command parameter block\r
104 // and data block.\r
105 //\r
4cda7726 106 PXE_CDB Cdb;\r
107 VOID *Cpb;\r
2883b67e 108 VOID *CpbUnmap;\r
4cda7726 109 VOID *Db;\r
2883b67e 110\r
111 //\r
112 // UNDI structure, we need to remember the init info for a long time!\r
113 //\r
4cda7726 114 PXE_DB_GET_INIT_INFO InitInfo;\r
2883b67e 115\r
116 VOID *SnpDriverUnmap;\r
117 //\r
118 // when ever we map an address, we must remember it's address and the un-map\r
119 // cookie so that we can unmap later\r
120 //\r
4cda7726 121 struct MAP_LIST {\r
122 EFI_PHYSICAL_ADDRESS VirtualAddress;\r
123 VOID *MapCookie;\r
124 } MapList[MAX_MAP_LENGTH];\r
0428a6cb 125\r
126 EFI_EVENT ExitBootServicesEvent;\r
c777c357 127\r
128 //\r
129 // Whether UNDI support reporting media status from GET_STATUS command,\r
130 // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED\r
131 //\r
132 BOOLEAN MediaStatusSupported;\r
4cda7726 133} SNP_DRIVER;\r
2883b67e 134\r
4cda7726 135#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)\r
2883b67e 136\r
137//\r
138// Global Variables\r
139//\r
216f7970 140extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding;\r
2883b67e 141extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;\r
142extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;\r
143\r
4cda7726 144/**\r
145 this routine calls undi to start the interface and changes the snp state.\r
146\r
147 @param Snp pointer to snp driver structure\r
148\r
149 @retval EFI_DEVICE_ERROR UNDI could not be started\r
150 @retval EFI_SUCCESS UNDI is started successfully\r
c777c357 151\r
4cda7726 152**/\r
153EFI_STATUS\r
154PxeStart (\r
155 IN SNP_DRIVER *Snp\r
156 );\r
157\r
158/**\r
159 this routine calls undi to stop the interface and changes the snp state.\r
160\r
161 @param Snp pointer to snp driver structure\r
162\r
163 @retval EFI_INVALID_PARAMETER invalid parameter\r
164 @retval EFI_NOT_STARTED SNP is not started\r
165 @retval EFI_DEVICE_ERROR SNP is not initialized\r
166 @retval EFI_UNSUPPORTED operation unsupported\r
167\r
168**/\r
169EFI_STATUS\r
170PxeStop (\r
171 SNP_DRIVER *Snp\r
172 );\r
173\r
174/**\r
175 this routine calls undi to initialize the interface.\r
176\r
177 @param Snp pointer to snp driver structure\r
178 @param CableDetectFlag Do/don't detect the cable (depending on what undi supports)\r
c777c357 179\r
4cda7726 180 @retval EFI_SUCCESS UNDI is initialized successfully\r
181 @retval EFI_DEVICE_ERROR UNDI could not be initialized\r
c777c357 182 @retval Other other errors\r
4cda7726 183\r
184**/\r
185EFI_STATUS\r
186PxeInit (\r
187 SNP_DRIVER *Snp,\r
188 UINT16 CableDetectFlag\r
189 );\r
c777c357 190\r
4cda7726 191/**\r
192 this routine calls undi to shut down the interface.\r
193\r
194 @param Snp pointer to snp driver structure\r
195\r
196 @retval EFI_SUCCESS UNDI is shut down successfully\r
197 @retval EFI_DEVICE_ERROR UNDI could not be shut down\r
198\r
199**/\r
2883b67e 200EFI_STATUS\r
4cda7726 201PxeShutdown (\r
202 IN SNP_DRIVER *Snp\r
ed66e1bc 203 );\r
2883b67e 204\r
4cda7726 205/**\r
206 this routine calls undi to read the MAC address of the NIC and updates the\r
207 mode structure with the address.\r
208\r
209 @param Snp pointer to snp driver structure.\r
c777c357 210\r
4cda7726 211 @retval EFI_SUCCESS the MAC address of the NIC is read successfully.\r
212 @retval EFI_DEVICE_ERROR failed to read the MAC address of the NIC.\r
213\r
214**/\r
215EFI_STATUS\r
216PxeGetStnAddr (\r
217 SNP_DRIVER *Snp\r
218 );\r
219\r
4cda7726 220/**\r
221 This is a callback routine supplied to UNDI3.1 at undi_start time.\r
222 UNDI call this routine when it wants to have exclusive access to a critical\r
223 section of the code/data.\r
224 New callbacks for 3.1:\r
225 there won't be a virtual2physical callback for UNDI 3.1 because undi3.1 uses\r
226 the MemMap call to map the required address by itself!\r
227\r
c777c357 228 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
9c9f5859 229 store Undi interface context (Undi does not read or write\r
230 this variable)\r
4cda7726 231 @param Enable non-zero indicates acquire\r
232 zero indicates release\r
233**/\r
234VOID\r
9c9f5859 235EFIAPI\r
4cda7726 236SnpUndi32CallbackBlock (\r
2883b67e 237 IN UINT64 UniqueId,\r
238 IN UINT32 Enable\r
ed66e1bc 239 );\r
2883b67e 240\r
4cda7726 241/**\r
242 This is a callback routine supplied to UNDI at undi_start time.\r
243 UNDI call this routine with the number of micro seconds when it wants to\r
244 pause.\r
245\r
246 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
9c9f5859 247 store Undi interface context (Undi does not read or write\r
248 this variable)\r
4cda7726 249 @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.\r
250**/\r
251VOID\r
9c9f5859 252EFIAPI\r
4cda7726 253SnpUndi32CallbackDelay (\r
2883b67e 254 IN UINT64 UniqueId,\r
255 IN UINT64 MicroSeconds\r
ed66e1bc 256 );\r
2883b67e 257\r
4cda7726 258/**\r
259 This is a callback routine supplied to UNDI at undi_start time.\r
260 This is the IO routine for UNDI3.1 to start CPB.\r
261\r
c777c357 262 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this\r
9c9f5859 263 to store Undi interface context (Undi does not read or\r
264 write this variable)\r
4cda7726 265 @param ReadOrWrite indicates read or write, IO or Memory.\r
266 @param NumBytes number of bytes to read or write.\r
267 @param MemOrPortAddr IO or memory address to read from or write to.\r
268 @param BufferPtr memory location to read into or that contains the bytes\r
269 to write.\r
270**/\r
271VOID\r
9c9f5859 272EFIAPI\r
4cda7726 273SnpUndi32CallbackMemio (\r
2883b67e 274 IN UINT64 UniqueId,\r
275 IN UINT8 ReadOrWrite,\r
276 IN UINT8 NumBytes,\r
277 IN UINT64 MemOrPortAddr,\r
278 IN OUT UINT64 BufferPtr\r
ed66e1bc 279 );\r
2883b67e 280\r
4cda7726 281/**\r
282 This is a callback routine supplied to UNDI at undi_start time.\r
283 UNDI call this routine when it has to map a CPU address to a device\r
284 address.\r
285\r
286 @param UniqueId - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
287 Undi interface context (Undi does not read or write this variable)\r
288 @param CpuAddr - Virtual address to be mapped!\r
289 @param NumBytes - size of memory to be mapped\r
290 @param Direction - direction of data flow for this memory's usage:\r
291 cpu->device, device->cpu or both ways\r
292 @param DeviceAddrPtr - pointer to return the mapped device address\r
293\r
294**/\r
295VOID\r
9c9f5859 296EFIAPI\r
4cda7726 297SnpUndi32CallbackMap (\r
2883b67e 298 IN UINT64 UniqueId,\r
299 IN UINT64 CpuAddr,\r
300 IN UINT32 NumBytes,\r
301 IN UINT32 Direction,\r
302 IN OUT UINT64 DeviceAddrPtr\r
ed66e1bc 303 );\r
2883b67e 304\r
4cda7726 305/**\r
306 This is a callback routine supplied to UNDI at undi_start time.\r
307 UNDI call this routine when it wants to unmap an address that was previously\r
308 mapped using map callback.\r
309\r
310 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to store.\r
311 Undi interface context (Undi does not read or write this variable)\r
312 @param CpuAddr Virtual address that was mapped!\r
313 @param NumBytes size of memory mapped\r
314 @param Direction direction of data flow for this memory's usage:\r
315 cpu->device, device->cpu or both ways\r
316 @param DeviceAddr the mapped device address\r
317\r
318**/\r
319VOID\r
9c9f5859 320EFIAPI\r
4cda7726 321SnpUndi32CallbackUnmap (\r
2883b67e 322 IN UINT64 UniqueId,\r
323 IN UINT64 CpuAddr,\r
324 IN UINT32 NumBytes,\r
325 IN UINT32 Direction,\r
4cda7726 326 IN UINT64 DeviceAddr\r
ed66e1bc 327 );\r
2883b67e 328\r
4cda7726 329/**\r
330 This is a callback routine supplied to UNDI at undi_start time.\r
331 UNDI call this routine when it wants synchronize the virtual buffer contents\r
332 with the mapped buffer contents. The virtual and mapped buffers need not\r
333 correspond to the same physical memory (especially if the virtual address is\r
334 > 4GB). Depending on the direction for which the buffer is mapped, undi will\r
335 need to synchronize their contents whenever it writes to/reads from the buffer\r
336 using either the cpu address or the device address.\r
337\r
338 EFI does not provide a sync call, since virt=physical, we sould just do\r
339 the synchronization ourself here!\r
340\r
341 @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to store\r
342 Undi interface context (Undi does not read or write this variable)\r
343 @param CpuAddr Virtual address that was mapped!\r
344 @param NumBytes size of memory mapped.\r
345 @param Direction direction of data flow for this memory's usage:\r
346 cpu->device, device->cpu or both ways.\r
347 @param DeviceAddr the mapped device address.\r
348\r
349**/\r
350VOID\r
9c9f5859 351EFIAPI\r
4cda7726 352SnpUndi32CallbackSync (\r
2883b67e 353 IN UINT64 UniqueId,\r
354 IN UINT64 CpuAddr,\r
355 IN UINT32 NumBytes,\r
356 IN UINT32 Direction,\r
4cda7726 357 IN UINT64 DeviceAddr\r
ed66e1bc 358 );\r
2883b67e 359\r
4cda7726 360/**\r
361 Changes the state of a network interface from "stopped" to "started".\r
c777c357 362\r
4cda7726 363 This function starts a network interface. If the network interface successfully\r
364 starts, then EFI_SUCCESS will be returned.\r
365\r
366 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
367\r
368 @retval EFI_SUCCESS The network interface was started.\r
369 @retval EFI_ALREADY_STARTED The network interface is already in the started state.\r
c777c357 370 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 371 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
372 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
373 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
374\r
375**/\r
376EFI_STATUS\r
2883b67e 377EFIAPI\r
4cda7726 378SnpUndi32Start (\r
379 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 380 );\r
2883b67e 381\r
4cda7726 382/**\r
383 Changes the state of a network interface from "started" to "stopped".\r
c777c357 384\r
4cda7726 385 This function stops a network interface. This call is only valid if the network\r
386 interface is in the started state. If the network interface was successfully\r
387 stopped, then EFI_SUCCESS will be returned.\r
c777c357 388\r
4cda7726 389 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 390\r
391\r
4cda7726 392 @retval EFI_SUCCESS The network interface was stopped.\r
393 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 394 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 395 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
396 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
397 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
398\r
399**/\r
400EFI_STATUS\r
2883b67e 401EFIAPI\r
4cda7726 402SnpUndi32Stop (\r
403 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 404 );\r
2883b67e 405\r
4cda7726 406/**\r
c777c357 407 Resets a network adapter and allocates the transmit and receive buffers\r
408 required by the network interface; optionally, also requests allocation of\r
4cda7726 409 additional transmit and receive buffers.\r
410\r
411 This function allocates the transmit and receive buffers required by the network\r
412 interface. If this allocation fails, then EFI_OUT_OF_RESOURCES is returned.\r
413 If the allocation succeeds and the network interface is successfully initialized,\r
414 then EFI_SUCCESS will be returned.\r
415\r
416 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
417\r
418 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
419 that the driver should allocate for the network interface.\r
c777c357 420 Some network interfaces will not be able to use the\r
421 extra buffer, and the caller will not know if it is\r
4cda7726 422 actually being used.\r
423 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
424 that the driver should allocate for the network interface.\r
425 Some network interfaces will not be able to use the\r
426 extra buffer, and the caller will not know if it is\r
427 actually being used.\r
428\r
429 @retval EFI_SUCCESS The network interface was initialized.\r
430 @retval EFI_NOT_STARTED The network interface has not been started.\r
431 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r
432 receive buffers.\r
433 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
434 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
435 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
436 @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
437\r
438**/\r
c777c357 439EFI_STATUS\r
2883b67e 440EFIAPI\r
4cda7726 441SnpUndi32Initialize (\r
442 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
443 IN UINTN ExtraRxBufferSize OPTIONAL,\r
444 IN UINTN ExtraTxBufferSize OPTIONAL\r
ed66e1bc 445 );\r
2883b67e 446\r
4cda7726 447/**\r
448 Resets a network adapter and reinitializes it with the parameters that were\r
449 provided in the previous call to Initialize().\r
450\r
451 This function resets a network adapter and reinitializes it with the parameters\r
c777c357 452 that were provided in the previous call to Initialize(). The transmit and\r
4cda7726 453 receive queues are emptied and all pending interrupts are cleared.\r
c777c357 454 Receive filters, the station address, the statistics, and the multicast-IP-to-HW\r
455 MAC addresses are not reset by this call. If the network interface was\r
456 successfully reset, then EFI_SUCCESS will be returned. If the driver has not\r
4cda7726 457 been initialized, EFI_DEVICE_ERROR will be returned.\r
458\r
459 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 460 @param ExtendedVerification Indicates that the driver may perform a more\r
461 exhaustive verification operation of the device\r
4cda7726 462 during reset.\r
463\r
464 @retval EFI_SUCCESS The network interface was reset.\r
465 @retval EFI_NOT_STARTED The network interface has not been started.\r
466 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
467 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
468 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
469\r
470**/\r
471EFI_STATUS\r
2883b67e 472EFIAPI\r
4cda7726 473SnpUndi32Reset (\r
474 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
2883b67e 475 IN BOOLEAN ExtendedVerification\r
ed66e1bc 476 );\r
2883b67e 477\r
4cda7726 478/**\r
c777c357 479 Resets a network adapter and leaves it in a state that is safe for another\r
480 driver to initialize.\r
481\r
4cda7726 482 This function releases the memory buffers assigned in the Initialize() call.\r
483 Pending transmits and receives are lost, and interrupts are cleared and disabled.\r
c777c357 484 After this call, only the Initialize() and Stop() calls may be used. If the\r
4cda7726 485 network interface was successfully shutdown, then EFI_SUCCESS will be returned.\r
486 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
487\r
488 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
489\r
490 @retval EFI_SUCCESS The network interface was shutdown.\r
491 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 492 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 493 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
494 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
495\r
496**/\r
497EFI_STATUS\r
2883b67e 498EFIAPI\r
4cda7726 499SnpUndi32Shutdown (\r
500 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
ed66e1bc 501 );\r
2883b67e 502\r
4cda7726 503/**\r
504 Manages the multicast receive filters of a network interface.\r
c777c357 505\r
506 This function is used enable and disable the hardware and software receive\r
4cda7726 507 filters for the underlying network device.\r
c777c357 508 The receive filter change is broken down into three steps:\r
509 * The filter mask bits that are set (ON) in the Enable parameter are added to\r
510 the current receive filter settings.\r
4cda7726 511 * The filter mask bits that are set (ON) in the Disable parameter are subtracted\r
512 from the updated receive filter settings.\r
513 * If the resulting receive filter setting is not supported by the hardware a\r
514 more liberal setting is selected.\r
c777c357 515 If the same bits are set in the Enable and Disable parameters, then the bits\r
4cda7726 516 in the Disable parameter takes precedence.\r
c777c357 517 If the ResetMCastFilter parameter is TRUE, then the multicast address list\r
518 filter is disabled (irregardless of what other multicast bits are set in the\r
519 Enable and Disable parameters). The SNP->Mode->MCastFilterCount field is set\r
4cda7726 520 to zero. The Snp->Mode->MCastFilter contents are undefined.\r
c777c357 521 After enabling or disabling receive filter settings, software should verify\r
522 the new settings by checking the Snp->Mode->ReceiveFilterSettings,\r
4cda7726 523 Snp->Mode->MCastFilterCount and Snp->Mode->MCastFilter fields.\r
c777c357 524 Note: Some network drivers and/or devices will automatically promote receive\r
4cda7726 525 filter settings if the requested setting can not be honored. For example, if\r
c777c357 526 a request for four multicast addresses is made and the underlying hardware\r
527 only supports two multicast addresses the driver might set the promiscuous\r
4cda7726 528 or promiscuous multicast receive filters instead. The receiving software is\r
c777c357 529 responsible for discarding any extra packets that get through the hardware\r
4cda7726 530 receive filters.\r
c777c357 531 Note: Note: To disable all receive filter hardware, the network driver must\r
4cda7726 532 be Shutdown() and Stopped(). Calling ReceiveFilters() with Disable set to\r
c777c357 533 Snp->Mode->ReceiveFilterSettings will make it so no more packets are\r
534 returned by the Receive() function, but the receive hardware may still be\r
4cda7726 535 moving packets into system memory before inspecting and discarding them.\r
c777c357 536 Unexpected system errors, reboots and hangs can occur if an OS is loaded\r
4cda7726 537 and the network devices are not Shutdown() and Stopped().\r
c777c357 538 If ResetMCastFilter is TRUE, then the multicast receive filter list on the\r
4cda7726 539 network interface will be reset to the default multicast receive filter list.\r
c777c357 540 If ResetMCastFilter is FALSE, and this network interface allows the multicast\r
541 receive filter list to be modified, then the MCastFilterCnt and MCastFilter\r
542 are used to update the current multicast receive filter list. The modified\r
543 receive filter list settings can be found in the MCastFilter field of\r
4cda7726 544 EFI_SIMPLE_NETWORK_MODE. If the network interface does not allow the multicast\r
545 receive filter list to be modified, then EFI_INVALID_PARAMETER will be returned.\r
546 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
c777c357 547 If the receive filter mask and multicast receive filter list have been\r
4cda7726 548 successfully updated on the network interface, EFI_SUCCESS will be returned.\r
549\r
550 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
551 @param Enable A bit mask of receive filters to enable on the network\r
552 interface.\r
553 @param Disable A bit mask of receive filters to disable on the network\r
c777c357 554 interface. For backward compatibility with EFI 1.1\r
4cda7726 555 platforms, the EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit\r
556 must be set when the ResetMCastFilter parameter is TRUE.\r
c777c357 557 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast\r
558 receive filters on the network interface to their\r
559 default values.\r
4cda7726 560 @param MCastFilterCnt Number of multicast HW MAC addresses in the new MCastFilter\r
c777c357 561 list. This value must be less than or equal to the\r
562 MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE.\r
4cda7726 563 This field is optional if ResetMCastFilter is TRUE.\r
564 @param MCastFilter A pointer to a list of new multicast receive filter HW\r
c777c357 565 MAC addresses. This list will replace any existing\r
566 multicast HW MAC address list. This field is optional\r
4cda7726 567 if ResetMCastFilter is TRUE.\r
c777c357 568\r
4cda7726 569 @retval EFI_SUCCESS The multicast receive filter list was updated.\r
570 @retval EFI_NOT_STARTED The network interface has not been started.\r
571 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
572 * This is NULL\r
573 * There are bits set in Enable that are not set\r
574 in Snp->Mode->ReceiveFilterMask\r
575 * There are bits set in Disable that are not set\r
576 in Snp->Mode->ReceiveFilterMask\r
c777c357 577 * Multicast is being enabled (the\r
578 EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit is\r
579 set in Enable, it is not set in Disable, and\r
4cda7726 580 ResetMCastFilter is FALSE) and MCastFilterCount\r
581 is zero\r
582 * Multicast is being enabled and MCastFilterCount\r
583 is greater than Snp->Mode->MaxMCastFilterCount\r
584 * Multicast is being enabled and MCastFilter is NULL\r
585 * Multicast is being enabled and one or more of\r
586 the addresses in the MCastFilter list are not\r
587 valid multicast MAC addresses\r
588 @retval EFI_DEVICE_ERROR One or more of the following conditions is TRUE:\r
589 * The network interface has been started but has\r
590 not been initialized\r
c777c357 591 * An unexpected error was returned by the\r
4cda7726 592 underlying network driver or device\r
593 @retval EFI_UNSUPPORTED This function is not supported by the network\r
594 interface.\r
595\r
596**/\r
597EFI_STATUS\r
2883b67e 598EFIAPI\r
4cda7726 599SnpUndi32ReceiveFilters (\r
600 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
601 IN UINT32 Enable,\r
602 IN UINT32 Disable,\r
603 IN BOOLEAN ResetMCastFilter,\r
604 IN UINTN MCastFilterCnt, OPTIONAL\r
605 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r
ed66e1bc 606 );\r
2883b67e 607\r
4cda7726 608/**\r
609 Modifies or resets the current station address, if supported.\r
c777c357 610\r
611 This function modifies or resets the current station address of a network\r
4cda7726 612 interface, if supported. If Reset is TRUE, then the current station address is\r
c777c357 613 set to the network interface's permanent address. If Reset is FALSE, and the\r
614 network interface allows its station address to be modified, then the current\r
615 station address is changed to the address specified by New. If the network\r
616 interface does not allow its station address to be modified, then\r
4cda7726 617 EFI_INVALID_PARAMETER will be returned. If the station address is successfully\r
618 updated on the network interface, EFI_SUCCESS will be returned. If the driver\r
619 has not been initialized, EFI_DEVICE_ERROR will be returned.\r
620\r
621 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 622 @param Reset Flag used to reset the station address to the network interface's\r
4cda7726 623 permanent address.\r
624 @param New New station address to be used for the network interface.\r
625\r
626\r
627 @retval EFI_SUCCESS The network interface's station address was updated.\r
c777c357 628 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not been\r
4cda7726 629 started by calling Start().\r
630 @retval EFI_INVALID_PARAMETER The New station address was not accepted by the NIC.\r
631 @retval EFI_INVALID_PARAMETER Reset is FALSE and New is NULL.\r
c777c357 632 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 633 been initialized by calling Initialize().\r
c777c357 634 @retval EFI_DEVICE_ERROR An error occurred attempting to set the new\r
4cda7726 635 station address.\r
c777c357 636 @retval EFI_UNSUPPORTED The NIC does not support changing the network\r
4cda7726 637 interface's station address.\r
638\r
639**/\r
640EFI_STATUS\r
2883b67e 641EFIAPI\r
4cda7726 642SnpUndi32StationAddress (\r
643 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
644 IN BOOLEAN Reset,\r
645 IN EFI_MAC_ADDRESS *New OPTIONAL\r
ed66e1bc 646 );\r
2883b67e 647\r
4cda7726 648/**\r
649 Resets or collects the statistics on a network interface.\r
c777c357 650\r
4cda7726 651 This function resets or collects the statistics on a network interface. If the\r
652 size of the statistics table specified by StatisticsSize is not big enough for\r
653 all the statistics that are collected by the network interface, then a partial\r
c777c357 654 buffer of statistics is returned in StatisticsTable, StatisticsSize is set to\r
655 the size required to collect all the available statistics, and\r
4cda7726 656 EFI_BUFFER_TOO_SMALL is returned.\r
c777c357 657 If StatisticsSize is big enough for all the statistics, then StatisticsTable\r
658 will be filled, StatisticsSize will be set to the size of the returned\r
4cda7726 659 StatisticsTable structure, and EFI_SUCCESS is returned.\r
660 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
661 If Reset is FALSE, and both StatisticsSize and StatisticsTable are NULL, then\r
662 no operations will be performed, and EFI_SUCCESS will be returned.\r
663 If Reset is TRUE, then all of the supported statistics counters on this network\r
664 interface will be reset to zero.\r
665\r
666 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
667 @param Reset Set to TRUE to reset the statistics for the network interface.\r
c777c357 668 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On output\r
4cda7726 669 the size, in bytes, of the resulting table of statistics.\r
c777c357 670 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
671 contains the statistics. Type EFI_NETWORK_STATISTICS is\r
672 defined in "Related Definitions" below.\r
673\r
4cda7726 674 @retval EFI_SUCCESS The requested operation succeeded.\r
675 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not been\r
676 started by calling Start().\r
c777c357 677 @retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is\r
678 NULL. The current buffer size that is needed to\r
4cda7726 679 hold all the statistics is returned in StatisticsSize.\r
c777c357 680 @retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is\r
4cda7726 681 not NULL. The current buffer size that is needed\r
c777c357 682 to hold all the statistics is returned in\r
683 StatisticsSize. A partial set of statistics is\r
4cda7726 684 returned in StatisticsTable.\r
c777c357 685 @retval EFI_INVALID_PARAMETER StatisticsSize is NULL and StatisticsTable is not\r
4cda7726 686 NULL.\r
c777c357 687 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 688 been initialized by calling Initialize().\r
c777c357 689 @retval EFI_DEVICE_ERROR An error was encountered collecting statistics\r
4cda7726 690 from the NIC.\r
c777c357 691 @retval EFI_UNSUPPORTED The NIC does not support collecting statistics\r
4cda7726 692 from the network interface.\r
693\r
694**/\r
695EFI_STATUS\r
2883b67e 696EFIAPI\r
4cda7726 697SnpUndi32Statistics (\r
698 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
699 IN BOOLEAN Reset,\r
700 IN OUT UINTN *StatisticsSize, OPTIONAL\r
701 IN OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r
ed66e1bc 702 );\r
2883b67e 703\r
4cda7726 704/**\r
705 Converts a multicast IP address to a multicast HW MAC address.\r
c777c357 706\r
707 This function converts a multicast IP address to a multicast HW MAC address\r
4cda7726 708 for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will\r
709 be returned.\r
710\r
711 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
712 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].\r
c777c357 713 Set to FALSE if the multicast IP address is IPv4 [RFC 791].\r
714 @param IP The multicast IP address that is to be converted to a multicast\r
4cda7726 715 HW MAC address.\r
716 @param MAC The multicast HW MAC address that is to be generated from IP.\r
c777c357 717\r
4cda7726 718 @retval EFI_SUCCESS The multicast IP address was mapped to the\r
719 multicast HW MAC address.\r
720 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not\r
721 been started by calling Start().\r
722 @retval EFI_INVALID_PARAMETER IP is NULL.\r
723 @retval EFI_INVALID_PARAMETER MAC is NULL.\r
c777c357 724 @retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6\r
4cda7726 725 multicast address.\r
c777c357 726 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not\r
4cda7726 727 been initialized by calling Initialize().\r
c777c357 728 @retval EFI_UNSUPPORTED IPv6 is TRUE and the implementation does not\r
4cda7726 729 support IPv6 multicast to MAC address conversion.\r
730\r
731**/\r
732EFI_STATUS\r
2883b67e 733EFIAPI\r
4cda7726 734SnpUndi32McastIpToMac (\r
735 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
2883b67e 736 IN BOOLEAN IPv6,\r
737 IN EFI_IP_ADDRESS *IP,\r
738 OUT EFI_MAC_ADDRESS *MAC\r
ed66e1bc 739 );\r
2883b67e 740\r
4cda7726 741/**\r
c777c357 742 Performs read and write operations on the NVRAM device attached to a network\r
4cda7726 743 interface.\r
c777c357 744\r
745 This function performs read and write operations on the NVRAM device attached\r
4cda7726 746 to a network interface. If ReadWrite is TRUE, a read operation is performed.\r
c777c357 747 If ReadWrite is FALSE, a write operation is performed. Offset specifies the\r
748 byte offset at which to start either operation. Offset must be a multiple of\r
749 NvRamAccessSize , and it must have a value between zero and NvRamSize.\r
4cda7726 750 BufferSize specifies the length of the read or write operation. BufferSize must\r
751 also be a multiple of NvRamAccessSize, and Offset + BufferSize must not exceed\r
c777c357 752 NvRamSize.\r
753 If any of the above conditions is not met, then EFI_INVALID_PARAMETER will be\r
754 returned.\r
755 If all the conditions are met and the operation is "read," the NVRAM device\r
756 attached to the network interface will be read into Buffer and EFI_SUCCESS\r
4cda7726 757 will be returned. If this is a write operation, the contents of Buffer will be\r
c777c357 758 used to update the contents of the NVRAM device attached to the network\r
4cda7726 759 interface and EFI_SUCCESS will be returned.\r
c777c357 760\r
4cda7726 761 It does the basic checking on the input parameters and retrieves snp structure\r
762 and then calls the read_nvdata() call which does the actual reading\r
763\r
764 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
765 @param ReadWrite TRUE for read operations, FALSE for write operations.\r
c777c357 766 @param Offset Byte offset in the NVRAM device at which to start the read or\r
767 write operation. This must be a multiple of NvRamAccessSize\r
768 and less than NvRamSize. (See EFI_SIMPLE_NETWORK_MODE)\r
769 @param BufferSize The number of bytes to read or write from the NVRAM device.\r
4cda7726 770 This must also be a multiple of NvramAccessSize.\r
771 @param Buffer A pointer to the data buffer.\r
772\r
773 @retval EFI_SUCCESS The NVRAM access was performed.\r
774 @retval EFI_NOT_STARTED The network interface has not been started.\r
775 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
c777c357 776 * The This parameter is NULL\r
777 * The This parameter does not point to a valid\r
4cda7726 778 EFI_SIMPLE_NETWORK_PROTOCOL structure\r
c777c357 779 * The Offset parameter is not a multiple of\r
4cda7726 780 EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
c777c357 781 * The Offset parameter is not less than\r
4cda7726 782 EFI_SIMPLE_NETWORK_MODE.NvRamSize\r
c777c357 783 * The BufferSize parameter is not a multiple of\r
4cda7726 784 EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
785 * The Buffer parameter is NULL\r
c777c357 786 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
4cda7726 787 interface.\r
788 @retval EFI_UNSUPPORTED This function is not supported by the network\r
789 interface.\r
2883b67e 790\r
4cda7726 791**/\r
792EFI_STATUS\r
2883b67e 793EFIAPI\r
4cda7726 794SnpUndi32NvData (\r
795 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
796 IN BOOLEAN ReadWrite,\r
797 IN UINTN Offset,\r
798 IN UINTN BufferSize,\r
799 IN OUT VOID *Buffer\r
ed66e1bc 800 );\r
2883b67e 801\r
4cda7726 802/**\r
803 Reads the current interrupt status and recycled transmit buffer status from a\r
804 network interface.\r
c777c357 805\r
806 This function gets the current interrupt and recycled transmit buffer status\r
4cda7726 807 from the network interface. The interrupt status is returned as a bit mask in\r
808 InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be\r
809 read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.\r
810 If a recycled transmit buffer address is returned in TxBuf, then the buffer has\r
811 been successfully transmitted, and the status for that buffer is cleared. If\r
c777c357 812 the status of the network interface is successfully collected, EFI_SUCCESS\r
4cda7726 813 will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will\r
814 be returned.\r
815\r
816 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 817 @param InterruptStatus A pointer to the bit mask of the currently active\r
4cda7726 818 interrupts (see "Related Definitions"). If this is NULL,\r
819 the interrupt status will not be read from the device.\r
820 If this is not NULL, the interrupt status will be read\r
c777c357 821 from the device. When the interrupt status is read, it\r
822 will also be cleared. Clearing the transmit interrupt does\r
4cda7726 823 not empty the recycled transmit buffer array.\r
824 @param TxBuf Recycled transmit buffer address. The network interface\r
c777c357 825 will not transmit if its internal recycled transmit\r
4cda7726 826 buffer array is full. Reading the transmit buffer does\r
827 not clear the transmit interrupt. If this is NULL, then\r
c777c357 828 the transmit buffer status will not be read. If there\r
829 are no transmit buffers to recycle and TxBuf is not NULL,\r
4cda7726 830 TxBuf will be set to NULL.\r
831\r
832 @retval EFI_SUCCESS The status of the network interface was retrieved.\r
833 @retval EFI_NOT_STARTED The network interface has not been started.\r
c777c357 834 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
4cda7726 835 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
c777c357 836 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
4cda7726 837 interface.\r
838\r
839**/\r
840EFI_STATUS\r
2883b67e 841EFIAPI\r
4cda7726 842SnpUndi32GetStatus (\r
843 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
844 OUT UINT32 *InterruptStatus, OPTIONAL\r
845 OUT VOID **TxBuf OPTIONAL\r
ed66e1bc 846 );\r
2883b67e 847\r
4cda7726 848/**\r
849 Places a packet in the transmit queue of a network interface.\r
c777c357 850\r
4cda7726 851 This function places the packet specified by Header and Buffer on the transmit\r
c777c357 852 queue. If HeaderSize is nonzero and HeaderSize is not equal to\r
853 This->Mode->MediaHeaderSize, then EFI_INVALID_PARAMETER will be returned. If\r
4cda7726 854 BufferSize is less than This->Mode->MediaHeaderSize, then EFI_BUFFER_TOO_SMALL\r
c777c357 855 will be returned. If Buffer is NULL, then EFI_INVALID_PARAMETER will be\r
4cda7726 856 returned. If HeaderSize is nonzero and DestAddr or Protocol is NULL, then\r
857 EFI_INVALID_PARAMETER will be returned. If the transmit engine of the network\r
c777c357 858 interface is busy, then EFI_NOT_READY will be returned. If this packet can be\r
859 accepted by the transmit engine of the network interface, the packet contents\r
860 specified by Buffer will be placed on the transmit queue of the network\r
861 interface, and EFI_SUCCESS will be returned. GetStatus() can be used to\r
862 determine when the packet has actually been transmitted. The contents of the\r
863 Buffer must not be modified until the packet has actually been transmitted.\r
4cda7726 864 The Transmit() function performs nonblocking I/O. A caller who wants to perform\r
c777c357 865 blocking I/O, should call Transmit(), and then GetStatus() until the\r
4cda7726 866 transmitted buffer shows up in the recycled transmit buffer.\r
867 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
868\r
869 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 870 @param HeaderSize The size, in bytes, of the media header to be filled in by the\r
4cda7726 871 Transmit() function. If HeaderSize is nonzero, then it must\r
872 be equal to This->Mode->MediaHeaderSize and the DestAddr and\r
873 Protocol parameters must not be NULL.\r
874 @param BufferSize The size, in bytes, of the entire packet (media header and\r
875 data) to be transmitted through the network interface.\r
c777c357 876 @param Buffer A pointer to the packet (media header followed by data) to be\r
877 transmitted. This parameter cannot be NULL. If HeaderSize is\r
4cda7726 878 zero, then the media header in Buffer must already be filled\r
c777c357 879 in by the caller. If HeaderSize is nonzero, then the media\r
4cda7726 880 header will be filled in by the Transmit() function.\r
c777c357 881 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this\r
882 parameter is ignored. If HeaderSize is nonzero and SrcAddr\r
883 is NULL, then This->Mode->CurrentAddress is used for the\r
4cda7726 884 source HW MAC address.\r
c777c357 885 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then\r
4cda7726 886 this parameter is ignored.\r
c777c357 887 @param Protocol The type of header to build. If HeaderSize is zero, then this\r
888 parameter is ignored. See RFC 1700, section "Ether Types,"\r
4cda7726 889 for examples.\r
890\r
891 @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
892 @retval EFI_NOT_STARTED The network interface has not been started.\r
893 @retval EFI_NOT_READY The network interface is too busy to accept this\r
894 transmit request.\r
895 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
896 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported\r
897 value.\r
898 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
899 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
900\r
901**/\r
c777c357 902EFI_STATUS\r
2883b67e 903EFIAPI\r
4cda7726 904SnpUndi32Transmit (\r
905 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
906 IN UINTN HeaderSize,\r
907 IN UINTN BufferSize,\r
908 IN VOID *Buffer,\r
909 IN EFI_MAC_ADDRESS *SrcAddr, OPTIONAL\r
910 IN EFI_MAC_ADDRESS *DestAddr, OPTIONAL\r
911 IN UINT16 *Protocol OPTIONAL\r
ed66e1bc 912 );\r
2883b67e 913\r
4cda7726 914/**\r
915 Receives a packet from a network interface.\r
916\r
917 This function retrieves one packet from the receive queue of a network interface.\r
c777c357 918 If there are no packets on the receive queue, then EFI_NOT_READY will be\r
4cda7726 919 returned. If there is a packet on the receive queue, and the size of the packet\r
920 is smaller than BufferSize, then the contents of the packet will be placed in\r
921 Buffer, and BufferSize will be updated with the actual size of the packet.\r
922 In addition, if SrcAddr, DestAddr, and Protocol are not NULL, then these values\r
c777c357 923 will be extracted from the media header and returned. EFI_SUCCESS will be\r
4cda7726 924 returned if a packet was successfully received.\r
925 If BufferSize is smaller than the received packet, then the size of the receive\r
926 packet will be placed in BufferSize and EFI_BUFFER_TOO_SMALL will be returned.\r
927 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
928\r
929 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
c777c357 930 @param HeaderSize The size, in bytes, of the media header received on the network\r
931 interface. If this parameter is NULL, then the media header size\r
4cda7726 932 will not be returned.\r
c777c357 933 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
4cda7726 934 bytes, of the packet that was received on the network interface.\r
935 @param Buffer A pointer to the data buffer to receive both the media\r
936 header and the data.\r
937 @param SrcAddr The source HW MAC address. If this parameter is NULL, the HW\r
c777c357 938 MAC source address will not be extracted from the media header.\r
939 @param DestAddr The destination HW MAC address. If this parameter is NULL,\r
940 the HW MAC destination address will not be extracted from\r
4cda7726 941 the media header.\r
c777c357 942 @param Protocol The media header type. If this parameter is NULL, then the\r
943 protocol will not be extracted from the media header. See\r
4cda7726 944 RFC 1700 section "Ether Types" for examples.\r
945\r
c777c357 946 @retval EFI_SUCCESS The received data was stored in Buffer, and\r
947 BufferSize has been updated to the number of\r
4cda7726 948 bytes received.\r
949 @retval EFI_NOT_STARTED The network interface has not been started.\r
950 @retval EFI_NOT_READY No packets have been received on the network interface.\r
c777c357 951 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the received packets.\r
4cda7726 952 BufferSize has been updated to the required size.\r
953 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
954 * The This parameter is NULL\r
c777c357 955 * The This parameter does not point to a valid\r
4cda7726 956 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
957 * The BufferSize parameter is NULL\r
958 * The Buffer parameter is NULL\r
959 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
960\r
961**/\r
2883b67e 962EFI_STATUS\r
4cda7726 963EFIAPI\r
964SnpUndi32Receive (\r
965 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
966 OUT UINTN *HeaderSize OPTIONAL,\r
967 IN OUT UINTN *BufferSize,\r
968 OUT VOID *Buffer,\r
969 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
970 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
971 OUT UINT16 *Protocol OPTIONAL\r
2883b67e 972 );\r
973\r
2883b67e 974/**\r
4cda7726 975 Nofication call back function for WaitForPacket event.\r
2883b67e 976\r
4cda7726 977 @param Event EFI Event.\r
978 @param SnpPtr Pointer to SNP_DRIVER structure.\r
2883b67e 979\r
980**/\r
4cda7726 981VOID\r
2883b67e 982EFIAPI\r
4cda7726 983SnpWaitForPacketNotify (\r
984 EFI_EVENT Event,\r
985 VOID *SnpPtr\r
ed66e1bc 986 );\r
2883b67e 987\r
988#define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)\r
989\r
990\r
4cda7726 991#endif /* _SNP_H_ */\r