+/*******************************************************************
+ *
+ * @brief fill Slice Cfg Request info in shared structre
+ *
+ * @details
+ *
+ * Function : fillSliceCfgInfo
+ *
+ * Functionality:
+ * fill Slice Cfg Request info in shared structre
+ *
+ * @params[in] SchSliceCfgReq *schSliceCfgReq
+ * MacSliceCfgReq *macSliceCfgReq;
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ **********************************************************************/
+uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
+{
+ uint8_t rrmPolicyIdx= 0,cfgIdx = 0, memberListIdx = 0, totalSliceCfgRecvd = 0;
+
+ if(macSliceCfgReq->listOfRrmPolicy)
+ {
+ for(cfgIdx = 0; cfgIdx<macSliceCfgReq->numOfRrmPolicy; cfgIdx++)
+ {
+ totalSliceCfgRecvd += macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem;
+ }
+
+ schSliceCfgReq->numOfConfiguredSlice = totalSliceCfgRecvd;
+ MAC_ALLOC(schSliceCfgReq->listOfSlices, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
+ if(schSliceCfgReq->listOfSlices == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
+ return RFAILED;
+ }
+ cfgIdx = 0;
+
+ for(rrmPolicyIdx = 0; rrmPolicyIdx<macSliceCfgReq->numOfRrmPolicy; rrmPolicyIdx++)
+ {
+ for(memberListIdx = 0; memberListIdx<macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->numOfRrmPolicyMem; memberListIdx++)
+ {
+ if(macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->rRMPolicyMemberList[memberListIdx])
+ {
+
+ MAC_ALLOC(schSliceCfgReq->listOfSlices[cfgIdx], sizeof(SchRrmPolicyOfSlice));
+ if(schSliceCfgReq->listOfSlices[cfgIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
+ return RFAILED;
+ }
+
+ memcpy(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, &macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->rRMPolicyMemberList[memberListIdx]->snssai, sizeof(Snssai));
+
+ schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.maxRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.maxRatio;
+ schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.minRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.minRatio;
+ schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.dedicatedRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.dedicatedRatio;
+ cfgIdx++;
+ }
+ }
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes Slice Cfg Request recived from DU
+ *
+ * @details
+ *
+ * Function : MacProcSliceCfgReq
+ *
+ * Functionality:
+ * Processes Processes Slice Cfg Request recived from DU
+ *
+ * @params[in] Post Structure Pointer
+ * MacSliceCfgReq *macSliceCfgReq;
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ **********************************************************************/
+uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
+{
+ uint8_t ret = ROK;
+ Pst schPst;
+ SchSliceCfgReq *schSliceCfgReq;
+
+ DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
+ if(macSliceCfgReq)
+ {
+ MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
+ if(schSliceCfgReq == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
+ ret = RFAILED;
+ }
+ else
+ {
+ if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
+ {
+ FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
+ ret = SchMessageRouter(&schPst, (void *)schSliceCfgReq);
+ }
+ }
+ freeMacSliceCfgReq(macSliceCfgReq, pst);
+ }
+ else
+ {
+ DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes Slice ReCfg Request recived from DU
+ *
+ * @details
+ *
+ * Function : MacProcSliceRecfgReq
+ *
+ * Functionality:
+ * Processes Processes Slice ReCfg Request recived from DU
+ *
+ * @params[in] Post Structure Pointer
+ * MacSliceCfgReq *macSliceRecfgReq;
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ **********************************************************************/
+uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
+{
+ uint8_t ret = ROK;
+ Pst schPst;
+ SchSliceRecfgReq *schSliceRecfgReq;
+
+ DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
+ if(macSliceRecfgReq)
+ {
+ MAC_ALLOC(schSliceRecfgReq, sizeof(SchSliceRecfgReq));
+ if(schSliceRecfgReq == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceRecfgReq");
+ ret = RFAILED;
+ }
+ else
+ {
+ if(fillSliceCfgInfo(schSliceRecfgReq, macSliceRecfgReq) == ROK)
+ {
+ FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
+ ret = SchMessageRouter(&schPst, (void *)schSliceRecfgReq);
+ }
+ }
+ freeMacSliceCfgReq(macSliceRecfgReq, pst);
+ }
+ else
+ {
+ DU_LOG("\nINFO --> MAC : Received MacSliceRecfgReq is NULL");
+ }
+ 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)
+{
+ uint8_t statsIdx = 0;
+ 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;
+ }
+
+ macStatsInd->subscriptionId = schStatsInd->subscriptionId;
+ macStatsInd->groupId = schStatsInd->groupId;
+
+ for(statsIdx = 0; statsIdx < schStatsInd->numStats; statsIdx++)
+ {
+ switch(schStatsInd->measuredStatsList[statsIdx].type)
+ {
+ case SCH_DL_TOTAL_PRB_USAGE:
+ {
+ macStatsInd->measuredStatsList[statsIdx].type = MAC_DL_TOTAL_PRB_USAGE;
+ break;
+ }
+ case SCH_UL_TOTAL_PRB_USAGE:
+ {
+ macStatsInd->measuredStatsList[statsIdx].type = MAC_UL_TOTAL_PRB_USAGE;
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> MAC : MacProcSchStatsInd: Invalid measurement type [%d]", \
+ schStatsInd->measuredStatsList[statsIdx].type);
+ MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, macStatsInd, sizeof(MacStatsInd));
+ return RFAILED;
+ }
+ }
+ macStatsInd->measuredStatsList[statsIdx].value = schStatsInd->measuredStatsList[statsIdx].value;
+ }
+ macStatsInd->numStats = schStatsInd->numStats;
+
+ memset(&indPst, 0, sizeof(Pst));
+ FILL_PST_MAC_TO_DUAPP(indPst, EVENT_MAC_STATISTICS_IND);
+ return (*macDuStatsIndOpts[indPst.selector])(&indPst, macStatsInd);
+}