]> git.ipfire.org Git - thirdparty/util-linux.git/blame - sys-utils/irq-common.h
sys-utils: cleanup license lines, add SPDX
[thirdparty/util-linux.git] / sys-utils / irq-common.h
CommitLineData
9abd5e4b
KZ
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 */
02f2919e
KZ
12#ifndef UTIL_LINUX_H_IRQ_COMMON
13#define UTIL_LINUX_H_IRQ_COMMON
94e7e258 14
02f2919e
KZ
15#include "c.h"
16#include "nls.h"
4b2fadb1 17#include "cpuset.h"
02f2919e
KZ
18
19/* supported columns */
94e7e258 20enum {
02f2919e 21 COL_IRQ = 0,
94e7e258
KZ
22 COL_TOTAL,
23 COL_DELTA,
24 COL_NAME,
25
26 __COL_COUNT
27};
28
29struct 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
a23aecc1
KZ
36struct irq_cpu {
37 unsigned long total;
38 unsigned long delta;
39};
77f57b90 40
94e7e258 41struct irq_stat {
61074478
KZ
42 unsigned long nr_irq; /* number of irq vector */
43 unsigned long nr_irq_info; /* number of irq info */
94e7e258 44 struct irq_info *irq_info; /* array of irq_info */
a23aecc1
KZ
45 struct irq_cpu *cpus; /* array of irq_cpu */
46 size_t nr_active_cpu; /* number of active cpu */
94e7e258
KZ
47 unsigned long total_irq; /* total irqs */
48 unsigned long delta_irq; /* delta irqs */
49};
50
a23aecc1 51
44e39c99 52typedef int (irq_cmp_t)(const struct irq_info *, const struct irq_info *);
94e7e258 53
02f2919e 54/* output definition */
94e7e258
KZ
55struct irq_output {
56 int columns[__COL_COUNT * 2];
57 size_t ncolumns;
58
44e39c99 59 irq_cmp_t *sort_cmp_func;
94e7e258
KZ
60
61 unsigned int
5a20c0de
KZ
62 json:1, /* JSON output */
63 pairs:1, /* export, NAME="value" aoutput */
64 no_headings:1; /* don't print header */
94e7e258
KZ
65};
66
67int irq_column_name_to_id(char const *const name, size_t const namesz);
77f57b90 68void free_irqstat(struct irq_stat *stat);
94e7e258 69
a0f62b0b 70void irq_print_columns(FILE *f, int nodelta);
94e7e258 71
44e39c99
KZ
72void set_sort_func_by_name(struct irq_output *out, const char *name);
73void set_sort_func_by_key(struct irq_output *out, const char c);
94e7e258
KZ
74
75struct libscols_table *get_scols_table(struct irq_output *out,
76 struct irq_stat *prev,
b6ce063b 77 struct irq_stat **xstat,
4b2fadb1 78 int softirq,
79 size_t setsize,
80 cpu_set_t *cpuset);
02f2919e 81
a23aecc1
KZ
82struct libscols_table *get_scols_cpus_table(struct irq_output *out,
83 struct irq_stat *prev,
4b2fadb1 84 struct irq_stat *curr,
85 size_t setsize,
86 cpu_set_t *cpuset);
a23aecc1 87
02f2919e 88#endif /* UTIL_LINUX_H_IRQ_COMMON */