1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2017 Intel Corporation. 3 * Copyright(c) 2017 Cavium. 4 * Copyright(c) 2017 NXP. 5 */ 6 7 #ifndef __INCLUDE_RTE_TM_H__ 8 #define __INCLUDE_RTE_TM_H__ 9 10 /** 11 * @file 12 * RTE Generic Traffic Manager API 13 * 14 * This interface provides the ability to configure the traffic manager in a 15 * generic way. It includes features such as: hierarchical scheduling, 16 * traffic shaping, congestion management, packet marking, etc. 17 */ 18 19 #include <stdint.h> 20 21 #include <rte_common.h> 22 #include <rte_meter.h> 23 #include <rte_compat.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /** 30 * Ethernet framing overhead. 31 * 32 * Overhead fields per Ethernet frame: 33 * 1. Preamble: 7 bytes; 34 * 2. Start of Frame Delimiter (SFD): 1 byte; 35 * 3. Inter-Frame Gap (IFG): 12 bytes. 36 * 37 * One of the typical values for the *pkt_length_adjust* field of the shaper 38 * profile. 39 * 40 * @see struct rte_tm_shaper_params 41 */ 42 #define RTE_TM_ETH_FRAMING_OVERHEAD 20 43 44 /** 45 * Ethernet framing overhead including the Frame Check Sequence (FCS) field. 46 * Useful when FCS is generated and added at the end of the Ethernet frame on 47 * Tx side without any SW intervention. 48 * 49 * One of the typical values for the pkt_length_adjust field of the shaper 50 * profile. 51 * 52 * @see struct rte_tm_shaper_params 53 */ 54 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24 55 56 /** 57 * Invalid WRED profile ID. 58 * 59 * @see struct rte_tm_node_params 60 * @see rte_tm_node_add() 61 * @see rte_tm_node_wred_context_update() 62 */ 63 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX 64 65 /** 66 *Invalid shaper profile ID. 67 * 68 * @see struct rte_tm_node_params 69 * @see rte_tm_node_add() 70 * @see rte_tm_node_shaper_update() 71 */ 72 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX 73 74 /** 75 * Node ID for the parent of the root node. 76 * 77 * @see rte_tm_node_add() 78 */ 79 #define RTE_TM_NODE_ID_NULL UINT32_MAX 80 81 /** 82 * Node level ID used to disable level ID checking. 83 * 84 * @see rte_tm_node_add() 85 */ 86 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX 87 88 /** 89 * Node statistics counter type 90 */ 91 enum rte_tm_stats_type { 92 /** Number of packets scheduled from current node. */ 93 RTE_TM_STATS_N_PKTS = 1 << 0, 94 95 /** Number of bytes scheduled from current node. */ 96 RTE_TM_STATS_N_BYTES = 1 << 1, 97 98 /** Number of green packets dropped by current leaf node. */ 99 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2, 100 101 /** Number of yellow packets dropped by current leaf node. */ 102 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3, 103 104 /** Number of red packets dropped by current leaf node. */ 105 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4, 106 107 /** Number of green bytes dropped by current leaf node. */ 108 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5, 109 110 /** Number of yellow bytes dropped by current leaf node. */ 111 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6, 112 113 /** Number of red bytes dropped by current leaf node. */ 114 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7, 115 116 /** Number of packets currently waiting in the packet queue of current 117 * leaf node. 118 */ 119 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8, 120 121 /** Number of bytes currently waiting in the packet queue of current 122 * leaf node. 123 */ 124 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9, 125 }; 126 127 /** 128 * Node statistics counters 129 */ 130 struct rte_tm_node_stats { 131 /** Number of packets scheduled from current node. */ 132 uint64_t n_pkts; 133 134 /** Number of bytes scheduled from current node. */ 135 uint64_t n_bytes; 136 137 /** Statistics counters for leaf nodes only. */ 138 struct { 139 /** Number of packets dropped by current leaf node per each 140 * color. 141 */ 142 uint64_t n_pkts_dropped[RTE_COLORS]; 143 144 /** Number of bytes dropped by current leaf node per each 145 * color. 146 */ 147 uint64_t n_bytes_dropped[RTE_COLORS]; 148 149 /** Number of packets currently waiting in the packet queue of 150 * current leaf node. 151 */ 152 uint64_t n_pkts_queued; 153 154 /** Number of bytes currently waiting in the packet queue of 155 * current leaf node. 156 */ 157 uint64_t n_bytes_queued; 158 } leaf; 159 }; 160 161 /** 162 * Traffic manager dynamic updates 163 */ 164 enum rte_tm_dynamic_update_type { 165 /** Dynamic parent node update. The new parent node is located on same 166 * hierarchy level as the former parent node. Consequently, the node 167 * whose parent is changed preserves its hierarchy level. 168 */ 169 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0, 170 171 /** Dynamic parent node update. The new parent node is located on 172 * different hierarchy level than the former parent node. Consequently, 173 * the node whose parent is changed also changes its hierarchy level. 174 */ 175 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1, 176 177 /** Dynamic node add/delete. */ 178 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2, 179 180 /** Suspend/resume nodes. */ 181 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3, 182 183 /** Dynamic switch between byte-based and packet-based WFQ weights. */ 184 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4, 185 186 /** Dynamic update on number of SP priorities. */ 187 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5, 188 189 /** Dynamic update of congestion management mode for leaf nodes. */ 190 RTE_TM_UPDATE_NODE_CMAN = 1 << 6, 191 192 /** Dynamic update of the set of enabled stats counter types. */ 193 RTE_TM_UPDATE_NODE_STATS = 1 << 7, 194 }; 195 196 /** 197 * Traffic manager capabilities 198 */ 199 struct rte_tm_capabilities { 200 /** Maximum number of nodes. */ 201 uint32_t n_nodes_max; 202 203 /** Maximum number of levels (i.e. number of nodes connecting the root 204 * node with any leaf node, including the root and the leaf). 205 */ 206 uint32_t n_levels_max; 207 208 /** When non-zero, this flag indicates that all the non-leaf nodes 209 * (with the exception of the root node) have identical capability set. 210 */ 211 int non_leaf_nodes_identical; 212 213 /** When non-zero, this flag indicates that all the leaf nodes have 214 * identical capability set. 215 */ 216 int leaf_nodes_identical; 217 218 /** Maximum number of shapers, either private or shared. In case the 219 * implementation does not share any resources between private and 220 * shared shapers, it is typically equal to the sum of 221 * *shaper_private_n_max* and *shaper_shared_n_max*. The 222 * value of zero indicates that traffic shaping is not supported. 223 */ 224 uint32_t shaper_n_max; 225 226 /** Maximum number of private shapers. Indicates the maximum number of 227 * nodes that can concurrently have their private shaper enabled. The 228 * value of zero indicates that private shapers are not supported. 229 */ 230 uint32_t shaper_private_n_max; 231 232 /** Maximum number of private shapers that support dual rate shaping. 233 * Indicates the maximum number of nodes that can concurrently have 234 * their private shaper enabled with dual rate support. Only valid when 235 * private shapers are supported. The value of zero indicates that dual 236 * rate shaping is not available for private shapers. The maximum value 237 * is *shaper_private_n_max*. 238 */ 239 int shaper_private_dual_rate_n_max; 240 241 /** Minimum committed/peak rate (bytes per second) for any private 242 * shaper. Valid only when private shapers are supported. 243 */ 244 uint64_t shaper_private_rate_min; 245 246 /** Maximum committed/peak rate (bytes per second) for any private 247 * shaper. Valid only when private shapers are supported. 248 */ 249 uint64_t shaper_private_rate_max; 250 251 /** Shaper private packet mode supported. When non-zero, this parameter 252 * indicates that there is at least one node that can be configured 253 * with packet mode in its private shaper. When shaper is configured 254 * in packet mode, committed/peak rate provided is interpreted 255 * in packets per second. 256 */ 257 int shaper_private_packet_mode_supported; 258 259 /** Shaper private byte mode supported. When non-zero, this parameter 260 * indicates that there is at least one node that can be configured 261 * with byte mode in its private shaper. When shaper is configured 262 * in byte mode, committed/peak rate provided is interpreted in 263 * bytes per second. 264 */ 265 int shaper_private_byte_mode_supported; 266 267 268 /** Maximum number of shared shapers. The value of zero indicates that 269 * shared shapers are not supported. 270 */ 271 uint32_t shaper_shared_n_max; 272 273 /** Maximum number of nodes that can share the same shared shaper. 274 * Only valid when shared shapers are supported. 275 */ 276 uint32_t shaper_shared_n_nodes_per_shaper_max; 277 278 /** Maximum number of shared shapers a node can be part of. This 279 * parameter indicates that there is at least one node that can be 280 * configured with this many shared shapers, which might not be true for 281 * all the nodes. Only valid when shared shapers are supported, in which 282 * case it ranges from 1 to *shaper_shared_n_max*. 283 */ 284 uint32_t shaper_shared_n_shapers_per_node_max; 285 286 /** Maximum number of shared shapers that can be configured with dual 287 * rate shaping. The value of zero indicates that dual rate shaping 288 * support is not available for shared shapers. 289 */ 290 uint32_t shaper_shared_dual_rate_n_max; 291 292 /** Minimum committed/peak rate (bytes per second) for any shared 293 * shaper. Only valid when shared shapers are supported. 294 */ 295 uint64_t shaper_shared_rate_min; 296 297 /** Maximum committed/peak rate (bytes per second) for any shared 298 * shaper. Only valid when shared shapers are supported. 299 */ 300 uint64_t shaper_shared_rate_max; 301 302 /** Shaper shared packet mode supported. When non-zero, this parameter 303 * indicates a shared shaper can be configured with packet mode. 304 * When shared shaper is configured in packet mode, committed/peak rate 305 * provided is interpreted in packets per second. 306 */ 307 int shaper_shared_packet_mode_supported; 308 309 /** Shaper shared byte mode supported. When non-zero, this parameter 310 * indicates that a shared shaper can be configured with byte mode. 311 * When shared shaper is configured in byte mode, committed/peak rate 312 * provided is interpreted in bytes per second. 313 */ 314 int shaper_shared_byte_mode_supported; 315 316 317 /** Minimum value allowed for packet length adjustment for any private 318 * or shared shaper. 319 */ 320 int shaper_pkt_length_adjust_min; 321 322 /** Maximum value allowed for packet length adjustment for any private 323 * or shared shaper. 324 */ 325 int shaper_pkt_length_adjust_max; 326 327 /** Maximum number of children nodes. This parameter indicates that 328 * there is at least one non-leaf node that can be configured with this 329 * many children nodes, which might not be true for all the non-leaf 330 * nodes. 331 */ 332 uint32_t sched_n_children_max; 333 334 /** Maximum number of supported priority levels. This parameter 335 * indicates that there is at least one non-leaf node that can be 336 * configured with this many priority levels for managing its children 337 * nodes, which might not be true for all the non-leaf nodes. The value 338 * of zero is invalid. The value of 1 indicates that only priority 0 is 339 * supported, which essentially means that Strict Priority (SP) 340 * algorithm is not supported. 341 */ 342 uint32_t sched_sp_n_priorities_max; 343 344 /** Maximum number of sibling nodes that can have the same priority at 345 * any given time, i.e. maximum size of the WFQ sibling node group. This 346 * parameter indicates there is at least one non-leaf node that meets 347 * this condition, which might not be true for all the non-leaf nodes. 348 * The value of zero is invalid. The value of 1 indicates that WFQ 349 * algorithm is not supported. The maximum value is 350 * *sched_n_children_max*. 351 */ 352 uint32_t sched_wfq_n_children_per_group_max; 353 354 /** Maximum number of priority levels that can have more than one child 355 * node at any given time, i.e. maximum number of WFQ sibling node 356 * groups that have two or more members. This parameter indicates there 357 * is at least one non-leaf node that meets this condition, which might 358 * not be true for all the non-leaf nodes. The value of zero states that 359 * WFQ algorithm is not supported. The value of 1 indicates that 360 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one 361 * child node, so there can be only one priority level with two or 362 * more sibling nodes making up a WFQ group. The maximum value is: 363 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*). 364 */ 365 uint32_t sched_wfq_n_groups_max; 366 367 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes 368 * with same priority have the same WFQ weight, so WFQ is reduced to FQ. 369 */ 370 uint32_t sched_wfq_weight_max; 371 372 /** WFQ packet mode supported. When non-zero, this parameter indicates 373 * that there is at least one non-leaf node that supports packet mode 374 * for WFQ among its children. WFQ weights will be applied against 375 * packet count for scheduling children when a non-leaf node 376 * is configured appropriately. 377 */ 378 int sched_wfq_packet_mode_supported; 379 380 /** WFQ byte mode supported. When non-zero, this parameter indicates 381 * that there is at least one non-leaf node that supports byte mode 382 * for WFQ among its children. WFQ weights will be applied against 383 * bytes for scheduling children when a non-leaf node is configured 384 * appropriately. 385 */ 386 int sched_wfq_byte_mode_supported; 387 388 /** WRED packet mode support. When non-zero, this parameter indicates 389 * that there is at least one leaf node that supports the WRED packet 390 * mode, which might not be true for all the leaf nodes. In packet 391 * mode, the WRED thresholds specify the queue length in packets, as 392 * opposed to bytes. 393 */ 394 int cman_wred_packet_mode_supported; 395 396 /** WRED byte mode support. When non-zero, this parameter indicates that 397 * there is at least one leaf node that supports the WRED byte mode, 398 * which might not be true for all the leaf nodes. In byte mode, the 399 * WRED thresholds specify the queue length in bytes, as opposed to 400 * packets. 401 */ 402 int cman_wred_byte_mode_supported; 403 404 /** Head drop algorithm support. When non-zero, this parameter 405 * indicates that there is at least one leaf node that supports the head 406 * drop algorithm, which might not be true for all the leaf nodes. 407 */ 408 int cman_head_drop_supported; 409 410 /** Maximum number of WRED contexts, either private or shared. In case 411 * the implementation does not share any resources between private and 412 * shared WRED contexts, it is typically equal to the sum of 413 * *cman_wred_context_private_n_max* and 414 * *cman_wred_context_shared_n_max*. The value of zero indicates that 415 * WRED is not supported. 416 */ 417 uint32_t cman_wred_context_n_max; 418 419 /** Maximum number of private WRED contexts. Indicates the maximum 420 * number of leaf nodes that can concurrently have their private WRED 421 * context enabled. The value of zero indicates that private WRED 422 * contexts are not supported. 423 */ 424 uint32_t cman_wred_context_private_n_max; 425 426 /** Maximum number of shared WRED contexts. The value of zero 427 * indicates that shared WRED contexts are not supported. 428 */ 429 uint32_t cman_wred_context_shared_n_max; 430 431 /** Maximum number of leaf nodes that can share the same WRED context. 432 * Only valid when shared WRED contexts are supported. 433 */ 434 uint32_t cman_wred_context_shared_n_nodes_per_context_max; 435 436 /** Maximum number of shared WRED contexts a leaf node can be part of. 437 * This parameter indicates that there is at least one leaf node that 438 * can be configured with this many shared WRED contexts, which might 439 * not be true for all the leaf nodes. Only valid when shared WRED 440 * contexts are supported, in which case it ranges from 1 to 441 * *cman_wred_context_shared_n_max*. 442 */ 443 uint32_t cman_wred_context_shared_n_contexts_per_node_max; 444 445 /** Support for VLAN DEI packet marking (per color). */ 446 int mark_vlan_dei_supported[RTE_COLORS]; 447 448 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */ 449 int mark_ip_ecn_tcp_supported[RTE_COLORS]; 450 451 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */ 452 int mark_ip_ecn_sctp_supported[RTE_COLORS]; 453 454 /** Support for IPv4/IPv6 DSCP packet marking (per color). */ 455 int mark_ip_dscp_supported[RTE_COLORS]; 456 457 /** Set of supported dynamic update operations. 458 * @see enum rte_tm_dynamic_update_type 459 */ 460 uint64_t dynamic_update_mask; 461 462 /** Set of supported statistics counter types. 463 * @see enum rte_tm_stats_type 464 */ 465 uint64_t stats_mask; 466 }; 467 468 /** 469 * Traffic manager level capabilities 470 */ 471 struct rte_tm_level_capabilities { 472 /** Maximum number of nodes for the current hierarchy level. */ 473 uint32_t n_nodes_max; 474 475 /** Maximum number of non-leaf nodes for the current hierarchy level. 476 * The value of 0 indicates that current level only supports leaf 477 * nodes. The maximum value is *n_nodes_max*. 478 */ 479 uint32_t n_nodes_nonleaf_max; 480 481 /** Maximum number of leaf nodes for the current hierarchy level. The 482 * value of 0 indicates that current level only supports non-leaf 483 * nodes. The maximum value is *n_nodes_max*. 484 */ 485 uint32_t n_nodes_leaf_max; 486 487 /** When non-zero, this flag indicates that all the non-leaf nodes on 488 * this level have identical capability set. Valid only when 489 * *n_nodes_nonleaf_max* is non-zero. 490 */ 491 int non_leaf_nodes_identical; 492 493 /** When non-zero, this flag indicates that all the leaf nodes on this 494 * level have identical capability set. Valid only when 495 * *n_nodes_leaf_max* is non-zero. 496 */ 497 int leaf_nodes_identical; 498 499 union { 500 /** Items valid only for the non-leaf nodes on this level. */ 501 struct { 502 /** Private shaper support. When non-zero, it indicates 503 * there is at least one non-leaf node on this level 504 * with private shaper support, which may not be the 505 * case for all the non-leaf nodes on this level. 506 */ 507 int shaper_private_supported; 508 509 /** Dual rate support for private shaper. Valid only 510 * when private shaper is supported for the non-leaf 511 * nodes on the current level. When non-zero, it 512 * indicates there is at least one non-leaf node on this 513 * level with dual rate private shaper support, which 514 * may not be the case for all the non-leaf nodes on 515 * this level. 516 */ 517 int shaper_private_dual_rate_supported; 518 519 /** Minimum committed/peak rate (bytes per second) for 520 * private shapers of the non-leaf nodes of this level. 521 * Valid only when private shaper is supported on this 522 * level. 523 */ 524 uint64_t shaper_private_rate_min; 525 526 /** Maximum committed/peak rate (bytes per second) for 527 * private shapers of the non-leaf nodes on this level. 528 * Valid only when private shaper is supported on this 529 * level. 530 */ 531 uint64_t shaper_private_rate_max; 532 533 /** Shaper private packet mode supported. When non-zero, 534 * this parameter indicates there is at least one 535 * non-leaf node at this level that can be configured 536 * with packet mode in its private shaper. When private 537 * shaper is configured in packet mode, committed/peak 538 * rate provided is interpreted in packets per second. 539 */ 540 int shaper_private_packet_mode_supported; 541 542 /** Shaper private byte mode supported. When non-zero, 543 * this parameter indicates there is at least one 544 * non-leaf node at this level that can be configured 545 * with byte mode in its private shaper. When private 546 * shaper is configured in byte mode, committed/peak 547 * rate provided is interpreted in bytes per second. 548 */ 549 int shaper_private_byte_mode_supported; 550 551 /** Maximum number of shared shapers that any non-leaf 552 * node on this level can be part of. The value of zero 553 * indicates that shared shapers are not supported by 554 * the non-leaf nodes on this level. When non-zero, it 555 * indicates there is at least one non-leaf node on this 556 * level that meets this condition, which may not be the 557 * case for all the non-leaf nodes on this level. 558 */ 559 uint32_t shaper_shared_n_max; 560 561 /** Shaper shared packet mode supported. When non-zero, 562 * this parameter indicates that there is at least one 563 * non-leaf node on this level that can be part of 564 * shared shapers which work in packet mode. 565 */ 566 int shaper_shared_packet_mode_supported; 567 568 /** Shaper shared byte mode supported. When non-zero, 569 * this parameter indicates that there is at least one 570 * non-leaf node on this level that can be part of 571 * shared shapers which work in byte mode. 572 */ 573 int shaper_shared_byte_mode_supported; 574 575 /** Maximum number of children nodes. This parameter 576 * indicates that there is at least one non-leaf node on 577 * this level that can be configured with this many 578 * children nodes, which might not be true for all the 579 * non-leaf nodes on this level. 580 */ 581 uint32_t sched_n_children_max; 582 583 /** Maximum number of supported priority levels. This 584 * parameter indicates that there is at least one 585 * non-leaf node on this level that can be configured 586 * with this many priority levels for managing its 587 * children nodes, which might not be true for all the 588 * non-leaf nodes on this level. The value of zero is 589 * invalid. The value of 1 indicates that only priority 590 * 0 is supported, which essentially means that Strict 591 * Priority (SP) algorithm is not supported on this 592 * level. 593 */ 594 uint32_t sched_sp_n_priorities_max; 595 596 /** Maximum number of sibling nodes that can have the 597 * same priority at any given time, i.e. maximum size of 598 * the WFQ sibling node group. This parameter indicates 599 * there is at least one non-leaf node on this level 600 * that meets this condition, which may not be true for 601 * all the non-leaf nodes on this level. The value of 602 * zero is invalid. The value of 1 indicates that WFQ 603 * algorithm is not supported on this level. The maximum 604 * value is *sched_n_children_max*. 605 */ 606 uint32_t sched_wfq_n_children_per_group_max; 607 608 /** Maximum number of priority levels that can have 609 * more than one child node at any given time, i.e. 610 * maximum number of WFQ sibling node groups that 611 * have two or more members. This parameter indicates 612 * there is at least one non-leaf node on this level 613 * that meets this condition, which might not be true 614 * for all the non-leaf nodes. The value of zero states 615 * that WFQ algorithm is not supported on this level. 616 * The value of 1 indicates that 617 * (*sched_sp_n_priorities_max* - 1) priority levels on 618 * this level have at most one child node, so there can 619 * be only one priority level with two or more sibling 620 * nodes making up a WFQ group on this level. The 621 * maximum value is: 622 * min(floor(*sched_n_children_max* / 2), 623 * *sched_sp_n_priorities_max*). 624 */ 625 uint32_t sched_wfq_n_groups_max; 626 627 /** Maximum WFQ weight. The value of 1 indicates that 628 * all sibling nodes on this level with same priority 629 * have the same WFQ weight, so on this level WFQ is 630 * reduced to FQ. 631 */ 632 uint32_t sched_wfq_weight_max; 633 634 /** WFQ packet mode supported. When non-zero, this 635 * parameter indicates that there is at least one 636 * non-leaf node at this level that supports packet 637 * mode for WFQ among its children. WFQ weights will 638 * be applied against packet count for scheduling 639 * children when a non-leaf node is configured 640 * appropriately. 641 */ 642 int sched_wfq_packet_mode_supported; 643 644 /** WFQ byte mode supported. When non-zero, this 645 * parameter indicates that there is at least one 646 * non-leaf node at this level that supports byte 647 * mode for WFQ among its children. WFQ weights will 648 * be applied against bytes for scheduling children 649 * when a non-leaf node is configured appropriately. 650 */ 651 int sched_wfq_byte_mode_supported; 652 653 /** Mask of statistics counter types supported by the 654 * non-leaf nodes on this level. Every supported 655 * statistics counter type is supported by at least one 656 * non-leaf node on this level, which may not be true 657 * for all the non-leaf nodes on this level. 658 * @see enum rte_tm_stats_type 659 */ 660 uint64_t stats_mask; 661 } nonleaf; 662 663 /** Items valid only for the leaf nodes on this level. */ 664 struct { 665 /** Private shaper support. When non-zero, it indicates 666 * there is at least one leaf node on this level with 667 * private shaper support, which may not be the case for 668 * all the leaf nodes on this level. 669 */ 670 int shaper_private_supported; 671 672 /** Dual rate support for private shaper. Valid only 673 * when private shaper is supported for the leaf nodes 674 * on this level. When non-zero, it indicates there is 675 * at least one leaf node on this level with dual rate 676 * private shaper support, which may not be the case for 677 * all the leaf nodes on this level. 678 */ 679 int shaper_private_dual_rate_supported; 680 681 /** Minimum committed/peak rate (bytes per second) for 682 * private shapers of the leaf nodes of this level. 683 * Valid only when private shaper is supported for the 684 * leaf nodes on this level. 685 */ 686 uint64_t shaper_private_rate_min; 687 688 /** Maximum committed/peak rate (bytes per second) for 689 * private shapers of the leaf nodes on this level. 690 * Valid only when private shaper is supported for the 691 * leaf nodes on this level. 692 */ 693 uint64_t shaper_private_rate_max; 694 695 /** Shaper private packet mode supported. When non-zero, 696 * this parameter indicates there is at least one leaf 697 * node at this level that can be configured with 698 * packet mode in its private shaper. When private 699 * shaper is configured in packet mode, committed/peak 700 * rate provided is interpreted in packets per second. 701 */ 702 int shaper_private_packet_mode_supported; 703 704 /** Shaper private byte mode supported. When non-zero, 705 * this parameter indicates there is at least one leaf 706 * node at this level that can be configured with 707 * byte mode in its private shaper. When private shaper 708 * is configured in byte mode, committed/peak rate 709 * provided is interpreted in bytes per second. 710 */ 711 int shaper_private_byte_mode_supported; 712 713 /** Maximum number of shared shapers that any leaf node 714 * on this level can be part of. The value of zero 715 * indicates that shared shapers are not supported by 716 * the leaf nodes on this level. When non-zero, it 717 * indicates there is at least one leaf node on this 718 * level that meets this condition, which may not be the 719 * case for all the leaf nodes on this level. 720 */ 721 uint32_t shaper_shared_n_max; 722 723 /** Shaper shared packet mode supported. When non-zero, 724 * this parameter indicates that there is at least one 725 * leaf node on this level that can be part of 726 * shared shapers which work in packet mode. 727 */ 728 int shaper_shared_packet_mode_supported; 729 730 /** Shaper shared byte mode supported. When non-zero, 731 * this parameter indicates that there is at least one 732 * leaf node on this level that can be part of 733 * shared shapers which work in byte mode. 734 */ 735 int shaper_shared_byte_mode_supported; 736 737 /** WRED packet mode support. When non-zero, this 738 * parameter indicates that there is at least one leaf 739 * node on this level that supports the WRED packet 740 * mode, which might not be true for all the leaf 741 * nodes. In packet mode, the WRED thresholds specify 742 * the queue length in packets, as opposed to bytes. 743 */ 744 int cman_wred_packet_mode_supported; 745 746 /** WRED byte mode support. When non-zero, this 747 * parameter indicates that there is at least one leaf 748 * node on this level that supports the WRED byte mode, 749 * which might not be true for all the leaf nodes. In 750 * byte mode, the WRED thresholds specify the queue 751 * length in bytes, as opposed to packets. 752 */ 753 int cman_wred_byte_mode_supported; 754 755 /** Head drop algorithm support. When non-zero, this 756 * parameter indicates that there is at least one leaf 757 * node on this level that supports the head drop 758 * algorithm, which might not be true for all the leaf 759 * nodes on this level. 760 */ 761 int cman_head_drop_supported; 762 763 /** Private WRED context support. When non-zero, it 764 * indicates there is at least one node on this level 765 * with private WRED context support, which may not be 766 * true for all the leaf nodes on this level. 767 */ 768 int cman_wred_context_private_supported; 769 770 /** Maximum number of shared WRED contexts that any 771 * leaf node on this level can be part of. The value of 772 * zero indicates that shared WRED contexts are not 773 * supported by the leaf nodes on this level. When 774 * non-zero, it indicates there is at least one leaf 775 * node on this level that meets this condition, which 776 * may not be the case for all the leaf nodes on this 777 * level. 778 */ 779 uint32_t cman_wred_context_shared_n_max; 780 781 /** Mask of statistics counter types supported by the 782 * leaf nodes on this level. Every supported statistics 783 * counter type is supported by at least one leaf node 784 * on this level, which may not be true for all the leaf 785 * nodes on this level. 786 * @see enum rte_tm_stats_type 787 */ 788 uint64_t stats_mask; 789 } leaf; 790 }; 791 }; 792 793 /** 794 * Traffic manager node capabilities 795 */ 796 struct rte_tm_node_capabilities { 797 /** Private shaper support for the current node. */ 798 int shaper_private_supported; 799 800 /** Dual rate shaping support for private shaper of current node. 801 * Valid only when private shaper is supported by the current node. 802 */ 803 int shaper_private_dual_rate_supported; 804 805 /** Minimum committed/peak rate (bytes per second) for private 806 * shaper of current node. Valid only when private shaper is supported 807 * by the current node. 808 */ 809 uint64_t shaper_private_rate_min; 810 811 /** Maximum committed/peak rate (bytes per second) for private 812 * shaper of current node. Valid only when private shaper is supported 813 * by the current node. 814 */ 815 uint64_t shaper_private_rate_max; 816 817 /** Shaper private packet mode supported. When non-zero, this parameter 818 * indicates private shaper of current node can be configured with 819 * packet mode. When configured in packet mode, committed/peak rate 820 * provided is interpreted in packets per second. 821 */ 822 int shaper_private_packet_mode_supported; 823 824 /** Shaper private byte mode supported. When non-zero, this parameter 825 * indicates private shaper of current node can be configured with 826 * byte mode. When configured in byte mode, committed/peak rate 827 * provided is interpreted in bytes per second. 828 */ 829 int shaper_private_byte_mode_supported; 830 831 /** Maximum number of shared shapers the current node can be part of. 832 * The value of zero indicates that shared shapers are not supported by 833 * the current node. 834 */ 835 uint32_t shaper_shared_n_max; 836 837 /** Shaper shared packet mode supported. When non-zero, 838 * this parameter indicates that current node can be part of 839 * shared shapers which work in packet mode. 840 */ 841 int shaper_shared_packet_mode_supported; 842 843 /** Shaper shared byte mode supported. When non-zero, 844 * this parameter indicates that current node can be part of 845 * shared shapers which work in byte mode. 846 */ 847 int shaper_shared_byte_mode_supported; 848 849 union { 850 /** Items valid only for non-leaf nodes. */ 851 struct { 852 /** Maximum number of children nodes. */ 853 uint32_t sched_n_children_max; 854 855 /** Maximum number of supported priority levels. The 856 * value of zero is invalid. The value of 1 indicates 857 * that only priority 0 is supported, which essentially 858 * means that Strict Priority (SP) algorithm is not 859 * supported. 860 */ 861 uint32_t sched_sp_n_priorities_max; 862 863 /** Maximum number of sibling nodes that can have the 864 * same priority at any given time, i.e. maximum size 865 * of the WFQ sibling node group. The value of zero 866 * is invalid. The value of 1 indicates that WFQ 867 * algorithm is not supported. The maximum value is 868 * *sched_n_children_max*. 869 */ 870 uint32_t sched_wfq_n_children_per_group_max; 871 872 /** Maximum number of priority levels that can have 873 * more than one child node at any given time, i.e. 874 * maximum number of WFQ sibling node groups that have 875 * two or more members. The value of zero states that 876 * WFQ algorithm is not supported. The value of 1 877 * indicates that (*sched_sp_n_priorities_max* - 1) 878 * priority levels have at most one child node, so there 879 * can be only one priority level with two or more 880 * sibling nodes making up a WFQ group. The maximum 881 * value is: min(floor(*sched_n_children_max* / 2), 882 * *sched_sp_n_priorities_max*). 883 */ 884 uint32_t sched_wfq_n_groups_max; 885 886 /** Maximum WFQ weight. The value of 1 indicates that 887 * all sibling nodes with same priority have the same 888 * WFQ weight, so WFQ is reduced to FQ. 889 */ 890 uint32_t sched_wfq_weight_max; 891 892 /** WFQ packet mode supported. When non-zero, this 893 * parameter indicates that current node supports packet 894 * mode for WFQ among its children. WFQ weights will be 895 * applied against packet count for scheduling children 896 * when configured appropriately. 897 */ 898 int sched_wfq_packet_mode_supported; 899 900 /** WFQ byte mode supported. When non-zero, this 901 * parameter indicates that current node supports byte 902 * mode for WFQ among its children. WFQ weights will be 903 * applied against bytes for scheduling children when 904 * configured appropriately. 905 */ 906 int sched_wfq_byte_mode_supported; 907 908 } nonleaf; 909 910 /** Items valid only for leaf nodes. */ 911 struct { 912 /** WRED packet mode support for current node. */ 913 int cman_wred_packet_mode_supported; 914 915 /** WRED byte mode support for current node. */ 916 int cman_wred_byte_mode_supported; 917 918 /** Head drop algorithm support for current node. */ 919 int cman_head_drop_supported; 920 921 /** Private WRED context support for current node. */ 922 int cman_wred_context_private_supported; 923 924 /** Maximum number of shared WRED contexts the current 925 * node can be part of. The value of zero indicates that 926 * shared WRED contexts are not supported by the current 927 * node. 928 */ 929 uint32_t cman_wred_context_shared_n_max; 930 } leaf; 931 }; 932 933 /** Mask of statistics counter types supported by the current node. 934 * @see enum rte_tm_stats_type 935 */ 936 uint64_t stats_mask; 937 }; 938 939 /** 940 * Congestion management (CMAN) mode 941 * 942 * This is used for controlling the admission of packets into a packet queue or 943 * group of packet queues on congestion. On request of writing a new packet 944 * into the current queue while the queue is full, the *tail drop* algorithm 945 * drops the new packet while leaving the queue unmodified, as opposed to *head 946 * drop* algorithm, which drops the packet at the head of the queue (the oldest 947 * packet waiting in the queue) and admits the new packet at the tail of the 948 * queue. 949 * 950 * The *Random Early Detection (RED)* algorithm works by proactively dropping 951 * more and more input packets as the queue occupancy builds up. When the queue 952 * is full or almost full, RED effectively works as *tail drop*. The *Weighted 953 * RED* algorithm uses a separate set of RED thresholds for each packet color. 954 */ 955 enum rte_tm_cman_mode { 956 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */ 957 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */ 958 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */ 959 }; 960 961 /** 962 * Random Early Detection (RED) profile 963 */ 964 struct rte_tm_red_params { 965 /** Minimum queue threshold */ 966 uint64_t min_th; 967 968 /** Maximum queue threshold */ 969 uint64_t max_th; 970 971 /** Inverse of packet marking probability maximum value (maxp), i.e. 972 * maxp_inv = 1 / maxp 973 */ 974 uint16_t maxp_inv; 975 976 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */ 977 uint16_t wq_log2; 978 }; 979 980 /** 981 * Weighted RED (WRED) profile 982 * 983 * Multiple WRED contexts can share the same WRED profile. Each leaf node with 984 * WRED enabled as its congestion management mode has zero or one private WRED 985 * context (only one leaf node using it) and/or zero, one or several shared 986 * WRED contexts (multiple leaf nodes use the same WRED context). A private 987 * WRED context is used to perform congestion management for a single leaf 988 * node, while a shared WRED context is used to perform congestion management 989 * for a group of leaf nodes. 990 * 991 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported 992 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported 993 */ 994 struct rte_tm_wred_params { 995 /** One set of RED parameters per packet color */ 996 struct rte_tm_red_params red_params[RTE_COLORS]; 997 998 /** When non-zero, the *min_th* and *max_th* thresholds are specified 999 * in packets (WRED packet mode). When zero, the *min_th* and *max_th* 1000 * thresholds are specified in bytes (WRED byte mode) 1001 */ 1002 int packet_mode; 1003 }; 1004 1005 /** 1006 * Token bucket 1007 */ 1008 struct rte_tm_token_bucket { 1009 /** Token bucket rate (bytes per second or packets per second) */ 1010 uint64_t rate; 1011 1012 /** Token bucket size (bytes or packets), a.k.a. max burst size */ 1013 uint64_t size; 1014 }; 1015 1016 /** 1017 * Shaper (rate limiter) profile 1018 * 1019 * Multiple shaper instances can share the same shaper profile. Each node has 1020 * zero or one private shaper (only one node using it) and/or zero, one or 1021 * several shared shapers (multiple nodes use the same shaper instance). 1022 * A private shaper is used to perform traffic shaping for a single node, while 1023 * a shared shaper is used to perform traffic shaping for a group of nodes. 1024 * 1025 * Single rate shapers use a single token bucket. A single rate shaper can be 1026 * configured by setting the rate of the committed bucket to zero, which 1027 * effectively disables this bucket. The peak bucket is used to limit the rate 1028 * and the burst size for the current shaper. 1029 * 1030 * Dual rate shapers use both the committed and the peak token buckets. The 1031 * rate of the peak bucket has to be bigger than zero, as well as greater than 1032 * or equal to the rate of the committed bucket. 1033 * 1034 * @see struct rte_tm_capabilities::shaper_private_packet_mode_supported 1035 * @see struct rte_tm_capabilities::shaper_private_byte_mode_supported 1036 * @see struct rte_tm_capabilities::shaper_shared_packet_mode_supported 1037 * @see struct rte_tm_capabilities::shaper_shared_byte_mode_supported 1038 */ 1039 struct rte_tm_shaper_params { 1040 /** Committed token bucket */ 1041 struct rte_tm_token_bucket committed; 1042 1043 /** Peak token bucket */ 1044 struct rte_tm_token_bucket peak; 1045 1046 /** Signed value to be added to the length of each packet for the 1047 * purpose of shaping. Can be used to correct the packet length with 1048 * the framing overhead bytes that are also consumed on the wire (e.g. 1049 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS). 1050 * This field is ignored when the profile enables packet mode. 1051 */ 1052 int32_t pkt_length_adjust; 1053 1054 /** When zero, the byte mode is enabled for the current profile, so the 1055 * *rate* and *size* fields in both the committed and peak token buckets 1056 * are specified in bytes per second and bytes, respectively. 1057 * When non-zero, the packet mode is enabled for the current profile, 1058 * so the *rate* and *size* fields in both the committed and peak token 1059 * buckets are specified in packets per second and packets, 1060 * respectively. 1061 */ 1062 int packet_mode; 1063 }; 1064 1065 /** 1066 * Node parameters 1067 * 1068 * Each non-leaf node has multiple inputs (its children nodes) and single output 1069 * (which is input to its parent node). It arbitrates its inputs using Strict 1070 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input 1071 * packets to its output while observing its shaping (rate limiting) 1072 * constraints. 1073 * 1074 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR 1075 * (DWRR), etc. are considered approximations of the WFQ ideal and are 1076 * assimilated to WFQ, although an associated implementation-dependent trade-off 1077 * on accuracy, performance and resource usage might exist. 1078 * 1079 * Children nodes with different priorities are scheduled using the SP algorithm 1080 * based on their priority, with zero (0) as the highest priority. Children with 1081 * the same priority are scheduled using the WFQ algorithm according to their 1082 * weights. The WFQ weight of a given child node is relative to the sum of the 1083 * weights of all its sibling nodes that have the same priority, with one (1) as 1084 * the lowest weight. For each SP priority, the WFQ weight mode can be set as 1085 * either byte-based or packet-based. 1086 * 1087 * Each leaf node sits on top of a Tx queue of the current Ethernet port. Hence, 1088 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N 1089 * is the number of Tx queues configured for the current Ethernet port. The 1090 * non-leaf nodes have their IDs generated by the application. 1091 */ 1092 struct rte_tm_node_params { 1093 /** Shaper profile for the private shaper. The absence of the private 1094 * shaper for the current node is indicated by setting this parameter 1095 * to RTE_TM_SHAPER_PROFILE_ID_NONE. 1096 */ 1097 uint32_t shaper_profile_id; 1098 1099 /** User allocated array of valid shared shaper IDs. */ 1100 uint32_t *shared_shaper_id; 1101 1102 /** Number of shared shaper IDs in the *shared_shaper_id* array. */ 1103 uint32_t n_shared_shapers; 1104 1105 union { 1106 /** Parameters only valid for non-leaf nodes. */ 1107 struct { 1108 /** WFQ weight mode for each SP priority. When NULL, it 1109 * indicates that WFQ is to be used for all priorities. 1110 * When non-NULL, it points to a pre-allocated array of 1111 * *n_sp_priorities* values, with non-zero value for 1112 * byte-mode and zero for packet-mode. 1113 * @see struct rte_tm_node_capabilities::sched_wfq_packet_mode_supported 1114 * @see struct rte_tm_node_capabilities::sched_wfq_byte_mode_supported 1115 */ 1116 int *wfq_weight_mode; 1117 1118 /** Number of SP priorities. */ 1119 uint32_t n_sp_priorities; 1120 } nonleaf; 1121 1122 /** Parameters only valid for leaf nodes. */ 1123 struct { 1124 /** Congestion management mode */ 1125 enum rte_tm_cman_mode cman; 1126 1127 /** WRED parameters (only valid when *cman* is set to 1128 * WRED). 1129 */ 1130 struct { 1131 /** WRED profile for private WRED context. The 1132 * absence of a private WRED context for the 1133 * current leaf node is indicated by value 1134 * RTE_TM_WRED_PROFILE_ID_NONE. 1135 */ 1136 uint32_t wred_profile_id; 1137 1138 /** User allocated array of shared WRED context 1139 * IDs. When set to NULL, it indicates that the 1140 * current leaf node should not currently be 1141 * part of any shared WRED contexts. 1142 */ 1143 uint32_t *shared_wred_context_id; 1144 1145 /** Number of elements in the 1146 * *shared_wred_context_id* array. Only valid 1147 * when *shared_wred_context_id* is non-NULL, 1148 * in which case it should be non-zero. 1149 */ 1150 uint32_t n_shared_wred_contexts; 1151 } wred; 1152 } leaf; 1153 }; 1154 1155 /** Mask of statistics counter types to be enabled for this node. This 1156 * needs to be a subset of the statistics counter types available for 1157 * the current node. Any statistics counter type not included in this 1158 * set is to be disabled for the current node. 1159 * @see enum rte_tm_stats_type 1160 */ 1161 uint64_t stats_mask; 1162 }; 1163 1164 /** 1165 * Verbose error types. 1166 * 1167 * Most of them provide the type of the object referenced by struct 1168 * rte_tm_error::cause. 1169 */ 1170 enum rte_tm_error_type { 1171 RTE_TM_ERROR_TYPE_NONE, /**< No error. */ 1172 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 1173 RTE_TM_ERROR_TYPE_CAPABILITIES, 1174 RTE_TM_ERROR_TYPE_LEVEL_ID, 1175 RTE_TM_ERROR_TYPE_WRED_PROFILE, 1176 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN, 1177 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW, 1178 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED, 1179 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID, 1180 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID, 1181 RTE_TM_ERROR_TYPE_SHAPER_PROFILE, 1182 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE, 1183 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE, 1184 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE, 1185 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE, 1186 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN, 1187 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE, 1188 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, 1189 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID, 1190 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID, 1191 RTE_TM_ERROR_TYPE_NODE_PRIORITY, 1192 RTE_TM_ERROR_TYPE_NODE_WEIGHT, 1193 RTE_TM_ERROR_TYPE_NODE_PARAMS, 1194 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID, 1195 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID, 1196 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS, 1197 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE, 1198 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES, 1199 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN, 1200 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID, 1201 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID, 1202 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS, 1203 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS, 1204 RTE_TM_ERROR_TYPE_NODE_ID, 1205 }; 1206 1207 /** 1208 * Verbose error structure definition. 1209 * 1210 * This object is normally allocated by applications and set by PMDs, the 1211 * message points to a constant string which does not need to be freed by 1212 * the application, however its pointer can be considered valid only as long 1213 * as its associated DPDK port remains configured. Closing the underlying 1214 * device or unloading the PMD invalidates it. 1215 * 1216 * Both cause and message may be NULL regardless of the error type. 1217 */ 1218 struct rte_tm_error { 1219 enum rte_tm_error_type type; /**< Cause field and error type. */ 1220 const void *cause; /**< Object responsible for the error. */ 1221 const char *message; /**< Human-readable error message. */ 1222 }; 1223 1224 /** 1225 * Traffic manager get number of leaf nodes 1226 * 1227 * Each leaf node sits on top of a Tx queue of the current Ethernet port. 1228 * Therefore, the set of leaf nodes is predefined, their number is always equal 1229 * to N (where N is the number of Tx queues configured for the current port) 1230 * and their IDs are 0 .. (N-1). 1231 * 1232 * @param[in] port_id 1233 * The port identifier of the Ethernet device. 1234 * @param[out] n_leaf_nodes 1235 * Number of leaf nodes for the current port. 1236 * @param[out] error 1237 * Error details. Filled in only on error, when not NULL. 1238 * @return 1239 * 0 on success, non-zero error code otherwise. 1240 */ 1241 int 1242 rte_tm_get_number_of_leaf_nodes(uint16_t port_id, 1243 uint32_t *n_leaf_nodes, 1244 struct rte_tm_error *error); 1245 1246 /** 1247 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get 1248 * 1249 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is 1250 * the number of Tx queues of the current Ethernet port. The non-leaf nodes 1251 * have their IDs generated by the application outside of the above range, 1252 * which is reserved for leaf nodes. 1253 * 1254 * @param[in] port_id 1255 * The port identifier of the Ethernet device. 1256 * @param[in] node_id 1257 * Node ID value. Needs to be valid. 1258 * @param[out] is_leaf 1259 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf). 1260 * @param[out] error 1261 * Error details. Filled in only on error, when not NULL. 1262 * @return 1263 * 0 on success, non-zero error code otherwise. 1264 */ 1265 int 1266 rte_tm_node_type_get(uint16_t port_id, 1267 uint32_t node_id, 1268 int *is_leaf, 1269 struct rte_tm_error *error); 1270 1271 /** 1272 * Traffic manager capabilities get 1273 * 1274 * @param[in] port_id 1275 * The port identifier of the Ethernet device. 1276 * @param[out] cap 1277 * Traffic manager capabilities. Needs to be pre-allocated and valid. 1278 * @param[out] error 1279 * Error details. Filled in only on error, when not NULL. 1280 * @return 1281 * 0 on success, non-zero error code otherwise. 1282 */ 1283 int 1284 rte_tm_capabilities_get(uint16_t port_id, 1285 struct rte_tm_capabilities *cap, 1286 struct rte_tm_error *error); 1287 1288 /** 1289 * Traffic manager level capabilities get 1290 * 1291 * @param[in] port_id 1292 * The port identifier of the Ethernet device. 1293 * @param[in] level_id 1294 * The hierarchy level identifier. The value of 0 identifies the level of the 1295 * root node. 1296 * @param[out] cap 1297 * Traffic manager level capabilities. Needs to be pre-allocated and valid. 1298 * @param[out] error 1299 * Error details. Filled in only on error, when not NULL. 1300 * @return 1301 * 0 on success, non-zero error code otherwise. 1302 */ 1303 int 1304 rte_tm_level_capabilities_get(uint16_t port_id, 1305 uint32_t level_id, 1306 struct rte_tm_level_capabilities *cap, 1307 struct rte_tm_error *error); 1308 1309 /** 1310 * Traffic manager node capabilities get 1311 * 1312 * @param[in] port_id 1313 * The port identifier of the Ethernet device. 1314 * @param[in] node_id 1315 * Node ID. Needs to be valid. 1316 * @param[out] cap 1317 * Traffic manager node capabilities. Needs to be pre-allocated and valid. 1318 * @param[out] error 1319 * Error details. Filled in only on error, when not NULL. 1320 * @return 1321 * 0 on success, non-zero error code otherwise. 1322 */ 1323 int 1324 rte_tm_node_capabilities_get(uint16_t port_id, 1325 uint32_t node_id, 1326 struct rte_tm_node_capabilities *cap, 1327 struct rte_tm_error *error); 1328 1329 /** 1330 * Traffic manager WRED profile add 1331 * 1332 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile 1333 * is used to create one or several WRED contexts. 1334 * 1335 * @param[in] port_id 1336 * The port identifier of the Ethernet device. 1337 * @param[in] wred_profile_id 1338 * WRED profile ID for the new profile. Needs to be unused. 1339 * @param[in] profile 1340 * WRED profile parameters. Needs to be pre-allocated and valid. 1341 * @param[out] error 1342 * Error details. Filled in only on error, when not NULL. 1343 * @return 1344 * 0 on success, non-zero error code otherwise. 1345 * 1346 * @see struct rte_tm_capabilities::cman_wred_context_n_max 1347 */ 1348 int 1349 rte_tm_wred_profile_add(uint16_t port_id, 1350 uint32_t wred_profile_id, 1351 const struct rte_tm_wred_params *profile, 1352 struct rte_tm_error *error); 1353 1354 /** 1355 * Traffic manager WRED profile delete 1356 * 1357 * Delete an existing WRED profile. This operation fails when there is 1358 * currently at least one user (i.e. WRED context) of this WRED profile. 1359 * 1360 * @param[in] port_id 1361 * The port identifier of the Ethernet device. 1362 * @param[in] wred_profile_id 1363 * WRED profile ID. Needs to be the valid. 1364 * @param[out] error 1365 * Error details. Filled in only on error, when not NULL. 1366 * @return 1367 * 0 on success, non-zero error code otherwise. 1368 * 1369 * @see struct rte_tm_capabilities::cman_wred_context_n_max 1370 */ 1371 int 1372 rte_tm_wred_profile_delete(uint16_t port_id, 1373 uint32_t wred_profile_id, 1374 struct rte_tm_error *error); 1375 1376 /** 1377 * Traffic manager shared WRED context add or update 1378 * 1379 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is 1380 * created by using the WRED profile identified by *wred_profile_id*. 1381 * 1382 * When *shared_wred_context_id* is valid, this WRED context is no longer using 1383 * the profile previously assigned to it and is updated to use the profile 1384 * identified by *wred_profile_id*. 1385 * 1386 * A valid shared WRED context can be assigned to several hierarchy leaf nodes 1387 * configured to use WRED as the congestion management mode. 1388 * 1389 * @param[in] port_id 1390 * The port identifier of the Ethernet device. 1391 * @param[in] shared_wred_context_id 1392 * Shared WRED context ID 1393 * @param[in] wred_profile_id 1394 * WRED profile ID. Needs to be the valid. 1395 * @param[out] error 1396 * Error details. Filled in only on error, when not NULL. 1397 * @return 1398 * 0 on success, non-zero error code otherwise. 1399 * 1400 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max 1401 */ 1402 int 1403 rte_tm_shared_wred_context_add_update(uint16_t port_id, 1404 uint32_t shared_wred_context_id, 1405 uint32_t wred_profile_id, 1406 struct rte_tm_error *error); 1407 1408 /** 1409 * Traffic manager shared WRED context delete 1410 * 1411 * Delete an existing shared WRED context. This operation fails when there is 1412 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED 1413 * context. 1414 * 1415 * @param[in] port_id 1416 * The port identifier of the Ethernet device. 1417 * @param[in] shared_wred_context_id 1418 * Shared WRED context ID. Needs to be the valid. 1419 * @param[out] error 1420 * Error details. Filled in only on error, when not NULL. 1421 * @return 1422 * 0 on success, non-zero error code otherwise. 1423 * 1424 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max 1425 */ 1426 int 1427 rte_tm_shared_wred_context_delete(uint16_t port_id, 1428 uint32_t shared_wred_context_id, 1429 struct rte_tm_error *error); 1430 1431 /** 1432 * Traffic manager shaper profile add 1433 * 1434 * Create a new shaper profile with ID set to *shaper_profile_id*. The new 1435 * shaper profile is used to create one or several shapers. 1436 * 1437 * @param[in] port_id 1438 * The port identifier of the Ethernet device. 1439 * @param[in] shaper_profile_id 1440 * Shaper profile ID for the new profile. Needs to be unused. 1441 * @param[in] profile 1442 * Shaper profile parameters. Needs to be pre-allocated and valid. 1443 * @param[out] error 1444 * Error details. Filled in only on error, when not NULL. 1445 * @return 1446 * 0 on success, non-zero error code otherwise. 1447 * 1448 * @see struct rte_tm_capabilities::shaper_n_max 1449 */ 1450 int 1451 rte_tm_shaper_profile_add(uint16_t port_id, 1452 uint32_t shaper_profile_id, 1453 const struct rte_tm_shaper_params *profile, 1454 struct rte_tm_error *error); 1455 1456 /** 1457 * Traffic manager shaper profile delete 1458 * 1459 * Delete an existing shaper profile. This operation fails when there is 1460 * currently at least one user (i.e. shaper) of this shaper profile. 1461 * 1462 * @param[in] port_id 1463 * The port identifier of the Ethernet device. 1464 * @param[in] shaper_profile_id 1465 * Shaper profile ID. Needs to be the valid. 1466 * @param[out] error 1467 * Error details. Filled in only on error, when not NULL. 1468 * @return 1469 * 0 on success, non-zero error code otherwise. 1470 * 1471 * @see struct rte_tm_capabilities::shaper_n_max 1472 */ 1473 int 1474 rte_tm_shaper_profile_delete(uint16_t port_id, 1475 uint32_t shaper_profile_id, 1476 struct rte_tm_error *error); 1477 1478 /** 1479 * Traffic manager shared shaper add or update 1480 * 1481 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper 1482 * with this ID is created using the shaper profile identified by 1483 * *shaper_profile_id*. 1484 * 1485 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is 1486 * no longer using the shaper profile previously assigned to it and is updated 1487 * to use the shaper profile identified by *shaper_profile_id*. 1488 * 1489 * @param[in] port_id 1490 * The port identifier of the Ethernet device. 1491 * @param[in] shared_shaper_id 1492 * Shared shaper ID 1493 * @param[in] shaper_profile_id 1494 * Shaper profile ID. Needs to be the valid. 1495 * @param[out] error 1496 * Error details. Filled in only on error, when not NULL. 1497 * @return 1498 * 0 on success, non-zero error code otherwise. 1499 * 1500 * @see struct rte_tm_capabilities::shaper_shared_n_max 1501 */ 1502 int 1503 rte_tm_shared_shaper_add_update(uint16_t port_id, 1504 uint32_t shared_shaper_id, 1505 uint32_t shaper_profile_id, 1506 struct rte_tm_error *error); 1507 1508 /** 1509 * Traffic manager shared shaper delete 1510 * 1511 * Delete an existing shared shaper. This operation fails when there is 1512 * currently at least one user (i.e. hierarchy node) of this shared shaper. 1513 * 1514 * @param[in] port_id 1515 * The port identifier of the Ethernet device. 1516 * @param[in] shared_shaper_id 1517 * Shared shaper ID. Needs to be the valid. 1518 * @param[out] error 1519 * Error details. Filled in only on error, when not NULL. 1520 * @return 1521 * 0 on success, non-zero error code otherwise. 1522 * 1523 * @see struct rte_tm_capabilities::shaper_shared_n_max 1524 */ 1525 int 1526 rte_tm_shared_shaper_delete(uint16_t port_id, 1527 uint32_t shared_shaper_id, 1528 struct rte_tm_error *error); 1529 1530 /** 1531 * Traffic manager node add 1532 * 1533 * Create new node and connect it as child of an existing node. The new node is 1534 * further identified by *node_id*, which needs to be unused by any of the 1535 * existing nodes. The parent node is identified by *parent_node_id*, which 1536 * needs to be the valid ID of an existing non-leaf node. The parent node is 1537 * going to use the provided SP *priority* and WFQ *weight* to schedule its new 1538 * child node. 1539 * 1540 * This function has to be called for both leaf and non-leaf nodes. In the case 1541 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as 1542 * the number of configured Tx queues of the current port), the leaf node is 1543 * configured rather than created (as the set of leaf nodes is predefined) and 1544 * it is also connected as child of an existing node. 1545 * 1546 * The first node that is added becomes the root node and all the nodes that 1547 * are subsequently added have to be added as descendants of the root node. The 1548 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there 1549 * can only be one node with this parent ID (i.e. the root node). Further 1550 * restrictions for root node: needs to be non-leaf, its private shaper profile 1551 * needs to be valid and single rate, cannot use any shared shapers. 1552 * 1553 * When called before rte_tm_hierarchy_commit() invocation, this function is 1554 * typically used to define the initial start-up hierarchy for the port. 1555 * Provided that dynamic hierarchy updates are supported by the current port (as 1556 * advertised in the port capability set), this function can be also called 1557 * after the rte_tm_hierarchy_commit() invocation. 1558 * 1559 * @param[in] port_id 1560 * The port identifier of the Ethernet device. 1561 * @param[in] node_id 1562 * Node ID. Needs to be unused by any of the existing nodes. 1563 * @param[in] parent_node_id 1564 * Parent node ID. Needs to be the valid. 1565 * @param[in] priority 1566 * Node priority. The highest node priority is zero. Used by the SP algorithm 1567 * running on the parent of the current node for scheduling this child node. 1568 * @param[in] weight 1569 * Node weight. The node weight is relative to the weight sum of all siblings 1570 * that have the same priority. The lowest weight is one. Used by the WFQ 1571 * algorithm running on the parent of the current node for scheduling this 1572 * child node. 1573 * @param[in] level_id 1574 * Level ID that should be met by this node. The hierarchy level of the 1575 * current node is already fully specified through its parent node (i.e. the 1576 * level of this node is equal to the level of its parent node plus one), 1577 * therefore the reason for providing this parameter is to enable the 1578 * application to perform step-by-step checking of the node level during 1579 * successive invocations of this function. When not desired, this check can 1580 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter. 1581 * @param[in] params 1582 * Node parameters. Needs to be pre-allocated and valid. 1583 * @param[out] error 1584 * Error details. Filled in only on error, when not NULL. 1585 * @return 1586 * 0 on success, non-zero error code otherwise. 1587 * 1588 * @see rte_tm_hierarchy_commit() 1589 * @see RTE_TM_UPDATE_NODE_ADD_DELETE 1590 * @see RTE_TM_NODE_LEVEL_ID_ANY 1591 * @see struct rte_tm_capabilities 1592 */ 1593 int 1594 rte_tm_node_add(uint16_t port_id, 1595 uint32_t node_id, 1596 uint32_t parent_node_id, 1597 uint32_t priority, 1598 uint32_t weight, 1599 uint32_t level_id, 1600 const struct rte_tm_node_params *params, 1601 struct rte_tm_error *error); 1602 1603 /** 1604 * Return information about a traffic management node 1605 * 1606 * Return information about a hierarchy node, using the same format of parameters 1607 * as was passed to the rte_rm_node_add() function. 1608 * Each of the "out" parameters pointers (except error) may be passed as NULL if the 1609 * information is not needed by the caller. For example, to one may check if a node id 1610 * is in use by: 1611 * 1612 * struct rte_tm_error error; 1613 * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error); 1614 * if (ret == ENOENT) ... 1615 * 1616 * @param[in] port_id 1617 * The port identifier of the Ethernet device. 1618 * @param[in] node_id 1619 * Node ID. Should be a valid node id. 1620 * @param[out] parent_node_id 1621 * Parent node ID. 1622 * @param[out] priority 1623 * Node priority. The highest node priority is zero. Used by the SP algorithm 1624 * running on the parent of the current node for scheduling this child node. 1625 * @param[out] weight 1626 * Node weight. The node weight is relative to the weight sum of all siblings 1627 * that have the same priority. The lowest weight is one. Used by the WFQ 1628 * algorithm running on the parent of the current node for scheduling this 1629 * child node. 1630 * @param[out] level_id 1631 * The node level in the scheduler hierarchy. 1632 * @param[out] params 1633 * Node parameters, as would be used when creating the node. 1634 * @param[out] error 1635 * Error details. Filled in only on error. Must not be NULL. 1636 * @return 1637 * 0 on success, non-zero error code otherwise. 1638 * -EINVAL - port or node id value is invalid 1639 * -ENOENT - no node exists with the provided id on the provided port 1640 */ 1641 __rte_experimental 1642 int 1643 rte_tm_node_query(uint16_t port_id, 1644 uint32_t node_id, 1645 uint32_t *parent_node_id, 1646 uint32_t *priority, 1647 uint32_t *weight, 1648 uint32_t *level_id, 1649 struct rte_tm_node_params *params, 1650 struct rte_tm_error *error); 1651 1652 /** 1653 * Traffic manager node delete 1654 * 1655 * Delete an existing node. This operation fails when this node currently has 1656 * at least one user (i.e. child node). 1657 * 1658 * When called before rte_tm_hierarchy_commit() invocation, this function is 1659 * typically used to define the initial start-up hierarchy for the port. 1660 * Provided that dynamic hierarchy updates are supported by the current port (as 1661 * advertised in the port capability set), this function can be also called 1662 * after the rte_tm_hierarchy_commit() invocation. 1663 * 1664 * @param[in] port_id 1665 * The port identifier of the Ethernet device. 1666 * @param[in] node_id 1667 * Node ID. Needs to be valid. 1668 * @param[out] error 1669 * Error details. Filled in only on error, when not NULL. 1670 * @return 1671 * 0 on success, non-zero error code otherwise. 1672 * 1673 * @see RTE_TM_UPDATE_NODE_ADD_DELETE 1674 */ 1675 int 1676 rte_tm_node_delete(uint16_t port_id, 1677 uint32_t node_id, 1678 struct rte_tm_error *error); 1679 1680 /** 1681 * Traffic manager node suspend 1682 * 1683 * Suspend an existing node. While the node is in suspended state, no packet is 1684 * scheduled from this node and its descendants. The node exits the suspended 1685 * state through the node resume operation. 1686 * 1687 * @param[in] port_id 1688 * The port identifier of the Ethernet device. 1689 * @param[in] node_id 1690 * Node ID. Needs to be valid. 1691 * @param[out] error 1692 * Error details. Filled in only on error, when not NULL. 1693 * @return 1694 * 0 on success, non-zero error code otherwise. 1695 * 1696 * @see rte_tm_node_resume() 1697 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME 1698 */ 1699 int 1700 rte_tm_node_suspend(uint16_t port_id, 1701 uint32_t node_id, 1702 struct rte_tm_error *error); 1703 1704 /** 1705 * Traffic manager node resume 1706 * 1707 * Resume an existing node that is currently in suspended state. The node 1708 * entered the suspended state as result of a previous node suspend operation. 1709 * 1710 * @param[in] port_id 1711 * The port identifier of the Ethernet device. 1712 * @param[in] node_id 1713 * Node ID. Needs to be valid. 1714 * @param[out] error 1715 * Error details. Filled in only on error, when not NULL. 1716 * @return 1717 * 0 on success, non-zero error code otherwise. 1718 * 1719 * @see rte_tm_node_suspend() 1720 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME 1721 */ 1722 int 1723 rte_tm_node_resume(uint16_t port_id, 1724 uint32_t node_id, 1725 struct rte_tm_error *error); 1726 1727 /** 1728 * Traffic manager hierarchy commit 1729 * 1730 * This function is called during the port initialization phase (before the 1731 * Ethernet port is started) to freeze the start-up hierarchy. 1732 * 1733 * This function typically performs the following steps: 1734 * a) It validates the start-up hierarchy that was previously defined for the 1735 * current port through successive rte_tm_node_add() invocations; 1736 * b) Assuming successful validation, it performs all the necessary port 1737 * specific configuration operations to install the specified hierarchy on 1738 * the current port, with immediate effect once the port is started. 1739 * 1740 * This function fails when the currently configured hierarchy is not supported 1741 * by the Ethernet port, in which case the user can abort or try out another 1742 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be 1743 * build from scratch (when *clear_on_fail* is enabled) or by modifying the 1744 * existing hierarchy configuration (when *clear_on_fail* is disabled). 1745 * 1746 * Note that this function can still fail due to other causes (e.g. not enough 1747 * memory available in the system, etc), even though the specified hierarchy is 1748 * supported in principle by the current port. 1749 * 1750 * @param[in] port_id 1751 * The port identifier of the Ethernet device. 1752 * @param[in] clear_on_fail 1753 * On function call failure, hierarchy is cleared when this parameter is 1754 * non-zero and preserved when this parameter is equal to zero. 1755 * @param[out] error 1756 * Error details. Filled in only on error, when not NULL. 1757 * @return 1758 * 0 on success, non-zero error code otherwise. 1759 * 1760 * @see rte_tm_node_add() 1761 * @see rte_tm_node_delete() 1762 */ 1763 int 1764 rte_tm_hierarchy_commit(uint16_t port_id, 1765 int clear_on_fail, 1766 struct rte_tm_error *error); 1767 1768 /** 1769 * Traffic manager node parent update 1770 * 1771 * This function may be used to move a node and its children to a different 1772 * parent. Additionally, if the new parent is the same as the current parent, 1773 * this function will update the priority/weight of an existing node. 1774 * 1775 * Restriction for root node: its parent cannot be changed. 1776 * 1777 * This function can only be called after the rte_tm_hierarchy_commit() 1778 * invocation. Its success depends on the port support for this operation, as 1779 * advertised through the port capability set. 1780 * 1781 * @param[in] port_id 1782 * The port identifier of the Ethernet device. 1783 * @param[in] node_id 1784 * Node ID. Needs to be valid. 1785 * @param[in] parent_node_id 1786 * Node ID for the new parent. Needs to be valid. 1787 * @param[in] priority 1788 * Node priority. The highest node priority is zero. Used by the SP algorithm 1789 * running on the parent of the current node for scheduling this child node. 1790 * @param[in] weight 1791 * Node weight. The node weight is relative to the weight sum of all siblings 1792 * that have the same priority. The lowest weight is zero. Used by the WFQ 1793 * algorithm running on the parent of the current node for scheduling this 1794 * child node. 1795 * @param[out] error 1796 * Error details. Filled in only on error, when not NULL. 1797 * @return 1798 * 0 on success, non-zero error code otherwise. 1799 * 1800 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL 1801 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL 1802 */ 1803 int 1804 rte_tm_node_parent_update(uint16_t port_id, 1805 uint32_t node_id, 1806 uint32_t parent_node_id, 1807 uint32_t priority, 1808 uint32_t weight, 1809 struct rte_tm_error *error); 1810 1811 /** 1812 * Traffic manager node private shaper update 1813 * 1814 * Restriction for the root node: its private shaper profile needs to be valid 1815 * and single rate. 1816 * 1817 * @param[in] port_id 1818 * The port identifier of the Ethernet device. 1819 * @param[in] node_id 1820 * Node ID. Needs to be valid. 1821 * @param[in] shaper_profile_id 1822 * Shaper profile ID for the private shaper of the current node. Needs to be 1823 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with 1824 * the latter disabling the private shaper of the current node. 1825 * @param[out] error 1826 * Error details. Filled in only on error, when not NULL. 1827 * @return 1828 * 0 on success, non-zero error code otherwise. 1829 * 1830 * @see struct rte_tm_capabilities::shaper_private_n_max 1831 */ 1832 int 1833 rte_tm_node_shaper_update(uint16_t port_id, 1834 uint32_t node_id, 1835 uint32_t shaper_profile_id, 1836 struct rte_tm_error *error); 1837 1838 /** 1839 * Traffic manager node shared shapers update 1840 * 1841 * Restriction for root node: cannot use any shared rate shapers. 1842 * 1843 * @param[in] port_id 1844 * The port identifier of the Ethernet device. 1845 * @param[in] node_id 1846 * Node ID. Needs to be valid. 1847 * @param[in] shared_shaper_id 1848 * Shared shaper ID. Needs to be valid. 1849 * @param[in] add 1850 * Set to non-zero value to add this shared shaper to current node or to zero 1851 * to delete this shared shaper from current node. 1852 * @param[out] error 1853 * Error details. Filled in only on error, when not NULL. 1854 * @return 1855 * 0 on success, non-zero error code otherwise. 1856 * 1857 * @see struct rte_tm_capabilities::shaper_shared_n_max 1858 */ 1859 int 1860 rte_tm_node_shared_shaper_update(uint16_t port_id, 1861 uint32_t node_id, 1862 uint32_t shared_shaper_id, 1863 int add, 1864 struct rte_tm_error *error); 1865 1866 /** 1867 * Traffic manager node enabled statistics counters update 1868 * 1869 * @param[in] port_id 1870 * The port identifier of the Ethernet device. 1871 * @param[in] node_id 1872 * Node ID. Needs to be valid. 1873 * @param[in] stats_mask 1874 * Mask of statistics counter types to be enabled for the current node. This 1875 * needs to be a subset of the statistics counter types available for the 1876 * current node. Any statistics counter type not included in this set is to 1877 * be disabled for the current node. 1878 * @param[out] error 1879 * Error details. Filled in only on error, when not NULL. 1880 * @return 1881 * 0 on success, non-zero error code otherwise. 1882 * 1883 * @see enum rte_tm_stats_type 1884 * @see RTE_TM_UPDATE_NODE_STATS 1885 */ 1886 int 1887 rte_tm_node_stats_update(uint16_t port_id, 1888 uint32_t node_id, 1889 uint64_t stats_mask, 1890 struct rte_tm_error *error); 1891 1892 /** 1893 * Traffic manager node WFQ weight mode update 1894 * 1895 * @param[in] port_id 1896 * The port identifier of the Ethernet device. 1897 * @param[in] node_id 1898 * Node ID. Needs to be valid non-leaf node ID. 1899 * @param[in] wfq_weight_mode 1900 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is 1901 * to be used for all priorities. When non-NULL, it points to a pre-allocated 1902 * array of *n_sp_priorities* values, with non-zero value for byte-mode and 1903 * zero for packet-mode. 1904 * @param[in] n_sp_priorities 1905 * Number of SP priorities. 1906 * @param[out] error 1907 * Error details. Filled in only on error, when not NULL. 1908 * @return 1909 * 0 on success, non-zero error code otherwise. 1910 * 1911 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE 1912 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES 1913 */ 1914 int 1915 rte_tm_node_wfq_weight_mode_update(uint16_t port_id, 1916 uint32_t node_id, 1917 int *wfq_weight_mode, 1918 uint32_t n_sp_priorities, 1919 struct rte_tm_error *error); 1920 1921 /** 1922 * Traffic manager node congestion management mode update 1923 * 1924 * @param[in] port_id 1925 * The port identifier of the Ethernet device. 1926 * @param[in] node_id 1927 * Node ID. Needs to be valid leaf node ID. 1928 * @param[in] cman 1929 * Congestion management mode. 1930 * @param[out] error 1931 * Error details. Filled in only on error, when not NULL. 1932 * @return 1933 * 0 on success, non-zero error code otherwise. 1934 * 1935 * @see RTE_TM_UPDATE_NODE_CMAN 1936 */ 1937 int 1938 rte_tm_node_cman_update(uint16_t port_id, 1939 uint32_t node_id, 1940 enum rte_tm_cman_mode cman, 1941 struct rte_tm_error *error); 1942 1943 /** 1944 * Traffic manager node private WRED context update 1945 * 1946 * @param[in] port_id 1947 * The port identifier of the Ethernet device. 1948 * @param[in] node_id 1949 * Node ID. Needs to be valid leaf node ID. 1950 * @param[in] wred_profile_id 1951 * WRED profile ID for the private WRED context of the current node. Needs to 1952 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the 1953 * latter disabling the private WRED context of the current node. 1954 * @param[out] error 1955 * Error details. Filled in only on error, when not NULL. 1956 * @return 1957 * 0 on success, non-zero error code otherwise. 1958 * 1959 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max 1960 */ 1961 int 1962 rte_tm_node_wred_context_update(uint16_t port_id, 1963 uint32_t node_id, 1964 uint32_t wred_profile_id, 1965 struct rte_tm_error *error); 1966 1967 /** 1968 * Traffic manager node shared WRED context update 1969 * 1970 * @param[in] port_id 1971 * The port identifier of the Ethernet device. 1972 * @param[in] node_id 1973 * Node ID. Needs to be valid leaf node ID. 1974 * @param[in] shared_wred_context_id 1975 * Shared WRED context ID. Needs to be valid. 1976 * @param[in] add 1977 * Set to non-zero value to add this shared WRED context to current node or 1978 * to zero to delete this shared WRED context from current node. 1979 * @param[out] error 1980 * Error details. Filled in only on error, when not NULL. 1981 * @return 1982 * 0 on success, non-zero error code otherwise. 1983 * 1984 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max 1985 */ 1986 int 1987 rte_tm_node_shared_wred_context_update(uint16_t port_id, 1988 uint32_t node_id, 1989 uint32_t shared_wred_context_id, 1990 int add, 1991 struct rte_tm_error *error); 1992 1993 /** 1994 * Traffic manager node statistics counters read 1995 * 1996 * @param[in] port_id 1997 * The port identifier of the Ethernet device. 1998 * @param[in] node_id 1999 * Node ID. Needs to be valid. 2000 * @param[out] stats 2001 * When non-NULL, it contains the current value for the statistics counters 2002 * enabled for the current node. 2003 * @param[out] stats_mask 2004 * When non-NULL, it contains the mask of statistics counter types that are 2005 * currently enabled for this node, indicating which of the counters 2006 * retrieved with the *stats* structure are valid. 2007 * @param[in] clear 2008 * When this parameter has a non-zero value, the statistics counters are 2009 * cleared (i.e. set to zero) immediately after they have been read, 2010 * otherwise the statistics counters are left untouched. 2011 * @param[out] error 2012 * Error details. Filled in only on error, when not NULL. 2013 * @return 2014 * 0 on success, non-zero error code otherwise. 2015 * 2016 * @see enum rte_tm_stats_type 2017 */ 2018 int 2019 rte_tm_node_stats_read(uint16_t port_id, 2020 uint32_t node_id, 2021 struct rte_tm_node_stats *stats, 2022 uint64_t *stats_mask, 2023 int clear, 2024 struct rte_tm_error *error); 2025 2026 /** 2027 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q) 2028 * 2029 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP) 2030 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop 2031 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical 2032 * Format Indicator (CFI). 2033 * 2034 * All VLAN frames of a given color get their DEI bit set if marking is enabled 2035 * for this color; otherwise, their DEI bit is left as is (either set or not). 2036 * 2037 * @param[in] port_id 2038 * The port identifier of the Ethernet device. 2039 * @param[in] mark_green 2040 * Set to non-zero value to enable marking of green packets and to zero to 2041 * disable it. 2042 * @param[in] mark_yellow 2043 * Set to non-zero value to enable marking of yellow packets and to zero to 2044 * disable it. 2045 * @param[in] mark_red 2046 * Set to non-zero value to enable marking of red packets and to zero to 2047 * disable it. 2048 * @param[out] error 2049 * Error details. Filled in only on error, when not NULL. 2050 * @return 2051 * 0 on success, non-zero error code otherwise. 2052 * 2053 * @see struct rte_tm_capabilities::mark_vlan_dei_supported 2054 */ 2055 int 2056 rte_tm_mark_vlan_dei(uint16_t port_id, 2057 int mark_green, 2058 int mark_yellow, 2059 int mark_red, 2060 struct rte_tm_error *error); 2061 2062 /** 2063 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168) 2064 * 2065 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field 2066 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated 2067 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion 2068 * Notification (ECN) field (2 bits). The DSCP field is typically used to 2069 * encode the traffic class and/or drop priority (RFC 2597), while the ECN 2070 * field is used by RFC 3168 to implement a congestion notification mechanism 2071 * to be leveraged by transport layer protocols such as TCP and SCTP that have 2072 * congestion control mechanisms. 2073 * 2074 * When congestion is experienced, as alternative to dropping the packet, 2075 * routers can change the ECN field of input packets from 2'b01 or 2'b10 2076 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning 2077 * that congestion is experienced). The destination endpoint can use the 2078 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the 2079 * source endpoint, which acknowledges it back to the destination endpoint with 2080 * the Congestion Window Reduced (CWR) TCP flag. 2081 * 2082 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10 2083 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is 2084 * enabled for the current color, otherwise the ECN field is left as is. 2085 * 2086 * @param[in] port_id 2087 * The port identifier of the Ethernet device. 2088 * @param[in] mark_green 2089 * Set to non-zero value to enable marking of green packets and to zero to 2090 * disable it. 2091 * @param[in] mark_yellow 2092 * Set to non-zero value to enable marking of yellow packets and to zero to 2093 * disable it. 2094 * @param[in] mark_red 2095 * Set to non-zero value to enable marking of red packets and to zero to 2096 * disable it. 2097 * @param[out] error 2098 * Error details. Filled in only on error, when not NULL. 2099 * @return 2100 * 0 on success, non-zero error code otherwise. 2101 * 2102 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported 2103 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported 2104 */ 2105 int 2106 rte_tm_mark_ip_ecn(uint16_t port_id, 2107 int mark_green, 2108 int mark_yellow, 2109 int mark_red, 2110 struct rte_tm_error *error); 2111 2112 /** 2113 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597) 2114 * 2115 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6 2116 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP 2117 * values proposed by this RFC: 2118 * 2119 * <pre> Class 1 Class 2 Class 3 Class 4 </pre> 2120 * <pre> +----------+----------+----------+----------+</pre> 2121 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre> 2122 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre> 2123 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre> 2124 * <pre> +----------+----------+----------+----------+</pre> 2125 * 2126 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2, 2127 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4. 2128 * 2129 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as 2130 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium 2131 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled 2132 * for each color; when not enabled for a given color, the DSCP field of all 2133 * packets with that color is left as is. 2134 * 2135 * @param[in] port_id 2136 * The port identifier of the Ethernet device. 2137 * @param[in] mark_green 2138 * Set to non-zero value to enable marking of green packets and to zero to 2139 * disable it. 2140 * @param[in] mark_yellow 2141 * Set to non-zero value to enable marking of yellow packets and to zero to 2142 * disable it. 2143 * @param[in] mark_red 2144 * Set to non-zero value to enable marking of red packets and to zero to 2145 * disable it. 2146 * @param[out] error 2147 * Error details. Filled in only on error, when not NULL. 2148 * @return 2149 * 0 on success, non-zero error code otherwise. 2150 * 2151 * @see struct rte_tm_capabilities::mark_ip_dscp_supported 2152 */ 2153 int 2154 rte_tm_mark_ip_dscp(uint16_t port_id, 2155 int mark_green, 2156 int mark_yellow, 2157 int mark_red, 2158 struct rte_tm_error *error); 2159 2160 #ifdef __cplusplus 2161 } 2162 #endif 2163 2164 #endif /* __INCLUDE_RTE_TM_H__ */ 2165