Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / niu / rxc_sat / vera / checkers / mem_checker / niu_rxdma_wr_chk.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_rxdma_wr_chk.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
37
38#include "cMesg.vrh"
39#include "mbox_defines.vri"
40#include "mbox_class.vrh"
41#include "get_mbox_id.vrh"
42#include "pg_top_pp.vrh"
43
44#include "niu_mem.vrh"
45#include "niu_rxdmc.vrh"
46#include "niu_rx_descp.vrh"
47#include "niu_rxtoken.vrh"
48#include "niu_cbclass.vrh"
49#include "niu_cb_events.vri"
50#include "niu_rxcbmgr.vrh"
51#include "niu_rxdma_pkttab.vrh"
52#include "niu_rxdma_pktchk.vrh"
53
54
55extern event RX_chk_done;
56extern mbox_class mbox_id;
57extern Mesg be_msg;
58extern pg pack_gen[16];
59
60extern CSparseMem SparseMem;
61
62extern CRDMC rdmc;
63
64
65
66
67
68class rxdma_wr_buf_cl {
69
70 bit [7:0] val [];
71}
72
73class Cniu_rxdma_wr_chkr {
74
75 integer mac_token = -1;
76 integer wrchk_timeout_val = 1000 ;
77 integer no_of_pkts_chkd = 0;
78 integer no_of_pkts_discarded = 0;
79 integer WRITE_TIMEOUT;
80 bit debug_en;
81 bit [3:0] ports_active;
82 bit [3:0] last_packet_seen;
83
84 CcbRxWriteMgr cbRxWriteMgr;
85 CRxDmaPktChk RxDmaPktChk;
86 integer use_cr_address;
87 integer use_old_timeout;
88 integer rx_pkt_buf_offset;
89
90 task new ();
91 local task protocol_chk_select();
92 local task count_pkts_chkd ();
93 local task count_pkts_chkd_old (/*TO BE REMOVED *** TMP ONLY*/);
94 local task StartPacketCheck ();
95 local task SpDropPacketsCheck();
96 local function integer getToken( var CRxToken RxToken );
97 local task check_good_packet( CRxToken RxToken);
98 local task check_drop_packet( CRxToken RxToken);
99 local task check_packet(CRxToken RxToken, integer semId );
100 local task free_memory(CRxToken RxToken );
101
102 local task processTestDefines(CRxToken RxToken );
103 local function bit[63:0] processErrorCodes(CRxToken RxToken );
104
105}
106
107
108task Cniu_rxdma_wr_chkr::new() {
109 string init_mac_ports,temp_port;
110 bit[31:0] get_mac_port;
111 integer i;
112 ports_active = 0;
113 if( get_plus_arg( CHECK, "GET_MAC_PORTS="))
114 get_mac_port = get_plus_arg( STR, "GET_MAC_PORTS=");
115 init_mac_ports.bittostr(get_mac_port);
116 for (i=0; i<init_mac_ports.len();i++)
117 {
118 temp_port =init_mac_ports.substr(i,i);
119 ports_active = ports_active | ( 1<<temp_port.atoi());
120 }
121
122 printf("Cniu_rxdma_wr_chkr::new ports_active - %x\n",ports_active);
123
124 last_packet_seen = 0;
125
126 if (get_plus_arg (CHECK, "RXDMA_WR_CHK_DEBUG_EN"))
127 debug_en = 1;
128 else
129 debug_en = 0;
130 if (get_plus_arg (CHECK, "USE_OLD_TIMEOUT"))
131 use_old_timeout = 1;
132 else
133 use_old_timeout = 0;
134
135 if (get_plus_arg (CHECK, "RX_PKT_BUF_OFFSET"))
136 rx_pkt_buf_offset = get_plus_arg (NUM, "RX_PKT_BUF_OFFSET");
137 else
138 rx_pkt_buf_offset = 0;
139
140 if (get_plus_arg (CHECK, "RXWRITE_TIMEOUT"))
141 WRITE_TIMEOUT = get_plus_arg (NUM, "RXWRITE_TIMEOUT");
142 else
143 WRITE_TIMEOUT = 5000;
144 if(get_plus_arg (CHECK, "RXDMA_WR_CHK_USE_CR")) {
145 use_cr_address = 1;
146 cbRxWriteMgr = new(40 /* MAX SPAWNED TASKS */);
147 } else {
148 use_cr_address = 0;
149 cbRxWriteMgr = new(10 /* MAX SPAWNED TASKS */);
150 }
151 fork {
152 StartPacketCheck ();
153 } join none
154
155 if(use_old_timeout) {
156 fork {
157 count_pkts_chkd_old();
158 } join none
159 }
160
161 if (get_plus_arg (CHECK, "RX_DROP_PKT_CHECK"))
162 RxDmaPktChk = new();
163}
164
165task Cniu_rxdma_wr_chkr::count_pkts_chkd_old(/*TO BE REMOVED *** TMP ONLY*/ ) {
166
167 integer no_of_pkts;
168
169
170 if (get_plus_arg (CHECK, "RXMAC_PKTCNT"))
171 no_of_pkts = get_plus_arg (NUM, "RXMAC_PKTCNT");
172 else
173 no_of_pkts = 1;
174 if (get_plus_arg (CHECK, "WRCHK_TO"))
175 wrchk_timeout_val = get_plus_arg (NUM, "WRCHK_TO");
176 else
177 wrchk_timeout_val = 1000;
178
179
180
181 repeat(wrchk_timeout_val*no_of_pkts) @(posedge CLOCK);
182 printf("In count_pkts_chkd : no_of_pkts- %d no_of_pkts_chkd - %d \n",no_of_pkts,no_of_pkts_chkd);
183
184 if ( (no_of_pkts_chkd+no_of_pkts_discarded) != no_of_pkts){
185 printf(" Cniu_rxdma_wr_chkr: ERROR: Not all RX packets written into memory. \
186 total_no_of_pkts = %0d, no_of_pkts_chkd = %0d, no_of_pkts_discarded = %0d\n",
187 no_of_pkts, no_of_pkts_chkd, no_of_pkts_discarded);
188 be_msg.print(e_mesg_error,"rxdma_wr_chkr", "count_pkts_chkd",
189 " Not all RX packets written into memory\n");
190
191 repeat(2) @(posedge CLOCK);
192 }
193 trigger (ON, RX_chk_done);
194 printf("In count_pkts_chkd : Triggered event RX_chk_done \n");
195}
196
197task Cniu_rxdma_wr_chkr::count_pkts_chkd( ) {
198
199 integer last_packet_timeout;
200 integer no_of_pkts;
201 integer pkts_per_flow;
202
203 if (get_plus_arg (CHECK, "STATEFULL_FLOW"))
204 {
205 if (get_plus_arg (CHECK, "PKTS_PER_FLOW="))
206 {
207 pkts_per_flow = get_plus_arg (NUM, "PKTS_PER_FLOW");
208 }
209 else
210 {
211 pkts_per_flow = 3;
212 }
213 }
214 else
215 {
216 pkts_per_flow = 1;
217 }
218
219 if (get_plus_arg (CHECK, "RXMAC_PKTCNT"))
220 no_of_pkts = pkts_per_flow * get_plus_arg (NUM, "RXMAC_PKTCNT");
221 else
222 no_of_pkts = 1 * pkts_per_flow; // Should not assume 1, better to print error to user
223
224
225 if (get_plus_arg (CHECK, "LAST_RXPKT_TO"))
226 last_packet_timeout = get_plus_arg (NUM, "LAST_RXPKT_TO");
227 else
228 last_packet_timeout = WRITE_TIMEOUT + 1000 ;
229
230
231 repeat(last_packet_timeout) @(posedge CLOCK);
232 printf("In count_pkts_chkd : no_of_pkts- %d no_of_pkts_chkd - %d \n",no_of_pkts,no_of_pkts_chkd);
233
234 if ( (no_of_pkts_chkd+no_of_pkts_discarded) != no_of_pkts){
235 printf(" Cniu_rxdma_wr_chkr: ERROR: Not all RX packets written into memory. \
236 total_no_of_pkts = %0d, no_of_pkts_chkd = %0d, no_of_pkts_discarded = %0d\n",
237 no_of_pkts, no_of_pkts_chkd, no_of_pkts_discarded);
238 be_msg.print(e_mesg_error,"rxdma_wr_chkr", "count_pkts_chkd",
239 " Not all RX packets written into memory\n");
240
241 repeat(2) @(posedge CLOCK);
242 }
243 trigger (ON, RX_chk_done);
244 printf("In count_pkts_chkd : Triggered event RX_chk_done \n");
245}
246
247
248function integer Cniu_rxdma_wr_chkr:: getToken( var CRxToken RxToken ) {
249 integer no_of_tokens;
250 no_of_tokens = mailbox_get(WAIT,mbox_id.niu_rxpacket_memchk_mb, RxToken);
251 printf(" No of Tokens left to check - %d \n", no_of_tokens);
252 if(RxToken == null) {
253 printf("ERROR Cniu_rxdma_wr_chkr::getToken -Failed for port \n");
254 getToken = -1;
255 }
256 getToken = 1;
257}
258
259task Cniu_rxdma_wr_chkr::SpDropPacketsCheck() {
260 integer semId;
261 integer status;
262 semId = cbRxWriteMgr.getdroppktSemId();
263
264 while(1) {
265 status = semaphore_get(WAIT,semId,1);
266 @(posedge CLOCK);
267 printf(" ERROR -- Packet Not expected to be written !!!! \n");
268 return;
269 }
270
271}
272
273
274task Cniu_rxdma_wr_chkr::StartPacketCheck() {
275
276// Task which parses various tokens and spawns off different call back
277// routines
278
279integer status;
280integer pkt_type;
281integer mac_id,gId;
282bit[63:0] error_code;
283CRxToken RxToken;
284
285
286
287
288// First get the token
289 while (1) {
290 status = getToken(RxToken);
291 if(status == -1) {
292 printf(" ERROR Occurred during Cniu_rxdma_wr_chkr:: getToken \n");
293 return;
294 }
295 mac_id = RxToken.port_num;
296 gId = RxToken.id;
297 printf(" Received a Token- Packet Originated at port = %d \n",mac_id);
298
299// Now check for available callbacks-- Dont want to spawn off too many
300// call backs
301
302
303while(!cbRxWriteMgr.isAvailable() ) {
304 // wait---
305 repeat(10) @(posedge CLOCK);
306}
307
308printf(" CcbRxWriteMgr::isAvailable is available - Current value - %d \n",cbRxWriteMgr.isAvailable());
309
310// check if this token belongs to the last packet of the sims
311 if(use_old_timeout ==0) { //TMP ONLY
312 if(RxToken.last_packet) {
313
314 last_packet_seen[RxToken.port_num] = 1;
315 printf(" Cniu_rxdma_wr_chkr::StartPacketCheck Last Packet Token Received from Port- %d Time - %d \n",RxToken.port_num,{get_time(HI), get_time(LO)});
316
317 printf(" port_active - %x last_packet_seen - %x \n",ports_active,last_packet_seen);
318 if(last_packet_seen == ports_active) {
319 printf(" Cniu_rxdma_wr_chkr::StartPacketCheck Last Packet Token Received from All Active Ports- Time - %d \n",{get_time(HI), get_time(LO)});
320 fork {
321 count_pkts_chkd();
322 } join none
323 }
324 }
325
326}
327
328
329
330
331// check token for the type of callback needed ie -
332// if this is a drop packet or a good packet
333
334 error_code = processErrorCodes(RxToken);
335 printf ("niu_rxdma_wr_chk.vr: error_code from processErrorCodes = %0d, pkt_num = %0d\n", error_code, RxToken.pgToken.gId);
336 processTestDefines(RxToken);
337
338 case(error_code) {
339 RX_TEST_CLASS_NO_ERR0R: {
340 pkt_type = RxToken.pkt_type;
341 if(pkt_type == GOOD_RxPKT) {
342 check_good_packet(RxToken);
343 printf("GOOD_RxPKT received pkt_num %0d\n", RxToken.pgToken.gId);
344 } else if(pkt_type == DROP_RxPKT) {
345 check_drop_packet(RxToken);
346 no_of_pkts_discarded ++;
347 } else if(pkt_type == RUNT_DROP_RxPKT) {
348 printf(" Packet id - %d Dropped by Checker - RUNT pkt has been sent to rtl. rtl will drop this pkt as well \n",RxToken.pgToken.gId);
349 no_of_pkts_discarded ++;
350 } else if(pkt_type == RNGFULL_DROP_RxPKT) {
351 printf(" Packet id - %d Dropped by Checker - RING is either FULL, EMPTY or is not initialized \n",RxToken.pgToken.gId);
352 no_of_pkts_discarded ++;
353 } else if(pkt_type == BUFFSIZE_EXCEEDED_DROP_RxPKT) {
354 printf(" Packet id - %d Dropped by Checker - PktSize Exceeded the programmed buf size \n",RxToken.pgToken.gId);
355 no_of_pkts_discarded ++;
356 } else if(pkt_type == VALID_DISABLED_DROP_RxPKT) {
357 printf(" Packet id - %d Dropped by Checker - All 3 buffer size valid bits are OFF \n",RxToken.pgToken.gId);
358 no_of_pkts_discarded ++;
359 } else if(pkt_type == CRCACHE_FULL_DROP_RxPKT) {
360 printf(" Packet id - %d Dropped by Checker - Completion Ring Cache FULL \n",RxToken.pgToken.gId);
361 no_of_pkts_discarded ++;
362 }
363 }
364 MEM_ERR0R_RBR_CACHE_PARITY_ERR: {
365 printf(" Packet id - %d Dropped by Checker - due to MEM_ERR0R_RBR_CACHE_PARITY_ERR\n", RxToken.pgToken.gId);
366 no_of_pkts_discarded ++;
367 }
368 MEM_ERR0R_RCR_CACHE_PARITY_ERR: {
369 printf(" Packet id - %d Dropped by Checker - due to MEM_ERR0R_RCR_CACHE_PARITY_ERR\n", RxToken.pgToken.gId);
370 no_of_pkts_discarded ++;
371 }
372 MEM_ERR0R_IPP_DFIFO_DOUBLE_BIT_ECC: {
373 printf(" Packet id - %d Dropped by Checker - due to MEM_ERR0R_IPP_DFIFO_DOUBLE_BIT_ECC\n", RxToken.pgToken.gId);
374 no_of_pkts_discarded ++;
375 }
376 NEP_RD_HOST_PEU_ECRC_ERR: {
377 printf(" Packet id - %d Dropped by Checker - due to NEP_RD_HOST_PEU_ECRC_ERR\n", RxToken.pgToken.gId);
378 no_of_pkts_discarded ++;
379 }
380 NEP_RD_HOST_PEU_POISON_ERR: {
381 printf(" Packet id - %d Dropped by Checker - due to NEP_RD_HOST_PEU_POISON_ERR\n", RxToken.pgToken.gId);
382 no_of_pkts_discarded ++;
383 }
384 NEP_RD_HOST_PEU_MAL_LEN_TLP_ERR: {
385 printf(" Packet id - %d Dropped by Checker - due to NEP_RD_HOST_PEU_MAL_LEN_TLP_ERR\n", RxToken.pgToken.gId);
386 no_of_pkts_discarded ++;
387 }
388 NEP_RD_HOST_PEU_MAL_TLP_NULL_ERR: {
389 printf(" Packet id - %d Dropped by Checker - due to NEP_RD_HOST_PEU_MAL_TLP_NULL_ERR\n", RxToken.pgToken.gId);
390 no_of_pkts_discarded ++;
391 }
392 NEP_RD_HOST_PEU_MAL_TLP_NULL_PLOAD_ERR: {
393 printf(" Packet id - %d Dropped by Checker - due to NEP_RD_HOST_PEU_MAL_TLP_NULL_PLOAD_ERR\n", RxToken.pgToken.gId);
394 no_of_pkts_discarded ++;
395 }
396 RX_TEST_CLASS_MAYBE_DROPED : {
397 printf(" Packet id - %d Dropped by Checker - due to RX_TEST_CLASS_MAYBE_DROPED \n", RxToken.pgToken.gId);
398 printf(" Packet id - %d Dropped by Checker - RX_TEST_CLASS_MAYBE_DROPED USED ONLY WITH RESETS \n", RxToken.pgToken.gId);
399 no_of_pkts_discarded ++;
400 }
401 default: { }
402 } // case
403
404 }
405}
406
407task Cniu_rxdma_wr_chkr::check_drop_packet( CRxToken RxToken ) {
408
409 bit[63:0] mem_rd_addr;
410 integer semId ;
411 CcbMem cb;
412
413 // This task needs to set the callback for the address where the packet
414 // is not expected to be written
415 // If the packet gets written, this should flag an error
416
417 semId = cbRxWriteMgr.getdroppktSemId();
418
419 mem_rd_addr = RxToken.packet_end_address[0];
420 cb = new(semId);
421 cb.set(mem_rd_addr,DROP_PACKET) ;
422 SparseMem.setCallBack(cb);
423 mem_rd_addr = RxToken.packet_start_address[0];
424 cb = new(semId);
425 cb.set(mem_rd_addr,DROP_PACKET) ;
426 SparseMem.setCallBack(cb);
427
428}
429
430
431task Cniu_rxdma_wr_chkr::check_good_packet( CRxToken RxToken) {
432
433 integer semId ;
434 integer i;
435
436 if(use_cr_address) {
437 semId = cbRxWriteMgr.getgoodpktSemId(RxToken.cr_address, 20000 /* CHOOSE THIS NO*/ );
438 printf(" Spawning off check_packet id - %d -- Address - %x \n",semId,RxToken.cr_address);
439 } else {
440 semId = cbRxWriteMgr.getgoodpktSemId(RxToken.packet_end_address[ RxToken.NoOfScatter -1 ]);
441 printf(" Spawning off check_packet id - %d -- NoOfScatter - %d Address - %x \n",semId,RxToken.NoOfScatter,RxToken.packet_end_address[ RxToken.NoOfScatter -1 ]);
442 }
443
444 if(semId == -1) {
445 printf(" TESTBENCH ERROR -- FIX IT\n");
446 }
447
448 fork {
449 check_packet(RxToken,semId);
450 } join none
451
452
453
454}
455
456function bit[63:0] Cniu_rxdma_wr_chkr::processErrorCodes(CRxToken RxToken){
457 if(RxToken.rx_test_class!=null){
458 if(RxToken.rx_test_class.valid){
459 processErrorCodes = RxToken.rx_test_class.errors.isErrSet();
460 }
461 else{
462 processErrorCodes = 0;
463 }
464 }
465}
466
467task Cniu_rxdma_wr_chkr::processTestDefines(CRxToken RxToken ){
468 bit[63:0] start_address,end_address;
469 integer semId;
470 CcbMem cb;
471
472 if(RxToken.rx_test_class!=null){
473 if(RxToken.rx_test_class.valid) {
474 if(RxToken.rx_test_class.test_defines & RX_SEMID_START_ADDR) {
475 semId = RxToken.rx_test_class.semId[RX_SEMID_START_ADDR];
476 start_address = RxToken.packet_start_address[0];
477 cb = new(semId);
478 cb.set(start_address, GOOD_PACKET);
479 SparseMem.setCallBack(cb);
480 }
481 if(RxToken.rx_test_class.test_defines & RX_SEMID_END_ADDR) {
482 semId = RxToken.rx_test_class.semId[RX_SEMID_END_ADDR];
483 end_address = RxToken.packet_end_address[RxToken.NoOfScatter -1]-16;
484 cb = new(semId);
485 cb.set(end_address, GOOD_PACKET);
486 SparseMem.setCallBack(cb);
487 }
488 }
489 }
490
491}
492
493task Cniu_rxdma_wr_chkr::check_packet(CRxToken RxToken, integer semId ){
494
495integer rx_len;
496integer NoOf8Bytes;
497integer index,offset;
498integer i,j,n,m;
499integer match;
500integer status;
501bit [63:0] mem_rd_data;
502bit [39:0] mem_rd_addr;
503bit [39:0] exp_address;
504bit [39:0] cr_address;
505integer mac_id,gId;
506CcbMem cb;
507integer k;
508integer sem_cnt;
509byte_array rxdma_wrbuf;
510byte_array nb,ctrlhdr;
511integer bytes_mismatched;
512integer total_offset, expected_port_num, port_num_from_pkt;
513integer ctrlhdr_len;
514
515bit [7:0] exp_cntl_hdr_B0, exp_cntl_hdr_B1, rtl_cntl_hdr_B0, rtl_cntl_hdr_B1;
516bit [1:0] exp_port_num, rtl_port_num, exp_tres, rtl_tres;
517bit exp_maccheck, rtl_maccheck;
518bit [4:0] exp_packet_class, rtl_packet_class;
519bit exp_vlan,exp_llcsnap,exp_noport,exp_badip,exp_tcamhit,exp_tzfvld;
520bit rtl_vlan,rtl_llcsnap,rtl_noport,rtl_badip,rtl_tcamhit,rtl_tzfvld;
521
522
523 mac_id = RxToken.port_num;
524 gId = RxToken.id;
525 printf(" Starting check_packet for Tokenid - %d - Packet Originated at port = %d \n",gId,mac_id);
526
527 mem_rd_addr = RxToken.packet_end_address[RxToken.NoOfScatter -1];
528 cr_address = RxToken.cr_address;
529
530
531 // Set callback in the memory
532 cb = new(semId);
533 if(use_cr_address) {
534 cb.set(cr_address,GOOD_PACKET) ;
535 exp_address = cr_address;
536 }
537 else {
538 cb.set(mem_rd_addr,GOOD_PACKET) ;
539 exp_address = mem_rd_addr;
540 }
541 SparseMem.setCallBack(cb);
542
543 // processTestDefines(RxToken);
544
545 sem_cnt = 0;
546
547 fork
548 {
549 while(semaphore_get(WAIT,semId,1) == 0 ) {
550 repeat(10) @(posedge CLOCK);
551 }
552 } {
553 while(sem_cnt<(WRITE_TIMEOUT/10)) {
554 sem_cnt = sem_cnt+1;
555 repeat(10) @(posedge CLOCK);
556 }
557 } join any
558
559 if (sem_cnt >= (WRITE_TIMEOUT/10) ){
560 printf("ERROR: TIMEOUT PACKET WRITES \n");
561 be_msg.print(e_mesg_error, "Cniu_rxdma_wr_chkr::check_packet", "PacketWrite TimeOut","Address - %x \
562 PacketID - %0d PortId - %0d DMA - %0d \n",exp_address,gId,mac_id,RxToken.dma_num);
563 exit(0);
564 }
565
566 cbRxWriteMgr.releaseSemId(semId);
567
568 #ifdef N2_FC
569 repeat(1000) @(posedge CLOCK);
570 // printf("%0d : MAQ-Debug: After 100 Clocks \n", {get_time(HI), get_time(LO)});
571 #else
572 repeat(10) @(posedge CLOCK);
573 #endif
574
575 nb = new();
576 rxdma_wrbuf = new();
577 //pack_gen[mac_id].build_frame(RxToken.pgToken.gId,RxToken.pgToken.pack_db, nb, rx_len);
578#ifdef MAC_SAT
579#else
580 nb = new RxToken.pgToken.buf;
581#endif
582 pack_gen[mac_id].display_buf(nb,rx_len,0);
583
584 offset = 0;
585 bytes_mismatched = 0;
586
587 for(k = 0; k < RxToken.NoOfScatter; k ++) {
588 rx_len = RxToken.bytesperchunk[k];
589 NoOf8Bytes = ( (rx_len)/8) + ( ((rx_len) %8) ? 1 :0 ) ;
590 mem_rd_addr = RxToken.packet_start_address[k];
591 printf("RDMC DEBUG TheNoOf8Bytes is %0d\n", NoOf8Bytes);
592
593
594
595 for(index=0;index <NoOf8Bytes;index ++) {
596 SparseMem.ReadMem(mem_rd_addr + 8*index ,mem_rd_data,8'hff);
597 // CLEAN UP -----
598 i=7;
599 j=0;
600 if ( index >=0 ) {
601 for ( n =0; n< 8; n++) {
602 rxdma_wrbuf.val[offset++] = mem_rd_data[i:j];
603 i +=8;
604 j +=8;
605 }
606 }
607 }
608 }
609
610 total_offset = RxToken.header_length;
611 printf ("total_offset=%0d\n", total_offset);
612 ctrlhdr = new();
613 ctrlhdr_len = total_offset - rx_pkt_buf_offset;
614 for(i=0;i<ctrlhdr_len;i++) {
615 ctrlhdr.val[i] = rxdma_wrbuf.val[rx_pkt_buf_offset+i];
616 }
617 if (ctrlhdr_len == 2)
618 port_num_from_pkt = ( ctrlhdr.val[0] & 8'hc0)>>6;
619 else if (ctrlhdr_len == 18) // for 18B hdr, second cycle has the port_num info
620 port_num_from_pkt = ( ctrlhdr.val[16] & 8'hc0)>>6;
621
622 expected_port_num = mac_id;
623
624
625 // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
626 // Checking the fields in the control header
627 // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
628
629 // ----------- PORT NUM check in control header -----------
630 if (expected_port_num !== port_num_from_pkt)
631 be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet",
632 "CNTL_HDR_MISMATCH, PORT_NUM: niu_rx_chkr[%0d]: Token: %0d Port# Expected %0h \
633 Port# Got %0h\n", mac_id, gId, expected_port_num, port_num_from_pkt);
634
635 if(get_plus_arg (CHECK, "ENABLE_RX_CNTL_HDR_CHECK")) {
636
637 // Collect the expected control header fields
638 exp_cntl_hdr_B0 = RxToken.rx_cntl_hdr.val[0];
639 exp_cntl_hdr_B1 = RxToken.rx_cntl_hdr.val[1];
640
641 exp_port_num = exp_cntl_hdr_B0[7:6];
642 exp_maccheck = exp_cntl_hdr_B0[5];
643 exp_packet_class = exp_cntl_hdr_B0[4:0];
644 exp_vlan = exp_cntl_hdr_B1[7];
645 exp_llcsnap = exp_cntl_hdr_B1[6];
646 exp_noport = exp_cntl_hdr_B1[5];
647 exp_badip = exp_cntl_hdr_B1[4];
648 exp_tcamhit = exp_cntl_hdr_B1[3];
649 exp_tres = exp_cntl_hdr_B1[2:1];
650 exp_tzfvld = exp_cntl_hdr_B1[0];
651
652
653 // Collect the RTL control header fields got from memory
654 rtl_cntl_hdr_B0 = rxdma_wrbuf.val[0];
655 rtl_cntl_hdr_B1 = rxdma_wrbuf.val[1];
656
657 rtl_port_num = rtl_cntl_hdr_B0[7:6];
658 rtl_maccheck = rtl_cntl_hdr_B0[5];
659 rtl_packet_class = rtl_cntl_hdr_B0[4:0];
660 rtl_vlan = rtl_cntl_hdr_B1[7];
661 rtl_llcsnap = rtl_cntl_hdr_B1[6];
662 rtl_noport = rtl_cntl_hdr_B1[5];
663 rtl_badip = rtl_cntl_hdr_B1[4];
664 rtl_tcamhit = rtl_cntl_hdr_B1[3];
665 rtl_tres = rtl_cntl_hdr_B1[2:1];
666 rtl_tzfvld = rtl_cntl_hdr_B1[0];
667
668
669
670 printf("CNTL_HDR_CHECK: ---------------------------------------------------\n");
671 printf("CNTL_HDR_CHECK: RX CONTROL HEADER CHECK IN MEMORY CHECKER \n");
672 printf("CNTL_HDR_CHECK: ---------------------------------------------------\n");
673 printf("CNTL_HDR_CHECK: RTL MODEL \n");
674 printf("CNTL_HDR_CHECK: ---------------------------------------------------\n");
675
676 if (rtl_tzfvld!==exp_tzfvld)
677 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TZFVLD = %0h\t\t%0h\n", rtl_tzfvld, exp_tzfvld);
678 else
679 printf("CNTL_HDR_CHECK: TZFVLD = %0h\t\t%0h\n", rtl_tzfvld, exp_tzfvld);
680 if (rtl_tres!==exp_tres)
681 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TRES = %0h\t\t%0h\n", rtl_tres, exp_tres);
682 else
683 printf("CNTL_HDR_CHECK: TRES = %0h\t\t%0h\n", rtl_tres, exp_tres);
684 if (rtl_tcamhit!==exp_tcamhit)
685 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TCAM-Hit = %0h\t\t%0h\n", rtl_tcamhit, exp_tcamhit);
686 else
687 printf("CNTL_HDR_CHECK: TCAM-Hit = %0h\t\t%0h\n", rtl_tcamhit, exp_tcamhit);
688 if (exp_badip!==exp_badip)
689 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "Bad-IP = %0h\t\t%0h\n", exp_badip, exp_badip);
690 else
691 printf("CNTL_HDR_CHECK: Bad-IP = %0h\t\t%0h\n", exp_badip, exp_badip);
692 if (rtl_noport!==exp_noport)
693 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "No-port = %0h\t\t%0h\n", rtl_noport, exp_noport);
694 else
695 printf("CNTL_HDR_CHECK: No-port = %0h\t\t%0h\n", rtl_noport, exp_noport);
696 if (rtl_llcsnap!==exp_llcsnap)
697 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "LLC-SNAP = %0h\t\t%0h\n", rtl_llcsnap, exp_llcsnap);
698 else
699 printf("CNTL_HDR_CHECK: LLC-SNAP = %0h\t\t%0h\n", rtl_llcsnap, exp_llcsnap);
700 if (rtl_vlan!==exp_vlan)
701 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "VLAN = %0h\t\t%0h\n", rtl_vlan, exp_vlan);
702 else
703 printf("CNTL_HDR_CHECK: VLAN = %0h\t\t%0h\n", rtl_vlan, exp_vlan);
704 if (rtl_packet_class!==exp_packet_class)
705 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "CLASS = %0h\t\t%0h\n", rtl_packet_class, exp_packet_class);
706 else
707 printf("CNTL_HDR_CHECK: CLASS = %0h\t\t%0h\n", rtl_packet_class, exp_packet_class);
708 if (rtl_maccheck!==exp_maccheck)
709 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "MAC-check = %0h\t\t%0h\n", rtl_maccheck, exp_maccheck);
710 else
711 printf("CNTL_HDR_CHECK: MAC-check = %0h\t\t%0h\n", rtl_maccheck, exp_maccheck);
712 if (rtl_port_num!==exp_port_num)
713 be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "MAC-PORT = %0h\t\t%0h\n", rtl_port_num, exp_port_num);
714 else
715 printf("CNTL_HDR_CHECK: MAC-PORT = %0h\t\t%0h\n", rtl_port_num, exp_port_num);
716 printf("CNTL_HDR_CHECK: ---------------------------------------------------\n");
717
718 }
719
720
721 if (debug_en) printf ("total offset for the packet# %0d is %0d\n", gId, total_offset);
722
723 m = RxToken.pkt_length;
724 for( n = 0; n < m; n = n + 1) {
725 if( nb.val[n] !== rxdma_wrbuf.val [n+total_offset]) { // check after "total_offset" number of Bytes
726 be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet",
727 "DATA_MISMATCH:niu_rx_chkr[%0d]: Token: %0d Word[%0d] Got %0h \
728 Expected %0h\n", mac_id, gId, n,rxdma_wrbuf.val[n+total_offset], nb.val[n] );
729 bytes_mismatched ++;
730 }
731 else {
732 if (debug_en)
733 be_msg.print(e_mesg_info, "niu_rx_chkr", "check_packet",
734 "Packet Successfully Written:niu_rx_chkr[%0d]: Token: %0d Word[%0d] Got %0h \
735 Expected %0h\n", mac_id, gId, n,rxdma_wrbuf.val[n+total_offset], nb.val[n] );
736 }
737
738 }
739 no_of_pkts_chkd++;
740 if (!bytes_mismatched) {
741 printf ("Completed RX packet check of Token: %0d arrived at dma_num %0d from port %0d, Len %0d\n",
742 gId, RxToken.dma_num, mac_id, RxToken.pkt_length);
743 printf ("Number of RX packets checked is %0d \n", no_of_pkts_chkd);
744 }
745 else {
746 if (get_plus_arg (CHECK,"EXIT_CHKR_ON_DATA_MISMATCH")) {
747 be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet",
748 "ERROR:niu_rx_chkr[%0d]: RX packet %0d has DATA_MISMATCH. Exiting the Test.\n", mac_id, gId);
749 repeat (100) @(posedge CLOCK);
750 exit(0);
751 }
752 }
753
754
755 if (debug_en)
756 printf ("Exiting check_packet in niu_rx_chkr \n");
757
758 free_memory(RxToken);
759}
760
761
762
763task Cniu_rxdma_wr_chkr::free_memory(CRxToken RxToken ){
764 rdmc.rx_dma[RxToken.dma_num ].free_memory(RxToken);
765}