1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2014-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _TF_UTIL_H_ 7 #define _TF_UTIL_H_ 8 9 #include "tf_core.h" 10 11 #define TF_BITS2BYTES(x) (((x) + 7) >> 3) 12 #define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4) 13 #define TF_BITS2BYTES_64B_WORD_ALIGN(x) ((((x) + 63) >> 6) * 8) 14 15 /** 16 * Helper function converting direction to text string 17 * 18 * [in] dir 19 * Receive or transmit direction identifier 20 * 21 * Returns: 22 * Pointer to a char string holding the string for the direction 23 */ 24 const char *tf_dir_2_str(enum tf_dir dir); 25 26 /** 27 * Helper function converting identifier to text string 28 * 29 * [in] id_type 30 * Identifier type 31 * 32 * Returns: 33 * Pointer to a char string holding the string for the identifier 34 */ 35 const char *tf_ident_2_str(enum tf_identifier_type id_type); 36 37 /** 38 * Helper function converting tcam type to text string 39 * 40 * [in] tcam_type 41 * TCAM type 42 * 43 * Returns: 44 * Pointer to a char string holding the string for the tcam 45 */ 46 const char *tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type); 47 48 /** 49 * Helper function converting tbl type to text string 50 * 51 * [in] tbl_type 52 * Table type 53 * 54 * Returns: 55 * Pointer to a char string holding the string for the table type 56 */ 57 const char *tf_tbl_type_2_str(enum tf_tbl_type tbl_type); 58 59 /** 60 * Helper function converting em tbl type to text string 61 * 62 * [in] em_type 63 * EM type 64 * 65 * Returns: 66 * Pointer to a char string holding the string for the EM type 67 */ 68 const char *tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type); 69 70 /** 71 * Helper function converting module and submodule type to 72 * text string. 73 * 74 * [in] module 75 * Module type 76 * 77 * [in] submodule 78 * Module specific subtype 79 * 80 * Returns: 81 * Pointer to a char string holding the string for the EM type 82 */ 83 const char *tf_module_subtype_2_str(enum tf_module_type module, 84 uint16_t subtype); 85 86 /** 87 * Helper function converting module type to text string 88 * 89 * [in] module 90 * Module type 91 * 92 * Returns: 93 * Pointer to a char string holding the string for the EM type 94 */ 95 const char *tf_module_2_str(enum tf_module_type module); 96 #endif /* _TF_UTIL_H_ */ 97