]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
1. Fix timer unit bug in MNP: default rx/tx timeout value should be 10,000,000 (10s...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpIo.c
index 0347dc7f1f4f8719e6aa835535afc3587bcaf96d..a7b703f8a8828837d8c833c6c84c14164563e19f 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+  Implementation of Managed Network Protocol I/O functions.\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 of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -9,29 +10,15 @@ http://opensource.org/licenses/bsd-license.php
 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
 \r
-Module Name:\r
-\r
-  MnpIo.c\r
-\r
-Abstract:\r
-\r
-  Implementation of Managed Network Protocol I/O functions.\r
-\r
-\r
 **/\r
 \r
 #include "MnpImpl.h"\r
-#include <Library/NetLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
 \r
 /**\r
   Validates the Mnp transmit token.\r
 \r
-  @param  Instance              Pointer to the Mnp instance context data.\r
-  @param  Token                 Pointer to the transmit token to check.\r
+  @param[in]  Instance            Pointer to the Mnp instance context data.\r
+  @param[in]  Token               Pointer to the transmit token to check.\r
 \r
   @return The Token is valid or not.\r
 \r
@@ -117,12 +104,12 @@ MnpIsValidTxToken (
 /**\r
   Build the packet to transmit from the TxData passed in.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
-  @param  TxData                Pointer to the transmit data containing the\r
-                                information to build the packet.\r
-  @param  PktBuf                Pointer to record the address of the packet.\r
-  @param  PktLen                Pointer to a UINT32 variable used to record the\r
-                                packet's length.\r
+  @param[in]   MnpServiceData      Pointer to the mnp service context data.\r
+  @param[in]   TxData              Pointer to the transmit data containing the information \r
+                                   to build the packet.\r
+  @param[out]  PktBuf              Pointer to record the address of the packet.\r
+  @param[out]  PktLen              Pointer to a UINT32 variable used to record the packet's \r
+                                   length.\r
 \r
 **/\r
 VOID\r
@@ -187,22 +174,22 @@ MnpBuildTxPacket (
 /**\r
   Synchronously send out the packet.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
-  @param  Packet                Pointer to the pakcet buffer.\r
-  @param  Length                The length of the packet.\r
-  @param  Token                 Pointer to the token the packet generated from.\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
+  @param[in, out]  Token               Pointer to the token the packet generated from.\r
 \r
-  @retval EFI_SUCCESS           The packet is sent out.\r
-  @retval EFI_TIMEOUT           Time out occurs, the packet isn't sent.\r
-  @retval EFI_DEVICE_ERROR      An unexpected network error occurs.\r
+  @retval EFI_SUCCESS                  The packet is sent out.\r
+  @retval EFI_TIMEOUT                  Time out occurs, the packet isn't sent.\r
+  @retval EFI_DEVICE_ERROR             An unexpected network error occurs.\r
 \r
 **/\r
 EFI_STATUS\r
 MnpSyncSendPacket (\r
-  IN MNP_SERVICE_DATA                      *MnpServiceData,\r
-  IN UINT8                                 *Packet,\r
-  IN UINT32                                Length,\r
-  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token\r
+  IN MNP_SERVICE_DATA                          *MnpServiceData,\r
+  IN UINT8                                     *Packet,\r
+  IN UINT32                                    Length,\r
+  IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
@@ -295,7 +282,7 @@ SIGNAL_TOKEN:
   //\r
   // Dispatch the DPC queued by the NotifyFunction of Token->Event.\r
   //\r
-  NetLibDispatchDpc ();\r
+  DispatchDpc ();\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -304,7 +291,7 @@ SIGNAL_TOKEN:
 /**\r
   Try to deliver the received packet to the instance.\r
 \r
-  @param  Instance              Pointer to the mnp instance context data.\r
+  @param[in, out]  Instance     Pointer to the mnp instance context data.\r
 \r
   @retval EFI_SUCCESS           The received packet is delivered, or there is no\r
                                 packet to deliver, or there is no available receive\r
@@ -314,7 +301,7 @@ SIGNAL_TOKEN:
 **/\r
 EFI_STATUS\r
 MnpInstanceDeliverPacket (\r
-  IN MNP_INSTANCE_DATA  *Instance\r
+  IN OUT MNP_INSTANCE_DATA  *Instance\r
   )\r
 {\r
   MNP_SERVICE_DATA                      *MnpServiceData;\r
@@ -398,9 +385,7 @@ MnpInstanceDeliverPacket (
 /**\r
   Deliver the received packet for the instances belonging to the MnpServiceData.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
-\r
-  @return None.\r
+  @param[in]  MnpServiceData        Pointer to the mnp service context data.\r
 \r
 **/\r
 VOID\r
@@ -429,8 +414,8 @@ MnpDeliverPacket (
   Recycle the RxData and other resources used to hold and deliver the received\r
   packet.\r
 \r
-  @param  Event                 The event this notify function registered to.\r
-  @param  Context               Pointer to the context data registerd to the Event.\r
+  @param[in]  Event               The event this notify function registered to.\r
+  @param[in]  Context             Pointer to the context data registerd to the Event.\r
 \r
 **/\r
 VOID\r
@@ -476,17 +461,14 @@ MnpRecycleRxData (
 /**\r
   Queue the received packet into instance's receive queue.\r
 \r
-  @param  Instance              Pointer to the mnp instance context data.\r
-  @param  RxDataWrap            Pointer to the Wrap structure containing the\r
-                                received data and other information.\r
-\r
-  @return None.\r
-\r
+  @param[in, out]  Instance        Pointer to the mnp instance context data.\r
+  @param[in, out]  RxDataWrap      Pointer to the Wrap structure containing the\r
+                                   received data and other information.\r
 **/\r
 VOID\r
 MnpQueueRcvdPacket (\r
-  IN MNP_INSTANCE_DATA  *Instance,\r
-  IN MNP_RXDATA_WRAP    *RxDataWrap\r
+  IN OUT MNP_INSTANCE_DATA  *Instance,\r
+  IN OUT MNP_RXDATA_WRAP    *RxDataWrap\r
   )\r
 {\r
   MNP_RXDATA_WRAP *OldRxDataWrap;\r
@@ -533,13 +515,13 @@ MnpQueueRcvdPacket (
 /**\r
   Match the received packet with the instance receive filters.\r
 \r
-  @param  Instance              Pointer to the mnp instance context data.\r
-  @param  RxData                Pointer to the EFI_MANAGED_NETWORK_RECEIVE_DATA.\r
-  @param  GroupAddress          Pointer to the GroupAddress, the GroupAddress is\r
+  @param[in]  Instance          Pointer to the mnp instance context data.\r
+  @param[in]  RxData            Pointer to the EFI_MANAGED_NETWORK_RECEIVE_DATA.\r
+  @param[in]  GroupAddress      Pointer to the GroupAddress, the GroupAddress is\r
                                 non-NULL and it contains the destination multicast\r
                                 mac address of the received packet if the packet\r
                                 destinated to a multicast mac address.\r
-  @param  PktAttr               The received packets attribute.\r
+  @param[in]  PktAttr           The received packets attribute.\r
 \r
   @return The received packet matches the instance's receive filters or not.\r
 \r
@@ -611,27 +593,25 @@ MnpMatchPacket (
 /**\r
   Analyse the received packets.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
-  @param  Nbuf                  Pointer to the net buffer holding the received\r
-                                packet.\r
-  @param  RxData                Pointer to the buffer used to save the analysed\r
-                                result in EFI_MANAGED_NETWORK_RECEIVE_DATA.\r
-  @param  GroupAddress          Pointer to pointer to a MNP_GROUP_ADDRESS used to\r
-                                pass out the address of the multicast address the\r
-                                received packet destinated to.\r
-  @param  PktAttr               Pointer to the buffer used to save the analysed\r
-                                packet attribute.\r
-\r
-  @return None.\r
+  @param[in]       MnpServiceData    Pointer to the mnp service context data.\r
+  @param[in]       Nbuf              Pointer to the net buffer holding the received\r
+                                     packet.\r
+  @param[in, out]  RxData            Pointer to the buffer used to save the analysed\r
+                                     result in EFI_MANAGED_NETWORK_RECEIVE_DATA.\r
+  @param[out]      GroupAddress      Pointer to pointer to a MNP_GROUP_ADDRESS used to\r
+                                     pass out the address of the multicast address the\r
+                                     received packet destinated to.\r
+  @param[out]      PktAttr           Pointer to the buffer used to save the analysed\r
+                                     packet attribute.\r
 \r
 **/\r
 VOID\r
 MnpAnalysePacket (\r
-  IN  MNP_SERVICE_DATA                  *MnpServiceData,\r
-  IN  NET_BUF                           *Nbuf,\r
-  IN  EFI_MANAGED_NETWORK_RECEIVE_DATA  *RxData,\r
-  OUT MNP_GROUP_ADDRESS                 **GroupAddress,\r
-  OUT UINT8                             *PktAttr\r
+  IN  MNP_SERVICE_DATA                      *MnpServiceData,\r
+  IN  NET_BUF                               *Nbuf,\r
+  IN  OUT EFI_MANAGED_NETWORK_RECEIVE_DATA  *RxData,\r
+  OUT MNP_GROUP_ADDRESS                     **GroupAddress,\r
+  OUT UINT8                                 *PktAttr\r
   )\r
 {\r
   EFI_SIMPLE_NETWORK_MODE *SnpMode;\r
@@ -715,8 +695,8 @@ MnpAnalysePacket (
 /**\r
   Wrap the RxData.\r
 \r
-  @param  Instance              Pointer to the mnp instance context data.\r
-  @param  RxData                Pointer to the receive data to wrap.\r
+  @param[in]  Instance           Pointer to the mnp instance context data.\r
+  @param[in]  RxData             Pointer to the receive data to wrap.\r
 \r
   @return Pointer to a MNP_RXDATA_WRAP which wraps the RxData.\r
 \r
@@ -771,12 +751,10 @@ MnpWrapRxData (
   Enqueue the received the packets to the instances belonging to the\r
   MnpServiceData.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
-  @param  Nbuf                  Pointer to the net buffer representing the received\r
+  @param[in]  MnpServiceData    Pointer to the mnp service context data.\r
+  @param[in]  Nbuf              Pointer to the net buffer representing the received\r
                                 packet.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 MnpEnqueuePacket (\r
@@ -848,7 +826,7 @@ MnpEnqueuePacket (
 /**\r
   Try to receive a packet and deliver it.\r
 \r
-  @param  MnpServiceData        Pointer to the mnp service context data.\r
+  @param[in, out]  MnpServiceData        Pointer to the mnp service context data.\r
 \r
   @retval EFI_SUCCESS           add return value to function comment\r
   @retval EFI_NOT_STARTED       The simple network protocol is not started.\r
@@ -858,7 +836,7 @@ MnpEnqueuePacket (
 **/\r
 EFI_STATUS\r
 MnpReceivePacket (\r
-  IN MNP_SERVICE_DATA  *MnpServiceData\r
+  IN OUT MNP_SERVICE_DATA  *MnpServiceData\r
   )\r
 {\r
   EFI_STATUS                  Status;\r
@@ -984,11 +962,6 @@ MnpReceivePacket (
   //\r
   MnpDeliverPacket (MnpServiceData);\r
 \r
-  //\r
-  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
-  //\r
-  NetLibDispatchDpc ();\r
-\r
 EXIT:\r
 \r
   ASSERT (Nbuf->TotalSize == MnpServiceData->BufferLength);\r
@@ -1000,8 +973,8 @@ EXIT:
 /**\r
   Remove the received packets if timeout occurs.\r
 \r
-  @param  Event                 The event this notify function registered to.\r
-  @param  Context               Pointer to the context data registered to the\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
    \r
 **/\r
@@ -1043,7 +1016,7 @@ MnpCheckPacketTimeout (
       RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);\r
 \r
       //\r
-      // TimeoutTick unit is ms, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
+      // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.\r
       //\r
       if (RxDataWrap->TimeoutTick >= (MNP_TIMEOUT_CHECK_INTERVAL / 10)) {\r
 \r
@@ -1067,18 +1040,15 @@ MnpCheckPacketTimeout (
   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  Event                 The event this notify function registered to.\r
-  @param  Context               Pointer to the context data registered to the\r
-                                event.\r
-\r
-  @return None.\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
 \r
 **/\r
 VOID\r
 EFIAPI\r
 MnpSystemPoll (\r
   IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
+  IN OUT VOID   *Context\r
   )\r
 {\r
   MNP_SERVICE_DATA  *MnpServiceData;\r
@@ -1091,5 +1061,8 @@ MnpSystemPoll (
   //\r
   MnpReceivePacket (MnpServiceData);\r
 \r
-  NetLibDispatchDpc ();\r
+  //\r
+  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
+  //\r
+  DispatchDpc ();\r
 }\r