From: lal.harshita Date: Fri, 1 Sep 2023 08:56:31 +0000 (+0530) Subject: [Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] Statistics Indication between DU APP... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=904a5d446b480d71da1bf81f892bab86ab365ce6;p=o-du%2Fl2.git [Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-523] Statistics Indication between DU APP and MAC/SCH Change-Id: I08e3e45b7a51243a8649f306a8c2c088b7e605a4 Signed-off-by: lal.harshita --- diff --git a/build/odu/makefile b/build/odu/makefile index 45b291f3d..515444826 100644 --- a/build/odu/makefile +++ b/build/odu/makefile @@ -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 diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index 756e288e8..a24535823 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -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 diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index b0779d95b..f5e6649ff 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -38,6 +38,14 @@ 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 **********************************************************************/ diff --git a/src/5gnrmac/mac_msg_router.c b/src/5gnrmac/mac_msg_router.c index a00eac7a1..37f07ae6e 100755 --- a/src/5gnrmac/mac_msg_router.c +++ b/src/5gnrmac/mac_msg_router.c @@ -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; diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 8e90431a2..397e8621a 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -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 **********************************************************************/ diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index 537ed318b..38d006329 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -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 diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 5051095ef..643ee657c 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -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; } diff --git a/src/5gnrsch/sch_tmr.c b/src/5gnrsch/sch_tmr.c index d88b1421f..fa716742e 100644 --- a/src/5gnrsch/sch_tmr.c +++ b/src/5gnrsch/sch_tmr.c @@ -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: diff --git a/src/cm/du_app_mac_inf.c b/src/cm/du_app_mac_inf.c index 3289cc780..52ea9dc02 100644 --- a/src/cm/du_app_mac_inf.c +++ b/src/cm/du_app_mac_inf.c @@ -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 **********************************************************************/ diff --git a/src/cm/du_app_mac_inf.h b/src/cm/du_app_mac_inf.h index c0cb0dc80..4b2f98ece 100644 --- a/src/cm/du_app_mac_inf.h +++ b/src/cm/du_app_mac_inf.h @@ -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 diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 781973f4a..58f894a01 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -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); diff --git a/src/du_app/du_mgr_msg_router.c b/src/du_app/du_mgr_msg_router.c index c077fe0ad..5acda22e9 100644 --- a/src/du_app/du_mgr_msg_router.c +++ b/src/du_app/du_mgr_msg_router.c @@ -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"); diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index 38bc4b531..ca5c9e5f3 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -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 **********************************************************************/