X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FSnp.h;h=e6b62930397d6aec9e2fb617c09f3d4d840ceb4c;hp=bf9ed8823338de4c4e74c47e427026d0e254277e;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hpb=e5eed7d3641d71d7ea539e5379ea9c6a5cd97004 diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.h b/MdeModulePkg/Universal/Network/SnpDxe/Snp.h index bf9ed88233..e6b6293039 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.h +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.h @@ -1,14 +1,8 @@ /** @file Declaration of strctures and functions for SnpDxe driver. -Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials are licensed -and made available under the terms and conditions of the BSD License which -accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _SNP_H_ @@ -31,8 +25,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include +#include #define FOUR_GIGABYTES (UINT64) 0x100000000ULL @@ -47,9 +43,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define PCI_BAR_MEM_MODE 0x00000000 #define PCI_BAR_MEM_64BIT 0x00000004 +#define SNP_TX_BUFFER_INCREASEMENT MAX_XMIT_BUFFERS +#define SNP_MAX_TX_BUFFER_NUM 65536 + typedef EFI_STATUS -(*ISSUE_UNDI32_COMMAND) ( +(EFIAPI *ISSUE_UNDI32_COMMAND) ( UINT64 Cdb ); @@ -125,9 +124,30 @@ typedef struct { // // Whether UNDI support reporting media status from GET_STATUS command, - // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED + // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED or + // PXE_STATFLAGS_GET_STATUS_NO_MEDIA_NOT_SUPPORTED // BOOLEAN MediaStatusSupported; + + // + // Whether UNDI support cable detect for INITIALIZE command, + // i.e. PXE_STATFLAGS_CABLE_DETECT_SUPPORTED or + // PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED + // + BOOLEAN CableDetectSupported; + + // + // Array of the recycled transmit buffer address from UNDI. + // + UINT64 *RecycledTxBuf; + // + // The maximum number of recycled buffer pointers in RecycledTxBuf. + // + UINT32 MaxRecycledTxBuf; + // + // Current number of recycled buffer pointers in RecycledTxBuf. + // + UINT32 RecycledTxBufCount; } SNP_DRIVER; #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE) @@ -135,65 +155,10 @@ typedef struct { // // Global Variables // +extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding; extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2; -// -// Virtual to physical mapping for all UNDI 3.0s. -// -typedef struct _V2P V2P; - -struct _V2P { - V2P *Next; - VOID *VirtualAddress; - UINTN BufferSize; - EFI_PHYSICAL_ADDRESS PhysicalAddress; - VOID *Unmap; -}; - -/** - This routine maps the given CPU address to a Device address. It creates a - an entry in the map list with the virtual and physical addresses and the - un map cookie. - - @param V2p pointer to return a map list node pointer. - @param Type the direction in which the data flows from the given - virtual address device->cpu or cpu->device or both - ways. - @param VirtualAddress virtual address (or CPU address) to be mapped. - @param BufferSize size of the buffer to be mapped. - - @retval EFI_SUCEESS routine has completed the mapping. - @retval other error as indicated. - -**/ -EFI_STATUS -AddV2p ( - V2P **V2p, - EFI_PCI_IO_PROTOCOL_OPERATION Type, - VOID *VirtualAddress, - UINTN BufferSize - ); - -/** - This routine searches the linked list of mapped address nodes (for undi3.0 - interface) to find the node that corresponds to the given virtual address and - returns a pointer to that node. - - @param V2p pointer to return a map list node pointer. - @param VirtualAddress virtual address (or CPU address) to be searched in - the map list - - @retval EFI_SUCEESS if a match found! - @retval Other match not found - -**/ -EFI_STATUS -FindV2p ( - V2P **V2p, - VOID *VirtualAddress - ); - /** this routine calls undi to start the interface and changes the snp state. @@ -271,93 +236,27 @@ PxeGetStnAddr ( ); /** - This routine unmaps the given virtual address and frees the memory allocated - for the map list node corresponding to that address. + Call undi to get the status of the interrupts, get the list of recycled transmit + buffers that completed transmitting. The recycled transmit buffer address will + be saved into Snp->RecycledTxBuf. This function will also update the MediaPresent + field of EFI_SIMPLE_NETWORK_MODE if UNDI support it. - @param VirtualAddress virtual address (or CPU address) to be unmapped + @param[in] Snp Pointer to snp driver structure. + @param[out] InterruptStatusPtr A non null pointer to contain the interrupt + status. + @param[in] GetTransmittedBuf Set to TRUE to retrieve the recycled transmit + buffer address. - @retval EFI_SUCEESS if successfully unmapped - @retval Other as indicated by the error + @retval EFI_SUCCESS The status of the network interface was retrieved. + @retval EFI_DEVICE_ERROR The command could not be sent to the network + interface. **/ EFI_STATUS -DelV2p ( - VOID *VirtualAddress - ); - -/** - This is a callback routine supplied to UNDI at undi_start time. - UNDI call this routine when it wants to have exclusive access to a critical - section of the code/data. - - @param Enable non-zero indicates acquire - zero indicates release - -**/ -VOID -SnpUndi32CallbackBlock30 ( - IN UINT32 Enable - ); - -/** - This is a callback routine supplied to UNDI at undi_start time. - UNDI call this routine with the number of micro seconds when it wants to - pause. - - @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10. - -**/ -VOID -SnpUndi32CallbackDelay30 ( - IN UINT64 MicroSeconds - ); - -/** - This is a callback routine supplied to UNDI at undi_start time. - This is the IO routine for UNDI. This is not currently being used by UNDI3.0 - because Undi3.0 uses io/mem offsets relative to the beginning of the device - io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the - start of the device's io/mem addresses. Since SNP cannot retrive the context - of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for - that NIC and uses one global IO functions structure, this does not work. - This however works fine for EFI1.0 Undis because they use absolute addresses - for io/mem access. - - @param ReadOrWrite indicates read or write, IO or Memory - @param NumBytes number of bytes to read or write - @param Address IO or memory address to read from or write to - @param BufferAddr memory location to read into or that contains the bytes to - write - -**/ -VOID -SnpUndi32CallbackMemio30 ( - IN UINT8 ReadOrWrite, - IN UINT8 NumBytes, - IN UINT64 Address, - IN OUT UINT64 BufferAddr - ); - -/** - This is a callback routine supplied to UNDI at undi_start time. - UNDI call this routine with a virtual or CPU address that SNP provided to - convert it to a physical or device address. Since EFI uses the identical - mapping, this routine returns the physical address same as the virtual address - for most of the addresses. an address above 4GB cannot generally be used as a - device address, it needs to be mapped to a lower physical address. This - routine does not call the map routine itself, but it assumes that the mapping - was done at the time of providing the address to UNDI. This routine just - looks up the address in a map table (which is the v2p structure chain). - - @param CpuAddr virtual address of a buffer. - @param DeviceAddrPtr pointer to the physical address. - The DeviceAddrPtr will contain 0 in case of any error. - -**/ -VOID -SnpUndi32CallbackV2p30 ( - IN UINT64 CpuAddr, - IN OUT UINT64 DeviceAddrPtr +PxeGetStatus ( + IN SNP_DRIVER *Snp, + OUT UINT32 *InterruptStatusPtr, + IN BOOLEAN GetTransmittedBuf ); /** @@ -369,12 +268,13 @@ SnpUndi32CallbackV2p30 ( the MemMap call to map the required address by itself! @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to - store Undi interface context (Undi does not read or write - this variable) + store Undi interface context (Undi does not read or write + this variable) @param Enable non-zero indicates acquire zero indicates release **/ VOID +EFIAPI SnpUndi32CallbackBlock ( IN UINT64 UniqueId, IN UINT32 Enable @@ -386,11 +286,12 @@ SnpUndi32CallbackBlock ( pause. @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to - store Undi interface context (Undi does not read or write - this variable) + store Undi interface context (Undi does not read or write + this variable) @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10. **/ VOID +EFIAPI SnpUndi32CallbackDelay ( IN UINT64 UniqueId, IN UINT64 MicroSeconds @@ -401,8 +302,8 @@ SnpUndi32CallbackDelay ( This is the IO routine for UNDI3.1 to start CPB. @param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this - to store Undi interface context (Undi does not read or - write this variable) + to store Undi interface context (Undi does not read or + write this variable) @param ReadOrWrite indicates read or write, IO or Memory. @param NumBytes number of bytes to read or write. @param MemOrPortAddr IO or memory address to read from or write to. @@ -410,6 +311,7 @@ SnpUndi32CallbackDelay ( to write. **/ VOID +EFIAPI SnpUndi32CallbackMemio ( IN UINT64 UniqueId, IN UINT8 ReadOrWrite, @@ -433,6 +335,7 @@ SnpUndi32CallbackMemio ( **/ VOID +EFIAPI SnpUndi32CallbackMap ( IN UINT64 UniqueId, IN UINT64 CpuAddr, @@ -456,6 +359,7 @@ SnpUndi32CallbackMap ( **/ VOID +EFIAPI SnpUndi32CallbackUnmap ( IN UINT64 UniqueId, IN UINT64 CpuAddr, @@ -486,6 +390,7 @@ SnpUndi32CallbackUnmap ( **/ VOID +EFIAPI SnpUndi32CallbackSync ( IN UINT64 UniqueId, IN UINT64 CpuAddr,