| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: ilupeuDmaPoisonPEUStr.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 DmaPoisonPEUStr extends PEUStrBase |
| 36 | { |
| 37 | integer f_len; // The packet's payload length |
| 38 | bit f_lenSpecified; // Was a length specified? |
| 39 | bit [4:0] f_type; // The request's type |
| 40 | bit f_data; // Does the request have data? |
| 41 | bit f_typeSpecified; // Was a length specified? |
| 42 | integer f_errQueue; |
| 43 | |
| 44 | task new( PEUTestEnv a_env ) |
| 45 | { |
| 46 | super.new( a_env ); |
| 47 | f_lenSpecified = 0; |
| 48 | f_typeSpecified = 0; |
| 49 | f_errQueue = 0; |
| 50 | } |
| 51 | task SetLen( integer a_len ) |
| 52 | { |
| 53 | f_len = a_len; |
| 54 | f_lenSpecified = 1; |
| 55 | } |
| 56 | task SetType( bit[5:0] a_type, bit a_data ) |
| 57 | { |
| 58 | f_type = a_type; |
| 59 | f_data = a_data; |
| 60 | f_typeSpecified = 1; |
| 61 | } |
| 62 | task SetErrQueue( integer a_queue ) |
| 63 | { |
| 64 | f_errQueue = a_queue; |
| 65 | } /* end SetErrQueue */ |
| 66 | |
| 67 | task Execute() |
| 68 | { |
| 69 | bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header |
| 70 | integer ingressData; // A payload descriptor |
| 71 | bit[7:0] ingressTag; // The tag for the TLP |
| 72 | |
| 73 | // What are we doing? |
| 74 | if ( !f_typeSpecified ) |
| 75 | { |
| 76 | randcase |
| 77 | { |
| 78 | 1: f_type = PEC_PCI__TYPE_MEM; |
| 79 | 1: f_type = PEC_PCI__TYPE_MSG; |
| 80 | } |
| 81 | randcase |
| 82 | { |
| 83 | 1: f_data = 0; |
| 84 | 1: f_data = 1; |
| 85 | } |
| 86 | } |
| 87 | if ( !f_lenSpecified ) f_len = urandom()%8 + 1; |
| 88 | |
| 89 | // First, get in line for a DMA tag... |
| 90 | f_env.allocDmaTag( ingressTag ); |
| 91 | |
| 92 | // Then build a TLP |
| 93 | if ( f_type == PEC_PCI__TYPE_MSG ) |
| 94 | f_env.genIngressMsg( ingressTag, ingressHdr, ingressData ); |
| 95 | else if ( f_data ) |
| 96 | f_env.genIngressWrReq( ingressTag, ingressHdr, ingressData, f_len ); |
| 97 | else |
| 98 | f_env.genIngressRdReq( ingressTag, ingressHdr, ingressData, f_len ); |
| 99 | |
| 100 | //Denali can hold a TLP from being transmitted if a previous TLP |
| 101 | // with the same tag and Request ID has not completed yet. This only |
| 102 | // should happen with error TLPs. To help with this make all bad REQs |
| 103 | // PEC_PCI__REQ_ID[0] = 1 |
| 104 | ingressHdr[80] = 1'b1; |
| 105 | |
| 106 | // Set the "poisoned" bit, and then |
| 107 | // push the beastie into the TLU. |
| 108 | ingressHdr[PEC_PCI__EP] = 1; |
| 109 | printf("(DmaPoison IngressHdr) EP : %x TYPE :%x FMT : %x TC : %x\n", |
| 110 | ingressHdr[PEC_PCI__EP], |
| 111 | ingressHdr[PEC_PCI__TYPE], |
| 112 | ingressHdr[PEC_PCI__FMT], |
| 113 | ingressHdr[PEC_PCI__TC]); |
| 114 | |
| 115 | printf("(DmaPoison IngressHdr) ATTR : %x REQ_ID : %x MSG_CODE : %x\n", |
| 116 | ingressHdr[PEC_PCI__ATTR], |
| 117 | ingressHdr[PEC_PCI__REQ_ID], |
| 118 | ingressHdr[PEC_PCI__MSG_CODE] |
| 119 | ); |
| 120 | |
| 121 | if( (f_type != PEC_PCI__TYPE_MSG) && !f_data ){ |
| 122 | f_env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlPoison ); |
| 123 | } |
| 124 | |
| 125 | //If a test calls this then we'll just disable this check for duration |
| 126 | f_env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_TL_COR_TLP_USERTAG_2 ); |
| 127 | |
| 128 | if ( super.f_abortErrTlp ) |
| 129 | { |
| 130 | f_env.drivePCIE( ingressHdr, ingressData, *, *, *, 1 ); |
| 131 | f_env.waitIngressLatency( ingressHdr ); |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | f_env.reserveIngressCredits( ingressHdr ); |
| 136 | f_env.drivePCIE( ingressHdr, ingressData ); |
| 137 | f_env.consumeIngressCredits( ingressHdr ); |
| 138 | if ( ingressHdr[PEC_PCI__FMT_DATA] ) |
| 139 | f_env.waitIngressLatency( ingressHdr ); |
| 140 | else |
| 141 | f_env.expectILU( ingressHdr, ingressData ); |
| 142 | } |
| 143 | f_env.freeDmaTag( ingressTag ); |
| 144 | if( (f_type != PEC_PCI__TYPE_MSG) && !f_data ){ |
| 145 | f_env.Pod.FNXPCIEEnableTrans.unSuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlPoison ); |
| 146 | } |
| 147 | |
| 148 | // Put a "poisoned" error into the |
| 149 | // error-queue, if one was supplied. |
| 150 | if ( f_errQueue != 0 && ingressHdr[PEC_PCI__FMT_DATA] ) |
| 151 | { |
| 152 | printf( "DmaPoison - Add poisoned header to error queue\n" ); |
| 153 | mailbox_put( f_errQueue, e_ERR_ue_pp ); |
| 154 | mailbox_put( f_errQueue, ingressHdr ); |
| 155 | } |
| 156 | else if ( f_errQueue != 0 ) |
| 157 | { |
| 158 | mailbox_put( f_errQueue, e_ERR_none ); |
| 159 | mailbox_put( f_errQueue, 0 ); |
| 160 | } |
| 161 | printf( "DmaPoison - Done!\n" ); |
| 162 | } /* end Execute */ |
| 163 | } /* end DmaPoison */ |