Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef VNET_LISP_GPE_GID_DICTIONARY_H_ |
| 17 | #define VNET_LISP_GPE_GID_DICTIONARY_H_ |
| 18 | |
| 19 | #include <vnet/vnet.h> |
| 20 | #include <vnet/lisp-cp/lisp_types.h> |
| 21 | #include <vppinfra/bihash_24_8.h> |
| 22 | #include <vppinfra/bihash_template.h> |
| 23 | |
| 24 | #define GID_LOOKUP_MISS ((u32)~0) |
| 25 | |
| 26 | /* Default size of the ip4 hash table */ |
| 27 | #define IP4_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 28 | #define IP4_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 29 | |
| 30 | /* Default size of the ip6 hash table */ |
| 31 | #define IP6_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 32 | #define IP6_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 33 | |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 34 | /* Default size of the MAC hash table */ |
| 35 | #define MAC_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 36 | #define MAC_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 37 | |
Filip Tehlar | d5fcc46 | 2016-10-17 16:20:18 +0200 | [diff] [blame] | 38 | typedef void (*foreach_subprefix_match_cb_t) (u32, void *); |
| 39 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 40 | typedef struct |
| 41 | { |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 42 | BVT (clib_bihash) ip4_lookup_table; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 43 | |
| 44 | /* bitmap/vector of mask widths to search */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 45 | uword *ip4_non_empty_dst_address_length_bitmap; |
| 46 | u8 *ip4_prefix_lengths_in_search_order; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 47 | ip4_address_t ip4_fib_masks[33]; |
| 48 | u32 ip4_prefix_len_refcount[33]; |
| 49 | |
| 50 | /* ip4 lookup table config parameters */ |
| 51 | u32 ip4_lookup_table_nbuckets; |
| 52 | uword ip4_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 53 | u32 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 54 | } gid_ip4_table_t; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 55 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 56 | typedef struct |
| 57 | { |
| 58 | BVT (clib_bihash) ip6_lookup_table; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 59 | |
| 60 | /* bitmap/vector of mask widths to search */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 61 | uword *ip6_non_empty_dst_address_length_bitmap; |
| 62 | u8 *ip6_prefix_lengths_in_search_order; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 63 | ip6_address_t ip6_fib_masks[129]; |
| 64 | u64 ip6_prefix_len_refcount[129]; |
| 65 | |
| 66 | /* ip6 lookup table config parameters */ |
| 67 | u32 ip6_lookup_table_nbuckets; |
| 68 | uword ip6_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 69 | u64 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 70 | } gid_ip6_table_t; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 71 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 72 | typedef struct gid_mac_table |
| 73 | { |
| 74 | BVT (clib_bihash) mac_lookup_table; |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 75 | |
| 76 | /* mac lookup table config parameters */ |
| 77 | u32 mac_lookup_table_nbuckets; |
| 78 | uword mac_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 79 | u64 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 80 | } gid_mac_table_t; |
| 81 | |
| 82 | typedef struct |
| 83 | { |
| 84 | /** destination IP LPM ip4 lookup table */ |
| 85 | gid_ip4_table_t dst_ip4_table; |
| 86 | |
| 87 | /** pool of source IP LPM ip4 lookup tables */ |
| 88 | gid_ip4_table_t *src_ip4_table_pool; |
| 89 | |
| 90 | /** destination IP LPM ip6 lookup table */ |
| 91 | gid_ip6_table_t dst_ip6_table; |
| 92 | |
| 93 | /** pool of source IP LPM ip6 lookup tables */ |
| 94 | gid_ip6_table_t *src_ip6_table_pool; |
| 95 | |
| 96 | /** flat source/dest mac lookup table */ |
| 97 | gid_mac_table_t sd_mac_table; |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 98 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 99 | } gid_dictionary_t; |
| 100 | |
| 101 | u32 |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 102 | gid_dictionary_add_del (gid_dictionary_t * db, gid_address_t * key, u32 value, |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 103 | u8 is_add); |
| 104 | |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 105 | u32 gid_dictionary_lookup (gid_dictionary_t * db, gid_address_t * key); |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 106 | u32 gid_dictionary_sd_lookup (gid_dictionary_t * db, gid_address_t * dst, |
| 107 | gid_address_t * src); |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 108 | |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 109 | void gid_dictionary_init (gid_dictionary_t * db); |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 110 | |
Filip Tehlar | d5fcc46 | 2016-10-17 16:20:18 +0200 | [diff] [blame] | 111 | void |
| 112 | gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid, |
| 113 | foreach_subprefix_match_cb_t cb, void *arg); |
| 114 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 115 | #endif /* VNET_LISP_GPE_GID_DICTIONARY_H_ */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * fd.io coding-style-patch-verification: ON |
| 119 | * |
| 120 | * Local Variables: |
| 121 | * eval: (c-set-style "gnu") |
| 122 | * End: |
| 123 | */ |