| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_EBPF_HARDIRQ_H |
| 4 | #define NETDATA_EBPF_HARDIRQ_H 1 |
| 5 | |
| 6 | // Module description |
| 7 | #define NETDATA_EBPF_HARDIRQ_MODULE_DESC "Show time spent servicing individual hardware interrupt requests (hard IRQs)." |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | #include <stdbool.h> |
| 11 | #include "libnetdata/libnetdata.h" |
| 12 | |
| 13 | /***************************************************************** |
| 14 | * copied from kernel-collectors repo, with modifications needed |
| 15 | * for inclusion here. |
| 16 | *****************************************************************/ |
| 17 | |
| 18 | #define NETDATA_HARDIRQ_NAME_LEN 32 |
| 19 | #define NETDATA_HARDIRQ_MAX_IRQS 1024L |
| 20 | |
| 21 | typedef struct hardirq_ebpf_key { |
| 22 | int irq; |
| 23 | } hardirq_ebpf_key_t; |
| 24 | |
| 25 | enum hardirq_ebpf_static { |
| 26 | HARDIRQ_EBPF_STATIC_APIC_THERMAL, |
| 27 | HARDIRQ_EBPF_STATIC_APIC_THRESHOLD, |
| 28 | HARDIRQ_EBPF_STATIC_APIC_ERROR, |
| 29 | HARDIRQ_EBPF_STATIC_APIC_DEFERRED_ERROR, |
| 30 | HARDIRQ_EBPF_STATIC_APIC_SPURIOUS, |
| 31 | HARDIRQ_EBPF_STATIC_FUNC_CALL, |
| 32 | HARDIRQ_EBPF_STATIC_FUNC_CALL_SINGLE, |
| 33 | HARDIRQ_EBPF_STATIC_RESCHEDULE, |
| 34 | HARDIRQ_EBPF_STATIC_LOCAL_TIMER, |
| 35 | HARDIRQ_EBPF_STATIC_IRQ_WORK, |
| 36 | HARDIRQ_EBPF_STATIC_X86_PLATFORM_IPI, |
| 37 | |
| 38 | HARDIRQ_EBPF_STATIC_END |
| 39 | }; |
| 40 | |
| 41 | enum hardirq_maps { HARDIRQ_MAP_LATENCY, HARDIRQ_MAP_LATENCY_STATIC }; |
| 42 | |
| 43 | typedef struct hardirq_ebpf_static_val { |
| 44 | uint64_t latency; |
| 45 | } hardirq_ebpf_static_val_t; |
| 46 | |
| 47 | /***************************************************************** |
| 48 | * below this is eBPF plugin-specific code. |
| 49 | *****************************************************************/ |
| 50 | |
| 51 | #define NETDATA_EBPF_MODULE_NAME_HARDIRQ "hardirq" |
| 52 | #define NETDATA_HARDIRQ_CONFIG_FILE "hardirq.conf" |
| 53 | |
| 54 | typedef struct hardirq_val { |
| 55 | int irq; |
| 56 | bool dim_exists; |
| 57 | uint64_t latency; |
| 58 | char name[NETDATA_HARDIRQ_NAME_LEN]; |
| 59 | } hardirq_val_t; |
| 60 | |
| 61 | typedef struct hardirq_static_val { |
| 62 | enum hardirq_ebpf_static idx; |
| 63 | char *name; |
| 64 | uint64_t latency; |
| 65 | } hardirq_static_val_t; |
| 66 | |
| 67 | #define NETDATA_EBPF_SYSTEM_HARDIRQ_LATENCY_CTX "system.hardirq_latency" |
| 68 | #define NETDATA_HARDIRQ_DIMENSION 1 |
| 69 | |
| 70 | extern struct config hardirq_config; |
| 71 | void ebpf_hardirq_thread(void *ptr); |
| 72 | |
| 73 | hardirq_val_t *ebpf_hardirq_get(int irq); |
| 74 | void ebpf_hardirq_release(int irq); |
| 75 | |
| 76 | #endif /* NETDATA_EBPF_HARDIRQ_H */ |