]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c
NetworkPkg: Move Network library and drivers from MdeModulePkg to NetworkPkg
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpMain.c
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c
deleted file mode 100644 (file)
index d96178a..0000000
+++ /dev/null
@@ -1,789 +0,0 @@
-/** @file\r
-  Implementation of Managed Network Protocol public services.\r
-\r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "MnpImpl.h"\r
-\r
-/**\r
-  Returns the operational parameters for the current MNP child driver. May also\r
-  support returning the underlying SNP driver mode data.\r
-\r
-  The GetModeData() function is used to read the current mode data (operational\r
-  parameters) from the MNP or the underlying SNP.\r
-\r
-  @param[in]  This          Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[out] MnpConfigData Pointer to storage for MNP operational parameters. Type\r
-                            EFI_MANAGED_NETWORK_CONFIG_DATA is defined in "Related\r
-                            Definitions" below.\r
-  @param[out] SnpModeData   Pointer to storage for SNP operational parameters. This\r
-                            feature may be unsupported. Type EFI_SIMPLE_NETWORK_MODE\r
-                            is defined in the EFI_SIMPLE_NETWORK_PROTOCOL.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER This is NULL.\r
-  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this\r
-                                MNP implementation.\r
-  @retval EFI_NOT_STARTED       This MNP child driver instance has not been\r
-                                configured. The default values are returned in\r
-                                MnpConfigData if it is not NULL.\r
-  @retval Others                The mode data could not be read.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpGetModeData (\r
-  IN     EFI_MANAGED_NETWORK_PROTOCOL      *This,\r
-     OUT EFI_MANAGED_NETWORK_CONFIG_DATA   *MnpConfigData OPTIONAL,\r
-     OUT EFI_SIMPLE_NETWORK_MODE           *SnpModeData OPTIONAL\r
-  )\r
-{\r
-  MNP_INSTANCE_DATA           *Instance;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-  EFI_TPL                     OldTpl;\r
-  EFI_STATUS                  Status;\r
-  UINT32                      InterruptStatus;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (MnpConfigData != NULL) {\r
-    //\r
-    // Copy the instance configuration data.\r
-    //\r
-    CopyMem (MnpConfigData, &Instance->ConfigData, sizeof (*MnpConfigData));\r
-  }\r
-\r
-  if (SnpModeData != NULL) {\r
-    //\r
-    // Copy the underlayer Snp mode data.\r
-    //\r
-    Snp = Instance->MnpServiceData->MnpDeviceData->Snp;\r
-\r
-    //\r
-    // Upon successful return of GetStatus(), the Snp->Mode->MediaPresent\r
-    // will be updated to reflect any change of media status\r
-    //\r
-    Snp->GetStatus (Snp, &InterruptStatus, NULL);\r
-    CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData));\r
-  }\r
-\r
-  if (!Instance->Configured) {\r
-    Status = EFI_NOT_STARTED;\r
-  } else {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Sets or clears the operational parameters for the MNP child driver.\r
-\r
-  The Configure() function is used to set, change, or reset the operational\r
-  parameters for the MNP child driver instance. Until the operational parameters\r
-  have been set, no network traffic can be sent or received by this MNP child\r
-  driver instance. Once the operational parameters have been reset, no more\r
-  traffic can be sent or received until the operational parameters have been set\r
-  again.\r
-  Each MNP child driver instance can be started and stopped independently of\r
-  each other by setting or resetting their receive filter settings with the\r
-  Configure() function.\r
-  After any successful call to Configure(), the MNP child driver instance is\r
-  started. The internal periodic timer (if supported) is enabled. Data can be\r
-  transmitted and may be received if the receive filters have also been enabled.\r
-  Note: If multiple MNP child driver instances will receive the same packet\r
-  because of overlapping receive filter settings, then the first MNP child\r
-  driver instance will receive the original packet and additional instances will\r
-  receive copies of the original packet.\r
-  Note: Warning: Receive filter settings that overlap will consume extra\r
-  processor and/or DMA resources and degrade system and network performance.\r
-\r
-  @param[in]  This           Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  MnpConfigData  Pointer to configuration data that will be assigned\r
-                             to the MNP child driver instance. If NULL, the MNP\r
-                             child driver instance is reset to startup defaults\r
-                             and all pending transmit and receive requests are\r
-                             flushed. Type EFI_MANAGED_NETWORK_CONFIG_DATA is\r
-                             defined in EFI_MANAGED_NETWORK_PROTOCOL.GetModeData().\r
-\r
-  @retval EFI_SUCCESS            The operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is\r
-                                 TRUE:\r
-                                 * This is NULL.\r
-                                 * MnpConfigData.ProtocolTypeFilter is not\r
-                                   valid.\r
-                                 The operational data for the MNP child driver\r
-                                 instance is unchanged.\r
-  @retval EFI_OUT_OF_RESOURCES   Required system resources (usually memory)\r
-                                 could not be allocated.\r
-                                 The MNP child driver instance has been reset to\r
-                                 startup defaults.\r
-  @retval EFI_UNSUPPORTED        The requested feature is unsupported in\r
-                                 this [MNP] implementation. The operational data\r
-                                 for the MNP child driver instance is unchanged.\r
-  @retval EFI_DEVICE_ERROR       An unexpected network or system error\r
-                                 occurred. The MNP child driver instance has\r
-                                 been reset to startup defaults.\r
-  @retval Others                 The MNP child driver instance has been reset to\r
-                                 startup defaults.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpConfigure (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL        *This,\r
-  IN EFI_MANAGED_NETWORK_CONFIG_DATA     *MnpConfigData OPTIONAL\r
-  )\r
-{\r
-  MNP_INSTANCE_DATA  *Instance;\r
-  EFI_TPL            OldTpl;\r
-  EFI_STATUS         Status;\r
-\r
-  if ((This == NULL) ||\r
-      ((MnpConfigData != NULL) &&\r
-       (MnpConfigData->ProtocolTypeFilter > 0) &&\r
-       (MnpConfigData->ProtocolTypeFilter <= 1500))\r
-     ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if ((MnpConfigData == NULL) && (!Instance->Configured)) {\r
-    //\r
-    // If the instance is not configured and a reset is requested, just return.\r
-    //\r
-    Status = EFI_SUCCESS;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // Configure the instance.\r
-  //\r
-  Status = MnpConfigureInstance (Instance, MnpConfigData);\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Translates an IP multicast address to a hardware (MAC) multicast address. This\r
-  function may be unsupported in some MNP implementations.\r
-\r
-  The McastIpToMac() function translates an IP multicast address to a hardware\r
-  (MAC) multicast address. This function may be implemented by calling the\r
-  underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be\r
-  unsupported in some MNP implementations.\r
-\r
-  @param[in]  This        Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  Ipv6Flag    Set to TRUE to if IpAddress is an IPv6 multicast address.\r
-                          Set to FALSE if IpAddress is an IPv4 multicast address.\r
-  @param[in]  IpAddress   Pointer to the multicast IP address (in network byte\r
-                          order) to convert.\r
-  @param[out] MacAddress  Pointer to the resulting multicast MAC address.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:\r
-                                 * This is NULL.\r
-                                 * IpAddress is NULL.\r
-                                 * IpAddress is not a valid multicast IP\r
-                                   address.\r
-                                 * MacAddress is NULL.\r
-  @retval EFI_NOT_STARTED       This MNP child driver instance has not been\r
-                                configured.\r
-  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this\r
-                                MNP implementation.\r
-  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.\r
-  @retval Others                The address could not be converted.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpMcastIpToMac (\r
-  IN     EFI_MANAGED_NETWORK_PROTOCOL    *This,\r
-  IN     BOOLEAN                         Ipv6Flag,\r
-  IN     EFI_IP_ADDRESS                  *IpAddress,\r
-     OUT EFI_MAC_ADDRESS                 *MacAddress\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  MNP_INSTANCE_DATA           *Instance;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-  EFI_TPL                     OldTpl;\r
-  EFI_IPv6_ADDRESS            *Ip6Address;\r
-\r
-  if ((This == NULL) || (IpAddress == NULL) || (MacAddress == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Ip6Address = &IpAddress->v6;\r
-\r
-  if ((Ipv6Flag && !IP6_IS_MULTICAST (Ip6Address)) ||\r
-      (!Ipv6Flag && !IP4_IS_MULTICAST (EFI_NTOHL (*IpAddress)))\r
-      ) {\r
-    //\r
-    // The IP address passed in is not a multicast address.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  Snp = Instance->MnpServiceData->MnpDeviceData->Snp;\r
-  ASSERT (Snp != NULL);\r
-\r
-  ZeroMem (MacAddress, sizeof (EFI_MAC_ADDRESS));\r
-\r
-  if (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) {\r
-    if (!Ipv6Flag) {\r
-      //\r
-      // Translate the IPv4 address into a multicast MAC address if the NIC is an\r
-      // ethernet NIC according to RFC1112..\r
-      //\r
-      MacAddress->Addr[0] = 0x01;\r
-      MacAddress->Addr[1] = 0x00;\r
-      MacAddress->Addr[2] = 0x5E;\r
-      MacAddress->Addr[3] = (UINT8) (IpAddress->v4.Addr[1] & 0x7F);\r
-      MacAddress->Addr[4] = IpAddress->v4.Addr[2];\r
-      MacAddress->Addr[5] = IpAddress->v4.Addr[3];\r
-    } else {\r
-      //\r
-      // Translate the IPv6 address into a multicast MAC address if the NIC is an\r
-      // ethernet NIC according to RFC2464.\r
-      //\r
-\r
-      MacAddress->Addr[0] = 0x33;\r
-      MacAddress->Addr[1] = 0x33;\r
-      MacAddress->Addr[2] = Ip6Address->Addr[12];\r
-      MacAddress->Addr[3] = Ip6Address->Addr[13];\r
-      MacAddress->Addr[4] = Ip6Address->Addr[14];\r
-      MacAddress->Addr[5] = Ip6Address->Addr[15];\r
-    }\r
-\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    //\r
-    // Invoke Snp to translate the multicast IP address.\r
-    //\r
-    Status = Snp->MCastIpToMac (\r
-                    Snp,\r
-                    Ipv6Flag,\r
-                    IpAddress,\r
-                    MacAddress\r
-                    );\r
-  }\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Enables and disables receive filters for multicast address. This function may\r
-  be unsupported in some MNP implementations.\r
-\r
-  The Groups() function only adds and removes multicast MAC addresses from the\r
-  filter list. The MNP driver does not transmit or process Internet Group\r
-  Management Protocol (IGMP) packets. If JoinFlag is FALSE and MacAddress is\r
-  NULL, then all joined groups are left.\r
-\r
-  @param[in]  This        Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  JoinFlag    Set to TRUE to join this multicast group.\r
-                          Set to FALSE to leave this multicast group.\r
-  @param[in]  MacAddress  Pointer to the multicast MAC group (address) to join or\r
-                          leave.\r
-\r
-  @retval EFI_SUCCESS           The requested operation completed successfully.\r
-  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
-                                * This is NULL.\r
-                                * JoinFlag is TRUE and MacAddress is NULL.\r
-                                * MacAddress is not a valid multicast MAC\r
-                                  address.\r
-                                * The MNP multicast group settings are\r
-                                  unchanged.\r
-  @retval EFI_NOT_STARTED       This MNP child driver instance has not been\r
-                                configured.\r
-  @retval EFI_ALREADY_STARTED   The supplied multicast group is already joined.\r
-  @retval EFI_NOT_FOUND         The supplied multicast group is not joined.\r
-  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.\r
-                                The MNP child driver instance has been reset to\r
-                                startup defaults.\r
-  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this MNP\r
-                                implementation.\r
-  @retval Others                The requested operation could not be completed.\r
-                                The MNP multicast group settings are unchanged.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpGroups (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                         JoinFlag,\r
-  IN EFI_MAC_ADDRESS                 *MacAddress OPTIONAL\r
-  )\r
-{\r
-  MNP_INSTANCE_DATA       *Instance;\r
-  EFI_SIMPLE_NETWORK_MODE *SnpMode;\r
-  MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;\r
-  MNP_GROUP_ADDRESS       *GroupAddress;\r
-  LIST_ENTRY              *ListEntry;\r
-  BOOLEAN                 AddressExist;\r
-  EFI_TPL                 OldTpl;\r
-  EFI_STATUS              Status;\r
-\r
-  if (This == NULL || (JoinFlag && (MacAddress == NULL))) {\r
-    //\r
-    // This is NULL, or it's a join operation but MacAddress is NULL.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance  = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-  SnpMode   = Instance->MnpServiceData->MnpDeviceData->Snp->Mode;\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  if ((!Instance->ConfigData.EnableMulticastReceive) ||\r
-    ((MacAddress != NULL) && !NET_MAC_IS_MULTICAST (MacAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize))) {\r
-    //\r
-    // The instance isn't configured to do mulitcast receive. OR\r
-    // the passed in MacAddress is not a mutlticast mac address.\r
-    //\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  Status       = EFI_SUCCESS;\r
-  AddressExist = FALSE;\r
-  GroupCtrlBlk = NULL;\r
-\r
-  if (MacAddress != NULL) {\r
-    //\r
-    // Search the instance's GroupCtrlBlkList to find the specific address.\r
-    //\r
-    NET_LIST_FOR_EACH (ListEntry, &Instance->GroupCtrlBlkList) {\r
-\r
-      GroupCtrlBlk = NET_LIST_USER_STRUCT (\r
-                      ListEntry,\r
-                      MNP_GROUP_CONTROL_BLOCK,\r
-                      CtrlBlkEntry\r
-                      );\r
-      GroupAddress = GroupCtrlBlk->GroupAddress;\r
-      if (0 == CompareMem (\r
-                MacAddress,\r
-                &GroupAddress->Address,\r
-                SnpMode->HwAddressSize\r
-                )) {\r
-        //\r
-        // There is already the same multicast mac address configured.\r
-        //\r
-        AddressExist = TRUE;\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (JoinFlag && AddressExist) {\r
-      //\r
-      // The multicast mac address to join already exists.\r
-      //\r
-      Status = EFI_ALREADY_STARTED;\r
-    }\r
-\r
-    if (!JoinFlag && !AddressExist) {\r
-      //\r
-      // The multicast mac address to leave doesn't exist in this instance.\r
-      //\r
-      Status = EFI_NOT_FOUND;\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_EXIT;\r
-    }\r
-  } else if (IsListEmpty (&Instance->GroupCtrlBlkList)) {\r
-    //\r
-    // The MacAddress is NULL and there is no configured multicast mac address,\r
-    // just return.\r
-    //\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // OK, it is time to take action.\r
-  //\r
-  Status = MnpGroupOp (Instance, JoinFlag, MacAddress, GroupCtrlBlk);\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Places asynchronous outgoing data packets into the transmit queue.\r
-\r
-  The Transmit() function places a completion token into the transmit packet\r
-  queue. This function is always asynchronous.\r
-  The caller must fill in the Token.Event and Token.TxData fields in the\r
-  completion token, and these fields cannot be NULL. When the transmit operation\r
-  completes, the MNP updates the Token.Status field and the Token.Event is\r
-  signaled.\r
-  Note: There may be a performance penalty if the packet needs to be\r
-  defragmented before it can be transmitted by the network device. Systems in\r
-  which performance is critical should review the requirements and features of\r
-  the underlying communications device and drivers.\r
-\r
-\r
-  @param[in]  This    Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  Token   Pointer to a token associated with the transmit data\r
-                      descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN\r
-                      is defined in "Related Definitions" below.\r
-\r
-  @retval EFI_SUCCESS            The transmit completion token was cached.\r
-  @retval EFI_NOT_STARTED        This MNP child driver instance has not been\r
-                                 configured.\r
-  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is\r
-                                 TRUE:\r
-                                 * This is NULL.\r
-                                 * Token is NULL.\r
-                                 * Token.Event is NULL.\r
-                                 * Token.TxData is NULL.\r
-                                 * Token.TxData.DestinationAddress is not\r
-                                   NULL and Token.TxData.HeaderLength is zero.\r
-                                 * Token.TxData.FragmentCount is zero.\r
-                                 * (Token.TxData.HeaderLength +\r
-                                   Token.TxData.DataLength) is not equal to the\r
-                                   sum of the\r
-                                   Token.TxData.FragmentTable[].FragmentLength\r
-                                   fields.\r
-                                 * One or more of the\r
-                                   Token.TxData.FragmentTable[].FragmentLength\r
-                                   fields is zero.\r
-                                 * One or more of the\r
-                                   Token.TxData.FragmentTable[].FragmentBufferfields\r
-                                   is NULL.\r
-                                 * Token.TxData.DataLength is greater than MTU.\r
-  @retval EFI_ACCESS_DENIED      The transmit completion token is already in the\r
-                                 transmit queue.\r
-  @retval EFI_OUT_OF_RESOURCES   The transmit data could not be queued due to a\r
-                                 lack of system resources (usually memory).\r
-  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.\r
-                                 The MNP child driver instance has been reset to\r
-                                 startup defaults.\r
-  @retval EFI_NOT_READY          The transmit request could not be queued because\r
-                                 the transmit queue is full.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpTransmit (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL            *This,\r
-  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN    *Token\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  MNP_INSTANCE_DATA *Instance;\r
-  MNP_SERVICE_DATA  *MnpServiceData;\r
-  UINT8             *PktBuf;\r
-  UINT32            PktLen;\r
-  EFI_TPL           OldTpl;\r
-\r
-  if ((This == NULL) || (Token == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  if (!MnpIsValidTxToken (Instance, Token)) {\r
-    //\r
-    // The Token is invalid.\r
-    //\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  MnpServiceData = Instance->MnpServiceData;\r
-  NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r
-\r
-  //\r
-  // Build the tx packet\r
-  //\r
-  Status = MnpBuildTxPacket (MnpServiceData, Token->Packet.TxData, &PktBuf, &PktLen);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  //  OK, send the packet synchronously.\r
-  //\r
-  Status = MnpSyncSendPacket (MnpServiceData, PktBuf, PktLen, Token);\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Places an asynchronous receiving request into the receiving queue.\r
-\r
-  The Receive() function places a completion token into the receive packet\r
-  queue. This function is always asynchronous.\r
-  The caller must fill in the Token.Event field in the completion token, and\r
-  this field cannot be NULL. When the receive operation completes, the MNP\r
-  updates the Token.Status and Token.RxData fields and the Token.Event is\r
-  signaled.\r
-\r
-  @param[in]  This      Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  Token     Pointer to a token associated with the receive\r
-                        data descriptor. Type\r
-                        EFI_MANAGED_NETWORK_COMPLETION_TOKEN is defined in\r
-                        EFI_MANAGED_NETWORK_PROTOCOL.Transmit().\r
-\r
-  @retval EFI_SUCCESS            The receive completion token was cached.\r
-  @retval EFI_NOT_STARTED        This MNP child driver instance has not been\r
-                                 configured.\r
-  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is\r
-                                 TRUE:\r
-                                 * This is NULL.\r
-                                 * Token is NULL.\r
-                                 * Token.Event is NULL\r
-  @retval EFI_OUT_OF_RESOURCES   The transmit data could not be queued due to a\r
-                                 lack of system resources (usually memory).\r
-  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.\r
-                                 The MNP child driver instance has been reset to\r
-                                 startup defaults.\r
-  @retval EFI_ACCESS_DENIED      The receive completion token was already in the\r
-                                 receive queue.\r
-  @retval EFI_NOT_READY          The receive request could not be queued because\r
-                                 the receive queue is full.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpReceive (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL            *This,\r
-  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN    *Token\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  MNP_INSTANCE_DATA  *Instance;\r
-  EFI_TPL            OldTpl;\r
-\r
-  if ((This == NULL) || (Token == NULL) || (Token->Event == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // Check whether this token(event) is already in the rx token queue.\r
-  //\r
-  Status = NetMapIterate (&Instance->RxTokenMap, MnpTokenExist, (VOID *) Token);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // Insert the Token into the RxTokenMap.\r
-  //\r
-  Status = NetMapInsertTail (&Instance->RxTokenMap, (VOID *) Token, NULL);\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Try to deliver any buffered packets.\r
-    //\r
-    Status = MnpInstanceDeliverPacket (Instance);\r
-\r
-    //\r
-    // Dispatch the DPC queued by the NotifyFunction of Token->Event.\r
-    //\r
-    DispatchDpc ();\r
-  }\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Aborts an asynchronous transmit or receive request.\r
-\r
-  The Cancel() function is used to abort a pending transmit or receive request.\r
-  If the token is in the transmit or receive request queues, after calling this\r
-  function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r
-  signaled. If the token is not in one of the queues, which usually means that\r
-  the asynchronous operation has completed, this function will not signal the\r
-  token and EFI_NOT_FOUND is returned.\r
-\r
-  @param[in]  This     Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-  @param[in]  Token    Pointer to a token that has been issued by\r
-                       EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or\r
-                       EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all\r
-                       pending tokens are aborted.\r
-\r
-  @retval EFI_SUCCESS            The asynchronous I/O request was aborted and\r
-                                 Token.Event was signaled. When Token is NULL,\r
-                                 all pending requests were aborted and their\r
-                                 events were signaled.\r
-  @retval EFI_NOT_STARTED        This MNP child driver instance has not been\r
-                                 configured.\r
-  @retval EFI_INVALID_PARAMETER  This is NULL.\r
-  @retval EFI_NOT_FOUND          When Token is not NULL, the asynchronous I/O\r
-                                 request was not found in the transmit or\r
-                                 receive queue. It has either completed or was\r
-                                 not issued by Transmit() and Receive().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpCancel (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL            *This,\r
-  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN    *Token OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  MNP_INSTANCE_DATA  *Instance;\r
-  EFI_TPL            OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // Iterate the RxTokenMap to cancel the specified Token.\r
-  //\r
-  Status = NetMapIterate (&Instance->RxTokenMap, MnpCancelTokens, (VOID *) Token);\r
-  if (Token != NULL) {\r
-    Status = (Status == EFI_ABORTED) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Dispatch the DPC queued by the NotifyFunction of the cancled token's events.\r
-  //\r
-  DispatchDpc ();\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Polls for incoming data packets and processes outgoing data packets.\r
-\r
-  The Poll() function can be used by network drivers and applications to\r
-  increase the rate that data packets are moved between the communications\r
-  device and the transmit and receive queues.\r
-  Normally, a periodic timer event internally calls the Poll() function. But, in\r
-  some systems, the periodic timer event may not call Poll() fast enough to\r
-  transmit and/or receive all data packets without missing packets. Drivers and\r
-  applications that are experiencing packet loss should try calling the Poll()\r
-  function more often.\r
-\r
-  @param[in]  This         Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCCESS      Incoming or outgoing data was processed.\r
-  @retval EFI_NOT_STARTED  This MNP child driver instance has not been\r
-                           configured.\r
-  @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The\r
-                           MNP child driver instance has been reset to startup\r
-                           defaults.\r
-  @retval EFI_NOT_READY    No incoming or outgoing data was processed. Consider\r
-                           increasing the polling rate.\r
-  @retval EFI_TIMEOUT      Data was dropped out of the transmit and/or receive\r
-                           queue. Consider increasing the polling rate.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MnpPoll (\r
-  IN EFI_MANAGED_NETWORK_PROTOCOL    *This\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  MNP_INSTANCE_DATA  *Instance;\r
-  EFI_TPL            OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = MNP_INSTANCE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  if (!Instance->Configured) {\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  //\r
-  // Try to receive packets.\r
-  //\r
-  Status = MnpReceivePacket (Instance->MnpServiceData->MnpDeviceData);\r
-\r
-  //\r
-  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
-  //\r
-  DispatchDpc ();\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r