Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [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 __MPLS_DISP_DPO_H__ |
| 17 | #define __MPLS_DISP_DPO_H__ |
| 18 | |
| 19 | #include <vnet/vnet.h> |
| 20 | #include <vnet/mpls/packet.h> |
| 21 | #include <vnet/dpo/dpo.h> |
| 22 | #include <vnet/mfib/mfib_types.h> |
| 23 | |
| 24 | /** |
| 25 | * A representation of an MPLS label for imposition in the data-path |
| 26 | */ |
| 27 | typedef struct mpls_disp_dpo_t |
| 28 | { |
| 29 | /** |
| 30 | * Next DPO in the graph |
| 31 | */ |
| 32 | dpo_id_t mdd_dpo; |
| 33 | |
| 34 | /** |
| 35 | * The protocol of the payload/packets that are being encapped |
| 36 | */ |
| 37 | dpo_proto_t mdd_payload_proto; |
| 38 | |
| 39 | /** |
| 40 | * RPF-ID (if this is an mcast disposition) |
| 41 | */ |
| 42 | fib_rpf_id_t mdd_rpf_id; |
| 43 | |
| 44 | /** |
| 45 | * Number of locks/users of the label |
| 46 | */ |
| 47 | u16 mdd_locks; |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * LSP mode |
| 51 | */ |
| 52 | fib_mpls_lsp_mode_t mdd_mode; |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 53 | } mpls_disp_dpo_t; |
| 54 | |
| 55 | /** |
| 56 | * @brief Assert that the MPLS label object is less than a cache line in size. |
| 57 | * Should this get any bigger then we will need to reconsider how many labels |
| 58 | * can be pushed in one object. |
| 59 | */ |
| 60 | _Static_assert((sizeof(mpls_disp_dpo_t) <= CLIB_CACHE_LINE_BYTES), |
| 61 | "MPLS Disposition DPO is larger than one cache line."); |
| 62 | |
| 63 | /** |
| 64 | * @brief Create an MPLS label object |
| 65 | * |
| 66 | * @param payload_proto The ptocool of the payload packets that will |
| 67 | * be imposed with this label header. |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 68 | * @param rpf_id The RPF ID the packet will aquire - only for mcast |
| 69 | * @param mode The LSP mode; pipe or uniform |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 70 | * @param dpo The parent of the created MPLS label object |
| 71 | */ |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 72 | extern void mpls_disp_dpo_create(dpo_proto_t payload_proto, |
| 73 | fib_rpf_id_t rpf_id, |
| 74 | fib_mpls_lsp_mode_t mode, |
| 75 | const dpo_id_t *parent, |
| 76 | dpo_id_t *dpo); |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 77 | |
| 78 | extern u8* format_mpls_disp_dpo(u8 *s, va_list *args); |
| 79 | |
| 80 | |
| 81 | /* |
| 82 | * Encapsulation violation for fast data-path access |
| 83 | */ |
| 84 | extern mpls_disp_dpo_t *mpls_disp_dpo_pool; |
| 85 | |
| 86 | static inline mpls_disp_dpo_t * |
| 87 | mpls_disp_dpo_get (index_t index) |
| 88 | { |
| 89 | return (pool_elt_at_index(mpls_disp_dpo_pool, index)); |
| 90 | } |
| 91 | |
| 92 | extern void mpls_disp_dpo_module_init(void); |
| 93 | |
| 94 | #endif |