fq.h 2.5 KB

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