2
0

663-remove_pfifo_fast.patch 3.6 KB

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