[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] KPI reporting per statistics group
[o-du/l2.git] / src / du_app / du_msg_hdl.c
index e29aa3b..6444943 100644 (file)
@@ -2150,11 +2150,13 @@ Statistics FetchStatsFromActionDefFormat1(ActionDefFormat1 format1)
 
    /* Hardcoding values for now for testing purpose 
     * Will be removed in next gerrit */
-   stats.macStatsReq.numStats = 2;
-   stats.macStatsReq.statsList[0].type = MAC_DL_TOTAL_PRB_USAGE;
-   stats.macStatsReq.statsList[0].periodicity = 100;
-   stats.macStatsReq.statsList[1].type = MAC_UL_TOTAL_PRB_USAGE;
-   stats.macStatsReq.statsList[1].periodicity = 100;
+   stats.macStatsReq.subscriptionId = 1;
+   stats.macStatsReq.numStatsGroup = 1;
+   stats.macStatsReq.statsGrpList[0].groupId = 1;
+   stats.macStatsReq.statsGrpList[0].periodicity = 100;
+   stats.macStatsReq.statsGrpList[0].numStats = 2;
+   stats.macStatsReq.statsGrpList[0].statsList[0] = MAC_DL_TOTAL_PRB_USAGE;
+   stats.macStatsReq.statsGrpList[0].statsList[1] = MAC_UL_TOTAL_PRB_USAGE;
 
    return stats;
 }
@@ -2217,6 +2219,103 @@ uint8_t BuildAndSendStatsReq(ActionDefinition subscribedAction)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Process statistics response from MAC
+ *
+ * @details
+ *
+ *    Function : DuProcMacStatsRsp
+ *
+ *    Functionality: Processes statistics configuration response
+ *       from MAC. If configuration is succsessful, DUAPP starts
+ *       reporting period timer for this subscription request 
+ *       from RIC
+ *
+ * @params[in]
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp)
+{
+   uint8_t idx = 0;
+
+   DU_LOG("\nINFO  -->  DU_APP : DuProcMacStatsRsp: Received Statistics Response from MAC");
+
+   if(statsRsp)
+   {
+#ifdef DEBUG_PRINT   
+      DU_LOG("\n  Subscription Id [%ld]", statsRsp->subscriptionId);
+
+      DU_LOG("\n  Number of Accepted Groups [%d]", statsRsp->numGrpAccepted);
+      for(idx=0; idx<statsRsp->numGrpAccepted; idx++)
+      {
+         DU_LOG("\n    Group Id [%d]", statsRsp->statsGrpAcceptedList[idx]);
+      }
+
+      DU_LOG("\n  Number of Rejected Groups [%d]", statsRsp->numGrpRejected);
+      for(idx=0; idx<statsRsp->numGrpRejected; idx++)
+      {
+         DU_LOG("\n    Group Id [%d]", statsRsp->statsGrpRejectedList[idx]);
+      }
+#endif      
+
+      DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsRsp, sizeof(MacStatsRsp));
+      return ROK;
+   }
+
+   DU_LOG("\nERROR  -->  DU_APP : DuProcMacStatsRsp: Received NULL Pointer");
+   return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Process statistics indication from MAC
+ *
+ * @details
+ *
+ *    Function : DuProcMacStatsInd
+ *
+ *    Functionality: Processes statistics indication from MAC.
+ *
+ * @params[in]
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcMacStatsInd(Pst *pst, MacStatsInd *statsInd)
+{
+   if(statsInd)
+   {
+#ifdef DEBUG_PRINT   
+      DU_LOG("\nDEBUG  -->  DU_APP : DuProcMacStatsInd: Received Statistics Indication");
+      DU_LOG("\n  Subscription Id [%ld]", statsInd->subscriptionId);
+      DU_LOG("\n  Group Id [%d]", statsInd->groupId);
+      for(int idx = 0; idx < statsInd->numStats; idx++)
+      {
+         DU_LOG("\n  Meas type [%d] Meas Value [%lf]", statsInd->measuredStatsList[idx].type,\
+            statsInd->measuredStatsList[idx].value);
+      }
+#endif      
+
+      /* TODO : When stats indication is received
+       * DU APP searches for the message type in E2AP RIC subscription database
+       * and stores in the value in the list of subscribed measurements
+       *
+       * This will be implemented in next gerrit.
+       */
+
+      DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsInd, sizeof(MacStatsInd));
+      return ROK;
+   }
+   
+   DU_LOG("\nINFO  -->  DU_APP : DuProcMacStatsInd: Received NULL Pointer");
+   return RFAILED;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/