mirror_iproute2/tc/tc_qevent.h
Petr Machata 01bb0bcd00 tc: Add helpers to support qevent handling
Introduce a set of helpers to make it easy to add support for qevents into
qdisc.

The idea behind this is that qevent types will be generally reused between
qdiscs, rather than each having a completely idiosyncratic set of qevents.
The qevent module holds functions for parsing, dumping and formatting of
these common qevent types, and for dispatch to the appropriate set of
handlers based on the qevent name.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2020-07-05 15:37:27 +00:00

50 lines
1.5 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _TC_QEVENT_H_
#define _TC_QEVENT_H_
#include <linux/types.h>
#include <libnetlink.h>
struct qevent_base {
__u32 block_idx;
};
struct qevent_util {
const char *id;
int (*parse_qevent)(struct qevent_util *qu, int *argc, char ***argv);
int (*read_qevent)(struct qevent_util *qu, struct rtattr **tb);
void (*print_qevent)(struct qevent_util *qu, FILE *f);
int (*dump_qevent)(struct qevent_util *qu, struct nlmsghdr *n);
size_t data_size;
void *data;
int attr;
};
#define QEVENT(_name, _form, _data, _attr) \
{ \
.id = _name, \
.parse_qevent = qevent_parse_##_form, \
.read_qevent = qevent_read_##_form, \
.print_qevent = qevent_print_##_form, \
.dump_qevent = qevent_dump_##_form, \
.data_size = sizeof(struct qevent_##_form), \
.data = _data, \
.attr = _attr, \
}
void qevents_init(struct qevent_util *qevents);
int qevent_parse(struct qevent_util *qevents, int *p_argc, char ***p_argv);
int qevents_read(struct qevent_util *qevents, struct rtattr **tb);
int qevents_dump(struct qevent_util *qevents, struct nlmsghdr *n);
void qevents_print(struct qevent_util *qevents, FILE *f);
struct qevent_plain {
struct qevent_base base;
};
int qevent_parse_plain(struct qevent_util *qu, int *p_argc, char ***p_argv);
int qevent_read_plain(struct qevent_util *qu, struct rtattr **tb);
void qevent_print_plain(struct qevent_util *qu, FILE *f);
int qevent_dump_plain(struct qevent_util *qu, struct nlmsghdr *n);
#endif