Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_rx_exit_tools.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 "niu_gen_pio.vrh" | |
37 | #include "niu_rx_descp.vrh" | |
38 | #include "niu_rxdmc.vrh" | |
39 | #include "cMesg.vrh" | |
40 | #include "mac_pio_class.vrh" | |
41 | #include "xpcs_memory_map.vri" | |
42 | #include "dmc_memory_map.vri" | |
43 | #include "ipp_memory_map.vri" | |
44 | #include "xmac_util.vrh" | |
45 | #include "bmac_util.vrh" | |
46 | #include "dmc_memory_map.vri" | |
47 | ||
48 | extern niu_gen_pio gen_pio_drv; | |
49 | extern Mesg be_msg; | |
50 | extern mac_util_class mac_util; | |
51 | extern bmac_util_class bmac_util; | |
52 | extern mac_pio_cl mac_pio_class; | |
53 | extern CRDMC rdmc; | |
54 | ||
55 | class rx_counters { // class to be used for both model and rtl values | |
56 | integer mac_id; | |
57 | string name; | |
58 | // mac: xmac => only xmac, bmac => only bmac, mac => xmac & bmac | |
59 | integer mac_crc_cntr; // CRC errors | |
60 | integer xmac_hist1_cntr; // 64B | |
61 | integer xmac_hist2_cntr; // 65-127B | |
62 | integer xmac_hist3_cntr; // 128-255B | |
63 | integer xmac_hist4_cntr; // 256-511B | |
64 | integer xmac_hist5_cntr; // 512-1023B | |
65 | integer xmac_hist6_cntr; // 1024-1522B | |
66 | integer xmac_hist7_cntr; // >1523B (or) All sizes | |
67 | integer mac_mpszer_cntr; // oversize pkts | |
68 | integer xmac_frag_cntr; // undersize pkts | |
69 | integer xmac_byte_cntr; // Bytes | |
70 | integer xmac_mcast_cntr; // multicast | |
71 | integer xmac_bcast_cntr; // boradcast | |
72 | integer mac_codevio_cntr; // code violations | |
73 | integer bmac_alignerr_cntr; // alignment errors | |
74 | integer bmac_frame_cntr; // alignment errors | |
75 | // ipp | |
76 | integer ipp_chksum_cntr; // checksum errors | |
77 | integer ipp_ecc_err_cntr; // ecc error pkts dropped | |
78 | integer ipp_runt_pkt_cntr; // runt pkts discarded | |
79 | ||
80 | task new (integer port_id) { | |
81 | mac_id = port_id; | |
82 | name = ""; | |
83 | mac_crc_cntr = 0; | |
84 | xmac_hist1_cntr = 0; | |
85 | xmac_hist2_cntr = 0; | |
86 | xmac_hist3_cntr = 0; | |
87 | xmac_hist4_cntr = 0; | |
88 | xmac_hist5_cntr = 0; | |
89 | xmac_hist6_cntr = 0; | |
90 | xmac_hist7_cntr = 0; | |
91 | mac_mpszer_cntr = 0; | |
92 | xmac_frag_cntr = 0; | |
93 | xmac_byte_cntr = 0; | |
94 | xmac_mcast_cntr = 0; | |
95 | xmac_bcast_cntr = 0; | |
96 | mac_codevio_cntr = 0; | |
97 | bmac_alignerr_cntr = 0; | |
98 | bmac_frame_cntr = 0; | |
99 | ipp_chksum_cntr = 0; | |
100 | ipp_ecc_err_cntr = 0; | |
101 | ipp_runt_pkt_cntr = 0; | |
102 | } | |
103 | ||
104 | task display_counters() { | |
105 | if (mac_id==0 || mac_id==1) { | |
106 | printf("%s_xmac_crc_cntr = %0d\n", name, mac_crc_cntr); | |
107 | printf("%s_xmac_hist1_cntr = %0d\n", name, xmac_hist1_cntr); | |
108 | printf("%s_xmac_hist2_cntr = %0d\n", name, xmac_hist2_cntr); | |
109 | printf("%s_xmac_hist3_cntr = %0d\n", name, xmac_hist3_cntr); | |
110 | printf("%s_xmac_hist4_cntr = %0d\n", name, xmac_hist4_cntr); | |
111 | printf("%s_xmac_hist5_cntr = %0d\n", name, xmac_hist5_cntr); | |
112 | printf("%s_xmac_hist6_cntr = %0d\n", name, xmac_hist6_cntr); | |
113 | printf("%s_xmac_hist7_cntr = %0d\n", name, xmac_hist7_cntr); | |
114 | printf("%s_xmac_mpszer_cntr = %0d\n", name, mac_mpszer_cntr); | |
115 | printf("%s_xmac_frag_cntr = %0d\n", name, xmac_frag_cntr); | |
116 | printf("%s_xmac_byte_cntr = %0d\n", name, xmac_byte_cntr); | |
117 | printf("%s_xmac_mcast_cntr = %0d\n", name, xmac_mcast_cntr); | |
118 | printf("%s_xmac_bcast_cntr = %0d\n", name, xmac_bcast_cntr); | |
119 | printf("%s_xmac_codevio_cntr = %0d\n", name, mac_codevio_cntr); | |
120 | } | |
121 | else if (mac_id==2 || mac_id==3) { | |
122 | printf("%s_bmac_crc_cntr = %0d\n", name, mac_crc_cntr); | |
123 | printf("%s_bmac_frame_cntr = %0d\n", name, bmac_frame_cntr); | |
124 | printf("%s_bmac_mpszer_cntr = %0d\n", name, mac_mpszer_cntr); | |
125 | printf("%s_bmac_codevio_cntr = %0d\n", name, mac_codevio_cntr); | |
126 | printf("%s_bmac_aligner_cntr = %0d\n", name, bmac_alignerr_cntr); | |
127 | } | |
128 | printf("%s_ipp_chksum_cntr = %0d\n", name, ipp_chksum_cntr); | |
129 | printf("%s_ipp_ecc_err_cntr = %0d\n", name, ipp_ecc_err_cntr); | |
130 | printf("%s_ipp_runt_pkt_cntr = %0d\n", name, ipp_runt_pkt_cntr); | |
131 | } | |
132 | } | |
133 | ||
134 | class rx_exit_tools { | |
135 | ||
136 | task new() { } | |
137 | function rx_counters read_rx_rtl_cntrs(integer port_id); | |
138 | task match_rtl_env_cntrs(rx_counters rtl_counts, rx_counters env_counts); | |
139 | task compare(integer port_num, integer rtl_cnt, integer env_cnt, string name_str); | |
140 | ||
141 | } | |
142 | ||
143 | function rx_counters rx_exit_tools::read_rx_rtl_cntrs(integer port_id) { | |
144 | rx_counters rx_cntr_handle; | |
145 | string handle_name; | |
146 | bit [39:0] base_addr; | |
147 | bit [31:0] read_data; | |
148 | ||
149 | sprintf(handle_name, "rtl_counts%0d", port_id); | |
150 | rx_cntr_handle = new(port_id); | |
151 | rx_cntr_handle.name = handle_name; | |
152 | ||
153 | if (port_id==0 || port_id==1){ | |
154 | base_addr = bmac_util.get_mac_reg_base(port_id); | |
155 | mac_pio_class.xmac_pio_rd(base_addr + MAC_CRC_ER_CNT, read_data,1'b0); | |
156 | rx_cntr_handle.mac_crc_cntr=read_data; | |
157 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT1, read_data,1'b0); | |
158 | rx_cntr_handle.xmac_hist1_cntr=read_data; | |
159 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT2, read_data,1'b0); | |
160 | rx_cntr_handle.xmac_hist2_cntr=read_data; | |
161 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT3, read_data,1'b0); | |
162 | rx_cntr_handle.xmac_hist3_cntr=read_data; | |
163 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT4, read_data,1'b0); | |
164 | rx_cntr_handle.xmac_hist4_cntr=read_data; | |
165 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT5, read_data,1'b0); | |
166 | rx_cntr_handle.xmac_hist5_cntr=read_data; | |
167 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT6, read_data,1'b0); | |
168 | rx_cntr_handle.xmac_hist6_cntr=read_data; | |
169 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_HIST_CNT7, read_data,1'b0); | |
170 | rx_cntr_handle.xmac_hist7_cntr=read_data; | |
171 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_MPSZER_CNT, read_data,1'b0); | |
172 | rx_cntr_handle.mac_mpszer_cntr=read_data; | |
173 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_FRAG_CNT, read_data,1'b0); | |
174 | rx_cntr_handle.xmac_frag_cntr=read_data; | |
175 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_BT_CNT, read_data,1'b0); | |
176 | rx_cntr_handle.xmac_byte_cntr=read_data; | |
177 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_MC_FRM_CNT, read_data,1'b0); | |
178 | rx_cntr_handle.xmac_mcast_cntr=read_data; | |
179 | mac_pio_class.xmac_pio_rd(base_addr + RxMAC_BC_FRM_CNT, read_data,1'b0); | |
180 | rx_cntr_handle.xmac_bcast_cntr=read_data; | |
181 | mac_pio_class.xmac_pio_rd(base_addr + MAC_CD_VIO_CNT, read_data,1'b0); | |
182 | rx_cntr_handle.mac_codevio_cntr=read_data; | |
183 | } | |
184 | else if (port_id==2 || port_id==3){ | |
185 | bmac_util.rd_ipp_mac_reg(port_id, BRxMAC_FRM_CNT, read_data, 1'b0); | |
186 | rx_cntr_handle.bmac_frame_cntr=read_data; | |
187 | bmac_util.rd_ipp_mac_reg(port_id, BMAC_AL_ER_CNT, read_data, 1'b0); | |
188 | rx_cntr_handle.bmac_alignerr_cntr=read_data; | |
189 | bmac_util.rd_ipp_mac_reg(port_id, BMAC_CRC_ER_CNT, read_data, 1'b0); | |
190 | rx_cntr_handle.mac_crc_cntr=read_data; | |
191 | bmac_util.rd_ipp_mac_reg(port_id, BMAC_CD_VIO_CNT, read_data, 1'b0); | |
192 | rx_cntr_handle.mac_codevio_cntr=read_data; | |
193 | bmac_util.rd_ipp_mac_reg(port_id, MAC_LEN_ER_CNT, read_data, 1'b0); | |
194 | rx_cntr_handle.mac_mpszer_cntr=read_data; | |
195 | } | |
196 | ||
197 | read_rx_rtl_cntrs = rx_cntr_handle.object_copy(); | |
198 | read_rx_rtl_cntrs.display_counters(); | |
199 | } | |
200 | ||
201 | task rx_exit_tools::match_rtl_env_cntrs(rx_counters rtl_counts, rx_counters env_counts) { | |
202 | ||
203 | if (rtl_counts.mac_id !== env_counts.mac_id) { | |
204 | printf("ERROR match_rtl_env_cntrs: Cannot compare rtl and env counts for 2 different ports\n"); | |
205 | printf("match_rtl_env_cntrs: Not doing the comparison of counts as part of exit check!\n"); | |
206 | return; | |
207 | } | |
208 | ||
209 | if (rtl_counts.mac_id==0 || rtl_counts.mac_id==1) { | |
210 | compare(rtl_counts.mac_id,rtl_counts.mac_crc_cntr, env_counts.mac_crc_cntr, "mac_crc_cntr"); | |
211 | ||
212 | #ifdef 0 | |
213 | ||
214 | // byte counter should be skipped as it is not accurate as well | |
215 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist1_cntr, env_counts.xmac_hist1_cntr, "xmac_hist1_cntr"); | |
216 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist2_cntr, env_counts.xmac_hist2_cntr, "xmac_hist2_cntr"); | |
217 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist3_cntr, env_counts.xmac_hist3_cntr, "xmac_hist3_cntr"); | |
218 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist4_cntr, env_counts.xmac_hist4_cntr, "xmac_hist4_cntr"); | |
219 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist5_cntr, env_counts.xmac_hist5_cntr, "xmac_hist5_cntr"); | |
220 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist6_cntr, env_counts.xmac_hist6_cntr, "xmac_hist6_cntr"); | |
221 | compare(rtl_counts.mac_id,rtl_counts.xmac_byte_cntr, env_counts.xmac_byte_cntr, "xmac_byte_cntr"); | |
222 | #endif | |
223 | ||
224 | compare(rtl_counts.mac_id,rtl_counts.xmac_hist7_cntr, env_counts.xmac_hist7_cntr, "xmac_hist7_cntr"); | |
225 | compare(rtl_counts.mac_id,rtl_counts.mac_mpszer_cntr, env_counts.mac_mpszer_cntr, "mac_mpszer_cntr"); | |
226 | compare(rtl_counts.mac_id,rtl_counts.xmac_frag_cntr, env_counts.xmac_frag_cntr, "xmac_frag_cntr"); | |
227 | compare(rtl_counts.mac_id,rtl_counts.xmac_mcast_cntr, env_counts.xmac_mcast_cntr, "xmac_mcast_cntr"); | |
228 | compare(rtl_counts.mac_id,rtl_counts.xmac_bcast_cntr, env_counts.xmac_bcast_cntr, "xmac_bcast_cntr"); | |
229 | compare(rtl_counts.mac_id,rtl_counts.mac_codevio_cntr, env_counts.mac_codevio_cntr, "mac_codevio_cntr"); | |
230 | } | |
231 | else if (rtl_counts.mac_id==0 || rtl_counts.mac_id==1) { | |
232 | compare(rtl_counts.mac_id,rtl_counts.mac_crc_cntr, env_counts.mac_crc_cntr, "mac_crc_cntr"); | |
233 | compare(rtl_counts.mac_id,rtl_counts.bmac_frame_cntr, env_counts.bmac_frame_cntr, "bmac_frame_cntr"); | |
234 | compare(rtl_counts.mac_id,rtl_counts.mac_mpszer_cntr, env_counts.mac_mpszer_cntr, "mac_mpszer_cntr"); | |
235 | compare(rtl_counts.mac_id,rtl_counts.mac_codevio_cntr, env_counts.mac_codevio_cntr, "mac_codevio_cntr"); | |
236 | compare(rtl_counts.mac_id,rtl_counts.bmac_alignerr_cntr, env_counts.bmac_alignerr_cntr, "bmac_alignerr_cntr"); | |
237 | } | |
238 | ||
239 | } | |
240 | ||
241 | task rx_exit_tools::compare(integer port_num, integer rtl_cnt, integer env_cnt, string name_str) { | |
242 | if (rtl_cnt!==env_cnt) { | |
243 | be_msg.print(e_mesg_error,"rx_exit_tools", "Counter Mismatch", | |
244 | "%s: Expected %0d Observed %0d \n", name_str, env_cnt, rtl_cnt); | |
245 | } | |
246 | else { | |
247 | printf ("rx_exit_tools.compare Counter %s matched between env and rtl for port %0d\n", | |
248 | name_str, port_num); | |
249 | } | |
250 | } |