662-remove_pfifo_fast.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. --- a/net/sched/sch_generic.c
  2. +++ b/net/sched/sch_generic.c
  3. @@ -449,146 +449,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 qdisc_skb_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 qdisc_skb_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. - struct sk_buff **to_free)
  42. -{
  43. - if (qdisc->q.qlen < 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 qdisc_skb_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, to_free);
  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 qdisc_skb_head *qh = band2list(priv, band);
  63. - struct sk_buff *skb = __qdisc_dequeue_head(qh);
  64. -
  65. - if (likely(skb != NULL)) {
  66. - qdisc_qstats_backlog_dec(qdisc, skb);
  67. - qdisc_bstats_update(qdisc, skb);
  68. - }
  69. -
  70. - qdisc->q.qlen--;
  71. - if (qh->qlen == 0)
  72. - priv->bitmap &= ~(1 << band);
  73. -
  74. - return skb;
  75. - }
  76. -
  77. - return NULL;
  78. -}
  79. -
  80. -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
  81. -{
  82. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  83. - int band = bitmap2band[priv->bitmap];
  84. -
  85. - if (band >= 0) {
  86. - struct qdisc_skb_head *qh = band2list(priv, band);
  87. -
  88. - return qh->head;
  89. - }
  90. -
  91. - return NULL;
  92. -}
  93. -
  94. -static void pfifo_fast_reset(struct Qdisc *qdisc)
  95. -{
  96. - int prio;
  97. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  98. -
  99. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  100. - __qdisc_reset_queue(band2list(priv, prio));
  101. -
  102. - priv->bitmap = 0;
  103. - qdisc->qstats.backlog = 0;
  104. - qdisc->q.qlen = 0;
  105. -}
  106. -
  107. -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  108. -{
  109. - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  110. -
  111. - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
  112. - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
  113. - goto nla_put_failure;
  114. - return skb->len;
  115. -
  116. -nla_put_failure:
  117. - return -1;
  118. -}
  119. -
  120. -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
  121. -{
  122. - int prio;
  123. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  124. -
  125. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  126. - qdisc_skb_head_init(band2list(priv, prio));
  127. -
  128. - /* Can by-pass the queue discipline */
  129. - qdisc->flags |= TCQ_F_CAN_BYPASS;
  130. - return 0;
  131. -}
  132. -
  133. -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  134. - .id = "pfifo_fast",
  135. - .priv_size = sizeof(struct pfifo_fast_priv),
  136. - .enqueue = pfifo_fast_enqueue,
  137. - .dequeue = pfifo_fast_dequeue,
  138. - .peek = pfifo_fast_peek,
  139. - .init = pfifo_fast_init,
  140. - .reset = pfifo_fast_reset,
  141. - .dump = pfifo_fast_dump,
  142. - .owner = THIS_MODULE,
  143. -};
  144. -EXPORT_SYMBOL(pfifo_fast_ops);
  145. -
  146. static struct lock_class_key qdisc_tx_busylock;
  147. static struct lock_class_key qdisc_running_key;