]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Admission test updated to support cancelation
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 27 May 2009 11:00:57 +0000 (13:00 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 27 May 2009 11:00:57 +0000 (13:00 +0200)
fwp/mngr/fwp_admctrl.c

index 00bf3f5d57beb7f0b58e9313e0109128be854f5f..3ab53c200dd17a5c3564a2817db36cc23ba5f0a9 100644 (file)
 #include <fwp.h>
 #include "fwp_idl.h"
 #include "fwp_admctrl.h"
+#include <ul_log.h>
+
+UL_LOG_CUST(ulogd_fwp_admctrl);
+ul_log_domain_t ulogd_frm_aqcpu = {UL_LOGL_MSG, "fwp_admctrl"};
 
 /* TODO: Find out the real value and determine what influences it (MTU
  *      of the interface minus header sizes?).  */
@@ -148,9 +152,8 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
        const int rate = 54*1000*1000;
        const bool erp_ofdm = true;
        const bool short_preamble = true;
-       struct fres_sa_contract *c, *c_new = NULL;
+       struct fres_sa_contract *c;
        long int period_usec;
-       fres_block_basic *basic;
        fres_block_fwp_sched *fwp_sched;
 
        size_t bytes; 
@@ -198,41 +201,44 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                //duration_usec *= 2; /* For demo, we have always STA-to-STA */
 
                basic = fres_contract_get_basic(c->contract);
-               period_usec = fosa_rel_time_to_msec(basic->period)*1000;
+               period_usec = basic ? fosa_rel_time_to_msec(basic->period)*1000 : 0;
+
                if (c->contract == c->new) {
-                       c_new = c;
                        if (period_usec == 0) {
+                               ul_logmsg("Period is zero!\n");
                                goto not_schedulable;
                        }
+
+                       frsh_rel_time_t deadline;
+                       long int d;
+                       if (fres_contract_get_deadline(&c->contract, &deadline)) {
+                               d = fosa_rel_time_to_msec(deadline)*1000;
+                       } else {
+                               d = 100/*sec*/*1000*1000;
+                       }
+                       if (d < 30/*msec*/*1000) {
+                               ul_logmsg("Deadline shorter than 30 ms!\n");
+                               goto not_schedulable;
+                       };
+                       
+                       fwp_sched = malloc(sizeof(*fwp_sched));
+                       fwp_sched->ac_id =
+                               d <  100*1000 ? FWP_AC_VO :
+                               d <  500*1000 ? FWP_AC_VI :
+                               d < 1000*1000 ? FWP_AC_BE :
+                               FWP_AC_BK;
+                       fres_contract_add_block(c->contract, FRES_BLOCK_FWP_SCHED, fwp_sched);  
                }
+
                utilization += (long long)(duration_usec * 10000) / period_usec;
        }
        
-       if (!c_new) {
-               *schedulable = false;
-               return -1;      
-       }       
        if (utilization >= 10000 * 96/100) {
                goto not_schedulable;
        }
        scenario->utilization = utilization/100; /* For GUI */
        
-       basic = fres_contract_get_basic(c_new->contract);
-       /*int d = c->deadline_usec;*/
-       long int d = fosa_rel_time_to_msec(basic->period)*1000;
-       if (d <= 0) d = 100*1000*1000;
-       if (d < 30000) {
-               goto not_schedulable;
-       };
-       
        *schedulable = true;
-       fwp_sched = malloc(sizeof(*fwp_sched));
-       fwp_sched->ac_id =
-                       d <  100*1000 ? FWP_AC_VO :
-                       d <  500*1000 ? FWP_AC_VI :
-                       d < 1000*1000 ? FWP_AC_BE :
-                       FWP_AC_BK;
-       fres_contract_add_block(c_new->contract, FRES_BLOCK_FWP_SCHED, fwp_sched);      
        return 0;
 
 not_schedulable: