// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: niu_rxdma_wr_chk.vr // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved // 4150 Network Circle, Santa Clara, California 95054, U.S.A. // // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // For the avoidance of doubt, and except that if any non-GPL license // choice is available it will apply instead, Sun elects to use only // the General Public License version 2 (GPLv2) at this time for any // software where a choice of GPL license versions is made // available with the language indicating that GPLv2 or any later version // may be used, or where a choice of which version of the GPL is applied is // otherwise unspecified. // // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, // CA 95054 USA or visit www.sun.com if you need additional information or // have any questions. // // ========== Copyright Header End ============================================ #include #include "cMesg.vrh" #include "mbox_defines.vri" #include "mbox_class.vrh" #include "get_mbox_id.vrh" #include "pg_top_pp.vrh" #include "niu_mem.vrh" #include "niu_rxdmc.vrh" #include "niu_rx_descp.vrh" #include "niu_rxtoken.vrh" #include "niu_cbclass.vrh" #include "niu_cb_events.vri" #include "niu_rxcbmgr.vrh" #include "niu_rxdma_pkttab.vrh" #include "niu_rxdma_pktchk.vrh" extern event RX_chk_done; extern mbox_class mbox_id; extern Mesg be_msg; extern pg pack_gen[16]; extern CSparseMem SparseMem; extern CRDMC rdmc; class rxdma_wr_buf_cl { bit [7:0] val []; } class Cniu_rxdma_wr_chkr { integer mac_token = -1; integer wrchk_timeout_val = 1000 ; integer no_of_pkts_chkd = 0; integer no_of_pkts_discarded = 0; integer WRITE_TIMEOUT; bit debug_en; bit [3:0] ports_active; bit [3:0] last_packet_seen; CcbRxWriteMgr cbRxWriteMgr; CRxDmaPktChk RxDmaPktChk; integer use_cr_address; integer use_old_timeout; integer rx_pkt_buf_offset; task new (); local task protocol_chk_select(); local task count_pkts_chkd (); local task count_pkts_chkd_old (/*TO BE REMOVED *** TMP ONLY*/); local task StartPacketCheck (); local task SpDropPacketsCheck(); local function integer getToken( var CRxToken RxToken ); local task check_good_packet( CRxToken RxToken); local task check_drop_packet( CRxToken RxToken); local task check_packet(CRxToken RxToken, integer semId ); local task free_memory(CRxToken RxToken ); local task processTestDefines(CRxToken RxToken ); local function bit[63:0] processErrorCodes(CRxToken RxToken ); } task Cniu_rxdma_wr_chkr::new() { string init_mac_ports,temp_port; bit[31:0] get_mac_port; integer i; ports_active = 0; if( get_plus_arg( CHECK, "GET_MAC_PORTS=")) get_mac_port = get_plus_arg( STR, "GET_MAC_PORTS="); init_mac_ports.bittostr(get_mac_port); for (i=0; i= (WRITE_TIMEOUT/10) ){ printf("ERROR: TIMEOUT PACKET WRITES \n"); be_msg.print(e_mesg_error, "Cniu_rxdma_wr_chkr::check_packet", "PacketWrite TimeOut","Address - %x \ PacketID - %0d PortId - %0d DMA - %0d \n",exp_address,gId,mac_id,RxToken.dma_num); exit(0); } cbRxWriteMgr.releaseSemId(semId); #ifdef N2_FC repeat(1000) @(posedge CLOCK); // printf("%0d : MAQ-Debug: After 100 Clocks \n", {get_time(HI), get_time(LO)}); #else repeat(10) @(posedge CLOCK); #endif nb = new(); rxdma_wrbuf = new(); //pack_gen[mac_id].build_frame(RxToken.pgToken.gId,RxToken.pgToken.pack_db, nb, rx_len); #ifdef MAC_SAT #else nb = new RxToken.pgToken.buf; #endif pack_gen[mac_id].display_buf(nb,rx_len,0); offset = 0; bytes_mismatched = 0; for(k = 0; k < RxToken.NoOfScatter; k ++) { rx_len = RxToken.bytesperchunk[k]; NoOf8Bytes = ( (rx_len)/8) + ( ((rx_len) %8) ? 1 :0 ) ; mem_rd_addr = RxToken.packet_start_address[k]; printf("RDMC DEBUG TheNoOf8Bytes is %0d\n", NoOf8Bytes); for(index=0;index =0 ) { for ( n =0; n< 8; n++) { rxdma_wrbuf.val[offset++] = mem_rd_data[i:j]; i +=8; j +=8; } } } } total_offset = RxToken.header_length; printf ("total_offset=%0d\n", total_offset); ctrlhdr = new(); ctrlhdr_len = total_offset - rx_pkt_buf_offset; for(i=0;i>6; else if (ctrlhdr_len == 18) // for 18B hdr, second cycle has the port_num info port_num_from_pkt = ( ctrlhdr.val[16] & 8'hc0)>>6; expected_port_num = mac_id; // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Checking the fields in the control header // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ----------- PORT NUM check in control header ----------- if (expected_port_num !== port_num_from_pkt) be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet", "CNTL_HDR_MISMATCH, PORT_NUM: niu_rx_chkr[%0d]: Token: %0d Port# Expected %0h \ Port# Got %0h\n", mac_id, gId, expected_port_num, port_num_from_pkt); if(get_plus_arg (CHECK, "ENABLE_RX_CNTL_HDR_CHECK")) { // Collect the expected control header fields exp_cntl_hdr_B0 = RxToken.rx_cntl_hdr.val[0]; exp_cntl_hdr_B1 = RxToken.rx_cntl_hdr.val[1]; exp_port_num = exp_cntl_hdr_B0[7:6]; exp_maccheck = exp_cntl_hdr_B0[5]; exp_packet_class = exp_cntl_hdr_B0[4:0]; exp_vlan = exp_cntl_hdr_B1[7]; exp_llcsnap = exp_cntl_hdr_B1[6]; exp_noport = exp_cntl_hdr_B1[5]; exp_badip = exp_cntl_hdr_B1[4]; exp_tcamhit = exp_cntl_hdr_B1[3]; exp_tres = exp_cntl_hdr_B1[2:1]; exp_tzfvld = exp_cntl_hdr_B1[0]; // Collect the RTL control header fields got from memory rtl_cntl_hdr_B0 = rxdma_wrbuf.val[0]; rtl_cntl_hdr_B1 = rxdma_wrbuf.val[1]; rtl_port_num = rtl_cntl_hdr_B0[7:6]; rtl_maccheck = rtl_cntl_hdr_B0[5]; rtl_packet_class = rtl_cntl_hdr_B0[4:0]; rtl_vlan = rtl_cntl_hdr_B1[7]; rtl_llcsnap = rtl_cntl_hdr_B1[6]; rtl_noport = rtl_cntl_hdr_B1[5]; rtl_badip = rtl_cntl_hdr_B1[4]; rtl_tcamhit = rtl_cntl_hdr_B1[3]; rtl_tres = rtl_cntl_hdr_B1[2:1]; rtl_tzfvld = rtl_cntl_hdr_B1[0]; printf("CNTL_HDR_CHECK: ---------------------------------------------------\n"); printf("CNTL_HDR_CHECK: RX CONTROL HEADER CHECK IN MEMORY CHECKER \n"); printf("CNTL_HDR_CHECK: ---------------------------------------------------\n"); printf("CNTL_HDR_CHECK: RTL MODEL \n"); printf("CNTL_HDR_CHECK: ---------------------------------------------------\n"); if (rtl_tzfvld!==exp_tzfvld) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TZFVLD = %0h\t\t%0h\n", rtl_tzfvld, exp_tzfvld); else printf("CNTL_HDR_CHECK: TZFVLD = %0h\t\t%0h\n", rtl_tzfvld, exp_tzfvld); if (rtl_tres!==exp_tres) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TRES = %0h\t\t%0h\n", rtl_tres, exp_tres); else printf("CNTL_HDR_CHECK: TRES = %0h\t\t%0h\n", rtl_tres, exp_tres); if (rtl_tcamhit!==exp_tcamhit) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "TCAM-Hit = %0h\t\t%0h\n", rtl_tcamhit, exp_tcamhit); else printf("CNTL_HDR_CHECK: TCAM-Hit = %0h\t\t%0h\n", rtl_tcamhit, exp_tcamhit); if (exp_badip!==exp_badip) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "Bad-IP = %0h\t\t%0h\n", exp_badip, exp_badip); else printf("CNTL_HDR_CHECK: Bad-IP = %0h\t\t%0h\n", exp_badip, exp_badip); if (rtl_noport!==exp_noport) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "No-port = %0h\t\t%0h\n", rtl_noport, exp_noport); else printf("CNTL_HDR_CHECK: No-port = %0h\t\t%0h\n", rtl_noport, exp_noport); if (rtl_llcsnap!==exp_llcsnap) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "LLC-SNAP = %0h\t\t%0h\n", rtl_llcsnap, exp_llcsnap); else printf("CNTL_HDR_CHECK: LLC-SNAP = %0h\t\t%0h\n", rtl_llcsnap, exp_llcsnap); if (rtl_vlan!==exp_vlan) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "VLAN = %0h\t\t%0h\n", rtl_vlan, exp_vlan); else printf("CNTL_HDR_CHECK: VLAN = %0h\t\t%0h\n", rtl_vlan, exp_vlan); if (rtl_packet_class!==exp_packet_class) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "CLASS = %0h\t\t%0h\n", rtl_packet_class, exp_packet_class); else printf("CNTL_HDR_CHECK: CLASS = %0h\t\t%0h\n", rtl_packet_class, exp_packet_class); if (rtl_maccheck!==exp_maccheck) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "MAC-check = %0h\t\t%0h\n", rtl_maccheck, exp_maccheck); else printf("CNTL_HDR_CHECK: MAC-check = %0h\t\t%0h\n", rtl_maccheck, exp_maccheck); if (rtl_port_num!==exp_port_num) be_msg.print(e_mesg_error,"CNTL_HDR_CHECK", "", "MAC-PORT = %0h\t\t%0h\n", rtl_port_num, exp_port_num); else printf("CNTL_HDR_CHECK: MAC-PORT = %0h\t\t%0h\n", rtl_port_num, exp_port_num); printf("CNTL_HDR_CHECK: ---------------------------------------------------\n"); } if (debug_en) printf ("total offset for the packet# %0d is %0d\n", gId, total_offset); m = RxToken.pkt_length; for( n = 0; n < m; n = n + 1) { if( nb.val[n] !== rxdma_wrbuf.val [n+total_offset]) { // check after "total_offset" number of Bytes be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet", "DATA_MISMATCH:niu_rx_chkr[%0d]: Token: %0d Word[%0d] Got %0h \ Expected %0h\n", mac_id, gId, n,rxdma_wrbuf.val[n+total_offset], nb.val[n] ); bytes_mismatched ++; } else { if (debug_en) be_msg.print(e_mesg_info, "niu_rx_chkr", "check_packet", "Packet Successfully Written:niu_rx_chkr[%0d]: Token: %0d Word[%0d] Got %0h \ Expected %0h\n", mac_id, gId, n,rxdma_wrbuf.val[n+total_offset], nb.val[n] ); } } no_of_pkts_chkd++; if (!bytes_mismatched) { printf ("Completed RX packet check of Token: %0d arrived at dma_num %0d from port %0d, Len %0d\n", gId, RxToken.dma_num, mac_id, RxToken.pkt_length); printf ("Number of RX packets checked is %0d \n", no_of_pkts_chkd); } else { if (get_plus_arg (CHECK,"EXIT_CHKR_ON_DATA_MISMATCH")) { be_msg.print(e_mesg_error, "niu_rx_chkr", "check_packet", "ERROR:niu_rx_chkr[%0d]: RX packet %0d has DATA_MISMATCH. Exiting the Test.\n", mac_id, gId); repeat (100) @(posedge CLOCK); exit(0); } } if (debug_en) printf ("Exiting check_packet in niu_rx_chkr \n"); free_memory(RxToken); } task Cniu_rxdma_wr_chkr::free_memory(CRxToken RxToken ){ rdmc.rx_dma[RxToken.dma_num ].free_memory(RxToken); }