-- Copyright (C) 1984  by Xerox Corporation. All rights reserved. 
-- File: StatsStrings.mesa,  (Last Edit: AOF  5-Sep-84 13:45:42)

DIRECTORY
  String USING [EquivalentString],
  Stats USING [StatCounterIndex],
  StatsOps USING [];

StatsStrings: MONITOR IMPORTS String EXPORTS Stats, StatsOps =
  BEGIN OPEN Stats;


  statText: PUBLIC ARRAY StatCounterIndex OF LONG STRING ←
    [

      --GENERAL
      statMouseTrap: "***** MouseTrap *****",
      statTime: "MilliSeconds Wall Time",
      statSeconds: "Seconds",
      statHours: "Hours",

      --QUEUE PACKAGE
      statEnqueue: "Buffers Enqueued",
      statDequeue: "Buffers Dequeued",
      statXqueue: "Buffers extracted from a queue",
      statDequeueNIL: "Empty Dequeue calls",
      statXqueueNIL: "Empty ExtractFromQueue calls",

      --BUFFER MANAGEMENT
      statNoBuffer: "FreeQueue Empty",
      statBufferWaits: "Waits for a Buffer",
      statBufferNIL: "Buffer returned NIL",
      statAddCluster: "Buffer cluster added",
      statNoCredit: "Buffer not credited",
      statClusterWait: "Wait for cluster allocation",
      statGetSmallBuffer: "Small buffer allocated",
      statGetFullBuffer: "Full buffer allocated",
      statPoolCreated: "Buffer pool created",
      statPreallocateCluster: "New cluster projected",

      --ROUTER
      statZappedP: "Zapped Packets",
      statJunkBroadcastPups: "Junk Broadcast Pups",
      statJunkBroadcastNS: "Junk Broadcast NS Packets",
      statJunkPupsForUsNoLocalSocket: "Junk Pups For Us - No Local Socket",
      statJunkNSForUsNoLocalSocket: "Junk NS Packets For Us - No Local Socket",
      statPacketsDiscarded: "Packets Discarded",
      statPupsDiscarded: "Pups Discarded",
      statNSDiscarded: "NS Packets Discarded",
      statPupReceived: "Pups Received",
      statNSReceived: "NS Packets Received",
      statPupForwarded: "Pups Forwarded",
      statNSForwarded: "NS Packets Forwarded",
      statPupSent: "Pups Sent",
      statNSSent: "NS Packets Sent",
      statPupBroadcast: "Pups Broadcast",
      statNSBroadcast: "NS Packets Broadcast",
      statPupGatewayPacketsRecv: "Pup Gateway Info Packets Received",
      statNSGatewayPacketsRecv: "NS Gateway Info Packets Received",
      statErrorPupsSent: "Error Pups sent",
      statNSErrorPacketsSent: "NS Error Packets sent",
      statPupsSentNowhere: "Pups Sent to Unknown Network",
      statNSSentNowhere: "NS Packets Sent to Unknown Network",
      statPupNotForwarded: "Pups Not Forwarded",
      statNSNotForwarded: "NS Packets Not Forwarded",
      statPupInputQueueOverflow: "Pups recycled - Input Queue Full",
      statNSInputQueueOverflow: "NS Packets recycled - Input Queue Full",
      pupTooShort: "Pups received with length less than 22 bytes ***",
      statReceivedBadPupChecksum: "Pups received/w Bad Software Checksum ***",
      statReceivedBadNSChecksum: "NS received/w Bad Software Checksum ***",

      --ROUTING TABLE
      statCacheFaults: "Routing table cache faults",
      statGratReceived: "Gratuitous routing information received",
      statDirectedReceived: "Directed routing information received",
      statBroadcastRequest: "Broadcasts for routing information",
      statCacheFlushed: "Routing table cache flushes",

      -- Socket level debugging
      pupsEchoed: "Pups Echoed",
      pupsBadEchoed: "Pups Echoed with bad checksum",
      pupBytesEchoed: "Bytes in Pups Echoed",
      packetsEchoed: "Packets Echoed",
      packetsBadEchoed: "Packets Echoed with bad checksum",
      bytesEchoed: "Bytes Echoed",

      -- Ethernet Hardware Interface
      statEtherPacketsSent: "Ether Packets Sent",
      statEtherWordsSent: "Ether Words Sent",
      statEtherPacketsReceived: "Ether Packets Received",
      statEtherWordsReceived: "Ether Words Received",
      statEtherPacketsLocal: "Ether Packets copied Locally",
      statEtherWordsLocal: "Ether Words copied Locally",
      statEtherInUnderOut: "Ether Packets Received while Sending - InUnderOut",

      -- Collisions
      statEtherSendsCollision1: "Collisions - once",
      statEtherSendsCollision2: "Collisions - twice",
      statEtherSendsCollision3: "Collisions - 3",
      statEtherSendsCollision4: "Collisions - 4",
      statEtherSendsCollision5: "Collisions - 5",
      statEtherSendsCollision6: "Collisions - 6",
      statEtherSendsCollision7: "Collisions - 7",
      statEtherSendsCollision8: "Collisions - 8",
      statEtherSendsCollision9: "Collisions - 9",
      statEtherSendsCollision10: "Collisions - 10",
      statEtherSendsCollision11: "Collisions - 11",
      statEtherSendsCollision12: "Collisions - 12",
      statEtherSendsCollision13: "Collisions - 13",
      statEtherSendsCollision14: "Collisions - 14",
      statEtherSendsCollision15: "Collisions - 15",
      statEtherSendsCollisionLoadOverflow: "Collisions - too many",

      -- Ethernet driver Glitches
      statEtherLostInterrupts: "Lost Ethernet Interrupts  ************",
      statEtherMissingStatus: "Missing Ethernet Interrupt Status",
      statEtherInterruptDuringInterrupt: "Ethernet Interrupts during Interrupt",
      statResetDidntPost: "Ethernet Resets didn't Post  ************",
      statInterfaceReset: "Ethernet interface reset",
      statPacketsStuckInOutput: "Ethernet packets stuck in output",
      statInputIdle: "Ethernet input idle too long",
      statsIocbWait: "Driver wait for IOCB",

      -- receiver funnys
      statEtherReceivedNot16: "Ethernet Receiver Not 16 and OK CRC ******",
      statEtherReceivedNot16BadCRC: "Ethernet Receiver Not 16 and Bad CRC",
      statEtherReceivedBadCRC: "Ethernet Receiver with Bad CRC ***",
      statEtherReceivedOverrun: "Ethernet Receiver Overran",
      statEtherReceivedBadStatus: "Ethernet Receiver Bad Status",
      statEtherReceivedTooLong: "Ethernet Packets received that were Too Long",
      statEtherReceivedKlobberedByReset:
        "Ethernet send packets klobbered by reset",
      statEtherEmptyFreeQueue: "Ethernet Packets Recycled - FreeQueue Empty",
      statEtherEmptyNoBuffer: "Ethernet Packets Missed - No Buffer ready",
      statEtherEmptyInputChain: "Ethernet Input Chain was Empty",

      -- transmitter funnys
      statEtherSendWhileReceiving: "Ethernet Packets Sent while Pouring In",
      statEtherSendOverrun: "Ethernet Transmitter Overrun",
      statEtherSendBadStatus: "Ethernet Transmitter Bad Status",
      statEtherSendFromOutputQueue: "Output queued when queue not empty",

      -- 8/32/48 translation things
      cacheFault: "Translation cache faults",
      unsuccessfulTranslation: "Translation failures",
      translationRetries: "Translation retries",
      requestsForMe: "Translation requests for ME",
      cacheDepth: "Translation cache hops",

      -- Streams
      statDataPacketsSent: "Data Packets Sent",
      statDataBytesSent: "Data Bytes Sent",
      statDataPacketsReceived: "Data Packets Received",
      statDataBytesReceived: "Data Bytes Received", statMarksSent: "Marks Sent",
      statMarksReceived: "Marks Received",
      statAckRequestsSent: "Ack Requests Sent",
      statAckRequestsReceived: "Ack Requests Received", statAcksSent: "Acks Sent",
      statAcksReceived: "Acks Received",
      statSystemPacketsSent: "System Packets Sent",
      statSystemPacketsReceived: "System Packets Received",
      statAttentionsSent: "Attentions Sent",
      statAttentionsReceived: "Attentions Received",

      statDataPacketsRetransmitted: "Data Packets Retransmitted",
      statErrorPacketsSent: "Error Packets Sent",
      statErrorPacketsReceived: "Error Packets Received",

      statDataPacketsReceivedAgain: "Data Packets Received Again",
      statDataPacketsReceivedEarly: "Data Packets Received Early",
      statDataPacketsReceivedVeryLate: "Data Packets Received Very Late",

      statProbesSent: "Probes Sent", statProbesReceived: "Probes Received",
      statEmptyFunnys: "Funny Empty Packets", statEmptyAlloc: "Empty Allocates",
      statDuplicateAcks: "Duplicate Acks",

      statPacketsRejectedBadID: "Packets Rejected - Bad ID",
      statPacketsRejectedBadSource: "Packets Rejected - Bad Source",
      statPacketsRejectedBadType: "Packets Rejected - Bad Type",



      -- spares for user use
      statSpares0: NIL, statSpares1: NIL, statSpares2: NIL, statSpares3: NIL,
      statSpares4: NIL, statSpares5: NIL, statSpares6: NIL, statSpares7: NIL,
      statSpares8: NIL, statSpares9: NIL, statSpares10: NIL, statSpares11: NIL,
      statSpares12: NIL, statSpares13: NIL, statSpares14: NIL, statSpares15: NIL,
      statSpares16: NIL, statSpares17: NIL, statSpares18: NIL, statSpares19: NIL,
      statSpares20: NIL, statSpares21: NIL, statSpares22: NIL, statSpares23: NIL,
      statSpares24: NIL, statSpares25: NIL, statSpares26: NIL, statSpares27: NIL,
      statSpares28: NIL, statSpares29: NIL, statSpares30: NIL, statSpares31: NIL,
      statSpares32: NIL, statSpares33: NIL, statSpares34: NIL, statSpares35: NIL,
      statSpares36: NIL, statSpares37: NIL, statSpares38: NIL, statSpares39: NIL,
      statSpares40: NIL, statSpares41: NIL, statSpares42: NIL, statSpares43: NIL,
      statSpares44: NIL, statSpares45: NIL, statSpares46: NIL, statSpares47: NIL,
      statSpares48: NIL, statSpares49: NIL, statSpares50: NIL, statSpares51: NIL,
      statSpares52: NIL, statSpares53: NIL, statSpares54: NIL, statSpares55: NIL,
      statSpares56: NIL, statSpares57: NIL, statSpares58: NIL, statSpares59: NIL,
      statSpares60: NIL, statSpares61: NIL, statSpares62: NIL, statSpares63: NIL,
      statSpares64: NIL, statSpares65: NIL, statSpares66: NIL, statSpares67: NIL,
      statSpares68: NIL, statSpares69: NIL, statSpares70: NIL, statSpares71: NIL,
      statSpares72: NIL, statSpares73: NIL, statSpares74: NIL, statSpares75: NIL,
      statSpares76: NIL, statSpares77: NIL, statSpares78: NIL, statSpares79: NIL,
      statSpares80: NIL, statSpares81: NIL, statSpares82: NIL, statSpares83: NIL,
      statSpares84: NIL, statSpares85: NIL, statSpares86: NIL, statSpares87: NIL,
      statSpares88: NIL, statSpares89: NIL, statSpares90: NIL, statSpares91: NIL,
      statSpares92: NIL, statSpares93: NIL, statSpares94: NIL, statSpares95: NIL,
      statSpares96: NIL, statSpares97: NIL, statSpares98: NIL, statSpares99: NIL];

  StatsStringsFull: PUBLIC ERROR = CODE;

  StatsStringToIndex: PUBLIC ENTRY PROCEDURE [s: LONG STRING]
    RETURNS [i: StatCounterIndex] =
    BEGIN
    -- first, check for the string already existing
    FOR i IN StatCounterIndex DO
      IF statText[i] # NIL AND String.EquivalentString[s, statText[i]] THEN
	RETURN;
      ENDLOOP;
    -- its not here yet, find a slot for it
    FOR i IN StatCounterIndex DO
      IF statText[i] = NIL THEN EXIT;
      REPEAT FINISHED => ERROR StatsStringsFull;
      ENDLOOP;
    statText[i] ← s; -- NB: Not copied over

    END;

  StatsGetText: PUBLIC PROCEDURE
    RETURNS [POINTER TO ARRAY StatCounterIndex OF LONG STRING] =
    BEGIN RETURN[@statText]; END;

  -- initialization

  END.