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