blob: 53001e10ac7e9694fa5c903f1ffe7c53c03d734c [file] [log] [blame]
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +00001/* 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
Julian Klaiber39d6dec2022-10-18 10:37:14 +020014#define IP6_HBH_PT_TYPE 50
15
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000016/*SR PT error codes*/
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000017#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
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000024/*SR PT paramters max values*/
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000025#define SR_PT_ID_MAX 4095
26#define SR_PT_LOAD_MAX 15
27#define SR_PT_TTS_TEMPLATE_MAX 3
28
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000029/*SR PT TTS Templates*/
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000030#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
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000036/*SR PT TTS Template shift value*/
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000037#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
Julian Klaiber39d6dec2022-10-18 10:37:14 +020042/*PT node behaviors*/
43#define PT_BEHAVIOR_SRC 0
44#define PT_BEHAVIOR_MID 1
45#define PT_BEHAVIOR_SNK 2
46
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000047typedef 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
Julian Klaiber39d6dec2022-10-18 10:37:14 +020056typedef struct
57{
58 u16 oif_oil;
59 u8 tts;
60} __clib_packed sr_pt_cmd_t;
61
62typedef struct
63{
64 sr_pt_cmd_t cmd_stack[12];
65} __clib_packed ip6_hop_by_hop_option_pt_t;
66
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000067/**
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000068 * @brief SR Path Tracing main datastructure
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000069 */
70typedef struct
71{
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000072 /* Pool of sr_pt_iface instances */
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000073 sr_pt_iface_t *sr_pt_iface;
74
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000075 /* Hash table for sr_pt_iface parameters */
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000076 mhash_t sr_pt_iface_index_hash;
77
Julian Klaiberb79d09b2022-11-08 08:44:06 +010078 /* convenience */
79 u16 msg_id_base;
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000080} sr_pt_main_t;
81
82extern sr_pt_main_t sr_pt_main;
Julian Klaiber39d6dec2022-10-18 10:37:14 +020083extern vlib_node_registration_t sr_pt_node;
Ahmed Abdelsalamc933bb72022-06-29 11:08:42 +000084extern int sr_pt_add_iface (u32 iface, u16 id, u8 ingress_load, u8 egress_load,
85 u8 tts_template);
86extern int sr_pt_del_iface (u32 iface);
87extern void *sr_pt_find_iface (u32 iface);
88
Ahmed Abdelsalamb0057282022-06-29 16:30:21 +000089#endif /* included_vnet_sr_pt_h */