Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuIngressAckNakErr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuIngressAckNakErr.vr
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35class ilupeuIngressAckNakErr extends PEUStrBase
36 {
37 integer f_errQueue; // A mailbox for bad pkt headers
38
39 integer nmbrAckNakErrsToInject = 10; //Total number of packets that get error injected
40 //Set the percentage weight of each type of receiver error
41 integer DLLPAckLessthanAckedErrWeight = 10;
42 integer DLLPNakLessthanAckedErrWeight = 10;
43 integer DLLPAckmorethanTLPNxtSeqErrWeight = 10;
44 integer DLLPNakmorethanTLPNxtSeqErrWeight = 10;
45 denaliPcieEiTypeT DenaliErrortype;
46 string DLLPtype;
47
48 //Only allow 1 of these strategies to be active at a time
49 static integer AckNakErr_semaphore = alloc(SEMAPHORE, 0, 1, 1);
50
51 task new( PEUTestEnv a_env )
52 {
53 super.new( a_env );
54 f_errQueue = 0;
55 }
56
57 task SetErrQueue( integer a_queue )
58 {
59 f_errQueue = a_queue;
60 } /* end SetErrQueue */
61
62 task Execute()
63 {
64 integer nmbrErrs;
65 integer DLLPAckNakErrsInject_freq = 100; // freq of clock cycles to inject this error
66 integer nmbrDLLPAckNakErrsInjected;
67 integer SeqNum = 0 ;
68 integer seqnum_adjust = 2;
69 string value = "";
70 integer DLP_error_inject = 0;
71
72
73 //Get the semaphore when its your turn
74 semaphore_get( WAIT, AckNakErr_semaphore, 1);
75
76
77 //Clear all the specific error trackers
78 nmbrDLLPAckNakErrsInjected = 0;
79
80 // create random number to cause Ack/Nak DLLP type
81 DLLPAckNakErrsInject_freq = (urandom() % 20) + 20;
82
83// PCIEDllpTrans = new( Pod.FNXPCIEBldr );
84
85 //inject errors until all the errors are injected
86 while (nmbrAckNakErrsToInject > nmbrDLLPAckNakErrsInjected) {
87
88
89 // adjust sequence number by 2 to 4097
90 // seqnum_adjust = (urandom() % 50) + 2;
91 seqnum_adjust = (urandom() % 4095) + 2;
92
93 //determine the type of errors inject based on the weight specified in the testcase
94 randcase {
95 // DLLPAckLessthanAckedErrWeight: {SeqNum = f_env.AckdSeqNum - 1; DLLPtype = "ack"; value = "less than"; }
96 // DLLPNakLessthanAckedErrWeight : {SeqNum = f_env.AckdSeqNum - 1; DLLPtype = "nak"; value = "less than"; }
97// DLLPAckLessthanAckedErrWeight: {SeqNum = f_env.AckdSeqNum - seqnum_adjust; DLLPtype = "ack"; value = "less than"; }
98// DLLPNakLessthanAckedErrWeight : {SeqNum = f_env.AckdSeqNum - seqnum_adjust; DLLPtype = "nak"; value = "less than"; }
99// DLLPAckmorethanTLPNxtSeqErrWeight: {
100// // SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + 1;
101// SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + seqnum_adjust;
102// DLLPtype = "ack"; value = "more than"; }
103// DLLPNakmorethanTLPNxtSeqErrWeight: {
104// // SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + 1;
105// SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + seqnum_adjust;
106// DLLPtype = "nak" ; value = "more than";}
107
108 DLLPAckLessthanAckedErrWeight: {SeqNum = f_env.AckdSeqNum - seqnum_adjust; DLLPtype = "ack"; value = "less than"; DLP_error_inject = 1; f_env.Pod.denali_root_monitor_PCIEEnableTrans.tempSuppressDenaliErr(PCIE_DL_FATAL_PROTOCOL_ERROR);}
109 DLLPNakLessthanAckedErrWeight : {SeqNum = f_env.AckdSeqNum - seqnum_adjust; DLLPtype = "nak"; value = "less than"; DLP_error_inject = 1; f_env.Pod.denali_root_monitor_PCIEEnableTrans.tempSuppressDenaliErr(PCIE_DL_FATAL_PROTOCOL_ERROR);}
110 DLLPAckmorethanTLPNxtSeqErrWeight: {
111 // SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + 1;
112 SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + seqnum_adjust;
113 DLLPtype = "ack"; value = "more than"; DLP_error_inject = 1; f_env.Pod.denali_root_monitor_PCIEEnableTrans.tempSuppressDenaliErr(PCIE_DL_FATAL_PROTOCOL_ERROR);}
114 DLLPNakmorethanTLPNxtSeqErrWeight: {
115 // SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + 1;
116 SeqNum = f_env.Pod.FNXPCIEEnableTrans.ReadDenaliReg(PCIE_REG_DEN_NXT_TX_TLP_SEQ) + seqnum_adjust;
117 DLLPtype = "nak" ; value = "more than"; DLP_error_inject = 1;
118 f_env.Pod.denali_root_monitor_PCIEEnableTrans.tempSuppressDenaliErr(PCIE_DL_FATAL_PROTOCOL_ERROR); }
119
120 }
121
122 f_env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_DL_FATAL_PROTOCOL_ERROR );
123
124 printf("AC: at time %0d, SeqNum to be sent = %d, DLLPtype = %0s, value = %s \n", get_time(LO), SeqNum, DLLPtype, value);
125 // sending the ack or nak
126 if (DLLPtype == "ack") {
127 f_env.sendAck(SeqNum);
128 }
129 if (DLLPtype == "nak") {
130 f_env.sendNak(SeqNum);
131 }
132
133
134 nmbrDLLPAckNakErrsInjected += 1;
135 printf("AC: IngressDLLAckNakErr injects error: nmbrDLLPAckNakErrsInjected=%0d nmbrAckNakErrsToInject=%0d \n",nmbrDLLPAckNakErrsInjected, nmbrAckNakErrsToInject);
136
137 repeat (DLLPAckNakErrsInject_freq) @(posedge CLOCK);
138 }
139
140
141
142 //Delay to allow the last error to propogate before checking
143 repeat( 100 ) @(posedge CLOCK);
144
145 //Track possible errors based on the type of errors injected
146 nmbrErrs = 0; // number of error type that got set.
147
148 printf("AC: nmbrErrs = %d \n", nmbrErrs);
149
150 if (nmbrDLLPAckNakErrsInjected == 1) {
151 nmbrErrs += 1; // only primary ce error got set.
152 }
153 else if (nmbrDLLPAckNakErrsInjected > 1) {
154 nmbrErrs += 2; // both primary and secondary ce errors got set.
155 }
156
157
158
159 if( f_errQueue != 0 ){
160
161 // note: bx = no header to check
162 // bx0 = error above is optional. clear it if it's set
163
164 mailbox_put( f_errQueue, e_ERR_none );
165 mailbox_put( f_errQueue, nmbrErrs );
166
167 mailbox_put( f_errQueue, e_ERR_ue_dlp ); // e_ERR_ue_dlp = DLLP protocol error
168 mailbox_put( f_errQueue, 128'bx );
169 mailbox_put( f_errQueue, e_ERR_ue_dlp ); // e_ERR_ue_dlp = DLLP protocol error
170 mailbox_put( f_errQueue, 128'bx );
171
172 } // f_errQueue !=0
173
174 // after the errors are injected, then do not suppress the error detection
175 if( DLP_error_inject ){
176 f_env.Pod.denali_root_monitor_PCIEEnableTrans.unSuppressDenaliErr(PCIE_DL_FATAL_PROTOCOL_ERROR);
177 DLP_error_inject = 0;
178 }
179
180
181 repeat( 10 ) @(posedge CLOCK);
182 semaphore_put( AckNakErr_semaphore, 1 );
183
184 } /* end Execute */
185
186 } /* end IngressUnsupportDLLPErr */