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