Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [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 __MFIB_ITF_H__ |
| 17 | #define __MFIB_ITF_H__ |
| 18 | |
| 19 | #include <vlib/vlib.h> |
| 20 | #include <vnet/mfib/mfib_types.h> |
| 21 | |
| 22 | /** |
| 23 | * @brief An interface associated with a particular MFIB entry |
| 24 | */ |
| 25 | typedef struct mfib_itf_t_ |
| 26 | { |
| 27 | /** |
Dave Barach | eb987d3 | 2018-05-03 08:26:39 -0400 | [diff] [blame] | 28 | * Required for pool_get_aligned |
| 29 | */ |
| 30 | CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); |
| 31 | |
| 32 | /** |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 33 | * @brief Forwarding Flags on the entry - checked in the data-path |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 34 | */ |
| 35 | mfib_itf_flags_t mfi_flags; |
| 36 | |
| 37 | /** |
| 38 | * The SW IF index that this MFIB interface represents |
| 39 | */ |
| 40 | u32 mfi_sw_if_index; |
| 41 | |
| 42 | /** |
| 43 | * The index of the signal in the pending list |
| 44 | */ |
| 45 | u32 mfi_si; |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * A hash table of path-inidices that are contributing flags to this interface. |
| 49 | * Since paths with next-hops can be on the same interface and each of those |
| 50 | * paths can contribute different flags, we need to maintain the flag |
| 51 | * contribution from each path, and use a combination for forwarding. |
| 52 | */ |
| 53 | uword *mfi_hash; |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 54 | } mfib_itf_t; |
| 55 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 56 | /** |
| 57 | * update an interface from a path. |
| 58 | * returns 1 if the entry is removed, i.e. has no flags left, as a result |
| 59 | * of the update. |
| 60 | */ |
| 61 | extern int mfib_itf_update(mfib_itf_t *itf, |
| 62 | fib_node_index_t path_index, |
| 63 | mfib_itf_flags_t mfi_flags); |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 64 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 65 | extern index_t mfib_itf_create(fib_node_index_t path_index, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 66 | mfib_itf_flags_t mfi_flags); |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 67 | |
| 68 | extern void mfib_itf_delete(mfib_itf_t *itf); |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 69 | |
| 70 | extern u8 *format_mfib_itf(u8 * s, va_list * args); |
| 71 | |
Neale Ranns | 21fb4f7 | 2020-10-05 12:26:47 +0000 | [diff] [blame] | 72 | extern void mfib_itf_mac_add(mfib_itf_t *itf, |
| 73 | const mfib_prefix_t *pfx); |
| 74 | extern void mfib_itf_mac_del(mfib_itf_t *itf, |
| 75 | const mfib_prefix_t *pfx); |
| 76 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 77 | extern mfib_itf_t *mfib_itf_pool; |
| 78 | |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 79 | /** |
| 80 | * Get the MFIB interface representation |
| 81 | */ |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 82 | static inline mfib_itf_t * |
| 83 | mfib_itf_get (index_t mi) |
| 84 | { |
| 85 | return (pool_elt_at_index(mfib_itf_pool, mi)); |
| 86 | } |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 87 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 88 | static inline index_t |
| 89 | mfib_itf_get_index (const mfib_itf_t *mfi) |
| 90 | { |
| 91 | return (mfi - mfib_itf_pool); |
| 92 | } |
| 93 | |
| 94 | #endif |