]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpImpl.h
index d35086221e0956eb3adba35fa2201e2e353b41e9..7d542403465993eb7b15d3ff307ea75ef6ef4e35 100644 (file)
@@ -1,15 +1,8 @@
 /** @file\r
   Declaration of structures and functions of MnpDxe driver.\r
 \r
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution.  The full\r
-text of the license may be found at<BR>\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -22,10 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define MNP_SYS_POLL_INTERVAL         (10 * TICKS_PER_MS)   // 10 milliseconds\r
 #define MNP_TIMEOUT_CHECK_INTERVAL    (50 * TICKS_PER_MS)   // 50 milliseconds\r
+#define MNP_MEDIA_DETECT_INTERVAL     (500 * TICKS_PER_MS)  // 500 milliseconds\r
 #define MNP_TX_TIMEOUT_TIME           (500 * TICKS_PER_MS)  // 500 milliseconds\r
 #define MNP_INIT_NET_BUFFER_NUM       512\r
 #define MNP_NET_BUFFER_INCREASEMENT   64\r
 #define MNP_MAX_NET_BUFFER_NUM        65536\r
+#define MNP_TX_BUFFER_INCREASEMENT    32    // Same as the recycling Q length for xmit_done in UNDI command.\r
+#define MNP_MAX_TX_BUFFER_NUM         65536\r
 \r
 #define MNP_MAX_RCVD_PACKET_QUE_SIZE  256\r
 \r
@@ -91,6 +87,15 @@ typedef struct {
   UINT64                            TimeoutTick;\r
 } MNP_RXDATA_WRAP;\r
 \r
+#define MNP_TX_BUF_WRAP_SIGNATURE   SIGNATURE_32 ('M', 'T', 'B', 'W')\r
+\r
+typedef struct {\r
+  UINT32                  Signature;\r
+  LIST_ENTRY              WrapEntry;  // Link to FreeTxBufList\r
+  LIST_ENTRY              AllEntry;   // Link to AllTxBufList\r
+  BOOLEAN                 InUse;\r
+  UINT8                   TxBuf[1];\r
+} MNP_TX_BUF_WRAP;\r
 \r
 /**\r
   Initialize the mnp device context data.\r
@@ -233,6 +238,7 @@ MnpInitializeInstanceData (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 MnpTokenExist (\r
   IN NET_MAP         *Map,\r
   IN NET_MAP_ITEM    *Item,\r
@@ -255,6 +261,7 @@ MnpTokenExist (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 MnpCancelTokens (\r
   IN OUT NET_MAP         *Map,\r
   IN OUT NET_MAP_ITEM    *Item,\r
@@ -339,8 +346,11 @@ MnpIsValidTxToken (
   @param[out]  PktLen              Pointer to a UINT32 variable used to record the packet's\r
                                    length.\r
 \r
+  @retval EFI_SUCCESS           TxPackage is built.\r
+  @retval EFI_OUT_OF_RESOURCES  The deliver fails due to lack of memory resource.\r
+\r
 **/\r
-VOID\r
+EFI_STATUS\r
 MnpBuildTxPacket (\r
   IN     MNP_SERVICE_DATA                    *MnpServiceData,\r
   IN     EFI_MANAGED_NETWORK_TRANSMIT_DATA   *TxData,\r
@@ -351,6 +361,10 @@ MnpBuildTxPacket (
 /**\r
   Synchronously send out the packet.\r
 \r
+  This functon places the packet buffer to SNP driver's tansmit queue. The packet\r
+  can be considered successfully sent out once SNP acccetp the packet, while the\r
+  packet buffer recycle is deferred for better performance.\r
+\r
   @param[in]       MnpServiceData      Pointer to the mnp service context data.\r
   @param[in]       Packet              Pointer to the pakcet buffer.\r
   @param[in]       Length              The length of the packet.\r
@@ -445,12 +459,41 @@ MnpFreeNbuf (
   IN OUT NET_BUF           *Nbuf\r
   );\r
 \r
+/**\r
+  Allocate a free TX buffer from MnpDeviceData->FreeTxBufList. If there is none\r
+  in the queue, first try to recycle some from SNP, then try to allocate some and add\r
+  them into the queue, then fetch the NET_BUF from the updated FreeTxBufList.\r
+\r
+  @param[in, out]  MnpDeviceData        Pointer to the MNP_DEVICE_DATA.\r
+\r
+  @return     Pointer to the allocated free NET_BUF structure, if NULL the\r
+              operation is failed.\r
+\r
+**/\r
+UINT8 *\r
+MnpAllocTxBuf (\r
+  IN OUT MNP_DEVICE_DATA   *MnpDeviceData\r
+  );\r
+\r
+/**\r
+  Try to recycle all the transmitted buffer address from SNP.\r
+\r
+  @param[in, out]  MnpDeviceData     Pointer to the mnp device context data.\r
+\r
+  @retval EFI_SUCCESS             Successed to recyclethe transmitted buffer address.\r
+  @retval Others                  Failed to recyclethe transmitted buffer address.\r
+\r
+**/\r
+EFI_STATUS\r
+MnpRecycleTxBuf (\r
+  IN OUT MNP_DEVICE_DATA   *MnpDeviceData\r
+  );\r
+\r
 /**\r
   Remove the received packets if timeout occurs.\r
 \r
-  @param[in]  Event             The event this notify function registered to.\r
-  @param[in]  Context           Pointer to the context data registered to the\r
-                                event.\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
 \r
 **/\r
 VOID\r
@@ -460,19 +503,33 @@ MnpCheckPacketTimeout (
   IN VOID          *Context\r
   );\r
 \r
+/**\r
+  Poll to update MediaPresent field in SNP ModeData by Snp.GetStatus().\r
+\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MnpCheckMediaStatus (\r
+  IN EFI_EVENT     Event,\r
+  IN VOID          *Context\r
+  );\r
+\r
 /**\r
   Poll to receive the packets from Snp. This function is either called by upperlayer\r
   protocols/applications or the system poll timer notify mechanism.\r
 \r
-  @param[in]       Event        The event this notify function registered to.\r
-  @param[in, out]  Context      Pointer to the context data registered to the event.\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 MnpSystemPoll (\r
-  IN     EFI_EVENT   Event,\r
-  IN OUT VOID        *Context\r
+  IN EFI_EVENT     Event,\r
+  IN VOID          *Context\r
   );\r
 \r
 /**\r