]>
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 | |
a7e0614a | 11 | /**\r |
f3816027 | 12 | Call UNDI to reset the NIC.\r |
a7e0614a | 13 | \r |
f3816027 | 14 | @param Snp Pointer to the snp driver structure.\r |
a7e0614a | 15 | \r |
f3816027 | 16 | @return EFI_SUCCESSFUL The NIC was reset.\r |
17 | @retval EFI_DEVICE_ERROR The NIC cannot be reset.\r | |
a7e0614a | 18 | \r |
19 | **/\r | |
a7e0614a | 20 | EFI_STATUS\r |
4cda7726 | 21 | PxeReset (\r |
d1050b9d | 22 | SNP_DRIVER *Snp\r |
a7e0614a | 23 | )\r |
24 | {\r | |
d1050b9d MK |
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 | |
a7e0614a | 35 | \r |
36 | //\r | |
37 | // Issue UNDI command and check result.\r | |
38 | //\r | |
c49ca4a2 | 39 | DEBUG ((DEBUG_NET, "\nsnp->undi.reset() "));\r |
a7e0614a | 40 | \r |
d1050b9d | 41 | (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);\r |
a7e0614a | 42 | \r |
4cda7726 | 43 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
a7e0614a | 44 | DEBUG (\r |
c49ca4a2 | 45 | (DEBUG_WARN,\r |
d1050b9d MK |
46 | "\nsnp->undi32.reset() %xh:%xh\n",\r |
47 | Snp->Cdb.StatFlags,\r | |
48 | Snp->Cdb.StatCode)\r | |
a7e0614a | 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 | |
a7e0614a | 60 | /**\r |
4cda7726 | 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 | |
d1102dba | 65 | that were provided in the previous call to Initialize(). The transmit and\r |
4cda7726 | 66 | receive queues are emptied and all pending interrupts are cleared.\r |
d1102dba LG |
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 | |
4cda7726 | 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 | |
d1102dba LG |
73 | @param ExtendedVerification Indicates that the driver may perform a more\r |
74 | exhaustive verification operation of the device\r | |
4cda7726 | 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 | |
a7e0614a | 82 | \r |
83 | **/\r | |
84 | EFI_STATUS\r | |
85 | EFIAPI\r | |
4cda7726 | 86 | SnpUndi32Reset (\r |
d1050b9d MK |
87 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r |
88 | IN BOOLEAN ExtendedVerification\r | |
a7e0614a | 89 | )\r |
90 | {\r | |
4cda7726 | 91 | SNP_DRIVER *Snp;\r |
a7e0614a | 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 | |
c49ca4a2 | 99 | DEBUG ((DEBUG_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));\r |
a7e0614a | 100 | \r |
4cda7726 | 101 | if (This == NULL) {\r |
a7e0614a | 102 | return EFI_INVALID_PARAMETER;\r |
103 | }\r | |
104 | \r | |
4cda7726 | 105 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
a7e0614a | 106 | \r |
107 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
108 | \r | |
4cda7726 | 109 | switch (Snp->Mode.State) {\r |
d1050b9d MK |
110 | case EfiSimpleNetworkInitialized:\r |
111 | break;\r | |
a7e0614a | 112 | \r |
d1050b9d MK |
113 | case EfiSimpleNetworkStopped:\r |
114 | Status = EFI_NOT_STARTED;\r | |
115 | goto ON_EXIT;\r | |
a7e0614a | 116 | \r |
d1050b9d MK |
117 | default:\r |
118 | Status = EFI_DEVICE_ERROR;\r | |
119 | goto ON_EXIT;\r | |
a7e0614a | 120 | }\r |
121 | \r | |
4cda7726 | 122 | Status = PxeReset (Snp);\r |
a7e0614a | 123 | \r |
124 | ON_EXIT:\r | |
125 | gBS->RestoreTPL (OldTpl);\r | |
126 | \r | |
127 | return Status;\r | |
128 | }\r |