2 * Copyright (c) 2015 Cisco and/or its affiliates. Licensed under the Apache
3 * License, Version 2.0 (the "License"); you may not use this file except in
4 * compliance with the License. You may obtain a copy of the License at:
6 * http://www.apache.org/licenses/LICENSE-2.0
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 * License for the specific language governing permissions and limitations
17 * @brief Segment Routing MPLS data structures definitions
21 #ifndef included_vnet_srmpls_h
22 #define included_vnet_srmpls_h
24 #include <vnet/vnet.h>
25 #include <vnet/mpls/packet.h>
26 #include <vnet/fib/mpls_fib.h>
27 #include <vnet/ip/ip.h>
28 #include <vnet/ip/lookup.h>
29 #include <vnet/dpo/dpo.h>
30 #include <vnet/dpo/replicate_dpo.h>
36 #define SR_POLICY_TYPE_DEFAULT 0
37 #define SR_POLICY_TYPE_SPRAY 1
39 #define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
41 #define SR_STEER_IPV4 4
42 #define SR_STEER_IPV6 6
44 #define SR_TE_CO_BITS_00 0
45 #define SR_TE_CO_BITS_01 1
46 #define SR_TE_CO_BITS_10 2
47 #define SR_TE_CO_BITS_11 3
50 * @brief SR Segment List (SID list)
55 mpls_label_t *segments;
57 /* SID list weight (wECMP / UCMP) */
64 u32 *segments_lists; /**< Pool of SID lists indexes */
66 mpls_label_t bsid; /**< BindingSID (key) */
68 u8 type; /**< Type (default is 0) */
69 /* SR Policy specific DPO */
70 /* IF Type = DEFAULT Then Load Balancer DPO among SID lists */
71 /* IF Type = SPRAY then Spray DPO with all SID lists */
73 ip46_address_t endpoint; /**< Optional NH for SR TE */
75 u32 color; /**< Optional color for SR TE */
79 * @brief Steering db key
81 * L3 is IPv4/IPv6 + mask
85 ip46_address_t prefix; /**< IP address of the prefix */
86 u32 mask_width; /**< Mask width of the prefix */
87 u32 fib_table; /**< VRF of the prefix */
88 u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
90 } sr_mpls_steering_key_t;
94 sr_mpls_steering_key_t classify; /**< Traffic classification */
95 mpls_label_t bsid; /**< SR Policy index */
96 ip46_address_t next_hop; /**< SR TE NH */
98 u32 *color; /**< Vector of SR TE colors */
99 char co_bits; /**< Color-Only bits */
100 mpls_label_t vpn_label;
101 } mpls_sr_steering_policy_t;
104 * @brief Segment Routing main datastructure
109 mpls_sr_sl_t *sid_lists;
111 /* SR MPLS policies */
112 mpls_sr_policy_t *sr_policies;
114 /* Hash table mapping BindingSID to SR MPLS policy */
115 uword *sr_policies_index_hash;
117 /* Pool of SR steer policies instances */
118 mpls_sr_steering_policy_t *steer_policies;
120 /* MHash table mapping steering rules to SR steer instance */
121 mhash_t sr_steer_policies_hash;
124 /* Hash table mapping (Color->Endpoint->BSID) for SR policies */
125 mhash_t sr_policies_c2e2eclabel_hash;
126 /* SR TE (internal) fib table (Endpoint, Color) */
128 /* Pool of (Endpoint, Color) hidden labels */
132 vlib_main_t *vlib_main;
133 vnet_main_t *vnet_main;
136 extern mpls_sr_main_t sr_mpls_main;
139 sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
140 u8 behavior, u32 weight);
143 sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
144 mpls_label_t * segments, u32 sl_index, u32 weight);
146 extern int sr_mpls_policy_del (mpls_label_t bsid);
149 sr_mpls_policy_assign_endpoint_color (mpls_label_t bsid,
150 ip46_address_t * endpoint,
151 u8 endpoint_type, u32 color);
154 sr_mpls_steering_policy_add (mpls_label_t bsid, u32 table_id,
155 ip46_address_t * prefix, u32 mask_width,
156 u8 traffic_type, ip46_address_t * next_hop,
157 u8 nh_type, u32 color, char co_bits,
158 mpls_label_t vpn_label);
161 sr_mpls_steering_policy_del (ip46_address_t * prefix,
162 u32 mask_width, u8 traffic_type, u32 table_id,
165 extern u32 find_or_create_internal_label (ip46_address_t endpoint, u32 color);
167 extern void internal_label_lock (ip46_address_t endpoint, u32 color);
169 extern void internal_label_unlock (ip46_address_t endpoint, u32 color);
171 #endif /* included_vnet_sr_mpls_h */
174 * fd.io coding-style-patch-verification: ON
176 * Local Variables: eval: (c-set-style "gnu") End: