Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_tx_pktconfig.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 | #include <vera_defines.vrh> | |
36 | #include <ListMacros.vrh> | |
37 | #include "pcg_token.vrh" | |
38 | #include "niu_txtoken.vrh" | |
39 | #include "niu_errclass.vrh" | |
40 | ||
41 | class TxPacketGenConfig { | |
42 | ||
43 | // This is to be used by the tests to communicate with the packet generator | |
44 | ||
45 | flow_desc flow; | |
46 | integer data_length; | |
47 | integer token; | |
48 | integer mac_id; | |
49 | integer g_mode = 0; | |
50 | integer mark_bit = 0; | |
51 | integer pad = 0; | |
52 | integer err_code = 0; | |
53 | integer h_err_code = 0; | |
54 | integer err_pkt = 0; | |
55 | // To be used only for Loopback modes | |
56 | integer loop_back_rx_lastpacket = 0; | |
57 | integer loop_back_rxdma_num = 0; | |
58 | integer set_wrong_ctlwd = 0; | |
59 | integer ecc_2biterr_line1 = 0; | |
60 | ||
61 | integer gConfig_length[15]; | |
62 | integer gConfig_alignment[15]; | |
63 | integer gConfig_mode; // if mode is -1 , then random lengths/alignment would be chosen | |
64 | integer gConfig_noOfDesc; | |
65 | integer gConfig_specific_alignment; | |
66 | integer gConfig_specific_line; | |
67 | CNiuErrors error_info; | |
68 | ||
69 | ||
70 | ||
71 | task new() { | |
72 | flow = new(); | |
73 | gConfig_mode = 0; | |
74 | gConfig_noOfDesc = 1; | |
75 | g_mode = 0; | |
76 | mark_bit = 0; | |
77 | pad = 0; | |
78 | err_code = 0; | |
79 | h_err_code = 0; | |
80 | err_pkt = 0; | |
81 | set_wrong_ctlwd = 0; | |
82 | ecc_2biterr_line1 = 0; | |
83 | error_info = new(); | |
84 | gConfig_specific_alignment = 0; | |
85 | gConfig_specific_line = 0; | |
86 | } | |
87 | ||
88 | function bit[4:0] get_frame_type() { | |
89 | ||
90 | bit [4:0] ftype; | |
91 | ||
92 | ftype = flow.frame.frame_type; | |
93 | printf("VAL_OF_FRM_TYPE %0h\n",ftype); | |
94 | ||
95 | get_frame_type = ftype; | |
96 | } | |
97 | ||
98 | function integer get_frame_class() { | |
99 | ||
100 | integer fclass; | |
101 | ||
102 | fclass = flow.frame.frame_class; | |
103 | printf("VAL_OF_FRM_CLASS %0d\n",fclass); | |
104 | ||
105 | get_frame_class = fclass; | |
106 | ||
107 | } | |
108 | ||
109 | function integer get_ip_hdr_len() { | |
110 | ||
111 | integer fip_hdr_len; | |
112 | fip_hdr_len = flow.frame.header_length; | |
113 | ||
114 | get_ip_hdr_len = fip_hdr_len; | |
115 | ||
116 | } | |
117 | task SetGatherFields(); | |
118 | task printGatherFields() { | |
119 | integer i; | |
120 | printf(" TxPacketGenConfig::printGatherFields NoOfGather - %d \n", gConfig_noOfDesc); | |
121 | for(i=0;i<gConfig_noOfDesc;i++) { | |
122 | printf(" TxPacketGenConfig::printGatherFields i - %d, length - gConfig_length - %d alignment - %d \n",i,this.gConfig_length[i],this.gConfig_alignment[i]); | |
123 | } | |
124 | } | |
125 | ||
126 | ||
127 | } | |
128 | ||
129 | ||
130 | task TxPacketGenConfig::SetGatherFields() { | |
131 | ||
132 | integer i; | |
133 | integer rem_length; | |
134 | integer length; | |
135 | integer alignment; | |
136 | integer j; | |
137 | integer done; | |
138 | done = 0; | |
139 | ||
140 | j=0; | |
141 | ||
142 | while((done==0) & ( j <10)) { | |
143 | ||
144 | i=0; | |
145 | rem_length = this.data_length + this.flow.frame.l2_pad_length - 4; | |
146 | while((i<15) & (rem_length>0) ) { | |
147 | if(i==0) { | |
148 | // special case, due to control word. | |
149 | alignment = 16; | |
150 | length = random() % rem_length + 1; | |
151 | ||
152 | ||
153 | if(length > 4096) { | |
154 | length = random() % 4095 + 1; | |
155 | } | |
156 | if(length<16) { | |
157 | // force this to 16 | |
158 | length = 16; | |
159 | } | |
160 | this.gConfig_length[i] = length; | |
161 | this.gConfig_alignment[i] = alignment; | |
162 | rem_length = rem_length - length; | |
163 | // printf("SetGatherFields i = %d length - %d alignment - %d \n",i,length,alignment); | |
164 | ||
165 | } else { | |
166 | alignment = random() % 16 + 1; | |
167 | // if the last descriptor, make sure the last descriptor gets everything | |
168 | if(i==15) { | |
169 | length = rem_length; | |
170 | } else | |
171 | length = random() % rem_length + 1; | |
172 | ||
173 | if(length > 4096) { | |
174 | length = random() % 4095 + 1; | |
175 | } | |
176 | // printf("SetGatherFields i = %d length - %d alignment - %d \n",i,length,alignment); | |
177 | this.gConfig_length[i] = length; | |
178 | this.gConfig_alignment[i] = alignment; | |
179 | rem_length = rem_length - length; | |
180 | } | |
181 | i++; | |
182 | } | |
183 | if(rem_length!=0) { | |
184 | // Need to restart the random generation | |
185 | j++; | |
186 | } else { | |
187 | done = 1; | |
188 | this.gConfig_noOfDesc = i ; | |
189 | } | |
190 | } | |
191 | ||
192 | if(j>=10) { | |
193 | printf("TX TB FATAL ERROR -!!! in task TxPacketGenConfig::SetGatherFields FIX THIS \n"); | |
194 | } | |
195 | ||
196 | } | |
197 | ||
198 |