]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/irq-common.h
sys-utils: cleanup license lines, add SPDX
[thirdparty/util-linux.git] / sys-utils / irq-common.h
1 /*
2 * SPDX-License-Identifier: GPL-2.1-or-later
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Copyright (C) 2012 Sami Kerola <kerolasa@iki.fi>
10 * Copyright (C) 2012-2023 Karel Zak <kzak@redhat.com>
11 */
12 #ifndef UTIL_LINUX_H_IRQ_COMMON
13 #define UTIL_LINUX_H_IRQ_COMMON
14
15 #include "c.h"
16 #include "nls.h"
17 #include "cpuset.h"
18
19 /* supported columns */
20 enum {
21 COL_IRQ = 0,
22 COL_TOTAL,
23 COL_DELTA,
24 COL_NAME,
25
26 __COL_COUNT
27 };
28
29 struct irq_info {
30 char *irq; /* short name of this irq */
31 char *name; /* descriptive name of this irq */
32 unsigned long total; /* total count since system start up */
33 unsigned long delta; /* delta count since previous update */
34 };
35
36 struct irq_cpu {
37 unsigned long total;
38 unsigned long delta;
39 };
40
41 struct irq_stat {
42 unsigned long nr_irq; /* number of irq vector */
43 unsigned long nr_irq_info; /* number of irq info */
44 struct irq_info *irq_info; /* array of irq_info */
45 struct irq_cpu *cpus; /* array of irq_cpu */
46 size_t nr_active_cpu; /* number of active cpu */
47 unsigned long total_irq; /* total irqs */
48 unsigned long delta_irq; /* delta irqs */
49 };
50
51
52 typedef int (irq_cmp_t)(const struct irq_info *, const struct irq_info *);
53
54 /* output definition */
55 struct irq_output {
56 int columns[__COL_COUNT * 2];
57 size_t ncolumns;
58
59 irq_cmp_t *sort_cmp_func;
60
61 unsigned int
62 json:1, /* JSON output */
63 pairs:1, /* export, NAME="value" aoutput */
64 no_headings:1; /* don't print header */
65 };
66
67 int irq_column_name_to_id(char const *const name, size_t const namesz);
68 void free_irqstat(struct irq_stat *stat);
69
70 void irq_print_columns(FILE *f, int nodelta);
71
72 void set_sort_func_by_name(struct irq_output *out, const char *name);
73 void set_sort_func_by_key(struct irq_output *out, const char c);
74
75 struct libscols_table *get_scols_table(struct irq_output *out,
76 struct irq_stat *prev,
77 struct irq_stat **xstat,
78 int softirq,
79 size_t setsize,
80 cpu_set_t *cpuset);
81
82 struct libscols_table *get_scols_cpus_table(struct irq_output *out,
83 struct irq_stat *prev,
84 struct irq_stat *curr,
85 size_t setsize,
86 cpu_set_t *cpuset);
87
88 #endif /* UTIL_LINUX_H_IRQ_COMMON */