From 836f6c6374020ac5f13e1ee567aa94134daa6e20 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Mon, 29 Oct 2018 17:12:43 +0100
Subject: [PATCH] Include statistics flag only when values are written

---
 .../CONTROL_MODULES/MAC/flexran_agent_mac.c        | 14 +++++++++-----
 .../CONTROL_MODULES/PDCP/flexran_agent_pdcp.c      |  2 +-
 .../CONTROL_MODULES/RRC/flexran_agent_rrc.c        |  2 ++
 openair2/ENB_APP/flexran_agent_handler.c           |  6 ++----
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
index 9890b2b0a24..f656bfb469f 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -84,12 +84,14 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                         }
 
                         ue_report[i]->bsr = elem;
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_BSR;
                 }
 
                 /* Check flag for creation of PHR report */
                 if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PHR) {
                         ue_report[i]->phr = flexran_get_ue_phr (enb_id, i); // eNB_UE_list->UE_template[UE_PCCID(enb_id,i)][i].phr_info;
                         ue_report[i]->has_phr = 1;
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PHR;
 
                 }
 
@@ -130,7 +132,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                         // Add RLC buffer status reports to the full report
                         if (ue_report[i]->n_rlc_report > 0)
                             ue_report[i]->rlc_report = rlc_reports;
-
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RLC_BS;
 
                 }
 
@@ -143,7 +145,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                                        // found in stats_common.pb-c.h. See
                                        // flex_ce_type in FlexRAN specification
                         ue_report[i]->has_pending_mac_ces = 1;
-
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_CE_BS;
                 }
 
                 /* Check flag for creation of DL CQI report */
@@ -368,7 +370,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                     dl_report->csi_report = csi_reports;
                     //Add the DL CQI report to the stats report
                      ue_report[i]->dl_cqi_report = dl_report;
-
+                    ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_DL_CQI;
                 }
 
                 /* Check flag for creation of paging buffer status report */
@@ -413,6 +415,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                             paging_report->paging_info = p_info;
                             //Add the paging report to the UE report
                             ue_report[i]->pbr = paging_report;
+                            ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PBS;
                 }
 
                   /* Check flag for creation of UL CQI report */
@@ -484,7 +487,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                           }
                         //  Add full UL CQI report to the UE report
                         ue_report[i]->ul_cqi_report = full_ul_report;
-
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_UL_CQI;
 
                      }
                       if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_STATS) {
@@ -580,7 +583,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
 
 
                         ue_report[i]->mac_stats = macstats;
-
+                        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_STATS;
                }
 
 
@@ -622,6 +625,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
                             ni_report->p0_nominal_pucch = flexran_get_p0_nominal_pucch(enb_id, 0);
                             ni_report->has_p0_nominal_pucch = 1;
                             cell_report[i]->noise_inter_report = ni_report;
+                            cell_report[i]->flags |= PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE;
                       }
             }
 
diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
index 34f3f414cca..85d5342c5f0 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
@@ -116,7 +116,7 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id,
 	pdcp_aggr_stats->has_sfn =1;
 
 	ue_report[i]->pdcp_stats = pdcp_aggr_stats;
-
+        ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PDCP_STATS;
       }
     }
   }  else {
diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
index ad5990b70fd..ecffc27002f 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
@@ -441,6 +441,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
         }
 
       	 ue_report[i]->rrc_measurements = rrc_measurements;
+         ue_report[i]->flags |= PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RRC_MEASUREMENTS;
       	
       }
 
@@ -477,6 +478,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
   //                           ni_report->p0_nominal_pucch = flexran_get_p0_nominal_pucch(enb_id, 0);
   //                           ni_report->has_p0_nominal_pucch = 1;
   //                           cell_report[i]->noise_inter_report = ni_report;
+  //                           cell_report[i]->flags |= PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE;
   //                     }
   //           }
             
diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c
index 5e1cf7809a7..aabf817c2c4 100644
--- a/openair2/ENB_APP/flexran_agent_handler.c
+++ b/openair2/ENB_APP/flexran_agent_handler.c
@@ -449,8 +449,7 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re
       protocol__flex_ue_stats_report__init(ue_report[i]);
       ue_report[i]->rnti = report_config->ue_report_type[i].ue_rnti;
       ue_report[i]->has_rnti = 1;
-      ue_report[i]->flags = report_config->ue_report_type[i].ue_report_flags;
-      ue_report[i]->has_flags = 1;
+      ue_report[i]->has_flags = 1; /* actual flags are filled in the CMs below */
   
   }
 
@@ -472,8 +471,7 @@ int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *re
       protocol__flex_cell_stats_report__init(cell_report[i]);
       cell_report[i]->carrier_index = report_config->cc_report_type[i].cc_id;
       cell_report[i]->has_carrier_index = 1;
-      cell_report[i]->flags = report_config->cc_report_type[i].cc_report_flags;
-      cell_report[i]->has_flags = 1;
+      cell_report[i]->has_flags = 1; /* actual flags are filled in the CMs below */
 
   }
 
-- 
GitLab