1 #ifndef __OF1X_L2HASH_MATCH_H__
2 #define __OF1X_L2HASH_MATCH_H__
5 #include "../matching_algorithms.h"
6 #include "../../of1x_flow_table.h"
34 unsigned int num_of_buckets;
40 #define L2HASH_MAX_ENTRIES 0xFFFF
43 unsigned int num_of_entries;
69 extern uint16_t l2hash_ht_T[L2HASH_MAX_ENTRIES];
72 static inline uint16_t l2hash_ht_hash64(
const char* key,
unsigned int size){
75 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[0])];
76 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[1])];
77 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[2])];
78 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[3])];
79 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[4])];
80 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[5])];
81 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[6])];
82 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[7])];
87 static inline uint16_t l2hash_ht_hash96(
const char* key,
unsigned int size){
90 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[0])];
91 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[1])];
92 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[2])];
93 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[3])];
94 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[4])];
95 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[5])];
96 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[6])];
97 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[7])];
98 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[8])];
99 hash = l2hash_ht_T[hash ^ (L2HASH_MAX_ENTRIES & key[9])];
108 #define L2_HASH_FNV_MASK_16 0xFFFF
109 #define L2_HASH_FNV_PRIME 0x01000193 //16777619
110 #define L2_HASH_FNV_SEED 0x811C9DC5 //2166136261
113 static inline uint32_t l2hash_fnv1a(
unsigned char c, uint32_t hash){
114 return (c ^ hash) * L2_HASH_FNV_PRIME;
117 static inline uint16_t l2hash_ht_hash64(
const char* key,
unsigned int size){
119 uint32_t hash = L2_HASH_FNV_SEED;
121 hash = l2hash_fnv1a( key[0], hash);
122 hash = l2hash_fnv1a( key[1], hash);
123 hash = l2hash_fnv1a( key[2], hash);
124 hash = l2hash_fnv1a( key[3], hash);
125 hash = l2hash_fnv1a( key[4], hash);
126 hash = l2hash_fnv1a( key[5], hash);
127 hash = l2hash_fnv1a( key[6], hash);
128 hash = l2hash_fnv1a( key[7], hash);
131 return (hash>>16) ^ (hash & L2_HASH_FNV_MASK_16);
135 static inline uint16_t l2hash_ht_hash96(
const char* key,
unsigned int size){
136 uint32_t hash = L2_HASH_FNV_SEED;
138 hash = l2hash_fnv1a( key[0], hash);
139 hash = l2hash_fnv1a( key[1], hash);
140 hash = l2hash_fnv1a( key[2], hash);
141 hash = l2hash_fnv1a( key[3], hash);
142 hash = l2hash_fnv1a( key[4], hash);
143 hash = l2hash_fnv1a( key[5], hash);
144 hash = l2hash_fnv1a( key[6], hash);
145 hash = l2hash_fnv1a( key[7], hash);
146 hash = l2hash_fnv1a( key[8], hash);
147 hash = l2hash_fnv1a( key[9], hash);
150 return (hash>>16) ^ (hash & L2_HASH_FNV_MASK_16);
163 #endif //L2HASH_MATCH
OpenFlow v1.0, 1.2 and 1.3.2 flow entry structure.