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