Lines Matching +full:3 +full:- +full:tuple
2 * FQ_Codel - The FlowQueue-Codel scheduler/AQM
8 * Implemented by Rasool Al-Saadi <ralsaadi@swin.edu.au>
73 * because fq_codel use different flows (sub-queues) structure and
74 * dn_queue includes many variables not needed by a flow (sub-queue
76 * Also, CoDel functions manages stats of sub-queues as well as the main queue.
97 if (error != 0 || req->newptr == NULL) in fqcodel_sysctl_interval_handler()
115 if (error != 0 || req->newptr == NULL) in fqcodel_sysctl_target_handler()
157 struct mbuf *m = q->mq.head; in codel_drop_head()
161 q->mq.head = m->m_nextpkt; in codel_drop_head()
163 fq_update_stats(q, si, -m->m_pkthdr.len, 1); in codel_drop_head()
165 if (si->main_q.ni.length == 0) /* queue is now idle */ in codel_drop_head()
166 si->main_q.q_time = V_dn_cfg.curr_time; in codel_drop_head()
179 len = m->m_pkthdr.len; in codel_enqueue()
181 if (len > q->cst.maxpkt_size) in codel_enqueue()
182 q->cst.maxpkt_size = len; in codel_enqueue()
195 if (m->m_pkthdr.rcvif != NULL) in codel_enqueue()
198 mq_append(&q->mq, m); in codel_enqueue()
220 uint8_t tuple[41]; in fq_codel_classify_flow() local
223 ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off); in fq_codel_classify_flow()
227 isip6 = (ip->ip_v == 6); in fq_codel_classify_flow()
231 *((uint8_t *) &tuple[0]) = ip6->ip6_nxt; in fq_codel_classify_flow()
232 *((uint32_t *) &tuple[1]) = si->perturbation; in fq_codel_classify_flow()
233 memcpy(&tuple[5], ip6->ip6_src.s6_addr, 16); in fq_codel_classify_flow()
234 memcpy(&tuple[21], ip6->ip6_dst.s6_addr, 16); in fq_codel_classify_flow()
236 switch (ip6->ip6_nxt) { in fq_codel_classify_flow()
239 *((uint16_t *) &tuple[37]) = th->th_dport; in fq_codel_classify_flow()
240 *((uint16_t *) &tuple[39]) = th->th_sport; in fq_codel_classify_flow()
245 *((uint16_t *) &tuple[37]) = uh->uh_dport; in fq_codel_classify_flow()
246 *((uint16_t *) &tuple[39]) = uh->uh_sport; in fq_codel_classify_flow()
249 memset(&tuple[37], 0, 4); in fq_codel_classify_flow()
252 hash = jenkins_hash(tuple, 41, HASHINIT) % fcount; in fq_codel_classify_flow()
258 *((uint8_t *) &tuple[0]) = ip->ip_p; in fq_codel_classify_flow()
259 *((uint32_t *) &tuple[1]) = si->perturbation; in fq_codel_classify_flow()
260 *((uint32_t *) &tuple[5]) = ip->ip_src.s_addr; in fq_codel_classify_flow()
261 *((uint32_t *) &tuple[9]) = ip->ip_dst.s_addr; in fq_codel_classify_flow()
263 switch (ip->ip_p) { in fq_codel_classify_flow()
266 *((uint16_t *) &tuple[13]) = th->th_dport; in fq_codel_classify_flow()
267 *((uint16_t *) &tuple[15]) = th->th_sport; in fq_codel_classify_flow()
272 *((uint16_t *) &tuple[13]) = uh->uh_dport; in fq_codel_classify_flow()
273 *((uint16_t *) &tuple[15]) = uh->uh_sport; in fq_codel_classify_flow()
276 memset(&tuple[13], 0, 4); in fq_codel_classify_flow()
278 hash = jenkins_hash(tuple, 17, HASHINIT) % fcount; in fq_codel_classify_flow()
299 schk = (struct fq_codel_schk *)(si->_si.sched+1); in fq_codel_enqueue()
300 param = &schk->cfg; in fq_codel_enqueue()
303 idx = fq_codel_classify_flow(m, param->flows_cnt, si); in fq_codel_enqueue()
307 drop = codel_enqueue(&si->flows[idx], m, si); in fq_codel_enqueue()
313 /* If the flow (sub-queue) is not active ,then add it to the tail of in fq_codel_enqueue()
316 if (!si->flows[idx].active ) { in fq_codel_enqueue()
317 STAILQ_INSERT_TAIL(&si->newflows, &si->flows[idx], flowchain); in fq_codel_enqueue()
318 si->flows[idx].deficit = param->quantum; in fq_codel_enqueue()
319 si->flows[idx].cst.dropping = false; in fq_codel_enqueue()
320 si->flows[idx].cst.first_above_time = 0; in fq_codel_enqueue()
321 si->flows[idx].active = 1; in fq_codel_enqueue()
328 if (mainq->ni.length > schk->cfg.limit) { D("over limit"); in fq_codel_enqueue()
330 for (maxidx = 0; maxidx < schk->cfg.flows_cnt; maxidx++) in fq_codel_enqueue()
331 if (si->flows[maxidx].active) in fq_codel_enqueue()
333 if (maxidx < schk->cfg.flows_cnt) { in fq_codel_enqueue()
334 /* find the largest sub- queue */ in fq_codel_enqueue()
335 for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) in fq_codel_enqueue()
336 if (si->flows[i].active && si->flows[i].stats.length > in fq_codel_enqueue()
337 si->flows[maxidx].stats.length) in fq_codel_enqueue()
339 codel_drop_head(&si->flows[maxidx], si); in fq_codel_enqueue()
363 schk = (struct fq_codel_schk *)(si->_si.sched+1); in fq_codel_dequeue()
364 param = &schk->cfg; in fq_codel_dequeue()
368 if (STAILQ_EMPTY(&si->newflows)) in fq_codel_dequeue()
369 fq_codel_flowlist = &si->oldflows; in fq_codel_dequeue()
371 fq_codel_flowlist = &si->newflows; in fq_codel_dequeue()
379 /* if there is no flow(sub-queue) deficit, increase deficit in fq_codel_dequeue()
384 if (f->deficit < 0) { in fq_codel_dequeue()
385 f->deficit += param->quantum; in fq_codel_dequeue()
387 STAILQ_INSERT_TAIL(&si->oldflows, f, flowchain); in fq_codel_dequeue()
407 if (fq_codel_flowlist == &si->newflows) { in fq_codel_dequeue()
409 STAILQ_INSERT_TAIL(&si->oldflows, f, flowchain); in fq_codel_dequeue()
411 f->active = 0; in fq_codel_dequeue()
420 f->deficit -= mbuf->m_pkthdr.len; in fq_codel_dequeue()
442 schk = (struct fq_codel_schk *)(_si->sched+1); in fq_codel_new_sched()
444 if(si->flows) { in fq_codel_new_sched()
450 q = &si->main_q; in fq_codel_new_sched()
451 set_oid(&q->ni.oid, DN_QUEUE, sizeof(*q)); in fq_codel_new_sched()
452 q->_si = _si; in fq_codel_new_sched()
453 q->fs = _si->sched->fs; in fq_codel_new_sched()
456 si->flows = mallocarray(schk->cfg.flows_cnt, in fq_codel_new_sched()
458 if (si->flows == NULL) { in fq_codel_new_sched()
464 si->perturbation = random(); in fq_codel_new_sched()
467 STAILQ_INIT(&si->newflows); in fq_codel_new_sched()
468 STAILQ_INIT(&si->oldflows); in fq_codel_new_sched()
470 /* init the flows (sub-queues) */ in fq_codel_new_sched()
471 for (i = 0; i < schk->cfg.flows_cnt; i++) { in fq_codel_new_sched()
473 si->flows[i].cst.maxpkt_size = 500; in fq_codel_new_sched()
489 free(si->flows , M_DUMMYNET); in fq_codel_free_sched()
490 si->flows = NULL; in fq_codel_free_sched()
491 fq_codel_desc.ref_count--; in fq_codel_free_sched()
508 ep = (struct dn_extra_parms *) _schk->cfg; in fq_codel_config()
511 * Codel: 0- target,1- interval, 2- flags in fq_codel_config()
512 * FQ_CODEL: 3- quantum, 4- limit, 5- flows in fq_codel_config()
514 if (ep && ep->oid.len ==sizeof(*ep) && in fq_codel_config()
515 ep->oid.subtype == DN_SCH_PARAMS) { in fq_codel_config()
516 fqc_cfg = &schk->cfg; in fq_codel_config()
517 if (ep->par[0] < 0) in fq_codel_config()
518 fqc_cfg->ccfg.target = fq_codel_sysctl.ccfg.target; in fq_codel_config()
520 fqc_cfg->ccfg.target = ep->par[0] * AQM_TIME_1US; in fq_codel_config()
522 if (ep->par[1] < 0) in fq_codel_config()
523 fqc_cfg->ccfg.interval = fq_codel_sysctl.ccfg.interval; in fq_codel_config()
525 fqc_cfg->ccfg.interval = ep->par[1] * AQM_TIME_1US; in fq_codel_config()
527 if (ep->par[2] < 0) in fq_codel_config()
528 fqc_cfg->ccfg.flags = 0; in fq_codel_config()
530 fqc_cfg->ccfg.flags = ep->par[2]; in fq_codel_config()
533 if (ep->par[3] < 0) in fq_codel_config()
534 fqc_cfg->quantum = fq_codel_sysctl.quantum; in fq_codel_config()
536 fqc_cfg->quantum = ep->par[3]; in fq_codel_config()
538 if (ep->par[4] < 0) in fq_codel_config()
539 fqc_cfg->limit = fq_codel_sysctl.limit; in fq_codel_config()
541 fqc_cfg->limit = ep->par[4]; in fq_codel_config()
543 if (ep->par[5] < 0) in fq_codel_config()
544 fqc_cfg->flows_cnt = fq_codel_sysctl.flows_cnt; in fq_codel_config()
546 fqc_cfg->flows_cnt = ep->par[5]; in fq_codel_config()
549 fqc_cfg->ccfg.target = BOUND_VAR(fqc_cfg->ccfg.target, 1 , in fq_codel_config()
551 fqc_cfg->ccfg.interval = BOUND_VAR(fqc_cfg->ccfg.interval, 1, in fq_codel_config()
554 fqc_cfg->quantum = BOUND_VAR(fqc_cfg->quantum,1, 9000); in fq_codel_config()
555 fqc_cfg->limit= BOUND_VAR(fqc_cfg->limit,1,20480); in fq_codel_config()
556 fqc_cfg->flows_cnt= BOUND_VAR(fqc_cfg->flows_cnt,1,65536); in fq_codel_config()
573 fqc_cfg = &schk->cfg; in fq_codel_getconfig()
575 strcpy(ep->name, fq_codel_desc.name); in fq_codel_getconfig()
576 ep->par[0] = fqc_cfg->ccfg.target / AQM_TIME_1US; in fq_codel_getconfig()
577 ep->par[1] = fqc_cfg->ccfg.interval / AQM_TIME_1US; in fq_codel_getconfig()
578 ep->par[2] = fqc_cfg->ccfg.flags; in fq_codel_getconfig()
580 ep->par[3] = fqc_cfg->quantum; in fq_codel_getconfig()
581 ep->par[4] = fqc_cfg->limit; in fq_codel_getconfig()
582 ep->par[5] = fqc_cfg->flows_cnt; in fq_codel_getconfig()
598 _SI( .si_datalen = ) sizeof(struct fq_codel_si) - sizeof(struct dn_sch_inst),