2 * Copyright (c) 2015 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @brief Segment Routing MPLS data structures definitions
22 #ifndef included_vnet_srmpls_h
23 #define included_vnet_srmpls_h
25 #include <vnet/vnet.h>
26 #include <vnet/mpls/packet.h>
27 #include <vnet/fib/mpls_fib.h>
28 #include <vnet/ip/ip.h>
29 #include <vnet/ip/lookup.h>
30 #include <vnet/dpo/dpo.h>
31 #include <vnet/dpo/replicate_dpo.h>
37 #define SR_POLICY_TYPE_DEFAULT 0
38 #define SR_POLICY_TYPE_SPRAY 1
40 #define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
42 #define SR_STEER_IPV4 4
43 #define SR_STEER_IPV6 6
46 * @brief SR Segment List (SID list)
53 mpls_label_t *segments;
56 * 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 */
76 * @brief Steering db key
78 * L3 is IPv4/IPv6 + mask
82 ip46_address_t prefix; /**< IP address of the prefix */
83 u32 mask_width; /**< Mask width of the prefix */
84 u32 fib_table; /**< VRF of the prefix */
85 u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
87 } sr_mpls_steering_key_t;
91 sr_mpls_steering_key_t classify; /**< Traffic classification */
92 u32 sr_policy; /**< SR Policy index */
93 } mpls_sr_steering_policy_t;
96 * @brief Segment Routing main datastructure
103 mpls_sr_sl_t *sid_lists;
108 mpls_sr_policy_t *sr_policies;
111 * Hash table mapping BindingSID to SR MPLS policy
113 uword *sr_policies_index_hash;
116 * Pool of SR steer policies instances
118 mpls_sr_steering_policy_t *steer_policies;
121 * MHash table mapping steering rules to SR steer instance
123 mhash_t sr_steer_policies_hash;
128 vlib_main_t *vlib_main;
129 vnet_main_t *vnet_main;
132 extern mpls_sr_main_t sr_mpls_main;
135 sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
136 u8 behavior, u32 weight);
139 sr_mpls_policy_mod (mpls_label_t bsid, u32 index, u8 operation,
140 mpls_label_t * segments, u32 sl_index, u32 weight);
142 extern int sr_mpls_policy_del (mpls_label_t bsid, u32 index);
144 #endif /* included_vnet_sr_mpls_h */
147 * fd.io coding-style-patch-verification: ON
150 * eval: (c-set-style "gnu")