Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * l2_fib.h : layer 2 forwarding table (aka mac table) |
| 3 | * |
| 4 | * Copyright (c) 2013 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef included_l2fib_h |
| 19 | #define included_l2fib_h |
| 20 | |
| 21 | #include <vlib/vlib.h> |
| 22 | #include <vppinfra/bihash_8_8.h> |
| 23 | |
| 24 | /* |
| 25 | * The size of the hash table |
| 26 | */ |
| 27 | #define L2FIB_NUM_BUCKETS (64 * 1024) |
John Lo | dbfa574 | 2017-09-02 08:27:36 -0400 | [diff] [blame] | 28 | #define L2FIB_MEMORY_SIZE (512<<20) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 30 | /* Ager scan interval is 1 minute for aging */ |
| 31 | #define L2FIB_AGE_SCAN_INTERVAL (60.0) |
| 32 | |
| 33 | /* MAC event scan delay is 100 msec unless specified by MAC event client */ |
| 34 | #define L2FIB_EVENT_SCAN_DELAY_DEFAULT (0.1) |
| 35 | |
| 36 | /* Max MACs in a event message is 100 unless specified by MAC event client */ |
| 37 | #define L2FIB_EVENT_MAX_MACS_DEFAULT (100) |
| 38 | |
| 39 | /* MAC event learn limit is 1000 unless specified by MAC event client */ |
| 40 | #define L2FIB_EVENT_LEARN_LIMIT_DEFAULT (1000) |
| 41 | |
Eyal Bari | 0f360dc | 2017-06-14 13:11:20 +0300 | [diff] [blame] | 42 | typedef struct |
| 43 | { |
| 44 | |
| 45 | /* hash table */ |
| 46 | BVT (clib_bihash) mac_table; |
| 47 | |
| 48 | /* per swif vector of sequence number for interface based flush of MACs */ |
| 49 | u8 *swif_seq_num; |
| 50 | |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 51 | /* last event or ager scan duration */ |
| 52 | f64 evt_scan_duration; |
| 53 | f64 age_scan_duration; |
| 54 | |
| 55 | /* delay between event scans, default to 100 msec */ |
| 56 | f64 event_scan_delay; |
| 57 | |
| 58 | /* max macs in evet message, default to 100 entries */ |
| 59 | u32 max_macs_in_event; |
| 60 | |
Eyal Bari | 0f360dc | 2017-06-14 13:11:20 +0300 | [diff] [blame] | 61 | /* convenience variables */ |
| 62 | vlib_main_t *vlib_main; |
| 63 | vnet_main_t *vnet_main; |
| 64 | } l2fib_main_t; |
| 65 | |
| 66 | extern l2fib_main_t l2fib_main; |
| 67 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | /* |
| 69 | * The L2fib key is the mac address and bridge domain ID |
| 70 | */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 71 | typedef struct |
| 72 | { |
| 73 | union |
| 74 | { |
| 75 | struct |
| 76 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | u16 bd_index; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 78 | u8 mac[6]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 79 | } fields; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 80 | struct |
| 81 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 82 | u32 w0; |
| 83 | u32 w1; |
| 84 | } words; |
| 85 | u64 raw; |
| 86 | }; |
| 87 | } l2fib_entry_key_t; |
| 88 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 89 | STATIC_ASSERT_SIZEOF (l2fib_entry_key_t, 8); |
| 90 | |
Eyal Bari | 7537e71 | 2017-04-27 14:07:55 +0300 | [diff] [blame] | 91 | |
| 92 | typedef struct |
| 93 | { |
| 94 | union |
| 95 | { |
| 96 | struct |
| 97 | { |
| 98 | u8 swif; |
| 99 | u8 bd; |
| 100 | }; |
| 101 | u16 as_u16; |
| 102 | }; |
| 103 | } l2fib_seq_num_t; |
| 104 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 105 | /* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 106 | * The l2fib entry results |
| 107 | */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 108 | typedef struct |
| 109 | { |
| 110 | union |
| 111 | { |
| 112 | struct |
| 113 | { |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 114 | u32 sw_if_index; /* output sw_if_index (L3 intf if bvi==1) */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 115 | |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 116 | u8 static_mac:1; /* static mac, no MAC move */ |
| 117 | u8 age_not:1; /* not subject to age */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 118 | u8 bvi:1; /* mac is for a bridged virtual interface */ |
| 119 | u8 filter:1; /* drop packets to/from this mac */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 120 | u8 lrn_evt:1; /* MAC learned to be sent in L2 MAC event */ |
| 121 | u8 unused:3; |
| 122 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 123 | u8 timestamp; /* timestamp for aging */ |
Eyal Bari | 7537e71 | 2017-04-27 14:07:55 +0300 | [diff] [blame] | 124 | l2fib_seq_num_t sn; /* bd/int seq num */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | } fields; |
| 126 | u64 raw; |
| 127 | }; |
| 128 | } l2fib_entry_result_t; |
| 129 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 130 | STATIC_ASSERT_SIZEOF (l2fib_entry_result_t, 8); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 131 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 132 | /** |
| 133 | * Compute the hash for the given key and return |
| 134 | * the corresponding bucket index |
| 135 | */ |
| 136 | always_inline u32 |
| 137 | l2fib_compute_hash_bucket (l2fib_entry_key_t * key) |
| 138 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 139 | u32 result; |
| 140 | u32 temp_a; |
| 141 | u32 temp_b; |
| 142 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 143 | result = 0xa5a5a5a5; /* some seed */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 144 | temp_a = key->words.w0; |
| 145 | temp_b = key->words.w1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 146 | hash_mix32 (temp_a, temp_b, result); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 147 | |
| 148 | return result % L2FIB_NUM_BUCKETS; |
| 149 | } |
| 150 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 151 | always_inline u64 |
| 152 | l2fib_make_key (u8 * mac_address, u16 bd_index) |
| 153 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 154 | u64 temp; |
| 155 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 156 | /* |
| 157 | * The mac address in memory is A:B:C:D:E:F |
| 158 | * The bd id in register is H:L |
| 159 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 160 | #if CLIB_ARCH_IS_LITTLE_ENDIAN |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 161 | /* |
| 162 | * Create the in-register key as F:E:D:C:B:A:H:L |
| 163 | * In memory the key is L:H:A:B:C:D:E:F |
| 164 | */ |
Damjan Marion | 30230dd | 2016-11-24 22:20:05 +0100 | [diff] [blame] | 165 | temp = *((u64 *) (mac_address)) << 16; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 166 | temp = (temp & ~0xffff) | (u64) (bd_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 167 | #else |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 168 | /* |
| 169 | * Create the in-register key as H:L:A:B:C:D:E:F |
| 170 | * In memory the key is H:L:A:B:C:D:E:F |
| 171 | */ |
| 172 | temp = *((u64 *) (mac_address)) >> 16; |
| 173 | temp = temp | (((u64) bd_index) << 48); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 174 | #endif |
| 175 | |
| 176 | return temp; |
| 177 | } |
| 178 | |
| 179 | |
| 180 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 181 | /** |
| 182 | * Lookup the entry for mac and bd_index in the mac table for 1 packet. |
| 183 | * Cached_key and cached_result are used as a one-entry cache. |
| 184 | * The function reads and updates them as needed. |
| 185 | * |
| 186 | * mac0 and bd_index0 are the keys. The entry is written to result0. |
| 187 | * If the entry was not found, result0 is set to ~0. |
| 188 | * |
| 189 | * key0 and bucket0 return with the computed key and hash bucket, |
| 190 | * convenient if the entry needs to be updated afterward. |
| 191 | * If the cached_result was used, bucket0 is set to ~0. |
| 192 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 193 | |
| 194 | static_always_inline void |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 195 | l2fib_lookup_1 (BVT (clib_bihash) * mac_table, |
| 196 | l2fib_entry_key_t * cached_key, |
| 197 | l2fib_entry_result_t * cached_result, |
| 198 | u8 * mac0, |
| 199 | u16 bd_index0, |
| 200 | l2fib_entry_key_t * key0, |
| 201 | u32 * bucket0, l2fib_entry_result_t * result0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 202 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 203 | /* set up key */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 204 | key0->raw = l2fib_make_key (mac0, bd_index0); |
| 205 | *bucket0 = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 206 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 207 | if (key0->raw == cached_key->raw) |
| 208 | { |
| 209 | /* Hit in the one-entry cache */ |
| 210 | result0->raw = cached_result->raw; |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | /* Do a regular mac table lookup */ |
| 215 | BVT (clib_bihash_kv) kv; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 216 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 217 | kv.key = key0->raw; |
| 218 | kv.value = ~0ULL; |
| 219 | BV (clib_bihash_search_inline) (mac_table, &kv); |
| 220 | result0->raw = kv.value; |
| 221 | |
| 222 | /* Update one-entry cache */ |
| 223 | cached_key->raw = key0->raw; |
| 224 | cached_result->raw = result0->raw; |
| 225 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 229 | /** |
| 230 | * Lookup the entry for mac and bd_index in the mac table for 2 packets. |
| 231 | * The lookups for the two packets are interleaved. |
| 232 | * |
| 233 | * Cached_key and cached_result are used as a one-entry cache. |
| 234 | * The function reads and updates them as needed. |
| 235 | * |
| 236 | * mac0 and bd_index0 are the keys. The entry is written to result0. |
| 237 | * If the entry was not found, result0 is set to ~0. The same |
| 238 | * holds for mac1/bd_index1/result1. |
| 239 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 240 | static_always_inline void |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 241 | l2fib_lookup_2 (BVT (clib_bihash) * mac_table, |
| 242 | l2fib_entry_key_t * cached_key, |
| 243 | l2fib_entry_result_t * cached_result, |
| 244 | u8 * mac0, |
| 245 | u8 * mac1, |
| 246 | u16 bd_index0, |
| 247 | u16 bd_index1, |
| 248 | l2fib_entry_key_t * key0, |
| 249 | l2fib_entry_key_t * key1, |
| 250 | u32 * bucket0, |
| 251 | u32 * bucket1, |
| 252 | l2fib_entry_result_t * result0, |
| 253 | l2fib_entry_result_t * result1) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 254 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 255 | /* set up key */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 256 | key0->raw = l2fib_make_key (mac0, bd_index0); |
| 257 | key1->raw = l2fib_make_key (mac1, bd_index1); |
| 258 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 259 | if ((key0->raw == cached_key->raw) && (key1->raw == cached_key->raw)) |
| 260 | { |
| 261 | /* Both hit in the one-entry cache */ |
| 262 | result0->raw = cached_result->raw; |
| 263 | result1->raw = cached_result->raw; |
| 264 | *bucket0 = ~0; |
| 265 | *bucket1 = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 266 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 267 | } |
| 268 | else |
| 269 | { |
| 270 | BVT (clib_bihash_kv) kv0, kv1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 271 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 272 | /* |
| 273 | * Do a regular mac table lookup |
| 274 | * Interleave lookups for packet 0 and packet 1 |
| 275 | */ |
| 276 | kv0.key = key0->raw; |
| 277 | kv1.key = key1->raw; |
| 278 | kv0.value = ~0ULL; |
| 279 | kv1.value = ~0ULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 280 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 281 | BV (clib_bihash_search_inline) (mac_table, &kv0); |
| 282 | BV (clib_bihash_search_inline) (mac_table, &kv1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 283 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 284 | result0->raw = kv0.value; |
| 285 | result1->raw = kv1.value; |
| 286 | |
| 287 | /* Update one-entry cache */ |
| 288 | cached_key->raw = key1->raw; |
| 289 | cached_result->raw = result1->raw; |
| 290 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Damjan Marion | daa2cd1 | 2016-11-22 21:10:25 -0800 | [diff] [blame] | 293 | static_always_inline void |
| 294 | l2fib_lookup_4 (BVT (clib_bihash) * mac_table, |
| 295 | l2fib_entry_key_t * cached_key, |
| 296 | l2fib_entry_result_t * cached_result, |
| 297 | u8 * mac0, |
| 298 | u8 * mac1, |
| 299 | u8 * mac2, |
| 300 | u8 * mac3, |
| 301 | u16 bd_index0, |
| 302 | u16 bd_index1, |
| 303 | u16 bd_index2, |
| 304 | u16 bd_index3, |
| 305 | l2fib_entry_key_t * key0, |
| 306 | l2fib_entry_key_t * key1, |
| 307 | l2fib_entry_key_t * key2, |
| 308 | l2fib_entry_key_t * key3, |
| 309 | u32 * bucket0, |
| 310 | u32 * bucket1, |
| 311 | u32 * bucket2, |
| 312 | u32 * bucket3, |
| 313 | l2fib_entry_result_t * result0, |
| 314 | l2fib_entry_result_t * result1, |
| 315 | l2fib_entry_result_t * result2, |
| 316 | l2fib_entry_result_t * result3) |
| 317 | { |
| 318 | /* set up key */ |
| 319 | key0->raw = l2fib_make_key (mac0, bd_index0); |
| 320 | key1->raw = l2fib_make_key (mac1, bd_index1); |
| 321 | key2->raw = l2fib_make_key (mac2, bd_index2); |
| 322 | key3->raw = l2fib_make_key (mac3, bd_index3); |
| 323 | |
| 324 | if ((key0->raw == cached_key->raw) && (key1->raw == cached_key->raw) && |
| 325 | (key2->raw == cached_key->raw) && (key3->raw == cached_key->raw)) |
| 326 | { |
| 327 | /* Both hit in the one-entry cache */ |
| 328 | result0->raw = cached_result->raw; |
| 329 | result1->raw = cached_result->raw; |
| 330 | result2->raw = cached_result->raw; |
| 331 | result3->raw = cached_result->raw; |
| 332 | *bucket0 = ~0; |
| 333 | *bucket1 = ~0; |
| 334 | *bucket2 = ~0; |
| 335 | *bucket3 = ~0; |
| 336 | |
| 337 | } |
| 338 | else |
| 339 | { |
| 340 | BVT (clib_bihash_kv) kv0, kv1, kv2, kv3; |
| 341 | |
| 342 | /* |
| 343 | * Do a regular mac table lookup |
| 344 | * Interleave lookups for packet 0 and packet 1 |
| 345 | */ |
| 346 | kv0.key = key0->raw; |
| 347 | kv1.key = key1->raw; |
| 348 | kv2.key = key2->raw; |
| 349 | kv3.key = key3->raw; |
| 350 | kv0.value = ~0ULL; |
| 351 | kv1.value = ~0ULL; |
| 352 | kv2.value = ~0ULL; |
| 353 | kv3.value = ~0ULL; |
| 354 | |
| 355 | BV (clib_bihash_search_inline) (mac_table, &kv0); |
| 356 | BV (clib_bihash_search_inline) (mac_table, &kv1); |
| 357 | BV (clib_bihash_search_inline) (mac_table, &kv2); |
| 358 | BV (clib_bihash_search_inline) (mac_table, &kv3); |
| 359 | |
| 360 | result0->raw = kv0.value; |
| 361 | result1->raw = kv1.value; |
| 362 | result2->raw = kv2.value; |
| 363 | result3->raw = kv3.value; |
| 364 | |
| 365 | /* Update one-entry cache */ |
| 366 | cached_key->raw = key1->raw; |
| 367 | cached_result->raw = result1->raw; |
| 368 | } |
| 369 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | |
Eyal Bari | 7537e71 | 2017-04-27 14:07:55 +0300 | [diff] [blame] | 371 | void l2fib_clear_table (void); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 372 | |
| 373 | void |
| 374 | l2fib_add_entry (u64 mac, |
| 375 | u32 bd_index, |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 376 | u32 sw_if_index, u8 static_mac, u8 drop_mac, u8 bvi_mac); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 377 | |
Eyal Bari | 31a71ab | 2017-06-25 14:42:33 +0300 | [diff] [blame] | 378 | static inline void |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 379 | l2fib_add_fwd_entry (u64 mac, u32 bd_index, u32 sw_if_index, u8 static_mac, |
| 380 | u8 bvi_mac) |
Eyal Bari | 31a71ab | 2017-06-25 14:42:33 +0300 | [diff] [blame] | 381 | { |
| 382 | l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, 0, bvi_mac); |
| 383 | } |
| 384 | |
| 385 | static inline void |
| 386 | l2fib_add_filter_entry (u64 mac, u32 bd_index) |
| 387 | { |
| 388 | l2fib_add_entry (mac, bd_index, ~0, 1, 1, 0); |
| 389 | } |
| 390 | |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 391 | u32 l2fib_del_entry (u64 mac, u32 bd_index); |
| 392 | |
| 393 | void l2fib_start_ager_scan (vlib_main_t * vm); |
| 394 | |
| 395 | void l2fib_flush_int_mac (vlib_main_t * vm, u32 sw_if_index); |
| 396 | |
| 397 | void l2fib_flush_bd_mac (vlib_main_t * vm, u32 bd_index); |
| 398 | |
Eyal Bari | 7537e71 | 2017-04-27 14:07:55 +0300 | [diff] [blame] | 399 | void l2fib_flush_all_mac (vlib_main_t * vm); |
| 400 | |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 401 | void |
| 402 | l2fib_table_dump (u32 bd_index, l2fib_entry_key_t ** l2fe_key, |
| 403 | l2fib_entry_result_t ** l2fe_res); |
| 404 | |
| 405 | u8 *format_vnet_sw_if_index_name_with_NA (u8 * s, va_list * args); |
| 406 | |
Eyal Bari | 0f360dc | 2017-06-14 13:11:20 +0300 | [diff] [blame] | 407 | static_always_inline u8 * |
| 408 | l2fib_swif_seq_num (u32 sw_if_index) |
| 409 | { |
| 410 | l2fib_main_t *mp = &l2fib_main; |
Eyal Bari | 0f360dc | 2017-06-14 13:11:20 +0300 | [diff] [blame] | 411 | return vec_elt_at_index (mp->swif_seq_num, sw_if_index); |
| 412 | } |
| 413 | |
Eyal Bari | b12ac56 | 2017-07-18 13:25:19 +0300 | [diff] [blame] | 414 | static_always_inline u8 * |
| 415 | l2fib_valid_swif_seq_num (u32 sw_if_index) |
| 416 | { |
| 417 | l2fib_main_t *mp = &l2fib_main; |
| 418 | vec_validate (mp->swif_seq_num, sw_if_index); |
| 419 | return l2fib_swif_seq_num (sw_if_index); |
| 420 | } |
| 421 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 422 | BVT (clib_bihash) * get_mac_table (void); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 423 | |
| 424 | #endif |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 425 | |
| 426 | /* |
| 427 | * fd.io coding-style-patch-verification: ON |
| 428 | * |
| 429 | * Local Variables: |
| 430 | * eval: (c-set-style "gnu") |
| 431 | * End: |
| 432 | */ |