libosmocore 1.9.0.196-9975
Osmocom core library
time_cc.h
Go to the documentation of this file.
1
4/* Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5 *
6 * All Rights Reserved
7 *
8 * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
19 *
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24#pragma once
25
26#include <stdint.h>
27
28#include <osmocom/core/timer.h>
29
35struct osmo_tdef;
36struct rate_ctr;
37
108 uint64_t gran_usec;
116
125};
126
160
162
165 uint64_t total_sum;
166
168
170 uint64_t start_time;
174
177 uint64_t sum;
180 uint64_t reported_sum;
181};
182
184void osmo_time_cc_set_flag(struct osmo_time_cc *tc, bool flag);
186
void osmo_time_cc_set_flag(struct osmo_time_cc *tc, bool flag)
void osmo_time_cc_cleanup(struct osmo_time_cc *tc)
void osmo_time_cc_init(struct osmo_time_cc *tc)
Define a GSM timer of the form Tnnn, with unit, default value and doc string.
Definition: tdef.h:65
Configuration for osmo_time_cc.
Definition: time_cc.h:105
int T_forget_sum
Update forget_sum_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:122
uint64_t gran_usec
Granularity in microseconds: nr of microseconds that one rate_ctr increment represents.
Definition: time_cc.h:108
struct rate_ctr * rate_ctr
Rate counter to report to, or NULL to not use it.
Definition: time_cc.h:115
uint64_t round_threshold_usec
Nr of microseconds above n * gran_usec at which to trigger a counter increment.
Definition: time_cc.h:111
int T_gran
Update gran_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:118
int T_round_threshold
Update round_threshold_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:120
struct osmo_tdef * T_defs
Look up T_gran and T_forget_sum in this list of timers, or NULL to not use any T timers.
Definition: time_cc.h:124
uint64_t forget_sum_usec
Forget counted sub-gran time after the flag was false for this long.
Definition: time_cc.h:113
Report the cumulative counter of time for which a flag is true as rate counter.
Definition: time_cc.h:158
uint64_t total_sum
Overall cumulative sum.
Definition: time_cc.h:165
uint64_t sum
Internal cumulative counter of time that flag_state was true.
Definition: time_cc.h:177
struct osmo_time_cc_cfg cfg
Definition: time_cc.h:159
uint64_t last_counted_time
CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc last evaluated the flag st...
Definition: time_cc.h:173
bool flag_state
Definition: time_cc.h:161
struct osmo_timer_list timer
Definition: time_cc.h:167
uint64_t reported_sum
The amount of time that already reported cfg.rate_ctr increments account for.
Definition: time_cc.h:180
uint64_t start_time
CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc instance started counting.
Definition: time_cc.h:170
A structure representing a single instance of a timer.
Definition: timer.h:52
data we keep for each actual value
Definition: rate_ctr.h:29
Osmocom timer handling routines.