Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [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 __BIER_DISP_TABLE_H__ |
| 17 | #define __BIER_DISP_TABLE_H__ |
| 18 | |
| 19 | #include <vnet/ip/ip.h> |
| 20 | #include <vnet/adj/adj.h> |
| 21 | #include <vnet/dpo/replicate_dpo.h> |
| 22 | |
| 23 | #include <vnet/bier/bier_types.h> |
| 24 | #include <vnet/bier/bier_disp_entry.h> |
| 25 | |
| 26 | /** |
| 27 | * @brief |
| 28 | * A protocol Independent IP multicast FIB table |
| 29 | */ |
| 30 | typedef struct bier_disp_table_t_ |
| 31 | { |
| 32 | /** |
| 33 | * number of locks on the table |
| 34 | */ |
| 35 | u16 bdt_locks; |
| 36 | |
| 37 | /** |
| 38 | * Table ID (hash key) for this FIB. |
| 39 | */ |
| 40 | u32 bdt_table_id; |
| 41 | |
| 42 | /** |
| 43 | * The lookup DB based on sender BP. Value is the index of the |
| 44 | * BIER disp object. |
| 45 | */ |
| 46 | index_t bdt_db[BIER_BP_MAX]; |
| 47 | } bier_disp_table_t; |
| 48 | |
| 49 | /** |
| 50 | * @brief |
| 51 | * Format the description/name of the table |
| 52 | */ |
| 53 | extern u8* format_bier_disp_table(u8* s, va_list *ap); |
| 54 | |
| 55 | extern void bier_disp_table_entry_path_add(u32 table_id, |
| 56 | bier_bp_t src, |
| 57 | bier_hdr_proto_id_t payload_proto, |
| 58 | const fib_route_path_t *rpath); |
| 59 | |
| 60 | extern void bier_disp_table_entry_path_remove(u32 table_id, |
| 61 | bier_bp_t src, |
| 62 | bier_hdr_proto_id_t payload_proto, |
| 63 | const fib_route_path_t *paths); |
| 64 | |
| 65 | extern index_t bier_disp_table_find(u32 table_id); |
| 66 | |
| 67 | |
| 68 | extern index_t bier_disp_table_add_or_lock(u32 table_id); |
| 69 | extern void bier_disp_table_unlock_w_table_id(u32 table_id); |
| 70 | |
| 71 | extern void bier_disp_table_unlock(index_t bdti); |
| 72 | extern void bier_disp_table_lock(index_t bdti); |
| 73 | extern void bier_disp_table_contribute_forwarding(index_t bdti, |
| 74 | dpo_id_t *dpo); |
| 75 | |
| 76 | /** |
| 77 | * Types and functions to walk all the entries in one BIER Table |
| 78 | */ |
| 79 | typedef void (*bier_disp_table_walk_fn_t)(const bier_disp_table_t *bdt, |
| 80 | const bier_disp_entry_t *bde, |
| 81 | u16 bp, |
| 82 | void *ctx); |
| 83 | extern void bier_disp_table_walk(u32 table_id, |
| 84 | bier_disp_table_walk_fn_t fn, |
| 85 | void *ctx); |
| 86 | |
| 87 | /** |
| 88 | * @brief |
| 89 | * Get a pointer to a FIB table |
| 90 | */ |
| 91 | extern bier_disp_table_t *bier_disp_table_pool; |
| 92 | |
| 93 | static inline bier_disp_table_t * |
| 94 | bier_disp_table_get (index_t bdti) |
| 95 | { |
| 96 | return (pool_elt_at_index(bier_disp_table_pool, bdti)); |
| 97 | } |
| 98 | |
| 99 | static inline index_t |
| 100 | bier_disp_table_lookup (index_t bdti, |
Neale Ranns | 93149bb | 2017-11-15 10:44:07 -0800 | [diff] [blame] | 101 | bier_hdr_src_id_t src) |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 102 | { |
| 103 | bier_disp_table_t *bdt; |
| 104 | |
| 105 | bdt = bier_disp_table_get(bdti); |
| 106 | |
| 107 | return (bdt->bdt_db[src]); |
| 108 | } |
| 109 | |
| 110 | #endif |