Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2014-2023 Broadcom 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #include <string.h> 7 : : #include "tf_util.h" 8 : : 9 : : const char * 10 : 0 : tf_dir_2_str(enum tf_dir dir) 11 : : { 12 [ # # # ]: 0 : switch (dir) { 13 : : case TF_DIR_RX: 14 : : return "RX"; 15 : 0 : case TF_DIR_TX: 16 : 0 : return "TX"; 17 : 0 : default: 18 : 0 : return "Invalid direction"; 19 : : } 20 : : } 21 : : 22 : : const char * 23 : 0 : tf_ident_2_str(enum tf_identifier_type id_type) 24 : : { 25 [ # # # # : 0 : switch (id_type) { # # # ] 26 : : case TF_IDENT_TYPE_L2_CTXT_HIGH: 27 : : return "l2_ctxt_remap_high"; 28 : 0 : case TF_IDENT_TYPE_L2_CTXT_LOW: 29 : 0 : return "l2_ctxt_remap_low"; 30 : 0 : case TF_IDENT_TYPE_PROF_FUNC: 31 : 0 : return "prof_func"; 32 : 0 : case TF_IDENT_TYPE_WC_PROF: 33 : 0 : return "wc_prof"; 34 : 0 : case TF_IDENT_TYPE_EM_PROF: 35 : 0 : return "em_prof"; 36 : 0 : case TF_IDENT_TYPE_L2_FUNC: 37 : 0 : return "l2_func"; 38 : 0 : default: 39 : 0 : return "Invalid identifier"; 40 : : } 41 : : } 42 : : 43 : : const char * 44 : 0 : tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type) 45 : : { 46 [ # # # # : 0 : switch (tcam_type) { # # # # # # ] 47 : : case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH: 48 : : return "l2_ctxt_tcam_high"; 49 : 0 : case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW: 50 : 0 : return "l2_ctxt_tcam_low"; 51 : 0 : case TF_TCAM_TBL_TYPE_PROF_TCAM: 52 : 0 : return "prof_tcam"; 53 : 0 : case TF_TCAM_TBL_TYPE_WC_TCAM: 54 : 0 : return "wc_tcam"; 55 : 0 : case TF_TCAM_TBL_TYPE_VEB_TCAM: 56 : 0 : return "veb_tcam"; 57 : 0 : case TF_TCAM_TBL_TYPE_SP_TCAM: 58 : 0 : return "sp_tcam"; 59 : 0 : case TF_TCAM_TBL_TYPE_CT_RULE_TCAM: 60 : 0 : return "ct_rule_tcam"; 61 : 0 : case TF_TCAM_TBL_TYPE_WC_TCAM_HIGH: 62 : 0 : return "wc_tcam_hi"; 63 : 0 : case TF_TCAM_TBL_TYPE_WC_TCAM_LOW: 64 : 0 : return "wc_tcam_lo"; 65 : 0 : default: 66 : 0 : return "Invalid tcam table type"; 67 : : } 68 : : } 69 : : 70 : : const char * 71 : 0 : tf_tbl_type_2_str(enum tf_tbl_type tbl_type) 72 : : { 73 [ # # # # : 0 : switch (tbl_type) { # # # # # # # # # # # # # # # # # # # # # # ] 74 : : case TF_TBL_TYPE_FULL_ACT_RECORD: 75 : : return "Full Action record"; 76 : 0 : case TF_TBL_TYPE_COMPACT_ACT_RECORD: 77 : 0 : return "Compact Action record"; 78 : 0 : case TF_TBL_TYPE_MCAST_GROUPS: 79 : 0 : return "Multicast Groups"; 80 : 0 : case TF_TBL_TYPE_ACT_ENCAP_8B: 81 : 0 : return "Encap 8B"; 82 : 0 : case TF_TBL_TYPE_ACT_ENCAP_16B: 83 : 0 : return "Encap 16B"; 84 : 0 : case TF_TBL_TYPE_ACT_ENCAP_32B: 85 : 0 : return "Encap 32B"; 86 : 0 : case TF_TBL_TYPE_ACT_ENCAP_64B: 87 : 0 : return "Encap 64B"; 88 : 0 : case TF_TBL_TYPE_ACT_SP_SMAC: 89 : 0 : return "Source Properties SMAC"; 90 : 0 : case TF_TBL_TYPE_ACT_SP_SMAC_IPV4: 91 : 0 : return "Source Properties SMAC IPv4"; 92 : 0 : case TF_TBL_TYPE_ACT_SP_SMAC_IPV6: 93 : 0 : return "Source Properties SMAC IPv6"; 94 : 0 : case TF_TBL_TYPE_ACT_STATS_64: 95 : 0 : return "Stats 64B"; 96 : 0 : case TF_TBL_TYPE_ACT_MODIFY_IPV4: 97 : 0 : return "Modify IPv4"; 98 : 0 : case TF_TBL_TYPE_ACT_MODIFY_8B: 99 : 0 : return "Modify 8B"; 100 : 0 : case TF_TBL_TYPE_ACT_MODIFY_16B: 101 : 0 : return "Modify 16B"; 102 : 0 : case TF_TBL_TYPE_ACT_MODIFY_32B: 103 : 0 : return "Modify 32B"; 104 : 0 : case TF_TBL_TYPE_ACT_MODIFY_64B: 105 : 0 : return "Modify 64B"; 106 : 0 : case TF_TBL_TYPE_METER_PROF: 107 : 0 : return "Meter Profile"; 108 : 0 : case TF_TBL_TYPE_METER_INST: 109 : 0 : return "Meter"; 110 : 0 : case TF_TBL_TYPE_MIRROR_CONFIG: 111 : 0 : return "Mirror"; 112 : 0 : case TF_TBL_TYPE_UPAR: 113 : 0 : return "UPAR"; 114 : 0 : case TF_TBL_TYPE_METADATA: 115 : 0 : return "Metadata"; 116 : 0 : case TF_TBL_TYPE_EM_FKB: 117 : 0 : return "EM Flexible Key Builder"; 118 : 0 : case TF_TBL_TYPE_WC_FKB: 119 : 0 : return "WC Flexible Key Builder"; 120 : 0 : case TF_TBL_TYPE_EXT: 121 : 0 : return "External"; 122 : 0 : case TF_TBL_TYPE_METER_DROP_CNT: 123 : 0 : return "Meter drop counter"; 124 : 0 : default: 125 : 0 : return "Invalid tbl type"; 126 : : } 127 : : } 128 : : 129 : : const char * 130 : 0 : tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type) 131 : : { 132 [ # # # ]: 0 : switch (em_type) { 133 : : case TF_EM_TBL_TYPE_EM_RECORD: 134 : : return "EM Record"; 135 : 0 : case TF_EM_TBL_TYPE_TBL_SCOPE: 136 : 0 : return "Table Scope"; 137 : 0 : default: 138 : 0 : return "Invalid EM type"; 139 : : } 140 : : } 141 : : 142 : : const char * 143 : 0 : tf_module_subtype_2_str(enum tf_module_type module, 144 : : uint16_t subtype) 145 : : { 146 [ # # # # : 0 : switch (module) { # ] 147 : 0 : case TF_MODULE_TYPE_IDENTIFIER: 148 : 0 : return tf_ident_2_str(subtype); 149 : 0 : case TF_MODULE_TYPE_TABLE: 150 : 0 : return tf_tbl_type_2_str(subtype); 151 : 0 : case TF_MODULE_TYPE_TCAM: 152 : 0 : return tf_tcam_tbl_2_str(subtype); 153 : 0 : case TF_MODULE_TYPE_EM: 154 : 0 : return tf_em_tbl_type_2_str(subtype); 155 : : default: 156 : : return "Invalid Module type"; 157 : : } 158 : : } 159 : : 160 : : const char * 161 : 0 : tf_module_2_str(enum tf_module_type module) 162 : : { 163 [ # # # # : 0 : switch (module) { # ] 164 : : case TF_MODULE_TYPE_IDENTIFIER: 165 : : return "Identifier"; 166 : 0 : case TF_MODULE_TYPE_TABLE: 167 : 0 : return "Table"; 168 : 0 : case TF_MODULE_TYPE_TCAM: 169 : 0 : return "TCAM"; 170 : 0 : case TF_MODULE_TYPE_EM: 171 : 0 : return "EM"; 172 : 0 : default: 173 : 0 : return "Invalid Device Module type"; 174 : : } 175 : : }