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