Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

tme.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001 - 2003
00003  * NetGroup, Politecnico di Torino (Italy)
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  * notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  * notice, this list of conditions and the following disclaimer in the
00014  * documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the Politecnico di Torino nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00023  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /*WIN_NT_DRIVER*/
00041 
00042 #include "memory_t.h"
00043 #include "time_calls.h"
00044 
00045 
00046 /* error codes */
00047 #define         TME_ERROR                       0       
00048 #define         TME_SUCCESS                     1
00049 #define         TME_TRUE                        2
00050 #define         TME_FALSE                       3
00051 
00052 /* some constants */
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  /* secs */
00057 
00058 #define         TME_LUT_ENTRIES                                 0x00000000  
00059 #define         TME_MAX_FILL_STATE                              0x00000001  /*potrebbe servire per un thread a passive level!?!?! */
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   /* contains the offset of the last found entry */
00074 #define         TME_LAST_FOUND_BLOCK                    0x00000010
00075 /* TME default values */
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 /* TME callback prototypes */
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 /* DO NOT MODIFY THIS STRUCTURE!!!! GV */
00098 typedef struct __RECORD
00099 
00100 {
00101         uint32 block;
00102         uint32 exec_fcn;
00103 }
00104         RECORD, *PRECORD;
00105 
00106 /* TME data registers */
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 /* TME core */
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 /* functions to manage TME */
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 /* function mappers */
00171 lut_fcn lut_fcn_mapper(uint32 index);
00172 exec_fcn exec_fcn_mapper(uint32 index);
00173 
00174 #endif

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2