ecn.h (17985B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_ECN_H__ 11 #define __BCM_ECN_H__ 12 13 #include <bcm/types.h> 14 15 /* ECN traffic map flag. */ 16 #define BCM_ECN_TRAFFIC_MAP_RESPONSIVE (1 << 0) /* 1: Responsive, 0: 17 Non-responsive. */ 18 19 #define BCM_ECN_TRAFFIC_MAP_LATENCY_ECN (1 << 1) /* Internal congestion 20 notification mapping of 21 Latency ECN. */ 22 23 /* ECN traffic map types. */ 24 typedef enum bcm_ecn_traffic_map_type_e { 25 bcmEcnTrafficMapTypeIngressPostForward = 0, /* Traffic map at ingress post 26 forwarding. */ 27 bcmEcnTrafficMapTypeIngressPreForward = 1, /* Traffic map at ingress pre 28 forwarding. */ 29 bcmEcnTrafficMapTypeTunnelInitiator = 2, /* Traffic map of tunnel initiator. */ 30 bcmEcnTrafficMapTypeCount = 3 /* Always last. Not a usable value. */ 31 } bcm_ecn_traffic_map_type_t; 32 33 /* Tunnel types definition for ECN traffic map. */ 34 typedef enum bcm_ecn_traffic_map_tunnel_type_e { 35 bcmEcnTrafficMapNonTunnel = 0, /* None tunnel traffic. */ 36 bcmEcnTrafficMapL2Tunnel = 1, /* L2 tunnel traffic, VxLAN and VPLS. */ 37 bcmEcnTrafficMapL3Tunnel = 2, /* L3 tunnel traffic, IPinIP, L3GRE and L3 38 MPLS. */ 39 bcmEcnTrafficMapMpls = 3, /* MPLS transit traffic. */ 40 bcmEcnTrafficMapCount = 4 /* End of list. */ 41 } bcm_ecn_traffic_map_tunnel_type_t; 42 43 /* ECN traffic map info. */ 44 typedef struct bcm_ecn_traffic_map_info_s { 45 uint32 flags; /* BCM_ECN_TRAFFIC_MAP_XXX flag 46 definitions. */ 47 uint8 ecn; /* ECN value of packet's IP header. */ 48 int int_cn; /* Mapped internal congestion 49 notification(int_cn) value. */ 50 uint8 tunnel_ecn; /* ECN information of packet's tunnel 51 header. */ 52 bcm_ecn_traffic_map_tunnel_type_t tunnel_type; /* Tunnel type. */ 53 bcm_ecn_traffic_map_type_t type; /* Traffic map type 54 bcmEcnTrafficMapTypeXXX to be 55 configured. */ 56 } bcm_ecn_traffic_map_info_t; 57 58 /* ECN marking types. */ 59 typedef enum bcm_ecn_marking_type_e { 60 bcmEcnMarkingTypeBufferUsage = 0, /* Buffer usage based marking. */ 61 bcmEcnMarkingTypeLatency = 1, /* Latency based marking. */ 62 bcmEcnMarkingTypeCount = 2 /* Always last. Not a usable value. */ 63 } bcm_ecn_marking_type_t; 64 65 /* ECN type map flags. */ 66 #define BCM_ECN_TYPE_MAP_INTPRI_TO_MARKINGTYPE (0x00000001) /* Mapping from internal 67 priority to marking 68 type. */ 69 70 #define BCM_ECN_TYPE_MAP_INGRESS_PRE_FORWARD_MARKING_TYPE_UPDATE (0x80000000) /* Indicates the 71 operation on ingress 72 pre-forward marking 73 type. */ 74 75 #define BCM_ECN_TYPE_MAP_INGRESS_POST_FORWARD_MARKING_TYPE_UPDATE (0x40000000) /* Indicates the 76 operation on ingress 77 post-forward marking 78 type. */ 79 80 /* ECN type map structure. */ 81 typedef struct bcm_ecn_type_map_s { 82 int int_pri; /* Internal priority. */ 83 bcm_ecn_marking_type_t ing_pre_fwd_marking; /* Marking type at ingress 84 pre-forwarding. */ 85 bcm_ecn_marking_type_t ing_post_fwd_marking; /* Marking type at ingress 86 post-forwarding. */ 87 } bcm_ecn_type_map_t; 88 89 /* ECN traffic action types */ 90 #define BCM_ECN_TRAFFIC_ACTION_TYPE_ENQUEUE (0x1) /* Action of enqueue 91 stage. */ 92 #define BCM_ECN_TRAFFIC_ACTION_TYPE_DEQUEUE (0x2) /* Action of dequeue 93 stage. */ 94 #define BCM_ECN_TRAFFIC_ACTION_TYPE_EGRESS (0x3) /* Action of egress 95 stage. */ 96 #define BCM_ECN_TRAFFIC_ACTION_TYPE_LATENCY_ECN_DEQUEUE (0x4) /* Action of Latency ECN 97 at dequeue stage. */ 98 99 /* ECN traffic action flags */ 100 #define BCM_ECN_TRAFFIC_ACTION_NONE (0x0) /* Action none */ 101 #define BCM_ECN_TRAFFIC_ACTION_ENQUEUE_WRED_RESPONSIVE (1 << 0) /* If set, enabled WRED 102 responsive dropping. 103 Otherwise, enables 104 WRED non-responsive 105 dropping. */ 106 #define BCM_ECN_TRAFFIC_ACTION_ENQUEUE_MARK_ELIGIBLE (1 << 1) /* If set, avoids WRED 107 dropping when ECN 108 marking is enabled. */ 109 #define BCM_ECN_TRAFFIC_ACTION_DEQUEUE_CONGESTION_INT_CN_UPDATE (1 << 2) /* If set, updates the 110 value of int_cn when 111 congestion is 112 experienced. */ 113 #define BCM_ECN_TRAFFIC_ACTION_DEQUEUE_NON_CONGESTION_INT_CN_UPDATE (1 << 3) /* If set, updates the 114 value of int_cn when 115 congestion is not 116 experienced. */ 117 #define BCM_ECN_TRAFFIC_ACTION_EGRESS_ECN_MARKING (1 << 4) /* If set, indicates that 118 the packet's ECN bits 119 need to be updated. */ 120 #define BCM_ECN_TRAFFIC_ACTION_EGRESS_DROP (1 << 5) /* If set, indicates to 121 drop packet in egress. */ 122 #define BCM_ECN_TRAFFIC_ACTION_INGRESS_DROP (1 << 6) /* If set, indicates to 123 drop packet in 124 ingress. */ 125 #define BCM_ECN_TRAFFIC_ACTION_EGRESS_EXP_MARKING (1 << 7) /* If set, indicates to 126 update EXP. */ 127 #define BCM_ECN_TRAFFIC_ACTION_INGRESS_ECN_MARKING (1 << 8) /* If set, indicates to 128 update ECN. */ 129 #define BCM_ECN_TRAFFIC_ACTION_RESPONSIVE (1 << 9) /* If set, indicates to 130 set configurations for 131 ecn responsive 132 traffic. */ 133 #define BCM_ECN_TRAFFIC_ACTION_EGRESS_INT_CN_MARKING (1 << 10) /* If set, indicates to 134 update INT_CN. */ 135 #define BCM_ECN_TRAFFIC_ACTION_ECN_COUNTER_ELIGIBLE (1 << 11) /* If set, indicates to 136 update ECN counter. */ 137 #define BCM_ECN_TRAFFIC_ACTION_DEQUEUE_LATENCY_INT_CN_UPDATE (1 << 12) /* If set, update int_cn 138 when latency 139 experienced. */ 140 141 /* 142 * ECN traffic action configuration. 143 * 144 * Contains information required for assigning the actions of ECN 145 * traffic. 146 */ 147 typedef struct bcm_ecn_traffic_action_config_s { 148 uint32 action_type; /* See BCM_ECN_TRAFFIC_ACTION_TYPE_XXX flag 149 definitions. */ 150 uint32 action_flags; /* See BCM_ECN_TRAFFIC_ACTION_XXX flag 151 definitions. */ 152 int int_cn; /* Internal congestion notification. */ 153 bcm_color_t color; /* Packet color. */ 154 uint8 ecn; /* ECN value of packet;s IP header. */ 155 uint8 new_ecn; /* New ECN value for remarking. */ 156 int congested_int_cn; /* New int_cn to be updated when the 157 congestion is experienced. */ 158 int non_congested_int_cn; /* New int_cn to be updated when the 159 congestion is not experienced. */ 160 int responsive; /* New responsive value to be used in the 161 egress pipeline. */ 162 int buffer_high_thd_exceeded; /* High buffer usage experienced. */ 163 int buffer_low_thd_exceeded; /* Low buffer usage experienced. */ 164 int latency_thd_exceeded; /* Latency experienced. */ 165 int congestion_marked; /* Enable counting congestion marked 166 packets. */ 167 int latency_int_cn; /* New int_cn when latency experienced. */ 168 } bcm_ecn_traffic_action_config_t; 169 170 /* Initialize the ECN type map structure. */ 171 extern void bcm_ecn_type_map_t_init( 172 bcm_ecn_type_map_t *ecn_type_map); 173 174 #ifndef BCM_HIDE_DISPATCHABLE 175 176 /* To get the ECN type mapping. */ 177 extern int bcm_ecn_type_map_get( 178 int unit, 179 uint32 flags, 180 bcm_ecn_type_map_t *map); 181 182 /* To set the ECN type mapping. */ 183 extern int bcm_ecn_type_map_set( 184 int unit, 185 uint32 flags, 186 bcm_ecn_type_map_t *map); 187 188 #endif /* BCM_HIDE_DISPATCHABLE */ 189 190 /* ECN type map traverse callback */ 191 typedef int (*bcm_ecn_type_map_traverse_cb)( 192 int unit, 193 uint32 flags, 194 bcm_ecn_type_map_t *map, 195 void *user_data); 196 197 #ifndef BCM_HIDE_DISPATCHABLE 198 199 /* Traverse all the specified created ECN type maps. */ 200 extern int bcm_ecn_type_map_traverse( 201 int unit, 202 uint32 flags, 203 bcm_ecn_type_map_traverse_cb cb, 204 void *user_data); 205 206 /* 207 * To configure the value of responsive indication of the IP protocol 208 * value. 209 */ 210 extern int bcm_ecn_responsive_protocol_get( 211 int unit, 212 uint8 ip_proto, 213 int *responsive); 214 215 /* 216 * To configure the value of responsive indication of the IP protocol 217 * value. 218 */ 219 extern int bcm_ecn_responsive_protocol_set( 220 int unit, 221 uint8 ip_proto, 222 int responsive); 223 224 /* To set/get the mapped internal congestion notification (int_cn). */ 225 extern int bcm_ecn_traffic_map_get( 226 int unit, 227 bcm_ecn_traffic_map_info_t *map); 228 229 /* To set/get the mapped internal congestion notification (int_cn). */ 230 extern int bcm_ecn_traffic_map_set( 231 int unit, 232 bcm_ecn_traffic_map_info_t *map); 233 234 /* Assign/Retrieve the actions to the specified ECN traffic. */ 235 extern int bcm_ecn_traffic_action_config_get( 236 int unit, 237 bcm_ecn_traffic_action_config_t *ecn_config); 238 239 /* Assign/Retrieve the actions to the specified ECN traffic. */ 240 extern int bcm_ecn_traffic_action_config_set( 241 int unit, 242 bcm_ecn_traffic_action_config_t *ecn_config); 243 244 #endif /* BCM_HIDE_DISPATCHABLE */ 245 246 /* Initialize an ECN traffic map information structure. */ 247 extern void bcm_ecn_traffic_map_info_t_init( 248 bcm_ecn_traffic_map_info_t *ecn_map); 249 250 /* Initialize an ECN traffic action configure structure. */ 251 extern void bcm_ecn_traffic_action_config_t_init( 252 bcm_ecn_traffic_action_config_t *ecn_action); 253 254 /* ECN map flags. */ 255 #define BCM_ECN_MAP_WITH_ID 0x00000001 /* ECN map ID is 256 specified by users */ 257 #define BCM_ECN_MAP_INGRESS 0x00000002 /* create an ingress map 258 used in conjunction 259 with map type */ 260 #define BCM_ECN_MAP_EGRESS 0x00000004 /* create an egress map 261 used in conjunction 262 with map type */ 263 #define BCM_ECN_MAP_MPLS 0x00000008 /* create an MPLS type of 264 map */ 265 #define BCM_ECN_MAP_MPLS_INT_CN_TO_EXP 0x00000010 /* create an INT_CN to 266 EXP map */ 267 #define BCM_ECN_MAP_TUNNEL_TERM 0x00000020 /* create a tunnel term 268 ecn map */ 269 #define BCM_ECN_MAP_TUNNEL_INIT_IP_PAYLOAD 0x00000040 /* Create tunnel 270 initiator for IP 271 payload ECN map. */ 272 #define BCM_ECN_MAP_TUNNEL_INIT_NON_IP_PAYLOAD 0x00000080 /* Create tunnel 273 initiator for non-IP 274 payload ECN map. */ 275 #define BCM_ECN_MAP_LATENCY_ECN 0x00000100 /* Create a Latency ECN 276 map. */ 277 278 #if defined(INCLUDE_L3) 279 /* MPLS ECN Map Structure. */ 280 typedef struct bcm_ecn_map_s { 281 uint32 action_flags; /* action flags for ECN map. */ 282 int int_cn; /* Internal congestion. */ 283 uint8 inner_ecn; /* IP ECN value in payload. */ 284 uint8 ecn; /* IP ECN value. */ 285 uint8 exp; /* Mpls EXP value. */ 286 uint8 new_ecn; /* New ECN value. */ 287 uint8 new_exp; /* New EXP value. */ 288 uint32 nonip_action_flags; /* action flags for Non-ip ECN map. */ 289 int new_int_cn; /* New internal congestion notification value. */ 290 int mmu_queue_id; /* MMU queue ID. */ 291 int latency_ecn_en; /* Enable/disable Latency ECN. */ 292 int latency_ecn_threshold; /* Latency ECN timestamp threshold in 293 nanoseconds. */ 294 } bcm_ecn_map_t; 295 #endif 296 297 #ifndef BCM_HIDE_DISPATCHABLE 298 299 #if defined(INCLUDE_L3) 300 /* To create an ECN mapping profile. */ 301 extern int bcm_ecn_map_create( 302 int unit, 303 uint32 flags, 304 int *ecn_map_id); 305 #endif 306 307 #if defined(INCLUDE_L3) 308 /* To destroy an ECN mapping profile. */ 309 extern int bcm_ecn_map_destroy( 310 int unit, 311 int ecn_map_id); 312 #endif 313 314 #if defined(INCLUDE_L3) 315 /* To set an ECN mapping entry in an ECN mapping profile. */ 316 extern int bcm_ecn_map_set( 317 int unit, 318 uint32 options, 319 int ecn_map_id, 320 bcm_ecn_map_t *ecn_map); 321 #endif 322 323 #if defined(INCLUDE_L3) 324 /* To get an ECN mapping entry from an ECN mapping profile. */ 325 extern int bcm_ecn_map_get( 326 int unit, 327 int ecn_map_id, 328 bcm_ecn_map_t *ecn_map); 329 #endif 330 331 #endif /* BCM_HIDE_DISPATCHABLE */ 332 333 #if defined(INCLUDE_L3) 334 /* To init an ECN mapping structure. */ 335 extern void bcm_ecn_map_t_init( 336 bcm_ecn_map_t *ecn_map); 337 #endif 338 339 /* ECN port map flags. */ 340 #define BCM_ECN_EGRESS_PORT_ECN_TO_EXP_MAP 0x00000001 /* Indicate an ECN_TO_EXP 341 map */ 342 #define BCM_ECN_EGRESS_PORT_INT_CN_TO_EXP_MAP 0x00000002 /* Indicate an 343 INT_CN_TO_EXP map */ 344 #define BCM_ECN_INGRESS_PORT_TUNNEL_TERM_MAP 0x00000004 /* Indicate a tunnel term 345 ECN map */ 346 #define BCM_ECN_EGRESS_PORT_LATENCY_ECN_MAP 0x00000008 /* Indicates a Latency 347 ECN map */ 348 349 #if defined(INCLUDE_L3) 350 /* MPLS ecn port Map Structure. */ 351 typedef struct bcm_ecn_port_map_s { 352 uint32 flags; /* flags for ECN port map. */ 353 int ecn_map_id; /* Ecn map id. */ 354 } bcm_ecn_port_map_t; 355 #endif 356 357 #if defined(INCLUDE_L3) 358 /* To initialize an ecn port map structure. */ 359 extern void bcm_ecn_port_map_t_init( 360 bcm_ecn_port_map_t *ecn_map); 361 #endif 362 363 #ifndef BCM_HIDE_DISPATCHABLE 364 365 #if defined(INCLUDE_L3) 366 /* To set/get the egress ecn_map_id on the specific port. */ 367 extern int bcm_ecn_port_map_get( 368 int unit, 369 bcm_gport_t port, 370 bcm_ecn_port_map_t *ecn_map); 371 #endif 372 373 #if defined(INCLUDE_L3) 374 /* To set/get the egress ecn_map_id on the specific port. */ 375 extern int bcm_ecn_port_map_set( 376 int unit, 377 bcm_gport_t port, 378 bcm_ecn_port_map_t *ecn_map); 379 #endif 380 381 #endif /* BCM_HIDE_DISPATCHABLE */ 382 383 #if defined(INCLUDE_L3) 384 /* ecn dscp map mode */ 385 typedef enum bcm_ecn_dscp_map_mode_e { 386 bcmEcnDscpMapModeDraft = 0, /* Draft mode */ 387 bcmEcnDscpMapModeRfc3168 = 1, /* Mode defined in RFC3168 */ 388 bcmEcnDscpMapModeCount = 2 /* End of list */ 389 } bcm_ecn_dscp_map_mode_t; 390 #endif 391 392 #if defined(INCLUDE_L3) 393 /* ecn map mode information */ 394 typedef struct bcm_ecn_map_mode_s { 395 int dscp; /* value of -1 to change all entries */ 396 bcm_ecn_dscp_map_mode_t dscp_map_mode; /* ecn map mode setting. */ 397 } bcm_ecn_map_mode_t; 398 #endif 399 400 #if defined(INCLUDE_L3) 401 /* To initialize an ecn mapping mode structure. */ 402 extern void bcm_ecn_map_mode_t_init( 403 bcm_ecn_map_mode_t *ecn_map_mode); 404 #endif 405 406 #ifndef BCM_HIDE_DISPATCHABLE 407 408 #if defined(INCLUDE_L3) 409 /* Configure the ECN mapping mode. */ 410 extern int bcm_ecn_map_mode_set( 411 int unit, 412 bcm_ecn_map_mode_t *ecn_map_mode); 413 #endif 414 415 #if defined(INCLUDE_L3) 416 /* Retrieve the ECN mapping mode. */ 417 extern int bcm_ecn_map_mode_get( 418 int unit, 419 bcm_ecn_map_mode_t *ecn_map_mode); 420 #endif 421 422 #endif /* BCM_HIDE_DISPATCHABLE */ 423 424 #endif /* __BCM_ECN_H__ */