Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2016 Qualcomm Atheros, Inc
0004  *
0005  * Based on net/sched/sch_fq_codel.c
0006  */
0007 #ifndef __NET_SCHED_FQ_H
0008 #define __NET_SCHED_FQ_H
0009 
0010 #include <linux/skbuff.h>
0011 #include <linux/spinlock.h>
0012 #include <linux/types.h>
0013 
0014 struct fq_tin;
0015 
0016 /**
0017  * struct fq_flow - per traffic flow queue
0018  *
0019  * @tin: owner of this flow. Used to manage collisions, i.e. when a packet
0020  *  hashes to an index which points to a flow that is already owned by a
0021  *  different tin the packet is destined to. In such case the implementer
0022  *  must provide a fallback flow
0023  * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++
0024  *  (deficit round robin) based round robin queuing similar to the one
0025  *  found in net/sched/sch_fq_codel.c
0026  * @queue: sk_buff queue to hold packets
0027  * @backlog: number of bytes pending in the queue. The number of packets can be
0028  *  found in @queue.qlen
0029  * @deficit: used for DRR++
0030  */
0031 struct fq_flow {
0032     struct fq_tin *tin;
0033     struct list_head flowchain;
0034     struct sk_buff_head queue;
0035     u32 backlog;
0036     int deficit;
0037 };
0038 
0039 /**
0040  * struct fq_tin - a logical container of fq_flows
0041  *
0042  * Used to group fq_flows into a logical aggregate. DRR++ scheme is used to
0043  * pull interleaved packets out of the associated flows.
0044  *
0045  * @new_flows: linked list of fq_flow
0046  * @old_flows: linked list of fq_flow
0047  */
0048 struct fq_tin {
0049     struct list_head new_flows;
0050     struct list_head old_flows;
0051     struct list_head tin_list;
0052     struct fq_flow default_flow;
0053     u32 backlog_bytes;
0054     u32 backlog_packets;
0055     u32 overlimit;
0056     u32 collisions;
0057     u32 flows;
0058     u32 tx_bytes;
0059     u32 tx_packets;
0060 };
0061 
0062 /**
0063  * struct fq - main container for fair queuing purposes
0064  *
0065  * @limit: max number of packets that can be queued across all flows
0066  * @backlog: number of packets queued across all flows
0067  */
0068 struct fq {
0069     struct fq_flow *flows;
0070     unsigned long *flows_bitmap;
0071 
0072     struct list_head tin_backlog;
0073     spinlock_t lock;
0074     u32 flows_cnt;
0075     u32 limit;
0076     u32 memory_limit;
0077     u32 memory_usage;
0078     u32 quantum;
0079     u32 backlog;
0080     u32 overlimit;
0081     u32 overmemory;
0082     u32 collisions;
0083 };
0084 
0085 typedef struct sk_buff *fq_tin_dequeue_t(struct fq *,
0086                      struct fq_tin *,
0087                      struct fq_flow *flow);
0088 
0089 typedef void fq_skb_free_t(struct fq *,
0090                struct fq_tin *,
0091                struct fq_flow *,
0092                struct sk_buff *);
0093 
0094 /* Return %true to filter (drop) the frame. */
0095 typedef bool fq_skb_filter_t(struct fq *,
0096                  struct fq_tin *,
0097                  struct fq_flow *,
0098                  struct sk_buff *,
0099                  void *);
0100 
0101 typedef struct fq_flow *fq_flow_get_default_t(struct fq *,
0102                           struct fq_tin *,
0103                           int idx,
0104                           struct sk_buff *);
0105 
0106 #endif