| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: pack_db_tasks.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 "pcg_defines.vri" |
| 37 | #include "pcg_types.vri" |
| 38 | #include "pcg_classes.vrh" |
| 39 | #include "pack_db.vrh" |
| 40 | #include "mac_db.vrh" |
| 41 | #include "ipp_db.vrh" |
| 42 | #include "fflp_db.vrh" |
| 43 | |
| 44 | extern integer pack_db_index; |
| 45 | extern integer pack_db_lock; |
| 46 | extern pack_db_entry pack_db[]; |
| 47 | |
| 48 | |
| 49 | task packet_db_init() { |
| 50 | integer n; |
| 51 | |
| 52 | // Alocate Semaphores |
| 53 | pack_db_lock = alloc(SEMAPHORE,0,1,1); |
| 54 | if(pack_db_lock == 0) { |
| 55 | printf("PACKET DB: INIT: Could not allocate spaphore pack_db_lock.\n"); |
| 56 | } else pack_db_index=0; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | // |
| 61 | function integer pack_db_add_entry(integer org_port, flow_desc flow,frame_desc frame, node_desc src_node, |
| 62 | node_desc dst_node, tup_descr tup, rcv_param rx_param, tmt_param tx_param, tcp_state fl_state, integer data_length, integer ttl, bit[63:0] options, integer order_seq, |
| 63 | integer pckt_num, bit [15:0] ifedxc) { |
| 64 | integer n; |
| 65 | |
| 66 | // Set LOCK |
| 67 | semaphore_get(WAIT,pack_db_lock,1); |
| 68 | |
| 69 | pack_db[pack_db_index] = new; |
| 70 | pack_db[pack_db_index].org_port = org_port; |
| 71 | pack_db[pack_db_index].order_seq = order_seq; |
| 72 | pack_db[pack_db_index].pckt_num = pckt_num; |
| 73 | |
| 74 | pack_db[pack_db_index].flow = new flow; |
| 75 | pack_db[pack_db_index].frame = new frame; |
| 76 | pack_db[pack_db_index].src_node = new src_node; |
| 77 | pack_db[pack_db_index].dst_node = new dst_node; |
| 78 | pack_db[pack_db_index].tup = new tup; |
| 79 | pack_db[pack_db_index].rx_param = new rx_param; |
| 80 | pack_db[pack_db_index].tx_param = new tx_param; |
| 81 | pack_db[pack_db_index].fl_state = new fl_state; |
| 82 | pack_db[pack_db_index].ttl = ttl; |
| 83 | pack_db[pack_db_index].data_length = data_length; |
| 84 | pack_db[pack_db_index].options = options; |
| 85 | pack_db[pack_db_index].ifedx_control= ifedxc; |
| 86 | pack_db[pack_db_index].pg_done = 0; |
| 87 | pack_db[pack_db_index].im_check = 0; |
| 88 | |
| 89 | for(n=0;n<20;n++) |
| 90 | pack_db[pack_db_index].pc_check[n] = 0; |
| 91 | |
| 92 | pack_db_add_entry = pack_db_index; |
| 93 | |
| 94 | pack_db[pack_db_index].mac = new; |
| 95 | pack_db[pack_db_index].ipp = new; |
| 96 | pack_db[pack_db_index].fflp = new; |
| 97 | |
| 98 | pack_db[pack_db_index].use_hdr = 0; |
| 99 | pack_db[pack_db_index].pass = 0; |
| 100 | pack_db_index++; |
| 101 | |
| 102 | // Reset LOCK |
| 103 | semaphore_put(pack_db_lock,1); |
| 104 | } |
| 105 | |
| 106 | task pack_db_add_header(integer index, byte_array buf, integer start, integer len) { |
| 107 | integer n; |
| 108 | |
| 109 | // Set LOCK |
| 110 | //printf("NVN Testing task Orig Len is %d\n",len); |
| 111 | |
| 112 | semaphore_get(WAIT,pack_db_lock,1); |
| 113 | |
| 114 | len = len-start; |
| 115 | //printf("NVN The length is %d \n",len); |
| 116 | |
| 117 | pack_db[index].header[ pack_db[index].use_hdr ] = new; |
| 118 | |
| 119 | len++; |
| 120 | for(n=0;n<len;n++) |
| 121 | pack_db[index].header[ pack_db[index].use_hdr ].val[n] = buf.val[start+n]; |
| 122 | |
| 123 | pack_db[index].header_len[ pack_db[index].use_hdr ] = len; |
| 124 | |
| 125 | // Reset LOCK |
| 126 | semaphore_put(pack_db_lock,1); |
| 127 | } |
| 128 | |
| 129 | |