]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - fwp/mngr/fwp_admctrl.c
Convert debug messages to uLUt and fix #include dependencies
[frescor/fwp.git] / fwp / mngr / fwp_admctrl.c
index 3ab53c200dd17a5c3564a2817db36cc23ba5f0a9..ee410b20bbbe57ff0f93da50e9fecc5f1e535857 100644 (file)
 #include "fwp_idl.h"
 #include "fwp_admctrl.h"
 #include <ul_log.h>
+#include <ul_logreg.h>
+#include "fwp_utils.h"
 
 UL_LOG_CUST(ulogd_fwp_admctrl);
-ul_log_domain_t ulogd_frm_aqcpu = {UL_LOGL_MSG, "fwp_admctrl"};
+ul_log_domain_t ulogd_fwp_admctrl = {UL_LOGL_MSG, "fwp_admctrl"};
+UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(fwp_admctrl_logreg_domains, ulogd_fwp_admctrl);
 
 /* TODO: Find out the real value and determine what influences it (MTU
  *      of the interface minus header sizes?).  */
@@ -168,15 +171,17 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                basic = fres_contract_get_basic(c->contract);
 
                frsh_network_budget_to_bytes(FRSH_NETPF_FWP,&basic->budget,&bytes);
-               printf("  processing: id=%s, period=%ld ms, budget=%lu bytes\n",
+               ul_logmsg("processing: id=%s, period=%ld ms, budget=%lu bytes\n",
                       id,
                       fosa_rel_time_to_msec(basic->period),
                       (long unsigned int)bytes);
 
+               period_usec = basic ? fosa_rel_time_to_msec(basic->period)*1000 : 0;
+
                /* Calculate protocol overhead */
                fragments = (bytes + MTU - 1) / MTU;
 
-               if (fragments == 0)
+               if (fragments == 0 && period_usec != 0)
                        continue;
 
                const int data_overhead = UDP_HEADER_SIZE + IP_HEADER_SIZE +
@@ -200,9 +205,6 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                 * AP may use different values for backoff. */
                //duration_usec *= 2; /* For demo, we have always STA-to-STA */
 
-               basic = fres_contract_get_basic(c->contract);
-               period_usec = basic ? fosa_rel_time_to_msec(basic->period)*1000 : 0;
-
                if (c->contract == c->new) {
                        if (period_usec == 0) {
                                ul_logmsg("Period is zero!\n");
@@ -227,7 +229,7 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                                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);  
+                       fres_contract_add_block(c->contract, FRES_BLOCK_FWP_SCHED, fwp_sched);
                }
 
                utilization += (long long)(duration_usec * 10000) / period_usec;
@@ -237,11 +239,13 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                goto not_schedulable;
        }
        scenario->utilization = utilization/100; /* For GUI */
-       
+
+       ul_logmsg("accepted\n");
        *schedulable = true;
        return 0;
 
 not_schedulable:
+       ul_logmsg("rejected\n");
        *schedulable = false;
        return 0;
 }