Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: ilupeuMalCplPEUStr.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 | #define _INFO_MSG_MAL_CPL(msg) printf( "MalCpl (cyc %0d) %s\n", get_cycle(), msg ) | |
36 | ||
37 | class MalCplPEUStr extends PEUStrBase | |
38 | { | |
39 | local bit f_typeSpecified; // Was a bad-boy type supplied? | |
40 | local bit [1:0] f_fmt; // The bad format | |
41 | local bit [4:0] f_type; // The bad type | |
42 | local bit f_lenSpecified; // Was a TLP length supplied? | |
43 | local integer f_len; // A requested TLP length | |
44 | local integer f_cross4K; // By what amount do we cross 4K | |
45 | local integer f_adjustLen; // The delta to the true length | |
46 | local integer f_errQueue; // A mailbox for bad pkt headers | |
47 | local bit f_tdSpecified; // Was the TD supplied? | |
48 | local bit f_tdFieldValue; // The TD value | |
49 | local integer f_solicitedCpl; | |
50 | ||
51 | task new( PEUTestEnv a_env ) | |
52 | { | |
53 | super.new( a_env ); | |
54 | f_typeSpecified = 0; | |
55 | f_lenSpecified = 0; | |
56 | f_errQueue = 0; | |
57 | f_adjustLen = 0; | |
58 | f_cross4K = 0; | |
59 | ||
60 | f_tdSpecified = 0; | |
61 | f_solicitedCpl = 1; | |
62 | } /* end new */ | |
63 | ||
64 | function bit SetType( bit [1:0] a_fmt, bit [4:0] a_type ) | |
65 | { | |
66 | bit isInvalid; | |
67 | ||
68 | f_typeSpecified = 1; | |
69 | f_type = a_type; | |
70 | f_fmt = a_fmt; | |
71 | ||
72 | case ( a_fmt ) { | |
73 | 2'b00 : isInvalid = !( PEC_PCI__TYPE_VALID_00 & ( 1 << a_type ) ); | |
74 | 2'b01 : isInvalid = !( PEC_PCI__TYPE_VALID_01 & ( 1 << a_type ) ); | |
75 | 2'b10 : isInvalid = !( PEC_PCI__TYPE_VALID_10 & ( 1 << a_type ) ); | |
76 | 2'b11 : isInvalid = !( PEC_PCI__TYPE_VALID_11 & ( 1 << a_type ) ); | |
77 | } | |
78 | ||
79 | SetType = isInvalid; | |
80 | } /* end SetType */ | |
81 | ||
82 | task SetLength( integer a_length ) | |
83 | { | |
84 | f_len = a_length; | |
85 | f_lenSpecified = 1; | |
86 | } /* end AdjustLen */ | |
87 | ||
88 | task AdjustLen( integer a_lengthDelta ) | |
89 | { | |
90 | f_adjustLen = a_lengthDelta; | |
91 | } /* end AdjustLen */ | |
92 | ||
93 | task Cross4K( integer a_dwCount ) | |
94 | { | |
95 | f_cross4K = a_dwCount; | |
96 | } /* end AdjustLen */ | |
97 | ||
98 | task SetErrQueue( integer a_queue ) | |
99 | { | |
100 | f_errQueue = a_queue; | |
101 | } /* end SetErrQueue */ | |
102 | ||
103 | task SetTD( bit a_TDValue ) | |
104 | { | |
105 | f_tdFieldValue = a_TDValue; | |
106 | f_tdSpecified = 1; | |
107 | } /* end SetTD */ | |
108 | ||
109 | task SetSolicited( integer a_solicited ) | |
110 | { | |
111 | f_solicitedCpl = a_solicited; | |
112 | } | |
113 | ||
114 | task Execute() | |
115 | { | |
116 | bit [ PEC_PCI__HDR ] reqHdr; // The request TLP's header | |
117 | bit [ PEC_PCI__HDR ] cplHdr; // The completion TLP's header | |
118 | bit [ PEC_PCI__HDR ] badCplHdr; // The corrupted completion TLP's header | |
119 | bit [ 7:0 ] reqTag; // The tag for the TLP | |
120 | integer pyld; // Reusable pyld variable | |
121 | ||
122 | // Get in line for a PIO tag | |
123 | if ( f_solicitedCpl ) | |
124 | f_env.allocRdTag( reqTag ); | |
125 | else | |
126 | reqTag = urandom(); | |
127 | // Then build a TLP. | |
128 | // Only PIO reads need completions | |
129 | if ( f_typeSpecified ) { | |
130 | if ( f_lenSpecified ) | |
131 | f_env.genEgressRdReq( reqTag, reqHdr, pyld, f_len, f_type ); | |
132 | else | |
133 | f_env.genEgressRdReq( reqTag, reqHdr, pyld, *, f_type ); | |
134 | } | |
135 | else { | |
136 | if ( f_lenSpecified ) | |
137 | f_env.genEgressRdReq( reqTag, reqHdr, pyld, f_len, * ); | |
138 | else | |
139 | f_env.genEgressRdReq( reqTag, reqHdr, pyld ); | |
140 | } | |
141 | // make sure RequesterID is 0, since RSB | |
142 | // will check that the completion has this | |
143 | // field set to 0 | |
144 | reqHdr[ PEC_PCI__REQ_ID ] = 16'h0; | |
145 | // adjust the Fmt field, since it | |
146 | // might not be what we want | |
147 | if( f_typeSpecified ) { | |
148 | reqHdr[ PEC_PCI__FMT_4DW ] = f_fmt[ 0 ]; | |
149 | if ( reqHdr[ PEC_PCI__FMT_4DW ] === 1'b1 ){ | |
150 | reqHdr[ PEC_PCI__ADDR ] = {urandom(),urandom()}; | |
151 | }else{ //Make sure addr[1:0] = 0 | |
152 | reqHdr[33:32] = 0; | |
153 | } | |
154 | ||
155 | } | |
156 | ||
157 | // create completion based on PIO req | |
158 | f_env.genIngressCpl( reqHdr, cplHdr, pyld ); | |
159 | badCplHdr = cplHdr; | |
160 | // corrupt the ingress completion | |
161 | if ( f_cross4K != 0 ) { | |
162 | // not implemented yet | |
163 | } | |
164 | if ( f_tdSpecified ) { | |
165 | badCplHdr[ PEC_PCI__TD ] = f_tdFieldValue; | |
166 | } | |
167 | ||
168 | // Force the digest if we've got a | |
169 | // cpl without data and a negative | |
170 | // 'adjustment'. | |
171 | if ( f_adjustLen < 0 && !badCplHdr[PEC_PCI__FMT_DATA] ) | |
172 | badCplHdr[PEC_PCI__TD] = 1; | |
173 | ||
174 | // Check if cpl is supposed to be expected | |
175 | if ( f_solicitedCpl ) { | |
176 | // drive the ILU with the request | |
177 | _INFO_MSG_MAL_CPL( psprintf("Sending PIO request (tag=%h)",reqTag) ); | |
178 | f_env.driveILU( reqHdr, 0, 0 ); | |
179 | // expect the request out the TLU | |
180 | f_env.expectPCIE( reqHdr, 0 ); | |
181 | // drive the TLU with the bad cpl | |
182 | // and free the PIO tag | |
183 | f_env.drivePCIE( badCplHdr, pyld, f_adjustLen, *, *, f_abortErrTlp ); | |
184 | _INFO_MSG_MAL_CPL( psprintf("Sending malformed completion (tag=%h)",reqTag) ); | |
185 | ||
186 | f_env.waitIngressLatency( badCplHdr, (f_adjustLen>0) ? f_adjustLen : 0 ); | |
187 | ||
188 | if ( f_errQueue != 0 ) { | |
189 | mailbox_put( f_errQueue, e_ERR_ue_mfp ); | |
190 | mailbox_put( f_errQueue, (f_adjustLen<0) ? 128'bx : cplHdr ); | |
191 | } | |
192 | ||
193 | f_env.drivePCIE( cplHdr, pyld ); | |
194 | ||
195 | f_env.expectILU( cplHdr, pyld ); | |
196 | ||
197 | f_env.freePioTag( reqTag ); | |
198 | } | |
199 | else { /* unsolicited cpl */ | |
200 | f_env.drivePCIE( badCplHdr, pyld, f_adjustLen, *, *, f_abortErrTlp ); | |
201 | _INFO_MSG_MAL_CPL( psprintf("Sending malformed completion (tag=%h)",reqTag) ); | |
202 | ||
203 | f_env.waitIngressLatency( badCplHdr, (f_adjustLen>0) ? f_adjustLen : 0 ); | |
204 | ||
205 | if( f_errQueue != 0 ) { | |
206 | mailbox_put( f_errQueue, e_ERR_ue_mfp ); | |
207 | mailbox_put( f_errQueue, (f_adjustLen<0) ? 128'bx : cplHdr ); | |
208 | } | |
209 | } | |
210 | } /* end Execute */ | |
211 | } /* end MalCplPEUStr */ | |
212 |