sr: SRv6 Path Tracing Midpoint behaviour
[vpp.git] / src / vnet / srv6 / sr_pt.h
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright(c) 2022 Cisco Systems, Inc.
3  */
4
5 /**
6  * @file
7  * @brief SR Path Tracing data structures definitions
8  *
9  */
10
11 #ifndef included_vnet_sr_pt_h
12 #define included_vnet_sr_pt_h
13
14 #define IP6_HBH_PT_TYPE 50
15
16 /*SR PT error codes*/
17 #define SR_PT_ERR_NOENT                -1 /* No such entry*/
18 #define SR_PT_ERR_EXIST                -2 /* Entry exists */
19 #define SR_PT_ERR_IFACE_INVALID        -3 /* IFACE invalid */
20 #define SR_PT_ERR_ID_INVALID           -4 /* ID invalid */
21 #define SR_PT_ERR_LOAD_INVALID         -5 /* LOAD invalid*/
22 #define SR_PT_ERR_TTS_TEMPLATE_INVALID -6 /* TTS Template invalid */
23
24 /*SR PT paramters max values*/
25 #define SR_PT_ID_MAX           4095
26 #define SR_PT_LOAD_MAX         15
27 #define SR_PT_TTS_TEMPLATE_MAX 3
28
29 /*SR PT TTS Templates*/
30 #define SR_PT_TTS_TEMPLATE_0       0
31 #define SR_PT_TTS_TEMPLATE_1       1
32 #define SR_PT_TTS_TEMPLATE_2       2
33 #define SR_PT_TTS_TEMPLATE_3       3
34 #define SR_PT_TTS_TEMPLATE_DEFAULT 2
35
36 /*SR PT TTS Template shift value*/
37 #define SR_PT_TTS_SHIFT_TEMPLATE_0 8
38 #define SR_PT_TTS_SHIFT_TEMPLATE_1 12
39 #define SR_PT_TTS_SHIFT_TEMPLATE_2 16
40 #define SR_PT_TTS_SHIFT_TEMPLATE_3 20
41
42 /*PT node behaviors*/
43 #define PT_BEHAVIOR_SRC 0
44 #define PT_BEHAVIOR_MID 1
45 #define PT_BEHAVIOR_SNK 2
46
47 typedef struct
48 {
49   u32 iface;       /**< Interface */
50   u16 id;          /**< Interface ID */
51   u8 ingress_load; /**< Interface Ingress Load */
52   u8 egress_load;  /**< Interface Egress Load */
53   u8 tts_template; /**< Interface TTS Template */
54 } sr_pt_iface_t;
55
56 typedef struct
57 {
58   u16 oif_oil;
59   u8 tts;
60 } __clib_packed sr_pt_cmd_t;
61
62 typedef struct
63 {
64   sr_pt_cmd_t cmd_stack[12];
65 } __clib_packed ip6_hop_by_hop_option_pt_t;
66
67 /**
68  * @brief SR Path Tracing main datastructure
69  */
70 typedef struct
71 {
72   /* Pool of sr_pt_iface instances */
73   sr_pt_iface_t *sr_pt_iface;
74
75   /* Hash table for sr_pt_iface parameters */
76   mhash_t sr_pt_iface_index_hash;
77
78 } sr_pt_main_t;
79
80 extern sr_pt_main_t sr_pt_main;
81 extern vlib_node_registration_t sr_pt_node;
82 extern int sr_pt_add_iface (u32 iface, u16 id, u8 ingress_load, u8 egress_load,
83                             u8 tts_template);
84 extern int sr_pt_del_iface (u32 iface);
85 extern void *sr_pt_find_iface (u32 iface);
86
87 #endif /* included_vnet_sr_pt_h */