+/*******************************************************************
+ *
+ * @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 ueIdx = 0;
+ uint16_t cellIdx;
+ uint16_t idx;
+ DlRlcBoInfo dlBoInfo;
+ memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
+
+ DU_LOG("\nMAC : 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
+ dlBoInfo.dataVolume = dlCcchIndInfo->dlCcchMsgLen;
+
+ /* storing Msg4 Pdu in raCb */
+ GET_UE_IDX(dlBoInfo.crnti, ueIdx);
+ ueIdx = ueIdx -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("\nMAC: 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("\nMAC: 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
+ *
+ *
+ * ****************************************************************/
+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(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
+}
+
+/*******************************************************************
+ *
+ * @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, uint8_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(*macSchSrUciIndOpts[pst.selector])(&pst, &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;
+ uint8_t ret = ROK;
+ uint16_t nPdus;
+ uint16_t crnti;
+
+ if(macUciInd)
+ {
+ nPdus = macUciInd->numUcis;
+ while(nPdus)
+ {
+ switch(macUciInd->pdus[pduIdx].pduType)
+ {
+ case UCI_IND_PUSCH:
+ break;
+ case UCI_IND_PUCCH_F0F1:
+ if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
+ {
+ DU_LOG("\nMAC : 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("\nMAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
+ ret = RFAILED;
+ break;
+ }
+ pduIdx++;
+ nPdus--;
+ }
+ }
+ else
+ {
+ DU_LOG("\nMAC: Received Uci Ind is NULL at FapiMacUciInd()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+