1 /* 2 * Copyright 2010-2014, 2022-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 #include <phNfcStatus.h> 21 22 typedef struct nci_log_level { 23 uint8_t global_log_level; 24 uint8_t extns_log_level; 25 uint8_t hal_log_level; 26 uint8_t dnld_log_level; 27 uint8_t tml_log_level; 28 uint8_t ncix_log_level; 29 uint8_t ncir_log_level; 30 } nci_log_level_t; 31 32 /* global log level Ref */ 33 extern nci_log_level_t gLog_level; 34 extern bool nfc_debug_enabled; 35 /* define log module included when compile */ 36 #define ENABLE_EXTNS_TRACES TRUE 37 #define ENABLE_HAL_TRACES TRUE 38 #define ENABLE_TML_TRACES TRUE 39 #define ENABLE_FWDNLD_TRACES TRUE 40 #define ENABLE_NCIX_TRACES TRUE 41 #define ENABLE_NCIR_TRACES TRUE 42 43 #define ENABLE_HCPX_TRACES FALSE 44 #define ENABLE_HCPR_TRACES FALSE 45 46 /* ####################### Set the log module name in .conf file 47 * ########################## */ 48 #define NAME_NXPLOG_EXTNS_LOGLEVEL "NXPLOG_EXTNS_LOGLEVEL" 49 #define NAME_NXPLOG_NCIHAL_LOGLEVEL "NXPLOG_NCIHAL_LOGLEVEL" 50 #define NAME_NXPLOG_NCIX_LOGLEVEL "NXPLOG_NCIX_LOGLEVEL" 51 #define NAME_NXPLOG_NCIR_LOGLEVEL "NXPLOG_NCIR_LOGLEVEL" 52 #define NAME_NXPLOG_FWDNLD_LOGLEVEL "NXPLOG_FWDNLD_LOGLEVEL" 53 #define NAME_NXPLOG_TML_LOGLEVEL "NXPLOG_TML_LOGLEVEL" 54 55 /* ####################### Set the log module name by Android property 56 * ########################## */ 57 #define PROP_NAME_NXPLOG_GLOBAL_LOGLEVEL "nfc.nxp_log_level_global" 58 #define PROP_NAME_NXPLOG_EXTNS_LOGLEVEL "nfc.nxp_log_level_extns" 59 #define PROP_NAME_NXPLOG_NCIHAL_LOGLEVEL "nfc.nxp_log_level_hal" 60 #define PROP_NAME_NXPLOG_NCI_LOGLEVEL "nfc.nxp_log_level_nci" 61 #define PROP_NAME_NXPLOG_FWDNLD_LOGLEVEL "nfc.nxp_log_level_dnld" 62 #define PROP_NAME_NXPLOG_TML_LOGLEVEL "nfc.nxp_log_level_tml" 63 64 /* ####################### Set the logging level for EVERY COMPONENT here 65 * ######################## :START: */ 66 #define NXPLOG_LOG_SILENT_LOGLEVEL 0x00 67 #define NXPLOG_LOG_ERROR_LOGLEVEL 0x01 68 #define NXPLOG_LOG_WARN_LOGLEVEL 0x02 69 #define NXPLOG_LOG_INFO_LOGLEVEL 0x03 70 #define NXPLOG_LOG_DEBUG_LOGLEVEL 0x04 71 /* ####################### Set the default logging level for EVERY COMPONENT 72 * here ########################## :END: */ 73 74 /* The Default log level for all the modules. */ 75 #define NXPLOG_DEFAULT_LOGLEVEL NXPLOG_LOG_ERROR_LOGLEVEL 76 77 /* Enable/Disable Capturing SMB ntf to a file */ 78 #define NAME_NXP_SMBLOG_ENABLED "NXP_SMBLOG_ENABLED" 79 /* ################################################################################################################ 80 */ 81 /* ############################################### Component Names 82 * ################################################ */ 83 /* ################################################################################################################ 84 */ 85 86 extern const char* NXPLOG_ITEM_EXTNS; /* Android logging tag for NxpExtns */ 87 extern const char* NXPLOG_ITEM_NCIHAL; /* Android logging tag for NxpNciHal */ 88 extern const char* NXPLOG_ITEM_NCIX; /* Android logging tag for NxpNciX */ 89 extern const char* NXPLOG_ITEM_NCIR; /* Android logging tag for NxpNciR */ 90 extern const char* NXPLOG_ITEM_FWDNLD; /* Android logging tag for NxpFwDnld */ 91 extern const char* NXPLOG_ITEM_TML; /* Android logging tag for NxpTml */ 92 93 #ifdef NXP_HCI_REQ 94 extern const char* NXPLOG_ITEM_HCPX; /* Android logging tag for NxpHcpX */ 95 extern const char* NXPLOG_ITEM_HCPR; /* Android logging tag for NxpHcpR */ 96 #endif /*NXP_HCI_REQ*/ 97 98 /* ######################################## Defines used for Logging data 99 * ######################################### */ 100 #ifdef NXP_VRBS_REQ 101 #define NXPLOG_FUNC_ENTRY(COMP) \ 102 LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "+:%s", (__func__)) 103 #define NXPLOG_FUNC_EXIT(COMP) \ 104 LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "-:%s", (__func__)) 105 #endif /*NXP_VRBS_REQ*/ 106 107 /* ################################################################################################################ 108 */ 109 /* ######################################## Logging APIs of actual modules 110 * ######################################## */ 111 /* ################################################################################################################ 112 */ 113 /* Logging APIs used by NxpExtns module */ 114 #if (ENABLE_EXTNS_TRACES == TRUE) 115 #define NXPLOG_EXTNS_D(...) \ 116 { \ 117 if ((nfc_debug_enabled) || \ 118 (gLog_level.extns_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 119 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 120 } 121 #define NXPLOG_EXTNS_I(...) \ 122 { \ 123 if ((nfc_debug_enabled) || \ 124 (gLog_level.extns_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 125 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 126 } 127 #define NXPLOG_EXTNS_W(...) \ 128 { \ 129 if ((nfc_debug_enabled) || \ 130 (gLog_level.extns_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 131 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 132 } 133 #define NXPLOG_EXTNS_E(...) \ 134 { \ 135 if (gLog_level.extns_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 136 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \ 137 } 138 #else 139 #define NXPLOG_EXTNS_D(...) 140 #define NXPLOG_EXTNS_W(...) 141 #define NXPLOG_EXTNS_E(...) 142 #define NXPLOG_EXTNS_I(...) 143 #endif /* Logging APIs used by NxpExtns module */ 144 145 /* Logging APIs used by NxpNciHal module */ 146 #if (ENABLE_HAL_TRACES == TRUE) 147 #define NXPLOG_NCIHAL_D(...) \ 148 { \ 149 if ((nfc_debug_enabled) || \ 150 (gLog_level.hal_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 151 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \ 152 } 153 #define NXPLOG_NCIHAL_I(...) \ 154 { \ 155 if ((nfc_debug_enabled) || \ 156 (gLog_level.hal_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 157 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \ 158 } 159 #define NXPLOG_NCIHAL_W(...) \ 160 { \ 161 if ((nfc_debug_enabled) || \ 162 (gLog_level.hal_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 163 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \ 164 } 165 #define NXPLOG_NCIHAL_E(...) \ 166 { \ 167 if (gLog_level.hal_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 168 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \ 169 } 170 #else 171 #define NXPLOG_NCIHAL_D(...) 172 #define NXPLOG_NCIHAL_I(...) 173 #define NXPLOG_NCIHAL_W(...) 174 #define NXPLOG_NCIHAL_E(...) 175 #endif /* Logging APIs used by HAL module */ 176 177 /* Logging APIs used by NxpNciX module */ 178 #if (ENABLE_NCIX_TRACES == TRUE) 179 #define NXPLOG_NCIX_D(...) \ 180 { \ 181 if ((nfc_debug_enabled) || \ 182 (gLog_level.ncix_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 183 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIX, __VA_ARGS__); \ 184 } 185 #define NXPLOG_NCIX_I(...) \ 186 { \ 187 if ((nfc_debug_enabled) || \ 188 (gLog_level.ncix_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 189 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_NCIX, __VA_ARGS__); \ 190 } 191 #define NXPLOG_NCIX_W(...) \ 192 { \ 193 if ((nfc_debug_enabled) || \ 194 (gLog_level.ncix_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 195 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIX, __VA_ARGS__); \ 196 } 197 #define NXPLOG_NCIX_E(...) \ 198 { \ 199 if (gLog_level.ncix_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 200 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIX, __VA_ARGS__); \ 201 } 202 #else 203 #define NXPLOG_NCIX_D(...) 204 #define NXPLOG_NCIX_I(...) 205 #define NXPLOG_NCIX_W(...) 206 #define NXPLOG_NCIX_E(...) 207 #endif /* Logging APIs used by NCIx module */ 208 209 /* Logging APIs used by NxpNciR module */ 210 #if (ENABLE_NCIR_TRACES == TRUE) 211 #define NXPLOG_NCIR_D(...) \ 212 { \ 213 if ((nfc_debug_enabled) || \ 214 (gLog_level.ncir_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 215 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIR, __VA_ARGS__); \ 216 } 217 #define NXPLOG_NCIR_I(...) \ 218 { \ 219 if ((nfc_debug_enabled) || \ 220 (gLog_level.ncir_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 221 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_NCIR, __VA_ARGS__); \ 222 } 223 #define NXPLOG_NCIR_W(...) \ 224 { \ 225 if ((nfc_debug_enabled) || \ 226 (gLog_level.ncir_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 227 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIR, __VA_ARGS__); \ 228 } 229 #define NXPLOG_NCIR_E(...) \ 230 { \ 231 if (gLog_level.ncir_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 232 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIR, __VA_ARGS__); \ 233 } 234 #else 235 #define NXPLOG_NCIR_D(...) 236 #define NXPLOG_NCIR_I(...) 237 #define NXPLOG_NCIR_W(...) 238 #define NXPLOG_NCIR_E(...) 239 #endif /* Logging APIs used by NCIR module */ 240 241 /* Logging APIs used by NxpFwDnld module */ 242 #if (ENABLE_FWDNLD_TRACES == TRUE) 243 #define NXPLOG_FWDNLD_D(...) \ 244 { \ 245 if ((nfc_debug_enabled) || \ 246 (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 247 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 248 } 249 #define NXPLOG_FWDNLD_I(...) \ 250 { \ 251 if ((nfc_debug_enabled) || \ 252 (gLog_level.dnld_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 253 LOG_PRI(ANDROID_INFO_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 254 } 255 #define NXPLOG_FWDNLD_W(...) \ 256 { \ 257 if ((nfc_debug_enabled) || \ 258 (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 259 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 260 } 261 #define NXPLOG_FWDNLD_E(...) \ 262 { \ 263 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 264 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 265 } 266 #else 267 #define NXPLOG_FWDNLD_D(...) 268 #define NXPLOG_FWDNLD_I(...) 269 #define NXPLOG_FWDNLD_W(...) 270 #define NXPLOG_FWDNLD_E(...) 271 #endif /* Logging APIs used by NxpFwDnld module */ 272 273 /* Logging APIs used by NxpTml module */ 274 #if (ENABLE_TML_TRACES == TRUE) 275 #define NXPLOG_TML_D(...) \ 276 { \ 277 if ((nfc_debug_enabled) || \ 278 (gLog_level.tml_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 279 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_TML, __VA_ARGS__); \ 280 } 281 #define NXPLOG_TML_I(...) \ 282 { \ 283 if ((nfc_debug_enabled) || \ 284 (gLog_level.tml_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 285 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_TML, __VA_ARGS__); \ 286 } 287 #define NXPLOG_TML_W(...) \ 288 { \ 289 if ((nfc_debug_enabled) || \ 290 (gLog_level.tml_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 291 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_TML, __VA_ARGS__); \ 292 } 293 #define NXPLOG_TML_E(...) \ 294 { \ 295 if (gLog_level.tml_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 296 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_TML, __VA_ARGS__); \ 297 } 298 #else 299 #define NXPLOG_TML_D(...) 300 #define NXPLOG_TML_I(...) 301 #define NXPLOG_TML_W(...) 302 #define NXPLOG_TML_E(...) 303 #endif /* Logging APIs used by NxpTml module */ 304 305 #ifdef NXP_HCI_REQ 306 /* Logging APIs used by NxpHcpX module */ 307 #if (ENABLE_HCPX_TRACES == TRUE) 308 #define NXPLOG_HCPX_D(...) \ 309 { \ 310 if ((nfc_debug_enabled) || \ 311 (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 312 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 313 } 314 #define NXPLOG_HCPX_I(...) \ 315 { \ 316 if ((nfc_debug_enabled) || \ 317 (gLog_level.dnld_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 318 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 319 } 320 #define NXPLOG_HCPX_W(...) \ 321 { \ 322 if ((nfc_debug_enabled) || \ 323 (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 324 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 325 } 326 #define NXPLOG_HCPX_E(...) \ 327 { \ 328 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 329 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 330 } 331 #else 332 #define NXPLOG_HCPX_D(...) 333 #define NXPLOG_HCPX_I(...) 334 #define NXPLOG_HCPX_W(...) 335 #define NXPLOG_HCPX_E(...) 336 #endif /* Logging APIs used by NxpHcpX module */ 337 338 /* Logging APIs used by NxpHcpR module */ 339 #if (ENABLE_HCPR_TRACES == TRUE) 340 #define NXPLOG_HCPR_D(...) \ 341 { \ 342 if ((nfc_debug_enabled) || \ 343 (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL)) \ 344 LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 345 } 346 #define NXPLOG_HCPR_I(...) \ 347 { \ 348 if ((nfc_debug_enabled) || \ 349 (gLog_level.dnld_log_level >= NXPLOG_LOG_INFO_LOGLEVEL)) \ 350 LOG_PRI(ANDROID_LOG_INFO, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 351 } 352 #define NXPLOG_HCPR_W(...) \ 353 { \ 354 if ((nfc_debug_enabled) || \ 355 (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL)) \ 356 LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 357 } 358 #define NXPLOG_HCPR_E(...) \ 359 { \ 360 if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \ 361 LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \ 362 } 363 #else 364 #define NXPLOG_HCPR_D(...) 365 #define NXPLOG_HCPR_I(...) 366 #define NXPLOG_HCPR_W(...) 367 #define NXPLOG_HCPR_E(...) 368 #endif /* Logging APIs used by NxpHcpR module */ 369 #endif /* NXP_HCI_REQ */ 370 371 #ifdef NXP_VRBS_REQ 372 #if (ENABLE_EXTNS_TRACES == TRUE) 373 #define NXPLOG_EXTNS_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_EXTNS) 374 #define NXPLOG_EXTNS_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_EXTNS) 375 #else 376 #define NXPLOG_EXTNS_ENTRY() 377 #define NXPLOG_EXTNS_EXIT() 378 #endif 379 380 #if (ENABLE_HAL_TRACES == TRUE) 381 #define NXPLOG_NCIHAL_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIHAL) 382 #define NXPLOG_NCIHAL_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIHAL) 383 #else 384 #define NXPLOG_NCIHAL_ENTRY() 385 #define NXPLOG_NCIHAL_EXIT() 386 #endif 387 388 #if (ENABLE_NCIX_TRACES == TRUE) 389 #define NXPLOG_NCIX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIX) 390 #define NXPLOG_NCIX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIX) 391 #else 392 #define NXPLOG_NCIX_ENTRY() 393 #define NXPLOG_NCIX_EXIT() 394 #endif 395 396 #if (ENABLE_NCIR_TRACES == TRUE) 397 #define NXPLOG_NCIR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIR) 398 #define NXPLOG_NCIR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIR) 399 #else 400 #define NXPLOG_NCIR_ENTRY() 401 #define NXPLOG_NCIR_EXIT() 402 #endif 403 404 #ifdef NXP_HCI_REQ 405 406 #if (ENABLE_HCPX_TRACES == TRUE) 407 #define NXPLOG_HCPX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPX) 408 #define NXPLOG_HCPX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPX) 409 #else 410 #define NXPLOG_HCPX_ENTRY() 411 #define NXPLOG_HCPX_EXIT() 412 #endif 413 414 #if (ENABLE_HCPR_TRACES == TRUE) 415 #define NXPLOG_HCPR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPR) 416 #define NXPLOG_HCPR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPR) 417 #else 418 #define NXPLOG_HCPR_ENTRY() 419 #define NXPLOG_HCPR_EXIT() 420 #endif 421 #endif /* NXP_HCI_REQ */ 422 423 #endif /* NXP_VRBS_REQ */ 424 425 void phNxpLog_InitializeLogLevel(void); 426 427 #endif /* NXPLOG__H_INCLUDED */ 428