+/*******************************************************************
+ *
+ * @brief Processes received short BSR
+ *
+ * @details
+ *
+ * Function : macProcShortBsr
+ *
+ * Functionality:
+ * MAC sends Short BSR to SCH
+ *
+ * @params[in] cell ID
+ * crnti
+ * lcg ID
+ * buffer size
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
+{
+ Pst pst;
+ UlBufferStatusRptInd bsrInd;
+
+ memset(&pst, 0, sizeof(Pst));
+ memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
+
+ bsrInd.cellId = cellId;
+ bsrInd.crnti = crnti;
+ bsrInd.bsrType = SHORT_BSR;
+ bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
+ bsrInd.dataVolInfo[0].lcgId = lcgId;
+ bsrInd.dataVolInfo[0].dataVol = bufferSize;
+
+ FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
+ return(SchMessageRouter(&pst, (void *)&bsrInd));
+}
+
+/*******************************************************************
+ *
+ * @brief Processes received short BSR
+ *
+ * @details
+ *
+ * Function : macProcShortBsr
+ *
+ * Functionality:
+ * MAC sends Short BSR to SCH
+ *
+ * @params[in] cell ID
+ * crnti
+ * lcg ID
+ * buffer size
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
+ DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
+{
+ Pst pst;
+ UlBufferStatusRptInd bsrInd;
+ uint8_t lcgIdx = 0;
+
+ memset(&pst, 0, sizeof(Pst));
+ memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
+
+ bsrInd.cellId = cellId;
+ bsrInd.crnti = crnti;
+ bsrInd.bsrType = LONG_BSR;
+ bsrInd.numLcg = numLcg;
+
+ for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
+ memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
+
+ FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
+ return(SchMessageRouter(&pst, (void *)&bsrInd));
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and send DL HARQ Indication to SCH
+ *
+ * @details
+ *
+ * Function : buildAndSendHarqInd
+ *
+ * Functionality:
+ * Builds and send HARQ UCI Indication to SCH
+ *
+ * @params[in] harqInfo Pointer
+ * crnti value
+ * cell Index value
+ * slot Ind Pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint16_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
+{
+ uint16_t harqCounter=0;
+ Pst pst;
+ DlHarqInd dlHarqInd;
+ memset(&pst, 0, sizeof(Pst));
+ memset(&dlHarqInd, 0, sizeof(DlHarqInd));
+
+ dlHarqInd.cellId = macCb.macCell[cellIdx]->cellId;
+ dlHarqInd.crnti = crnti;
+ dlHarqInd.slotInd.sfn = slotInd->sfn;
+ dlHarqInd.slotInd.slot = slotInd->slot;
+ dlHarqInd.numHarq = harqInfo->numHarq;
+ memset(dlHarqInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
+ for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
+ {
+ dlHarqInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
+ }
+
+ /* Fill Pst */
+ FILL_PST_MAC_TO_SCH(pst, EVENT_DL_HARQ_IND_TO_SCH);
+
+ return SchMessageRouter(&pst, (void *)&dlHarqInd);
+}
+
+
+/*******************************************************************
+ *
+ * @brief Builds and send SR UCI Indication to SCH
+ *
+ * @details
+ *
+ * Function : buildAndSendSrInd
+ *
+ * Functionality:
+ * Builds and send SR UCI Indication to SCH
+ *
+ * @params[in] SrUciIndInfo Pointer
+ * crnti value
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t buildAndSendSrInd(UciInd *macUciInd, uint16_t crnti)
+{
+ uint16_t cellIdx;
+ Pst pst;
+ SrUciIndInfo srUciInd;
+ memset(&pst, 0, sizeof(Pst));
+ memset(&srUciInd, 0, sizeof(SrUciIndInfo));
+
+ GET_CELL_IDX(macUciInd->cellId, cellIdx);
+ srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
+ srUciInd.crnti = crnti;
+ srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
+ srUciInd.slotInd.slot = macUciInd->slotInd.slot;
+ srUciInd.numSrBits++;
+ memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
+
+ /* Fill Pst */
+ FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
+
+ return(SchMessageRouter(&pst, (void *)&srUciInd));
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UCI Indication from PHY
+ *
+ * @details
+ *
+ * Function : fapiMacUciInd
+ *
+ * Functionality:
+ * Processes UCI Indication from PHY
+ *
+ * @params[in] Post Structure Pointer
+ * UCI Indication Pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
+{
+ uint8_t pduIdx = 0, ret = ROK;
+ uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
+
+ if(macUciInd)
+ {
+ nPdus = macUciInd->numUcis;
+ while(nPdus)
+ {
+ switch(macUciInd->pdus[pduIdx].pduType)
+ {
+ case UCI_IND_PUSCH:
+ break;
+ case UCI_IND_PUCCH_F0F1:
+ {
+ {
+ DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
+ GET_CELL_IDX(macUciInd->cellId, cellIdx);
+ buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
+ }
+ if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
+ {
+ DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
+ crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
+ ret = buildAndSendSrInd(macUciInd, crnti);
+ }
+ }
+ break;
+ case UCI_IND_PUCCH_F2F3F4:
+ break;
+ default:
+ DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
+ ret = RFAILED;
+ break;
+ }
+ pduIdx++;
+ nPdus--;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
+ ret = RFAILED;
+ }
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @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);
+}
+