fq.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include <linux/skbuff.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/types.h>
  12. struct fq_tin;
  13. /**
  14. * struct fq_flow - per traffic flow queue
  15. *
  16. * @tin: owner of this flow. Used to manage collisions, i.e. when a packet
  17. * hashes to an index which points to a flow that is already owned by a
  18. * different tin the packet is destined to. In such case the implementer
  19. * must provide a fallback flow
  20. * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++
  21. * (deficit round robin) based round robin queuing similar to the one
  22. * found in net/sched/sch_fq_codel.c
  23. * @queue: sk_buff queue to hold packets
  24. * @backlog: number of bytes pending in the queue. The number of packets can be
  25. * found in @queue.qlen
  26. * @deficit: used for DRR++
  27. */
  28. struct fq_flow {
  29. struct fq_tin *tin;
  30. struct list_head flowchain;
  31. struct sk_buff_head queue;
  32. u32 backlog;
  33. int deficit;
  34. };
  35. /**
  36. * struct fq_tin - a logical container of fq_flows
  37. *
  38. * Used to group fq_flows into a logical aggregate. DRR++ scheme is used to
  39. * pull interleaved packets out of the associated flows.
  40. *
  41. * @new_flows: linked list of fq_flow
  42. * @old_flows: linked list of fq_flow
  43. */
  44. struct fq_tin {
  45. struct list_head new_flows;
  46. struct list_head old_flows;
  47. struct list_head tin_list;
  48. struct fq_flow default_flow;
  49. u32 backlog_bytes;
  50. u32 backlog_packets;
  51. u32 overlimit;
  52. u32 collisions;
  53. u32 flows;
  54. u32 tx_bytes;
  55. u32 tx_packets;
  56. };
  57. /**
  58. * struct fq - main container for fair queuing purposes
  59. *
  60. * @limit: max number of packets that can be queued across all flows
  61. * @backlog: number of packets queued across all flows
  62. */
  63. struct fq {
  64. struct fq_flow *flows;
  65. unsigned long *flows_bitmap;
  66. struct list_head tin_backlog;
  67. spinlock_t lock;
  68. u32 flows_cnt;
  69. u32 limit;
  70. u32 memory_limit;
  71. u32 memory_usage;
  72. u32 quantum;
  73. u32 backlog;
  74. u32 overlimit;
  75. u32 overmemory;
  76. u32 collisions;
  77. };
  78. typedef struct sk_buff *fq_tin_dequeue_t(struct fq *,
  79. struct fq_tin *,
  80. struct fq_flow *flow);
  81. typedef void fq_skb_free_t(struct fq *,
  82. struct fq_tin *,
  83. struct fq_flow *,
  84. struct sk_buff *);
  85. /* Return %true to filter (drop) the frame. */
  86. typedef bool fq_skb_filter_t(struct fq *,
  87. struct fq_tin *,
  88. struct fq_flow *,
  89. struct sk_buff *,
  90. void *);
  91. typedef struct fq_flow *fq_flow_get_default_t(struct fq *,
  92. struct fq_tin *,
  93. int idx,
  94. struct sk_buff *);
  95. #endif