[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] Statistics Indication between DU APP... 60/11760/2
authorlal.harshita <Harshita.Lal@radisys.com>
Fri, 1 Sep 2023 08:56:31 +0000 (14:26 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Mon, 4 Sep 2023 10:31:15 +0000 (16:01 +0530)
Change-Id: I08e3e45b7a51243a8649f306a8c2c088b7e605a4
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
13 files changed:
build/odu/makefile
src/5gnrmac/mac.h
src/5gnrmac/mac_msg_hdl.c
src/5gnrmac/mac_msg_router.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_slot_ind.c
src/5gnrsch/sch_tmr.c
src/cm/du_app_mac_inf.c
src/cm/du_app_mac_inf.h
src/cm/mac_sch_interface.h
src/du_app/du_mgr_msg_router.c
src/du_app/du_msg_hdl.c

index 45b291f..5154448 100644 (file)
@@ -74,7 +74,7 @@ endif
 # macro for output file name and makefile name
 #
 
-PLTFRM_FLAGS= -UMSPD -DODU -DINTEL_FAPI -UODU_MEMORY_DEBUG_LOG -DDEBUG_ASN_PRINT -DDEBUG_PRINT -DERROR_PRINT -USTART_DL_UL_DATA -UNR_DRX -UCALL_FLOW_DEBUG_LOG -UODU_SLOT_IND_DEBUG_LOG
+PLTFRM_FLAGS= -UMSPD -DODU -DINTEL_FAPI -UODU_MEMORY_DEBUG_LOG -DDEBUG_ASN_PRINT -UDEBUG_PRINT -DERROR_PRINT -USTART_DL_UL_DATA -UNR_DRX -UCALL_FLOW_DEBUG_LOG -UODU_SLOT_IND_DEBUG_LOG
 
 ifeq ($(MODE),TDD)
    PLTFRM_FLAGS += -DNR_TDD
index 756e288..a245358 100644 (file)
@@ -289,6 +289,7 @@ uint8_t MacProcDlPageAlloc(Pst *pst, DlPageAlloc *dlPageAlloc);
 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDeleteRsp);
 
 uint8_t MacProcSchStatsRsp(Pst *pst, SchStatsRsp *schStatsRsp);
+uint8_t MacProcSchStatsInd(Pst *pst, SchStatsInd *schStatsInd);
 #endif
 /**********************************************************************
   End of file
index b0779d9..f5e6649 100644 (file)
 
 MacCb  macCb;
 
+MacDuStatsIndFunc macDuStatsIndOpts[] =
+{
+   packDuMacStatsInd,   /* packing for loosely coupled */
+   DuProcMacStatsInd,   /* packing for tightly coupled */
+   packDuMacStatsInd   /* packing for light weight loosly coupled */
+};
+
+
 /*******************************************************************
  *
  * @brief Sends DL BO Info to SCH
@@ -1057,6 +1065,68 @@ uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
    return ret;
 }
 
+/**
+ * @brief Mac process the statistics indication received from sch.
+ *
+ * @details
+ *
+ *     Function : MacProcSchStatsInd
+ *
+ *     This function process the statistics indication received from sch
+ *
+ *  @param[in]  Pst           *pst
+ *  @param[in]  SchStatsInd   *schStatsInd
+ *  @return  int
+ *      -# ROK
+ **/
+uint8_t MacProcSchStatsInd(Pst *pst, SchStatsInd *schStatsInd)
+{
+   Pst indPst;
+   MacStatsInd *macStatsInd;
+
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG  -->  MAC : MacProcSchStatsInd: Received Statistics Indication from SCH");
+#endif   
+
+   if(schStatsInd == NULLP)
+   {
+      DU_LOG("\nERROR  -->  MAC : MacProcSchStatsInd: NULL pointer :schStatsInd");
+      return RFAILED;
+   }
+
+   MAC_ALLOC_SHRABL_BUF(macStatsInd, sizeof(MacStatsInd));
+   if(macStatsInd == NULLP)
+   {
+      DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchStatsInd");
+      return RFAILED;
+   }
+
+   switch(schStatsInd->type)
+   {
+      case SCH_DL_TOTAL_PRB_USAGE:
+         {
+            macStatsInd->type = MAC_DL_TOTAL_PRB_USAGE;
+            break;
+         }
+      case SCH_UL_TOTAL_PRB_USAGE:
+         {
+            macStatsInd->type = MAC_UL_TOTAL_PRB_USAGE;
+            break;
+         }
+      default:
+         {
+            DU_LOG("\nERROR  -->  MAC : MacProcSchStatsInd: Invalid measurement type [%d]", schStatsInd->type);
+            MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, macStatsInd, sizeof(MacStatsInd));
+            return RFAILED;
+         }
+   }
+   macStatsInd->value = schStatsInd->value;
+
+   memset(&indPst, 0, sizeof(Pst));
+   FILL_PST_MAC_TO_DUAPP(indPst, EVENT_MAC_STATISTICS_IND);
+   return (*macDuStatsIndOpts[indPst.selector])(&indPst, macStatsInd);
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/
index a00eac7..37f07ae 100755 (executable)
@@ -480,6 +480,11 @@ void callFlowMacActvTsk(Pst *pst)
                         strcpy(message,"EVENT_STATISTICS_RSP_TO_MAC");
                         break;
                      }
+                  case EVENT_STATISTICS_IND_TO_MAC:
+                     {
+                        strcpy(message,"EVENT_STATISTICS_IND_TO_MAC");
+                        break;
+                     }
                   default:
                      strcpy(message,"Invalid Event");
                      break;
@@ -629,6 +634,11 @@ uint8_t MacMessageRouter(Pst *pst, void *msg)
             MacProcSchStatsRsp(pst, (SchStatsRsp *)msg);
             break;
          }
+      case EVENT_STATISTICS_IND_TO_MAC:
+         {
+            MacProcSchStatsInd(pst, (SchStatsInd *)msg);
+            break;
+         }
       default:
          {
             return RFAILED;
index 8e90431..397e862 100644 (file)
@@ -2690,6 +2690,52 @@ uint8_t SchProcStatsReq(Pst *pst, SchStatsReq *statsReq)
    return ROK;
 } /* End of SchProcStatsReq */
 
+/*******************************************************************
+ *
+ * @brief Fill and send statistics indication to MAC
+ *
+ * @details
+ *
+ *    Function :  SchSendStatsIndToMac
+ *
+ *    Functionality: Fill and send statistics indication to MAC
+ *
+ * @params[in]  SCH Instance
+ *              Measurement Type
+ *              Measurement Value
+ *              Size of value parameter
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t SchSendStatsIndToMac(Inst inst, SchMeasurementType measType, double value)
+{
+   Pst pst;
+   uint8_t ret = ROK;
+   SchStatsInd  statsInd;
+
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG  --> SCH : Filling statistics indication");
+#endif
+
+   memset(&statsInd, 0, sizeof(SchStatsInd));
+   statsInd.type = measType;
+   statsInd.value = value;
+
+   /* Filling post structure */
+   memset(&pst, 0, sizeof(Pst));
+   FILL_PST_SCH_TO_MAC(pst, inst);
+   pst.event = EVENT_STATISTICS_IND_TO_MAC;
+
+   ret = MacMessageRouter(&pst, (void *)&statsInd);
+   if(ret == RFAILED)
+   {
+      DU_LOG("\nERROR  -->  SCH : SchSendStatsIndToMac(): Failed to send Statistics Indication");
+   }
+   return ret;
+}
+
+
 /**********************************************************************
   End of file
  **********************************************************************/
index 537ed31..38d0063 100644 (file)
@@ -796,6 +796,7 @@ void schMsg4Complete(SchUeCb *ueCb);
 
 /* Statistics Function */
 uint8_t SchProcStatsReq(Pst *pst, SchStatsReq *statsReq);
+uint8_t SchSendStatsIndToMac(Inst inst, SchMeasurementType measType, double value);
 
 /**********************************************************************
   End of file
index 5051095..643ee65 100644 (file)
@@ -753,7 +753,7 @@ uint8_t SchProcSlotInd(Pst *pst, SlotTimingInfo *slotInd)
    /* Update DL statistics */
    if(schCb[schInst].statistics.dlTotalPrbUsage)
    {
-      schCb[schInst].statistics.dlTotalPrbUsage->numPrbUsedForTx += cell->schUlSlotInfo[slot]->prbAlloc.numPrbAlloc; 
+      schCb[schInst].statistics.dlTotalPrbUsage->numPrbUsedForTx += cell->schDlSlotInfo[slot]->prbAlloc.numPrbAlloc; 
       schCb[schInst].statistics.dlTotalPrbUsage->totalPrbAvailForTx += MAX_NUM_RB;
    }
    
index d88b142..fa71674 100644 (file)
@@ -82,8 +82,10 @@ void schStartTmr(SchCb *gCb, PTR cb, int16_t tmrEvnt, uint8_t timerValue)
 
    arg.wait = 0;
 
-   DU_LOG("\nINFO   -->  SCH : Starting Timer Event [%d] with Wait Time [%d] ms", \
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG   -->  SCH : Starting Timer Event [%d] with Wait Time [%d] ms", \
       tmrEvnt, timerValue);
+#endif      
    
    switch (tmrEvnt)
    {
@@ -140,7 +142,9 @@ void schStopTmr(SchCb *gCb, PTR cb, uint8_t tmrType)
 
    arg.timers = NULLP;
 
-   DU_LOG("\nINFO   -->  SCH : Stopping Timer Event [%d]", tmrType);
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG   -->  SCH : Stopping Timer Event [%d]", tmrType);
+#endif   
 
    switch (tmrType)
    {
@@ -190,11 +194,11 @@ void schStopTmr(SchCb *gCb, PTR cb, uint8_t tmrType)
 */
 uint8_t SchProcDlTotalPrbUsageTmrExp(TotalPrbUsage *dlTotalPrbUsage)
 {
-   uint8_t percentageOfTotalPrbUsed = 0;
+   double percentageOfTotalPrbUsed = 0;
 
    if(dlTotalPrbUsage->totalPrbAvailForTx)
-      percentageOfTotalPrbUsed = ((dlTotalPrbUsage->numPrbUsedForTx * 100) / dlTotalPrbUsage->totalPrbAvailForTx);
-   //SchSendStatsIndToMac(dlTotalPrbUsage->schInst, SCH_DL_TOTAL_PRB_USAGE, percentageOfTotalPrbUsed);
+      percentageOfTotalPrbUsed = ((100.0 * dlTotalPrbUsage->numPrbUsedForTx) / dlTotalPrbUsage->totalPrbAvailForTx);
+   SchSendStatsIndToMac(dlTotalPrbUsage->schInst, SCH_DL_TOTAL_PRB_USAGE, percentageOfTotalPrbUsed);
    
    /* Restart Timer */
    dlTotalPrbUsage->numPrbUsedForTx = 0;
@@ -217,11 +221,11 @@ uint8_t SchProcDlTotalPrbUsageTmrExp(TotalPrbUsage *dlTotalPrbUsage)
 */
 uint8_t SchProcUlTotalPrbUsageTmrExp(TotalPrbUsage *ulTotalPrbUsage)
 {
-   uint8_t percentageOfTotalPrbUsed = 0;
+   double percentageOfTotalPrbUsed = 0;
 
    if(ulTotalPrbUsage->totalPrbAvailForTx)
-      percentageOfTotalPrbUsed = ((ulTotalPrbUsage->numPrbUsedForTx * 100) / ulTotalPrbUsage->totalPrbAvailForTx);
-   //SchSendStatsIndToMac(ulTotalPrbUsage->schInst, SCH_UL_TOTAL_PRB_USAGE, percentageOfTotalPrbUsed);
+      percentageOfTotalPrbUsed = ((100.0 * ulTotalPrbUsage->numPrbUsedForTx) / ulTotalPrbUsage->totalPrbAvailForTx);
+   SchSendStatsIndToMac(ulTotalPrbUsage->schInst, SCH_UL_TOTAL_PRB_USAGE, percentageOfTotalPrbUsed);
 
    /* Restart Timer */
    ulTotalPrbUsage->numPrbUsedForTx = 0;
@@ -250,6 +254,10 @@ uint8_t SchProcUlTotalPrbUsageTmrExp(TotalPrbUsage *ulTotalPrbUsage)
  **/
 uint8_t schTmrExpiry(PTR cb, uint8_t tmrEvnt)
 {
+#ifdef DEBUG_PRINT
+   DU_LOG("\nDEBUG   -->  SCH : Timer Expired. Event [%d]", tmrEvnt);
+#endif
+
    switch (tmrEvnt)
    {
       case EVENT_DL_TOTAL_PRB_USAGE_TMR:
index 3289cc7..52ea9dc 100644 (file)
@@ -2476,6 +2476,85 @@ uint8_t unpackDuMacStatsRsp(MacDuStatsRspFunc func, Pst *pst, Buffer *mBuf)
     return RFAILED;
 }
 
+/*******************************************************************
+*
+* @brief Packs and Sends Statistics Indication from MAC to DUAPP
+*
+* @details
+*
+*    Function : packDuMacStatsInd
+*
+*    Functionality:
+*       Packs and Sends statistics response from MAC to DUAPP
+*
+*
+* @params[in] Post structure pointer
+*             StatsInd pointer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t packDuMacStatsInd(Pst *pst, MacStatsInd *statsInd)
+{
+    Buffer *mBuf = NULLP;
+
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+       {
+          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacStatsInd");
+          return RFAILED;
+       }
+       /* pack the address of the structure */
+       CMCHKPK(oduPackPointer,(PTR)statsInd, mBuf);
+    }
+    else
+    {
+       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacStatsInd");
+       return RFAILED;
+    }
+    return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+*
+* @brief Unpacks Statistics Indication received from MAC
+*
+* @details
+*
+*    Function : unpackDuMacStatsInd
+*
+*    Functionality:
+*         Unpacks Statistics Indication received from MAC
+*
+* @params[in] Pointer to Handler
+*             Post structure pointer
+*             Message Buffer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t unpackDuMacStatsInd(MacDuStatsIndFunc func, Pst *pst, Buffer *mBuf)
+{
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       MacStatsInd *statsInd;
+
+       /* unpack the address of the structure */
+       CMCHKUNPK(oduUnpackPointer, (PTR *)&statsInd, mBuf);
+       ODU_PUT_MSG_BUF(mBuf);
+       return (*func)(pst, statsInd);
+    }
+    else
+    {
+       /* Nothing to do for other selectors */
+       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Statistics Indication ");
+       ODU_PUT_MSG_BUF(mBuf);
+    }
+
+    return RFAILED;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/
index c0cb0dc..4b2f98e 100644 (file)
@@ -91,6 +91,7 @@
 #define EVENT_MAC_DL_BROADCAST_REQ   228
 #define EVENT_MAC_STATISTICS_REQ     229
 #define EVENT_MAC_STATISTICS_RSP     230
+#define EVENT_MAC_STATISTICS_IND     231
 
 #define BSR_PERIODIC_TIMER_SF_10 10
 #define BSR_RETX_TIMER_SF_320 320
@@ -1872,6 +1873,12 @@ typedef struct macStatsRsp
    CauseOfResult cause;
 }MacStatsRsp;
 
+typedef struct macStatsInd
+{
+   MacMeasurementType type;
+   double value;
+}MacStatsInd;
+
 /****************** FUNCTION POINTERS ********************************/
 
 /* DL broadcast req from DU APP to MAC*/
@@ -2036,6 +2043,11 @@ typedef uint8_t (*MacDuStatsRspFunc) ARGS((
       Pst *pst,
       MacStatsRsp *statsRsp));
 
+/* Statistics Ind from MAC to DU APP */
+typedef uint8_t (*MacDuStatsIndFunc) ARGS((
+      Pst *pst,
+      MacStatsInd *statsInd));
+
 /******************** FUNCTION DECLARATIONS ********************************/
 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId);
 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf);
@@ -2165,6 +2177,9 @@ uint8_t packDuMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp);
 uint8_t DuProcMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp);
 uint8_t unpackDuMacStatsRsp(MacDuStatsRspFunc func, Pst *pst, Buffer *mBuf);
 
+uint8_t packDuMacStatsInd(Pst *pst, MacStatsInd *statsRsp);
+uint8_t DuProcMacStatsInd(Pst *pst, MacStatsInd *statsRsp);
+uint8_t unpackDuMacStatsInd(MacDuStatsIndFunc func, Pst *pst, Buffer *mBuf);
 #endif
 
 
index 781973f..58f894a 100644 (file)
@@ -53,6 +53,7 @@
 #define EVENT_PHR_IND_TO_SCH         34
 #define EVENT_STATISTICS_REQ_TO_SCH  35
 #define EVENT_STATISTICS_RSP_TO_MAC  36
+#define EVENT_STATISTICS_IND_TO_MAC  37
 
 /*macros*/
 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
@@ -2265,6 +2266,12 @@ typedef struct schStatsRsp
    CauseOfResult cause;
 }SchStatsRsp;
 
+typedef struct schStatsInd
+{
+   SchMeasurementType type;
+   double value;
+}SchStatsInd;
+
 /* function declarations */
 uint8_t MacMessageRouter(Pst *pst, void *msg);
 uint8_t SchMessageRouter(Pst *pst, void *msg);
index c077fe0..5acda22 100644 (file)
@@ -292,6 +292,11 @@ void callFlowduActvTsk(Pst *pst)
                      strcpy(message,"EVENT_MAC_STATISTICS_RSP");
                      break;
                   }
+               case EVENT_MAC_STATISTICS_IND:
+                  {
+                     strcpy(message,"EVENT_MAC_STATISTICS_IND");
+                     break;
+                  }
                default:
                   {
                      strcpy(message,"Invalid Event");
@@ -592,6 +597,11 @@ uint8_t duActvTsk(Pst *pst, Buffer *mBuf)
                      ret = unpackDuMacStatsRsp(DuProcMacStatsRsp, pst, mBuf);
                      break;
                   }
+               case EVENT_MAC_STATISTICS_IND:
+                  {
+                     ret = unpackDuMacStatsInd(DuProcMacStatsInd, pst, mBuf);
+                     break;
+                  }
                default:
                   {
                      DU_LOG("\nERROR  -->  DU_APP : Invalid event received at duActvTsk from ENTMAC");
index 38bc4b5..ca5c9e5 100644 (file)
@@ -2258,6 +2258,46 @@ uint8_t DuProcMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp)
    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("\nMeasurement type [%d]  Measurement Value [%lf]", statsInd->type, statsInd->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
  **********************************************************************/