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 #ifndef _TF_UTIL_H_ 78187694bSMichael Wildt #define _TF_UTIL_H_ 88187694bSMichael Wildt 98187694bSMichael Wildt #include "tf_core.h" 108187694bSMichael Wildt 1108e1af1aSFarah Smith #define TF_BITS2BYTES(x) (((x) + 7) >> 3) 1208e1af1aSFarah Smith #define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4) 1308e1af1aSFarah Smith #define TF_BITS2BYTES_64B_WORD_ALIGN(x) ((((x) + 63) >> 6) * 8) 1408e1af1aSFarah Smith 158187694bSMichael Wildt /** 168187694bSMichael Wildt * Helper function converting direction to text string 1748d3dff2SMichael Wildt * 1848d3dff2SMichael Wildt * [in] dir 1948d3dff2SMichael Wildt * Receive or transmit direction identifier 2048d3dff2SMichael Wildt * 2148d3dff2SMichael Wildt * Returns: 2248d3dff2SMichael Wildt * Pointer to a char string holding the string for the direction 238187694bSMichael Wildt */ 2448d3dff2SMichael Wildt const char *tf_dir_2_str(enum tf_dir dir); 258187694bSMichael Wildt 268187694bSMichael Wildt /** 278187694bSMichael Wildt * Helper function converting identifier to text string 2848d3dff2SMichael Wildt * 2948d3dff2SMichael Wildt * [in] id_type 3048d3dff2SMichael Wildt * Identifier type 3148d3dff2SMichael Wildt * 3248d3dff2SMichael Wildt * Returns: 3348d3dff2SMichael Wildt * Pointer to a char string holding the string for the identifier 348187694bSMichael Wildt */ 3548d3dff2SMichael Wildt const char *tf_ident_2_str(enum tf_identifier_type id_type); 368187694bSMichael Wildt 378187694bSMichael Wildt /** 388187694bSMichael Wildt * Helper function converting tcam type to text string 3948d3dff2SMichael Wildt * 4048d3dff2SMichael Wildt * [in] tcam_type 4148d3dff2SMichael Wildt * TCAM type 4248d3dff2SMichael Wildt * 4348d3dff2SMichael Wildt * Returns: 4448d3dff2SMichael Wildt * Pointer to a char string holding the string for the tcam 458187694bSMichael Wildt */ 4648d3dff2SMichael Wildt const char *tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type); 478187694bSMichael Wildt 488187694bSMichael Wildt /** 498187694bSMichael Wildt * Helper function converting tbl type to text string 5048d3dff2SMichael Wildt * 5148d3dff2SMichael Wildt * [in] tbl_type 5248d3dff2SMichael Wildt * Table type 5348d3dff2SMichael Wildt * 5448d3dff2SMichael Wildt * Returns: 5548d3dff2SMichael Wildt * Pointer to a char string holding the string for the table type 568187694bSMichael Wildt */ 5748d3dff2SMichael Wildt const char *tf_tbl_type_2_str(enum tf_tbl_type tbl_type); 588187694bSMichael Wildt 598187694bSMichael Wildt /** 608187694bSMichael Wildt * Helper function converting em tbl type to text string 6148d3dff2SMichael Wildt * 6248d3dff2SMichael Wildt * [in] em_type 6348d3dff2SMichael Wildt * EM type 6448d3dff2SMichael Wildt * 6548d3dff2SMichael Wildt * Returns: 6648d3dff2SMichael Wildt * Pointer to a char string holding the string for the EM type 678187694bSMichael Wildt */ 6848d3dff2SMichael Wildt const char *tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type); 698187694bSMichael Wildt 70eee264adSMichael Wildt /** 7170529991SFarah Smith * Helper function converting module and submodule type to 72eee264adSMichael Wildt * text string. 73eee264adSMichael Wildt * 7470529991SFarah Smith * [in] module 7570529991SFarah Smith * Module type 76eee264adSMichael Wildt * 7770529991SFarah Smith * [in] submodule 7870529991SFarah Smith * Module specific subtype 79eee264adSMichael Wildt * 80eee264adSMichael Wildt * Returns: 81eee264adSMichael Wildt * Pointer to a char string holding the string for the EM type 82eee264adSMichael Wildt */ 8370529991SFarah Smith const char *tf_module_subtype_2_str(enum tf_module_type module, 8470529991SFarah Smith uint16_t subtype); 85eee264adSMichael Wildt 86eee264adSMichael Wildt /** 8770529991SFarah Smith * Helper function converting module type to text string 88eee264adSMichael Wildt * 8970529991SFarah Smith * [in] module 9070529991SFarah Smith * Module type 91eee264adSMichael Wildt * 92eee264adSMichael Wildt * Returns: 93eee264adSMichael Wildt * Pointer to a char string holding the string for the EM type 94eee264adSMichael Wildt */ 9570529991SFarah Smith const char *tf_module_2_str(enum tf_module_type module); 968187694bSMichael Wildt #endif /* _TF_UTIL_H_ */ 97