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) |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 25 | #define GID_LOOKUP_MISS_L2 ((u64)~0) |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 26 | |
| 27 | /* Default size of the ip4 hash table */ |
| 28 | #define IP4_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 29 | #define IP4_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 30 | |
| 31 | /* Default size of the ip6 hash table */ |
| 32 | #define IP6_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 33 | #define IP6_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 34 | |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 35 | /* Default size of the MAC hash table */ |
| 36 | #define MAC_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 37 | #define MAC_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 38 | |
Filip Tehlar | 0587999 | 2017-09-05 15:46:09 +0200 | [diff] [blame] | 39 | /* Default size of the ARP/NDP hash table */ |
| 40 | #define ARP_NDP_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 41 | #define ARP_NDP_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 42 | |
Filip Tehlar | ef2a5bf | 2017-05-30 07:14:46 +0200 | [diff] [blame] | 43 | /* Default size of the NSH hash table */ |
| 44 | #define NSH_LOOKUP_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) |
| 45 | #define NSH_LOOKUP_DEFAULT_HASH_MEMORY_SIZE (32<<20) |
| 46 | |
Filip Tehlar | d5fcc46 | 2016-10-17 16:20:18 +0200 | [diff] [blame] | 47 | typedef void (*foreach_subprefix_match_cb_t) (u32, void *); |
| 48 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 49 | typedef struct |
| 50 | { |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 51 | BVT (clib_bihash) ip4_lookup_table; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 52 | |
| 53 | /* bitmap/vector of mask widths to search */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 54 | uword *ip4_non_empty_dst_address_length_bitmap; |
| 55 | u8 *ip4_prefix_lengths_in_search_order; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 56 | ip4_address_t ip4_fib_masks[33]; |
| 57 | u32 ip4_prefix_len_refcount[33]; |
| 58 | |
| 59 | /* ip4 lookup table config parameters */ |
| 60 | u32 ip4_lookup_table_nbuckets; |
| 61 | uword ip4_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 62 | u32 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 63 | } gid_ip4_table_t; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 64 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 65 | typedef struct |
| 66 | { |
| 67 | BVT (clib_bihash) ip6_lookup_table; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 68 | |
| 69 | /* bitmap/vector of mask widths to search */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 70 | uword *ip6_non_empty_dst_address_length_bitmap; |
| 71 | u8 *ip6_prefix_lengths_in_search_order; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 72 | ip6_address_t ip6_fib_masks[129]; |
| 73 | u64 ip6_prefix_len_refcount[129]; |
| 74 | |
| 75 | /* ip6 lookup table config parameters */ |
| 76 | u32 ip6_lookup_table_nbuckets; |
| 77 | uword ip6_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 78 | u64 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 79 | } gid_ip6_table_t; |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 80 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 81 | typedef struct gid_mac_table |
| 82 | { |
| 83 | BVT (clib_bihash) mac_lookup_table; |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 84 | |
| 85 | /* mac lookup table config parameters */ |
| 86 | u32 mac_lookup_table_nbuckets; |
| 87 | uword mac_lookup_table_size; |
Filip Tehlar | f3fe820 | 2017-02-15 13:27:08 +0100 | [diff] [blame] | 88 | u64 count; |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 89 | } gid_mac_table_t; |
| 90 | |
Filip Tehlar | ef2a5bf | 2017-05-30 07:14:46 +0200 | [diff] [blame] | 91 | typedef struct gid_nsh_table |
| 92 | { |
| 93 | BVT (clib_bihash) nsh_lookup_table; |
| 94 | |
| 95 | /* nsh lookup table config parameters */ |
| 96 | u32 nsh_lookup_table_nbuckets; |
| 97 | uword nsh_lookup_table_size; |
| 98 | u64 count; |
| 99 | } gid_nsh_table_t; |
| 100 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 101 | typedef struct |
| 102 | { |
Filip Tehlar | 0587999 | 2017-09-05 15:46:09 +0200 | [diff] [blame] | 103 | BVT (clib_bihash) arp_ndp_lookup_table; |
| 104 | u32 arp_ndp_lookup_table_nbuckets; |
| 105 | uword arp_ndp_lookup_table_size; |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 106 | u64 count; |
Filip Tehlar | 0587999 | 2017-09-05 15:46:09 +0200 | [diff] [blame] | 107 | } gid_l2_arp_ndp_table_t; |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 108 | |
| 109 | typedef struct |
| 110 | { |
Filip Tehlar | 0587999 | 2017-09-05 15:46:09 +0200 | [diff] [blame] | 111 | /** L2 ARP/NDP table */ |
| 112 | gid_l2_arp_ndp_table_t arp_ndp_table; |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 113 | |
Filip Tehlar | ef2a5bf | 2017-05-30 07:14:46 +0200 | [diff] [blame] | 114 | /** NSH lookup table */ |
| 115 | gid_nsh_table_t nsh_table; |
| 116 | |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 117 | /** destination IP LPM ip4 lookup table */ |
| 118 | gid_ip4_table_t dst_ip4_table; |
| 119 | |
| 120 | /** pool of source IP LPM ip4 lookup tables */ |
| 121 | gid_ip4_table_t *src_ip4_table_pool; |
| 122 | |
| 123 | /** destination IP LPM ip6 lookup table */ |
| 124 | gid_ip6_table_t dst_ip6_table; |
| 125 | |
| 126 | /** pool of source IP LPM ip6 lookup tables */ |
| 127 | gid_ip6_table_t *src_ip6_table_pool; |
| 128 | |
| 129 | /** flat source/dest mac lookup table */ |
| 130 | gid_mac_table_t sd_mac_table; |
Filip Tehlar | 8e39bb4 | 2016-06-24 14:16:34 +0200 | [diff] [blame] | 131 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 132 | } gid_dictionary_t; |
| 133 | |
| 134 | u32 |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 135 | gid_dictionary_add_del (gid_dictionary_t * db, gid_address_t * key, u64 value, |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 136 | u8 is_add); |
| 137 | |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 138 | u64 gid_dictionary_lookup (gid_dictionary_t * db, gid_address_t * key); |
Florin Coras | dca8804 | 2016-09-14 16:01:38 +0200 | [diff] [blame] | 139 | u32 gid_dictionary_sd_lookup (gid_dictionary_t * db, gid_address_t * dst, |
| 140 | gid_address_t * src); |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 141 | |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 142 | void gid_dictionary_init (gid_dictionary_t * db); |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 143 | |
Filip Tehlar | d5fcc46 | 2016-10-17 16:20:18 +0200 | [diff] [blame] | 144 | void |
| 145 | gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid, |
| 146 | foreach_subprefix_match_cb_t cb, void *arg); |
| 147 | |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 148 | void |
Neale Ranns | f50bac1 | 2019-12-06 05:53:17 +0000 | [diff] [blame] | 149 | gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db, |
| 150 | BV (clib_bihash_foreach_key_value_pair_cb) |
| 151 | cb, void *ht); |
Filip Tehlar | d5a65db | 2017-05-17 17:21:10 +0200 | [diff] [blame] | 152 | |
Florin Coras | e127a7e | 2016-02-18 22:20:01 +0100 | [diff] [blame] | 153 | #endif /* VNET_LISP_GPE_GID_DICTIONARY_H_ */ |
Florin Coras | a2157cf | 2016-08-16 21:09:14 +0200 | [diff] [blame] | 154 | |
| 155 | /* |
| 156 | * fd.io coding-style-patch-verification: ON |
| 157 | * |
| 158 | * Local Variables: |
| 159 | * eval: (c-set-style "gnu") |
| 160 | * End: |
| 161 | */ |