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

Commit 8cc472f2 authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "net_sched: Add flow control support to prio qdisc" into msm-4.9

parents 01d8a20d abb705d4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ static inline __be16 tc_skb_protocol(const struct sk_buff *skb)
	return skb->protocol;
}

extern int tc_qdisc_flow_control(struct net_device *dev, u32 tcm_handle,
				  int flow_enable);
/* Calculate maximal size of packet seen by hard_start_xmit
   routine of this device.
 */
+3 −0
Original line number Diff line number Diff line
@@ -130,8 +130,11 @@ struct tc_fifo_qopt {
struct tc_prio_qopt {
	int	bands;			/* Number of bands */
	__u8	priomap[TC_PRIO_MAX+1];	/* Map: logical priority -> PRIO band */
	__u8	enable_flow;		/* Enable dequeue */
};

#define TCQ_PRIO_FLOW_CONTROL 1

/* MULTIQ section */

struct tc_multiq_qopt {
+39 −0
Original line number Diff line number Diff line
@@ -1178,6 +1178,45 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
	return 0;
}

/*
 * enable/disable flow on qdisc.
 */
int
tc_qdisc_flow_control(struct net_device *dev, u32 tcm_handle, int enable_flow)
{
	struct Qdisc *q;
	int qdisc_len = 0;
	struct __qdisc_change_req {
		struct nlattr attr;
		struct tc_prio_qopt data;
	} req =	{
		.attr = {sizeof(struct __qdisc_change_req), TCA_OPTIONS},
		.data = {3, {1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}, 1}
		};

	/* override flow bit */
	req.data.enable_flow = enable_flow;

	/* look up using tcm handle */
	q = qdisc_lookup(dev, tcm_handle);

	/* call registered change function */
	if (likely(q && q->ops)) {
		if (likely(q->ops->change)) {
			qdisc_len = q->q.qlen;
			if (q->ops->change(q, &req.attr))
				pr_err("%s(): qdisc change failed", __func__);
		} else {
			WARN_ONCE(1, "%s(): called on queue which does %s",
				  __func__, "not support change() operation");
		}
	} else {
		WARN_ONCE(1, "%s(): called on bad queue", __func__);
	}
	return qdisc_len;
}
EXPORT_SYMBOL(tc_qdisc_flow_control);

/*
 * Create/change qdisc.
 */
+10 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ struct prio_sched_data {
	struct tcf_proto __rcu *filter_list;
	u8  prio2band[TC_PRIO_MAX+1];
	struct Qdisc *queues[TCQ_PRIO_BANDS];
	u8 enable_flow;
};


@@ -99,6 +100,9 @@ static struct sk_buff *prio_peek(struct Qdisc *sch)
	struct prio_sched_data *q = qdisc_priv(sch);
	int prio;

	if (!q->enable_flow)
		return NULL;

	for (prio = 0; prio < q->bands; prio++) {
		struct Qdisc *qdisc = q->queues[prio];
		struct sk_buff *skb = qdisc->ops->peek(qdisc);
@@ -113,6 +117,9 @@ static struct sk_buff *prio_dequeue(struct Qdisc *sch)
	struct prio_sched_data *q = qdisc_priv(sch);
	int prio;

	if (!q->enable_flow)
		return NULL;

	for (prio = 0; prio < q->bands; prio++) {
		struct Qdisc *qdisc = q->queues[prio];
		struct sk_buff *skb = qdisc_dequeue_peeked(qdisc);
@@ -137,6 +144,7 @@ prio_reset(struct Qdisc *sch)
		qdisc_reset(q->queues[prio]);
	sch->qstats.backlog = 0;
	sch->q.qlen = 0;
	q->enable_flow = 1;
}

static void
@@ -181,6 +189,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
	}

	sch_tree_lock(sch);
	q->enable_flow = qopt->enable_flow;
	q->bands = qopt->bands;
	memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);

@@ -214,6 +223,7 @@ static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
	struct tc_prio_qopt opt;

	opt.bands = q->bands;
	opt.enable_flow = q->enable_flow;
	memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX + 1);

	if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))