12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 24b549a2eSEric Dumazet /* 34b549a2eSEric Dumazet * Fair Queue CoDel discipline 44b549a2eSEric Dumazet * 580ba92faSEric Dumazet * Copyright (C) 2012,2015 Eric Dumazet <edumazet@google.com> 64b549a2eSEric Dumazet */ 74b549a2eSEric Dumazet 84b549a2eSEric Dumazet #include <linux/module.h> 94b549a2eSEric Dumazet #include <linux/types.h> 104b549a2eSEric Dumazet #include <linux/kernel.h> 114b549a2eSEric Dumazet #include <linux/jiffies.h> 124b549a2eSEric Dumazet #include <linux/string.h> 134b549a2eSEric Dumazet #include <linux/in.h> 144b549a2eSEric Dumazet #include <linux/errno.h> 154b549a2eSEric Dumazet #include <linux/init.h> 164b549a2eSEric Dumazet #include <linux/skbuff.h> 174b549a2eSEric Dumazet #include <linux/slab.h> 184b549a2eSEric Dumazet #include <linux/vmalloc.h> 194b549a2eSEric Dumazet #include <net/netlink.h> 204b549a2eSEric Dumazet #include <net/pkt_sched.h> 21cf1facdaSJiri Pirko #include <net/pkt_cls.h> 224b549a2eSEric Dumazet #include <net/codel.h> 23d068ca2aSMichal Kazior #include <net/codel_impl.h> 24d068ca2aSMichal Kazior #include <net/codel_qdisc.h> 254b549a2eSEric Dumazet 264b549a2eSEric Dumazet /* Fair Queue CoDel. 274b549a2eSEric Dumazet * 284b549a2eSEric Dumazet * Principles : 294b549a2eSEric Dumazet * Packets are classified (internal classifier or external) on flows. 304b549a2eSEric Dumazet * This is a Stochastic model (as we use a hash, several flows 314b549a2eSEric Dumazet * might be hashed on same slot) 324b549a2eSEric Dumazet * Each flow has a CoDel managed queue. 334b549a2eSEric Dumazet * Flows are linked onto two (Round Robin) lists, 344b549a2eSEric Dumazet * so that new flows have priority on old ones. 354b549a2eSEric Dumazet * 364b549a2eSEric Dumazet * For a given flow, packets are not reordered (CoDel uses a FIFO) 374b549a2eSEric Dumazet * head drops only. 384b549a2eSEric Dumazet * ECN capability is on by default. 394b549a2eSEric Dumazet * Low memory footprint (64 bytes per flow) 404b549a2eSEric Dumazet */ 414b549a2eSEric Dumazet 424b549a2eSEric Dumazet struct fq_codel_flow { 434b549a2eSEric Dumazet struct sk_buff *head; 444b549a2eSEric Dumazet struct sk_buff *tail; 454b549a2eSEric Dumazet struct list_head flowchain; 464b549a2eSEric Dumazet int deficit; 474b549a2eSEric Dumazet struct codel_vars cvars; 484b549a2eSEric Dumazet }; /* please try to keep this structure <= 64 bytes */ 494b549a2eSEric Dumazet 504b549a2eSEric Dumazet struct fq_codel_sched_data { 5125d8c0d5SJohn Fastabend struct tcf_proto __rcu *filter_list; /* optional external classifier */ 526529eabaSJiri Pirko struct tcf_block *block; 534b549a2eSEric Dumazet struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ 544b549a2eSEric Dumazet u32 *backlogs; /* backlog table [flows_cnt] */ 554b549a2eSEric Dumazet u32 flows_cnt; /* number of flows */ 564b549a2eSEric Dumazet u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ 579d18562aSEric Dumazet u32 drop_batch_size; 5895b58430SEric Dumazet u32 memory_limit; 594b549a2eSEric Dumazet struct codel_params cparams; 604b549a2eSEric Dumazet struct codel_stats cstats; 6195b58430SEric Dumazet u32 memory_usage; 6295b58430SEric Dumazet u32 drop_overmemory; 634b549a2eSEric Dumazet u32 drop_overlimit; 644b549a2eSEric Dumazet u32 new_flow_count; 654b549a2eSEric Dumazet 664b549a2eSEric Dumazet struct list_head new_flows; /* list of new flows */ 674b549a2eSEric Dumazet struct list_head old_flows; /* list of old flows */ 684b549a2eSEric Dumazet }; 694b549a2eSEric Dumazet 704b549a2eSEric Dumazet static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, 71342db221STom Herbert struct sk_buff *skb) 724b549a2eSEric Dumazet { 73264b87faSAndrew Collins return reciprocal_scale(skb_get_hash(skb), q->flows_cnt); 744b549a2eSEric Dumazet } 754b549a2eSEric Dumazet 764b549a2eSEric Dumazet static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, 774b549a2eSEric Dumazet int *qerr) 784b549a2eSEric Dumazet { 794b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 8025d8c0d5SJohn Fastabend struct tcf_proto *filter; 814b549a2eSEric Dumazet struct tcf_result res; 824b549a2eSEric Dumazet int result; 834b549a2eSEric Dumazet 844b549a2eSEric Dumazet if (TC_H_MAJ(skb->priority) == sch->handle && 854b549a2eSEric Dumazet TC_H_MIN(skb->priority) > 0 && 864b549a2eSEric Dumazet TC_H_MIN(skb->priority) <= q->flows_cnt) 874b549a2eSEric Dumazet return TC_H_MIN(skb->priority); 884b549a2eSEric Dumazet 8969204cf7SValdis.Kletnieks@vt.edu filter = rcu_dereference_bh(q->filter_list); 9025d8c0d5SJohn Fastabend if (!filter) 914b549a2eSEric Dumazet return fq_codel_hash(q, skb) + 1; 924b549a2eSEric Dumazet 934b549a2eSEric Dumazet *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; 9487d83093SJiri Pirko result = tcf_classify(skb, filter, &res, false); 954b549a2eSEric Dumazet if (result >= 0) { 964b549a2eSEric Dumazet #ifdef CONFIG_NET_CLS_ACT 974b549a2eSEric Dumazet switch (result) { 984b549a2eSEric Dumazet case TC_ACT_STOLEN: 994b549a2eSEric Dumazet case TC_ACT_QUEUED: 100e25ea21fSJiri Pirko case TC_ACT_TRAP: 1014b549a2eSEric Dumazet *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; 102f3ae608eSGustavo A. R. Silva /* fall through */ 1034b549a2eSEric Dumazet case TC_ACT_SHOT: 1044b549a2eSEric Dumazet return 0; 1054b549a2eSEric Dumazet } 1064b549a2eSEric Dumazet #endif 1074b549a2eSEric Dumazet if (TC_H_MIN(res.classid) <= q->flows_cnt) 1084b549a2eSEric Dumazet return TC_H_MIN(res.classid); 1094b549a2eSEric Dumazet } 1104b549a2eSEric Dumazet return 0; 1114b549a2eSEric Dumazet } 1124b549a2eSEric Dumazet 1134b549a2eSEric Dumazet /* helper functions : might be changed when/if skb use a standard list_head */ 1144b549a2eSEric Dumazet 1154b549a2eSEric Dumazet /* remove one skb from head of slot queue */ 1164b549a2eSEric Dumazet static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) 1174b549a2eSEric Dumazet { 1184b549a2eSEric Dumazet struct sk_buff *skb = flow->head; 1194b549a2eSEric Dumazet 1204b549a2eSEric Dumazet flow->head = skb->next; 121a8305bffSDavid S. Miller skb_mark_not_on_list(skb); 1224b549a2eSEric Dumazet return skb; 1234b549a2eSEric Dumazet } 1244b549a2eSEric Dumazet 1254b549a2eSEric Dumazet /* add skb to flow queue (tail add) */ 1264b549a2eSEric Dumazet static inline void flow_queue_add(struct fq_codel_flow *flow, 1274b549a2eSEric Dumazet struct sk_buff *skb) 1284b549a2eSEric Dumazet { 1294b549a2eSEric Dumazet if (flow->head == NULL) 1304b549a2eSEric Dumazet flow->head = skb; 1314b549a2eSEric Dumazet else 1324b549a2eSEric Dumazet flow->tail->next = skb; 1334b549a2eSEric Dumazet flow->tail = skb; 1344b549a2eSEric Dumazet skb->next = NULL; 1354b549a2eSEric Dumazet } 1364b549a2eSEric Dumazet 137520ac30fSEric Dumazet static unsigned int fq_codel_drop(struct Qdisc *sch, unsigned int max_packets, 138520ac30fSEric Dumazet struct sk_buff **to_free) 1394b549a2eSEric Dumazet { 1404b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 1414b549a2eSEric Dumazet struct sk_buff *skb; 1424b549a2eSEric Dumazet unsigned int maxbacklog = 0, idx = 0, i, len; 1434b549a2eSEric Dumazet struct fq_codel_flow *flow; 1449d18562aSEric Dumazet unsigned int threshold; 14595b58430SEric Dumazet unsigned int mem = 0; 1464b549a2eSEric Dumazet 1479d18562aSEric Dumazet /* Queue is full! Find the fat flow and drop packet(s) from it. 1484b549a2eSEric Dumazet * This might sound expensive, but with 1024 flows, we scan 1494b549a2eSEric Dumazet * 4KB of memory, and we dont need to handle a complex tree 1504b549a2eSEric Dumazet * in fast path (packet queue/enqueue) with many cache misses. 1519d18562aSEric Dumazet * In stress mode, we'll try to drop 64 packets from the flow, 1529d18562aSEric Dumazet * amortizing this linear lookup to one cache line per drop. 1534b549a2eSEric Dumazet */ 1544b549a2eSEric Dumazet for (i = 0; i < q->flows_cnt; i++) { 1554b549a2eSEric Dumazet if (q->backlogs[i] > maxbacklog) { 1564b549a2eSEric Dumazet maxbacklog = q->backlogs[i]; 1574b549a2eSEric Dumazet idx = i; 1584b549a2eSEric Dumazet } 1594b549a2eSEric Dumazet } 1609d18562aSEric Dumazet 1619d18562aSEric Dumazet /* Our goal is to drop half of this fat flow backlog */ 1629d18562aSEric Dumazet threshold = maxbacklog >> 1; 1639d18562aSEric Dumazet 1644b549a2eSEric Dumazet flow = &q->flows[idx]; 1659d18562aSEric Dumazet len = 0; 1669d18562aSEric Dumazet i = 0; 1679d18562aSEric Dumazet do { 1684b549a2eSEric Dumazet skb = dequeue_head(flow); 1699d18562aSEric Dumazet len += qdisc_pkt_len(skb); 170008830bcSEric Dumazet mem += get_codel_cb(skb)->mem_usage; 171520ac30fSEric Dumazet __qdisc_drop(skb, to_free); 1729d18562aSEric Dumazet } while (++i < max_packets && len < threshold); 1739d18562aSEric Dumazet 174ae697f3bSDave Taht /* Tell codel to increase its signal strength also */ 175ae697f3bSDave Taht flow->cvars.count += i; 1769d18562aSEric Dumazet q->backlogs[idx] -= len; 17795b58430SEric Dumazet q->memory_usage -= mem; 1789d18562aSEric Dumazet sch->qstats.drops += i; 1799d18562aSEric Dumazet sch->qstats.backlog -= len; 1809d18562aSEric Dumazet sch->q.qlen -= i; 1814b549a2eSEric Dumazet return idx; 1824b549a2eSEric Dumazet } 1834b549a2eSEric Dumazet 184520ac30fSEric Dumazet static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch, 185520ac30fSEric Dumazet struct sk_buff **to_free) 1864b549a2eSEric Dumazet { 1874b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 1889d18562aSEric Dumazet unsigned int idx, prev_backlog, prev_qlen; 1894b549a2eSEric Dumazet struct fq_codel_flow *flow; 1904b549a2eSEric Dumazet int uninitialized_var(ret); 19180e509dbSEric Dumazet unsigned int pkt_len; 19295b58430SEric Dumazet bool memory_limited; 1934b549a2eSEric Dumazet 1944b549a2eSEric Dumazet idx = fq_codel_classify(skb, sch, &ret); 1954b549a2eSEric Dumazet if (idx == 0) { 1964b549a2eSEric Dumazet if (ret & __NET_XMIT_BYPASS) 19725331d6cSJohn Fastabend qdisc_qstats_drop(sch); 198520ac30fSEric Dumazet __qdisc_drop(skb, to_free); 1994b549a2eSEric Dumazet return ret; 2004b549a2eSEric Dumazet } 2014b549a2eSEric Dumazet idx--; 2024b549a2eSEric Dumazet 2034b549a2eSEric Dumazet codel_set_enqueue_time(skb); 2044b549a2eSEric Dumazet flow = &q->flows[idx]; 2054b549a2eSEric Dumazet flow_queue_add(flow, skb); 2064b549a2eSEric Dumazet q->backlogs[idx] += qdisc_pkt_len(skb); 20725331d6cSJohn Fastabend qdisc_qstats_backlog_inc(sch, skb); 2084b549a2eSEric Dumazet 2094b549a2eSEric Dumazet if (list_empty(&flow->flowchain)) { 2104b549a2eSEric Dumazet list_add_tail(&flow->flowchain, &q->new_flows); 2114b549a2eSEric Dumazet q->new_flow_count++; 2124b549a2eSEric Dumazet flow->deficit = q->quantum; 2134b549a2eSEric Dumazet } 214008830bcSEric Dumazet get_codel_cb(skb)->mem_usage = skb->truesize; 215008830bcSEric Dumazet q->memory_usage += get_codel_cb(skb)->mem_usage; 21695b58430SEric Dumazet memory_limited = q->memory_usage > q->memory_limit; 21795b58430SEric Dumazet if (++sch->q.qlen <= sch->limit && !memory_limited) 2184b549a2eSEric Dumazet return NET_XMIT_SUCCESS; 2194b549a2eSEric Dumazet 2202ccccf5fSWANG Cong prev_backlog = sch->qstats.backlog; 2219d18562aSEric Dumazet prev_qlen = sch->q.qlen; 2224b549a2eSEric Dumazet 22380e509dbSEric Dumazet /* save this packet length as it might be dropped by fq_codel_drop() */ 22480e509dbSEric Dumazet pkt_len = qdisc_pkt_len(skb); 2259d18562aSEric Dumazet /* fq_codel_drop() is quite expensive, as it performs a linear search 2269d18562aSEric Dumazet * in q->backlogs[] to find a fat flow. 2279d18562aSEric Dumazet * So instead of dropping a single packet, drop half of its backlog 2289d18562aSEric Dumazet * with a 64 packets limit to not add a too big cpu spike here. 2299d18562aSEric Dumazet */ 230520ac30fSEric Dumazet ret = fq_codel_drop(sch, q->drop_batch_size, to_free); 2319d18562aSEric Dumazet 23280e509dbSEric Dumazet prev_qlen -= sch->q.qlen; 23380e509dbSEric Dumazet prev_backlog -= sch->qstats.backlog; 23480e509dbSEric Dumazet q->drop_overlimit += prev_qlen; 23595b58430SEric Dumazet if (memory_limited) 23680e509dbSEric Dumazet q->drop_overmemory += prev_qlen; 2379d18562aSEric Dumazet 23880e509dbSEric Dumazet /* As we dropped packet(s), better let upper stack know this. 23980e509dbSEric Dumazet * If we dropped a packet for this flow, return NET_XMIT_CN, 24080e509dbSEric Dumazet * but in this case, our parents wont increase their backlogs. 24180e509dbSEric Dumazet */ 24280e509dbSEric Dumazet if (ret == idx) { 24380e509dbSEric Dumazet qdisc_tree_reduce_backlog(sch, prev_qlen - 1, 24480e509dbSEric Dumazet prev_backlog - pkt_len); 24580e509dbSEric Dumazet return NET_XMIT_CN; 24680e509dbSEric Dumazet } 24780e509dbSEric Dumazet qdisc_tree_reduce_backlog(sch, prev_qlen, prev_backlog); 24880e509dbSEric Dumazet return NET_XMIT_SUCCESS; 2494b549a2eSEric Dumazet } 2504b549a2eSEric Dumazet 2514b549a2eSEric Dumazet /* This is the specific function called from codel_dequeue() 2524b549a2eSEric Dumazet * to dequeue a packet from queue. Note: backlog is handled in 2534b549a2eSEric Dumazet * codel, we dont need to reduce it here. 2544b549a2eSEric Dumazet */ 25579bdc4c8SMichal Kazior static struct sk_buff *dequeue_func(struct codel_vars *vars, void *ctx) 2564b549a2eSEric Dumazet { 25779bdc4c8SMichal Kazior struct Qdisc *sch = ctx; 258865ec552SEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 2594b549a2eSEric Dumazet struct fq_codel_flow *flow; 2604b549a2eSEric Dumazet struct sk_buff *skb = NULL; 2614b549a2eSEric Dumazet 2624b549a2eSEric Dumazet flow = container_of(vars, struct fq_codel_flow, cvars); 2634b549a2eSEric Dumazet if (flow->head) { 2644b549a2eSEric Dumazet skb = dequeue_head(flow); 265865ec552SEric Dumazet q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); 266008830bcSEric Dumazet q->memory_usage -= get_codel_cb(skb)->mem_usage; 2674b549a2eSEric Dumazet sch->q.qlen--; 26879bdc4c8SMichal Kazior sch->qstats.backlog -= qdisc_pkt_len(skb); 2694b549a2eSEric Dumazet } 2704b549a2eSEric Dumazet return skb; 2714b549a2eSEric Dumazet } 2724b549a2eSEric Dumazet 27379bdc4c8SMichal Kazior static void drop_func(struct sk_buff *skb, void *ctx) 27479bdc4c8SMichal Kazior { 27579bdc4c8SMichal Kazior struct Qdisc *sch = ctx; 27679bdc4c8SMichal Kazior 277520ac30fSEric Dumazet kfree_skb(skb); 278520ac30fSEric Dumazet qdisc_qstats_drop(sch); 27979bdc4c8SMichal Kazior } 28079bdc4c8SMichal Kazior 2814b549a2eSEric Dumazet static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) 2824b549a2eSEric Dumazet { 2834b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 2844b549a2eSEric Dumazet struct sk_buff *skb; 2854b549a2eSEric Dumazet struct fq_codel_flow *flow; 2864b549a2eSEric Dumazet struct list_head *head; 2874b549a2eSEric Dumazet 2884b549a2eSEric Dumazet begin: 2894b549a2eSEric Dumazet head = &q->new_flows; 2904b549a2eSEric Dumazet if (list_empty(head)) { 2914b549a2eSEric Dumazet head = &q->old_flows; 2924b549a2eSEric Dumazet if (list_empty(head)) 2934b549a2eSEric Dumazet return NULL; 2944b549a2eSEric Dumazet } 2954b549a2eSEric Dumazet flow = list_first_entry(head, struct fq_codel_flow, flowchain); 2964b549a2eSEric Dumazet 2974b549a2eSEric Dumazet if (flow->deficit <= 0) { 2984b549a2eSEric Dumazet flow->deficit += q->quantum; 2994b549a2eSEric Dumazet list_move_tail(&flow->flowchain, &q->old_flows); 3004b549a2eSEric Dumazet goto begin; 3014b549a2eSEric Dumazet } 3024b549a2eSEric Dumazet 30379bdc4c8SMichal Kazior skb = codel_dequeue(sch, &sch->qstats.backlog, &q->cparams, 30479bdc4c8SMichal Kazior &flow->cvars, &q->cstats, qdisc_pkt_len, 30579bdc4c8SMichal Kazior codel_get_enqueue_time, drop_func, dequeue_func); 3064b549a2eSEric Dumazet 3074b549a2eSEric Dumazet if (!skb) { 3084b549a2eSEric Dumazet /* force a pass through old_flows to prevent starvation */ 3094b549a2eSEric Dumazet if ((head == &q->new_flows) && !list_empty(&q->old_flows)) 3104b549a2eSEric Dumazet list_move_tail(&flow->flowchain, &q->old_flows); 3114b549a2eSEric Dumazet else 3124b549a2eSEric Dumazet list_del_init(&flow->flowchain); 3134b549a2eSEric Dumazet goto begin; 3144b549a2eSEric Dumazet } 3154b549a2eSEric Dumazet qdisc_bstats_update(sch, skb); 3164b549a2eSEric Dumazet flow->deficit -= qdisc_pkt_len(skb); 3172ccccf5fSWANG Cong /* We cant call qdisc_tree_reduce_backlog() if our qlen is 0, 3184b549a2eSEric Dumazet * or HTB crashes. Defer it for next round. 3194b549a2eSEric Dumazet */ 3204b549a2eSEric Dumazet if (q->cstats.drop_count && sch->q.qlen) { 3212ccccf5fSWANG Cong qdisc_tree_reduce_backlog(sch, q->cstats.drop_count, 3222ccccf5fSWANG Cong q->cstats.drop_len); 3234b549a2eSEric Dumazet q->cstats.drop_count = 0; 3242ccccf5fSWANG Cong q->cstats.drop_len = 0; 3254b549a2eSEric Dumazet } 3264b549a2eSEric Dumazet return skb; 3274b549a2eSEric Dumazet } 3284b549a2eSEric Dumazet 329ece5d4c7SEric Dumazet static void fq_codel_flow_purge(struct fq_codel_flow *flow) 330ece5d4c7SEric Dumazet { 331ece5d4c7SEric Dumazet rtnl_kfree_skbs(flow->head, flow->tail); 332ece5d4c7SEric Dumazet flow->head = NULL; 333ece5d4c7SEric Dumazet } 334ece5d4c7SEric Dumazet 3354b549a2eSEric Dumazet static void fq_codel_reset(struct Qdisc *sch) 3364b549a2eSEric Dumazet { 3373d0e0af4SEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 3383d0e0af4SEric Dumazet int i; 3394b549a2eSEric Dumazet 3403d0e0af4SEric Dumazet INIT_LIST_HEAD(&q->new_flows); 3413d0e0af4SEric Dumazet INIT_LIST_HEAD(&q->old_flows); 3423d0e0af4SEric Dumazet for (i = 0; i < q->flows_cnt; i++) { 3433d0e0af4SEric Dumazet struct fq_codel_flow *flow = q->flows + i; 3443d0e0af4SEric Dumazet 345ece5d4c7SEric Dumazet fq_codel_flow_purge(flow); 3463d0e0af4SEric Dumazet INIT_LIST_HEAD(&flow->flowchain); 3473d0e0af4SEric Dumazet codel_vars_init(&flow->cvars); 3483d0e0af4SEric Dumazet } 3493d0e0af4SEric Dumazet memset(q->backlogs, 0, q->flows_cnt * sizeof(u32)); 3503d0e0af4SEric Dumazet sch->q.qlen = 0; 351ece5d4c7SEric Dumazet sch->qstats.backlog = 0; 35277f57761SEric Dumazet q->memory_usage = 0; 3533d0e0af4SEric Dumazet } 3543d0e0af4SEric Dumazet 3554b549a2eSEric Dumazet static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { 3564b549a2eSEric Dumazet [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, 3574b549a2eSEric Dumazet [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, 3584b549a2eSEric Dumazet [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, 3594b549a2eSEric Dumazet [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, 3604b549a2eSEric Dumazet [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, 3614b549a2eSEric Dumazet [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, 36280ba92faSEric Dumazet [TCA_FQ_CODEL_CE_THRESHOLD] = { .type = NLA_U32 }, 3639d18562aSEric Dumazet [TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .type = NLA_U32 }, 36495b58430SEric Dumazet [TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NLA_U32 }, 3654b549a2eSEric Dumazet }; 3664b549a2eSEric Dumazet 3672030721cSAlexander Aring static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt, 3682030721cSAlexander Aring struct netlink_ext_ack *extack) 3694b549a2eSEric Dumazet { 3704b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 3714b549a2eSEric Dumazet struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; 3724b549a2eSEric Dumazet int err; 3734b549a2eSEric Dumazet 3744b549a2eSEric Dumazet if (!opt) 3754b549a2eSEric Dumazet return -EINVAL; 3764b549a2eSEric Dumazet 3778cb08174SJohannes Berg err = nla_parse_nested_deprecated(tb, TCA_FQ_CODEL_MAX, opt, 3788cb08174SJohannes Berg fq_codel_policy, NULL); 3794b549a2eSEric Dumazet if (err < 0) 3804b549a2eSEric Dumazet return err; 3814b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_FLOWS]) { 3824b549a2eSEric Dumazet if (q->flows) 3834b549a2eSEric Dumazet return -EINVAL; 3844b549a2eSEric Dumazet q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); 3854b549a2eSEric Dumazet if (!q->flows_cnt || 3864b549a2eSEric Dumazet q->flows_cnt > 65536) 3874b549a2eSEric Dumazet return -EINVAL; 3884b549a2eSEric Dumazet } 3894b549a2eSEric Dumazet sch_tree_lock(sch); 3904b549a2eSEric Dumazet 3914b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_TARGET]) { 3924b549a2eSEric Dumazet u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); 3934b549a2eSEric Dumazet 3944b549a2eSEric Dumazet q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; 3954b549a2eSEric Dumazet } 3964b549a2eSEric Dumazet 39780ba92faSEric Dumazet if (tb[TCA_FQ_CODEL_CE_THRESHOLD]) { 39880ba92faSEric Dumazet u64 val = nla_get_u32(tb[TCA_FQ_CODEL_CE_THRESHOLD]); 39980ba92faSEric Dumazet 40080ba92faSEric Dumazet q->cparams.ce_threshold = (val * NSEC_PER_USEC) >> CODEL_SHIFT; 40180ba92faSEric Dumazet } 40280ba92faSEric Dumazet 4034b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_INTERVAL]) { 4044b549a2eSEric Dumazet u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); 4054b549a2eSEric Dumazet 4064b549a2eSEric Dumazet q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; 4074b549a2eSEric Dumazet } 4084b549a2eSEric Dumazet 4094b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_LIMIT]) 4104b549a2eSEric Dumazet sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); 4114b549a2eSEric Dumazet 4124b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_ECN]) 4134b549a2eSEric Dumazet q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); 4144b549a2eSEric Dumazet 4154b549a2eSEric Dumazet if (tb[TCA_FQ_CODEL_QUANTUM]) 4164b549a2eSEric Dumazet q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); 4174b549a2eSEric Dumazet 4189d18562aSEric Dumazet if (tb[TCA_FQ_CODEL_DROP_BATCH_SIZE]) 41914695212SEric Dumazet q->drop_batch_size = max(1U, nla_get_u32(tb[TCA_FQ_CODEL_DROP_BATCH_SIZE])); 4209d18562aSEric Dumazet 42195b58430SEric Dumazet if (tb[TCA_FQ_CODEL_MEMORY_LIMIT]) 42295b58430SEric Dumazet q->memory_limit = min(1U << 31, nla_get_u32(tb[TCA_FQ_CODEL_MEMORY_LIMIT])); 42395b58430SEric Dumazet 42495b58430SEric Dumazet while (sch->q.qlen > sch->limit || 42595b58430SEric Dumazet q->memory_usage > q->memory_limit) { 4264b549a2eSEric Dumazet struct sk_buff *skb = fq_codel_dequeue(sch); 4274b549a2eSEric Dumazet 4282ccccf5fSWANG Cong q->cstats.drop_len += qdisc_pkt_len(skb); 429ece5d4c7SEric Dumazet rtnl_kfree_skbs(skb, skb); 4304b549a2eSEric Dumazet q->cstats.drop_count++; 4314b549a2eSEric Dumazet } 4322ccccf5fSWANG Cong qdisc_tree_reduce_backlog(sch, q->cstats.drop_count, q->cstats.drop_len); 4334b549a2eSEric Dumazet q->cstats.drop_count = 0; 4342ccccf5fSWANG Cong q->cstats.drop_len = 0; 4354b549a2eSEric Dumazet 4364b549a2eSEric Dumazet sch_tree_unlock(sch); 4374b549a2eSEric Dumazet return 0; 4384b549a2eSEric Dumazet } 4394b549a2eSEric Dumazet 4404b549a2eSEric Dumazet static void fq_codel_destroy(struct Qdisc *sch) 4414b549a2eSEric Dumazet { 4424b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 4434b549a2eSEric Dumazet 4446529eabaSJiri Pirko tcf_block_put(q->block); 445752ade68SMichal Hocko kvfree(q->backlogs); 446752ade68SMichal Hocko kvfree(q->flows); 4474b549a2eSEric Dumazet } 4484b549a2eSEric Dumazet 449e63d7dfdSAlexander Aring static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, 450e63d7dfdSAlexander Aring struct netlink_ext_ack *extack) 4514b549a2eSEric Dumazet { 4524b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 4534b549a2eSEric Dumazet int i; 4546529eabaSJiri Pirko int err; 4554b549a2eSEric Dumazet 4564b549a2eSEric Dumazet sch->limit = 10*1024; 4574b549a2eSEric Dumazet q->flows_cnt = 1024; 45895b58430SEric Dumazet q->memory_limit = 32 << 20; /* 32 MBytes */ 4599d18562aSEric Dumazet q->drop_batch_size = 64; 4604b549a2eSEric Dumazet q->quantum = psched_mtu(qdisc_dev(sch)); 4614b549a2eSEric Dumazet INIT_LIST_HEAD(&q->new_flows); 4624b549a2eSEric Dumazet INIT_LIST_HEAD(&q->old_flows); 46379bdc4c8SMichal Kazior codel_params_init(&q->cparams); 4644b549a2eSEric Dumazet codel_stats_init(&q->cstats); 4654b549a2eSEric Dumazet q->cparams.ecn = true; 46679bdc4c8SMichal Kazior q->cparams.mtu = psched_mtu(qdisc_dev(sch)); 4674b549a2eSEric Dumazet 4684b549a2eSEric Dumazet if (opt) { 46983fe6b87SJacob Keller err = fq_codel_change(sch, opt, extack); 4704b549a2eSEric Dumazet if (err) 47183fe6b87SJacob Keller goto init_failure; 4724b549a2eSEric Dumazet } 4734b549a2eSEric Dumazet 4748d1a77f9SAlexander Aring err = tcf_block_get(&q->block, &q->filter_list, sch, extack); 4756529eabaSJiri Pirko if (err) 47683fe6b87SJacob Keller goto init_failure; 4776529eabaSJiri Pirko 4784b549a2eSEric Dumazet if (!q->flows) { 479778e1cddSKees Cook q->flows = kvcalloc(q->flows_cnt, 480778e1cddSKees Cook sizeof(struct fq_codel_flow), 481778e1cddSKees Cook GFP_KERNEL); 48283fe6b87SJacob Keller if (!q->flows) { 48383fe6b87SJacob Keller err = -ENOMEM; 48483fe6b87SJacob Keller goto init_failure; 48583fe6b87SJacob Keller } 486778e1cddSKees Cook q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL); 48783fe6b87SJacob Keller if (!q->backlogs) { 48883fe6b87SJacob Keller err = -ENOMEM; 48983fe6b87SJacob Keller goto alloc_failure; 49083fe6b87SJacob Keller } 4914b549a2eSEric Dumazet for (i = 0; i < q->flows_cnt; i++) { 4924b549a2eSEric Dumazet struct fq_codel_flow *flow = q->flows + i; 4934b549a2eSEric Dumazet 4944b549a2eSEric Dumazet INIT_LIST_HEAD(&flow->flowchain); 495b379135cSEric Dumazet codel_vars_init(&flow->cvars); 4964b549a2eSEric Dumazet } 4974b549a2eSEric Dumazet } 4984b549a2eSEric Dumazet if (sch->limit >= 1) 4994b549a2eSEric Dumazet sch->flags |= TCQ_F_CAN_BYPASS; 5004b549a2eSEric Dumazet else 5014b549a2eSEric Dumazet sch->flags &= ~TCQ_F_CAN_BYPASS; 5024b549a2eSEric Dumazet return 0; 50383fe6b87SJacob Keller 50483fe6b87SJacob Keller alloc_failure: 50583fe6b87SJacob Keller kvfree(q->flows); 50683fe6b87SJacob Keller q->flows = NULL; 50783fe6b87SJacob Keller init_failure: 50883fe6b87SJacob Keller q->flows_cnt = 0; 50983fe6b87SJacob Keller return err; 5104b549a2eSEric Dumazet } 5114b549a2eSEric Dumazet 5124b549a2eSEric Dumazet static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) 5134b549a2eSEric Dumazet { 5144b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 5154b549a2eSEric Dumazet struct nlattr *opts; 5164b549a2eSEric Dumazet 517ae0be8deSMichal Kubecek opts = nla_nest_start_noflag(skb, TCA_OPTIONS); 5184b549a2eSEric Dumazet if (opts == NULL) 5194b549a2eSEric Dumazet goto nla_put_failure; 5204b549a2eSEric Dumazet 5214b549a2eSEric Dumazet if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, 5224b549a2eSEric Dumazet codel_time_to_us(q->cparams.target)) || 5234b549a2eSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, 5244b549a2eSEric Dumazet sch->limit) || 5254b549a2eSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, 5264b549a2eSEric Dumazet codel_time_to_us(q->cparams.interval)) || 5274b549a2eSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_ECN, 5284b549a2eSEric Dumazet q->cparams.ecn) || 5294b549a2eSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, 5304b549a2eSEric Dumazet q->quantum) || 5319d18562aSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_DROP_BATCH_SIZE, 5329d18562aSEric Dumazet q->drop_batch_size) || 53395b58430SEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_MEMORY_LIMIT, 53495b58430SEric Dumazet q->memory_limit) || 5354b549a2eSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, 5364b549a2eSEric Dumazet q->flows_cnt)) 5374b549a2eSEric Dumazet goto nla_put_failure; 5384b549a2eSEric Dumazet 53980ba92faSEric Dumazet if (q->cparams.ce_threshold != CODEL_DISABLED_THRESHOLD && 54080ba92faSEric Dumazet nla_put_u32(skb, TCA_FQ_CODEL_CE_THRESHOLD, 54180ba92faSEric Dumazet codel_time_to_us(q->cparams.ce_threshold))) 54280ba92faSEric Dumazet goto nla_put_failure; 54380ba92faSEric Dumazet 544d59b7d80SYang Yingliang return nla_nest_end(skb, opts); 5454b549a2eSEric Dumazet 5464b549a2eSEric Dumazet nla_put_failure: 5474b549a2eSEric Dumazet return -1; 5484b549a2eSEric Dumazet } 5494b549a2eSEric Dumazet 5504b549a2eSEric Dumazet static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) 5514b549a2eSEric Dumazet { 5524b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 5534b549a2eSEric Dumazet struct tc_fq_codel_xstats st = { 5544b549a2eSEric Dumazet .type = TCA_FQ_CODEL_XSTATS_QDISC, 5554b549a2eSEric Dumazet }; 5564b549a2eSEric Dumazet struct list_head *pos; 5574b549a2eSEric Dumazet 558669d67bfSSasha Levin st.qdisc_stats.maxpacket = q->cstats.maxpacket; 559669d67bfSSasha Levin st.qdisc_stats.drop_overlimit = q->drop_overlimit; 560669d67bfSSasha Levin st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; 561669d67bfSSasha Levin st.qdisc_stats.new_flow_count = q->new_flow_count; 56280ba92faSEric Dumazet st.qdisc_stats.ce_mark = q->cstats.ce_mark; 56395b58430SEric Dumazet st.qdisc_stats.memory_usage = q->memory_usage; 56495b58430SEric Dumazet st.qdisc_stats.drop_overmemory = q->drop_overmemory; 565669d67bfSSasha Levin 566edb09eb1SEric Dumazet sch_tree_lock(sch); 5674b549a2eSEric Dumazet list_for_each(pos, &q->new_flows) 5684b549a2eSEric Dumazet st.qdisc_stats.new_flows_len++; 5694b549a2eSEric Dumazet 5704b549a2eSEric Dumazet list_for_each(pos, &q->old_flows) 5714b549a2eSEric Dumazet st.qdisc_stats.old_flows_len++; 572edb09eb1SEric Dumazet sch_tree_unlock(sch); 5734b549a2eSEric Dumazet 5744b549a2eSEric Dumazet return gnet_stats_copy_app(d, &st, sizeof(st)); 5754b549a2eSEric Dumazet } 5764b549a2eSEric Dumazet 5774b549a2eSEric Dumazet static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) 5784b549a2eSEric Dumazet { 5794b549a2eSEric Dumazet return NULL; 5804b549a2eSEric Dumazet } 5814b549a2eSEric Dumazet 582143976ceSWANG Cong static unsigned long fq_codel_find(struct Qdisc *sch, u32 classid) 5834b549a2eSEric Dumazet { 5844b549a2eSEric Dumazet return 0; 5854b549a2eSEric Dumazet } 5864b549a2eSEric Dumazet 5874b549a2eSEric Dumazet static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, 5884b549a2eSEric Dumazet u32 classid) 5894b549a2eSEric Dumazet { 5904b549a2eSEric Dumazet return 0; 5914b549a2eSEric Dumazet } 5924b549a2eSEric Dumazet 593143976ceSWANG Cong static void fq_codel_unbind(struct Qdisc *q, unsigned long cl) 5944b549a2eSEric Dumazet { 5954b549a2eSEric Dumazet } 5964b549a2eSEric Dumazet 597cbaacc4eSAlexander Aring static struct tcf_block *fq_codel_tcf_block(struct Qdisc *sch, unsigned long cl, 598cbaacc4eSAlexander Aring struct netlink_ext_ack *extack) 5994b549a2eSEric Dumazet { 6004b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 6014b549a2eSEric Dumazet 6024b549a2eSEric Dumazet if (cl) 6034b549a2eSEric Dumazet return NULL; 6046529eabaSJiri Pirko return q->block; 6054b549a2eSEric Dumazet } 6064b549a2eSEric Dumazet 6074b549a2eSEric Dumazet static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, 6084b549a2eSEric Dumazet struct sk_buff *skb, struct tcmsg *tcm) 6094b549a2eSEric Dumazet { 6104b549a2eSEric Dumazet tcm->tcm_handle |= TC_H_MIN(cl); 6114b549a2eSEric Dumazet return 0; 6124b549a2eSEric Dumazet } 6134b549a2eSEric Dumazet 6144b549a2eSEric Dumazet static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, 6154b549a2eSEric Dumazet struct gnet_dump *d) 6164b549a2eSEric Dumazet { 6174b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 6184b549a2eSEric Dumazet u32 idx = cl - 1; 6194b549a2eSEric Dumazet struct gnet_stats_queue qs = { 0 }; 6204b549a2eSEric Dumazet struct tc_fq_codel_xstats xstats; 6214b549a2eSEric Dumazet 6224b549a2eSEric Dumazet if (idx < q->flows_cnt) { 6234b549a2eSEric Dumazet const struct fq_codel_flow *flow = &q->flows[idx]; 624edb09eb1SEric Dumazet const struct sk_buff *skb; 6254b549a2eSEric Dumazet 6264b549a2eSEric Dumazet memset(&xstats, 0, sizeof(xstats)); 6274b549a2eSEric Dumazet xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; 6284b549a2eSEric Dumazet xstats.class_stats.deficit = flow->deficit; 6294b549a2eSEric Dumazet xstats.class_stats.ldelay = 6304b549a2eSEric Dumazet codel_time_to_us(flow->cvars.ldelay); 6314b549a2eSEric Dumazet xstats.class_stats.count = flow->cvars.count; 6324b549a2eSEric Dumazet xstats.class_stats.lastcount = flow->cvars.lastcount; 6334b549a2eSEric Dumazet xstats.class_stats.dropping = flow->cvars.dropping; 6344b549a2eSEric Dumazet if (flow->cvars.dropping) { 6354b549a2eSEric Dumazet codel_tdiff_t delta = flow->cvars.drop_next - 6364b549a2eSEric Dumazet codel_get_time(); 6374b549a2eSEric Dumazet 6384b549a2eSEric Dumazet xstats.class_stats.drop_next = (delta >= 0) ? 6394b549a2eSEric Dumazet codel_time_to_us(delta) : 6404b549a2eSEric Dumazet -codel_time_to_us(-delta); 6414b549a2eSEric Dumazet } 642edb09eb1SEric Dumazet if (flow->head) { 643edb09eb1SEric Dumazet sch_tree_lock(sch); 644edb09eb1SEric Dumazet skb = flow->head; 6454b549a2eSEric Dumazet while (skb) { 6464b549a2eSEric Dumazet qs.qlen++; 6474b549a2eSEric Dumazet skb = skb->next; 6484b549a2eSEric Dumazet } 649edb09eb1SEric Dumazet sch_tree_unlock(sch); 650edb09eb1SEric Dumazet } 6514b549a2eSEric Dumazet qs.backlog = q->backlogs[idx]; 65277ddaff2SDave Taht qs.drops = 0; 6534b549a2eSEric Dumazet } 654aafddbf0SEric Dumazet if (gnet_stats_copy_queue(d, NULL, &qs, qs.qlen) < 0) 6554b549a2eSEric Dumazet return -1; 6564b549a2eSEric Dumazet if (idx < q->flows_cnt) 6574b549a2eSEric Dumazet return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); 6584b549a2eSEric Dumazet return 0; 6594b549a2eSEric Dumazet } 6604b549a2eSEric Dumazet 6614b549a2eSEric Dumazet static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) 6624b549a2eSEric Dumazet { 6634b549a2eSEric Dumazet struct fq_codel_sched_data *q = qdisc_priv(sch); 6644b549a2eSEric Dumazet unsigned int i; 6654b549a2eSEric Dumazet 6664b549a2eSEric Dumazet if (arg->stop) 6674b549a2eSEric Dumazet return; 6684b549a2eSEric Dumazet 6694b549a2eSEric Dumazet for (i = 0; i < q->flows_cnt; i++) { 6704b549a2eSEric Dumazet if (list_empty(&q->flows[i].flowchain) || 6714b549a2eSEric Dumazet arg->count < arg->skip) { 6724b549a2eSEric Dumazet arg->count++; 6734b549a2eSEric Dumazet continue; 6744b549a2eSEric Dumazet } 6754b549a2eSEric Dumazet if (arg->fn(sch, i + 1, arg) < 0) { 6764b549a2eSEric Dumazet arg->stop = 1; 6774b549a2eSEric Dumazet break; 6784b549a2eSEric Dumazet } 6794b549a2eSEric Dumazet arg->count++; 6804b549a2eSEric Dumazet } 6814b549a2eSEric Dumazet } 6824b549a2eSEric Dumazet 6834b549a2eSEric Dumazet static const struct Qdisc_class_ops fq_codel_class_ops = { 6844b549a2eSEric Dumazet .leaf = fq_codel_leaf, 685143976ceSWANG Cong .find = fq_codel_find, 6866529eabaSJiri Pirko .tcf_block = fq_codel_tcf_block, 6874b549a2eSEric Dumazet .bind_tcf = fq_codel_bind, 688143976ceSWANG Cong .unbind_tcf = fq_codel_unbind, 6894b549a2eSEric Dumazet .dump = fq_codel_dump_class, 6904b549a2eSEric Dumazet .dump_stats = fq_codel_dump_class_stats, 6914b549a2eSEric Dumazet .walk = fq_codel_walk, 6924b549a2eSEric Dumazet }; 6934b549a2eSEric Dumazet 6944b549a2eSEric Dumazet static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { 6954b549a2eSEric Dumazet .cl_ops = &fq_codel_class_ops, 6964b549a2eSEric Dumazet .id = "fq_codel", 6974b549a2eSEric Dumazet .priv_size = sizeof(struct fq_codel_sched_data), 6984b549a2eSEric Dumazet .enqueue = fq_codel_enqueue, 6994b549a2eSEric Dumazet .dequeue = fq_codel_dequeue, 7004b549a2eSEric Dumazet .peek = qdisc_peek_dequeued, 7014b549a2eSEric Dumazet .init = fq_codel_init, 7024b549a2eSEric Dumazet .reset = fq_codel_reset, 7034b549a2eSEric Dumazet .destroy = fq_codel_destroy, 7044b549a2eSEric Dumazet .change = fq_codel_change, 7054b549a2eSEric Dumazet .dump = fq_codel_dump, 7064b549a2eSEric Dumazet .dump_stats = fq_codel_dump_stats, 7074b549a2eSEric Dumazet .owner = THIS_MODULE, 7084b549a2eSEric Dumazet }; 7094b549a2eSEric Dumazet 7104b549a2eSEric Dumazet static int __init fq_codel_module_init(void) 7114b549a2eSEric Dumazet { 7124b549a2eSEric Dumazet return register_qdisc(&fq_codel_qdisc_ops); 7134b549a2eSEric Dumazet } 7144b549a2eSEric Dumazet 7154b549a2eSEric Dumazet static void __exit fq_codel_module_exit(void) 7164b549a2eSEric Dumazet { 7174b549a2eSEric Dumazet unregister_qdisc(&fq_codel_qdisc_ops); 7184b549a2eSEric Dumazet } 7194b549a2eSEric Dumazet 7204b549a2eSEric Dumazet module_init(fq_codel_module_init) 7214b549a2eSEric Dumazet module_exit(fq_codel_module_exit) 7224b549a2eSEric Dumazet MODULE_AUTHOR("Eric Dumazet"); 7234b549a2eSEric Dumazet MODULE_LICENSE("GPL"); 724