1 /* 2 * Copyright 2012-2018, 2023 NXP 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #if !defined(NXPLOG__H_INCLUDED) 18 #define NXPLOG__H_INCLUDED 19 #include <log/log.h> 20 21 typedef struct uci_log_level { 22 uint8_t global_log_level; 23 uint8_t extns_log_level; 24 uint8_t hal_log_level; 25 uint8_t dnld_log_level; 26 uint8_t tml_log_level; 27 uint8_t ucix_log_level; 28 uint8_t ucir_log_level; 29 } uci_log_level_t; 30 31 /* global log level Ref */ 32 extern uci_log_level_t gLog_level; 33 /* define log module included when compile */ 34 #define ENABLE_EXTNS_TRACES TRUE 35 #define ENABLE_HAL_TRACES TRUE 36 #define ENABLE_TML_TRACES TRUE 37 #define ENABLE_FWDNLD_TRACES TRUE 38 #define ENABLE_UCIX_TRACES TRUE 39 #define ENABLE_UCIR_TRACES TRUE 40 41 #define ENABLE_HCPX_TRACES FALSE 42 #define ENABLE_HCPR_TRACES FALSE 43 44 /* ####################### Set the log module name in .conf file 45 * ########################## */ 46 #define NAME_NXPLOG_EXTNS_LOGLEVEL "NXP_LOG_EXTNS_LOGLEVEL" 47 #define NAME_NXPLOG_HAL_LOGLEVEL "NXP_LOG_UCIHAL_LOGLEVEL" 48 #define NAME_NXPLOG_UCIX_LOGLEVEL "NXP_LOG_UCIX_LOGLEVEL" 49 #define NAME_NXPLOG_UCIR_LOGLEVEL "NXP_LOG_UCIR_LOGLEVEL" 50 #define NAME_NXPLOG_FWDNLD_LOGLEVEL "NXP_LOG_FWDNLD_LOGLEVEL" 51 #define NAME_NXPLOG_TML_LOGLEVEL "NXP_LOG_TML_LOGLEVEL" 52 53 /* ####################### Set the log module name by Android property 54 * ########################## */ 55 #define PROP_NAME_NXPLOG_GLOBAL_LOGLEVEL "persist.vendor.uwb.nxp_log_level_global" 56 #define PROP_NAME_NXPLOG_EXTNS_LOGLEVEL "persist.vendor.uwb.nxp_log_level_extns" 57 #define PROP_NAME_NXPLOG_HAL_LOGLEVEL "persist.vendor.uwb.nxp_log_level_hal" 58 #define PROP_NAME_NXPLOG_UCI_LOGLEVEL "persist.vendor.uwb.nxp_log_level_uci" 59 #define PROP_NAME_NXPLOG_FWDNLD_LOGLEVEL "persist.vendor.uwb.nxp_log_level_dnld" 60 #define PROP_NAME_NXPLOG_TML_LOGLEVEL "persist.vendor.uwb.nxp_log_level_tml" 61 62 /* ####################### Set the logging level for EVERY COMPONENT here 63 * ######################## :START: */ 64 #define NXPLOG_LOG_SILENT_LOGLEVEL 0x00 65 #define NXPLOG_LOG_ERROR_LOGLEVEL 0x01 66 #define NXPLOG_LOG_WARN_LOGLEVEL 0x02 67 #define NXPLOG_LOG_DEBUG_LOGLEVEL 0x03 68 #define NXPLOG_LOG_VERBOSE_LOGLEVEL 0x04 69 /* ####################### Set the default logging level for EVERY COMPONENT 70 * here ########################## :END: */ 71 72 /* The Default log level for all the modules. */ 73 #define NXPLOG_DEFAULT_LOGLEVEL NXPLOG_LOG_ERROR_LOGLEVEL 74 75 /* ################################################################################################################ 76 */ 77 /* ############################################### Component Names 78 * ################################################ */ 79 /* ################################################################################################################ 80 */ 81 82 extern const char* NXPLOG_ITEM_EXTNS; /* Android logging tag for NxpExtns */ 83 extern const char* NXPLOG_ITEM_UCIHAL; /* Android logging tag for NxpUciHal */ 84 extern const char* NXPLOG_ITEM_UCIX; /* Android logging tag for NxpUciX */ 85 extern const char* NXPLOG_ITEM_UCIR; /* Android logging tag for NxpUciR */ 86 extern const char* NXPLOG_ITEM_FWDNLD; /* Android logging tag for NxpFwDnld */ 87 extern const char* NXPLOG_ITEM_TML; /* Android logging tag for NxpTml */ 88 89 #ifdef NXP_HCI_REQ 90 extern const char* NXPLOG_ITEM_HCPX; /* Android logging tag for NxpHcpX */ 91 extern const char* NXPLOG_ITEM_HCPR; /* Android logging tag for NxpHcpR */ 92 #endif /*NXP_HCI_REQ*/ 93 94 /* ######################################## Defines used for Logging data 95 * ######################################### */ 96 #ifdef NXP_VRBS_REQ 97 #define NXPLOG_FUNC_ENTRY(COMP) \ 98 LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "+:%s", (__func__)) 99 #define NXPLOG_FUNC_EXIT(COMP) \ 100 LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "-:%s", (__func__)) 101 #endif /*NXP_VRBS_REQ*/ 102 103 /* ################################################################################################################ 104 */ 105 /* ######################################## Logging APIs of actual modules 106 * ######################################## */ 107 /* ################################################################################################################ 108 */ 109 /* Logging APIs used by NxpExtns module */ 110 #if (ENABLE_EXTNS_TRACES == TRUE) 111 #define NXPLOG_EXTNS_D(...) \ 112 { \ 113 if ((gLog_level.extns_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 114 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 115 } 116 #define NXPLOG_EXTNS_W(...) \ 117 { \ 118 if ((gLog_level.extns_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 119 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 120 } 121 #define NXPLOG_EXTNS_E(...) \ 122 { \ 123 if (gLog_level.extns_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 124 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 125 } 126 #else 127 #define NXPLOG_EXTNS_D(...) 128 #define NXPLOG_EXTNS_W(...) 129 #define NXPLOG_EXTNS_E(...) 130 #endif /* Logging APIs used by NxpExtns module */ 131 132 /* Logging APIs used by NxpUciHal module */ 133 #if (ENABLE_HAL_TRACES == TRUE) 134 #define NXPLOG_UCIHAL_V(...) \ 135 { \ 136 if ((gLog_level.hal_log_level >= NXPLOG_LOG_VERBOSE_LOGLEVEL)) \ 137 LOG_PRI(ANDROID_LOG_VERBOSE, NXPLOG_ITEM_UCIHAL, __VA_ARGS__); \ 138 } 139 #define NXPLOG_UCIHAL_D(...) \ 140 { \ 141 if ((gLog_level.hal_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 142 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_UCIHAL, __VA_ARGS__); \ 143 } 144 #define NXPLOG_UCIHAL_W(...) \ 145 { \ 146 if ((gLog_level.hal_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 147 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_UCIHAL, __VA_ARGS__); \ 148 } 149 #define NXPLOG_UCIHAL_E(...) \ 150 { \ 151 if (gLog_level.hal_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 152 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_UCIHAL, __VA_ARGS__); \ 153 } 154 #else 155 #define NXPLOG_UCIHAL_V(...) 156 #define NXPLOG_UCIHAL_D(...) 157 #define NXPLOG_UCIHAL_W(...) 158 #define NXPLOG_UCIHAL_E(...) 159 #endif /* Logging APIs used by HAL module */ 160 161 /* Logging APIs used by NxpUciX module */ 162 #if (ENABLE_UCIX_TRACES == TRUE) 163 #define NXPLOG_UCIX_D(...) \ 164 { \ 165 if ((gLog_level.ucix_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 166 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_UCIX, __VA_ARGS__); \ 167 } 168 #define NXPLOG_UCIX_W(...) \ 169 { \ 170 if ((gLog_level.ucix_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 171 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_UCIX, __VA_ARGS__); \ 172 } 173 #define NXPLOG_UCIX_E(...) \ 174 { \ 175 if (gLog_level.ucix_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 176 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_UCIX, __VA_ARGS__); \ 177 } 178 #else 179 #define NXPLOG_UCIX_D(...) 180 #define NXPLOG_UCIX_W(...) 181 #define NXPLOG_UCIX_E(...) 182 #endif /* Logging APIs used by UCIx module */ 183 184 /* Logging APIs used by NxpUciR module */ 185 #if (ENABLE_UCIR_TRACES == TRUE) 186 #define NXPLOG_UCIR_D(...) \ 187 { \ 188 if ((gLog_level.ucir_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 189 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_UCIR, __VA_ARGS__); \ 190 } 191 #define NXPLOG_UCIR_W(...) \ 192 { \ 193 if ((gLog_level.ucir_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 194 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_UCIR, __VA_ARGS__); \ 195 } 196 #define NXPLOG_UCIR_E(...) \ 197 { \ 198 if (gLog_level.ucir_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 199 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_UCIR, __VA_ARGS__); \ 200 } 201 #else 202 #define NXPLOG_UCIR_D(...) 203 #define NXPLOG_UCIR_W(...) 204 #define NXPLOG_UCIR_E(...) 205 #endif /* Logging APIs used by UCIR module */ 206 207 /* Logging APIs used by NxpFwDnld module */ 208 #if (ENABLE_FWDNLD_TRACES == TRUE) 209 #define NXPLOG_FWDNLD_D(...) \ 210 { \ 211 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 212 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 213 } 214 #define NXPLOG_FWDNLD_W(...) \ 215 { \ 216 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 217 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 218 } 219 #define NXPLOG_FWDNLD_E(...) \ 220 { \ 221 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 222 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 223 } 224 #else 225 #define NXPLOG_FWDNLD_D(...) 226 #define NXPLOG_FWDNLD_W(...) 227 #define NXPLOG_FWDNLD_E(...) 228 #endif /* Logging APIs used by NxpFwDnld module */ 229 230 /* Logging APIs used by NxpTml module */ 231 #if (ENABLE_TML_TRACES == TRUE) 232 #define NXPLOG_TML_V(...) \ 233 { \ 234 if ((gLog_level.tml_log_level >= NXPLOG_LOG_VERBOSE_LOGLEVEL)) \ 235 LOG_PRI(ANDROID_LOG_VERBOSE, NXPLOG_ITEM_TML, __VA_ARGS__); \ 236 } 237 #define NXPLOG_TML_D(...) \ 238 { \ 239 if ((gLog_level.tml_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 240 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_TML, __VA_ARGS__); \ 241 } 242 #define NXPLOG_TML_W(...) \ 243 { \ 244 if ((gLog_level.tml_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 245 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_TML, __VA_ARGS__); \ 246 } 247 #define NXPLOG_TML_E(...) \ 248 { \ 249 if (gLog_level.tml_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 250 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_TML, __VA_ARGS__); \ 251 } 252 #else 253 #define NXPLOG_TML_V(...) 254 #define NXPLOG_TML_D(...) 255 #define NXPLOG_TML_W(...) 256 #define NXPLOG_TML_E(...) 257 #endif /* Logging APIs used by NxpTml module */ 258 259 #ifdef NXP_HCI_REQ 260 /* Logging APIs used by NxpHcpX module */ 261 #if (ENABLE_HCPX_TRACES == TRUE) 262 #define NXPLOG_HCPX_D(...) \ 263 { \ 264 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 265 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 266 } 267 #define NXPLOG_HCPX_W(...) \ 268 { \ 269 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 270 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 271 } 272 #define NXPLOG_HCPX_E(...) \ 273 { \ 274 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 275 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 276 } 277 #else 278 #define NXPLOG_HCPX_D(...) 279 #define NXPLOG_HCPX_W(...) 280 #define NXPLOG_HCPX_E(...) 281 #endif /* Logging APIs used by NxpHcpX module */ 282 283 /* Logging APIs used by NxpHcpR module */ 284 #if (ENABLE_HCPR_TRACES == TRUE) 285 #define NXPLOG_HCPR_D(...) \ 286 { \ 287 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 288 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 289 } 290 #define NXPLOG_HCPR_W(...) \ 291 { \ 292 if ((gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 293 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 294 } 295 #define NXPLOG_HCPR_E(...) \ 296 { \ 297 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 298 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 299 } 300 #else 301 #define NXPLOG_HCPR_D(...) 302 #define NXPLOG_HCPR_W(...) 303 #define NXPLOG_HCPR_E(...) 304 #endif /* Logging APIs used by NxpHcpR module */ 305 #endif /* NXP_HCI_REQ */ 306 307 #ifdef NXP_VRBS_REQ 308 #if (ENABLE_EXTNS_TRACES == TRUE) 309 #define NXPLOG_EXTNS_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_EXTNS) 310 #define NXPLOG_EXTNS_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_EXTNS) 311 #else 312 #define NXPLOG_EXTNS_ENTRY() 313 #define NXPLOG_EXTNS_EXIT() 314 #endif 315 316 #if (ENABLE_HAL_TRACES == TRUE) 317 #define NXPLOG_UCIHAL_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_UCIHAL) 318 #define NXPLOG_UCIHAL_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_UCIHAL) 319 #else 320 #define NXPLOG_UCIHAL_ENTRY() 321 #define NXPLOG_UCIHAL_EXIT() 322 #endif 323 324 #if (ENABLE_UCIX_TRACES == TRUE) 325 #define NXPLOG_UCIX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_UCIX) 326 #define NXPLOG_UCIX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_UCIX) 327 #else 328 #define NXPLOG_UCIX_ENTRY() 329 #define NXPLOG_UCIX_EXIT() 330 #endif 331 332 #if (ENABLE_UCIR_TRACES == TRUE) 333 #define NXPLOG_UCIR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_UCIR) 334 #define NXPLOG_UCIR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_UCIR) 335 #else 336 #define NXPLOG_UCIR_ENTRY() 337 #define NXPLOG_UCIR_EXIT() 338 #endif 339 340 #ifdef NXP_HCI_REQ 341 342 #if (ENABLE_HCPX_TRACES == TRUE) 343 #define NXPLOG_HCPX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPX) 344 #define NXPLOG_HCPX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPX) 345 #else 346 #define NXPLOG_HCPX_ENTRY() 347 #define NXPLOG_HCPX_EXIT() 348 #endif 349 350 #if (ENABLE_HCPR_TRACES == TRUE) 351 #define NXPLOG_HCPR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPR) 352 #define NXPLOG_HCPR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPR) 353 #else 354 #define NXPLOG_HCPR_ENTRY() 355 #define NXPLOG_HCPR_EXIT() 356 #endif 357 #endif /* NXP_HCI_REQ */ 358 359 #endif /* NXP_VRBS_REQ */ 360 361 void phNxpLog_InitializeLogLevel(void); 362 363 #endif /* NXPLOG__H_INCLUDED */ 364