Deleted Added
sdiff udiff text old ( 301162 ) new ( 302338 )
full compact
1/*
2 * PIE - Proportional Integral controller Enhanced AQM algorithm.
3 *
4 * $FreeBSD: head/sys/netpfil/ipfw/dn_aqm_pie.c 301162 2016-06-01 20:04:24Z truckman $
5 *
6 * Copyright (C) 2016 Centre for Advanced Internet Architectures,
7 * Swinburne University of Technology, Melbourne, Australia.
8 * Portions of this code were made possible in part by a gift from
9 * The Comcast Innovation Fund.
10 * Implemented by Rasool Al-Saadi <ralsaadi@swin.edu.au>
11 *
12 * Redistribution and use in source and binary forms, with or without

--- 189 unchanged lines hidden (view full) ---

202 */
203static void
204calculate_drop_prob(void *x)
205{
206 int64_t p, prob, oldprob;
207 struct dn_aqm_pie_parms *pprms;
208 struct pie_status *pst = (struct pie_status *) x;
209
210 /* dealing with race condition */
211 if (callout_pending(&pst->aqm_pie_callout)) {
212 /* callout was reset */
213 mtx_unlock(&pst->lock_mtx);
214 return;
215 }
216
217 if (!callout_active(&pst->aqm_pie_callout)) {
218 /* callout was stopped */
219 mtx_unlock(&pst->lock_mtx);
220 mtx_destroy(&pst->lock_mtx);
221 free(x, M_DUMMYNET);
222 //pst->pq->aqm_status = NULL;
223 pie_desc.ref_count--;
224 return;
225 }
226 callout_deactivate(&pst->aqm_pie_callout);
227
228 pprms = pst->parms;
229 prob = pst->drop_prob;
230
231 /* calculate current qdelay */
232 if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
233 pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes *
234 pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS;
235 }

--- 335 unchanged lines hidden (view full) ---

571 struct pie_status *pst;
572 struct dn_aqm_pie_parms *pprms;
573 int err = 0;
574
575 pprms = q->fs->aqmcfg;
576
577 do { /* exit with break when error occurs*/
578 if (!pprms){
579 D("AQM_PIE is not configured");
580 err = EINVAL;
581 break;
582 }
583
584 q->aqm_status = malloc(sizeof(struct pie_status),
585 M_DUMMYNET, M_NOWAIT | M_ZERO);
586 if (q->aqm_status == NULL) {
587 D("cannot allocate PIE private data");

--- 22 unchanged lines hidden (view full) ---

610 //DX(2, "aqm_PIE_init");
611
612 } while(0);
613
614 return err;
615}
616
617/*
618 * Clean up PIE status for queue 'q'
619 * Destroy memory allocated for PIE status.
620 */
621static int
622aqm_pie_cleanup(struct dn_queue *q)
623{
624
625 if(!q) {

--- 9 unchanged lines hidden (view full) ---

635 D("fs is null or no cfg");
636 return 1;
637 }
638 if (q->fs->aqmfp && q->fs->aqmfp->type !=DN_AQM_PIE) {
639 D("Not PIE fs (%d)", q->fs->fs.fs_nr);
640 return 1;
641 }
642
643 mtx_lock(&pst->lock_mtx);
644
645 /* stop callout timer */
646 if (callout_stop(&pst->aqm_pie_callout) || !(pst->sflags & PIE_ACTIVE)) {
647 mtx_unlock(&pst->lock_mtx);
648 mtx_destroy(&pst->lock_mtx);
649 free(q->aqm_status, M_DUMMYNET);
650 q->aqm_status = NULL;
651 pie_desc.ref_count--;
652 return 0;
653 } else {
654 q->aqm_status = NULL;
655 mtx_unlock(&pst->lock_mtx);
656 DX(2, "PIE callout has not been stoped from cleanup!");
657 return EBUSY;
658 }
659 return 0;
660}
661
662/*
663 * Config PIE parameters
664 * also allocate memory for PIE configurations
665 */
666static int

--- 127 unchanged lines hidden ---