2 Implementation of shutting down a network adapter.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 Call UNDI to shut down the interface.
14 @param Snp Pointer to snp driver structure.
16 @retval EFI_SUCCESS UNDI is shut down successfully.
17 @retval EFI_DEVICE_ERROR UNDI could not be shut down.
25 Snp
->Cdb
.OpCode
= PXE_OPCODE_SHUTDOWN
;
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
;
37 // Issue UNDI command and check result.
39 DEBUG ((DEBUG_NET
, "\nsnp->undi.shutdown() "));
41 (*Snp
->IssueUndi32Command
)((UINT64
)(UINTN
)&Snp
->Cdb
);
43 if (Snp
->Cdb
.StatCode
!= PXE_STATCODE_SUCCESS
) {
45 // UNDI could not be shutdown. Return UNDI error.
47 DEBUG ((DEBUG_WARN
, "\nsnp->undi.shutdown() %xh:%xh\n", Snp
->Cdb
.StatFlags
, Snp
->Cdb
.StatCode
));
49 return EFI_DEVICE_ERROR
;
53 // Free allocated memory.
55 if (Snp
->TxRxBuffer
!= NULL
) {
56 Snp
->PciIo
->FreeBuffer (
58 SNP_MEM_PAGES (Snp
->TxRxBufferSize
),
59 (VOID
*)Snp
->TxRxBuffer
63 Snp
->TxRxBuffer
= NULL
;
64 Snp
->TxRxBufferSize
= 0;
70 Resets a network adapter and leaves it in a state that is safe for another
73 This function releases the memory buffers assigned in the Initialize() call.
74 Pending transmits and receives are lost, and interrupts are cleared and disabled.
75 After this call, only the Initialize() and Stop() calls may be used. If the
76 network interface was successfully shutdown, then EFI_SUCCESS will be returned.
77 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.
79 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
81 @retval EFI_SUCCESS The network interface was shutdown.
82 @retval EFI_NOT_STARTED The network interface has not been started.
83 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid
84 EFI_SIMPLE_NETWORK_PROTOCOL structure.
85 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
91 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
99 // Get pointer to SNP driver instance for *This.
102 return EFI_INVALID_PARAMETER
;
105 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
107 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
110 // Return error if the SNP is not initialized.
112 switch (Snp
->Mode
.State
) {
113 case EfiSimpleNetworkInitialized
:
116 case EfiSimpleNetworkStopped
:
117 Status
= EFI_NOT_STARTED
;
121 Status
= EFI_DEVICE_ERROR
;
125 Status
= PxeShutdown (Snp
);
127 Snp
->Mode
.State
= EfiSimpleNetworkStarted
;
128 Snp
->Mode
.ReceiveFilterSetting
= 0;
130 Snp
->Mode
.MCastFilterCount
= 0;
131 Snp
->Mode
.ReceiveFilterSetting
= 0;
132 ZeroMem (Snp
->Mode
.MCastFilter
, sizeof Snp
->Mode
.MCastFilter
);
134 &Snp
->Mode
.CurrentAddress
,
135 &Snp
->Mode
.PermanentAddress
,
136 sizeof (EFI_MAC_ADDRESS
)
139 gBS
->CloseEvent (Snp
->Snp
.WaitForPacket
);
142 gBS
->RestoreTPL (OldTpl
);