Loading...
Searching...
No Matches
netstats.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#include "irq.h"
24
25#define GNRC_RPL_NETSTATS_MULTICAST (0)
26#define GNRC_RPL_NETSTATS_UNICAST (1)
27
35static inline void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
36{
37 /* other threads (e.g. the shell thread via the rpl shell command) read
38 * out the data, so we have to sync accesses */
39 unsigned irq_state = irq_disable();
40 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
41 netstats->dio.rx_mcast_count++;
42 netstats->dio.rx_mcast_bytes += len;
43 }
44 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
45 netstats->dio.rx_ucast_count++;
46 netstats->dio.rx_ucast_bytes += len;
47 }
48 irq_restore(irq_state);
49}
50
58static inline void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
59{
60 /* other threads (e.g. the shell thread via the rpl shell command) read
61 * out the data, so we have to sync accesses */
62 unsigned irq_state = irq_disable();
63 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
64 netstats->dio.tx_mcast_count++;
65 netstats->dio.tx_mcast_bytes += len;
66 }
67 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
68 netstats->dio.tx_ucast_count++;
69 netstats->dio.tx_ucast_bytes += len;
70 }
71 irq_restore(irq_state);
72}
73
81static inline void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
82{
83 /* other threads (e.g. the shell thread via the rpl shell command) read
84 * out the data, so we have to sync accesses */
85 unsigned irq_state = irq_disable();
86 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
87 netstats->dis.rx_mcast_count++;
88 netstats->dis.rx_mcast_bytes += len;
89 }
90 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
91 netstats->dis.rx_ucast_count++;
92 netstats->dis.rx_ucast_bytes += len;
93 }
94 irq_restore(irq_state);
95}
96
104static inline void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
105{
106 /* other threads (e.g. the shell thread via the rpl shell command) read
107 * out the data, so we have to sync accesses */
108 unsigned irq_state = irq_disable();
109 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
110 netstats->dis.tx_mcast_count++;
111 netstats->dis.tx_mcast_bytes += len;
112 }
113 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
114 netstats->dis.tx_ucast_count++;
115 netstats->dis.tx_ucast_bytes += len;
116 }
117 irq_restore(irq_state);
118}
119
127static inline void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
128{
129 /* other threads (e.g. the shell thread via the rpl shell command) read
130 * out the data, so we have to sync accesses */
131 unsigned irq_state = irq_disable();
132 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
133 netstats->dao.rx_mcast_count++;
134 netstats->dao.rx_mcast_bytes += len;
135 }
136 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
137 netstats->dao.rx_ucast_count++;
138 netstats->dao.rx_ucast_bytes += len;
139 }
140 irq_restore(irq_state);
141}
142
150static inline void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
151{
152 /* other threads (e.g. the shell thread via the rpl shell command) read
153 * out the data, so we have to sync accesses */
154 unsigned irq_state = irq_disable();
155 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
156 netstats->dao.tx_mcast_count++;
157 netstats->dao.tx_mcast_bytes += len;
158 }
159 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
160 netstats->dao.tx_ucast_count++;
161 netstats->dao.tx_ucast_bytes += len;
162 }
163 irq_restore(irq_state);
164}
165
173static inline void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
174{
175 /* other threads (e.g. the shell thread via the rpl shell command) read
176 * out the data, so we have to sync accesses */
177 unsigned irq_state = irq_disable();
178 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
179 netstats->dao_ack.rx_mcast_count++;
180 netstats->dao_ack.rx_mcast_bytes += len;
181 }
182 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
183 netstats->dao_ack.rx_ucast_count++;
184 netstats->dao_ack.rx_ucast_bytes += len;
185 }
186 irq_restore(irq_state);
187}
188
196static inline void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
197{
198 /* other threads (e.g. the shell thread via the rpl shell command) read
199 * out the data, so we have to sync accesses */
200 unsigned irq_state = irq_disable();
201 if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
202 netstats->dao_ack.tx_mcast_count++;
203 netstats->dao_ack.tx_mcast_bytes += len;
204 }
205 else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
206 netstats->dao_ack.tx_ucast_count++;
207 netstats->dao_ack.tx_ucast_bytes += len;
208 }
209 irq_restore(irq_state);
210}
211
212#ifdef __cplusplus
213}
214#endif
215
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
IRQ driver interface.
static void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIO.
Definition netstats.h:58
static void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DAO-ACK.
Definition netstats.h:196
static void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DAO.
Definition netstats.h:127
static void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIO.
Definition netstats.h:150
static void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DIO.
Definition netstats.h:35
static void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DIS.
Definition netstats.h:81
static void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for received DAO-ACK.
Definition netstats.h:173
static void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
Increase statistics for sent DIS.
Definition netstats.h:104
Definition of RPL related packet statistics.
uint32_t rx_ucast_bytes
unicast bytes received
uint32_t rx_mcast_count
multicast packets received
uint32_t tx_mcast_count
multicast packets sent
uint32_t rx_ucast_count
unicast packets received
uint32_t rx_mcast_bytes
multicast bytes received
uint32_t tx_ucast_bytes
unicast bytes sent
uint32_t tx_mcast_bytes
multicast bytes sent
uint32_t tx_ucast_count
unicast packets sent
RPL statistics struct.
netstats_rpl_block_t dis
DIS statistics.
netstats_rpl_block_t dio
DIO statistics.
netstats_rpl_block_t dao_ack
DAO-ACK statistics.
netstats_rpl_block_t dao
DAO statistics.