summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_hardirq.h
blob: 52dea1e560a774991e8b3d31da4c0481f0a0f682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_EBPF_HARDIRQ_H
#define NETDATA_EBPF_HARDIRQ_H 1

#include <stdint.h>
#include "libnetdata/avl/avl.h"

/*****************************************************************
 *  copied from kernel-collectors repo, with modifications needed
 *  for inclusion here.
 *****************************************************************/

#define NETDATA_HARDIRQ_NAME_LEN 32
#define NETDATA_HARDIRQ_MAX_IRQS 1024L

typedef struct hardirq_ebpf_key {
    int irq;
} hardirq_ebpf_key_t;

enum hardirq_ebpf_static {
    HARDIRQ_EBPF_STATIC_APIC_THERMAL,
    HARDIRQ_EBPF_STATIC_APIC_THRESHOLD,
    HARDIRQ_EBPF_STATIC_APIC_ERROR,
    HARDIRQ_EBPF_STATIC_APIC_DEFERRED_ERROR,
    HARDIRQ_EBPF_STATIC_APIC_SPURIOUS,
    HARDIRQ_EBPF_STATIC_FUNC_CALL,
    HARDIRQ_EBPF_STATIC_FUNC_CALL_SINGLE,
    HARDIRQ_EBPF_STATIC_RESCHEDULE,
    HARDIRQ_EBPF_STATIC_LOCAL_TIMER,
    HARDIRQ_EBPF_STATIC_IRQ_WORK,
    HARDIRQ_EBPF_STATIC_X86_PLATFORM_IPI,

    HARDIRQ_EBPF_STATIC_END
};

typedef struct hardirq_ebpf_static_val {
    uint64_t latency;
    uint64_t ts;
} hardirq_ebpf_static_val_t;

/*****************************************************************
 * below this is eBPF plugin-specific code.
 *****************************************************************/

// ARAL Name
#define NETDATA_EBPF_HARDIRQ_ARAL_NAME "ebpf_harddirq"

#define NETDATA_EBPF_MODULE_NAME_HARDIRQ "hardirq"
#define NETDATA_HARDIRQ_CONFIG_FILE "hardirq.conf"

typedef struct hardirq_val {
    // must be at top for simplified AVL tree usage.
    // if it's not at the top, we need to use `containerof` for almost all ops.
    avl_t avl;

    int irq;
    bool dim_exists; // keep this after `int irq` for alignment byte savings.
    uint64_t latency;
    char name[NETDATA_HARDIRQ_NAME_LEN];
} hardirq_val_t;

typedef struct hardirq_static_val {
    enum hardirq_ebpf_static idx;
    char *name;
    uint64_t latency;
} hardirq_static_val_t;

extern struct config hardirq_config;
void *ebpf_hardirq_thread(void *ptr);

#endif /* NETDATA_EBPF_HARDIRQ_H */