linux/include/net/fq.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * Copyright (c) 2016 Qualcomm Atheros, Inc
   4 *
   5 * Based on net/sched/sch_fq_codel.c
   6 */
   7#ifndef __NET_SCHED_FQ_H
   8#define __NET_SCHED_FQ_H
   9
  10struct fq_tin;
  11
  12/**
  13 * struct fq_flow - per traffic flow queue
  14 *
  15 * @tin: owner of this flow. Used to manage collisions, i.e. when a packet
  16 *      hashes to an index which points to a flow that is already owned by a
  17 *      different tin the packet is destined to. In such case the implementer
  18 *      must provide a fallback flow
  19 * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++
  20 *      (deficit round robin) based round robin queuing similar to the one
  21 *      found in net/sched/sch_fq_codel.c
  22 * @backlogchain: can be linked to other fq_flow and fq. Used to keep track of
  23 *      fat flows and efficient head-dropping if packet limit is reached
  24 * @queue: sk_buff queue to hold packets
  25 * @backlog: number of bytes pending in the queue. The number of packets can be
  26 *      found in @queue.qlen
  27 * @deficit: used for DRR++
  28 */
  29struct fq_flow {
  30        struct fq_tin *tin;
  31        struct list_head flowchain;
  32        struct list_head backlogchain;
  33        struct sk_buff_head queue;
  34        u32 backlog;
  35        int deficit;
  36};
  37
  38/**
  39 * struct fq_tin - a logical container of fq_flows
  40 *
  41 * Used to group fq_flows into a logical aggregate. DRR++ scheme is used to
  42 * pull interleaved packets out of the associated flows.
  43 *
  44 * @new_flows: linked list of fq_flow
  45 * @old_flows: linked list of fq_flow
  46 */
  47struct fq_tin {
  48        struct list_head new_flows;
  49        struct list_head old_flows;
  50        u32 backlog_bytes;
  51        u32 backlog_packets;
  52        u32 overlimit;
  53        u32 collisions;
  54        u32 flows;
  55        u32 tx_bytes;
  56        u32 tx_packets;
  57};
  58
  59/**
  60 * struct fq - main container for fair queuing purposes
  61 *
  62 * @backlogs: linked to fq_flows. Used to maintain fat flows for efficient
  63 *      head-dropping when @backlog reaches @limit
  64 * @limit: max number of packets that can be queued across all flows
  65 * @backlog: number of packets queued across all flows
  66 */
  67struct fq {
  68        struct fq_flow *flows;
  69        struct list_head backlogs;
  70        spinlock_t lock;
  71        u32 flows_cnt;
  72        u32 perturbation;
  73        u32 limit;
  74        u32 memory_limit;
  75        u32 memory_usage;
  76        u32 quantum;
  77        u32 backlog;
  78        u32 overlimit;
  79        u32 overmemory;
  80        u32 collisions;
  81};
  82
  83typedef struct sk_buff *fq_tin_dequeue_t(struct fq *,
  84                                         struct fq_tin *,
  85                                         struct fq_flow *flow);
  86
  87typedef void fq_skb_free_t(struct fq *,
  88                           struct fq_tin *,
  89                           struct fq_flow *,
  90                           struct sk_buff *);
  91
  92/* Return %true to filter (drop) the frame. */
  93typedef bool fq_skb_filter_t(struct fq *,
  94                             struct fq_tin *,
  95                             struct fq_flow *,
  96                             struct sk_buff *,
  97                             void *);
  98
  99typedef struct fq_flow *fq_flow_get_default_t(struct fq *,
 100                                              struct fq_tin *,
 101                                              int idx,
 102                                              struct sk_buff *);
 103
 104#endif
 105