# TRACE
[DEBUG]

Trace buffer debug module. More...

Collaboration diagram for TRACE:

## Defines
#define | TRACE_HEADER_LEN 4
| Size of trace header (in 16bits words).
#define | TRACE_MAX_PARAM 0xff
| Maximum number of parameter in one trace entry.
#define | TRACE_MAX_ID 0xffffff
| Maximum ID of a trace entry.
#define | TRACE_LEN(i) (((i) >> 8) + TRACE_HEADER_LEN)
| Return size (in 16bits words) of the trace entry whose first word is `i`.
#define | TRACE_LAST_ENTRY 0xffff
| Pattern to mark last trace entry.
#define | TRACE_READY 0x1234
| Pattern to mark than trace buffer is ready.
#define | TRACE_LOCKED 0xdead
| Pattern to mark than trace buffer is being read or write.
#define | TRACE(a,...)
| Macro used to add a unfiltered trace point in the trace buffer.
#define | TRACE_BUF(format, size, buf)
| Macro used to add a unfiltered trace containing a dump of a buffer in the trace buffer.
#define | TR_32(a) (uint16_t)((uint32_t)(a) >> 16), (uint16_t)((uint32_t)(a))
| Macro to trace a 32bits parameters.
#define | TR_64(a) TR_32(((uint64_t)(a) >> 32)), TR_32(a)
| Macro to trace a 64bits parameters.
#define | TR_PTR(p) TR_32(p)
| Macro to trace a pointer.
#define | TR_MAC(m) ((uint16_t *)(m))[0], ((uint16_t *)(m))[1], ((uint16_t *)(m))[2]
| Macro to trace a MAC address.
#define | TR_IP4(m) TR_32(*((uint32_t *)m))
| Macro to trace a IPv4 address.
#define | TR_IP6(m)
| Macro to trace a IPv6 address.
#define | _PTR_ALIGN(p) ((uint16_t *)((uint32_t)p & ~0x1))
| internal
#define | TR_STR_8(s)
| Macro to trace a string.
#define | TRACE_FILT(compo, lvl,...)
| Acts like TRACE macro if bit `lvl` is set in trace level for `compo`.
#define | TRACE_BUF_FILT(compo, lvl,...)
| Acts like TRACE_BUF macro if bit `lvl` is set in trace level for `compo`.
#define | TRACE_COMPO(compo) NX_TRACE && TRACE_##compo##_EN
| Macro defining whether a trace component should be compiled or not.
#define | TRACE_KERNEL_DEFAULT
| Default trace level for KERNEL component.
#define | TRACE_KERNEL_EN 1
| Define whether to include or not KERNEL traces.
#define | TRACE_KERNEL(lvl,...) TRACE_FILT(KERNEL, KERNEL_##lvl, __VA_ARGS__ )
| add trace point for KERNEL component
#define | TRACE_BUF_KERNEL(lvl,...) TRACE_BUF_FILT(KERNEL, KERNEL_##lvl, __VA_ARGS__ )
| add buffer trace point for KERNEL component
#define | TRACE_LMAC_DEFAULT (CO_BIT(TRACE_LVL_LMAC_ERR))
| Default trace level for LMAC component.
#define | TRACE_LMAC_EN 1
| Define whether to include or not LMAC traces.
#define | TRACE_LMAC(lvl,...) TRACE_FILT(LMAC, LMAC_##lvl, __VA_ARGS__ )
| add trace point for LMAC component
#define | TRACE_BUF_LMAC(lvl,...) TRACE_BUF_FILT(LMAC, LMAC_##lvl, __VA_ARGS__ )
| add buffer trace point for LMAC component
#define | TRACE_CHAN_DEFAULT
| Default trace level for CHAN component.
#define | TRACE_CHAN_EN 1
| Define whether to include or not CHAN traces.
#define | TRACE_CHAN(lvl,...) TRACE_FILT(CHAN, CHAN_##lvl, __VA_ARGS__ )
| add trace point for CHAN component
#define | TRACE_BUF_CHAN(lvl,...) TRACE_BUF_FILT(CHAN, CHAN_##lvl, __VA_ARGS__ )
| add buffer trace point for CHAN component
#define | TRACE_STA_DEFAULT (CO_BIT(TRACE_LVL_STA_ERR))
| Default trace level for STA component.
#define | TRACE_STA_EN 1
| Define whether to include or not STA traces.
#define | TRACE_STA(lvl,...) TRACE_FILT(STA, STA_##lvl, __VA_ARGS__ )
| add trace point for STA component
#define | TRACE_BUF_STA(lvl,...) TRACE_BUF_FILT(STA, STA_##lvl, __VA_ARGS__ )
| add buffer trace point for STA component
#define | TRACE_AP_DEFAULT (CO_BIT(TRACE_LVL_AP_ERR))
| Default trace level for AP component.
#define | TRACE_AP_EN 1
| Define whether to include or not AP traces.
#define | TRACE_AP(lvl,...) TRACE_FILT(AP, AP_##lvl, __VA_ARGS__ )
| add trace point for AP component
#define | TRACE_BUF_AP(lvl,...) TRACE_BUF_FILT(AP, AP_##lvl, __VA_ARGS__ )
| add buffer trace point for AP component
#define | TRACE_P2P_DEFAULT (CO_BIT(TRACE_LVL_P2P_ERR))
| Default trace level for P2P component.
#define | TRACE_P2P_EN 1
| Define whether to include or not P2P traces.
#define | TRACE_P2P(lvl,...) TRACE_FILT(P2P, P2P_##lvl, __VA_ARGS__ )
| add trace point for P2P component
#define | TRACE_BUF_P2P(lvl,...) TRACE_BUF_FILT(P2P, P2P_##lvl, __VA_ARGS__ )
| add buffer trace point for P2P component
#define | TRACE_MESH_DEFAULT (CO_BIT(TRACE_LVL_MESH_ERR))
| Default trace level for MESH component.
#define | TRACE_MESH_EN 1
| Define whether to include or not MESH traces.
#define | TRACE_MESH(lvl,...) TRACE_FILT(MESH, MESH_##lvl, __VA_ARGS__ )
| add trace point for MESH component
#define | TRACE_BUF_MESH(lvl,...) TRACE_BUF_FILT(MESH, MESH_##lvl, __VA_ARGS__ )
| add buffer trace point for MESH component
#define | TRACE_RTOS_DEFAULT
| Default trace level for RTOS component.
#define | TRACE_RTOS_EN 1
| Define whether to include or not RTOS traces.
#define | TRACE_RTOS(lvl,...) TRACE_FILT(RTOS, RTOS_##lvl, __VA_ARGS__ )
| add trace point for RTOS component
#define | TRACE_BUF_RTOS(lvl,...) TRACE_BUF_FILT(RTOS, RTOS_##lvl, __VA_ARGS__ )
| add buffer trace point for RTOS component
#define | TRACE_FHOST_DEFAULT (CO_BIT(TRACE_LVL_FHOST_ERR))
| Default trace level for FHOST component.
#define | TRACE_FHOST_EN 1
| Define whether to include or not FHOST traces.
#define | TRACE_FHOST(lvl,...) TRACE_FILT(FHOST, FHOST_##lvl, __VA_ARGS__ )
| add trace point for FHOST component
#define | TRACE_BUF_FHOST(lvl,...) TRACE_BUF_FILT(FHOST, FHOST_##lvl, __VA_ARGS__ )
| add buffer trace point for RTOS component
#define | TRACE_APP_DEFAULT (CO_BIT(TRACE_LVL_APP_ERR))
| Default trace level for APP component.
#define | TRACE_APP_EN 1
| Define whether to include or not APP traces.
#define | TRACE_APP(lvl,...) TRACE_FILT(APP, APP_##lvl, __VA_ARGS__ )
| add trace point for APP component
#define | TRACE_BUF_APP(lvl,...) TRACE_BUF_FILT(APP, APP_##lvl, __VA_ARGS__ )
| add buffer trace point for APP component
#define | TRACE_TDLS_DEFAULT
| Default trace level for TDLS component.
#define | TRACE_TDLS_EN 1
| Define whether to include or not TDLS traces.
#define | TRACE_TDLS(lvl,...) TRACE_FILT(TDLS, TDLS_##lvl, __VA_ARGS__ )
| add trace point for TDLS component
#define | TRACE_BUF_TDLS(lvl,...) TRACE_BUF_FILT(TDLS, TDLS_##lvl, __VA_ARGS__ )
| add buffer trace point for TDLS component
## Enumerations
enum | trace_compo { TRACE_COMPO_KERNEL, TRACE_COMPO_LMAC, TRACE_COMPO_CHAN, TRACE_COMPO_STA, TRACE_COMPO_AP, TRACE_COMPO_P2P, TRACE_COMPO_MESH, TRACE_COMPO_RTOS, TRACE_COMPO_FHOST, TRACE_COMPO_APP, TRACE_COMPO_TDLS, TRACE_COMPO_MAX }
| Filterable trace component. More...
enum | trace_level_kernel { TRACE_LVL_KERNEL_ERR, TRACE_LVL_KERNEL_MSG_API, TRACE_LVL_KERNEL_MSG_LOCAL, TRACE_LVL_KERNEL_STATE }
| Specific filter for KERNEL component. More...
enum | trace_level_lmac { TRACE_LVL_LMAC_ERR, TRACE_LVL_LMAC_TX, TRACE_LVL_LMAC_RX, TRACE_LVL_LMAC_RX_ALL, TRACE_LVL_LMAC_DOZE, TRACE_LVL_LMAC_BA, TRACE_LVL_LMAC_TPC }
| Specific filter for LMAC. More...
enum | trace_level_chan { TRACE_LVL_CHAN_ERR, TRACE_LVL_CHAN_INF, TRACE_LVL_CHAN_CREATE, TRACE_LVL_CHAN_SWITCH, TRACE_LVL_CHAN_STATUS, TRACE_LVL_CHAN_CON_LESS, TRACE_LVL_CHAN_NOA, TRACE_LVL_CHAN_TBTT }
| Specific filter for Channel context. More...
enum | trace_level_sta { TRACE_LVL_STA_ERR, TRACE_LVL_STA_BCN, TRACE_LVL_STA_PS }
| Specific filter for STA component. More...
enum | trace_level_ap { TRACE_LVL_AP_ERR, TRACE_LVL_AP_BCN, TRACE_LVL_AP_PS }
| Specific filter for AP component. More...
enum | trace_level_p2p { TRACE_LVL_P2P_ERR, TRACE_LVL_P2P_ITF, TRACE_LVL_P2P_PS, TRACE_LVL_P2P_NOA, TRACE_LVL_P2P_NOA_DET, TRACE_LVL_P2P_TBTT }
| Specific filter for P2P component. More...
enum | trace_level_mesh { TRACE_LVL_MESH_ERR, TRACE_LVL_MESH_INF, TRACE_LVL_MESH_PS, TRACE_LVL_MESH_SP, TRACE_LVL_MESH_AWIN, TRACE_LVL_MESH_SLEEP, TRACE_LVL_MESH_RX, TRACE_LVL_MESH_BCN_RX, TRACE_LVL_MESH_BCN_TX, TRACE_LVL_MESH_POST_TRAFFIC, TRACE_LVL_MESH_HWMP, TRACE_LVL_MESH_MPATH, TRACE_LVL_MESH_MPM, TRACE_LVL_MESH_TBTT }
| Specific filter for MESH component. More...
enum | trace_level_rtos { TRACE_LVL_RTOS_ERR, TRACE_LVL_RTOS_ALLOC, TRACE_LVL_RTOS_FREE, TRACE_LVL_RTOS_CREATE, TRACE_LVL_RTOS_SUSPEND, TRACE_LVL_RTOS_SWITCH_IN, TRACE_LVL_RTOS_SWITCH_OUT }
| Specific filter for RTOS component. More...
enum | trace_level_fhost { TRACE_LVL_FHOST_ERR, TRACE_LVL_FHOST_WPA_FSM, TRACE_LVL_FHOST_WPA_CMD, TRACE_LVL_FHOST_WPA_INFO, TRACE_LVL_FHOST_DHCP, TRACE_LVL_FHOST_TASK_INIT, TRACE_LVL_FHOST_SMARTCONF }
| Specific filter for FHOST component. More...
enum | trace_level_app { TRACE_LVL_APP_ERR, TRACE_LVL_APP_WARN, TRACE_LVL_APP_INF, TRACE_LVL_APP_DBG }
| Specific filter for FHOST APPLICATION component. More...
enum | trace_level_tdls { TRACE_LVL_TDLS_ERR, TRACE_LVL_TDLS_CHSWITCH }
| Specific filter for TDLS component. More...
## Functions
void | trace_init (bool force, bool loop)
| Initialize trace buffer.
void | trace (uint32_t id, uint16_t nb_param, uint16_t *param, bool trace_buf)
| Add a trace point in the buffer.
void | trace_set_filter (unsigned int compo_id, unsigned int level)
| Modify trace level on a given component.
## Variables
static bool | trace_initialized = false
| Global variable indicating if trace buffer has been initialized.
static bool | trace_loop = false
| Global variable indicating if trace buffer must be used as a circular buffer.
uint16_t | _trace_start
uint16_t | _trace_end
uint32_t | trace_compo_level [TRACE_COMPO_MAX]
| Trace filter for each component.
uint32_t | trace_compo_level [TRACE_COMPO_MAX]
| Current trace filters status.

## Detailed Description

Trace buffer debug module.

Trace module is enabled when fw is compiled with TRACE=on option.

Trace module is using a buffer located in shared ram, to store trace event form fw. A trace entry is optimized to only contains IDs and parameters, instead of complete string. This IDs and parameters can then be decoded using dictionary generated at compilation time.

A trace entry in memory looks like :

     *  15       8 7        0
     * +---------------------+ --+
     * | NB PARAM |  ID MSB  |   |
     * +---------------------+   |
     * |       ID LSB        |   |
     * +---------------------+   +--> header (fixed size)
     * | TIMESTAMP  MSB      |   |
     * +---------------------+   |
     * | TIMESTAMP  LSB      |   |
     * +---------------------+ --+
     * | PARAM(1)            |   |
     * +---------------------+   |
     *    ....                   +--> parameters (variable size)
     * +---------------------+   |
     * | PARAM(x)            |   |
     * +---------------------+ --+
     *

Trace buffer is defined by _trace_start and _trace_end whose value is defined in linker script in order to use all the remaining shared ram.

Usage:
You can add:

- an unfiltered trace point using TRACE macro for printf like trace and TRACE_BUF to trace a buffer.
- a filterable trace point (i.e. can can be disabled/enabled at run-time) using the TRACE_FILT or TRACE_BUF_FILT macros.

Unfiltered trace points are always traced.
A filterable trace point is traced if the bit of the trace point level is set in the current filter for the component. See trace_level_<compo> for trace level specific to a given component.

You can then use trace_set_filter to change the current filter of a given component. As trace_compo_level is stored in shared_memory Host can also directy modify its content.

Filterable Components:

To define a new filterable component "compo", in file trace_compo.h:

- Defined a new value TRACE_COMPO_<COMPO> in the trace_compo enum.

- set its default trace level in trace_compo_level, initialized in trace_init function.

- Defined a new enum name trace_level_<compo> with filters specific to this component.
  All name must start with the TRACE_LVL_<COMPO> prefix.
  Although not mandatory, it is good practice to define the first filter as error (so that enabling level 1 on all components enable all error traces).
  It is also good practice to add a small comment to describe which kind of traces are controlled by this filter.

- Defined specific macro TRACE_<COMPO> that call the generic TRACE_FILT macro. (You could directly use TRACE_FILT in the code but don't do that)
  Defining a specific macro:
- Makes the code more compact (compared to calling TRACE_FILT directly).
- Allows to easily remove all traces from one component at compilation, usually using a TRACE_<COMPO>_EN macro.

Note:
  trace_compo.h is parsed during compilation to extract list of components and filters. To avoid parsing issue try to re-use the same format as other component when adding a new one.

## Define Documentation

#define TR_32 | ( | a |  | ) | (uint16_t)((uint32_t)(a) >> 16), (uint16_t)((uint32_t)(a))

Macro to trace a 32bits parameters.

To be used with %ld, %lu, %lx, %lX format

Parameters:

  `[in]` | a | A 32bit value

Definition at line 258 of file trace.h.

Referenced by chan_add_next_tbtt(), chan_fix_ctxt_until(), chan_schedule_extra_switch_to_p2pgo_ctxt(), chan_schedule_one_switch(), chan_schedule_switch_from_p2pgo_ctxt(), chan_schedule_switch_to_p2pgo_ctxt(), chan_start_p2pgo_noa(), chan_tx_cfm(), p2p_cli_noa_get_abs_time(), p2p_cli_noa_start(), and p2p_noa_timer_prog().

#define TR_64 | ( | a |  | ) | TR_32(((uint64_t)(a) >> 32)), TR_32(a)

Macro to trace a 64bits parameters.

To be used with %lld, %llu, %llx, %llX format

Parameters:

  `[in]` | a | A 64bit value

Definition at line 268 of file trace.h.

#define TR_IP4 | ( | m |  | ) | TR_32(*((uint32_t *)m))

Macro to trace a IPv4 address.

To be used with %pI4 format

Parameters:

  `[in]` | m | Address on an IPv4 address (Not the ip address as 32bit value)

Definition at line 298 of file trace.h.

#define TR_IP6 | ( | m |  | ) |

Value:

    ((uint16_t *)(m))[0], ((uint16_t *)(m))[1], ((uint16_t *)(m))[2] \
            ((uint16_t *)(m))[3], ((uint16_t *)(m))[4], ((uint16_t *)(m))[5] \
            ((uint16_t *)(m))[6], ((uint16_t *)(m))[7]

Macro to trace a IPv6 address.

To be used with %pI6, %ipI6c format

Parameters:

  `[in]` | m | Address on an IPv6 address

Definition at line 308 of file trace.h.

#define TR_MAC | ( | m |  | ) | ((uint16_t *)(m))[0], ((uint16_t *)(m))[1], ((uint16_t *)(m))[2]

Macro to trace a MAC address.

To be used with %pM format

Parameters:

  `[in]` | m | Address on a MAC address

Definition at line 288 of file trace.h.

#define TR_PTR | ( | p |  | ) | TR_32(p)

Macro to trace a pointer.

To be used with %p format

Parameters:

  `[in]` | p | A 32bit address

Definition at line 278 of file trace.h.

#define TR_STR_8 | ( | s |  | ) |

Value:

    (0x0800 + (uint16_t)((uint32_t)(s) & 0x1)) ,  \
            _PTR_ALIGN(s)[0], _PTR_ALIGN(s)[1],                       \
            _PTR_ALIGN(s)[2], _PTR_ALIGN(s)[3]

Macro to trace a string.

To be used with %s format. Trace only the 8 first characters of the string

Note:
  Using this macro will always store 8bytes in the trace buffer, and decoder will stop as soon as it read 8 characters or '' is found.

Definition at line 342 of file trace.h.

#define TRACE | ( | a,
|  | ... |  | ) |

Value:

    {                                               \
            uint16_t __p[] = { __VA_ARGS__ };                            \
            trace((TRACE_FILE_ID << 16) +  __LINE__ , sizeof(__p)/sizeof(__p[0]), __p, false); \
        }

Macro used to add a unfiltered trace point in the trace buffer.

It should be called with a printf like protoype, and will generate an unique trace id based of file and line number.
TRACE_FILE_ID is passed on the compilation line and is different for each file.

Current format string supported by the decoder are:

- For character :
  use format %c and pass directly the character as parameter

      TRACE("first char is %c", string[0])

- For 16bits value :
  Use one of the following format %d, %u, %x, %X and pass directly the value as parameter.

      TRACE("this is a 16bit value %d", myval)

  It is also possible to add formatting option

      TRACE("this is a 16bit value 0x%04x", myval)

- For 32bits value :
  Use one of the following format %ld, %lu, %lx, %lX and pass the value using TR_32 macro.

      TRACE("this is a 32bit value 0x%08lx", TR_32(myval))

- For a string :
  Use format %s and pass string using TR_STR_8 macro.

      TRACE("SSID = %s", TR_STR_8(param->ssid))

  Note:
    As implied by the name, string are currently limited to 8 characters.
- For a pointer :
  Use format %p and pass the value using TR_PTR macro.

      TRACE("buffer address is %p", TR_PTR(buffer))

  Note:
    %p is actually just a shortcut for %08lx
- For a MAC address :
  Use format %pM and pass the value using TR_MAC macro.

      TRACE("vif mac = %pM", TR_MAC(mac_addr))

- For a file name :
  Use format %F and pass TRACE_FILE_ID as parameter

      TRACE("Error in file %F", TRACE_FILE_ID)

- For ke_msg_id_t :
  Use format %kM and pass the message id directly. Using this format it just like a simple 16bits value, but it also indicates the decoder to translate the message id into its real name (if found inside the dictionary).

      TRACE("msg received is receive [%kM]", msg_id)
         => msg received is [MM_VERSION_REQ]

- For ke_task_id_t :
  Use format %kT and pass the task id directly. Using this format it just like a simple 16bits value, but it also indicates the decoder to translate the task id into its real name (if found inside the dictionary) and index.

      TRACE("send message to task [%kT]", msg_id)
         => send message to task [ME(0)]

- For ke_state_t :
  Use format %kS and pass both the task id and the state index. Using this format is like tracing 2 16bits value, but it also indicates the decoder to translate these values into a task name and a state name. (task id is needed because state enum is specific to each task).

      TRACE("set [%kS]", task_id, state)
         => set SCANU(0):SCANU_IDLE

- For a timestamp :
  Use format %t and pass the timestamp value as a 32bits value in microsecond (same format as returned by hal_machw_time). The decoder will format the timestamp value like the timestamp of the trace (i.e. <s>.<ms>_<us>) and will show the delta between the timestamp parameter and the timestamp of the trace.

      TRACE("Timer set at %t", TR_32(timer_date))
         => Timer set at @23.234_789 (+25.35 ms)

- For a Frame Control :
  Use format %fc and pass the value as a 16bits value. The decoder will parse this value as a frame control field (as found in MAC header)

      TRACE("Received frame: %fc", mac_hdr->fctl)
         => Received frame: Association response

- For a IPv4 address :
  Use format %pI4 and pass the value using TR_IP4 macro.

      TRACE("ip = %pI4", TR_IP4(ip4_addr))

- For a IPv6 address :
  Use format %pI6 or %pI6c and pass the value using TR_IP6 macro.

      TRACE("ipv6 = %pI6", TR_IP6(ip6_addr))

Definition at line 182 of file trace.h.

#define TRACE_BUF | ( | format,
|  | size,
|  | buf |  | ) |

Value:

    {                                  \
            uint16_t __p[] = {(uint16_t)(size), (uint16_t)((uint32_t)buf),  \
                              (uint16_t)(((uint32_t)buf) >> 16)};           \
            uint16_t __size = 1 + (size + 1 + ((uint32_t)buf & 0x1)) / 2;   \
            trace((TRACE_FILE_ID << 16) + __LINE__, __size, __p, true);     \
        }

Macro used to add a unfiltered trace containing a dump of a buffer in the trace buffer.

It will generate an unique trace id based of file and line number.
TRACE_FILE_ID is passed on the compilation line and is different for each file.

The format string supported by the decoder is:
pB(F)?(number_of_characters)?(word_size)?(representation)?

- number_of_characters :
  optional group indicating the number of words to print in one line.
  Default value : 8

      TRACE_BUF("my_buf: %pB4", my_buf_len, my_buf);
         => my_buf: 00 10 00 20
                    40 FF 00 1A

- word_size :
  Optional group indication the size of a word.
  Default value : b
  Possible values:
  1. b: byte
  2. h: half-word(16 bits)
  3. w: word(32 bits)

         TRACE_BUF("my_buf: %pB4h", my_buf_len, my_buf);
            => my_buf: 0010 0020 40FF 001A

- representation :
  Optional group indicating the print format of a word
  Default value: x
  Possible values:
  1. d: decimal
  2. x: hexadecimal
  3. c: char

         TRACE_BUF("my_buf: %pB4hd", my_buf_len, my_buf);
            => my_buf: 16 32 16639 26

- 802.11 Frame:
  If format %pBF is used (instead of only %pB), then the decoder will treat the buffer as a 802.11 frame. It will then parse the MAC header and dump the rest of the frame just like any other buffer using number_of_characters/word_size/representation parameters if set.

      TRACE_BUF("received frame: %pBF12bx", my_buf_len, my_buf);
         => received frame: Authentication Dur=60us Seq=1322 frag=0
                            A1=aa:06:cc:dd:ee:fe A2=c4:04:15:3d:41:e8 A3=c4:04:15:3d:41:e8
                            00 00 02 00 00 00 dd 09 00 10 18 02
                            00 00 1c 00 00

Parameters:

  `[in]` | format | string specifying how to interpret the data
  `[in]` | size | size of the buffer in bytes (independent from number_of_characters in the conversion specification)
  `[in]` | buf | buffer to dump

Definition at line 243 of file trace.h.

#define TRACE_BUF_FILT | ( | compo,
|  | lvl,
|  | ... |  | ) |

Value:

    if (trace_compo_level[TRACE_COMPO_##compo] & CO_BIT(TRACE_LVL_##lvl)) { \
            TRACE_BUF(__VA_ARGS__) }

Acts like TRACE_BUF macro if bit `lvl` is set in trace level for `compo`.

Does nothing otherwise.

Parameters:

  `[in]` | compo | Name of the component from trace_compo. TRACE_COMPO_ prefix should be omitted.
  `[in]` | lvl | Trace level form one of trace_level_... enum. TRACE_LVL_ prefix should be omitted

Definition at line 371 of file trace.h.

#define TRACE_CHAN_DEFAULT

Value:

    (CO_BIT(TRACE_LVL_CHAN_ERR) | \
                                CO_BIT(TRACE_LVL_CHAN_INF))

Default trace level for CHAN component.

Definition at line 177 of file trace_compo.h.

#define TRACE_FILT | ( | compo,
|  | lvl,
|  | ... |  | ) |

Value:

    if (trace_compo_level[TRACE_COMPO_##compo] & CO_BIT(TRACE_LVL_##lvl)) { \
            TRACE(__VA_ARGS__) }

Acts like TRACE macro if bit `lvl` is set in trace level for `compo`.

Does nothing otherwise.

Parameters:

  `[in]` | compo | Name of the component from trace_compo. TRACE_COMPO_ prefix should be omitted.
  `[in]` | lvl | Trace level form one of trace_level_... enum. TRACE_LVL_ prefix should be omitted

Definition at line 358 of file trace.h.

#define TRACE_KERNEL_DEFAULT

Value:

    (CO_BIT(TRACE_LVL_KERNEL_ERR) |            \
                                  CO_BIT(TRACE_LVL_KERNEL_MSG_API) |        \
                                  CO_BIT(TRACE_LVL_KERNEL_MSG_LOCAL))

Default trace level for KERNEL component.

Definition at line 97 of file trace_compo.h.

#define TRACE_RTOS_DEFAULT

Value:

    (CO_BIT(TRACE_LVL_RTOS_ERR) |                     \
                                CO_BIT(TRACE_LVL_RTOS_CREATE))

Default trace level for RTOS component.

Definition at line 364 of file trace_compo.h.

#define TRACE_TDLS_DEFAULT

Value:

    (CO_BIT(TRACE_LVL_TDLS_ERR)| \
                                CO_BIT(TRACE_LVL_TDLS_CHSWITCH))

Default trace level for TDLS component.

Definition at line 463 of file trace_compo.h.

## Enumeration Type Documentation

enum trace_compo

Filterable trace component.

Definition at line 56 of file trace_compo.h.

enum trace_level_ap

Specific filter for AP component.

Enumerator:

  TRACE_LVL_AP_ERR | Error.
  TRACE_LVL_AP_BCN | Beacon transmitted on AP interfaces.
  TRACE_LVL_AP_PS | PS traffic requested/sent by/to connected STA.

Definition at line 227 of file trace_compo.h.

enum trace_level_app

Specific filter for FHOST APPLICATION component.

Enumerator:

  TRACE_LVL_APP_ERR | Error.
  TRACE_LVL_APP_WARN | Warning.
  TRACE_LVL_APP_INF | Information (depends of the application used).
  TRACE_LVL_APP_DBG | Debug (depends of the application used).

Definition at line 422 of file trace_compo.h.

enum trace_level_chan

Specific filter for Channel context.

Enumerator:

  TRACE_LVL_CHAN_ERR | Error.
  TRACE_LVL_CHAN_INF | Info (actual channel switch).
  TRACE_LVL_CHAN_SWITCH | Channel Switch progress.
  TRACE_LVL_CHAN_STATUS | Ctxt status update.
  TRACE_LVL_CHAN_CON_LESS | Connection-less (SCAN, ROC) channel context.
  TRACE_LVL_CHAN_NOA | Action related to Notice of Absence.
  TRACE_LVL_CHAN_TBTT | Handling of TBTT for various vifs.

Definition at line 156 of file trace_compo.h.

enum trace_level_fhost

Specific filter for FHOST component.

Enumerator:

  TRACE_LVL_FHOST_ERR | Error.
  TRACE_LVL_FHOST_WPA_FSM | wpa_supplicant task state machine
  TRACE_LVL_FHOST_WPA_CMD | Trace command sent to wpa_supplicant.
  TRACE_LVL_FHOST_WPA_INFO | Trace update of wpa_supplicant status.
  TRACE_LVL_FHOST_DHCP | DHCP.
  TRACE_LVL_FHOST_TASK_INIT | FHOST Tasks initialization.
  TRACE_LVL_FHOST_SMARTCONF | smart_config

Definition at line 384 of file trace_compo.h.

enum trace_level_kernel

Specific filter for KERNEL component.

Enumerator:

  TRACE_LVL_KERNEL_ERR | Error.
  TRACE_LVL_KERNEL_MSG_API | Messages to API layer.
  TRACE_LVL_KERNEL_MSG_LOCAL | Messages from API layer or internal task.
  TRACE_LVL_KERNEL_STATE | State changes.

Definition at line 84 of file trace_compo.h.

enum trace_level_lmac

Specific filter for LMAC.

Enumerator:

  TRACE_LVL_LMAC_ERR | Error.
  TRACE_LVL_LMAC_TX | Trace all frame sent by LMAC (except beacons).
  TRACE_LVL_LMAC_RX | Trace frame received by LMAC from known STA.
  TRACE_LVL_LMAC_RX_ALL | Trace frame received by LMAC from unknown STA.
  TRACE_LVL_LMAC_DOZE | Trace when MACHW enter/exit doze mode.
  TRACE_LVL_LMAC_BA | Trace when a block agreement is created/deleted.
  TRACE_LVL_LMAC_TPC | Trace TX power configuration.

Definition at line 118 of file trace_compo.h.

enum trace_level_mesh

Specific filter for MESH component.

Enumerator:

  TRACE_LVL_MESH_ERR | Error.
  TRACE_LVL_MESH_INF | General status.
  TRACE_LVL_MESH_PS | Transition of power save mode.
  TRACE_LVL_MESH_SP | Start/end of Service period.
  TRACE_LVL_MESH_AWIN | Start/end of Awake window (local and peer).
  TRACE_LVL_MESH_SLEEP | When a VIF/PEER prevent to enter sleep mode.
  TRACE_LVL_MESH_RX | Received frames from peers.
  TRACE_LVL_MESH_BCN_RX | Received beacons.
  TRACE_LVL_MESH_BCN_TX | Transmitted beacons.
  TRACE_LVL_MESH_POST_TRAFFIC | Postponed traffic (because of Power Save).
  TRACE_LVL_MESH_HWMP | Frame send/receiving for Hybrid Wireless Mesh Protocol.
  TRACE_LVL_MESH_MPATH | Detailed information about mesh path.
  TRACE_LVL_MESH_MPM | Mesh Peering Management.
  TRACE_LVL_MESH_TBTT | TBTT of local mesh interfaces and connected peers.

Definition at line 293 of file trace_compo.h.

enum trace_level_p2p

Specific filter for P2P component.

Enumerator:

  TRACE_LVL_P2P_ERR | Error.
  TRACE_LVL_P2P_ITF | creation/deletion/activation of P2P interfaces
  TRACE_LVL_P2P_PS | Opportunistic PS information.
  TRACE_LVL_P2P_NOA | Notice of Absence.
  TRACE_LVL_P2P_NOA_DET | Notice of Absence details.
  TRACE_LVL_P2P_TBTT | TBTT.

Definition at line 257 of file trace_compo.h.

enum trace_level_rtos

Specific filter for RTOS component.

Enumerator:

  TRACE_LVL_RTOS_ERR | Error.
  TRACE_LVL_RTOS_ALLOC | Memory allocation.
  TRACE_LVL_RTOS_FREE | Memory liberation.
  TRACE_LVL_RTOS_CREATE | Creation/destruction of RTOS tasks.
  TRACE_LVL_RTOS_SUSPEND | Suspension/resumption of RTOS tasks.
  TRACE_LVL_RTOS_SWITCH_IN | RTOS Task becomes active.
  TRACE_LVL_RTOS_SWITCH_OUT | RTOS Task is no longer active.

Definition at line 345 of file trace_compo.h.

enum trace_level_sta

Specific filter for STA component.

Enumerator:

  TRACE_LVL_STA_ERR | Error.
  TRACE_LVL_STA_BCN | Beacon received on STA interfaces.
  TRACE_LVL_STA_PS | Power Save status of STA interfaces.

Definition at line 197 of file trace_compo.h.

enum trace_level_tdls

Specific filter for TDLS component.

Enumerator:

  TRACE_LVL_TDLS_ERR | Error.
  TRACE_LVL_TDLS_CHSWITCH | TDLS channel Switch progress.

Definition at line 453 of file trace_compo.h.

## Function Documentation

void trace | ( | uint32_t | id,
|  | uint16_t | nb_param,
|  | uint16_t * | param,
|  | bool | trace_buf |
| ) |  |  |

Add a trace point in the buffer.

This function must NOT be called directly. use TRACE, TRACE_BUF or any of the TRACE_<LVL> macro instead.

Parameters:

  `[in]` | id | Unique trace id
  `[in]` | nb_param | Number of parameters to trace
  `[in]` | param | Table of parameters
  `[in]` | trace_buf | boolean indicating if TRACE_BUF macro is used. if true, param = [buffer size, buffer address(16 LSB), buffer address(16 MSB)]

void trace_init | ( | bool | force,
|  | bool | loop |
| ) |  |  |

Initialize trace buffer.

Normal usage would be to initialize trace buffer at boot with:

- `force` set to false, so that if fw jumps back to boot code (e.g. by dereferencing invalid pointer), it will appear in the trace.
- `loop` set to true to keep the latest trace.

In some specific debug cases, it may be usefull to start the trace after a specific event and to not use a circular buffer so that it ensure that trace that happened just after that specific event is kept. In this case set `force` to true and `loop` to false.

Parameters:

  `[in]` | force | Force buffer initialization even if trace buffer has already been initialized.
  `[in]` | loop | Whether trace buffer must be used circular buffer or not

void trace_set_filter | ( | unsigned int | compo_id,
|  | unsigned int | level |
| ) |  |  |

Modify trace level on a given component.

Parameters:

  `[in]` | compo_id | Component id (trace_compo). use TRACE_COMPO_MAX to configure all components.
  `[in]` | level | Trace level to activate on the component.

## Variable Documentation

uint32_t trace_compo_level[TRACE_COMPO_MAX]

Trace filter for each component.

Current trace filters status.

Definition at line 80 of file trace.c.