3 * Politecnico di Torino. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the Politecnico
13 * di Torino, and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 #ifndef __tme_include_
23 #define __tme_include_
29 #include "time_calls.h"
30 #endif /*WIN_NT_DRIVER*/
34 #include "time_calls.h"
42 #include <net/tme/time_calls.h>
44 #include <tme/time_calls.h>
56 #define DEFAULT_MEM_EX_SIZE 65536
57 #define MAX_TME_DATA_BLOCKS 4
58 #define TME_NONE_ACTIVE 0xffffffff
59 #define DELTA_READ 2 /* secs */
61 #define TME_LUT_ENTRIES 0x00000000
62 #define TME_MAX_FILL_STATE 0x00000001 /*potrebbe servire per un thread a passive level!?!?! */
63 #define TME_REHASHING_VALUE 0x00000002
64 #define TME_KEY_LEN 0x00000003
65 #define TME_SHARED_MEMORY_BLOCKS 0x00000004
66 #define TME_FILLED_ENTRIES 0x00000005
67 #define TME_BLOCK_SIZE 0x00000006
68 #define TME_EXTRA_SEGMENT_SIZE 0x00000007
69 #define TME_LOOKUP_CODE 0x00000008
70 #define TME_OUT_LUT_EXEC 0x00000009
71 #define TME_FILLED_BLOCKS 0x0000000a
72 #define TME_DEFAULT_EXEC 0x0000000b
73 #define TME_LUT_BASE_ADDRESS 0x0000000c
74 #define TME_SHARED_MEMORY_BASE_ADDRESS 0x0000000d
75 #define TME_EXTRA_SEGMENT_BASE_ADDRESS 0x0000000e
76 #define TME_LAST_FOUND 0x0000000f /* contains the offset of the last found entry */
77 #define TME_LAST_FOUND_BLOCK 0x00000010
78 /* TME default values */
79 #define TME_LUT_ENTRIES_DEFAULT 32007
80 #define TME_REHASHING_VALUE_DEFAULT 1
81 #define TME_SHARED_MEMORY_BLOCKS_DEFAULT 16000
82 #define TME_BLOCK_SIZE_DEFAULT 64
83 #define TME_EXTRA_SEGMENT_SIZE_DEFAULT 0
84 #define TME_LOOKUP_CODE_DEFAULT 0
85 #define TME_OUT_LUT_EXEC_DEFAULT 0
86 #define TME_DEFAULT_EXEC_DEFAULT 0
87 #define TME_MAX_FILL_STATE_DEFAULT 15000
89 #define IS_VALIDATED(src,index) (src&(1<<index))
91 #define VALIDATE(src,index) src|=(1<<index);
94 #define FORCE_NO_DELETION(timestamp) (struct timeval*)(timestamp)->tv_sec=0x7fffffff;
96 /* TME callback prototypes */
98 typedef uint32 (*lut_fcn)(uint8 *key, struct __TME_DATA *data,MEM_TYPE *mem_ex, struct time_conv *time_ref );
99 typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, struct __TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data);
101 typedef uint32 (*lut_fcn)(uint8 *key, void *data,MEM_TYPE *mem_ex, struct time_conv *time_ref );
102 typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, void *data, MEM_TYPE *mem_ex, uint8 *mem_data);
105 /* DO NOT MODIFY THIS STRUCTURE!!!! GV */
106 typedef struct __RECORD
114 /* TME data registers */
118 uint32 max_fill_state;
119 uint32 rehashing_value;
121 uint32 shared_memory_blocks;
122 uint32 filled_entries;
124 uint32 extra_segment_size;
125 uint32 filled_blocks;
129 uint8 *lut_base_address;
130 uint8 *shared_memory_base_address;
131 uint8 *extra_segment_base_address;
132 struct timeval last_read;
133 uint32 enable_deletion;
137 typedef struct __TME_DATA TME_DATA,*PTME_DATA;
142 typedef struct __TME_CORE
146 uint32 validated_blocks;
147 TME_DATA block_data[MAX_TME_DATA_BLOCKS];
150 } TME_CORE, *PTME_CORE;
152 static __inline int32 IS_DELETABLE(void *timestamp, TME_DATA *data)
154 struct timeval *ts=(struct timeval*)timestamp;
156 if (data->enable_deletion==FALSE)
158 if (data->filled_entries<data->max_fill_state)
160 if ((ts->tv_sec+DELTA_READ)<data->last_read.tv_sec)
165 /* functions to manage TME */
166 uint32 init_tme_block(TME_CORE *tme, uint32 block);
167 uint32 validate_tme_block(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 block, uint32 mem_ex_offset);
168 uint32 lookup_frontend(MEM_TYPE *mem_ex, TME_CORE *tme,uint32 mem_ex_offset, struct time_conv *time_ref);
169 uint32 execute_frontend(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 pkt_size,uint32 offset);
170 uint32 set_active_tme_block(TME_CORE *tme, uint32 block);
171 uint32 init_extended_memory(uint32 size, MEM_TYPE *mem_ex);
172 uint32 reset_tme(TME_CORE *tme);
173 uint32 get_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 *rval);
174 uint32 set_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 value, int32 init);
175 uint32 set_active_read_tme_block(TME_CORE *tme, uint32 block);
176 uint32 set_autodeletion(TME_DATA *data, uint32 value);
178 /* function mappers */
179 lut_fcn lut_fcn_mapper(uint32 index);
180 exec_fcn exec_fcn_mapper(uint32 index);