FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
sr.h
Go to the documentation of this file.
1 /*
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:
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 /**
17  * @file
18  * @brief Segment Routing MPLS data structures definitions
19  *
20  */
21 
22 #ifndef included_vnet_srmpls_h
23 #define included_vnet_srmpls_h
24 
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>
32 
33 #include <stdlib.h>
34 #include <string.h>
35 
36 /* SR policy types */
37 #define SR_POLICY_TYPE_DEFAULT 0
38 #define SR_POLICY_TYPE_SPRAY 1
39 
40 #define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
41 
42 #define SR_STEER_IPV4 4
43 #define SR_STEER_IPV6 6
44 
45 /**
46  * @brief SR Segment List (SID list)
47  */
48 typedef struct
49 {
50  /**
51  * SIDs (key)
52  */
54 
55  /**
56  * SID list weight (wECMP / UCMP)
57  */
59 
60 } mpls_sr_sl_t;
61 
62 typedef struct
63 {
64  u32 *segments_lists; /**< Pool of SID lists indexes */
65 
66  mpls_label_t bsid; /**< BindingSID (key) */
67 
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 */
72 
74 
75 /**
76  * @brief Steering db key
77  *
78  * L3 is IPv4/IPv6 + mask
79  */
80 typedef struct
81 {
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) */
86  u8 padding[3];
88 
89 typedef struct
90 {
91  sr_mpls_steering_key_t classify; /**< Traffic classification */
92  u32 sr_policy; /**< SR Policy index */
94 
95 /**
96  * @brief Segment Routing main datastructure
97  */
98 typedef struct
99 {
100  /**
101  * SR SID lists
102  */
104 
105  /**
106  * SR MPLS policies
107  */
109 
110  /**
111  * Hash table mapping BindingSID to SR MPLS policy
112  */
114 
115  /**
116  * Pool of SR steer policies instances
117  */
119 
120  /**
121  * MHash table mapping steering rules to SR steer instance
122  */
124 
125  /**
126  * convenience
127  */
131 
133 
134 extern int
136  u8 behavior, u32 weight);
137 
138 extern int
139 sr_mpls_policy_mod (mpls_label_t bsid, u32 index, u8 operation,
140  mpls_label_t * segments, u32 sl_index, u32 weight);
141 
142 extern int sr_mpls_policy_del (mpls_label_t bsid, u32 index);
143 
144 #endif /* included_vnet_sr_mpls_h */
145 
146 /*
147  * fd.io coding-style-patch-verification: ON
148  *
149  * Local Variables:
150  * eval: (c-set-style "gnu")
151  * End:
152  */
Definition: mhash.h:46
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
Definition: sr.h:85
vlib_main_t * vlib_main
convenience
Definition: sr.h:128
int sr_mpls_policy_mod(mpls_label_t bsid, u32 index, u8 operation, mpls_label_t *segments, u32 sl_index, u32 weight)
Modify an existing SR policy.
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
ip46_address_t prefix
IP address of the prefix.
Definition: sr.h:82
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
u32 padding
Definition: vhost-user.h:77
mhash_t sr_steer_policies_hash
MHash table mapping steering rules to SR steer instance.
Definition: sr.h:123
SR Segment List (SID list)
Definition: sr.h:48
u32 fib_table
VRF of the prefix.
Definition: sr.h:84
mpls_sr_sl_t * sid_lists
SR SID lists.
Definition: sr.h:103
mpls_sr_steering_policy_t * steer_policies
Pool of SR steer policies instances.
Definition: sr.h:118
mpls_label_t bsid
BindingSID (key)
Definition: sr.h:66
mpls_sr_main_t sr_mpls_main
sr_mpls_steering_key_t classify
Traffic classification.
Definition: sr.h:91
u32 mask_width
Mask width of the prefix.
Definition: sr.h:83
mpls_sr_policy_t * sr_policies
SR MPLS policies.
Definition: sr.h:108
Segment Routing main datastructure.
Definition: sr.h:98
unsigned int u32
Definition: types.h:88
vnet_main_t * vnet_main
Definition: sr.h:129
uword * sr_policies_index_hash
Hash table mapping BindingSID to SR MPLS policy.
Definition: sr.h:113
u32 sr_policy
SR Policy index.
Definition: sr.h:92
u64 uword
Definition: types.h:112
int sr_mpls_policy_add(mpls_label_t bsid, mpls_label_t *segments, u8 behavior, u32 weight)
Create a new SR policy.
unsigned char u8
Definition: types.h:56
u8 type
Type (default is 0)
Definition: sr.h:68
mpls_label_t * segments
SIDs (key)
Definition: sr.h:53
u32 * segments_lists
Pool of SID lists indexes.
Definition: sr.h:64
Steering db key.
Definition: sr.h:80
int sr_mpls_policy_del(mpls_label_t bsid, u32 index)
Delete a SR policy.
u32 weight
SID list weight (wECMP / UCMP)
Definition: sr.h:58