| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: ilupeuEdbErrPEUStr.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 EdbErrPEUStr 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[7:0] f_mask; |
| 43 | bit f_bndySpecified; |
| 44 | integer f_bndy; |
| 45 | integer f_bndySize; |
| 46 | |
| 47 | task new( PEUTestEnv a_env ) |
| 48 | { |
| 49 | super.new( a_env ); |
| 50 | f_errQueue = 0; |
| 51 | f_lenSpecified = 0; |
| 52 | f_typeSpecified = 0; |
| 53 | f_mask = 8'b0; |
| 54 | f_bndySpecified = 0; |
| 55 | } |
| 56 | |
| 57 | task SetErrQueue( integer a_queue ) |
| 58 | { |
| 59 | f_errQueue = a_queue; |
| 60 | } /* end SetErrQueue */ |
| 61 | |
| 62 | task SetLength( integer a_len ) |
| 63 | { |
| 64 | f_len = a_len; |
| 65 | f_lenSpecified = 1; |
| 66 | } /* end SetLength */ |
| 67 | |
| 68 | task SetType( integer a_type ) |
| 69 | { |
| 70 | f_type = a_type; |
| 71 | f_typeSpecified = 1; |
| 72 | } /* end SetType */ |
| 73 | |
| 74 | task SetMask( bit[7:0] a_mask ) |
| 75 | { |
| 76 | f_mask = a_mask; |
| 77 | } /* end SetMask */ |
| 78 | |
| 79 | task SetBndy( integer a_bndy, (integer a_size=64) ) |
| 80 | { |
| 81 | f_bndySpecified = 1; |
| 82 | f_bndy = a_bndy; |
| 83 | f_bndySize = a_size; |
| 84 | } /* end SetBndy */ |
| 85 | |
| 86 | task Execute() |
| 87 | { |
| 88 | bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header |
| 89 | integer egressData; // A payload descriptor |
| 90 | bit[7:0] egressTag; // The tag for the TLP |
| 91 | bit[7:0] egressAddr; // The DOU starting address |
| 92 | bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header |
| 93 | integer ingressData; // A payload descriptor |
| 94 | bit[7:0] ingressTag; // The tag for the TLP |
| 95 | integer cnt1,cnt2; |
| 96 | |
| 97 | |
| 98 | // Build a TLP, using the specified |
| 99 | // type and length, if any. |
| 100 | if ( !f_typeSpecified ) |
| 101 | { |
| 102 | randcase |
| 103 | { |
| 104 | 4 : { f_type = PEC_PCI__TYPE_MEM; f_len = urandom()%2 + 1; } |
| 105 | 1 : { f_type = PEC_PCI__TYPE_CFG0; f_len = 1; } |
| 106 | 1 : { f_type = PEC_PCI__TYPE_CFG1; f_len = 1; } |
| 107 | 1 : { f_type = PEC_PCI__TYPE_IO; f_len = 1; } |
| 108 | 1 : { f_type = PEC_PCI__TYPE_CPL; f_len = urandom()%32 + 1; } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | else if ( !f_lenSpecified ) |
| 113 | { |
| 114 | if ( f_type == PEC_PCI__TYPE_CPL ) |
| 115 | f_len = urandom()%32 + 1; |
| 116 | else if ( f_type == PEC_PCI__TYPE_MEM ) |
| 117 | f_len = urandom()%2 + 1; |
| 118 | else |
| 119 | f_len = 1; |
| 120 | } |
| 121 | |
| 122 | // If a completion (with data) was |
| 123 | // requested, then base it on a DMA |
| 124 | // read request (which we won't submit). |
| 125 | if ( f_type == PEC_PCI__TYPE_CPL ) |
| 126 | { |
| 127 | f_env.allocDmaTag( ingressTag ); |
| 128 | f_env.genIngressRdReq( ingressTag, ingressHdr, ingressData, f_len ); |
| 129 | if ( f_bndySpecified ) |
| 130 | f_env.setAddrBndy( ingressHdr, f_bndy, f_bndySize ); |
| 131 | f_env.genEgressCpl( ingressHdr, egressHdr, egressData ); |
| 132 | f_env.allocCplData( ingressHdr[PEC_PCI__LEN], |
| 133 | egressHdr[PEC_PCI__LOWADDR], |
| 134 | egressAddr ); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | f_env.allocWrTag( egressTag, egressAddr ); |
| 139 | f_env.genEgressWrReq( egressTag, egressHdr, egressData, f_len, f_type ); |
| 140 | if ( f_bndySpecified ) |
| 141 | f_env.setAddrBndy( egressHdr, f_bndy, f_bndySize ); |
| 142 | } |
| 143 | |
| 144 | // Present the TLP to the ILU, and |
| 145 | // specify that parity errors are to |
| 146 | // accompany the payload. |
| 147 | f_env.errorPayload( egressData, f_mask ); |
| 148 | f_env.driveILU( egressHdr, egressAddr, egressData ); |
| 149 | |
| 150 | // We're going to enter the drain state. |
| 151 | f_env.enterDrainState(); |
| 152 | |
| 153 | // Expect the faulty TLP from the TLU. |
| 154 | // And wait for the TLU to signal the |
| 155 | // ILU to enter the "drain state". |
| 156 | // We used to "disconnectEgressPipeline" |
| 157 | // when the TLU's behavior was wierd. |
| 158 | //Make denali check for this instead of just disabling error |
| 159 | //[PCISIG-PHY.2.3#11]. [port_0].RX Nullified TLP |
| 160 | // f_env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_PL_NONFATAL_FRAME_NULL_TLP ); |
| 161 | //Packet will come out as a NULL packet so set the Xtr to check |
| 162 | // for the PCIE_PL_NONFATAL_FRAME_NULL_TLP error |
| 163 | f_env.Pod.FNXPCIEEnableTrans.ExpectNullPkt(); |
| 164 | cnt1 = f_env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; |
| 165 | |
| 166 | //If the packet gets transmitted than make sure its NULL |
| 167 | fork |
| 168 | { |
| 169 | f_env.expectPCIE( egressHdr, egressData ); |
| 170 | @(posedge CLOCK); |
| 171 | cnt2 = f_env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; |
| 172 | //Make sure packet expect wasn't removed and a NULL pkt was received |
| 173 | if( cnt1 !== (cnt2 + 1) && |
| 174 | !sync( CHECK, f_env.ev_removePcie ) && |
| 175 | !sync( CHECK, f_env.ev_drainStateEnd ) && |
| 176 | !f_env.drainStateActive ){ |
| 177 | f_env.Report.report(RTYP_TEST_ERROR,"ilupeuEdbErrPEUStr Outgoing packet matched but a NullPkt wasn't received cnt1=%0d cnt2=%0d \n", cnt1,cnt2); |
| 178 | } |
| 179 | } |
| 180 | join none |
| 181 | |
| 182 | f_env.waitDrainState(); |
| 183 | |
| 184 | // Free the DMA tag if we just pushed |
| 185 | // a completion through the pipe. |
| 186 | if ( f_type == PEC_PCI__TYPE_CPL ) |
| 187 | { |
| 188 | f_env.freeDmaTag( ingressTag ); |
| 189 | } |
| 190 | |
| 191 | // Tell the error-checker about this |
| 192 | // bad-boy. |
| 193 | if ( f_errQueue != 0 ) |
| 194 | { |
| 195 | mailbox_put( f_errQueue, e_ERR_oe_edp ); |
| 196 | mailbox_put( f_errQueue, 128'hx ); |
| 197 | } |
| 198 | |
| 199 | } /* end Execute */ |
| 200 | } /* end EdbErrPEUStr */ |