xref: /dpdk/drivers/net/bnxt/tf_core/tf_util.c (revision e6e8f03e5459f25153f1e4cd3e9ac30d3e473a61)
18187694bSMichael Wildt /* SPDX-License-Identifier: BSD-3-Clause
2*e6e8f03eSRandy Schacher  * Copyright(c) 2014-2023 Broadcom
38187694bSMichael Wildt  * All rights reserved.
48187694bSMichael Wildt  */
58187694bSMichael Wildt 
68187694bSMichael Wildt #include <string.h>
78187694bSMichael Wildt #include "tf_util.h"
88187694bSMichael Wildt 
9eee264adSMichael Wildt const char *
tf_dir_2_str(enum tf_dir dir)10eee264adSMichael Wildt tf_dir_2_str(enum tf_dir dir)
118187694bSMichael Wildt {
128187694bSMichael Wildt 	switch (dir) {
138187694bSMichael Wildt 	case TF_DIR_RX:
148187694bSMichael Wildt 		return "RX";
158187694bSMichael Wildt 	case TF_DIR_TX:
168187694bSMichael Wildt 		return "TX";
178187694bSMichael Wildt 	default:
188187694bSMichael Wildt 		return "Invalid direction";
198187694bSMichael Wildt 	}
208187694bSMichael Wildt }
218187694bSMichael Wildt 
22eee264adSMichael Wildt const char *
tf_ident_2_str(enum tf_identifier_type id_type)23eee264adSMichael Wildt tf_ident_2_str(enum tf_identifier_type id_type)
248187694bSMichael Wildt {
258187694bSMichael Wildt 	switch (id_type) {
268cc50a63SPeter Spreadborough 	case TF_IDENT_TYPE_L2_CTXT_HIGH:
278cc50a63SPeter Spreadborough 		return "l2_ctxt_remap_high";
288cc50a63SPeter Spreadborough 	case TF_IDENT_TYPE_L2_CTXT_LOW:
298cc50a63SPeter Spreadborough 		return "l2_ctxt_remap_low";
308187694bSMichael Wildt 	case TF_IDENT_TYPE_PROF_FUNC:
318187694bSMichael Wildt 		return "prof_func";
328187694bSMichael Wildt 	case TF_IDENT_TYPE_WC_PROF:
338187694bSMichael Wildt 		return "wc_prof";
348187694bSMichael Wildt 	case TF_IDENT_TYPE_EM_PROF:
358187694bSMichael Wildt 		return "em_prof";
368187694bSMichael Wildt 	case TF_IDENT_TYPE_L2_FUNC:
378187694bSMichael Wildt 		return "l2_func";
388187694bSMichael Wildt 	default:
398187694bSMichael Wildt 		return "Invalid identifier";
408187694bSMichael Wildt 	}
418187694bSMichael Wildt }
428187694bSMichael Wildt 
43eee264adSMichael Wildt const char *
tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type)44eee264adSMichael Wildt tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type)
458187694bSMichael Wildt {
468187694bSMichael Wildt 	switch (tcam_type) {
478cc50a63SPeter Spreadborough 	case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH:
488cc50a63SPeter Spreadborough 		return "l2_ctxt_tcam_high";
498cc50a63SPeter Spreadborough 	case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW:
508cc50a63SPeter Spreadborough 		return "l2_ctxt_tcam_low";
518187694bSMichael Wildt 	case TF_TCAM_TBL_TYPE_PROF_TCAM:
528187694bSMichael Wildt 		return "prof_tcam";
538187694bSMichael Wildt 	case TF_TCAM_TBL_TYPE_WC_TCAM:
548187694bSMichael Wildt 		return "wc_tcam";
558187694bSMichael Wildt 	case TF_TCAM_TBL_TYPE_VEB_TCAM:
568187694bSMichael Wildt 		return "veb_tcam";
578187694bSMichael Wildt 	case TF_TCAM_TBL_TYPE_SP_TCAM:
588187694bSMichael Wildt 		return "sp_tcam";
598187694bSMichael Wildt 	case TF_TCAM_TBL_TYPE_CT_RULE_TCAM:
608187694bSMichael Wildt 		return "ct_rule_tcam";
6187286092SFarah Smith 	case TF_TCAM_TBL_TYPE_WC_TCAM_HIGH:
6287286092SFarah Smith 		return "wc_tcam_hi";
6387286092SFarah Smith 	case TF_TCAM_TBL_TYPE_WC_TCAM_LOW:
6487286092SFarah Smith 		return "wc_tcam_lo";
658187694bSMichael Wildt 	default:
668187694bSMichael Wildt 		return "Invalid tcam table type";
678187694bSMichael Wildt 	}
688187694bSMichael Wildt }
698187694bSMichael Wildt 
70eee264adSMichael Wildt const char *
tf_tbl_type_2_str(enum tf_tbl_type tbl_type)71eee264adSMichael Wildt tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
728187694bSMichael Wildt {
738187694bSMichael Wildt 	switch (tbl_type) {
748187694bSMichael Wildt 	case TF_TBL_TYPE_FULL_ACT_RECORD:
758187694bSMichael Wildt 		return "Full Action record";
7637ff91c1SFarah Smith 	case TF_TBL_TYPE_COMPACT_ACT_RECORD:
7737ff91c1SFarah Smith 		return "Compact Action record";
788187694bSMichael Wildt 	case TF_TBL_TYPE_MCAST_GROUPS:
798187694bSMichael Wildt 		return "Multicast Groups";
808187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_ENCAP_8B:
818187694bSMichael Wildt 		return "Encap 8B";
828187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_ENCAP_16B:
838187694bSMichael Wildt 		return "Encap 16B";
848187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_ENCAP_32B:
858187694bSMichael Wildt 		return "Encap 32B";
868187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_ENCAP_64B:
878187694bSMichael Wildt 		return "Encap 64B";
888187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_SP_SMAC:
898187694bSMichael Wildt 		return "Source Properties SMAC";
908187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
918187694bSMichael Wildt 		return "Source Properties SMAC IPv4";
928187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
938187694bSMichael Wildt 		return "Source Properties SMAC IPv6";
948187694bSMichael Wildt 	case TF_TBL_TYPE_ACT_STATS_64:
958187694bSMichael Wildt 		return "Stats 64B";
96b860bcb7SJay Ding 	case TF_TBL_TYPE_ACT_MODIFY_IPV4:
97acd38b0aSFarah Smith 		return "Modify IPv4";
9837ff91c1SFarah Smith 	case TF_TBL_TYPE_ACT_MODIFY_8B:
9937ff91c1SFarah Smith 		return "Modify 8B";
10037ff91c1SFarah Smith 	case TF_TBL_TYPE_ACT_MODIFY_16B:
10137ff91c1SFarah Smith 		return "Modify 16B";
10237ff91c1SFarah Smith 	case TF_TBL_TYPE_ACT_MODIFY_32B:
10337ff91c1SFarah Smith 		return "Modify 32B";
10437ff91c1SFarah Smith 	case TF_TBL_TYPE_ACT_MODIFY_64B:
10537ff91c1SFarah Smith 		return "Modify 64B";
1068187694bSMichael Wildt 	case TF_TBL_TYPE_METER_PROF:
1078187694bSMichael Wildt 		return "Meter Profile";
1088187694bSMichael Wildt 	case TF_TBL_TYPE_METER_INST:
1098187694bSMichael Wildt 		return "Meter";
1108187694bSMichael Wildt 	case TF_TBL_TYPE_MIRROR_CONFIG:
1118187694bSMichael Wildt 		return "Mirror";
1128187694bSMichael Wildt 	case TF_TBL_TYPE_UPAR:
1138187694bSMichael Wildt 		return "UPAR";
1148187694bSMichael Wildt 	case TF_TBL_TYPE_METADATA:
1158187694bSMichael Wildt 		return "Metadata";
1168187694bSMichael Wildt 	case TF_TBL_TYPE_EM_FKB:
1178187694bSMichael Wildt 		return "EM Flexible Key Builder";
1188187694bSMichael Wildt 	case TF_TBL_TYPE_WC_FKB:
1198187694bSMichael Wildt 		return "WC Flexible Key Builder";
1208187694bSMichael Wildt 	case TF_TBL_TYPE_EXT:
1218187694bSMichael Wildt 		return "External";
122998b9639SJay Ding 	case TF_TBL_TYPE_METER_DROP_CNT:
123998b9639SJay Ding 		return "Meter drop counter";
1248187694bSMichael Wildt 	default:
1258187694bSMichael Wildt 		return "Invalid tbl type";
1268187694bSMichael Wildt 	}
1278187694bSMichael Wildt }
1288187694bSMichael Wildt 
129eee264adSMichael Wildt const char *
tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type)130eee264adSMichael Wildt tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type)
1318187694bSMichael Wildt {
1328187694bSMichael Wildt 	switch (em_type) {
1338187694bSMichael Wildt 	case TF_EM_TBL_TYPE_EM_RECORD:
1348187694bSMichael Wildt 		return "EM Record";
1358187694bSMichael Wildt 	case TF_EM_TBL_TYPE_TBL_SCOPE:
1368187694bSMichael Wildt 		return "Table Scope";
1378187694bSMichael Wildt 	default:
1388187694bSMichael Wildt 		return "Invalid EM type";
1398187694bSMichael Wildt 	}
1408187694bSMichael Wildt }
141eee264adSMichael Wildt 
142eee264adSMichael Wildt const char *
tf_module_subtype_2_str(enum tf_module_type module,uint16_t subtype)14370529991SFarah Smith tf_module_subtype_2_str(enum tf_module_type module,
14470529991SFarah Smith 			uint16_t subtype)
145eee264adSMichael Wildt {
14670529991SFarah Smith 	switch (module) {
14770529991SFarah Smith 	case TF_MODULE_TYPE_IDENTIFIER:
14870529991SFarah Smith 		return tf_ident_2_str(subtype);
14970529991SFarah Smith 	case TF_MODULE_TYPE_TABLE:
15070529991SFarah Smith 		return tf_tbl_type_2_str(subtype);
15170529991SFarah Smith 	case TF_MODULE_TYPE_TCAM:
15270529991SFarah Smith 		return tf_tcam_tbl_2_str(subtype);
15370529991SFarah Smith 	case TF_MODULE_TYPE_EM:
15470529991SFarah Smith 		return tf_em_tbl_type_2_str(subtype);
155eee264adSMichael Wildt 	default:
15670529991SFarah Smith 		return "Invalid Module type";
157eee264adSMichael Wildt 	}
158eee264adSMichael Wildt }
159eee264adSMichael Wildt 
160eee264adSMichael Wildt const char *
tf_module_2_str(enum tf_module_type module)16170529991SFarah Smith tf_module_2_str(enum tf_module_type module)
162eee264adSMichael Wildt {
16370529991SFarah Smith 	switch (module) {
16470529991SFarah Smith 	case TF_MODULE_TYPE_IDENTIFIER:
165eee264adSMichael Wildt 		return "Identifier";
16670529991SFarah Smith 	case TF_MODULE_TYPE_TABLE:
167eee264adSMichael Wildt 		return "Table";
16870529991SFarah Smith 	case TF_MODULE_TYPE_TCAM:
169eee264adSMichael Wildt 		return "TCAM";
17070529991SFarah Smith 	case TF_MODULE_TYPE_EM:
171eee264adSMichael Wildt 		return "EM";
172eee264adSMichael Wildt 	default:
173eee264adSMichael Wildt 		return "Invalid Device Module type";
174eee264adSMichael Wildt 	}
175eee264adSMichael Wildt }
176