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