18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2016 Qualcomm Atheros, Inc 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Based on net/sched/sch_fq_codel.c 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef __NET_SCHED_FQ_H 88c2ecf20Sopenharmony_ci#define __NET_SCHED_FQ_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistruct fq_tin; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/** 138c2ecf20Sopenharmony_ci * struct fq_flow - per traffic flow queue 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * @tin: owner of this flow. Used to manage collisions, i.e. when a packet 168c2ecf20Sopenharmony_ci * hashes to an index which points to a flow that is already owned by a 178c2ecf20Sopenharmony_ci * different tin the packet is destined to. In such case the implementer 188c2ecf20Sopenharmony_ci * must provide a fallback flow 198c2ecf20Sopenharmony_ci * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++ 208c2ecf20Sopenharmony_ci * (deficit round robin) based round robin queuing similar to the one 218c2ecf20Sopenharmony_ci * found in net/sched/sch_fq_codel.c 228c2ecf20Sopenharmony_ci * @backlogchain: can be linked to other fq_flow and fq. Used to keep track of 238c2ecf20Sopenharmony_ci * fat flows and efficient head-dropping if packet limit is reached 248c2ecf20Sopenharmony_ci * @queue: sk_buff queue to hold packets 258c2ecf20Sopenharmony_ci * @backlog: number of bytes pending in the queue. The number of packets can be 268c2ecf20Sopenharmony_ci * found in @queue.qlen 278c2ecf20Sopenharmony_ci * @deficit: used for DRR++ 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_cistruct fq_flow { 308c2ecf20Sopenharmony_ci struct fq_tin *tin; 318c2ecf20Sopenharmony_ci struct list_head flowchain; 328c2ecf20Sopenharmony_ci struct list_head backlogchain; 338c2ecf20Sopenharmony_ci struct sk_buff_head queue; 348c2ecf20Sopenharmony_ci u32 backlog; 358c2ecf20Sopenharmony_ci int deficit; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/** 398c2ecf20Sopenharmony_ci * struct fq_tin - a logical container of fq_flows 408c2ecf20Sopenharmony_ci * 418c2ecf20Sopenharmony_ci * Used to group fq_flows into a logical aggregate. DRR++ scheme is used to 428c2ecf20Sopenharmony_ci * pull interleaved packets out of the associated flows. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * @new_flows: linked list of fq_flow 458c2ecf20Sopenharmony_ci * @old_flows: linked list of fq_flow 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistruct fq_tin { 488c2ecf20Sopenharmony_ci struct list_head new_flows; 498c2ecf20Sopenharmony_ci struct list_head old_flows; 508c2ecf20Sopenharmony_ci u32 backlog_bytes; 518c2ecf20Sopenharmony_ci u32 backlog_packets; 528c2ecf20Sopenharmony_ci u32 overlimit; 538c2ecf20Sopenharmony_ci u32 collisions; 548c2ecf20Sopenharmony_ci u32 flows; 558c2ecf20Sopenharmony_ci u32 tx_bytes; 568c2ecf20Sopenharmony_ci u32 tx_packets; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/** 608c2ecf20Sopenharmony_ci * struct fq - main container for fair queuing purposes 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * @backlogs: linked to fq_flows. Used to maintain fat flows for efficient 638c2ecf20Sopenharmony_ci * head-dropping when @backlog reaches @limit 648c2ecf20Sopenharmony_ci * @limit: max number of packets that can be queued across all flows 658c2ecf20Sopenharmony_ci * @backlog: number of packets queued across all flows 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_cistruct fq { 688c2ecf20Sopenharmony_ci struct fq_flow *flows; 698c2ecf20Sopenharmony_ci struct list_head backlogs; 708c2ecf20Sopenharmony_ci spinlock_t lock; 718c2ecf20Sopenharmony_ci u32 flows_cnt; 728c2ecf20Sopenharmony_ci u32 limit; 738c2ecf20Sopenharmony_ci u32 memory_limit; 748c2ecf20Sopenharmony_ci u32 memory_usage; 758c2ecf20Sopenharmony_ci u32 quantum; 768c2ecf20Sopenharmony_ci u32 backlog; 778c2ecf20Sopenharmony_ci u32 overlimit; 788c2ecf20Sopenharmony_ci u32 overmemory; 798c2ecf20Sopenharmony_ci u32 collisions; 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_citypedef struct sk_buff *fq_tin_dequeue_t(struct fq *, 838c2ecf20Sopenharmony_ci struct fq_tin *, 848c2ecf20Sopenharmony_ci struct fq_flow *flow); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_citypedef void fq_skb_free_t(struct fq *, 878c2ecf20Sopenharmony_ci struct fq_tin *, 888c2ecf20Sopenharmony_ci struct fq_flow *, 898c2ecf20Sopenharmony_ci struct sk_buff *); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Return %true to filter (drop) the frame. */ 928c2ecf20Sopenharmony_citypedef bool fq_skb_filter_t(struct fq *, 938c2ecf20Sopenharmony_ci struct fq_tin *, 948c2ecf20Sopenharmony_ci struct fq_flow *, 958c2ecf20Sopenharmony_ci struct sk_buff *, 968c2ecf20Sopenharmony_ci void *); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_citypedef struct fq_flow *fq_flow_get_default_t(struct fq *, 998c2ecf20Sopenharmony_ci struct fq_tin *, 1008c2ecf20Sopenharmony_ci int idx, 1018c2ecf20Sopenharmony_ci struct sk_buff *); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif 104