1 /** @file 2 * @brief Various priority to traffic class mappings 3 * 4 * This is not to be included by the application. 5 */ 6 7 /* 8 * Copyright (c) 2018 Intel Corporation. 9 * 10 * SPDX-License-Identifier: Apache-2.0 11 */ 12 13 #ifndef __TC_MAPPING_H 14 #define __TC_MAPPING_H 15 16 #include <zephyr/types.h> 17 18 /* All the maps below use priorities and indexes, below is the list of them 19 * according to 802.1Q - table I-2. 20 * 21 * Priority Acronym Traffic types 22 * 1 (lowest) BK Background 23 * 0 (default) BE Best effort 24 * 2 EE Excellent effort 25 * 3 CA Critical applications 26 * 4 VI Video, < 100 ms latency and jitter 27 * 5 VO Voice, < 10 ms latency and jitter 28 * 6 IC Internetwork control 29 * 7 (highest) NC Network control 30 */ 31 32 /* Helper macros used to generate the map to use */ 33 #define PRIORITY2TC_GEN_INNER(TYPE, COUNT) priority2tc_ ## TYPE ## _ ## COUNT 34 #define PRIORITY2TC_GEN(TYPE, COUNT) PRIORITY2TC_GEN_INNER(TYPE, COUNT) 35 36 #if defined(CONFIG_NET_TC_MAPPING_STRICT) && (NET_TC_COUNT > 0) 37 38 /* This is the recommended priority to traffic class mapping for 39 * implementations that do not support the credit-based shaper transmission 40 * selection algorithm. 41 * Ref: 802.1Q - chapter 8.6.6 - table 8-4 42 */ 43 44 #if NET_TC_TX_COUNT == 1 || NET_TC_RX_COUNT == 1 45 static const uint8_t priority2tc_strict_1[] = {0, 0, 0, 0, 0, 0, 0, 0}; 46 #endif 47 #if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2 48 static const uint8_t priority2tc_strict_2[] = {0, 0, 0, 0, 1, 1, 1, 1}; 49 #endif 50 #if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3 51 static const uint8_t priority2tc_strict_3[] = {0, 0, 0, 0, 1, 1, 2, 2}; 52 #endif 53 #if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4 54 static const uint8_t priority2tc_strict_4[] = {0, 0, 1, 1, 2, 2, 3, 3}; 55 #endif 56 #if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5 57 static const uint8_t priority2tc_strict_5[] = {0, 0, 1, 1, 2, 2, 3, 4}; 58 #endif 59 #if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6 60 static const uint8_t priority2tc_strict_6[] = {1, 0, 2, 2, 3, 3, 4, 5}; 61 #endif 62 #if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7 63 static const uint8_t priority2tc_strict_7[] = {1, 0, 2, 3, 4, 4, 5, 6}; 64 #endif 65 #if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8 66 static const uint8_t priority2tc_strict_8[] = {1, 0, 2, 3, 4, 5, 6, 7}; 67 #endif 68 69 #if NET_TC_TX_COUNT > 0 70 static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(strict, NET_TC_TX_COUNT); 71 #endif 72 #if NET_TC_RX_COUNT > 0 73 static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(strict, NET_TC_RX_COUNT); 74 #endif 75 76 #elif defined(CONFIG_NET_TC_MAPPING_SR_CLASS_A_AND_B) && (NET_TC_COUNT > 0) 77 78 /* This is the recommended priority to traffic class mapping for a system that 79 * supports SR (Stream Reservation) class A and SR class B. 80 * Ref: 802.1Q - chapter 34.5 - table 34-1 81 */ 82 83 #if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2 84 static const uint8_t priority2tc_sr_ab_2[] = {0, 0, 1, 1, 0, 0, 0, 0}; 85 #endif 86 #if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3 87 static const uint8_t priority2tc_sr_ab_3[] = {0, 0, 1, 2, 0, 0, 0, 0}; 88 #endif 89 #if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4 90 static const uint8_t priority2tc_sr_ab_4[] = {0, 0, 2, 3, 1, 1, 1, 1}; 91 #endif 92 #if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5 93 static const uint8_t priority2tc_sr_ab_5[] = {0, 0, 3, 4, 1, 1, 2, 2}; 94 #endif 95 #if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6 96 static const uint8_t priority2tc_sr_ab_6[] = {0, 0, 4, 5, 1, 1, 2, 3}; 97 #endif 98 #if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7 99 static const uint8_t priority2tc_sr_ab_7[] = {0, 0, 5, 6, 1, 2, 3, 4}; 100 #endif 101 #if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8 102 static const uint8_t priority2tc_sr_ab_8[] = {1, 0, 6, 7, 2, 3, 4, 5}; 103 #endif 104 105 #if NET_TC_TX_COUNT > 0 106 static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(sr_ab, NET_TC_TX_COUNT); 107 #endif 108 #if NET_TC_RX_COUNT > 0 109 static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(sr_ab, NET_TC_RX_COUNT); 110 #endif 111 112 #elif defined(CONFIG_NET_TC_MAPPING_SR_CLASS_B_ONLY) && (NET_TC_COUNT > 0) 113 114 /* This is the recommended priority to traffic class mapping for a system that 115 * supports SR (Stream Reservation) class B only. 116 * Ref: 802.1Q - chapter 34.5 - table 34-2 117 */ 118 119 #if NET_TC_TX_COUNT == 2 || NET_TC_RX_COUNT == 2 120 static const uint8_t priority2tc_sr_b_2[] = {0, 0, 1, 0, 0, 0, 0, 0}; 121 #endif 122 #if NET_TC_TX_COUNT == 3 || NET_TC_RX_COUNT == 3 123 static const uint8_t priority2tc_sr_b_3[] = {0, 0, 2, 0, 1, 1, 1, 1}; 124 #endif 125 #if NET_TC_TX_COUNT == 4 || NET_TC_RX_COUNT == 4 126 static const uint8_t priority2tc_sr_b_4[] = {0, 0, 3, 0, 1, 1, 2, 2}; 127 #endif 128 #if NET_TC_TX_COUNT == 5 || NET_TC_RX_COUNT == 5 129 static const uint8_t priority2tc_sr_b_5[] = {0, 0, 4, 1, 2, 2, 3, 3}; 130 #endif 131 #if NET_TC_TX_COUNT == 6 || NET_TC_RX_COUNT == 6 132 static const uint8_t priority2tc_sr_b_6[] = {0, 0, 5, 1, 2, 2, 3, 4}; 133 #endif 134 #if NET_TC_TX_COUNT == 7 || NET_TC_RX_COUNT == 7 135 static const uint8_t priority2tc_sr_b_7[] = {1, 0, 6, 2, 3, 3, 4, 5}; 136 #endif 137 #if NET_TC_TX_COUNT == 8 || NET_TC_RX_COUNT == 8 138 static const uint8_t priority2tc_sr_b_8[] = {1, 0, 7, 2, 3, 4, 5, 6}; 139 #endif 140 141 #if NET_TC_TX_COUNT > 0 142 static const uint8_t *tx_prio2tc_map = PRIORITY2TC_GEN(sr_b, NET_TC_TX_COUNT); 143 #endif 144 #if NET_TC_RX_COUNT > 0 145 static const uint8_t *rx_prio2tc_map = PRIORITY2TC_GEN(sr_b, NET_TC_RX_COUNT); 146 #endif 147 148 #endif 149 150 #endif /* __TC_MAPPING_H */ 151