1/* 2 * PIE - Proportional Integral controller Enhanced AQM algorithm. 3 * |
4 * $FreeBSD: head/sys/netpfil/ipfw/dn_aqm_pie.c 302338 2016-07-05 00:53:01Z 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 pprms = pst->parms; 211 prob = pst->drop_prob; 212 213 /* calculate current qdelay */ 214 if (pprms->flags & PIE_DEPRATEEST_ENABLED) { 215 pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes * 216 pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS; 217 } --- 335 unchanged lines hidden (view full) --- 553 struct pie_status *pst; 554 struct dn_aqm_pie_parms *pprms; 555 int err = 0; 556 557 pprms = q->fs->aqmcfg; 558 559 do { /* exit with break when error occurs*/ 560 if (!pprms){ |
561 DX(2, "AQM_PIE is not configured"); |
562 err = EINVAL; 563 break; 564 } 565 566 q->aqm_status = malloc(sizeof(struct pie_status), 567 M_DUMMYNET, M_NOWAIT | M_ZERO); 568 if (q->aqm_status == NULL) { 569 D("cannot allocate PIE private data"); --- 22 unchanged lines hidden (view full) --- 592 //DX(2, "aqm_PIE_init"); 593 594 } while(0); 595 596 return err; 597} 598 599/* |
600 * Callout function to destroy pie mtx and free PIE status memory 601 */ 602static void 603pie_callout_cleanup(void *x) 604{ 605 struct pie_status *pst = (struct pie_status *) x; 606 607 mtx_unlock(&pst->lock_mtx); 608 mtx_destroy(&pst->lock_mtx); 609 free(x, M_DUMMYNET); 610 DN_BH_WLOCK(); 611 pie_desc.ref_count--; 612 DN_BH_WUNLOCK(); 613} 614 615/* |
616 * Clean up PIE status for queue 'q' 617 * Destroy memory allocated for PIE status. 618 */ 619static int 620aqm_pie_cleanup(struct dn_queue *q) 621{ 622 623 if(!q) { --- 9 unchanged lines hidden (view full) --- 633 D("fs is null or no cfg"); 634 return 1; 635 } 636 if (q->fs->aqmfp && q->fs->aqmfp->type !=DN_AQM_PIE) { 637 D("Not PIE fs (%d)", q->fs->fs.fs_nr); 638 return 1; 639 } 640 |
641 /* 642 * Free PIE status allocated memory using pie_callout_cleanup() callout 643 * function to avoid any potential race. 644 * We reset aqm_pie_callout to call pie_callout_cleanup() in next 1um. This 645 * stops the scheduled calculate_drop_prob() callout and call pie_callout_cleanup() 646 * which does memory freeing. 647 */ |
648 mtx_lock(&pst->lock_mtx); |
649 callout_reset_sbt(&pst->aqm_pie_callout, 650 SBT_1US, 0, pie_callout_cleanup, pst, 0); 651 q->aqm_status = NULL; 652 mtx_unlock(&pst->lock_mtx); |
653 |
654 return 0; 655} 656 657/* 658 * Config PIE parameters 659 * also allocate memory for PIE configurations 660 */ 661static int --- 127 unchanged lines hidden --- |