X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_cfg_hdl.c;h=589f73029201faec7cd5d445bc4cade098899180;hb=refs%2Fchanges%2F82%2F11782%2F4;hp=fee5f4f77b54f112e14efba3c2a347239d10d4c5;hpb=47a15faec02b721d3e466815eb388fea0a209e3c;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_cfg_hdl.c b/src/5gnrmac/mac_cfg_hdl.c index fee5f4f77..589f73029 100644 --- a/src/5gnrmac/mac_cfg_hdl.c +++ b/src/5gnrmac/mac_cfg_hdl.c @@ -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 * @@ -1014,6 +1022,186 @@ 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 + * + * @details + * + * Function : MacProcStatsReq + * + * This function process the statistics request from duapp + * + * @param[in] Pst *pst + * @param[in] StatsReq *statsReq + * @return int + * -# ROK + **/ +uint8_t MacProcStatsReq(Pst *pst, MacStatsReq *macStatsReq) +{ + uint8_t macStatsIdx = 0, schStatsIdx = 0; + uint8_t ret = RFAILED; + bool measTypeInvalid = false; + Pst schPst; + SchStatsReq *schStatsReq = NULLP; + CauseOfResult cause; + + if(macStatsReq) + { + DU_LOG("\nINFO --> MAC : Received Statistics Request from DU_APP"); + + MAC_ALLOC(schStatsReq, sizeof(SchStatsReq)); + if(schStatsReq == NULLP) + { + DU_LOG("\nERROR --> MAC : MacProcStatsReq: Failed to allocate memory"); + cause = RESOURCE_UNAVAILABLE; + } + else + { + schStatsReq->numStats = 0; + for(macStatsIdx=0; macStatsIdx < macStatsReq->numStats; macStatsIdx++) + { + /* Checking each measurement type to send only SCH related + * measurement config to SCH + * This will be useful in future when some measurement type will + * be configured for SCH and rest for only MAC */ + switch(macStatsReq->statsList[macStatsIdx].type) + { + case MAC_DL_TOTAL_PRB_USAGE: + { + schStatsReq->statsList[schStatsIdx].type = SCH_DL_TOTAL_PRB_USAGE; + break; + } + case MAC_UL_TOTAL_PRB_USAGE: + { + schStatsReq->statsList[schStatsIdx].type = SCH_UL_TOTAL_PRB_USAGE; + break; + } + default: + { + DU_LOG("\nERROR --> MAC : MacProcStatsReq: Invalid measurement type [%d]", \ + macStatsReq->statsList[macStatsIdx].type); + measTypeInvalid = true; + } + } + + if(!measTypeInvalid) + { + schStatsReq->statsList[schStatsIdx].periodicity = macStatsReq->statsList[macStatsIdx].periodicity; + schStatsIdx++; + measTypeInvalid = false; + } + } + schStatsReq->numStats = schStatsIdx; + + /* If no measurement types are valid, it is failure scenario. + * Even if one measurement type is valid, send to SCH */ + if(schStatsReq->numStats) + { + FILL_PST_MAC_TO_SCH(schPst, EVENT_STATISTICS_REQ_TO_SCH); + ret = SchMessageRouter(&schPst, (void *)schStatsReq); + } + else + { + cause = PARAM_INVALID; + } + } + MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macStatsReq, sizeof(MacStatsReq)); + } + else + { + DU_LOG("\nERROR --> MAC : MacProcStatsReq(): Received Null pointer"); + cause = PARAM_INVALID; + } + + if(ret == RFAILED) + { + 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; +} + /********************************************************************** End of file **********************************************************************/