pkt_sched: Get rid of u32_list.
[safe/jmp/linux-2.6] / include / net / sch_generic.h
index ea71705..8a44386 100644 (file)
@@ -23,6 +23,12 @@ struct qdisc_rate_table
        int             refcnt;
 };
 
+enum qdisc_state_t
+{
+       __QDISC_STATE_RUNNING,
+       __QDISC_STATE_SCHED,
+};
+
 struct Qdisc
 {
        int                     (*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
@@ -36,8 +42,11 @@ struct Qdisc
        u32                     handle;
        u32                     parent;
        atomic_t                refcnt;
+       unsigned long           state;
+       struct sk_buff          *gso_skb;
        struct sk_buff_head     q;
        struct netdev_queue     *dev_queue;
+       struct Qdisc            *next_sched;
        struct list_head        list;
 
        struct gnet_stats_basic bstats;
@@ -47,6 +56,8 @@ struct Qdisc
        int                     (*reshape_fail)(struct sk_buff *skb,
                                        struct Qdisc *q);
 
+       void                    *u32_node;
+
        /* This field is deprecated, but it is still used by CBQ
         * and it will live until better solution will be invented.
         */
@@ -154,18 +165,40 @@ struct tcf_proto
        struct tcf_proto_ops    *ops;
 };
 
+static inline spinlock_t *qdisc_lock(struct Qdisc *qdisc)
+{
+       return &qdisc->q.lock;
+}
+
+static inline struct Qdisc *qdisc_root(struct Qdisc *qdisc)
+{
+       return qdisc->dev_queue->qdisc;
+}
+
+static inline spinlock_t *qdisc_root_lock(struct Qdisc *qdisc)
+{
+       struct Qdisc *root = qdisc_root(qdisc);
+
+       return qdisc_lock(root);
+}
+
 static inline struct net_device *qdisc_dev(struct Qdisc *qdisc)
 {
        return qdisc->dev_queue->dev;
 }
 
-extern void qdisc_lock_tree(struct net_device *dev);
-extern void qdisc_unlock_tree(struct net_device *dev);
+static inline void sch_tree_lock(struct Qdisc *q)
+{
+       spin_lock_bh(qdisc_root_lock(q));
+}
 
-#define sch_tree_lock(q)       qdisc_lock_tree(qdisc_dev(q))
-#define sch_tree_unlock(q)     qdisc_unlock_tree(qdisc_dev(q))
-#define tcf_tree_lock(tp)      qdisc_lock_tree(qdisc_dev((tp)->q))
-#define tcf_tree_unlock(tp)    qdisc_unlock_tree(qdisc_dev((tp)->q))
+static inline void sch_tree_unlock(struct Qdisc *q)
+{
+       spin_unlock_bh(qdisc_root_lock(q));
+}
+
+#define tcf_tree_lock(tp)      sch_tree_lock((tp)->q)
+#define tcf_tree_unlock(tp)    sch_tree_unlock((tp)->q)
 
 extern struct Qdisc noop_qdisc;
 extern struct Qdisc_ops noop_qdisc_ops;
@@ -227,6 +260,52 @@ extern struct Qdisc *qdisc_create_dflt(struct net_device *dev,
 extern void tcf_destroy(struct tcf_proto *tp);
 extern void tcf_destroy_chain(struct tcf_proto **fl);
 
+/* Reset all TX qdiscs of a device.  */
+static inline void qdisc_reset_all_tx(struct net_device *dev)
+{
+       unsigned int i;
+       for (i = 0; i < dev->num_tx_queues; i++)
+               qdisc_reset(netdev_get_tx_queue(dev, i)->qdisc);
+}
+
+/* Are all TX queues of the device empty?  */
+static inline bool qdisc_all_tx_empty(const struct net_device *dev)
+{
+       unsigned int i;
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               const struct Qdisc *q = txq->qdisc;
+
+               if (q->q.qlen)
+                       return false;
+       }
+       return true;
+}
+
+/* Are any of the TX qdiscs changing?  */
+static inline bool qdisc_tx_changing(struct net_device *dev)
+{
+       unsigned int i;
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               if (txq->qdisc != txq->qdisc_sleeping)
+                       return true;
+       }
+       return false;
+}
+
+/* Is the device using the noop qdisc on all queues?  */
+static inline bool qdisc_tx_is_noop(const struct net_device *dev)
+{
+       unsigned int i;
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               if (txq->qdisc != &noop_qdisc)
+                       return false;
+       }
+       return true;
+}
+
 static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
                                       struct sk_buff_head *list)
 {
@@ -297,7 +376,7 @@ static inline void __qdisc_reset_queue(struct Qdisc *sch,
         * We do not know the backlog in bytes of this list, it
         * is up to the caller to correct it
         */
-       skb_queue_purge(list);
+       __skb_queue_purge(list);
 }
 
 static inline void qdisc_reset_queue(struct Qdisc *sch)