ETHFW API Guide
|
Data Structures | |
struct | EthFwTrace_Cfg |
EthFw trace configuration parameters. More... | |
Functions | |
int32_t | EthFwTrace_init (const EthFwTrace_Cfg *cfg) |
Initialize ETHFW trace functionality. More... | |
void | EthFwTrace_deinit (void) |
Deinitialize ETHFW trace functionality. More... | |
EthFwTrace_TraceLevel | EthFwTrace_setLevel (EthFwTrace_TraceLevel level) |
Set runtime trace level. More... | |
EthFwTrace_TraceLevel | EthFwTrace_getLevel (void) |
Get runtime trace level. More... | |
void | EthFwTrace_setTsFunc (EthFwTrace_TraceTsFunc func) |
Set trace timestamp function. More... | |
void | EthFwTrace_setExtTraceFunc (EthFwTrace_ExtTraceFunc func) |
Set extended trace funtion. More... | |
void | EthFwTrace_print (const char *fmt,...) |
Print a message. More... | |
void | EthFwTrace_trace (EthFwTrace_TraceLevel globalLevel, EthFwTrace_TraceLevel level, uint32_t mod, const char *file, uint32_t line, const char *func, uint32_t status, const char *fmt,...) |
Log a trace message if log level is enabled. More... | |
Variables | |
EthFwTrace_TraceLevel | gEthFwTrace_runtimeLevel |
Runtime log level. More... | |
Typedefs | |
typedef void(* | EthFwTrace_Print) (const char *format,...) |
Print function used for traces. More... | |
typedef uint64_t(* | EthFwTrace_TraceTsFunc) (void) |
Callback function used to get trace timestamps. More... | |
typedef void(* | EthFwTrace_ExtTraceFunc) (uint32_t errCode) |
Callback function called to report errors. More... | |
Enumerations | |
enum | EthFwTrace_TraceLevel { ETHFW_TRACE_NONE = 0U, ETHFW_TRACE_ERROR = 1U, ETHFW_TRACE_WARN = 2U, ETHFW_TRACE_INFO = 3U, ETHFW_TRACE_DEBUG = 4U, ETHFW_TRACE_VERBOSE = 5U } |
Enumerates the types of trace level. More... | |
Macros | |
#define | ETHFW_CFG_TRACE_LINE_TERM "\n" |
Line terminator to be used by all EthFwTrace macros. More... | |
#define | ETHFW_CFG_PRINT_BUF_LEN (1024U) |
Trace print buffer length. More... | |
Build-Time Trace Levels | |
Ethernet Firmware supports two types of trace levels: build-time and runtime. Build time trace level is specified via ETHFW_CFG_TRACE_LEVEL and can be any of the levels in this group. The runtime trace level is set through EthFwTrace_setLevel(). The runtime trace level should be set equal to or less than the build-time trace level. | |
#define | ETHFW_CFG_TRACE_LEVEL_NONE (0U) |
All traces disabled at build-time. More... | |
#define | ETHFW_CFG_TRACE_LEVEL_ERROR (1U) |
Build-time error level. More... | |
#define | ETHFW_CFG_TRACE_LEVEL_WARN (2U) |
Build-time warning level. More... | |
#define | ETHFW_CFG_TRACE_LEVEL_INFO (3U) |
Build-time information level. More... | |
#define | ETHFW_CFG_TRACE_LEVEL_DEBUG (4U) |
Build-time debug level. More... | |
#define | ETHFW_CFG_TRACE_LEVEL_VERBOSE (5U) |
Build-time verbose level. More... | |
Trace Formats | |
The following trace formats are supported:
Any of these trace formats can also be prefixed with a timestamp. | |
#define | ETHFW_CFG_TRACE_FORMAT_DFLT (0U) |
Trace prefix: "<mod>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FUNC (1U) |
Trace prefix: "<func>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FILE (2U) |
Trace prefix: "<file>: <line>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FULL (3U) |
Trace prefix: "<file>: <line>: <func>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_DFLT_TS (4U) |
Trace prefix: "<timestamp>: <mod>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FUNC_TS (5U) |
Trace prefix: "<timestamp>: <func>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FILE_TS (6U) |
Trace prefix: "<timestamp>: <file>: <line>: string". More... | |
#define | ETHFW_CFG_TRACE_FORMAT_FULL_TS (7U) |
Trace prefix: "<timestamp>: <file>: <line>: <func>: string". More... | |
EthFw Trace Configuration Parameters | |
The default values of the EthFw Trace configuration parameters if none is provided. | |
#define | ETHFW_CFG_TRACE_LEVEL (ETHFW_CFG_TRACE_LEVEL_INFO) |
Default trace level if none is set. More... | |
#define | ETHFW_CFG_TRACE_FORMAT (ETHFW_CFG_TRACE_FORMAT_DFLT) |
Default trace format if none is specified. More... | |
Ethernet Firmware Trace Error Code | |||||||||||||||||||||||||
EthFw Trace is capable of generating unique error codes from module id (CpswProxy, VEPA, VLAN, etc), line number (where error code was detected) and status (error value reported by the module). The error code is a 32-bit value which is generated as follows:
Each individual source file in the locations shown in previous table is considered a module and is tagged with a unique | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_OFFSET (20U) | ||||||||||||||||||||||||
Module id offset in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MAJ_OFFSET (28U) | ||||||||||||||||||||||||
Module id (major number) offset in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MIN_OFFSET (20U) | ||||||||||||||||||||||||
Module id (minor number) offset in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_LINE_OFFSET (8U) | ||||||||||||||||||||||||
Line number offset in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_STATUS_OFFSET (0U) | ||||||||||||||||||||||||
Status offset in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MASK (0xFFF00000U) | ||||||||||||||||||||||||
Module id mask in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MAJ_MASK (0xF0000000U) | ||||||||||||||||||||||||
Module id (major number) mask in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MIN_MASK (0x0FF00000U) | ||||||||||||||||||||||||
Module id (minor number) mask in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_LINE_MASK (0x000FFF00U) | ||||||||||||||||||||||||
Line number mask in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_STATUS_MASK (0x000000FFU) | ||||||||||||||||||||||||
Status mask in the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD(x) | ||||||||||||||||||||||||
Helper macro to extract the module id from the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MAJ(x) | ||||||||||||||||||||||||
Helper macro to extract the module id (major number) from the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_MOD_MIN(x) | ||||||||||||||||||||||||
Helper macro to extract the module id (minor number) from the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_LINE(x) | ||||||||||||||||||||||||
Helper macro to extract the line number from the error code value. More... | |||||||||||||||||||||||||
#define | ETHFW_TRACE_ERRCODE_STATUS(x) | ||||||||||||||||||||||||
Helper macro to extract the status value from the error code value. More... | |||||||||||||||||||||||||
EthFw Trace Macros | |
Macros used throughout Ethernet Firmware modules to log/trace errors, warnings, info and debug messages. | |
#define | ETHFWTRACE_MOD_NAME "ETHFW" |
Trace module name. More... | |
#define | ETHFWTRACE_trace(globalLevel, level, status, fmt, ...) |
Trace prefix type. More... | |
#define | ETHFWTRACE_errTrace(globalLevel, level, status, fmt, ...) |
#define | ETHFWTRACE_ERR(status, fmt, ...) |
Helper macro to add trace message with ETHFW_TRACE_ERROR level. More... | |
#define | ETHFWTRACE_ERR_IF(cond, ...) ((cond) ? ETHFWTRACE_ERR(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_ERROR level if a condition is met. More... | |
#define | ETHFWTRACE_WARN(fmt, ...) |
Helper macro to add trace message with ETHFW_TRACE_WARN level. More... | |
#define | ETHFWTRACE_WARN_IF(cond, ...) ((cond) ? ETHFWTRACE_WARN(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_WARN level if a condition is met. More... | |
#define | ETHFWTRACE_INFO(fmt, ...) |
Helper macro to add trace message with ETHFW_TRACE_INFO level. More... | |
#define | ETHFWTRACE_INFO_IF(cond, ...) ((cond) ? ETHFWTRACE_INFO(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_INFO level if a condition is met. More... | |
#define | ETHFWTRACE_DBG(fmt, ...) |
Helper macro to add trace message with ETHFW_TRACE_DEBUG level. More... | |
#define | ETHFWTRACE_DBG_IF(cond, ...) |
#define | ETHFWTRACE_VERBOSE(fmt, ...) |
Helper macro to add trace message with ETHFW_TRACE_VERBOSE level. More... | |
#define | ETHFWTRACE_VERBOSE_IF(cond, ...) |
#define | ETHFWTRACE_VAR(var) ((var) = (var)) |
Variable declaration helper macro to avoid unused variable error (-Werror=unused-variable) when variable is used in TRACE and when corresponding trace level is not enabled. More... | |
#define ETHFW_CFG_TRACE_LINE_TERM "\n" |
Line terminator to be used by all EthFwTrace macros.
#define ETHFW_CFG_PRINT_BUF_LEN (1024U) |
Trace print buffer length.
#define ETHFW_CFG_TRACE_LEVEL_NONE (0U) |
All traces disabled at build-time.
#define ETHFW_CFG_TRACE_LEVEL_ERROR (1U) |
Build-time error level.
#define ETHFW_CFG_TRACE_LEVEL_WARN (2U) |
Build-time warning level.
#define ETHFW_CFG_TRACE_LEVEL_INFO (3U) |
Build-time information level.
#define ETHFW_CFG_TRACE_LEVEL_DEBUG (4U) |
Build-time debug level.
#define ETHFW_CFG_TRACE_LEVEL_VERBOSE (5U) |
Build-time verbose level.
#define ETHFW_CFG_TRACE_FORMAT_DFLT (0U) |
Trace prefix: "<mod>: string".
#define ETHFW_CFG_TRACE_FORMAT_FUNC (1U) |
Trace prefix: "<func>: string".
#define ETHFW_CFG_TRACE_FORMAT_FILE (2U) |
Trace prefix: "<file>: <line>: string".
#define ETHFW_CFG_TRACE_FORMAT_FULL (3U) |
Trace prefix: "<file>: <line>: <func>: string".
#define ETHFW_CFG_TRACE_FORMAT_DFLT_TS (4U) |
Trace prefix: "<timestamp>: <mod>: string".
#define ETHFW_CFG_TRACE_FORMAT_FUNC_TS (5U) |
Trace prefix: "<timestamp>: <func>: string".
#define ETHFW_CFG_TRACE_FORMAT_FILE_TS (6U) |
Trace prefix: "<timestamp>: <file>: <line>: string".
#define ETHFW_CFG_TRACE_FORMAT_FULL_TS (7U) |
Trace prefix: "<timestamp>: <file>: <line>: <func>: string".
#define ETHFW_CFG_TRACE_LEVEL (ETHFW_CFG_TRACE_LEVEL_INFO) |
Default trace level if none is set.
#define ETHFW_CFG_TRACE_FORMAT (ETHFW_CFG_TRACE_FORMAT_DFLT) |
Default trace format if none is specified.
#define ETHFW_TRACE_ERRCODE_MOD_OFFSET (20U) |
Module id offset in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MAJ_OFFSET (28U) |
Module id (major number) offset in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MIN_OFFSET (20U) |
Module id (minor number) offset in the error code value.
#define ETHFW_TRACE_ERRCODE_LINE_OFFSET (8U) |
Line number offset in the error code value.
#define ETHFW_TRACE_ERRCODE_STATUS_OFFSET (0U) |
Status offset in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MASK (0xFFF00000U) |
Module id mask in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MAJ_MASK (0xF0000000U) |
Module id (major number) mask in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MIN_MASK (0x0FF00000U) |
Module id (minor number) mask in the error code value.
#define ETHFW_TRACE_ERRCODE_LINE_MASK (0x000FFF00U) |
Line number mask in the error code value.
#define ETHFW_TRACE_ERRCODE_STATUS_MASK (0x000000FFU) |
Status mask in the error code value.
#define ETHFW_TRACE_ERRCODE_MOD | ( | x | ) |
Helper macro to extract the module id from the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MAJ | ( | x | ) |
Helper macro to extract the module id (major number) from the error code value.
#define ETHFW_TRACE_ERRCODE_MOD_MIN | ( | x | ) |
Helper macro to extract the module id (minor number) from the error code value.
#define ETHFW_TRACE_ERRCODE_LINE | ( | x | ) |
Helper macro to extract the line number from the error code value.
#define ETHFW_TRACE_ERRCODE_STATUS | ( | x | ) |
Helper macro to extract the status value from the error code value.
#define ETHFWTRACE_MOD_NAME "ETHFW" |
Trace module name.
Trace module name which can be set individually per source code file by defining it before this header file is included. If not defined, it will default to "ETHFW".
#define ETHFWTRACE_trace | ( | globalLevel, | |
level, | |||
status, | |||
fmt, | |||
... | |||
) |
Trace prefix type.
#define ETHFWTRACE_errTrace | ( | globalLevel, | |
level, | |||
status, | |||
fmt, | |||
... | |||
) |
#define ETHFWTRACE_ERR | ( | status, | |
fmt, | |||
... | |||
) |
Helper macro to add trace message with ETHFW_TRACE_ERROR level.
#define ETHFWTRACE_ERR_IF | ( | cond, | |
... | |||
) | ((cond) ? ETHFWTRACE_ERR(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_ERROR level if a condition is met.
#define ETHFWTRACE_WARN | ( | fmt, | |
... | |||
) |
Helper macro to add trace message with ETHFW_TRACE_WARN level.
#define ETHFWTRACE_WARN_IF | ( | cond, | |
... | |||
) | ((cond) ? ETHFWTRACE_WARN(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_WARN level if a condition is met.
#define ETHFWTRACE_INFO | ( | fmt, | |
... | |||
) |
Helper macro to add trace message with ETHFW_TRACE_INFO level.
Traces with this level should give only important informational messages to the user, which typically they don't occur very often (i.e. "NIMU is ready", "PHY n link is up"). This trace level may be enabled by default.
#define ETHFWTRACE_INFO_IF | ( | cond, | |
... | |||
) | ((cond) ? ETHFWTRACE_INFO(__VA_ARGS__) : 0U) |
Helper macro to add trace message with ETHFW_TRACE_INFO level if a condition is met.
#define ETHFWTRACE_DBG | ( | fmt, | |
... | |||
) |
Helper macro to add trace message with ETHFW_TRACE_DEBUG level.
Traces with this level will provide the user further information about operations taking place in Ethernet Firmware.
#define ETHFWTRACE_DBG_IF | ( | cond, | |
... | |||
) |
#define ETHFWTRACE_VERBOSE | ( | fmt, | |
... | |||
) |
Helper macro to add trace message with ETHFW_TRACE_VERBOSE level.
Traces with this level will provide even more information and much more often than the DEBUG level.
Enabling this trace level is likely going to flood with messages, so developers must ensure that their debug messages that occur often enough are set with VERBOSE level.
#define ETHFWTRACE_VERBOSE_IF | ( | cond, | |
... | |||
) |
#define ETHFWTRACE_VAR | ( | var | ) | ((var) = (var)) |
Variable declaration helper macro to avoid unused variable error (-Werror=unused-variable) when variable is used in TRACE and when corresponding trace level is not enabled.
typedef void(* EthFwTrace_Print) (const char *format,...) |
Print function used for traces.
Trace print callback function. It must be provided by application at init time.
typedef uint64_t(* EthFwTrace_TraceTsFunc) (void) |
Callback function used to get trace timestamps.
Callback function called when ETHFW_CFG_TRACE_FORMAT is set to ETHFW_CFG_TRACE_FORMAT_DFLT_TS, ETHFW_CFG_TRACE_FORMAT_FUNC_TS, ETHFW_CFG_TRACE_FORMAT_FILE_TS or ETHFW_CFG_TRACE_FORMAT_FULL_TS.
The timestamp value must be in microseconds.
typedef void(* EthFwTrace_ExtTraceFunc) (uint32_t errCode) |
Callback function called to report errors.
Callback function called by EthFwTrace when an error has been reported by any module in Ethernet Firmware. A unique 32-bit error code is passed to the callback, which encodes information about the module where error occurred, line of code and the status value.
Application can use the helper macros ETHFW_TRACE_ERRCODE_MOD, ETHFW_TRACE_ERRCODE_MOD_MAJ, ETHFW_TRACE_ERRCODE_MOD_MIN, ETHFW_TRACE_ERRCODE_LINE and ETHFW_TRACE_ERRCODE_STATUS to decode the error code.
Enumerates the types of trace level.
Enumerator | |
---|---|
ETHFW_TRACE_NONE | All traces are disabled at runtime |
ETHFW_TRACE_ERROR | Error trace level |
ETHFW_TRACE_WARN | Warning trace level |
ETHFW_TRACE_INFO | Info trace level: enables only important informational messages for the user. The amount of info logs is not invasive in nature so this trace level may be enabled at init time. |
ETHFW_TRACE_DEBUG | Debug trace level: enables further information messages about operations taking place in Ethernet Firmware. The debug level should be enabled by the user on a need basis (i.e. for debugging or tracing execution flow, etc) as the number of messages will increase considerably with respect to ETHFW_TRACE_INFO level. This trace level should be enabled at runtime only in debug builds. |
ETHFW_TRACE_VERBOSE | Verbose trace level: enables even further messages about operations taking place in Ethernet Firmware that are periodic in nature or simply happen very often during normal execution. The amount of messages will increase drastically when the verbose level is enabled, so it's recommended to set it only if really needed. This trace level should be enabled at runtime only in debug builds. |
int32_t EthFwTrace_init | ( | const EthFwTrace_Cfg * | cfg | ) |
Initialize ETHFW trace functionality.
Initializes ETHFW trace functionality with the provided callback functions, including the function used to print traces for logging purpose, timestamp provider and an extended trace function which can be used to log errors for tracing purposes (i.e. breadcrum of unique error codes).
cfg | Trace configuration parameters |
void EthFwTrace_deinit | ( | void | ) |
Deinitialize ETHFW trace functionality.
Deinitializes trace functionality. No trace macros or functions should be called after deinitialization is done.
EthFwTrace_TraceLevel EthFwTrace_setLevel | ( | EthFwTrace_TraceLevel | level | ) |
Set runtime trace level.
Set the Ethetnet Firmware's runtime trace level.
level | Trace level to be enabled |
EthFwTrace_TraceLevel EthFwTrace_getLevel | ( | void | ) |
Get runtime trace level.
Get the Ethernet Firmware's runtime trace level.
void EthFwTrace_setTsFunc | ( | EthFwTrace_TraceTsFunc | func | ) |
Set trace timestamp function.
Sets the function to be used to timestamp EthFw traces. The timestamp values returned by this function must be in microseconds. If application provides a NULL function pointer, all traces will have a timestamp value of 0.
The timestamping function will be called only when ETHFW_CFG_TRACE_FORMAT is set to ETHFW_CFG_TRACE_FORMAT_DFLT_TS, ETHFW_CFG_TRACE_FORMAT_FUNC_TS, ETHFW_CFG_TRACE_FORMAT_FILE_TS or ETHFW_CFG_TRACE_FORMAT_FULL_TS.
func | Trace timestamping function |
void EthFwTrace_setExtTraceFunc | ( | EthFwTrace_ExtTraceFunc | func | ) |
Set extended trace funtion.
Sets the extended trace function called when any module in Ethernet Firmware has reported an error. A 32-bit unique error code is passed to this callback function.
func | Extended trace callback function |
void EthFwTrace_print | ( | const char * | fmt, |
... | |||
) |
Print a message.
Print messages using common print function provided at EthFwTrace_init() via EthFwTrace_Cfg::print.
This function can be provided as the print function for drivers such as Enet or UDMA.
fmt | Print string |
void EthFwTrace_trace | ( | EthFwTrace_TraceLevel | globalLevel, |
EthFwTrace_TraceLevel | level, | ||
uint32_t | mod, | ||
const char * | file, | ||
uint32_t | line, | ||
const char * | func, | ||
uint32_t | status, | ||
const char * | fmt, | ||
... | |||
) |
Log a trace message if log level is enabled.
Log trace messages for log levels that are enabled at runtime.
globalLevel | Trace module global level |
level | Trace level intended to be logged |
mod | Module id |
file | File name |
line | Line number |
func | Function name |
status | Status code (see EthFwTrace_ErrorCode). |
fmt | Print string |
EthFwTrace_TraceLevel gEthFwTrace_runtimeLevel |
Runtime log level.