os/boardsupport/emulator/emulatorbsp/wpdpack/include/tme.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/emulator/emulatorbsp/wpdpack/include/tme.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,176 @@
     1.4 +/*
     1.5 + * Copyright (c) 2001 - 2003
     1.6 + * NetGroup, Politecnico di Torino (Italy)
     1.7 + * All rights reserved.
     1.8 + *
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions
    1.11 + * are met:
    1.12 + *
    1.13 + * 1. Redistributions of source code must retain the above copyright
    1.14 + * notice, this list of conditions and the following disclaimer.
    1.15 + * 2. Redistributions in binary form must reproduce the above copyright
    1.16 + * notice, this list of conditions and the following disclaimer in the
    1.17 + * documentation and/or other materials provided with the distribution.
    1.18 + * 3. Neither the name of the Politecnico di Torino nor the names of its
    1.19 + * contributors may be used to endorse or promote products derived from
    1.20 + * this software without specific prior written permission.
    1.21 + *
    1.22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.23 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.24 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.25 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.26 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.27 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.28 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.29 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.30 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.31 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.32 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.33 + *
    1.34 + */
    1.35 +
    1.36 +#ifndef __tme_include_
    1.37 +#define __tme_include_
    1.38 +
    1.39 +#ifdef WIN_NT_DRIVER
    1.40 +#include "ndis.h"
    1.41 +#else
    1.42 +#include <windows.h>
    1.43 +#endif /*WIN_NT_DRIVER*/
    1.44 +
    1.45 +#include "memory_t.h"
    1.46 +#include "time_calls.h"
    1.47 +
    1.48 +
    1.49 +/* error codes */
    1.50 +#define		TME_ERROR			0	
    1.51 +#define		TME_SUCCESS			1
    1.52 +#define		TME_TRUE			2
    1.53 +#define		TME_FALSE			3
    1.54 +
    1.55 +/* some constants */
    1.56 +#define		DEFAULT_MEM_EX_SIZE		65536
    1.57 +#define		MAX_TME_DATA_BLOCKS		4
    1.58 +#define		TME_NONE_ACTIVE			0xffffffff
    1.59 +#define		DELTA_READ				2  /* secs */
    1.60 +
    1.61 +#define		TME_LUT_ENTRIES					0x00000000  
    1.62 +#define		TME_MAX_FILL_STATE				0x00000001  /*potrebbe servire per un thread a passive level!?!?! */
    1.63 +#define		TME_REHASHING_VALUE				0x00000002	
    1.64 +#define		TME_KEY_LEN  					0x00000003
    1.65 +#define		TME_SHARED_MEMORY_BLOCKS		0x00000004
    1.66 +#define		TME_FILLED_ENTRIES				0x00000005
    1.67 +#define		TME_BLOCK_SIZE					0x00000006
    1.68 +#define		TME_EXTRA_SEGMENT_SIZE			0x00000007
    1.69 +#define		TME_LOOKUP_CODE					0x00000008
    1.70 +#define		TME_OUT_LUT_EXEC				0x00000009
    1.71 +#define		TME_FILLED_BLOCKS				0x0000000a
    1.72 +#define		TME_DEFAULT_EXEC				0x0000000b
    1.73 +#define		TME_LUT_BASE_ADDRESS			0x0000000c
    1.74 +#define		TME_SHARED_MEMORY_BASE_ADDRESS	0x0000000d
    1.75 +#define		TME_EXTRA_SEGMENT_BASE_ADDRESS	0x0000000e
    1.76 +#define		TME_LAST_FOUND					0x0000000f   /* contains the offset of the last found entry */
    1.77 +#define		TME_LAST_FOUND_BLOCK			0x00000010
    1.78 +/* TME default values */
    1.79 +#define		TME_LUT_ENTRIES_DEFAULT				32007
    1.80 +#define		TME_REHASHING_VALUE_DEFAULT			1
    1.81 +#define		TME_SHARED_MEMORY_BLOCKS_DEFAULT	16000
    1.82 +#define		TME_BLOCK_SIZE_DEFAULT				64
    1.83 +#define		TME_EXTRA_SEGMENT_SIZE_DEFAULT		0
    1.84 +#define		TME_LOOKUP_CODE_DEFAULT				0
    1.85 +#define		TME_OUT_LUT_EXEC_DEFAULT			0
    1.86 +#define		TME_DEFAULT_EXEC_DEFAULT			0
    1.87 +#define		TME_MAX_FILL_STATE_DEFAULT			15000
    1.88 +
    1.89 +#define IS_VALIDATED(src,index) (src&(1<<index))
    1.90 +
    1.91 +#define VALIDATE(src,index) src|=(1<<index);
    1.92 +
    1.93 +
    1.94 +#define FORCE_NO_DELETION(timestamp)  (struct timeval*)(timestamp)->tv_sec=0x7fffffff;
    1.95 +
    1.96 +struct __TME_DATA;
    1.97 +
    1.98 +/* TME callback prototypes */
    1.99 +typedef uint32 (*lut_fcn)(uint8 *key, struct __TME_DATA *data,MEM_TYPE *mem_ex, struct time_conv *time_ref );
   1.100 +typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, struct __TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data);
   1.101 +
   1.102 +/* DO NOT MODIFY THIS STRUCTURE!!!! GV */
   1.103 +typedef struct __RECORD
   1.104 +
   1.105 +{
   1.106 +	uint32 block;
   1.107 +	uint32 exec_fcn;
   1.108 +}
   1.109 +	RECORD, *PRECORD;
   1.110 +
   1.111 +/* TME data registers */
   1.112 +struct __TME_DATA
   1.113 +{
   1.114 +	uint32 lut_entries;
   1.115 +	uint32 max_fill_state;
   1.116 +	uint32 rehashing_value;
   1.117 +	uint32 key_len;
   1.118 +	uint32 shared_memory_blocks;
   1.119 +	uint32 filled_entries;
   1.120 +	uint32 block_size;
   1.121 +	uint32 extra_segment_size;
   1.122 +	uint32 filled_blocks;
   1.123 +	lut_fcn lookup_code;
   1.124 +	uint32 default_exec;
   1.125 +	uint32 out_lut_exec;
   1.126 +	uint8 *lut_base_address;
   1.127 +	uint8 *shared_memory_base_address;
   1.128 +	uint8 *extra_segment_base_address;
   1.129 +	struct timeval last_read;
   1.130 +	uint32	enable_deletion;
   1.131 +	uint8 *last_found;
   1.132 +};
   1.133 +
   1.134 +typedef struct __TME_DATA TME_DATA,*PTME_DATA;
   1.135 +
   1.136 +
   1.137 +
   1.138 +/* TME core */
   1.139 +typedef struct __TME_CORE
   1.140 +{
   1.141 +	uint32      working;
   1.142 +	uint32		active;
   1.143 +	uint32		validated_blocks;
   1.144 +	TME_DATA	block_data[MAX_TME_DATA_BLOCKS];
   1.145 +	uint32		active_read;
   1.146 +	
   1.147 +} TME_CORE, *PTME_CORE;
   1.148 +
   1.149 +static __inline int32 IS_DELETABLE(void *timestamp, TME_DATA *data)
   1.150 +{
   1.151 +	struct timeval *ts=(struct timeval*)timestamp;
   1.152 +
   1.153 +	if (data->enable_deletion==FALSE)
   1.154 +		return FALSE;
   1.155 +	if (data->filled_entries<data->max_fill_state)
   1.156 +		return FALSE;
   1.157 +	if ((ts->tv_sec+DELTA_READ)<data->last_read.tv_sec)
   1.158 +		return TRUE;
   1.159 +	return FALSE;
   1.160 +}
   1.161 +
   1.162 +/* functions to manage TME */
   1.163 +uint32 init_tme_block(TME_CORE *tme, uint32 block);
   1.164 +uint32 validate_tme_block(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 block, uint32 mem_ex_offset);
   1.165 +uint32 lookup_frontend(MEM_TYPE *mem_ex, TME_CORE *tme,uint32 mem_ex_offset, struct time_conv *time_ref);
   1.166 +uint32 execute_frontend(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 pkt_size,uint32 offset);
   1.167 +uint32 set_active_tme_block(TME_CORE *tme, uint32 block);
   1.168 +uint32 init_extended_memory(uint32 size, MEM_TYPE *mem_ex);
   1.169 +uint32 reset_tme(TME_CORE *tme);
   1.170 +uint32 get_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 *rval);
   1.171 +uint32 set_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 value, int32 init);
   1.172 +uint32 set_active_read_tme_block(TME_CORE *tme, uint32 block);
   1.173 +uint32 set_autodeletion(TME_DATA *data, uint32 value);
   1.174 +
   1.175 +/* function mappers */
   1.176 +lut_fcn lut_fcn_mapper(uint32 index);
   1.177 +exec_fcn exec_fcn_mapper(uint32 index);
   1.178 +
   1.179 +#endif
   1.180 \ No newline at end of file