nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_802154_stats.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35#ifndef NRF_802154_STATS_H_
36#define NRF_802154_STATS_H_
37
38#include "nrfx.h"
39#include "nrf_802154_types.h"
40#include "nrf_802154_sl_atomics.h"
41
42#ifdef __STATIC_INLINE__
43#undef __STATIC_INLINE__
44#endif
45
46#ifdef NRF_802154_STATS_DECLARE_ONLY
47#define __STATIC_INLINE__
48#else
49#define __STATIC_INLINE__ __STATIC_INLINE
50#endif
51
53__STATIC_INLINE__ void nrf_802154_stat_counter_increment_received_frames(void);
56__STATIC_INLINE__ void nrf_802154_stat_counter_increment_coex_requests(void);
60
61__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_csmaca_start_timestamp(uint64_t value);
62__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_cca_start_timestamp(uint64_t value);
63__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_cca_idle_timestamp(uint64_t value);
64__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_tx_end_timestamp(uint64_t value);
65__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_ack_end_timestamp(uint64_t value);
66__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_rx_end_timestamp(uint64_t value);
67
68__STATIC_INLINE__ uint64_t nrf_802154_stat_timestamp_read_last_rx_end_timestamp(void);
69__STATIC_INLINE__ uint64_t nrf_802154_stat_timestamp_read_last_ack_end_timestamp(void);
70
71#ifndef NRF_802154_STATS_DECLARE_ONLY
72
73#define __NRF_802154_STAT_COUNTER_INC_IMPL(_field_name) \
74 do \
75 { \
76 extern nrf_802154_stats_t g_nrf_802154_stats; \
77 nrf_802154_sl_atomic_add_u32(&g_nrf_802154_stats.counters._field_name, 1);\
78 } \
79 while (0)
80
81#define __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(_field_name, _value) \
82 do \
83 { \
84 extern nrf_802154_stats_t g_nrf_802154_stats; \
85 nrf_802154_sl_atomic_store_u64(&g_nrf_802154_stats.timestamps._field_name, (_value));\
86 } \
87 while (0)
88
90{
91 __NRF_802154_STAT_COUNTER_INC_IMPL(cca_failed_attempts);
92}
93
95{
96 __NRF_802154_STAT_COUNTER_INC_IMPL(received_frames);
97}
98
100{
101 __NRF_802154_STAT_COUNTER_INC_IMPL(received_energy_events);
102}
103
105{
106 __NRF_802154_STAT_COUNTER_INC_IMPL(received_preambles);
107}
108
110{
111 __NRF_802154_STAT_COUNTER_INC_IMPL(coex_requests);
112}
113
115{
116 __NRF_802154_STAT_COUNTER_INC_IMPL(coex_granted_requests);
117}
118
120{
121 __NRF_802154_STAT_COUNTER_INC_IMPL(coex_denied_requests);
122}
123
125{
126 __NRF_802154_STAT_COUNTER_INC_IMPL(coex_unsolicited_grants);
127}
128
130{
131 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_csmaca_start_timestamp, value);
132}
133
135{
136 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_cca_start_timestamp, value);
137}
138
140{
141 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_cca_idle_timestamp, value);
142}
143
144__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_tx_end_timestamp(uint64_t value)
145{
146 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_tx_end_timestamp, value);
147}
148
149__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_ack_end_timestamp(uint64_t value)
150{
151 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_ack_end_timestamp, value);
152}
153
154__STATIC_INLINE__ void nrf_802154_stat_timestamp_write_last_rx_end_timestamp(uint64_t value)
155{
156 __NRF_80214_STAT_TIMESTAMP_WRITE_IMPL(last_rx_end_timestamp, value);
157}
158
160{
161 extern nrf_802154_stats_t g_nrf_802154_stats;
162
163 return nrf_802154_sl_atomic_load_u64(&g_nrf_802154_stats.timestamps.last_rx_end_timestamp);
164}
165
167{
168 extern nrf_802154_stats_t g_nrf_802154_stats;
169
170 return nrf_802154_sl_atomic_load_u64(&g_nrf_802154_stats.timestamps.last_ack_end_timestamp);
171}
172
173#endif /* NRF_802154_STATS_DECLARE_ONLY */
174
175#endif /* NRF_802154_STATS_H_ */
__STATIC_INLINE uint64_t nrf_802154_stat_timestamp_read_last_rx_end_timestamp(void)
Definition nrf_802154_stats.h:159
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_ack_end_timestamp(uint64_t value)
Definition nrf_802154_stats.h:149
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_cca_start_timestamp(uint64_t value)
Definition nrf_802154_stats.h:134
__STATIC_INLINE void nrf_802154_stat_counter_increment_received_frames(void)
Definition nrf_802154_stats.h:94
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_csmaca_start_timestamp(uint64_t value)
Definition nrf_802154_stats.h:129
__STATIC_INLINE void nrf_802154_stat_counter_increment_cca_failed_attempts(void)
Definition nrf_802154_stats.h:89
__STATIC_INLINE void nrf_802154_stat_counter_increment_received_energy_events(void)
Definition nrf_802154_stats.h:99
__STATIC_INLINE void nrf_802154_stat_counter_increment_coex_unsolicited_grants(void)
Definition nrf_802154_stats.h:124
__STATIC_INLINE void nrf_802154_stat_counter_increment_received_preambles(void)
Definition nrf_802154_stats.h:104
__STATIC_INLINE uint64_t nrf_802154_stat_timestamp_read_last_ack_end_timestamp(void)
Definition nrf_802154_stats.h:166
__STATIC_INLINE void nrf_802154_stat_counter_increment_coex_requests(void)
Definition nrf_802154_stats.h:109
__STATIC_INLINE void nrf_802154_stat_counter_increment_coex_denied_requests(void)
Definition nrf_802154_stats.h:119
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_tx_end_timestamp(uint64_t value)
Definition nrf_802154_stats.h:144
__STATIC_INLINE void nrf_802154_stat_counter_increment_coex_granted_requests(void)
Definition nrf_802154_stats.h:114
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_rx_end_timestamp(uint64_t value)
Definition nrf_802154_stats.h:154
__STATIC_INLINE void nrf_802154_stat_timestamp_write_last_cca_idle_timestamp(uint64_t value)
Definition nrf_802154_stats.h:139
uint64_t last_ack_end_timestamp
Definition nrf_802154_types.h:328
uint64_t last_rx_end_timestamp
Definition nrf_802154_types.h:329
nrf_802154_stat_timestamps_t timestamps
Definition nrf_802154_types.h:338
Type of structure holding statistics about the Radio Driver behavior.
Definition nrf_802154_types.h:336