Example #1
0
static int fq_init(struct Qdisc *sch, struct nlattr *opt)
{
	struct fq_sched_data *q = qdisc_priv(sch);
	int err;

	sch->limit		= 10000;
	q->flow_plimit		= 100;
	q->quantum		= 2 * psched_mtu(qdisc_dev(sch));
	q->initial_quantum	= 10 * psched_mtu(qdisc_dev(sch));
	q->flow_refill_delay	= msecs_to_jiffies(40);
	q->flow_max_rate	= ~0U;
	q->rate_enable		= 1;
	q->new_flows.first	= NULL;
	q->old_flows.first	= NULL;
	q->delayed		= RB_ROOT;
	q->fq_root		= NULL;
	q->fq_trees_log		= ilog2(1024);
	q->orphan_mask		= 1024 - 1;
	qdisc_watchdog_init(&q->watchdog, sch);

	if (opt)
		err = fq_change(sch, opt);
	else
		err = fq_resize(sch, q->fq_trees_log);

	return err;
}
Example #2
0
static int tbf_init(struct Qdisc* sch, struct rtattr *opt)
{
	struct tbf_sched_data *q = qdisc_priv(sch);

	if (opt == NULL)
		return -EINVAL;

	q->t_c = psched_get_time();
	qdisc_watchdog_init(&q->watchdog, sch);
	q->qdisc = &noop_qdisc;

	return tbf_change(sch, opt);
}
Example #3
0
/* Initialize Qdisc */
static int wfq_init(struct Qdisc *sch, struct nlattr *opt)
{
	int i;
	struct wfq_sched_data *q = qdisc_priv(sch);
	struct Qdisc *child;

	if(sch->parent != TC_H_ROOT)
		return -EOPNOTSUPP;

        q->tokens = 0;
        q->time_ns = ktime_get_ns();
        q->sum_len_bytes = 0;
	qdisc_watchdog_init(&q->watchdog, sch);

        /* Initialize per-priority variables */
	for (i = 0; i < wfq_max_prio; i++)
	{
		q->prio_len_bytes[i] = 0;
		q->virtual_time[i] = 0;
	}

	/* Initialize per-queue variables */
	for (i = 0; i < wfq_max_queues; i++)
	{
		/* bfifo is in bytes */
		child = fifo_create_dflt(sch,
                                         &bfifo_qdisc_ops,
                                         wfq_max_buffer_bytes);
		if (likely(child))
			(q->queues[i]).qdisc = child;
		else
			goto err;

                (q->queues[i]).id = i;
		(q->queues[i]).head_fin_time = 0;
                (q->queues[i]).len_bytes = 0;
                (q->queues[i]).count = 0;
                (q->queues[i]).lastcount = 0;
                (q->queues[i]).marking = false;
                (q->queues[i]).rec_inv_sqrt = 0;
                (q->queues[i]).first_above_time = 0;
                (q->queues[i]).mark_next = false;
                (q->queues[i]).ldelay = 0;
	}

	return wfq_change(sch, opt);
err:
	wfq_destroy(sch);
	return -ENOMEM;
}
Example #4
0
static int tbf_init(struct Qdisc *sch, struct nlattr *opt,
		    struct netlink_ext_ack *extack)
{
	struct tbf_sched_data *q = qdisc_priv(sch);

	qdisc_watchdog_init(&q->watchdog, sch);
	q->qdisc = &noop_qdisc;

	if (!opt)
		return -EINVAL;

	q->t_c = ktime_get_ns();

	return tbf_change(sch, opt, extack);
}