1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2014-2019 Broadcom 3 * All rights reserved. 4 */ 5 6 #include <string.h> 7 8 #include "tf_util.h" 9 10 const char * 11 tf_dir_2_str(enum tf_dir dir) 12 { 13 switch (dir) { 14 case TF_DIR_RX: 15 return "RX"; 16 case TF_DIR_TX: 17 return "TX"; 18 default: 19 return "Invalid direction"; 20 } 21 } 22 23 const char * 24 tf_ident_2_str(enum tf_identifier_type id_type) 25 { 26 switch (id_type) { 27 case TF_IDENT_TYPE_L2_CTXT: 28 return "l2_ctxt_remap"; 29 case TF_IDENT_TYPE_PROF_FUNC: 30 return "prof_func"; 31 case TF_IDENT_TYPE_WC_PROF: 32 return "wc_prof"; 33 case TF_IDENT_TYPE_EM_PROF: 34 return "em_prof"; 35 case TF_IDENT_TYPE_L2_FUNC: 36 return "l2_func"; 37 default: 38 return "Invalid identifier"; 39 } 40 } 41 42 const char * 43 tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type) 44 { 45 switch (tcam_type) { 46 case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM: 47 return "l2_ctxt_tcam"; 48 case TF_TCAM_TBL_TYPE_PROF_TCAM: 49 return "prof_tcam"; 50 case TF_TCAM_TBL_TYPE_WC_TCAM: 51 return "wc_tcam"; 52 case TF_TCAM_TBL_TYPE_VEB_TCAM: 53 return "veb_tcam"; 54 case TF_TCAM_TBL_TYPE_SP_TCAM: 55 return "sp_tcam"; 56 case TF_TCAM_TBL_TYPE_CT_RULE_TCAM: 57 return "ct_rule_tcam"; 58 default: 59 return "Invalid tcam table type"; 60 } 61 } 62 63 const char * 64 tf_tbl_type_2_str(enum tf_tbl_type tbl_type) 65 { 66 switch (tbl_type) { 67 case TF_TBL_TYPE_FULL_ACT_RECORD: 68 return "Full Action record"; 69 case TF_TBL_TYPE_MCAST_GROUPS: 70 return "Multicast Groups"; 71 case TF_TBL_TYPE_ACT_ENCAP_8B: 72 return "Encap 8B"; 73 case TF_TBL_TYPE_ACT_ENCAP_16B: 74 return "Encap 16B"; 75 case TF_TBL_TYPE_ACT_ENCAP_32B: 76 return "Encap 32B"; 77 case TF_TBL_TYPE_ACT_ENCAP_64B: 78 return "Encap 64B"; 79 case TF_TBL_TYPE_ACT_SP_SMAC: 80 return "Source Properties SMAC"; 81 case TF_TBL_TYPE_ACT_SP_SMAC_IPV4: 82 return "Source Properties SMAC IPv4"; 83 case TF_TBL_TYPE_ACT_SP_SMAC_IPV6: 84 return "Source Properties SMAC IPv6"; 85 case TF_TBL_TYPE_ACT_STATS_64: 86 return "Stats 64B"; 87 case TF_TBL_TYPE_ACT_MODIFY_SPORT: 88 return "NAT Source Port"; 89 case TF_TBL_TYPE_ACT_MODIFY_DPORT: 90 return "NAT Destination Port"; 91 case TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC: 92 return "NAT IPv4 Source"; 93 case TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST: 94 return "NAT IPv4 Destination"; 95 case TF_TBL_TYPE_METER_PROF: 96 return "Meter Profile"; 97 case TF_TBL_TYPE_METER_INST: 98 return "Meter"; 99 case TF_TBL_TYPE_MIRROR_CONFIG: 100 return "Mirror"; 101 case TF_TBL_TYPE_UPAR: 102 return "UPAR"; 103 case TF_TBL_TYPE_EPOCH0: 104 return "EPOCH0"; 105 case TF_TBL_TYPE_EPOCH1: 106 return "EPOCH1"; 107 case TF_TBL_TYPE_METADATA: 108 return "Metadata"; 109 case TF_TBL_TYPE_CT_STATE: 110 return "Connection State"; 111 case TF_TBL_TYPE_RANGE_PROF: 112 return "Range Profile"; 113 case TF_TBL_TYPE_RANGE_ENTRY: 114 return "Range"; 115 case TF_TBL_TYPE_LAG: 116 return "Link Aggregation"; 117 case TF_TBL_TYPE_VNIC_SVIF: 118 return "VNIC SVIF"; 119 case TF_TBL_TYPE_EM_FKB: 120 return "EM Flexible Key Builder"; 121 case TF_TBL_TYPE_WC_FKB: 122 return "WC Flexible Key Builder"; 123 case TF_TBL_TYPE_EXT: 124 return "External"; 125 default: 126 return "Invalid tbl type"; 127 } 128 } 129 130 const char * 131 tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type) 132 { 133 switch (em_type) { 134 case TF_EM_TBL_TYPE_EM_RECORD: 135 return "EM Record"; 136 case TF_EM_TBL_TYPE_TBL_SCOPE: 137 return "Table Scope"; 138 default: 139 return "Invalid EM type"; 140 } 141 } 142 143 const char * 144 tf_device_module_type_subtype_2_str(enum tf_device_module_type dm_type, 145 uint16_t mod_type) 146 { 147 switch (dm_type) { 148 case TF_DEVICE_MODULE_TYPE_IDENTIFIER: 149 return tf_ident_2_str(mod_type); 150 case TF_DEVICE_MODULE_TYPE_TABLE: 151 return tf_tbl_type_2_str(mod_type); 152 case TF_DEVICE_MODULE_TYPE_TCAM: 153 return tf_tcam_tbl_2_str(mod_type); 154 case TF_DEVICE_MODULE_TYPE_EM: 155 return tf_em_tbl_type_2_str(mod_type); 156 default: 157 return "Invalid Device Module type"; 158 } 159 } 160 161 const char * 162 tf_device_module_type_2_str(enum tf_device_module_type dm_type) 163 { 164 switch (dm_type) { 165 case TF_DEVICE_MODULE_TYPE_IDENTIFIER: 166 return "Identifier"; 167 case TF_DEVICE_MODULE_TYPE_TABLE: 168 return "Table"; 169 case TF_DEVICE_MODULE_TYPE_TCAM: 170 return "TCAM"; 171 case TF_DEVICE_MODULE_TYPE_EM: 172 return "EM"; 173 default: 174 return "Invalid Device Module type"; 175 } 176 } 177