1 /* SPDX-License-Identifier: LGPL-2.1-or-later 2 * Copyright © 2019 VMware, Inc. */ 3 #pragma once 4 5 #include "conf-parser.h" 6 #include "networkd-util.h" 7 8 typedef struct Link Link; 9 typedef struct Manager Manager; 10 typedef struct Network Network; 11 12 typedef enum QDiscKind { 13 QDISC_KIND_BFIFO, 14 QDISC_KIND_CAKE, 15 QDISC_KIND_CODEL, 16 QDISC_KIND_DRR, 17 QDISC_KIND_ETS, 18 QDISC_KIND_FQ, 19 QDISC_KIND_FQ_CODEL, 20 QDISC_KIND_FQ_PIE, 21 QDISC_KIND_GRED, 22 QDISC_KIND_HHF, 23 QDISC_KIND_HTB, 24 QDISC_KIND_NETEM, 25 QDISC_KIND_PFIFO, 26 QDISC_KIND_PFIFO_FAST, 27 QDISC_KIND_PFIFO_HEAD_DROP, 28 QDISC_KIND_PIE, 29 QDISC_KIND_QFQ, 30 QDISC_KIND_SFB, 31 QDISC_KIND_SFQ, 32 QDISC_KIND_TBF, 33 QDISC_KIND_TEQL, 34 _QDISC_KIND_MAX, 35 _QDISC_KIND_INVALID = -EINVAL, 36 } QDiscKind; 37 38 typedef struct QDisc { 39 Link *link; 40 Network *network; 41 ConfigSection *section; 42 NetworkConfigSource source; 43 NetworkConfigState state; 44 45 uint32_t handle; 46 uint32_t parent; 47 48 char *tca_kind; 49 QDiscKind kind; 50 } QDisc; 51 52 typedef struct QDiscVTable { 53 size_t object_size; 54 const char *tca_kind; 55 /* called in qdisc_new() */ 56 int (*init)(QDisc *qdisc); 57 int (*fill_message)(Link *link, QDisc *qdisc, sd_netlink_message *m); 58 int (*verify)(QDisc *qdisc); 59 } QDiscVTable; 60 61 extern const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX]; 62 63 #define QDISC_VTABLE(q) ((q)->kind != _QDISC_KIND_INVALID ? qdisc_vtable[(q)->kind] : NULL) 64 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)) \ 69 return NULL; \ 70 \ 71 return (MixedCase*) q; \ 72 } 73 74 DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(QDisc, qdisc); 75 76 QDisc* qdisc_free(QDisc *qdisc); 77 int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret); 78 79 int link_find_qdisc(Link *link, uint32_t handle, uint32_t parent, const char *kind, QDisc **qdisc); 80 81 int link_request_qdisc(Link *link, QDisc *qdisc); 82 83 void network_drop_invalid_qdisc(Network *network); 84 85 int manager_rtnl_process_qdisc(sd_netlink *rtnl, sd_netlink_message *message, Manager *m); 86 87 DEFINE_SECTION_CLEANUP_FUNCTIONS(QDisc, qdisc_free); 88 89 CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_parent); 90 CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle); 91 92 #include "cake.h" 93 #include "codel.h" 94 #include "ets.h" 95 #include "fifo.h" 96 #include "fq-codel.h" 97 #include "fq-pie.h" 98 #include "fq.h" 99 #include "gred.h" 100 #include "hhf.h" 101 #include "htb.h" 102 #include "pie.h" 103 #include "qfq.h" 104 #include "netem.h" 105 #include "drr.h" 106 #include "sfb.h" 107 #include "sfq.h" 108 #include "tbf.h" 109 #include "teql.h" 110