ETHFW API Guide
Ethernet Firmware Trace API

Introduction

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:

  • Function prefix: <func>: string
  • File and line number prefix: <func>: <line>: string
  • File, line number and function prefix: <file>: <line>: <func>: string

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:

  • Bits 31:28 - Module's major number (see ETHFW_TRACE_MOD_ID)
  • Bits 27:20 - Module's minor number (see ETHFW_TRACE_MOD_ID)
  • Bits 19:8 - Line number where error was reported
  • Bits 7:0 - Status value (positive value)
Major Number Module File location ------—
1 ETHFW Server ethremotecfg/server
2 ETHFW Client ethremotecfg/client
3 ETHFW Common Utils utils/ethfw_common
4 Board Library utils/board
5 Other Utils utils/*
6 Server App apps/app_remoteswitchcfg_server
7 Client App apps/app_remoteswitchcfg_client

Each individual source file in the locations shown in previous table is considered a module and is tagged with a unique ETHFW_TRACE_MOD_ID, denoting the module's major (4-bit) and minor (16-bit) numbers.

#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...
 

Macro Definition Documentation

◆ ETHFW_CFG_TRACE_LINE_TERM

#define ETHFW_CFG_TRACE_LINE_TERM   "\n"

Line terminator to be used by all EthFwTrace macros.

◆ ETHFW_CFG_PRINT_BUF_LEN

#define ETHFW_CFG_PRINT_BUF_LEN   (1024U)

Trace print buffer length.

◆ ETHFW_CFG_TRACE_LEVEL_NONE

#define ETHFW_CFG_TRACE_LEVEL_NONE   (0U)

All traces disabled at build-time.

◆ ETHFW_CFG_TRACE_LEVEL_ERROR

#define ETHFW_CFG_TRACE_LEVEL_ERROR   (1U)

Build-time error level.

◆ ETHFW_CFG_TRACE_LEVEL_WARN

#define ETHFW_CFG_TRACE_LEVEL_WARN   (2U)

Build-time warning level.

◆ ETHFW_CFG_TRACE_LEVEL_INFO

#define ETHFW_CFG_TRACE_LEVEL_INFO   (3U)

Build-time information level.

◆ ETHFW_CFG_TRACE_LEVEL_DEBUG

#define ETHFW_CFG_TRACE_LEVEL_DEBUG   (4U)

Build-time debug level.

◆ ETHFW_CFG_TRACE_LEVEL_VERBOSE

#define ETHFW_CFG_TRACE_LEVEL_VERBOSE   (5U)

Build-time verbose level.

◆ ETHFW_CFG_TRACE_FORMAT_DFLT

#define ETHFW_CFG_TRACE_FORMAT_DFLT   (0U)

Trace prefix: "<mod>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FUNC

#define ETHFW_CFG_TRACE_FORMAT_FUNC   (1U)

Trace prefix: "<func>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FILE

#define ETHFW_CFG_TRACE_FORMAT_FILE   (2U)

Trace prefix: "<file>: <line>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FULL

#define ETHFW_CFG_TRACE_FORMAT_FULL   (3U)

Trace prefix: "<file>: <line>: <func>: string".

◆ ETHFW_CFG_TRACE_FORMAT_DFLT_TS

#define ETHFW_CFG_TRACE_FORMAT_DFLT_TS   (4U)

Trace prefix: "<timestamp>: <mod>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FUNC_TS

#define ETHFW_CFG_TRACE_FORMAT_FUNC_TS   (5U)

Trace prefix: "<timestamp>: <func>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FILE_TS

#define ETHFW_CFG_TRACE_FORMAT_FILE_TS   (6U)

Trace prefix: "<timestamp>: <file>: <line>: string".

◆ ETHFW_CFG_TRACE_FORMAT_FULL_TS

#define ETHFW_CFG_TRACE_FORMAT_FULL_TS   (7U)

Trace prefix: "<timestamp>: <file>: <line>: <func>: string".

◆ ETHFW_CFG_TRACE_LEVEL

#define ETHFW_CFG_TRACE_LEVEL   (ETHFW_CFG_TRACE_LEVEL_INFO)

Default trace level if none is set.

◆ ETHFW_CFG_TRACE_FORMAT

#define ETHFW_CFG_TRACE_FORMAT   (ETHFW_CFG_TRACE_FORMAT_DFLT)

Default trace format if none is specified.

◆ ETHFW_TRACE_ERRCODE_MOD_OFFSET

#define ETHFW_TRACE_ERRCODE_MOD_OFFSET   (20U)

Module id offset in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MAJ_OFFSET

#define ETHFW_TRACE_ERRCODE_MOD_MAJ_OFFSET   (28U)

Module id (major number) offset in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MIN_OFFSET

#define ETHFW_TRACE_ERRCODE_MOD_MIN_OFFSET   (20U)

Module id (minor number) offset in the error code value.

◆ ETHFW_TRACE_ERRCODE_LINE_OFFSET

#define ETHFW_TRACE_ERRCODE_LINE_OFFSET   (8U)

Line number offset in the error code value.

◆ ETHFW_TRACE_ERRCODE_STATUS_OFFSET

#define ETHFW_TRACE_ERRCODE_STATUS_OFFSET   (0U)

Status offset in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MASK

#define ETHFW_TRACE_ERRCODE_MOD_MASK   (0xFFF00000U)

Module id mask in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MAJ_MASK

#define ETHFW_TRACE_ERRCODE_MOD_MAJ_MASK   (0xF0000000U)

Module id (major number) mask in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MIN_MASK

#define ETHFW_TRACE_ERRCODE_MOD_MIN_MASK   (0x0FF00000U)

Module id (minor number) mask in the error code value.

◆ ETHFW_TRACE_ERRCODE_LINE_MASK

#define ETHFW_TRACE_ERRCODE_LINE_MASK   (0x000FFF00U)

Line number mask in the error code value.

◆ ETHFW_TRACE_ERRCODE_STATUS_MASK

#define ETHFW_TRACE_ERRCODE_STATUS_MASK   (0x000000FFU)

Status mask in the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD

#define ETHFW_TRACE_ERRCODE_MOD (   x)
Value:
#define ETHFW_TRACE_ERRCODE_MOD_OFFSET
Module id offset in the error code value.
Definition: ethfw_trace.h:198
#define ETHFW_TRACE_ERRCODE_MOD_MASK
Module id mask in the error code value.
Definition: ethfw_trace.h:213

Helper macro to extract the module id from the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MAJ

#define ETHFW_TRACE_ERRCODE_MOD_MAJ (   x)
Value:
#define ETHFW_TRACE_ERRCODE_MOD_MAJ_OFFSET
Module id (major number) offset in the error code value.
Definition: ethfw_trace.h:201
#define ETHFW_TRACE_ERRCODE_MOD_MAJ_MASK
Module id (major number) mask in the error code value.
Definition: ethfw_trace.h:216

Helper macro to extract the module id (major number) from the error code value.

◆ ETHFW_TRACE_ERRCODE_MOD_MIN

#define ETHFW_TRACE_ERRCODE_MOD_MIN (   x)
Value:
#define ETHFW_TRACE_ERRCODE_MOD_MIN_MASK
Module id (minor number) mask in the error code value.
Definition: ethfw_trace.h:219
#define ETHFW_TRACE_ERRCODE_MOD_MIN_OFFSET
Module id (minor number) offset in the error code value.
Definition: ethfw_trace.h:204

Helper macro to extract the module id (minor number) from the error code value.

◆ ETHFW_TRACE_ERRCODE_LINE

#define ETHFW_TRACE_ERRCODE_LINE (   x)
Value:
#define ETHFW_TRACE_ERRCODE_LINE_MASK
Line number mask in the error code value.
Definition: ethfw_trace.h:222
#define ETHFW_TRACE_ERRCODE_LINE_OFFSET
Line number offset in the error code value.
Definition: ethfw_trace.h:207

Helper macro to extract the line number from the error code value.

◆ ETHFW_TRACE_ERRCODE_STATUS

#define ETHFW_TRACE_ERRCODE_STATUS (   x)
Value:
#define ETHFW_TRACE_ERRCODE_STATUS_OFFSET
Status offset in the error code value.
Definition: ethfw_trace.h:210
#define ETHFW_TRACE_ERRCODE_STATUS_MASK
Status mask in the error code value.
Definition: ethfw_trace.h:225

Helper macro to extract the status value from the error code value.

◆ ETHFWTRACE_MOD_NAME

#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".

◆ ETHFWTRACE_trace

#define ETHFWTRACE_trace (   globalLevel,
  level,
  status,
  fmt,
  ... 
)
Value:
EthFwTrace_trace((globalLevel), (level), ETHFWTRACE_MOD_ID, \
__FILE__, __LINE__, __func__, (status), \
"%s: " fmt, \
ETHFWTRACE_MOD_NAME, ## __VA_ARGS__)
#define ETHFWTRACE_MOD_NAME
Trace module name.
Definition: ethfw_trace.h:265
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.

Trace prefix type.

◆ ETHFWTRACE_errTrace

#define ETHFWTRACE_errTrace (   globalLevel,
  level,
  status,
  fmt,
  ... 
)
Value:
EthFwTrace_trace((globalLevel), (level), ETHFWTRACE_MOD_ID, \
__FILE__, __LINE__, __func__, (status), \
"%s: %s: " fmt, \
ETHFWTRACE_MOD_NAME, __func__, ## __VA_ARGS__)
#define ETHFWTRACE_MOD_NAME
Trace module name.
Definition: ethfw_trace.h:265
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.

◆ ETHFWTRACE_ERR

#define ETHFWTRACE_ERR (   status,
  fmt,
  ... 
)
Value:
status, \
fmt, \
## __VA_ARGS__)
#define ETHFWTRACE_errTrace(globalLevel, level, status, fmt,...)
Definition: ethfw_trace.h:279
Definition: ethfw_trace.h:474
EthFwTrace_TraceLevel gEthFwTrace_runtimeLevel
Runtime log level.

Helper macro to add trace message with ETHFW_TRACE_ERROR level.

◆ ETHFWTRACE_ERR_IF

#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.

◆ ETHFWTRACE_WARN

#define ETHFWTRACE_WARN (   fmt,
  ... 
)
Value:
0U, \
fmt, \
## __VA_ARGS__)
#define ETHFWTRACE_trace(globalLevel, level, status, fmt,...)
Trace prefix type.
Definition: ethfw_trace.h:273
Definition: ethfw_trace.h:477
EthFwTrace_TraceLevel gEthFwTrace_runtimeLevel
Runtime log level.

Helper macro to add trace message with ETHFW_TRACE_WARN level.

◆ ETHFWTRACE_WARN_IF

#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.

◆ ETHFWTRACE_INFO

#define ETHFWTRACE_INFO (   fmt,
  ... 
)
Value:
0U, \
fmt, \
## __VA_ARGS__)
Definition: ethfw_trace.h:484
#define ETHFWTRACE_trace(globalLevel, level, status, fmt,...)
Trace prefix type.
Definition: ethfw_trace.h:273
EthFwTrace_TraceLevel gEthFwTrace_runtimeLevel
Runtime log level.

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.

◆ ETHFWTRACE_INFO_IF

#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.

◆ ETHFWTRACE_DBG

#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.

◆ ETHFWTRACE_DBG_IF

#define ETHFWTRACE_DBG_IF (   cond,
  ... 
)

◆ ETHFWTRACE_VERBOSE

#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.

◆ ETHFWTRACE_VERBOSE_IF

#define ETHFWTRACE_VERBOSE_IF (   cond,
  ... 
)

◆ ETHFWTRACE_VAR

#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 Documentation

◆ EthFwTrace_Print

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.

◆ EthFwTrace_TraceTsFunc

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.

◆ EthFwTrace_ExtTraceFunc

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.

Enumeration Type Documentation

◆ EthFwTrace_TraceLevel

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.

Function Documentation

◆ EthFwTrace_init()

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).

Parameters
cfgTrace configuration parameters
Returns
ETHFW_SOK if trace functionality was correctly initialized, or a negative error in case of failure.

◆ EthFwTrace_deinit()

void EthFwTrace_deinit ( void  )

Deinitialize ETHFW trace functionality.

Deinitializes trace functionality. No trace macros or functions should be called after deinitialization is done.

◆ EthFwTrace_setLevel()

EthFwTrace_TraceLevel EthFwTrace_setLevel ( EthFwTrace_TraceLevel  level)

Set runtime trace level.

Set the Ethetnet Firmware's runtime trace level.

Parameters
levelTrace level to be enabled
Returns
Previous trace level

◆ EthFwTrace_getLevel()

EthFwTrace_TraceLevel EthFwTrace_getLevel ( void  )

Get runtime trace level.

Get the Ethernet Firmware's runtime trace level.

Returns
Current trace level

◆ EthFwTrace_setTsFunc()

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.

Parameters
funcTrace timestamping function

◆ EthFwTrace_setExtTraceFunc()

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.

Parameters
funcExtended trace callback function

◆ EthFwTrace_print()

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.

Parameters
fmtPrint string

◆ EthFwTrace_trace()

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.

Parameters
globalLevelTrace module global level
levelTrace level intended to be logged
modModule id
fileFile name
lineLine number
funcFunction name
statusStatus code (see EthFwTrace_ErrorCode).
fmtPrint string

Variable Documentation

◆ gEthFwTrace_runtimeLevel

EthFwTrace_TraceLevel gEthFwTrace_runtimeLevel

Runtime log level.