Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuIngressDLLPErr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuIngressDLLPErr.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 ilupeuIngressDLLPErr extends PEUStrBase
36 {
37 integer f_errQueue; // A mailbox for bad pkt headers
38
39// integer nmbrUnsupportDLLPErrsToInject = 10; //Total number of packets that get error injected
40 integer nmbrDLLPErrsToInject = 10; //Total number of packets that get error injected
41 //Set the percentage weight of each type of receiver error
42 integer DLLPErrUnsupportWeight = 0;
43 integer DLLPErrBadCRCWeight = 0;
44 denaliPcieEiTypeT DenaliErrortype;
45
46 //Only allow 1 of these strategies to be active at a time
47// static integer supportDLLPErr_semaphore = alloc(SEMAPHORE, 0, 1, 1);
48 static integer DLLPErr_semaphore = alloc(SEMAPHORE, 0, 1, 1);
49
50 task new( PEUTestEnv a_env )
51 {
52 super.new( a_env );
53 f_errQueue = 0;
54 }
55
56 task SetErrQueue( integer a_queue )
57 {
58 f_errQueue = a_queue;
59 } /* end SetErrQueue */
60
61 task Execute()
62 {
63 integer nmbrErrs;
64 integer UnsupportDLLPInject_freq = 100; // freq of clock cycles to inject this error
65 integer BadCRCDLLPInject_freq = 100;
66 integer nmbrDLLPErrsInjected = 0;
67 integer nmbrUnsupportDLLPErrsInjected = 0;
68 integer nmbrBadCRCDLLPErrsInjected = 0 ;
69
70 //Get the semaphore when its your turn
71// semaphore_get( WAIT, UnsupportDLLPErr_semaphore, 1);
72 semaphore_get( WAIT, DLLPErr_semaphore, 1);
73
74
75 //Clear all the specific error trackers
76 nmbrUnsupportDLLPErrsInjected = 0;
77 nmbrBadCRCDLLPErrsInjected = 0;
78 nmbrDLLPErrsInjected = 0;
79
80 // create random number to cause unsupported and bad CRC DLLP type
81 UnsupportDLLPInject_freq = (urandom() % 100) + 50;
82 BadCRCDLLPInject_freq = (urandom() % 100) + 50;
83 printf("AC: ilupeuIngressDLLPErr.vr, nmbrDLLPErrsToInject = %d \n", nmbrDLLPErrsToInject);
84
85 //inject errors until all the errors are injected
86// while (nmbrDLLPErrsToInject > nmbrBadCRCDLLPErrsInjected) {
87 while (nmbrDLLPErrsInjected < nmbrDLLPErrsToInject) {
88 //determine the type of errors inject based on the weight specified in the testcase
89 randcase {
90 DLLPErrUnsupportWeight: {DenaliErrortype = PCIE_EI_RSRVD_TYPE;}
91 DLLPErrBadCRCWeight : {DenaliErrortype = PCIE_EI_LCRC;}
92 }
93 printf("AC: ilupeuIngressDLLPErr.vr, DenaliErrortype = %s \n", DenaliErrortype);
94
95 if( DenaliErrortype == PCIE_EI_RSRVD_TYPE) {
96 f_env.driveUnsupportDLLP();
97 nmbrUnsupportDLLPErrsInjected += 1;
98 printf("AC: IngressUnsupportDLLPErr injects error: nmbrDLLPErrsToInject=%0d nmbrUnsupportDLLPErrsInjected=%0d at time %d \n",nmbrDLLPErrsToInject, nmbrUnsupportDLLPErrsInjected, get_time(LO));
99 repeat (UnsupportDLLPInject_freq) @(posedge CLOCK);
100 }
101
102 if( DenaliErrortype == PCIE_EI_LCRC) {
103 f_env.driveBadCRCDLLP();
104 nmbrBadCRCDLLPErrsInjected += 1;
105 printf("AC: IngressUnsupportDLLPErr injects error: nmbrDLLPErrsToInject=%0d nmbrBadCRCDLLPErrsInjected=%0d at time %d \n",nmbrDLLPErrsToInject, nmbrBadCRCDLLPErrsInjected, get_time(LO));
106 repeat (BadCRCDLLPInject_freq) @(posedge CLOCK);
107 }
108
109 nmbrDLLPErrsInjected += 1;
110 printf("AC: IngressUnsupportDLLPErr injects error: nmbrDLLPErrsToInject=%0d nmbrDLLPErrsInjected=%0d \n",nmbrDLLPErrsToInject, nmbrDLLPErrsInjected);
111
112 repeat (100) @(posedge CLOCK);
113
114 }
115
116 //Uelay to allow the last error to propogate before checking
117 repeat( 100 ) @(posedge CLOCK);
118 printf("AC: after all errors are collected \n");
119
120 //Track possible errors based on the type of errors injected
121 nmbrErrs = 0; // number of error type that got set.
122
123 if (nmbrUnsupportDLLPErrsInjected >= 1) {
124
125 // for unsupport DLLP type: CXLP unsupport error + primary / removed PRM 1.0 secondary link event interrupt
126 nmbrErrs += 2; // number of error type that got set. 1 for header , 1 for error
127 }
128 if (nmbrBadCRCDLLPErrsInjected == 1) {
129 nmbrErrs += 1; // only primary ce error got set.
130 }
131 else if (nmbrBadCRCDLLPErrsInjected > 1) {
132 nmbrErrs += 2; // both primary and secondary ce errors got set.
133 }
134
135 printf("AC: nmbrErrs = %d, nmbrUnsupportDLLPErrsInjected = %d, nmbrBadCRCDLLPErrsInjected = %d \n", nmbrErrs, nmbrUnsupportDLLPErrsInjected, nmbrBadCRCDLLPErrsInjected );
136
137
138 if( f_errQueue != 0 ){
139
140 // note: bx = no header to check
141 // bx0 = error above is optional. clear it if it's set
142
143 mailbox_put( f_errQueue, e_ERR_none );
144 mailbox_put( f_errQueue, nmbrErrs );
145
146// // DLLP with bad CRC: e_ERR_ce_bdp = Bad DLLP (LPU)
147// mailbox_put( f_errQueue, e_ERR_ce_bdp );
148// mailbox_put( f_errQueue, 128'bx ); // bx : not to check the header
149// if (nmbrUnsupportDLLPErrsToInject > 1 ) {
150// mailbox_put( f_errQueue, e_ERR_ce_bdp );
151// mailbox_put( f_errQueue, 128'bx );
152// }
153
154 if(nmbrUnsupportDLLPErrsInjected >= 1) {
155 // Unsupported DLLP: e_ERR_dlpl_unsup_dllp, e_ERR_oe_lin(primary & secondary)
156 mailbox_put( f_errQueue, e_ERR_dlpl_unsup_dllp );
157 mailbox_put( f_errQueue, 128'bx ); // bx : not to check the header
158 mailbox_put( f_errQueue, e_ERR_oe_lin );
159 mailbox_put( f_errQueue, 128'bx );
160//Removed PRM 1.0 mailbox_put( f_errQueue, e_ERR_oe_lin );
161//Removed PRM 1.0 mailbox_put( f_errQueue, 128'bx );
162 }
163
164 if (nmbrBadCRCDLLPErrsInjected == 1) {
165 mailbox_put( f_errQueue, e_ERR_ce_bdp ); // e_ERR_ce_bdp = Bad DLLP
166 mailbox_put( f_errQueue, 128'bx );
167 }
168 else if (nmbrBadCRCDLLPErrsInjected > 1) {
169 mailbox_put( f_errQueue, e_ERR_ce_bdp ); // e_ERR_ce_bdp = Bad DLLP
170 mailbox_put( f_errQueue, 128'bx );
171 mailbox_put( f_errQueue, e_ERR_ce_bdp ); // e_ERR_ce_bdp = Bad DLLP
172 mailbox_put( f_errQueue, 128'bx );
173 }
174
175 } // f_errQueue !=0
176
177 repeat( 10 ) @(posedge CLOCK);
178// semaphore_put( UnsupportDLLPErr_semaphore, 1 );
179 semaphore_put( DLLPErr_semaphore, 1 );
180
181 } /* end Execute */
182
183 } /* end IngressUnsupportDLLPErr */