Mercury Modem
Mercury ARQ/Broadcast modem
Loading...
Searching...
No Matches
arq_trace.h
Go to the documentation of this file.
1/* Low-perturbation event trace for diagnosing connect-path races.
2 *
3 * The failure this exists for disappears under -v: any per-event logging shifts
4 * the timing enough to hide it. So nothing here does I/O on the hot path. A
5 * record is 16 bytes appended to a preallocated array under one relaxed atomic
6 * increment; the whole trace is printed once, later, by arq_trace_dump().
7 *
8 * SPDX-License-Identifier: GPL-3.0-or-later
9 */
10#ifndef ARQ_TRACE_H_
11#define ARQ_TRACE_H_
12
13#include <stdint.h>
14#include <stdbool.h>
15
16typedef enum {
17 ARQ_TR_RX_FRAME = 1, /* a frame decoded off the air: a=packet_type b=subtype */
18 ARQ_TR_EV_IN, /* event entering the FSM: a=event id b=conn_state */
19 ARQ_TR_EV_OUT, /* FSM returned: a=conn_state */
20 ARQ_TR_TX_START, /* we keyed up: a=packet_type b=mode&0xff */
21 ARQ_TR_TX_END, /* we unkeyed */
22 ARQ_TR_DROP, /* a frame was discarded: a=reason */
23 ARQ_TR_DECODE, /* decoder said something: a=mode b=sync|status<<1 x=bytes */
25
26void arq_trace_add(uint8_t kind, uint8_t a, uint8_t b, uint16_t extra);
27void arq_trace_dump(const char *why);
28
29/* Compiled in only for diagnosis; the release build pays nothing. */
30#ifdef ARQ_TRACE_ENABLED
31#define ARQ_TRACE_ON 1
32#define ARQ_TRACE(kind, a, b, extra) arq_trace_add((kind), (uint8_t)(a), (uint8_t)(b), (uint16_t)(extra))
33#define ARQ_TRACE_DUMP(why) arq_trace_dump((why))
34#else
35#define ARQ_TRACE_ON 0
36#define ARQ_TRACE(kind, a, b, extra) ((void)0)
37#define ARQ_TRACE_DUMP(why) ((void)0)
38#endif
39
40#endif /* ARQ_TRACE_H_ */
void arq_trace_add(uint8_t kind, uint8_t a, uint8_t b, uint16_t extra)
void arq_trace_dump(const char *why)
arq_trace_kind_t
Definition arq_trace.h:16
@ ARQ_TR_TX_END
Definition arq_trace.h:21
@ ARQ_TR_EV_IN
Definition arq_trace.h:18
@ ARQ_TR_RX_FRAME
Definition arq_trace.h:17
@ ARQ_TR_DROP
Definition arq_trace.h:22
@ ARQ_TR_TX_START
Definition arq_trace.h:20
@ ARQ_TR_EV_OUT
Definition arq_trace.h:19
@ ARQ_TR_DECODE
Definition arq_trace.h:23