Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stats.h File Reference

Statistics. More...

#include <stddef.h>
#include <zephyr/types.h>

Go to the source code of this file.

Data Structures

struct  stats_name_map
 Describe one generated statistic entry name. More...
struct  stats_hdr
 Store metadata for one statistics group. More...

Macros

Statistics group declarations
#define STATS_SECT_DECL(group__)
 Declares a stat group struct.
#define STATS_SECT_END   }
 Ends a stats group struct definition.
#define STATS_SECT_START(group__)
 Begins a stats group struct definition.
#define STATS_SECT_ENTRY(var__)
 Declares a 32-bit stat entry inside a group struct.
#define STATS_SECT_ENTRY16(var__)
 Declares a 16-bit stat entry inside a group struct.
#define STATS_SECT_ENTRY32(var__)
 Declares a 32-bit stat entry inside a group struct.
#define STATS_SECT_ENTRY64(var__)
 Declares a 64-bit stat entry inside a group struct.
#define STATS_SIZE_16   (sizeof(uint16_t))
 16-bit statistics entry size, in bytes.
#define STATS_SIZE_32   (sizeof(uint32_t))
 32-bit statistics entry size, in bytes.
#define STATS_SIZE_64   (sizeof(uint64_t))
 64-bit statistics entry size, in bytes.
Counter update helpers
#define STATS_INCN(group__, var__, n__)
 Increases a statistic entry by the specified amount.
#define STATS_INC(group__, var__)
 Increments a statistic entry.
#define STATS_SET(group__, var__, n__)
 Set a statistic entry to the specified amount.
#define STATS_CLEAR(group__, var__)
 Sets a statistic entry to zero.
Optional statistic names

These macros define the optional entry-name map used when CONFIG_STATS_NAMES is enabled.

When the option is disabled, the name macros compile out and statistics entries are reported as generated names such as "s0" and "s1".

#define STATS_NAME_START(sectname__)
 Begin a statistics entry name map.
#define STATS_NAME(sectname__, entry__)
 Add an entry name to a statistics entry name map.
#define STATS_NAME_END(sectname__)
 End a statistics entry name map.
#define STATS_NAME_INIT_PARMS(name__)
 Expand name-map arguments for stats_init().

Initialization and registration

#define STATS_INIT_AND_REG(group__, size__, name__)
 Initializes and registers a statistics group.
void stats_init (struct stats_hdr *shdr, uint8_t size, uint16_t cnt, const struct stats_name_map *map, uint16_t map_cnt)
 Initializes a statistics group.
int stats_register (const char *name, struct stats_hdr *shdr)
 Registers a statistics group to be managed.
int stats_init_and_reg (struct stats_hdr *hdr, uint8_t size, uint16_t cnt, const struct stats_name_map *map, uint16_t map_cnt, const char *name)
 Initializes and registers a statistics group.
void stats_reset (struct stats_hdr *shdr)
 Zeroes the specified statistics group.

Walking and lookup

typedef int stats_walk_fn(struct stats_hdr *hdr, void *arg, const char *name, uint16_t off)
 Function that gets applied to every stat entry during a walk.
typedef int stats_group_walk_fn(struct stats_hdr *hdr, void *arg)
 Function that gets applied to every registered stats group.
int stats_walk (struct stats_hdr *hdr, stats_walk_fn *walk_cb, void *arg)
 Applies a function to every stat entry in a group.
int stats_group_walk (stats_group_walk_fn *walk_cb, void *arg)
 Applies a function every registered statistics group.
struct stats_hdrstats_group_get_next (const struct stats_hdr *cur)
 Retrieves the next registered statistics group.
struct stats_hdrstats_group_find (const char *name)
 Retrieves the statistics group with the specified name.

Detailed Description

Statistics.