qos.h (14458B)
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_QOS_H__ 11 #define __BCM_QOS_H__ 12 13 #include <bcm/types.h> 14 #include <bcm/multicast.h> 15 16 /* QoS Configuration Flags. */ 17 #define BCM_QOS_MAP_WITH_ID 0x0001 18 #define BCM_QOS_MAP_REPLACE 0x0002 19 #define BCM_QOS_MAP_L2 0x0004 20 #define BCM_QOS_MAP_L2_OUTER_TAG BCM_QOS_MAP_L2 21 #define BCM_QOS_MAP_L2_INNER_TAG 0x0008 22 #define BCM_QOS_MAP_L2_UNTAGGED 0x0010 23 #define BCM_QOS_MAP_L2_VLAN_PCP 0x0020 24 #define BCM_QOS_MAP_L3 0x0040 25 #define BCM_QOS_MAP_IPV4 BCM_QOS_MAP_L3 26 #define BCM_QOS_MAP_IPV6 0x0080 27 #define BCM_QOS_MAP_MPLS 0x0100 28 #define BCM_QOS_MAP_ENCAP 0x0200 29 #define BCM_QOS_MAP_INGRESS 0x0400 30 #define BCM_QOS_MAP_EGRESS 0x0800 31 #define BCM_QOS_MAP_MPLS_ELSP 0x1000 32 #define BCM_QOS_MAP_MIM_ITAG 0x2000 33 #define BCM_QOS_MAP_QUEUE 0x4000 34 #define BCM_QOS_MAP_POLICER 0x8000 35 #define BCM_QOS_MAP_PACKET_INVALID 0x10000 36 #define BCM_QOS_MAP_IGNORE_OFFSET 0x20000 37 #define BCM_QOS_MAP_OPCODE 0x40000 38 #define BCM_QOS_MAP_L2_ETAG 0x80000 39 #define BCM_QOS_MAP_MPLS_SECOND BCM_QOS_MAP_L2_ETAG 40 #define BCM_QOS_MAP_L2_VLAN_ETAG 0x100000 41 #define BCM_QOS_MAP_L2_TWO_TAGS BCM_QOS_MAP_L2_VLAN_ETAG 42 #define BCM_QOS_MAP_MPLS_PHP 0x200000 43 #define BCM_QOS_MAP_SUBPORT 0x400000 44 #define BCM_QOS_MAP_PORT BCM_QOS_MAP_SUBPORT 45 #define BCM_QOS_MAP_L3_L2 0x800000 46 #define BCM_QOS_MAP_VFT 0x1000000 47 #define BCM_QOS_MAP_VSAN 0x2000000 48 #define BCM_QOS_MAP_IP_MC BCM_QOS_MAP_VSAN 49 #define BCM_QOS_MAP_RCH 0x2000000 50 #define BCM_QOS_MAP_OAM_PCP 0x4000000 51 #define BCM_QOS_MAP_OAM_INTPRI 0x8000000 52 #define BCM_QOS_MAP_OAM_OUTER_VLAN_PCP 0x10000000 53 #define BCM_QOS_MAP_OAM_INNER_VLAN_PCP 0x20000000 54 #define BCM_QOS_MAP_OAM_MPLS_EXP 0x40000000 55 #define BCM_QOS_MAP_REMARK 0x10000000 56 #define BCM_QOS_MAP_ECN 0x20000000 57 #define BCM_QOS_MAP_PHB 0x40000000 58 #define BCM_QOS_MAP_REPLICATION 0x80000000 59 #define BCM_QOS_MAP_MIML BCM_QOS_MAP_MIM_ITAG 60 #define BCM_QOS_MAP_ENCAP_INTPRI_COLOR BCM_QOS_MAP_VFT 61 #define BCM_QOS_MAP_INGRESS_COPIED BCM_QOS_MAP_REMARK /* Use packet QoS fields 62 (priority, CFI, DSCP and 63 ECN) copied from the 64 ingress for QoS remark at 65 the egress. */ 66 67 /* Special qos map values */ 68 #define BCM_QOS_OPCODE_PRESERVE -4 /* Dedicated opcode for QoS preserve. */ 69 70 #define BCM_QOS_MAX_TUNNEL_EXP 7 /* Maximum tunnel EXP number */ 71 72 /* QoS map action definitions. */ 73 #define BCM_QOS_MAP_ACTION_DROP (1 << 0) /* Packet drop */ 74 75 /* QoS Map structure */ 76 typedef struct bcm_qos_map_s { 77 uint8 pkt_pri; /* Packet priority */ 78 uint8 pkt_cfi; /* Packet CFI */ 79 int dscp; /* Packet DSCP */ 80 int exp; /* Packet EXP */ 81 int int_pri; /* Internal priority */ 82 bcm_color_t color; /* Color */ 83 int remark_int_pri; /* (internal) remarking priority */ 84 bcm_color_t remark_color; /* (internal) remark color */ 85 int policer_offset; /* Offset based on pri/cos to fetch a 86 policer */ 87 int queue_offset; /* Offset based on int_pri to fetch cosq 88 for subscriber ports */ 89 int port_offset; /* Offset based on port connection for 90 indexing into the action table */ 91 uint8 etag_pcp; /* ETAG PCP field */ 92 uint8 etag_de; /* ETAG DE field */ 93 int counter_offset; /* Offset based on priority for indexing 94 into the loss measurement counter 95 table */ 96 int inherited_dscp_exp; /* Inherited DSCP EXP value */ 97 uint32 opcode; /* Set QOS Map Opcode ID */ 98 uint8 inner_pkt_pri; /* Inner Tag Packet priority */ 99 uint8 inner_pkt_cfi; /* Inner Tag Packet CFI */ 100 uint8 int_cn; /* Internal congestion notification */ 101 uint8 pkt_ecn; /* Packet explicit congestion 102 notification */ 103 uint8 responsive; /* Responsive flow (like TCP) */ 104 uint8 latency_marked; /* Packet marked with latency congestion */ 105 int tunnel_exp[BCM_QOS_MAX_TUNNEL_EXP]; /* MPLS tunnel EXP */ 106 uint32 actions; /* QOS map actions */ 107 uint8 copied_pkt_pri; /* Packet priority copied from ingress 108 pipeline */ 109 uint8 copied_pkt_cfi; /* Packet CFI copied from ingress 110 pipeline */ 111 uint8 copied_pkt_dscp; /* Packet DSCP copied from ingress 112 pipeline */ 113 uint8 copied_pkt_ecn; /* Packet ECN copied from ingress 114 pipeline */ 115 } bcm_qos_map_t; 116 117 /* qos ingress model type */ 118 typedef enum bcm_qos_ingress_model_type_e { 119 bcmQosIngressModelInvalid = 0, /* qos model invalid */ 120 bcmQosIngressModelShortpipe = 1, /* qos model is short pipe */ 121 bcmQosIngressModelPipe = 2, /* qos model is pipe */ 122 bcmQosIngressModelUniform = 3, /* qos model is uniform */ 123 bcmQosIngressModelStuck = 4 /* qos model is stuck */ 124 } bcm_qos_ingress_model_type_t; 125 126 /* qos ingress ecn model type */ 127 typedef enum bcm_qos_ingress_ecn_model_type_e { 128 bcmQosIngressEcnModelInvalid = 0, /* qos ecn model is invalid */ 129 bcmQosIngressEcnModelEligible = 1 /* qos ecn model is eligible */ 130 } bcm_qos_ingress_ecn_model_type_t; 131 132 /* Ingress QoS model structure */ 133 typedef struct bcm_qos_ingress_model_s { 134 bcm_qos_ingress_model_type_t ingress_phb; /* ingress PHB model */ 135 bcm_qos_ingress_model_type_t ingress_remark; /* ingress remark model */ 136 bcm_qos_ingress_model_type_t ingress_ttl; /* ingress ttl model */ 137 bcm_qos_ingress_ecn_model_type_t ingress_ecn; /* ingress ecn model */ 138 } bcm_qos_ingress_model_t; 139 140 /* qos egress model type */ 141 typedef enum bcm_qos_egress_model_type_e { 142 bcmQosEgressModelUniform = 0, /* use previous layer qos */ 143 bcmQosEgressModelPipeNextNameSpace = 1, /* qos egress pipe next name space */ 144 bcmQosEgressModelPipeMyNameSpace = 2, /* qos egress pipe my name space */ 145 bcmQosEgressModelInitial = 3 /* use egress initial qos */ 146 } bcm_qos_egress_model_type_t; 147 148 /* qos egress ecn model type */ 149 typedef enum bcm_qos_egress_ecn_model_type_e { 150 bcmQosEgressEcnModelInvalid = 0, /* qos ecn model is invalid */ 151 bcmQosEgressEcnModelEligible = 1 /* qos ecn model is eligible */ 152 } bcm_qos_egress_ecn_model_type_t; 153 154 /* egress QoS model structure */ 155 typedef struct bcm_qos_egress_model_s { 156 bcm_qos_egress_model_type_t egress_qos; /* egress qos variable */ 157 bcm_qos_egress_model_type_t egress_ttl; /* egress ttl */ 158 bcm_qos_egress_ecn_model_type_t egress_ecn; /* layer ecn is eligible */ 159 } bcm_qos_egress_model_t; 160 161 /* qos map control */ 162 typedef enum bcm_qos_map_control_type_e { 163 bcmQosMapControlL3L2 = 0, /* QoS map L2 use L3 */ 164 bcmQosMapControlL2TwoTagsMode = 1, /* Ethernet Two tags mapping mode */ 165 bcmQosMapControlMplsPortModeServiceTag = 2 /* PWE tagged mode mapping */ 166 } bcm_qos_map_control_type_t; 167 168 /* qos map control two tags mode */ 169 typedef enum bcm_qos_map_control_two_tags_e { 170 bcmQosMapControlL2TwoTagsModeOuterOnly = 0, /* QoS map only outer tag in case two 171 tags */ 172 bcmQosMapControlL2TwoTagsModeInnerOnly = 1, /* QoS map only inner tag in case two 173 tags */ 174 bcmQosMapControlL2TwoTagsModeDoubleTag = 2 /* QoS map only double tags in case two 175 tags */ 176 } bcm_qos_map_control_two_tags_t; 177 178 /* qos map control mpls port mode service tag */ 179 typedef enum bcm_qos_map_control_mpls_port_e { 180 bcmQosMapControlMplsPortModeServiceTagDisable = 0, /* disable MPLS port QOS map service tag */ 181 bcmQosMapControlMplsPortModeServiceTagTypical = 1, /* mpls port service tag typical map */ 182 bcmQosMapControlMplsPortModeServiceTagOuter = 2 /* mpls port map use only outer service 183 tag */ 184 } bcm_qos_map_control_mpls_port_t; 185 186 /* Initialize the QoS Map structure. */ 187 extern void bcm_qos_map_t_init( 188 bcm_qos_map_t *qos_map); 189 190 /* Initialize the QoS ingress model structure. */ 191 extern void bcm_qos_ingress_model_t_init( 192 bcm_qos_ingress_model_t *qos_ingress_model); 193 194 /* Initialize the QoS egress model structure. */ 195 extern void bcm_qos_egress_model_t_init( 196 bcm_qos_egress_model_t *qos_egress_model); 197 198 #ifndef BCM_HIDE_DISPATCHABLE 199 200 /* Initialize the BCM QoS subsystem. */ 201 extern int bcm_qos_init( 202 int unit); 203 204 /* Detach the BCM QoS subsystem. */ 205 extern int bcm_qos_detach( 206 int unit); 207 208 /* Allocates hardware resources for QoS mapping. */ 209 extern int bcm_qos_map_create( 210 int unit, 211 uint32 flags, 212 int *map_id); 213 214 /* Frees hardware resources for QoS mapping. */ 215 extern int bcm_qos_map_destroy( 216 int unit, 217 int map_id); 218 219 /* Add a specific mapping entry to a QoS map. */ 220 extern int bcm_qos_map_add( 221 int unit, 222 uint32 flags, 223 bcm_qos_map_t *map, 224 int map_id); 225 226 /* Get an entire QoS mapping for the given QoS Map ID. */ 227 extern int bcm_qos_map_multi_get( 228 int unit, 229 uint32 flags, 230 int map_id, 231 int array_size, 232 bcm_qos_map_t *array, 233 int *array_count); 234 235 /* Deletes a specific mapping entry from a QoS map. */ 236 extern int bcm_qos_map_delete( 237 int unit, 238 uint32 flags, 239 bcm_qos_map_t *map, 240 int map_id); 241 242 /* Associates a GPORT with a QoS map. */ 243 extern int bcm_qos_port_map_set( 244 int unit, 245 bcm_gport_t port, 246 int ing_map, 247 int egr_map); 248 249 /* 250 * Retrieves the configured QoS mapping matching a type for the given 251 * GPORT. 252 */ 253 extern int bcm_qos_port_map_type_get( 254 int unit, 255 bcm_gport_t port, 256 uint32 flags, 257 int *map_id); 258 259 /* Retrieves the configured QoS mapping for the given GPORT. */ 260 extern int bcm_qos_port_map_get( 261 int unit, 262 bcm_gport_t port, 263 int *ing_map, 264 int *egr_map); 265 266 /* Associate a port, vid with an ingress and egress QoS mapping. */ 267 extern int bcm_qos_port_vlan_map_set( 268 int unit, 269 bcm_port_t port, 270 bcm_vlan_t vid, 271 int ing_map, 272 int egr_map); 273 274 /* Get the QoS map ID for a port, vid. */ 275 extern int bcm_qos_port_vlan_map_get( 276 int unit, 277 bcm_port_t port, 278 bcm_vlan_t vid, 279 int *ing_map, 280 int *egr_map); 281 282 /* Get the list of all QoS Map IDs. */ 283 extern int bcm_qos_multi_get( 284 int unit, 285 int array_size, 286 int *map_ids_array, 287 int *flags_array, 288 int *array_count); 289 290 /* Set QOS Map control properties */ 291 extern int bcm_qos_map_control_set( 292 int unit, 293 uint32 map_id, 294 uint32 flags, 295 bcm_qos_map_control_type_t type, 296 int arg); 297 298 /* Get QOS Map control properties */ 299 extern int bcm_qos_map_control_get( 300 int unit, 301 uint32 map_id, 302 uint32 flags, 303 bcm_qos_map_control_type_t type, 304 int *arg); 305 306 /* bcm_qos_map_id_get_by_profile */ 307 extern int bcm_qos_map_id_get_by_profile( 308 int unit, 309 uint32 flags, 310 int profile, 311 int *map_id); 312 313 #endif /* BCM_HIDE_DISPATCHABLE */ 314 315 /* QoS control types */ 316 typedef enum bcm_qos_control_type_e { 317 bcmQosControlMplsIngressSwapRemarkProfile = 0, /* Egress QoS map Id for MPLS ingress 318 swap cases. */ 319 bcmQosControlMplsExplicitNullIngressQosProfile = 1, /* Ingress QOS profile on MPLS Explicit 320 NULL label. */ 321 bcmQosControlMplsExplicitNullIngressPhbModel = 2, /* Ingress QOS PHB model of MPLS 322 Explicit NULL label. */ 323 bcmQosControlMplsExplicitNullIngressRemarkModel = 3, /* Ingress QOS Remark model of MPLS 324 Explicit NULL label. */ 325 bcmQosControlMplsExplicitNullIngressTtlModel = 4, /* Ingress QOS TTL model of MPLS 326 Explicit NULL label. */ 327 bcmQosControlMplsIngressSwapTtlModel = 5, /* TTL Model for MPLS ingress swap and 328 encapsulation cases. */ 329 bcmQosControlMplsIngressSwapTtl = 6, /* TTL value for MPLS ingress swap and 330 encapsulation cases. */ 331 bcmQosControlMplsIngressPopQoSPreserve = 7, /* MPLS ingress pop DSCP preserve. */ 332 bcmQosControlMplsEgressForwardQoSPreserve = 8, /* MPLS egress forward exp preserve. */ 333 bcmQosControl__Count = 9 /* Always last. Not a usable value. */ 334 } bcm_qos_control_type_t; 335 336 #ifndef BCM_HIDE_DISPATCHABLE 337 338 /* Set/get QoS control properties per the control type. */ 339 extern int bcm_qos_control_set( 340 int unit, 341 uint32 flags, 342 bcm_qos_control_type_t type, 343 int arg); 344 345 /* bcm_qos_control_get */ 346 extern int bcm_qos_control_get( 347 int unit, 348 uint32 flags, 349 bcm_qos_control_type_t type, 350 int *arg); 351 352 /* Requires BROADCOM_PREMIUM license */ 353 extern int bcm_qos_vpn_map_set( 354 int unit, 355 bcm_vpn_t vpn, 356 int ing_map, 357 int egr_map); 358 359 /* Requires BROADCOM_PREMIUM license */ 360 extern int bcm_qos_vpn_map_type_get( 361 int unit, 362 bcm_vpn_t vpn, 363 uint32 flags, 364 int *map_id); 365 366 #endif /* BCM_HIDE_DISPATCHABLE */ 367 368 #endif /* __BCM_QOS_H__ */