1 /* SPDX-License-Identifier: LGPL-2.1-or-later
2 * Copyright © 2019 VMware, Inc. */
5 #include "conf-parser.h"
6 #include "networkd-link.h"
7 #include "networkd-network.h"
8 #include "networkd-util.h"
11 typedef enum QDiscKind
{
25 QDISC_KIND_PFIFO_FAST
,
26 QDISC_KIND_PFIFO_HEAD_DROP
,
34 _QDISC_KIND_INVALID
= -EINVAL
,
37 typedef struct QDisc
{
40 NetworkConfigSection
*section
;
51 typedef struct QDiscVTable
{
54 /* called in qdisc_new() */
55 int (*init
)(QDisc
*qdisc
);
56 int (*fill_tca_kind
)(Link
*link
, QDisc
*qdisc
, sd_netlink_message
*m
);
57 int (*fill_message
)(Link
*link
, QDisc
*qdisc
, sd_netlink_message
*m
);
58 int (*verify
)(QDisc
*qdisc
);
61 extern const QDiscVTable
* const qdisc_vtable
[_QDISC_KIND_MAX
];
63 #define QDISC_VTABLE(q) ((q)->kind != _QDISC_KIND_INVALID ? qdisc_vtable[(q)->kind] : NULL)
65 /* For casting a qdisc into the various qdisc kinds */
66 #define DEFINE_QDISC_CAST(UPPERCASE, MixedCase) \
67 static inline MixedCase* UPPERCASE(QDisc *q) { \
68 if (_unlikely_(!q || q->kind != QDISC_KIND_##UPPERCASE)) \
71 return (MixedCase*) q; \
74 /* For casting the various qdisc kinds into a qdisc */
75 #define QDISC(q) (&(q)->meta)
77 QDisc
* qdisc_free(QDisc
*qdisc
);
78 int qdisc_new_static(QDiscKind kind
, Network
*network
, const char *filename
, unsigned section_line
, QDisc
**ret
);
80 int qdisc_configure(Link
*link
, QDisc
*qdisc
);
81 int qdisc_section_verify(QDisc
*qdisc
, bool *has_root
, bool *has_clsact
);
83 DEFINE_NETWORK_SECTION_FUNCTIONS(QDisc
, qdisc_free
);
85 DEFINE_TC_CAST(QDISC
, QDisc
);
87 CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_parent
);
88 CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle
);