00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __tme_include_
00034 #define __tme_include_
00035
00036 #ifdef WIN_NT_DRIVER
00037 #include "ndis.h"
00038 #else
00039 #include <windows.h>
00040 #endif
00041
00042 #include "memory_t.h"
00043 #include "time_calls.h"
00044
00045
00046
00047 #define TME_ERROR 0
00048 #define TME_SUCCESS 1
00049 #define TME_TRUE 2
00050 #define TME_FALSE 3
00051
00052
00053 #define DEFAULT_MEM_EX_SIZE 65536
00054 #define MAX_TME_DATA_BLOCKS 4
00055 #define TME_NONE_ACTIVE 0xffffffff
00056 #define DELTA_READ 2
00057
00058 #define TME_LUT_ENTRIES 0x00000000
00059 #define TME_MAX_FILL_STATE 0x00000001
00060 #define TME_REHASHING_VALUE 0x00000002
00061 #define TME_KEY_LEN 0x00000003
00062 #define TME_SHARED_MEMORY_BLOCKS 0x00000004
00063 #define TME_FILLED_ENTRIES 0x00000005
00064 #define TME_BLOCK_SIZE 0x00000006
00065 #define TME_EXTRA_SEGMENT_SIZE 0x00000007
00066 #define TME_LOOKUP_CODE 0x00000008
00067 #define TME_OUT_LUT_EXEC 0x00000009
00068 #define TME_FILLED_BLOCKS 0x0000000a
00069 #define TME_DEFAULT_EXEC 0x0000000b
00070 #define TME_LUT_BASE_ADDRESS 0x0000000c
00071 #define TME_SHARED_MEMORY_BASE_ADDRESS 0x0000000d
00072 #define TME_EXTRA_SEGMENT_BASE_ADDRESS 0x0000000e
00073 #define TME_LAST_FOUND 0x0000000f
00074 #define TME_LAST_FOUND_BLOCK 0x00000010
00075
00076 #define TME_LUT_ENTRIES_DEFAULT 32007
00077 #define TME_REHASHING_VALUE_DEFAULT 1
00078 #define TME_SHARED_MEMORY_BLOCKS_DEFAULT 16000
00079 #define TME_BLOCK_SIZE_DEFAULT 64
00080 #define TME_EXTRA_SEGMENT_SIZE_DEFAULT 0
00081 #define TME_LOOKUP_CODE_DEFAULT 0
00082 #define TME_OUT_LUT_EXEC_DEFAULT 0
00083 #define TME_DEFAULT_EXEC_DEFAULT 0
00084 #define TME_MAX_FILL_STATE_DEFAULT 15000
00085
00086 #define IS_VALIDATED(src,index) (src&(1<<index))
00087
00088 #define VALIDATE(src,index) src|=(1<<index);
00089
00090
00091 #define FORCE_NO_DELETION(timestamp) (struct timeval*)(timestamp)->tv_sec=0x7fffffff;
00092
00093
00094 typedef uint32 (*lut_fcn)(uint8 *key, struct __TME_DATA *data,MEM_TYPE *mem_ex, struct time_conv *time_ref );
00095 typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, struct __TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data);
00096
00097
00098 typedef struct __RECORD
00099
00100 {
00101 uint32 block;
00102 uint32 exec_fcn;
00103 }
00104 RECORD, *PRECORD;
00105
00106
00107 struct __TME_DATA
00108 {
00109 uint32 lut_entries;
00110 uint32 max_fill_state;
00111 uint32 rehashing_value;
00112 uint32 key_len;
00113 uint32 shared_memory_blocks;
00114 uint32 filled_entries;
00115 uint32 block_size;
00116 uint32 extra_segment_size;
00117 uint32 filled_blocks;
00118 lut_fcn lookup_code;
00119 uint32 default_exec;
00120 uint32 out_lut_exec;
00121 uint8 *lut_base_address;
00122 uint8 *shared_memory_base_address;
00123 uint8 *extra_segment_base_address;
00124 struct timeval last_read;
00125 uint32 enable_deletion;
00126 uint8 *last_found;
00127 };
00128
00129 typedef struct __TME_DATA TME_DATA,*PTME_DATA;
00130
00131
00132
00133
00134 typedef struct __TME_CORE
00135 {
00136 uint32 working;
00137 uint32 active;
00138 uint32 validated_blocks;
00139 TME_DATA block_data[MAX_TME_DATA_BLOCKS];
00140 uint32 active_read;
00141
00142 } TME_CORE, *PTME_CORE;
00143
00144 static __inline int32 IS_DELETABLE(void *timestamp, TME_DATA *data)
00145 {
00146 struct timeval *ts=(struct timeval*)timestamp;
00147
00148 if (data->enable_deletion==FALSE)
00149 return FALSE;
00150 if (data->filled_entries<data->max_fill_state)
00151 return FALSE;
00152 if ((ts->tv_sec+DELTA_READ)<data->last_read.tv_sec)
00153 return TRUE;
00154 return FALSE;
00155 }
00156
00157
00158 uint32 init_tme_block(TME_CORE *tme, uint32 block);
00159 uint32 validate_tme_block(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 block, uint32 mem_ex_offset);
00160 uint32 lookup_frontend(MEM_TYPE *mem_ex, TME_CORE *tme,uint32 mem_ex_offset, struct time_conv *time_ref);
00161 uint32 execute_frontend(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 pkt_size,uint32 offset);
00162 uint32 set_active_tme_block(TME_CORE *tme, uint32 block);
00163 uint32 init_extended_memory(uint32 size, MEM_TYPE *mem_ex);
00164 uint32 reset_tme(TME_CORE *tme);
00165 uint32 get_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 *rval);
00166 uint32 set_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 value, int32 init);
00167 uint32 set_active_read_tme_block(TME_CORE *tme, uint32 block);
00168 uint32 set_autodeletion(TME_DATA *data, uint32 value);
00169
00170
00171 lut_fcn lut_fcn_mapper(uint32 index);
00172 exec_fcn exec_fcn_mapper(uint32 index);
00173
00174 #endif