Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: ilupeuEgrParErr.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 ============================================ | |
35 | class EgrParErrStr extends PEUStrBase | |
36 | { | |
37 | integer f_errQueue; // A mailbox for bad pkt headers | |
38 | integer f_len; // The packet's payload length | |
39 | bit f_lenSpecified; // Was a length specified? | |
40 | bit[4:0] f_type; // The packet's type | |
41 | bit f_typeSpecified; // Was a type specified? | |
42 | bit [1:0] f_injectType; | |
43 | bit[7:0] f_mask; | |
44 | bit f_bndySpecified; | |
45 | integer f_bndy; | |
46 | integer f_bndySize; | |
47 | integer bit_flip; | |
48 | integer cnt1,cnt2; | |
49 | ||
50 | task new( PEUTestEnv a_env ) | |
51 | { | |
52 | super.new( a_env ); | |
53 | f_errQueue = 0; | |
54 | f_lenSpecified = 0; | |
55 | f_typeSpecified = 0; | |
56 | f_injectType = 0; | |
57 | f_mask = 8'b0; | |
58 | f_bndySpecified = 0; | |
59 | bit_flip = random() % 16; | |
60 | } | |
61 | ||
62 | task SetErrQueue( integer a_queue ) | |
63 | { | |
64 | f_errQueue = a_queue; | |
65 | } /* end SetErrQueue */ | |
66 | ||
67 | task SetLength( integer a_len ) | |
68 | { | |
69 | f_len = a_len; | |
70 | f_lenSpecified = 1; | |
71 | } /* end SetLength */ | |
72 | ||
73 | task SetType( integer a_type ) | |
74 | { | |
75 | f_type = a_type; | |
76 | f_typeSpecified = 1; | |
77 | } /* end SetType */ | |
78 | ||
79 | task SetInjectType( bit [1:0] a_injectType ) | |
80 | { | |
81 | f_injectType = a_injectType; | |
82 | } | |
83 | ||
84 | task SetMask( bit[7:0] a_mask ) | |
85 | { | |
86 | f_mask = a_mask; | |
87 | } /* end SetMask */ | |
88 | ||
89 | task SetBndy( integer a_bndy, (integer a_size=64) ) | |
90 | { | |
91 | f_bndySpecified = 1; | |
92 | f_bndy = a_bndy; | |
93 | f_bndySize = a_size; | |
94 | } /* end SetBndy */ | |
95 | ||
96 | task Execute() | |
97 | { | |
98 | bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header | |
99 | integer egressData; // A payload descriptor | |
100 | bit[7:0] egressTag; // The tag for the TLP | |
101 | bit[7:0] egressAddr; // The DOU starting address | |
102 | bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header | |
103 | integer ingressData; // A payload descriptor | |
104 | bit[7:0] ingressTag; // The tag for the TLP | |
105 | bit [63:0] data; | |
106 | ||
107 | // Build a TLP, using the specified | |
108 | // type and length, if any. | |
109 | if ( !f_typeSpecified ) | |
110 | { | |
111 | randcase | |
112 | { // do only mem write case with no completion for now | |
113 | 1 : { f_type = PEC_PCI__TYPE_MEM; f_len = urandom()%2 + 1; } | |
114 | 0 : { f_type = PEC_PCI__TYPE_CFG0; f_len = 1; } | |
115 | 0 : { f_type = PEC_PCI__TYPE_CFG1; f_len = 1; } | |
116 | 0 : { f_type = PEC_PCI__TYPE_IO; f_len = 1; } | |
117 | } | |
118 | } | |
119 | ||
120 | else if ( !f_lenSpecified ) | |
121 | { | |
122 | if ( f_type == PEC_PCI__TYPE_CPL ) | |
123 | f_len = urandom()%32 + 1; | |
124 | else if ( f_type == PEC_PCI__TYPE_MEM ) | |
125 | f_len = urandom()%2 + 1; | |
126 | else | |
127 | f_len = 1; | |
128 | } | |
129 | ||
130 | if (f_injectType == 2) { | |
131 | printf("Writing the ILU Diagnostic register\n"); | |
132 | data = f_env.readCSRdirect(f_env.getCSRaddr(e_CSR_ilu_diagnos)); | |
133 | data[FIRE_DLC_ILU_CIB_CSR_A_ILU_DIAGNOS_EHI_PAR_SLC] = 1 << (bit_flip % 4); | |
134 | data[FIRE_DLC_ILU_CIB_CSR_A_ILU_DIAGNOS_EHI_TRIG_SLC] = 1; | |
135 | f_env.writeCSRdirect(f_env.getCSRaddr(e_CSR_ilu_diagnos), data); | |
136 | } else if (f_injectType == 1) { | |
137 | printf("Writing the ILU Diagnostic register\n"); | |
138 | data = f_env.readCSRdirect(f_env.getCSRaddr(e_CSR_ilu_diagnos)); | |
139 | data[FIRE_DLC_ILU_CIB_CSR_A_ILU_DIAGNOS_EDI_PAR_SLC] = 1 << (bit_flip % 4); | |
140 | data[FIRE_DLC_ILU_CIB_CSR_A_ILU_DIAGNOS_EDI_TRIG_SLC] = 1; | |
141 | f_env.writeCSRdirect(f_env.getCSRaddr(e_CSR_ilu_diagnos), data); | |
142 | } else { | |
143 | printf("Writing the PEU Diagnostic register\n"); | |
144 | data = f_env.readCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag)); | |
145 | data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_EPI_PAR_SLC] = 1 << bit_flip; | |
146 | data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_EPI_TRG_SLC] = 1; | |
147 | f_env.writeCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag), data); | |
148 | } | |
149 | ||
150 | if ( f_type == PEC_PCI__TYPE_CPL ) | |
151 | { | |
152 | f_env.allocDmaTag( ingressTag ); | |
153 | f_env.genIngressRdReq( ingressTag, ingressHdr, ingressData, f_len ); | |
154 | if ( f_bndySpecified ) | |
155 | f_env.setAddrBndy( ingressHdr, f_bndy, f_bndySize ); | |
156 | f_env.genEgressCpl( ingressHdr, egressHdr, egressData ); | |
157 | f_env.allocCplData( ingressHdr[PEC_PCI__LEN], | |
158 | egressHdr[PEC_PCI__LOWADDR], | |
159 | egressAddr ); | |
160 | } | |
161 | else | |
162 | { | |
163 | f_env.allocWrTag( egressTag, egressAddr ); | |
164 | f_env.genEgressWrReq( egressTag, egressHdr, egressData, f_len, f_type ); | |
165 | if ( f_bndySpecified ) | |
166 | f_env.setAddrBndy( egressHdr, f_bndy, f_bndySize ); | |
167 | } | |
168 | ||
169 | ||
170 | // Present the TLP to the ILU, and | |
171 | // specify that parity errors are to | |
172 | // accompany the payload. | |
173 | f_env.driveILU( egressHdr, egressAddr, egressData ); | |
174 | ||
175 | // Expect the faulty TLP from the TLU. | |
176 | // And wait for the TLU to signal the | |
177 | // ILU to enter the "drain state". | |
178 | // We used to "disconnectEgressPipeline" | |
179 | // when the TLU's behavior was wierd. | |
180 | ||
181 | if (f_injectType == 2) { // ILU header parity error case | |
182 | f_env.enterDrainState(); | |
183 | // f_env.expectPCIE( egressHdr, egressData ); // no packet for header parity error | |
184 | f_env.waitDrainState(); | |
185 | } else if (f_injectType == 1) { // ILU data parity error case | |
186 | f_env.enterDrainState(); | |
187 | f_env.Pod.FNXPCIEEnableTrans.ExpectNullPkt(); | |
188 | cnt1 = f_env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; | |
189 | f_env.expectPCIE( egressHdr, egressData ); | |
190 | cnt2 = f_env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; | |
191 | printf("Cnt1 was %0d and cnt2 was %0d\n", cnt1, cnt2); | |
192 | if( cnt1 !== (cnt2 + 1)) { | |
193 | f_env.Report.report(RTYP_TEST_ERROR,"ilupeuEgrParErrStr Outgoing packet matched but a NullPkt wasn't received\n"); | |
194 | } | |
195 | f_env.waitDrainState(); | |
196 | } else { // egress data parity error case | |
197 | ||
198 | //If the packet gets transmitted than make sure its NULL | |
199 | f_env.expectPCIE( egressHdr, egressData ); | |
200 | } | |
201 | ||
202 | // Free the DMA tag if we just pushed | |
203 | // a completion through the pipe. | |
204 | if ( f_type == PEC_PCI__TYPE_CPL ) | |
205 | { | |
206 | f_env.freeDmaTag( ingressTag ); | |
207 | } | |
208 | ||
209 | // Tell the error-checker about this | |
210 | // bad-boy. | |
211 | if ( f_errQueue != 0 ) | |
212 | { | |
213 | printf("sending over the error\n"); | |
214 | if (f_injectType == 2) { | |
215 | mailbox_put( f_errQueue, e_ERR_oe_ehp ); | |
216 | mailbox_put( f_errQueue, 128'hx); // egressHdr ); //doesn't log header? | |
217 | } else if (f_injectType == 1) { | |
218 | mailbox_put( f_errQueue, e_ERR_oe_edp ); | |
219 | mailbox_put( f_errQueue, 128'hx); // egressHdr ); //doesn't log header? | |
220 | } else { | |
221 | mailbox_put( f_errQueue, e_ERR_oe_eip ); | |
222 | mailbox_put( f_errQueue, 128'hx); // egressHdr ); //doesn't log header? | |
223 | } | |
224 | } | |
225 | ||
226 | } /* end Execute */ | |
227 | } /* end EdbErrPEUStr */ |