2
0

663-remove_pfifo_fast.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. --- a/net/sched/sch_generic.c
  2. +++ b/net/sched/sch_generic.c
  3. @@ -438,139 +438,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
  4. .owner = THIS_MODULE,
  5. };
  6. -static const u8 prio2band[TC_PRIO_MAX + 1] = {
  7. - 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
  8. -};
  9. -
  10. -/* 3-band FIFO queue: old style, but should be a bit faster than
  11. - generic prio+fifo combination.
  12. - */
  13. -
  14. -#define PFIFO_FAST_BANDS 3
  15. -
  16. -/*
  17. - * Private data for a pfifo_fast scheduler containing:
  18. - * - queues for the three band
  19. - * - bitmap indicating which of the bands contain skbs
  20. - */
  21. -struct pfifo_fast_priv {
  22. - u32 bitmap;
  23. - struct sk_buff_head q[PFIFO_FAST_BANDS];
  24. -};
  25. -
  26. -/*
  27. - * Convert a bitmap to the first band number where an skb is queued, where:
  28. - * bitmap=0 means there are no skbs on any band.
  29. - * bitmap=1 means there is an skb on band 0.
  30. - * bitmap=7 means there are skbs on all 3 bands, etc.
  31. - */
  32. -static const int bitmap2band[] = {-1, 0, 1, 0, 2, 0, 1, 0};
  33. -
  34. -static inline struct sk_buff_head *band2list(struct pfifo_fast_priv *priv,
  35. - int band)
  36. -{
  37. - return priv->q + band;
  38. -}
  39. -
  40. -static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc)
  41. -{
  42. - if (skb_queue_len(&qdisc->q) < qdisc_dev(qdisc)->tx_queue_len) {
  43. - int band = prio2band[skb->priority & TC_PRIO_MAX];
  44. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  45. - struct sk_buff_head *list = band2list(priv, band);
  46. -
  47. - priv->bitmap |= (1 << band);
  48. - qdisc->q.qlen++;
  49. - return __qdisc_enqueue_tail(skb, qdisc, list);
  50. - }
  51. -
  52. - return qdisc_drop(skb, qdisc);
  53. -}
  54. -
  55. -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
  56. -{
  57. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  58. - int band = bitmap2band[priv->bitmap];
  59. -
  60. - if (likely(band >= 0)) {
  61. - struct sk_buff_head *list = band2list(priv, band);
  62. - struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list);
  63. -
  64. - qdisc->q.qlen--;
  65. - if (skb_queue_empty(list))
  66. - priv->bitmap &= ~(1 << band);
  67. -
  68. - return skb;
  69. - }
  70. -
  71. - return NULL;
  72. -}
  73. -
  74. -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
  75. -{
  76. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  77. - int band = bitmap2band[priv->bitmap];
  78. -
  79. - if (band >= 0) {
  80. - struct sk_buff_head *list = band2list(priv, band);
  81. -
  82. - return skb_peek(list);
  83. - }
  84. -
  85. - return NULL;
  86. -}
  87. -
  88. -static void pfifo_fast_reset(struct Qdisc *qdisc)
  89. -{
  90. - int prio;
  91. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  92. -
  93. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  94. - __qdisc_reset_queue(qdisc, band2list(priv, prio));
  95. -
  96. - priv->bitmap = 0;
  97. - qdisc->qstats.backlog = 0;
  98. - qdisc->q.qlen = 0;
  99. -}
  100. -
  101. -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  102. -{
  103. - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  104. -
  105. - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
  106. - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
  107. - goto nla_put_failure;
  108. - return skb->len;
  109. -
  110. -nla_put_failure:
  111. - return -1;
  112. -}
  113. -
  114. -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
  115. -{
  116. - int prio;
  117. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  118. -
  119. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  120. - __skb_queue_head_init(band2list(priv, prio));
  121. -
  122. - /* Can by-pass the queue discipline */
  123. - qdisc->flags |= TCQ_F_CAN_BYPASS;
  124. - return 0;
  125. -}
  126. -
  127. -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  128. - .id = "pfifo_fast",
  129. - .priv_size = sizeof(struct pfifo_fast_priv),
  130. - .enqueue = pfifo_fast_enqueue,
  131. - .dequeue = pfifo_fast_dequeue,
  132. - .peek = pfifo_fast_peek,
  133. - .init = pfifo_fast_init,
  134. - .reset = pfifo_fast_reset,
  135. - .dump = pfifo_fast_dump,
  136. - .owner = THIS_MODULE,
  137. -};
  138. -
  139. static struct lock_class_key qdisc_tx_busylock;
  140. struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,