Lines Matching +full:static +full:- +full:beta

2  * PIE - Proportional Integral controller Enhanced AQM algorithm.
8 * Implemented by Rasool Al-Saadi <ralsaadi@swin.edu.au>
74 static struct dn_aqm pie_desc;
78 * max_ecnth=0.1, alpha=0.125, beta=1.25,
85 static int
91 if (!strcmp(oidp->oid_name,"alpha")) in pie_sysctl_alpha_beta_handler()
94 value = pie_sysctl.beta; in pie_sysctl_alpha_beta_handler()
98 if (error != 0 || req->newptr == NULL) in pie_sysctl_alpha_beta_handler()
103 if (!strcmp(oidp->oid_name,"alpha")) in pie_sysctl_alpha_beta_handler()
106 pie_sysctl.beta = value; in pie_sysctl_alpha_beta_handler()
110 static int
116 if (!strcmp(oidp->oid_name,"target")) in pie_sysctl_target_tupdate_maxb_handler()
118 else if (!strcmp(oidp->oid_name,"tupdate")) in pie_sysctl_target_tupdate_maxb_handler()
125 if (error != 0 || req->newptr == NULL) in pie_sysctl_target_tupdate_maxb_handler()
131 if (!strcmp(oidp->oid_name,"target")) in pie_sysctl_target_tupdate_maxb_handler()
133 else if (!strcmp(oidp->oid_name,"tupdate")) in pie_sysctl_target_tupdate_maxb_handler()
140 static int
149 if (error != 0 || req->newptr == NULL) in pie_sysctl_max_ecnth_handler()
163 static SYSCTL_NODE(_net_inet_ip_dummynet, OID_AUTO, pie,
190 SYSCTL_PROC(_net_inet_ip_dummynet_pie, OID_AUTO, beta,
193 "beta scaled by 1000");
201 static void
209 pprms = pst->parms; in calculate_drop_prob()
210 prob = pst->drop_prob; in calculate_drop_prob()
216 if (pprms->flags & PIE_DEPRATEEST_ENABLED) in calculate_drop_prob()
217 pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes * in calculate_drop_prob()
218 pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS; in calculate_drop_prob()
220 if (!pst->pq->ni.len_bytes) in calculate_drop_prob()
221 pst->current_qdelay = 0; in calculate_drop_prob()
224 p = (int64_t)pprms->alpha * in calculate_drop_prob()
225 ((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); in calculate_drop_prob()
226 p +=(int64_t) pprms->beta * in calculate_drop_prob()
227 ((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); in calculate_drop_prob()
232 p = -p; in calculate_drop_prob()
235 /* We PIE_MAX_PROB shift by 12-bits to increase the division precision */ in calculate_drop_prob()
238 /* auto-tune drop probability */ in calculate_drop_prob()
257 prob = prob - p; in calculate_drop_prob()
266 if ((pprms->flags & PIE_CAPDROP_ENABLED) && in calculate_drop_prob()
288 if (pst->current_qdelay == 0 && pst->qdelay_old == 0) { in calculate_drop_prob()
289 /* 0.98 ~= 1- 1/64 */ in calculate_drop_prob()
290 prob = prob - (prob >> 6); in calculate_drop_prob()
298 pst->drop_prob = prob; in calculate_drop_prob()
301 pst->qdelay_old = pst->current_qdelay; in calculate_drop_prob()
304 if ((pst->sflags & PIE_ACTIVE) && pst->burst_allowance>0) { in calculate_drop_prob()
306 if (pst->burst_allowance > pprms->tupdate ) in calculate_drop_prob()
307 pst->burst_allowance -= pprms->tupdate; in calculate_drop_prob()
309 pst->burst_allowance = 0; in calculate_drop_prob()
313 if (pst->sflags & PIE_ACTIVE) in calculate_drop_prob()
314 callout_reset_sbt(&pst->aqm_pie_callout, in calculate_drop_prob()
315 (uint64_t)pprms->tupdate * SBT_1US, 0, calculate_drop_prob, pst, 0); in calculate_drop_prob()
317 mtx_unlock(&pst->lock_mtx); in calculate_drop_prob()
325 static struct mbuf *
331 next: m = q->mq.head; in pie_extract_head()
334 q->mq.head = m->m_nextpkt; in pie_extract_head()
337 update_stats(q, -m->m_pkthdr.len, 0); in pie_extract_head()
339 if (q->ni.length == 0) /* queue is now idle */ in pie_extract_head()
340 q->q_time = V_dn_cfg.curr_time; in pie_extract_head()
353 if (m->m_pkthdr.rcvif != NULL && in pie_extract_head()
364 __inline static void
369 mtx_lock(&pst->lock_mtx); in init_activate_pie()
370 pprms = pst->parms; in init_activate_pie()
371 pst->drop_prob = 0; in init_activate_pie()
372 pst->qdelay_old = 0; in init_activate_pie()
373 pst->burst_allowance = pprms->max_burst; in init_activate_pie()
374 pst->accu_prob = 0; in init_activate_pie()
375 pst->dq_count = 0; in init_activate_pie()
376 pst->avg_dq_time = 0; in init_activate_pie()
377 pst->sflags = PIE_INMEASUREMENT; in init_activate_pie()
378 pst->measurement_start = AQM_UNOW; in init_activate_pie()
381 pst->sflags |= PIE_ACTIVE; in init_activate_pie()
382 callout_reset_sbt(&pst->aqm_pie_callout, in init_activate_pie()
383 (uint64_t)pprms->tupdate * SBT_1US, in init_activate_pie()
387 mtx_unlock(&pst->lock_mtx); in init_activate_pie()
393 __inline static void
396 mtx_lock(&pst->lock_mtx); in deactivate_pie()
397 pst->sflags &= ~(PIE_ACTIVE | PIE_INMEASUREMENT); in deactivate_pie()
398 callout_stop(&pst->aqm_pie_callout); in deactivate_pie()
400 mtx_unlock(&pst->lock_mtx); in deactivate_pie()
407 static struct mbuf *
417 pst = q->aqm_status; in aqm_pie_dequeue()
418 pprms = pst->parms; in aqm_pie_dequeue()
421 m = pie_extract_head(q, &pkt_ts, !(pprms->flags & PIE_DEPRATEEST_ENABLED)); in aqm_pie_dequeue()
423 if (!m || !(pst->sflags & PIE_ACTIVE)) in aqm_pie_dequeue()
427 if (pprms->flags & PIE_DEPRATEEST_ENABLED) { in aqm_pie_dequeue()
429 if(pst->sflags & PIE_INMEASUREMENT) { in aqm_pie_dequeue()
430 pst->dq_count += m->m_pkthdr.len; in aqm_pie_dequeue()
432 if (pst->dq_count >= PIE_DQ_THRESHOLD) { in aqm_pie_dequeue()
433 dq_time = now - pst->measurement_start; in aqm_pie_dequeue()
439 if(pst->avg_dq_time == 0) in aqm_pie_dequeue()
440 pst->avg_dq_time = dq_time; in aqm_pie_dequeue()
448 pst->avg_dq_time = (dq_time* w in aqm_pie_dequeue()
449 + (pst->avg_dq_time * ((1L << 8) - w))) >> 8; in aqm_pie_dequeue()
450 pst->sflags &= ~PIE_INMEASUREMENT; in aqm_pie_dequeue()
459 if(!(pst->sflags & PIE_INMEASUREMENT) && in aqm_pie_dequeue()
460 q->ni.len_bytes >= PIE_DQ_THRESHOLD) { in aqm_pie_dequeue()
461 pst->sflags |= PIE_INMEASUREMENT; in aqm_pie_dequeue()
462 pst->measurement_start = now; in aqm_pie_dequeue()
463 pst->dq_count = 0; in aqm_pie_dequeue()
468 pst->current_qdelay = now - pkt_ts; in aqm_pie_dequeue()
475 * (whose parameters are in q->fs).
479 static int
489 len = m->m_pkthdr.len; in aqm_pie_enqueue()
490 pst = q->aqm_status; in aqm_pie_enqueue()
498 f = &(q->fs->fs); in aqm_pie_enqueue()
499 pprms = pst->parms; in aqm_pie_enqueue()
503 qlen = (f->flags & DN_QSIZE_BYTES) ? in aqm_pie_enqueue()
504 q->ni.len_bytes : q->ni.length; in aqm_pie_enqueue()
507 if (qlen >= f->qsize) in aqm_pie_enqueue()
510 else if ((pst->sflags & PIE_ACTIVE) && pst->burst_allowance==0 in aqm_pie_enqueue()
511 && drop_early(pst, q->ni.len_bytes) == DROP) { in aqm_pie_enqueue()
516 if ((pprms->flags & PIE_ECN_ENABLED) && pst->drop_prob < in aqm_pie_enqueue()
517 (pprms->max_ecnth << (PIE_PROB_BITS - PIE_FIX_POINT_BITS)) in aqm_pie_enqueue()
525 if (!(pst->sflags & PIE_ACTIVE) && qlen >= pst->one_third_q_size) { in aqm_pie_enqueue()
530 if ((pst->sflags & PIE_ACTIVE) && pst->drop_prob == 0 && in aqm_pie_enqueue()
531 pst->current_qdelay < (pprms->qdelay_ref >> 1) && in aqm_pie_enqueue()
532 pst->qdelay_old < (pprms->qdelay_ref >> 1)) { in aqm_pie_enqueue()
533 pst->burst_allowance = pprms->max_burst; in aqm_pie_enqueue()
534 if ((pprms->flags & PIE_ON_OFF_MODE_ENABLED) && qlen<=0) in aqm_pie_enqueue()
539 if (t != DROP && !(pprms->flags & PIE_DEPRATEEST_ENABLED)) { in aqm_pie_enqueue()
555 mq_append(&q->mq, m); in aqm_pie_enqueue()
562 pst->accu_prob = 0; in aqm_pie_enqueue()
573 static int
580 pprms = q->fs->aqmcfg; in aqm_pie_init()
589 q->aqm_status = malloc(sizeof(struct pie_status), in aqm_pie_init()
591 if (q->aqm_status == NULL) { in aqm_pie_init()
597 pst = q->aqm_status; in aqm_pie_init()
603 pst->pq = q; in aqm_pie_init()
604 pst->parms = pprms; in aqm_pie_init()
608 pst->one_third_q_size = q->fs->fs.qsize/3; in aqm_pie_init()
610 mtx_init(&pst->lock_mtx, "mtx_pie", NULL, MTX_DEF); in aqm_pie_init()
611 callout_init_mtx(&pst->aqm_pie_callout, &pst->lock_mtx, in aqm_pie_init()
614 pst->current_qdelay = 0; in aqm_pie_init()
615 init_activate_pie(pst, !(pprms->flags & PIE_ON_OFF_MODE_ENABLED)); in aqm_pie_init()
627 static void
632 mtx_unlock(&pst->lock_mtx); in pie_callout_cleanup()
633 mtx_destroy(&pst->lock_mtx); in pie_callout_cleanup()
636 pie_desc.ref_count--; in pie_callout_cleanup()
644 static int
652 struct pie_status *pst = q->aqm_status; in aqm_pie_cleanup()
657 if(!q->fs || !q->fs->aqmcfg) { in aqm_pie_cleanup()
661 if (q->fs->aqmfp && q->fs->aqmfp->type !=DN_AQM_PIE) { in aqm_pie_cleanup()
662 D("Not PIE fs (%d)", q->fs->fs.fs_nr); in aqm_pie_cleanup()
673 mtx_lock(&pst->lock_mtx); in aqm_pie_cleanup()
674 callout_reset_sbt(&pst->aqm_pie_callout, in aqm_pie_cleanup()
676 q->aqm_status = NULL; in aqm_pie_cleanup()
677 mtx_unlock(&pst->lock_mtx); in aqm_pie_cleanup()
686 static int
699 if (fs->aqmcfg) { in aqm_pie_config()
700 free(fs->aqmcfg, M_DUMMYNET); in aqm_pie_config()
701 fs->aqmcfg = NULL; in aqm_pie_config()
704 fs->aqmcfg = malloc(sizeof(struct dn_aqm_pie_parms), in aqm_pie_config()
706 if (fs->aqmcfg== NULL) { in aqm_pie_config()
712 * 0- qdelay_ref,1- tupdate, 2- max_burst in aqm_pie_config()
713 * 3- max_ecnth, 4- alpha, 5- beta, 6- flags in aqm_pie_config()
717 pcfg = fs->aqmcfg; in aqm_pie_config()
719 if (ep->par[0] < 0) in aqm_pie_config()
720 pcfg->qdelay_ref = pie_sysctl.qdelay_ref * AQM_TIME_1US; in aqm_pie_config()
722 pcfg->qdelay_ref = ep->par[0]; in aqm_pie_config()
723 if (ep->par[1] < 0) in aqm_pie_config()
724 pcfg->tupdate = pie_sysctl.tupdate * AQM_TIME_1US; in aqm_pie_config()
726 pcfg->tupdate = ep->par[1]; in aqm_pie_config()
727 if (ep->par[2] < 0) in aqm_pie_config()
728 pcfg->max_burst = pie_sysctl.max_burst * AQM_TIME_1US; in aqm_pie_config()
730 pcfg->max_burst = ep->par[2]; in aqm_pie_config()
731 if (ep->par[3] < 0) in aqm_pie_config()
732 pcfg->max_ecnth = pie_sysctl.max_ecnth; in aqm_pie_config()
734 pcfg->max_ecnth = ep->par[3]; in aqm_pie_config()
735 if (ep->par[4] < 0) in aqm_pie_config()
736 pcfg->alpha = pie_sysctl.alpha; in aqm_pie_config()
738 pcfg->alpha = ep->par[4]; in aqm_pie_config()
739 if (ep->par[5] < 0) in aqm_pie_config()
740 pcfg->beta = pie_sysctl.beta; in aqm_pie_config()
742 pcfg->beta = ep->par[5]; in aqm_pie_config()
743 if (ep->par[6] < 0) in aqm_pie_config()
744 pcfg->flags = pie_sysctl.flags; in aqm_pie_config()
746 pcfg->flags = ep->par[6]; in aqm_pie_config()
749 pcfg->qdelay_ref = BOUND_VAR(pcfg->qdelay_ref, 1, 10 * AQM_TIME_1S); in aqm_pie_config()
750 pcfg->tupdate = BOUND_VAR(pcfg->tupdate, 1, 10 * AQM_TIME_1S); in aqm_pie_config()
751 pcfg->max_burst = BOUND_VAR(pcfg->max_burst, 0, 10 * AQM_TIME_1S); in aqm_pie_config()
752 pcfg->max_ecnth = BOUND_VAR(pcfg->max_ecnth, 0, PIE_SCALE); in aqm_pie_config()
753 pcfg->alpha = BOUND_VAR(pcfg->alpha, 0, 7 * PIE_SCALE); in aqm_pie_config()
754 pcfg->beta = BOUND_VAR(pcfg->beta, 0 , 7 * PIE_SCALE); in aqm_pie_config()
764 static int
767 if (fs && fs->aqmcfg) { in aqm_pie_deconfig()
768 free(fs->aqmcfg, M_DUMMYNET); in aqm_pie_deconfig()
769 fs->aqmcfg = NULL; in aqm_pie_deconfig()
770 pie_desc.cfg_ref_count--; in aqm_pie_deconfig()
778 static int
782 if (fs->aqmcfg) { in aqm_pie_getconfig()
783 strlcpy(ep->name, pie_desc.name, sizeof(ep->name)); in aqm_pie_getconfig()
784 pcfg = fs->aqmcfg; in aqm_pie_getconfig()
785 ep->par[0] = pcfg->qdelay_ref / AQM_TIME_1US; in aqm_pie_getconfig()
786 ep->par[1] = pcfg->tupdate / AQM_TIME_1US; in aqm_pie_getconfig()
787 ep->par[2] = pcfg->max_burst / AQM_TIME_1US; in aqm_pie_getconfig()
788 ep->par[3] = pcfg->max_ecnth; in aqm_pie_getconfig()
789 ep->par[4] = pcfg->alpha; in aqm_pie_getconfig()
790 ep->par[5] = pcfg->beta; in aqm_pie_getconfig()
791 ep->par[6] = pcfg->flags; in aqm_pie_getconfig()
798 static struct dn_aqm pie_desc = {