// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: niu_txhost_pktgen.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 #include "niu_mem.vrh" #include "dmc_memory_map.vri" #include "txc_memory_map.vri" // #include "tx_host_err_defines.vri" #include "niu_error_dfn.vri" #include "niu_dma.vrh" #include "pcg_token.vrh" #include "niu_txtoken.vrh" #include "niu_txcntrl_wd.vrh" #include "niu_tx_pktconfig.vrh" #include "niu_tx_descp.vrh" #include "cMesg.vrh" #include "pgIdgen.vrh" extern CSparseMem SparseMem; extern mbox_class mbox_id; extern Mesg be_msg; extern niu_gen_pio gen_pio_drv; function byte_array DMAChannel::generate_packets(TxPacketGenConfig PktGenConfig,CTxToken TxToken ) { byte_array packets; integer mac_id; integer d; integer token; integer port_id; integer i; CpgToken pgToken; integer LLC_HACK = 1; bit [15:0] llc_length; integer status; if(PktGenConfig.error_info.hosterrors.dma_errors == NACK_PREF_ERROR) { is_nack_pref_err = 1; nack_pref_err_addr = TxToken.xlate_desc_addr; nack_pref_err_pcaddr = TxToken.xlate_desc_addr - 64'h40; } status = SetTxError.set_up_errors(PktGenConfig,TxToken); if(status) do_not_check_packet = 1; mac_id = PktGenConfig.mac_id ; packets = new(); printf(" Generating Packets for DMA id %d , data_length = %d \n",id,PktGenConfig.data_length); if (get_plus_arg (CHECK, "RX_DROP_PKT_CHECK")) { printf("RX_DROP_PKT_CHECK is specified. MAC-SA before replacing 0x%h\n", PktGenConfig.flow.src_node.l2_addr); // modify src address for the drop checker // This is to be used only for loopback cases PktGenConfig.flow.src_node.l2_addr = pgIdgen.getMacSA(PktGenConfig.loop_back_rxdma_num,mac_id); printf("RX_DROP_PKT_CHECK is specified. MAC-SA after replacing 0x%h\n", PktGenConfig.flow.src_node.l2_addr); } else PktGenConfig.flow.src_node.l2_addr = pgIdgen.getMacSA(id,mac_id); // Need some config info which indicates the type of packets to generate pack_gen[mac_id + 8].pkt_gen( PktGenConfig.flow,PktGenConfig.data_length, 3, pgToken, O_WAIT_SEND_FAKE | O_FAKE_OUT ); printf(" data_len - %d \n",pgToken.pack_db.data_length); printf(" header len - %d \n",pgToken.pack_db.header_len[0]); token = pgToken.gId; // Copy header to out_header in pack_db pgToken.pack_db.out_header[mac_id ] = new; pgToken.pack_db.out_header[mac_id ].use_header = 0; pgToken.pack_db.out_header[mac_id ].header[0] = new; pgToken.pack_db.out_header[mac_id ].header_len[0] = pgToken.pack_db.header_len[ pgToken.pack_db.use_hdr ]; for( i = 0; i < pgToken.pack_db.out_header[mac_id ].header_len[0]; i++ ) pgToken.pack_db.out_header[mac_id].header[0].val[i] = pgToken.pack_db.header[ pgToken.pack_db.use_hdr ].val[i]; // NEW PACKET #ifdef MAC_SAT #else packets = new pgToken.buf; #endif TxToken.pgToken = new pgToken; TxToken.pgToken.exp_err = PktGenConfig.err_pkt; if(PktGenConfig.ecc_2biterr_line1) TxToken.pgToken.do_not_check = do_not_check_packet || PktGenConfig.err_pkt; else TxToken.pgToken.do_not_check = do_not_check_packet; TxToken.pgToken.tx_dma_id = id; printf("Err DEBUG ID - %d Flag - %d \n",TxToken.pgToken.gId,do_not_check_packet); printf("Err DEBUG ID - %d Flag - %d \n",TxToken.pgToken.gId,TxToken.pgToken.do_not_check); printf("gen_pkts : value of exp_err %0d\n",TxToken.pgToken.exp_err); printf("################## BEFORE HOSTPKT DISPLAY\n"); if (get_plus_arg(CHECK,"TX_VERBOSE")) { pack_gen[mac_id + 8].display_buf(packets,PktGenConfig.data_length); } if(tx_port_num == -1) { printf("ERROR- TxPort Not Bound for DMA Channel Id -%d \n",id); } else { port_id = tx_port_num; // Only for MAC loop back TxToken.loop_back_rxdma_num = PktGenConfig.loop_back_rxdma_num; TxToken.loop_back_rx_lastpacket = PktGenConfig.loop_back_rx_lastpacket; generate_tokens(port_id,token,TxToken); } generate_packets = packets; } task DMAChannel::gen_txpacket(integer ii,TxPacketGenConfig PktGenConfig) { /* ip_packets = generate_packet(config); noofdescs = check_how_many_descriptors_for_this_packet; for(i=0;i partial_chksum) psd_hdr_chksum = full_chksum - partial_chksum; else { tmp = full_chksum - 1; psd_hdr_chksum = {1'b1,tmp} - partial_chksum; } printf("stuff : partial_cksum : value of psd_hdr_chksum %0h\n",psd_hdr_chksum); inv_psd_hdr_chksum = ~psd_hdr_chksum; printf("stuff : partial_cksum : value of inv_psd_hdr_chksum %0h\n",inv_psd_hdr_chksum); ip_packets.val[index] = inv_psd_hdr_chksum[7:0]; ip_packets.val[index+1] = inv_psd_hdr_chksum[15:8]; } //--- function to calculate the index base value function integer DMAChannel:: get_index_base(TxPacketGenConfig PktGenConfig) { integer base; integer fclass; bit vlan; bit llc; bit ipver; ipver = PktGenConfig.flow.frame.frame_type[3]; vlan = PktGenConfig.flow.frame.frame_type[2]; llc = PktGenConfig.flow.frame.frame_type[0]; fclass = PktGenConfig.flow.frame.frame_class; if(ipver == 1'b0) { if(fclass == CL_TCP) { case({llc,vlan}) { 2'b00 : base = 50; 2'b01 : base = 54; 2'b10 : base = 58; 2'b11 : base = 62; } } else if(fclass == CL_UDP) { case({llc,vlan}) { 2'b00 : base = 40; 2'b01 : base = 44; 2'b10 : base = 48; 2'b11 : base = 52; } } } else { if(fclass == CL_TCP_IP_V6) { case({llc,vlan}) { 2'b00 : base = 70; 2'b01 : base = 74; 2'b10 : base = 78; 2'b11 : base = 82; } } else if(fclass == CL_UDP_IP_V6) { case({llc,vlan}) { 2'b00 : base = 60; 2'b01 : base = 64; 2'b10 : base = 68; 2'b11 : base = 72; } } } get_index_base = base; }