aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/map/map.h
AgeCommit message (Expand)AuthorFilesLines
2019-10-09map: use ip6-full-reassembly instead of own codeKlement Sekera1-99/+0
2019-10-03map: fix indent-offKlement Sekera1-121/+133
2019-10-01map: use SVR for MAP-TKlement Sekera1-108/+13
2019-09-26map: use SVR for MAP-EKlement Sekera1-0/+2
2019-07-31vppinfra: refactor test_and_set spinlocks to use clib_spinlock_tjaszha031-6/+7
2019-07-30vppinfra: refactor use of CLIB_MEMORY_BARRIER ()jaszha031-2/+2
2019-07-30vppinfra: conformed spinlocks to use CLIB_PAUSEjaszha031-2/+3
2019-06-18api: string type to convert to vectorOle Troan1-2/+2
2019-03-19MAP: Add optional user-supplied 'tag' field in MAPs.Jon Loeliger1-2/+14
2019-01-07MAP: Prevent duplicate MAP-E/T graph nodes.Jon Loeliger1-0/+4
2018-12-21MAP: Convert from DPO to input feature.Jon Loeliger1-37/+79
2018-12-19MAP: Add API support for MAP input feature.Jon Loeliger1-0/+5
2018-12-11MAP: Add API support for setting parameters.Jon Loeliger1-0/+18
2018-11-22Revert "Add support for MAP-T CE (VPP-1058)"Ole Troan1-2/+0
2018-11-14Remove c-11 memcpy checks from perf-critical codeDave Barach1-1/+1
2018-10-19vppinfra: add atomic macros for __sync builtinsSirshak Das1-4/+4
2018-09-27MAP: 64-bit DMROle Troan1-6/+10
2018-06-25MAP: Move MAP-E/T to a plugin.Ole Troan1-0/+597
to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <vppinfra/format.h> #include <vppinfra/hash.h> #include <vppinfra/heap.h> /* Hash table plus vector of keys. */ typedef struct { /* Vector or heap used to store keys. Hash table stores keys as byte offsets into this vector. */ u8 *key_vector_or_heap; /* Byte offsets of free keys in vector (used to store free keys when n_key_bytes > 1). */ u32 *key_vector_free_indices; u8 **key_tmps; /* Possibly fixed size of key. 0 means keys are vectors of u8's. 1 means keys are null terminated c strings. */ #define MHASH_VEC_STRING_KEY 0 #define MHASH_C_STRING_KEY 1 u32 n_key_bytes; /* Seed value for Jenkins hash. */ u32 hash_seed; /* Hash table mapping key -> value. */ uword *hash; /* Format function for keys. */ format_function_t *format_key; } mhash_t; void mhash_init (mhash_t * h, uword n_value_bytes, uword n_key_bytes); always_inline void mhash_init_c_string (mhash_t * h, uword n_value_bytes) { mhash_init (h, n_value_bytes, MHASH_C_STRING_KEY); } always_inline void mhash_init_vec_string (mhash_t * h, uword n_value_bytes) { mhash_init (h, n_value_bytes, MHASH_VEC_STRING_KEY); } always_inline void * mhash_key_to_mem (mhash_t * h, uword key) { if (key == ~0) { u8 *key_tmp; int my_cpu = os_get_thread_index (); vec_validate (h->key_tmps, my_cpu); key_tmp = h->key_tmps[my_cpu]; return key_tmp; } return vec_elt_at_index (h->key_vector_or_heap, key); } hash_pair_t *mhash_get_pair (mhash_t * h, const void *key); uword mhash_set_mem (mhash_t * h, void *key, uword * new_value, uword * old_value); uword mhash_unset (mhash_t * h, void *key, uword * old_value); always_inline uword * mhash_get (mhash_t * h, const void *key) { hash_pair_t *p = mhash_get_pair (h, key); return p ? &p->value[0] : 0; } always_inline uword mhash_set (mhash_t * h, void *key, uword new_value, uword * old_value) { return mhash_set_mem (h, key, &new_value, old_value); } always_inline uword mhash_unset_key (mhash_t * h, uword key, uword * old_value) { void *k = mhash_key_to_mem (h, key); return mhash_unset (h, k, old_value); } always_inline uword mhash_value_bytes (mhash_t * m) { hash_t *h = hash_header (m->hash); return hash_value_bytes (h); } always_inline uword mhash_elts (mhash_t * m) { return hash_elts (m->hash); } always_inline uword mhash_key_vector_is_heap (mhash_t * h) { return h->n_key_bytes <= 1; } always_inline void mhash_free (mhash_t * h) { if (mhash_key_vector_is_heap (h)) heap_free (h->key_vector_or_heap); else vec_free (h->key_vector_or_heap); vec_free (h->key_vector_free_indices); hash_free (h->hash); } #define mhash_foreach(k,v,mh,body) \ do { \ hash_pair_t * _mhash_foreach_p; \ hash_foreach_pair (_mhash_foreach_p, (mh)->hash, ({ \ (k) = mhash_key_to_mem ((mh), _mhash_foreach_p->key); \ (v) = &_mhash_foreach_p->value[0]; \ body; \ })); \ } while (0) format_function_t format_mhash_key; #endif /* included_clib_mhash_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */