Ejemplo n.º 1
0
/* Borrow from codel_should_drop in Linux kernel */
static bool codel_should_mark(const struct sk_buff *skb,
	                      struct wfq_class *cl,
			      s64 now_ns)
{
        bool ok_to_mark;
        codel_time_t now = ns_to_codel_time(now_ns);

        cl->ldelay = ns_to_codel_time(now_ns - skb->tstamp.tv64);

	if (codel_time_before(cl->ldelay, (codel_time_t)wfq_codel_target) ||
	    cl->len_bytes <= wfq_max_pkt_bytes)
	{
		/* went below - stay below for at least interval */
		cl->first_above_time = 0;
		return false;
	}

	ok_to_mark = false;
	if (cl->first_above_time == 0)
	{
                /* just went above from below. If we stay above
         	 * for at least interval we'll say it's ok to mark
         	 */
                 cl->first_above_time = now + wfq_codel_interval;
	}
	else if (codel_time_after(now, cl->first_above_time))
	{
		ok_to_mark = true;
	}

	return ok_to_mark;
}
Ejemplo n.º 2
0
/* TCN marking scheme */
static inline void tcn_marking(struct sk_buff *skb)
{
        codel_time_t delay;
        delay = ns_to_codel_time(ktime_get_ns() - skb->tstamp.tv64);

        if (codel_time_after(delay, (codel_time_t)wfq_tcn_thresh))
                INET_ECN_set_ce(skb);
}
Ejemplo n.º 3
0
static int
codel_should_drop(struct codel *c, class_queue_t *q, struct mbuf *m,
    u_int64_t now)
{
	struct m_tag *mtag;
	uint64_t *enqueue_time;

	if (m == NULL) {
		c->vars.first_above_time = 0;
		return (0);
	}

	mtag = m_tag_locate(m, MTAG_CODEL, 0, NULL);
	if (mtag == NULL) {
		/* Only one warning per second. */
		if (ppsratecheck(&c->last_log, &c->last_pps, 1))
			printf("%s: could not found the packet mtag!\n",
			    __func__);
		c->vars.first_above_time = 0;
		return (0);
	}
	enqueue_time = (uint64_t *)(mtag + 1);
	c->vars.ldelay = now - *enqueue_time;
	c->stats.maxpacket = MAX(c->stats.maxpacket, m_pktlen(m));

	if (codel_time_before(c->vars.ldelay, c->params.target) ||
	    qsize(q) <= c->stats.maxpacket) {
		/* went below - stay below for at least interval */
		c->vars.first_above_time = 0;
		return (0);
	}
	if (c->vars.first_above_time == 0) {
		/* just went above from below. If we stay above
		 * for at least interval we'll say it's ok to drop
		 */
		c->vars.first_above_time = now + c->params.interval;
		return (0);
	}
	if (codel_time_after(now, c->vars.first_above_time))
		return (1);

	return (0);
}