Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 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 | |
Julian Klaiber | 39d6dec | 2022-10-18 10:37:14 +0200 | [diff] [blame] | 14 | #define IP6_HBH_PT_TYPE 50 |
| 15 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 16 | /*SR PT error codes*/ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 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 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 24 | /*SR PT paramters max values*/ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 25 | #define SR_PT_ID_MAX 4095 |
| 26 | #define SR_PT_LOAD_MAX 15 |
| 27 | #define SR_PT_TTS_TEMPLATE_MAX 3 |
| 28 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 29 | /*SR PT TTS Templates*/ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 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 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 36 | /*SR PT TTS Template shift value*/ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 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 | |
Julian Klaiber | 39d6dec | 2022-10-18 10:37:14 +0200 | [diff] [blame] | 42 | /*PT node behaviors*/ |
| 43 | #define PT_BEHAVIOR_SRC 0 |
| 44 | #define PT_BEHAVIOR_MID 1 |
| 45 | #define PT_BEHAVIOR_SNK 2 |
| 46 | |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 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 | |
Julian Klaiber | 39d6dec | 2022-10-18 10:37:14 +0200 | [diff] [blame] | 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 | |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 67 | /** |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 68 | * @brief SR Path Tracing main datastructure |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 69 | */ |
| 70 | typedef struct |
| 71 | { |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 72 | /* Pool of sr_pt_iface instances */ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 73 | sr_pt_iface_t *sr_pt_iface; |
| 74 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 75 | /* Hash table for sr_pt_iface parameters */ |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 76 | mhash_t sr_pt_iface_index_hash; |
| 77 | |
Julian Klaiber | b79d09b | 2022-11-08 08:44:06 +0100 | [diff] [blame] | 78 | /* convenience */ |
| 79 | u16 msg_id_base; |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 80 | } sr_pt_main_t; |
| 81 | |
| 82 | extern sr_pt_main_t sr_pt_main; |
Julian Klaiber | 39d6dec | 2022-10-18 10:37:14 +0200 | [diff] [blame] | 83 | extern vlib_node_registration_t sr_pt_node; |
Ahmed Abdelsalam | c933bb7 | 2022-06-29 11:08:42 +0000 | [diff] [blame] | 84 | extern int sr_pt_add_iface (u32 iface, u16 id, u8 ingress_load, u8 egress_load, |
| 85 | u8 tts_template); |
| 86 | extern int sr_pt_del_iface (u32 iface); |
| 87 | extern void *sr_pt_find_iface (u32 iface); |
| 88 | |
Ahmed Abdelsalam | b005728 | 2022-06-29 16:30:21 +0000 | [diff] [blame] | 89 | #endif /* included_vnet_sr_pt_h */ |