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