[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] Statistics Response between DU APP and... 74/11674/2
authorlal.harshita <Harshita.Lal@radisys.com>
Mon, 28 Aug 2023 12:50:25 +0000 (18:20 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Tue, 29 Aug 2023 12:43:24 +0000 (18:13 +0530)
Change-Id: I70aa590dfabebeb2a160a018017caff19d79728c
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
src/5gnrmac/mac.h
src/5gnrmac/mac_cfg_hdl.c
src/5gnrmac/mac_msg_router.c
src/5gnrsch/sch.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 647299f..756e288 100644 (file)
@@ -287,6 +287,8 @@ uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
 uint8_t MacProcSchRachRsrcRsp(Pst *pst, SchRachRsrcRsp *schRachRsrcRsp);
 uint8_t MacProcDlPageAlloc(Pst *pst, DlPageAlloc *dlPageAlloc);
 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDeleteRsp);
+
+uint8_t MacProcSchStatsRsp(Pst *pst, SchStatsRsp *schStatsRsp);
 #endif
 /**********************************************************************
   End of file
index fa17ba0..589f730 100644 (file)
@@ -63,6 +63,14 @@ MacDuSliceRecfgRspFunc macDuSliceRecfgRspOpts[] =
    packDuMacSliceRecfgRsp    /* packing for light weight loosly coupled */
 };
 
+MacDuStatsRspFunc macDuStatsRspOpts[] =
+{
+   packDuMacStatsRsp,   /* packing for loosely coupled */
+   DuProcMacStatsRsp,   /* packing for tightly coupled */
+   packDuMacStatsRsp   /* packing for light weight loosly coupled */
+};
+
+
 /**
  * @brief Layer Manager  Configuration request handler for Scheduler
  *
@@ -1015,6 +1023,57 @@ uint8_t MacProcDlBroadcastReq(Pst *pst, MacDlBroadcastReq *dlBroadcastReq)
    return ret;
 }
 
+/**
+ * @brief Fill and send statistics response to DU APP
+ *
+ * @details
+ *
+ *     Function : MacSendStatsRspToDuApp
+ *
+ *     Fill and send statistics response to DU APP
+ *
+ *  @param[in]  Response
+ *  @param[in]  Cause of response
+ *  @return  int
+ *      -# ROK
+ **/
+uint8_t MacSendStatsRspToDuApp(MacRsp rsp, CauseOfResult cause)
+{
+   uint8_t ret = ROK;
+   Pst  pst;
+   MacStatsRsp *macStatsRsp = NULLP;
+
+   /* Workaround : To skip corrupted memory, allocating a pointer that will
+    * remain unused */
+   uint8_t *dummyPtr = NULLP;
+   MAC_ALLOC_SHRABL_BUF(dummyPtr, sizeof(uint8_t));
+
+   MAC_ALLOC_SHRABL_BUF(macStatsRsp, sizeof(MacStatsRsp));
+   if(macStatsRsp == NULLP)
+   {
+      DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchStatsRsp");
+      ret = RFAILED;
+   }
+   else
+   {
+      macStatsRsp->rsp = rsp;
+      macStatsRsp->cause = cause;
+
+      memset(&pst, 0, sizeof(Pst));
+      FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_STATISTICS_RSP);
+      if(((*macDuStatsRspOpts[pst.selector])(&pst, macStatsRsp))!= ROK)
+      {
+         DU_LOG("\nERROR  -->  MAC : Failed to send statistics response to DU APP");
+         MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, macStatsRsp, sizeof(MacStatsRsp));
+         ret = RFAILED;
+      }
+   }
+
+   /* Workaround : Freeing the dummy pointer */
+   MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, dummyPtr, sizeof(uint8_t));
+   return ret;
+}
+
 /**
  * @brief Mac process the statistics Req received from DUAPP
  *
@@ -1108,7 +1167,37 @@ uint8_t MacProcStatsReq(Pst *pst, MacStatsReq *macStatsReq)
 
    if(ret == RFAILED)
    {
-      /* Send negative acknowledgment to DU APP. TBD in next gerrit */
+      MacSendStatsRspToDuApp(MAC_DU_APP_RSP_NOK, cause);
+   }
+   return ret;
+}
+
+/**
+ * @brief Mac process the statistics rsp received from sch.
+ *
+ * @details
+ *
+ *     Function : MacProcSchStatsRsp
+ *
+ *     This function  process the statistics response received from sch
+ *
+ *  @param[in]  Pst           *pst
+ *  @param[in]  SchStatsRsp *schStatsRsp
+ *  @return  int
+ *      -# ROK
+ **/
+uint8_t MacProcSchStatsRsp(Pst *pst, SchStatsRsp *schStatsRsp)
+{
+   uint8_t ret = RFAILED;
+
+   if(schStatsRsp)
+   {
+      if(schStatsRsp->rsp == RSP_OK)
+         ret = MacSendStatsRspToDuApp(MAC_DU_APP_RSP_OK, schStatsRsp->cause);
+      else
+         ret = MacSendStatsRspToDuApp(MAC_DU_APP_RSP_NOK, schStatsRsp->cause);
+
+      MAC_FREE(schStatsRsp, sizeof(SchStatsRsp));
    }
    return ret;
 }
index 62b25d3..a00eac7 100755 (executable)
@@ -475,6 +475,11 @@ void callFlowMacActvTsk(Pst *pst)
                         strcpy(message,"EVENT_DL_REL_HQ_PROC");
                         break;
                      }
+                  case EVENT_STATISTICS_RSP_TO_MAC:
+                     {
+                        strcpy(message,"EVENT_STATISTICS_RSP_TO_MAC");
+                        break;
+                     }
                   default:
                      strcpy(message,"Invalid Event");
                      break;
@@ -619,6 +624,11 @@ uint8_t MacMessageRouter(Pst *pst, void *msg)
             MacSchReleaseDlHarqProc(pst, (SchRlsHqInfo *)msg);
             break;
          }
+      case EVENT_STATISTICS_RSP_TO_MAC:
+         {
+            MacProcSchStatsRsp(pst, (SchStatsRsp *)msg);
+            break;
+         }
       default:
          {
             return RFAILED;
index 563cb5a..8e90431 100644 (file)
@@ -2501,6 +2501,52 @@ uint8_t SchProcPhrInd(Pst *pst, SchPwrHeadroomInd *schPhrInd)
    return ret;
 }
 
+/*******************************************************************
+ *
+ * @brief Fill and send statistics response to MAC
+ *
+ * @details
+ *
+ *    Function :  SchSendStatsRspToMac
+ *
+ *    Functionality: Fill and send statistics response to MAC
+ *
+ * @params[in]  Inst inst, SchMacRsp result
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t SchSendStatsRspToMac(Inst inst, SchMacRsp result, CauseOfResult cause)
+{
+   Pst rspPst;
+   uint8_t ret = ROK;
+   SchStatsRsp  *statsRsp;
+
+   DU_LOG("\nINFO   --> SCH : Filling statistics response");
+   SCH_ALLOC(statsRsp, sizeof(SchStatsRsp));
+   if(statsRsp == NULLP)
+   {
+      DU_LOG("\nERROR  --> SCH : Failed to allocate memory in SchSendStatsRspToMac()");
+      return RFAILED;
+   }
+   memset(statsRsp, 0, sizeof(SchStatsRsp));
+   statsRsp->rsp = result;
+   statsRsp->cause = cause;
+
+   /* Filling response post */
+   memset(&rspPst, 0, sizeof(Pst));
+   FILL_PST_SCH_TO_MAC(rspPst, inst);
+   rspPst.event = EVENT_STATISTICS_RSP_TO_MAC;
+
+   ret = MacMessageRouter(&rspPst, (void *)statsRsp);
+   if(ret == RFAILED)
+   {
+      DU_LOG("\nERROR  -->  SCH : SchSendStatsRspToMac(): Failed to send Statistics Response");
+      return ret;
+   }
+   return ret;
+}
+
 /*******************************************************************
  *
  * @brief Processes Statistics Request from MAC
@@ -2639,8 +2685,7 @@ uint8_t SchProcStatsReq(Pst *pst, SchStatsReq *statsReq)
 
    SCH_FREE(statsReq, sizeof(SchStatsReq));
 
-   /* TODO : in next gerrit */
-   //SchSendStatsRspToMac(inst, rsp, cause);
+   SchSendStatsRspToMac(inst, rsp, cause);
 
    return ROK;
 } /* End of SchProcStatsReq */
index e31c518..d88b142 100644 (file)
@@ -250,13 +250,6 @@ uint8_t SchProcUlTotalPrbUsageTmrExp(TotalPrbUsage *ulTotalPrbUsage)
  **/
 uint8_t schTmrExpiry(PTR cb, uint8_t tmrEvnt)
 {
-   DU_LOG("\nINFO   -->  SCH : Timer Event [%d] expired", tmrEvnt);
-
-   struct timeval tp;
-   gettimeofday(&tp, 0);
-   time_t curtime = tp.tv_sec;
-   struct tm *t = localtime(&curtime);
-
    switch (tmrEvnt)
    {
       case EVENT_DL_TOTAL_PRB_USAGE_TMR:
index e5e18c9..3289cc7 100644 (file)
@@ -2397,6 +2397,85 @@ uint8_t unpackMacStatsReq(DuMacStatsReqFunc func, Pst *pst, Buffer *mBuf)
     return RFAILED;
 }
 
+/*******************************************************************
+*
+* @brief Packs and Sends Statistics Response from MAC to DUAPP
+*
+* @details
+*
+*    Function : packDuMacStatsRsp
+*
+*    Functionality:
+*       Packs and Sends statistics response from MAC to DUAPP
+*
+*
+* @params[in] Post structure pointer
+*             StatsRsp pointer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t packDuMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp)
+{
+    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 packDuMacStatsRsp");
+          return RFAILED;
+       }
+       /* pack the address of the structure */
+       CMCHKPK(oduPackPointer,(PTR)statsRsp, mBuf);
+    }
+    else
+    {
+       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacStatsRsp");
+       return RFAILED;
+    }
+    return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+*
+* @brief Unpacks Statistics Response received from MAC
+*
+* @details
+*
+*    Function : unpackDuMacStatsRsp
+*
+*    Functionality:
+*         Unpacks Statistics Response received from MAC
+*
+* @params[in] Pointer to Handler
+*             Post structure pointer
+*             Message Buffer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t unpackDuMacStatsRsp(MacDuStatsRspFunc func, Pst *pst, Buffer *mBuf)
+{
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       MacStatsRsp *statsRsp;
+
+       /* unpack the address of the structure */
+       CMCHKUNPK(oduUnpackPointer, (PTR *)&statsRsp, mBuf);
+       ODU_PUT_MSG_BUF(mBuf);
+       return (*func)(pst, statsRsp);
+    }
+    else
+    {
+       /* Nothing to do for other selectors */
+       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Statistics Response ");
+       ODU_PUT_MSG_BUF(mBuf);
+    }
+
+    return RFAILED;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/
index c7f88d6..c0cb0dc 100644 (file)
@@ -90,6 +90,7 @@
 #define EVENT_MAC_UE_SYNC_STATUS_IND 227
 #define EVENT_MAC_DL_BROADCAST_REQ   228
 #define EVENT_MAC_STATISTICS_REQ     229
+#define EVENT_MAC_STATISTICS_RSP     230
 
 #define BSR_PERIODIC_TIMER_SF_10 10
 #define BSR_RETX_TIMER_SF_320 320
@@ -1865,6 +1866,12 @@ typedef struct macStatsReq
    MacStatsInfo statsList[MAX_NUM_STATS];
 }MacStatsReq;
 
+typedef struct macStatsRsp
+{
+   MacRsp  rsp;
+   CauseOfResult cause;
+}MacStatsRsp;
+
 /****************** FUNCTION POINTERS ********************************/
 
 /* DL broadcast req from DU APP to MAC*/
@@ -2024,6 +2031,11 @@ typedef uint8_t (*DuMacStatsReqFunc) ARGS((
       Pst *pst,
       MacStatsReq *statsReq));
 
+/* Statistics Response from MAC to DU APP */
+typedef uint8_t (*MacDuStatsRspFunc) ARGS((
+      Pst *pst,
+      MacStatsRsp *statsRsp));
+
 /******************** FUNCTION DECLARATIONS ********************************/
 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId);
 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf);
@@ -2149,6 +2161,10 @@ uint8_t packDuMacStatsReq(Pst *pst, MacStatsReq *statsReq);
 uint8_t MacProcStatsReq(Pst *pst, MacStatsReq *statsReq);
 uint8_t unpackMacStatsReq(DuMacStatsReqFunc func, Pst *pst, Buffer *mBuf);
 
+uint8_t packDuMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp);
+uint8_t DuProcMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp);
+uint8_t unpackDuMacStatsRsp(MacDuStatsRspFunc func, Pst *pst, Buffer *mBuf);
+
 #endif
 
 
index ca34970..781973f 100644 (file)
@@ -52,6 +52,7 @@
 #define EVENT_UL_CQI_TO_SCH          33
 #define EVENT_PHR_IND_TO_SCH         34
 #define EVENT_STATISTICS_REQ_TO_SCH  35
+#define EVENT_STATISTICS_RSP_TO_MAC  36
 
 /*macros*/
 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */
@@ -2258,6 +2259,12 @@ typedef struct schStatsReq
    SchStatsInfo statsList[MAX_NUM_STATS];
 }SchStatsReq;
 
+typedef struct schStatsRsp
+{
+   SchMacRsp rsp; 
+   CauseOfResult cause;
+}SchStatsRsp;
+
 /* function declarations */
 uint8_t MacMessageRouter(Pst *pst, void *msg);
 uint8_t SchMessageRouter(Pst *pst, void *msg);
index 073b3e7..c077fe0 100644 (file)
@@ -287,6 +287,11 @@ void callFlowduActvTsk(Pst *pst)
                      strcpy(message,"EVENT_MAC_SLICE_RECFG_RSP");
                      break;
                   }
+               case EVENT_MAC_STATISTICS_RSP:
+                  {
+                     strcpy(message,"EVENT_MAC_STATISTICS_RSP");
+                     break;
+                  }
                default:
                   {
                      strcpy(message,"Invalid Event");
@@ -582,6 +587,11 @@ uint8_t duActvTsk(Pst *pst, Buffer *mBuf)
                      ret = unpackDuMacUeResetRsp(DuProcMacUeResetRsp, pst, mBuf);
                      break;
                   }
+               case EVENT_MAC_STATISTICS_RSP:
+                  {
+                     ret = unpackDuMacStatsRsp(DuProcMacStatsRsp, pst, mBuf);
+                     break;
+                  }
                default:
                   {
                      DU_LOG("\nERROR  -->  DU_APP : Invalid event received at duActvTsk from ENTMAC");
index e29aa3b..38bc4b5 100644 (file)
@@ -2217,6 +2217,47 @@ 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)
+{
+   if(statsRsp)
+   {
+      if(statsRsp->rsp == MAC_DU_APP_RSP_OK)
+      {
+         DU_LOG("\nINFO  -->  DU_APP : Statistics configured successfully");
+         /* TODO : Start Reporting period timer for this subscription request
+          * To be handled in next gerrit */
+      }
+      else
+      {
+         DU_LOG("\nERROR  -->  DU_APP : Statistics configuration failed with cause [%d]", statsRsp->cause);
+      }
+      DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsRsp, sizeof(MacStatsRsp));
+      return ROK;
+   }
+
+   DU_LOG("\nINFO  -->  DU_APP : DuProcMacStatsRsp: Received NULL Pointer");
+   return RFAILED;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/