]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/SnpDxe/Reset.c
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / SnpDxe / Reset.c
1 /** @file
2 Implementation of resetting a network adapter.
3
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "Snp.h"
10
11 /**
12 Call UNDI to reset the NIC.
13
14 @param Snp Pointer to the snp driver structure.
15
16 @return EFI_SUCCESSFUL The NIC was reset.
17 @retval EFI_DEVICE_ERROR The NIC cannot be reset.
18
19 **/
20 EFI_STATUS
21 PxeReset (
22 SNP_DRIVER *Snp
23 )
24 {
25 Snp->Cdb.OpCode = PXE_OPCODE_RESET;
26 Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
27 Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
28 Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
29 Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
30 Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
31 Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
32 Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
33 Snp->Cdb.IFnum = Snp->IfNum;
34 Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
35
36 //
37 // Issue UNDI command and check result.
38 //
39 DEBUG ((DEBUG_NET, "\nsnp->undi.reset() "));
40
41 (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);
42
43 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {
44 DEBUG (
45 (DEBUG_WARN,
46 "\nsnp->undi32.reset() %xh:%xh\n",
47 Snp->Cdb.StatFlags,
48 Snp->Cdb.StatCode)
49 );
50
51 //
52 // UNDI could not be reset. Return UNDI error.
53 //
54 return EFI_DEVICE_ERROR;
55 }
56
57 return EFI_SUCCESS;
58 }
59
60 /**
61 Resets a network adapter and reinitializes it with the parameters that were
62 provided in the previous call to Initialize().
63
64 This function resets a network adapter and reinitializes it with the parameters
65 that were provided in the previous call to Initialize(). The transmit and
66 receive queues are emptied and all pending interrupts are cleared.
67 Receive filters, the station address, the statistics, and the multicast-IP-to-HW
68 MAC addresses are not reset by this call. If the network interface was
69 successfully reset, then EFI_SUCCESS will be returned. If the driver has not
70 been initialized, EFI_DEVICE_ERROR will be returned.
71
72 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
73 @param ExtendedVerification Indicates that the driver may perform a more
74 exhaustive verification operation of the device
75 during reset.
76
77 @retval EFI_SUCCESS The network interface was reset.
78 @retval EFI_NOT_STARTED The network interface has not been started.
79 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
80 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
81 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
82
83 **/
84 EFI_STATUS
85 EFIAPI
86 SnpUndi32Reset (
87 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
88 IN BOOLEAN ExtendedVerification
89 )
90 {
91 SNP_DRIVER *Snp;
92 EFI_TPL OldTpl;
93 EFI_STATUS Status;
94
95 //
96 // Resolve Warning 4 unreferenced parameter problem
97 //
98 ExtendedVerification = 0;
99 DEBUG ((DEBUG_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));
100
101 if (This == NULL) {
102 return EFI_INVALID_PARAMETER;
103 }
104
105 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
106
107 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
108
109 switch (Snp->Mode.State) {
110 case EfiSimpleNetworkInitialized:
111 break;
112
113 case EfiSimpleNetworkStopped:
114 Status = EFI_NOT_STARTED;
115 goto ON_EXIT;
116
117 default:
118 Status = EFI_DEVICE_ERROR;
119 goto ON_EXIT;
120 }
121
122 Status = PxeReset (Snp);
123
124 ON_EXIT:
125 gBS->RestoreTPL (OldTpl);
126
127 return Status;
128 }