/* * Copyright (C) 2020-2022 MaxLinear, Inc. * Copyright (C) 2019-2020 Intel Corporation * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/. * * SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ #ifndef __INTEL_KERNEL_LOGGER #define __INTEL_KERNEL_LOGGER /*! \file intel_logger.h * \brief Single place where kernel logger macros for PP are defined. * \warning For security reasons printing filenames, line numbers and any internal info is prihibited! * \warning Do not use printk without logging level! */ #include //====================== LOGGING DEFINITIONS ======================= #define INTEL_EMERG_PRINTK(fmt, args...) pr_emerg( KBUILD_MODNAME " Emergency: " fmt, ## args) /*!< system is unusable */ #define INTEL_ALERT_PRINTK(fmt, args...) pr_alert( KBUILD_MODNAME " Alert: " fmt, ## args) /*!< action must be taken immediately */ #define INTEL_CRIT_PRINTK(fmt, args...) pr_crit( KBUILD_MODNAME " Critical: " fmt, ## args) /*!< critical conditions */ #define INTEL_ERR_PRINTK(fmt, args...) pr_err( KBUILD_MODNAME " Error: " fmt, ## args) /*!< error conditions */ #define INTEL_WARN_PRINTK(fmt, args...) pr_warn( KBUILD_MODNAME " Warn: " fmt, ## args) /*!< warning conditions */ #define INTEL_NOTE_PRINTK(fmt, args...) pr_notice( KBUILD_MODNAME " Note: " fmt, ## args) /*!< normal but significant condition */ #define INTEL_INFO_PRINTK(fmt, args...) pr_info( KBUILD_MODNAME " Info: " fmt, ## args) /*!< informational */ #define INTEL_DBG_PRINTK(fmt, args...) pr_debug( KBUILD_MODNAME " Dbg: " fmt, ## args) /*!< debug-level messages */ #define INTEL_CONT_PRINTK(fmt, args...) pr_cont( fmt, ## args) /*!< continue previous line */ #define INTEL_NEW_LINE_PRINTK() pr_debug( KBUILD_MODNAME ) /*!< new line @em only for debug messages */ /*! Print messages regardless of logging level. Allowed to use only when user requests and output (for example "status" command) */ #define INTEL_JUST_PRINTK(fmt, args...) printk( KBUILD_MODNAME ": " fmt, ## args) //====================== PP LOGGER DEFINITIONS ======================= /*! \def PP_LOG_LEVEL_TABLE(ENTRY) \brief X-MACRO hardcoded table for PP logger log levels declarations. \note In order to create a new log level in order to use EXT_PP_LOG or PP_LOG in hil driver, create a new line in the table and specify the new log level name. */ #define PP_LOG_LEVEL_TABLE( __ENTRY ) \ /* +-----------------------------+ */ \ /* | LL | | Name | */ \ /* +-----------------------------+ */ \ /* | 0 |*/ __ENTRY(HIL ) \ /* | 1 |*/ __ENTRY(TDOX ) \ /* | 2 |*/ __ENTRY(SCB ) \ /* | 3 |*/ __ENTRY(DGAF ) \ /* | 4 |*/ __ENTRY(MAPT ) \ /* | 5 |*/ __ENTRY(LOOKUP ) \ /* | 6 |*/ __ENTRY(MCAST ) \ /* | 7 |*/ __ENTRY(HAL ) \ /* | 8 |*/ __ENTRY(CORE ) \ /* | 9 |*/ __ENTRY(DB ) \ /* | 10 |*/ __ENTRY(QOS ) \ /* | 11 |*/ __ENTRY(TOE ) \ /* | 12 |*/ __ENTRY(SGC ) \ /* | 13 |*/ __ENTRY(SPDTST ) #define PP_LOG_CONCAT2(a, b) a ## b #define PP_LOG_LEVEL_TABLE_AS_ENUM( _enumName ) PP_LOG_CONCAT2(PP_LOG_LL_, _enumName), #define PP_LOG_STRINGIFY(x) #x #define PP_LOG_LEVEL_TABLE_AS_STRS( _enumName ) PP_LOG_STRINGIFY( _enumName ), /*! \def LOG_LEVEL_PREFIX_STRS \brief Creates a string array with PP logger prefix. \attention only use inside c file. */ #define LOG_LEVEL_PREFIX_STRS( _arrayName ) \ static const Char * _arrayName[] = \ { \ PP_LOG_LEVEL_TABLE(PP_LOG_LEVEL_TABLE_AS_STRS) \ NULL \ } /*! \def pp_logger_loglevel \brief Creates an enum out of pp logger log levels */ typedef enum pp_logger_loglevel { PP_LOG_LL_INVALID = -1, PP_LOG_LEVEL_TABLE(PP_LOG_LEVEL_TABLE_AS_ENUM) PP_LOG_LL_MAX } pp_logger_loglevel_e; #define EXT_PP_LOG_MSG_MAX_SIZE (200) typedef struct { pp_logger_loglevel_e loglevel; char log_msg[EXT_PP_LOG_MSG_MAX_SIZE]; } ext_pp_log_msg_t; #ifdef CONFIG_PP_DEBUG_API_OTHER /* EXT_PP_LOG is a macro used by pp driver or any pp depended driver */ #define EXT_PP_LOG(loglvl, fmt, args...) \ do \ { \ if (avalanche_pp_get_log_level_status( \ PP_LOG_CONCAT2(PP_LOG_LL_, loglvl))) \ { \ ext_pp_log_msg_t log; \ log.loglevel = PP_LOG_CONCAT2(PP_LOG_LL_, loglvl); \ snprintf(log.log_msg, EXT_PP_LOG_MSG_MAX_SIZE, fmt, ##args); \ ti_hil_pp_event(TI_PP_LOG_ADD_ENTRY, &log); \ } \ } while (0) #else #define EXT_PP_LOG(fmt, args...) #endif #endif //__INTEL_KERNEL_LOGGER