Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc135b23 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: Define accessors to manipulate QDISC_STATE_RUNNING



Define three helpers to manipulate QDISC_STATE_RUNNIG flag, that a
second patch will move on another location.

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f26f547
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -95,7 +95,7 @@ extern void __qdisc_run(struct Qdisc *q);


static inline void qdisc_run(struct Qdisc *q)
static inline void qdisc_run(struct Qdisc *q)
{
{
	if (!test_and_set_bit(__QDISC_STATE_RUNNING, &q->state))
	if (qdisc_run_begin(q))
		__qdisc_run(q);
		__qdisc_run(q);
}
}


+15 −0
Original line number Original line Diff line number Diff line
@@ -76,6 +76,21 @@ struct Qdisc {
	struct rcu_head     rcu_head;
	struct rcu_head     rcu_head;
};
};


static inline bool qdisc_is_running(struct Qdisc *qdisc)
{
	return test_bit(__QDISC_STATE_RUNNING, &qdisc->state);
}

static inline bool qdisc_run_begin(struct Qdisc *qdisc)
{
	return !test_and_set_bit(__QDISC_STATE_RUNNING, &qdisc->state);
}

static inline void qdisc_run_end(struct Qdisc *qdisc)
{
	clear_bit(__QDISC_STATE_RUNNING, &qdisc->state);
}

struct Qdisc_class_ops {
struct Qdisc_class_ops {
	/* Child qdisc manipulation */
	/* Child qdisc manipulation */
	struct netdev_queue *	(*select_queue)(struct Qdisc *, struct tcmsg *);
	struct netdev_queue *	(*select_queue)(struct Qdisc *, struct tcmsg *);
+2 −2
Original line number Original line Diff line number Diff line
@@ -2047,7 +2047,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
		kfree_skb(skb);
		kfree_skb(skb);
		rc = NET_XMIT_DROP;
		rc = NET_XMIT_DROP;
	} else if ((q->flags & TCQ_F_CAN_BYPASS) && !qdisc_qlen(q) &&
	} else if ((q->flags & TCQ_F_CAN_BYPASS) && !qdisc_qlen(q) &&
		   !test_and_set_bit(__QDISC_STATE_RUNNING, &q->state)) {
		   qdisc_run_begin(q)) {
		/*
		/*
		 * This is a work-conserving queue; there are no old skbs
		 * This is a work-conserving queue; there are no old skbs
		 * waiting to be sent out; and the qdisc is not running -
		 * waiting to be sent out; and the qdisc is not running -
@@ -2059,7 +2059,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
		if (sch_direct_xmit(skb, q, dev, txq, root_lock))
		if (sch_direct_xmit(skb, q, dev, txq, root_lock))
			__qdisc_run(q);
			__qdisc_run(q);
		else
		else
			clear_bit(__QDISC_STATE_RUNNING, &q->state);
			qdisc_run_end(q);


		rc = NET_XMIT_SUCCESS;
		rc = NET_XMIT_SUCCESS;
	} else {
	} else {
+2 −2
Original line number Original line Diff line number Diff line
@@ -205,7 +205,7 @@ void __qdisc_run(struct Qdisc *q)
		}
		}
	}
	}


	clear_bit(__QDISC_STATE_RUNNING, &q->state);
	qdisc_run_end(q);
}
}


unsigned long dev_trans_start(struct net_device *dev)
unsigned long dev_trans_start(struct net_device *dev)
@@ -797,7 +797,7 @@ static bool some_qdisc_is_busy(struct net_device *dev)


		spin_lock_bh(root_lock);
		spin_lock_bh(root_lock);


		val = (test_bit(__QDISC_STATE_RUNNING, &q->state) ||
		val = (qdisc_is_running(q) ||
		       test_bit(__QDISC_STATE_SCHED, &q->state));
		       test_bit(__QDISC_STATE_SCHED, &q->state));


		spin_unlock_bh(root_lock);
		spin_unlock_bh(root_lock);