]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_frescan/frescan_bwres_fna.c
changes to use the FRSH FSA module to do the analysis and spare capacity. TODO: finis...
[frescor/fna.git] / src_frescan / frescan_bwres_fna.c
index 648a807a68d56293807597f35dbc1a8b3ec1b991..24c82e7c6fa35883025a9b442a8bda6cf2cdeab8 100644 (file)
 
 #include "frsh.h" /* frsh_resource_id_t, .. */
 #include "frescan.h" /* frescan_init, ... */
-#include "frescan_data.h" /* frescan_contract_t, ... */
 #include "frescan_bwres.h" /* frescan_bwres_init, ... */
 #include "fna.h" /* fna_vres_id_t, fna_endpoint_data_t */
-
-#undef ERROR
-#include "frescan_debug.h" /* DEBUG, ERROR */
+#include "frescan_debug.h" /* DEBUG, FRESCAN_ERROR */
 
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
@@ -111,12 +108,12 @@ int frescan_fna_init(const frsh_resource_id_t resource_id)
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "Initializing FRESCAN\n");
 
         ret = frescan_init(&init_params);
-        if (ret != 0) ERROR ("could not init FRESCAN");
+        if (ret != 0) FRESCAN_ERROR ("could not init FRESCAN");
 
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "Initializing BWRES\n");
 
         ret = frescan_bwres_init(init_params.net);
-        if (ret != 0) ERROR ("could not init BWRES");
+        if (ret != 0) FRESCAN_ERROR ("could not init BWRES");
 
         return 0;
 }
@@ -166,24 +163,10 @@ int frescan_fna_contract_negotiate
         int ret;
         bool accepted;
         frescan_ss_t ss;
-        frescan_contract_t frescan_contract;
-
-        DEBUG(FRESCAN_FNA_ENABLE_DEBUG,
-              "frsh contract->frescan contract\n");
-
-        // NOTE: budget is stored as number of can frames in tv_sec
-        frescan_contract.min_values.budget = contract->budget_min.tv_sec;
-        frescan_contract.min_values.period = contract->period_max;
-
-        frescan_contract.max_values.budget = contract->budget_max.tv_sec;
-        frescan_contract.max_values.period = contract->period_min;
-
-        // TODO: put 0 if we want the sa module to assign the prios
-        frescan_contract.prio = contract->preemption_level;
 
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "calling frescan_bwres_negotiate\n");
         ret = frescan_bwres_negotiate((frescan_network_t)resource_id,
-                                       &frescan_contract,
+                                       contract,
                                        &ss,
                                        &accepted);
         if (ret != 0) return -1;
@@ -233,7 +216,7 @@ int frescan_fna_contract_renegotiate_sync
                  const fna_vres_id_t vres,
                  const frsh_contract_t *new_contract)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -285,7 +268,7 @@ int frescan_fna_contract_renegotiate_async
                  frsh_signal_t signal_to_notify,
                  frsh_signal_info_t signal_info)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -322,7 +305,7 @@ int frescan_fna_vres_get_renegotiation_status
                  const fna_vres_id_t vres,
                  frsh_renegotiation_status_t *renegotiation_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -351,7 +334,7 @@ int frescan_fna_vres_destroy
                 (const frsh_resource_id_t resource_id,
                  const fna_vres_id_t vres)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -381,7 +364,7 @@ int frescan_fna_vres_get_contract
                  const fna_vres_id_t vres,
                  frsh_contract_t *contract)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -410,7 +393,7 @@ int frescan_fna_vres_get_usage
                  const fna_vres_id_t vres,
                  struct timespec *usage)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -440,7 +423,7 @@ int frescan_fna_vres_get_remaining_budget
                  const fna_vres_id_t vres,
                  struct timespec *remaining_budget)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -472,7 +455,7 @@ int frescan_fna_vres_get_budget_and_period
                  struct timespec *budget,
                  struct timespec *period)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -520,7 +503,7 @@ int frescan_fna_resource_get_capacity
                  const int importance,
                  uint32_t *capacity)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -548,7 +531,7 @@ int frescan_fna_resource_get_total_weight
                  const int importance,
                  int *total_weight)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -583,7 +566,7 @@ int frescan_fna_vres_decrease_capacity
                  const struct timespec new_budget,
                  const struct timespec new_period)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -619,7 +602,7 @@ int frescan_fna_send_sync
                  const void *msg,
                  const size_t size)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -668,7 +651,7 @@ int frescan_fna_send_async
 
         ret = frescan_send(&params, (uint8_t *)msg, size);
         if (ret != 0) {
-                ERROR ("could not send message\n");
+                FRESCAN_ERROR ("could not send message\n");
                 return -1;
         }
 
@@ -736,7 +719,7 @@ int frescan_fna_receive_sync
                            received_bytes, &frescan_from, &prio);
 
         if (ret != 0) {
-                ERROR ("error while receiving message");
+                FRESCAN_ERROR ("error while receiving message");
                 return -1;
         }
 
@@ -781,7 +764,7 @@ int frescan_fna_receive_async
                  size_t *received_bytes,
                  frsh_network_address_t *from)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -811,7 +794,7 @@ int frescan_fna_send_endpoint_get_status
                  frsh_endpoint_network_status_t *network_status,
                  frsh_protocol_status_t *protocol_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -866,7 +849,7 @@ int frescan_fna_receive_endpoint_get_status
                  frsh_endpoint_network_status_t *network_status,
                  frsh_protocol_status_t *protocol_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -906,7 +889,7 @@ int frescan_fna_network_get_max_message_size
                  const frsh_network_address_t destination,
                  size_t *max_size)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }