]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Statistics.c
NetworkPkg: Move Network library and drivers from MdeModulePkg to NetworkPkg
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Statistics.c
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Statistics.c b/MdeModulePkg/Universal/Network/SnpDxe/Statistics.c
deleted file mode 100644 (file)
index 480e261..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/** @file\r
-    Implementation of collecting the statistics on a network interface.\r
-\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "Snp.h"\r
-\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  This function resets or collects the statistics on a network interface. If the\r
-  size of the statistics table specified by StatisticsSize is not big enough for\r
-  all the statistics that are collected by the network interface, then a partial\r
-  buffer of statistics is returned in StatisticsTable, StatisticsSize is set to\r
-  the size required to collect all the available statistics, and\r
-  EFI_BUFFER_TOO_SMALL is returned.\r
-  If StatisticsSize is big enough for all the statistics, then StatisticsTable\r
-  will be filled, StatisticsSize will be set to the size of the returned\r
-  StatisticsTable structure, and EFI_SUCCESS is returned.\r
-  If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
-  If Reset is FALSE, and both StatisticsSize and StatisticsTable are NULL, then\r
-  no operations will be performed, and EFI_SUCCESS will be returned.\r
-  If Reset is TRUE, then all of the supported statistics counters on this network\r
-  interface will be reset to zero.\r
-\r
-  @param This            A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
-  @param Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param StatisticsSize  On input the size, in bytes, of StatisticsTable. On output\r
-                         the size, in bytes, of the resulting table of statistics.\r
-  @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                         contains the statistics. Type EFI_NETWORK_STATISTICS is\r
-                         defined in "Related Definitions" below.\r
-\r
-  @retval EFI_SUCCESS           The requested operation succeeded.\r
-  @retval EFI_NOT_STARTED       The Simple Network Protocol interface has not been\r
-                                started by calling Start().\r
-  @retval EFI_BUFFER_TOO_SMALL  StatisticsSize is not NULL and StatisticsTable is\r
-                                NULL. The current buffer size that is needed to\r
-                                hold all the statistics is returned in StatisticsSize.\r
-  @retval EFI_BUFFER_TOO_SMALL  StatisticsSize is not NULL and StatisticsTable is\r
-                                not NULL. The current buffer size that is needed\r
-                                to hold all the statistics is returned in\r
-                                StatisticsSize. A partial set of statistics is\r
-                                returned in StatisticsTable.\r
-  @retval EFI_INVALID_PARAMETER StatisticsSize is NULL and StatisticsTable is not\r
-                                NULL.\r
-  @retval EFI_DEVICE_ERROR      The Simple Network Protocol interface has not\r
-                                been initialized by calling Initialize().\r
-  @retval EFI_DEVICE_ERROR      An error was encountered collecting statistics\r
-                                from the NIC.\r
-  @retval EFI_UNSUPPORTED       The NIC does not support collecting statistics\r
-                                from the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SnpUndi32Statistics (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
-  IN BOOLEAN                     Reset,\r
-  IN OUT UINTN                   *StatisticsSize, OPTIONAL\r
-  IN OUT EFI_NETWORK_STATISTICS  *StatisticsTable OPTIONAL\r
-  )\r
-{\r
-  SNP_DRIVER        *Snp;\r
-  PXE_DB_STATISTICS *Db;\r
-  UINT64            *Stp;\r
-  UINT64            Mask;\r
-  UINTN             Size;\r
-  UINTN             Index;\r
-  EFI_TPL           OldTpl;\r
-  EFI_STATUS        Status;\r
-\r
-  //\r
-  // Get pointer to SNP driver instance for *This.\r
-  //\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  //\r
-  // Return error if the SNP is not initialized.\r
-  //\r
-  switch (Snp->Mode.State) {\r
-  case EfiSimpleNetworkInitialized:\r
-    break;\r
-\r
-  case EfiSimpleNetworkStopped:\r
-    Status = EFI_NOT_STARTED;\r
-    goto ON_EXIT;\r
-\r
-  default:\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto ON_EXIT;\r
-  }\r
-  //\r
-  // if we are not resetting the counters, we have to have a valid stat table\r
-  // with >0 size. if no reset, no table and no size, return success.\r
-  //\r
-  if (!Reset && StatisticsSize == NULL) {\r
-    Status = (StatisticsTable != NULL) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;\r
-    goto ON_EXIT;\r
-  }\r
-  //\r
-  // Initialize UNDI Statistics CDB\r
-  //\r
-  Snp->Cdb.OpCode     = PXE_OPCODE_STATISTICS;\r
-  Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
-  Snp->Cdb.CPBaddr    = PXE_CPBADDR_NOT_USED;\r
-  Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
-  Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
-  Snp->Cdb.IFnum      = Snp->IfNum;\r
-  Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
-\r
-  if (Reset) {\r
-    Snp->Cdb.OpFlags  = PXE_OPFLAGS_STATISTICS_RESET;\r
-    Snp->Cdb.DBsize   = PXE_DBSIZE_NOT_USED;\r
-    Snp->Cdb.DBaddr   = PXE_DBADDR_NOT_USED;\r
-    Db                = Snp->Db;\r
-  } else {\r
-    Snp->Cdb.OpFlags                = PXE_OPFLAGS_STATISTICS_READ;\r
-    Snp->Cdb.DBsize                 = (UINT16) sizeof (PXE_DB_STATISTICS);\r
-    Snp->Cdb.DBaddr                 = (UINT64)(UINTN) (Db = Snp->Db);\r
-  }\r
-  //\r
-  // Issue UNDI command and check result.\r
-  //\r
-  DEBUG ((EFI_D_NET, "\nsnp->undi.statistics()  "));\r
-\r
-  (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
-\r
-  switch (Snp->Cdb.StatCode) {\r
-  case PXE_STATCODE_SUCCESS:\r
-    break;\r
-\r
-  case PXE_STATCODE_UNSUPPORTED:\r
-    DEBUG (\r
-      (EFI_D_ERROR,\r
-      "\nsnp->undi.statistics()  %xh:%xh\n",\r
-      Snp->Cdb.StatFlags,\r
-      Snp->Cdb.StatCode)\r
-      );\r
-\r
-    Status = EFI_UNSUPPORTED;\r
-    goto ON_EXIT;\r
-\r
-  default:\r
-    DEBUG (\r
-      (EFI_D_ERROR,\r
-      "\nsnp->undi.statistics()  %xh:%xh\n",\r
-      Snp->Cdb.StatFlags,\r
-      Snp->Cdb.StatCode)\r
-      );\r
-\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  if (Reset) {\r
-    Status = EFI_SUCCESS;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  if (StatisticsTable == NULL) {\r
-    *StatisticsSize = sizeof (EFI_NETWORK_STATISTICS);\r
-    Status = EFI_BUFFER_TOO_SMALL;\r
-    goto ON_EXIT;\r
-  }\r
-  //\r
-  // Convert the UNDI statistics information to SNP statistics\r
-  // information.\r
-  //\r
-  ZeroMem (StatisticsTable, *StatisticsSize);\r
-  Stp   = (UINT64 *) StatisticsTable;\r
-  Size  = 0;\r
-\r
-  for (Index = 0, Mask = 1; Index < 64; Index++, Mask = LShiftU64 (Mask, 1), Stp++) {\r
-    //\r
-    // There must be room for a full UINT64.  Partial\r
-    // numbers will not be stored.\r
-    //\r
-    if ((Index + 1) * sizeof (UINT64) > *StatisticsSize) {\r
-      break;\r
-    }\r
-\r
-    if ((Db->Supported & Mask) != 0) {\r
-      *Stp  = Db->Data[Index];\r
-      Size  = Index + 1;\r
-    } else {\r
-      SetMem (Stp, sizeof (UINT64), 0xFF);\r
-    }\r
-  }\r
-  //\r
-  // Compute size up to last supported statistic.\r
-  //\r
-  while (++Index < 64) {\r
-    if ((Db->Supported & (Mask = LShiftU64 (Mask, 1))) != 0) {\r
-      Size = Index;\r
-    }\r
-  }\r
-\r
-  Size *= sizeof (UINT64);\r
-\r
-  if (*StatisticsSize >= Size) {\r
-    *StatisticsSize = Size;\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    *StatisticsSize = Size;\r
-    Status = EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-ON_EXIT:\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r