]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
MdeModulePkg: Update the default size of MNP TX buffer pool.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpImpl.h
index 54a61c39612b31aa745e3e3af493c933b8fe1ff4..51391afe2685ea587ae64989d3c650972af49056 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Declaration of structures and functions of MnpDxe driver.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -27,6 +27,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -92,6 +94,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
@@ -234,6 +245,7 @@ MnpInitializeInstanceData (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 MnpTokenExist (\r
   IN NET_MAP         *Map,\r
   IN NET_MAP_ITEM    *Item,\r
@@ -256,6 +268,7 @@ MnpTokenExist (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 MnpCancelTokens (\r
   IN OUT NET_MAP         *Map,\r
   IN OUT NET_MAP_ITEM    *Item,\r
@@ -340,8 +353,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
@@ -350,7 +366,11 @@ MnpBuildTxPacket (
   );\r
 \r
 /**\r
-  Synchronously send out the packet.\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
@@ -446,6 +466,36 @@ 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