+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles DL CCCH Ind from DU APP
+ *
+ * @details
+ *
+ * Function : MacProcDlCcchInd
+ *
+ * Functionality:
+ * Handles DL CCCH Ind from DU APP
+ *
+ * @params[in] Post structure pointer
+ * DL CCCH Ind pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
+{
+ uint8_t ueId = 0, ueIdx = 0;
+ uint16_t cellIdx;
+ uint16_t idx;
+ DlRlcBoInfo dlBoInfo;
+ memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
+
+ DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
+
+ GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
+
+ dlBoInfo.cellId = dlCcchIndInfo->cellId;
+ dlBoInfo.crnti = dlCcchIndInfo->crnti;
+
+ if(dlCcchIndInfo->msgType == RRC_SETUP)
+ {
+ dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
+ /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
+ dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
+
+ /* storing Msg4 Pdu in raCb */
+ GET_UE_ID(dlBoInfo.crnti, ueId);
+ ueIdx = ueId -1;
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
+ {
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
+ MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
+ {
+ for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
+ {
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
+ dlCcchIndInfo->dlCcchMsg[idx];
+ }
+ }
+ }
+ }
+ sendDlRlcBoInfoToSch(&dlBoInfo);
+
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
+ dlCcchIndInfo->dlCcchMsgLen);
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
+ return ROK;
+
+}
+
+/*******************************************************************
+ *
+ * @brief Sends UL CCCH Ind to DU APP
+ *
+ * @details
+ *
+ * Function : macProcUlCcchInd
+ *
+ * Functionality:
+ * MAC sends UL CCCH Ind to DU APP
+ *
+ * @params[in] Post structure pointer
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
+{
+ Pst pst;
+ uint8_t ret = ROK;
+ UlCcchIndInfo *ulCcchIndInfo = NULLP;
+
+ MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
+ if(!ulCcchIndInfo)
+ {
+ DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
+ return RFAILED;
+ }
+
+ ulCcchIndInfo->cellId = cellId;
+ ulCcchIndInfo->crnti = crnti;
+ ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
+ ulCcchIndInfo->ulCcchMsg = rrcContainer;
+
+ /* Fill Pst */
+ FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
+
+ if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
+ MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
+ MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @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;