1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* header include files -- defines (.h) */
20 #include "common_def.h"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "rlc_mac_inf.h"
26 #include "mac_upr_inf_api.h"
29 #include "fapi_interface.h"
31 #include "lwr_mac_fsm.h"
32 #include "lwr_mac_upr_inf.h"
34 #include "mac_utils.h"
35 #include "mac_harq_dl.h"
37 /* This file contains message handling functionality for MAC */
41 /*******************************************************************
43 * @brief Sends DL BO Info to SCH
47 * Function : sendDlRlcBoInfoToSch
50 * Sends DL BO Info to SCH
53 * @return ROK - success
56 ****************************************************************/
57 uint8_t sendDlRlcBoInfoToSch(DlRlcBoInfo *dlBoInfo)
61 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_RLC_BO_INFO_TO_SCH);
62 return(SchMessageRouter(&pst, (void *)dlBoInfo));
65 /*******************************************************************
67 * @brief Sends CRC Indication to SCH
71 * Function : sendCrcIndMacToSch
74 * Sends CRC Indication to SCH
77 * @return ROK - success
80 ****************************************************************/
81 uint8_t sendCrcIndMacToSch(CrcIndInfo *crcInd)
85 FILL_PST_MAC_TO_SCH(pst, EVENT_CRC_IND_TO_SCH);
86 return(SchMessageRouter(&pst, (void *)crcInd));
89 /*******************************************************************
91 * @brief Sends UL CQI Indication to SCH
95 * Function : sendUlCqiIndMacToSch
98 * Sends Ul Cqi Indication to SCH
101 * @return ROK - success
104 ****************************************************************/
105 uint8_t sendUlCqiIndMacToSch(SchUlCqiInd *ulCqiInd)
109 FILL_PST_MAC_TO_SCH(pst, EVENT_UL_CQI_TO_SCH);
110 return(SchMessageRouter(&pst, (void *)ulCqiInd));
113 /*******************************************************************
115 * @brief Sends DL CQI Indication to SCH
119 * Function : sendDlCqiIndMacToSch
122 * Sends Dl Cqi Indication to SCH
125 * @return ROK - success
128 ****************************************************************/
129 uint8_t sendDlCqiIndMacToSch(SchDlCqiInd *dlCqiInd)
133 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_CQI_TO_SCH);
134 return(SchMessageRouter(&pst, (void *)dlCqiInd));
137 /*******************************************************************
139 * @brief Sends Power Headroom Indication to SCH
143 * Function : sendPhrIndToSch
146 * Sends Phr Indication to SCH
149 * @return ROK - success
152 ****************************************************************/
153 uint8_t sendPhrIndToSch(SchPwrHeadroomInd *macPhrInd)
157 FILL_PST_MAC_TO_SCH(pst, EVENT_PHR_IND_TO_SCH);
158 return(SchMessageRouter(&pst, (void *)macPhrInd));
161 /*******************************************************************
163 * @brief Processes CRC Indication from PHY
167 * Function : fapiMacCrcInd
170 * Processes CRC Indication from PHY
172 * @params[in] Post Structure Pointer
173 * Crc Indication Pointer
174 * @return ROK - success
177 * ****************************************************************/
178 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
181 CrcIndInfo crcIndInfo;
182 DU_LOG("\nDEBUG --> MAC : Received CRC indication");
183 GET_CELL_IDX(crcInd->cellId, cellIdx);
184 /* Considering one pdu and one preamble */
185 crcIndInfo.cellId = macCb.macCell[cellIdx]->cellId;
186 crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
187 crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
188 crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
189 crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
190 crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
192 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, crcInd, sizeof(CrcInd));
193 return(sendCrcIndMacToSch(&crcIndInfo));
196 /*******************************************************************
198 * @brief Process Rx Data Ind at MAC
202 * Function : fapiMacRxDataInd
205 * Process Rx Data Ind at MAC
207 * @params[in] Post structure
209 * @return ROK - success
212 * ****************************************************************/
213 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
216 uint16_t pduIdx, cellIdx = 0;
217 DU_LOG("\nDEBUG --> MAC : Received Rx Data indication");
218 /* TODO : compare the handle received in RxDataInd with handle send in PUSCH
219 * PDU, which is stored in raCb */
221 for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
224 GET_CELL_IDX(rxDataInd->cellId, cellIdx);
225 GET_UE_ID(rxDataInd->pdus[pduIdx].rnti, ueId);
227 if(macCb.macCell[cellIdx] && macCb.macCell[cellIdx]->ueCb[ueId -1].transmissionAction == STOP_TRANSMISSION)
229 DU_LOG("\nINFO --> MAC : UL data transmission not allowed for UE %d", macCb.macCell[cellIdx]->ueCb[ueId -1].ueId);
233 unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
235 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd->pdus[pduIdx].pduData,\
236 rxDataInd->pdus[pduIdx].pduLength);
238 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd, sizeof(RxDataInd));
242 /*******************************************************************
244 * @brief Processes DL data from RLC
248 * Function : MacProcRlcDlData
251 * Processes DL data from RLC
253 * @params[in] Post structure
255 * @return ROK - success
258 * ****************************************************************/
259 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcDlData *dlData)
264 uint8_t *txPdu = NULLP;
265 uint16_t cellIdx = 0, txPduLen = 0;
267 MacDlSlot *currDlSlot = NULLP;
268 DlRlcBoInfo dlBoInfo;
270 memset(&macDlData , 0, sizeof(MacDlData));
271 DU_LOG("\nDEBUG --> MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
272 dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
274 GET_UE_ID(dlData->rnti, ueId);
276 /* Copy the pdus to be muxed into mac Dl data */
277 macDlData.ueId = ueId;
278 macDlData.numPdu = dlData->numPdu;
279 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
281 macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
282 macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
283 macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
286 GET_CELL_IDX(dlData->cellId, cellIdx);
287 /* Store DL data in the scheduled slot */
288 if(macCb.macCell[cellIdx] ==NULLP)
290 DU_LOG("\nERROR --> MAC : MacProcRlcDlData(): macCell does not exists");
293 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
294 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
296 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg)
298 txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg->codeword[0].tbSize\
299 - TX_PAYLOAD_HDR_LEN;
300 MAC_ALLOC(txPdu, txPduLen);
303 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData");
306 macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
308 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPduLen = txPduLen;
309 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdu = txPdu;
310 /* Add muxed TB to DL HARQ Proc CB. This will be used if retranmission of
311 * TB is requested in future. */
312 updateNewTbInDlHqProcCb(dlData->slotInfo, &macCb.macCell[cellIdx]->ueCb[ueId -1], \
313 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg->codeword[0].tbSize, txPdu);
317 for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
319 if(dlData->boStatus[lcIdx].bo)
321 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
322 dlBoInfo.cellId = dlData->boStatus[lcIdx].cellId;
323 GET_CRNTI(dlBoInfo.crnti, dlData->boStatus[lcIdx].ueId);
324 dlBoInfo.lcId = dlData->boStatus[lcIdx].lcId;
325 dlBoInfo.dataVolume = dlData->boStatus[lcIdx].bo;
326 sendDlRlcBoInfoToSch(&dlBoInfo);
331 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
333 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
334 dlData->pduInfo[pduIdx].pduLen);
336 if(pstInfo->selector == ODU_SELECTOR_LWLC)
338 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcDlData));
343 /*******************************************************************
345 * @brief Builds and Sends UL Data to RLC
349 * Function : macProcUlData
351 * Functionality: Builds and Sends UL Data to RLC
356 * LC Id on which payload was received
357 * Pointer to the payload
359 * @return ROK - success
362 * ****************************************************************/
363 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
364 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
369 /* Filling RLC Ul Data*/
370 MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcUlData));
373 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
376 memset(ulData, 0, sizeof(RlcUlData));
377 ulData->cellId = cellId;
379 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
380 ulData->slotInfo.cellId = cellId;
382 /* Filling pdu info */
383 ulData->pduInfo[ulData->numPdu].lcId = lcId;
384 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
385 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
388 /* Filling Post and send to RLC */
389 memset(&pst, 0, sizeof(Pst));
390 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
391 MacSendUlDataToRlc(&pst, ulData);
397 /*******************************************************************
399 * @brief Processes BO status from RLC
403 * Function : MacProcRlcBOStatus
406 * Processes BO status from RLC
408 * @params[in] Post structure
410 * @return ROK - success
413 * ****************************************************************/
414 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
416 DlRlcBoInfo dlBoInfo;
418 dlBoInfo.cellId = boStatus->cellId;
419 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
420 dlBoInfo.lcId = boStatus->lcId;
421 dlBoInfo.dataVolume = boStatus->bo;
423 sendDlRlcBoInfoToSch(&dlBoInfo);
425 if(pst->selector == ODU_SELECTOR_LWLC)
427 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
433 /*******************************************************************
435 * @brief Send LC schedule result report to RLC
439 * Function : sendSchRptToRlc
441 * Functionality: Send LC schedule result report to RLC
444 * @return ROK - success
447 * ****************************************************************/
448 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
452 RlcSchedResultRpt *schedRpt = NULLP;
454 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
457 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
461 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
462 schedRpt->cellId = dlInfo.cellId;
463 schedRpt->slotInfo.sfn = slotInfo.sfn;
464 schedRpt->slotInfo.slot = slotInfo.slot;
466 if(dlInfo.dlMsgAlloc[ueIdx])
468 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
469 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].numLc;
470 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
472 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].lcSchInfo[lcIdx].lcId;
473 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].lcSchInfo[lcIdx].schBytes;
478 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
479 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
481 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
482 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
489 /*******************************************************************
491 * @brief Handles cell start reuqest from DU APP
495 * Function : MacProcCellStart
498 * Handles cell start reuqest from DU APP
500 * @params[in] Post structure pointer
502 * @return ROK - success
505 * ****************************************************************/
506 uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStart)
508 DU_LOG("\nINFO --> MAC : Handling cell start request");
510 sendToLowerMac(START_REQUEST, 0, cellStart);
512 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStart, \
513 sizeof(CellStartInfo));
518 /*******************************************************************
520 * @brief Handles cell stop from DU APP
524 * Function : MacProcCellStop
527 * Handles cell stop from DU APP
529 * @params[in] Post structure pointer
531 * @return ROK - success
534 * ****************************************************************/
535 uint8_t MacProcCellStop(Pst *pst, CellStopInfo *cellStop)
540 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
541 GET_CELL_IDX(cellStop->cellId, cellIdx);
542 if(macCb.macCell[cellIdx])
544 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
548 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStop, \
549 sizeof(CellStopInfo));
554 /*******************************************************************
556 * @brief Handles DL CCCH Ind from DU APP
560 * Function : MacProcDlCcchInd
563 * Handles DL CCCH Ind from DU APP
565 * @params[in] Post structure pointer
566 * DL CCCH Ind pointer
567 * @return ROK - success
570 * ****************************************************************/
571 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
573 uint8_t ueId = 0, ueIdx = 0;
576 DlRlcBoInfo dlBoInfo;
577 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
579 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
581 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
583 dlBoInfo.cellId = dlCcchIndInfo->cellId;
584 dlBoInfo.crnti = dlCcchIndInfo->crnti;
586 if(dlCcchIndInfo->msgType == RRC_SETUP)
588 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
589 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
590 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
592 /* storing Msg4 Pdu in raCb */
593 GET_UE_ID(dlBoInfo.crnti, ueId);
595 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
597 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
598 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
599 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
600 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
602 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
604 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
605 dlCcchIndInfo->dlCcchMsg[idx];
610 sendDlRlcBoInfoToSch(&dlBoInfo);
612 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
613 dlCcchIndInfo->dlCcchMsgLen);
614 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
619 /*******************************************************************
621 * @brief Sends UL CCCH Ind to DU APP
625 * Function : macProcUlCcchInd
628 * MAC sends UL CCCH Ind to DU APP
630 * @params[in] Post structure pointer
632 * @return ROK - success
635 * ****************************************************************/
636 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
640 UlCcchIndInfo *ulCcchIndInfo = NULLP;
642 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
645 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
649 ulCcchIndInfo->cellId = cellId;
650 ulCcchIndInfo->crnti = crnti;
651 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
652 ulCcchIndInfo->ulCcchMsg = rrcContainer;
655 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
657 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
659 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
660 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
661 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
667 /*******************************************************************
669 * @brief Processes received short BSR
673 * Function : macProcShortBsr
676 * MAC sends Short BSR to SCH
678 * @params[in] cell ID
683 * @return ROK - success
686 * ****************************************************************/
687 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
690 UlBufferStatusRptInd bsrInd;
692 memset(&pst, 0, sizeof(Pst));
693 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
695 bsrInd.cellId = cellId;
696 bsrInd.crnti = crnti;
697 bsrInd.bsrType = SHORT_BSR;
698 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
699 bsrInd.dataVolInfo[0].lcgId = lcgId;
700 bsrInd.dataVolInfo[0].dataVol = bufferSize;
702 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
703 return(SchMessageRouter(&pst, (void *)&bsrInd));
706 /*******************************************************************
708 * @brief Processes received short BSR
712 * Function : macProcShortBsr
715 * MAC sends Short BSR to SCH
717 * @params[in] cell ID
722 * @return ROK - success
725 * ****************************************************************/
726 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
727 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
730 UlBufferStatusRptInd bsrInd;
733 memset(&pst, 0, sizeof(Pst));
734 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
736 bsrInd.cellId = cellId;
737 bsrInd.crnti = crnti;
738 bsrInd.bsrType = LONG_BSR;
739 bsrInd.numLcg = numLcg;
741 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
742 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
744 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
745 return(SchMessageRouter(&pst, (void *)&bsrInd));
748 /*******************************************************************
750 * @brief Builds and send DL HARQ Indication to SCH
754 * Function : buildAndSendHarqInd
757 * Builds and send HARQ UCI Indication to SCH
759 * @params[in] harqInfo Pointer
763 * @return ROK - success
766 * ****************************************************************/
767 uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
769 uint16_t harqCounter=0;
772 memset(&pst, 0, sizeof(Pst));
773 memset(&dlHarqInd, 0, sizeof(DlHarqInd));
775 dlHarqInd.cellId = macCb.macCell[cellIdx]->cellId;
776 dlHarqInd.crnti = crnti;
777 dlHarqInd.slotInd.sfn = slotInd->sfn;
778 dlHarqInd.slotInd.slot = slotInd->slot;
779 dlHarqInd.numHarq = harqInfo->numHarq;
780 memset(dlHarqInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
781 for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
783 dlHarqInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
787 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_HARQ_IND_TO_SCH);
789 return SchMessageRouter(&pst, (void *)&dlHarqInd);
793 /*******************************************************************
795 * @brief Builds and send SR UCI Indication to SCH
799 * Function : buildAndSendSrInd
802 * Builds and send SR UCI Indication to SCH
804 * @params[in] SrUciIndInfo Pointer
806 * @return ROK - success
809 * ****************************************************************/
810 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
814 SrUciIndInfo srUciInd;
815 memset(&pst, 0, sizeof(Pst));
816 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
818 GET_CELL_IDX(macUciInd->cellId, cellIdx);
819 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
820 srUciInd.crnti = crnti;
821 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
822 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
823 srUciInd.numSrBits++;
824 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
827 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
829 return(SchMessageRouter(&pst, (void *)&srUciInd));
832 /*******************************************************************
834 * @brief Processes UCI Indication from PHY
838 * Function : fapiMacUciInd
841 * Processes UCI Indication from PHY
843 * @params[in] Post Structure Pointer
844 * UCI Indication Pointer
845 * @return ROK - success
848 * ****************************************************************/
849 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
851 uint8_t pduIdx = 0, ret = ROK;
852 uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
856 nPdus = macUciInd->numUcis;
859 switch(macUciInd->pdus[pduIdx].pduType)
863 case UCI_IND_PUCCH_F0F1:
866 DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
867 GET_CELL_IDX(macUciInd->cellId, cellIdx);
868 buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
870 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
872 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
873 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
874 ret = buildAndSendSrInd(macUciInd, crnti);
878 case UCI_IND_PUCCH_F2F3F4:
881 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
891 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
894 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
898 /*******************************************************************
900 * @brief fill Slice Cfg Request info in shared structre
904 * Function : fillSliceCfgInfo
907 * fill Slice Cfg Request info in shared structre
909 * @params[in] SchSliceCfgReq *schSliceCfgReq
910 * MacSliceCfgReq *macSliceCfgReq;
911 * @return ROK - success
914 **********************************************************************/
915 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
917 uint8_t rrmPolicyIdx= 0,cfgIdx = 0, memberListIdx = 0, totalSliceCfgRecvd = 0;
919 if(macSliceCfgReq->listOfRrmPolicy)
921 for(cfgIdx = 0; cfgIdx<macSliceCfgReq->numOfRrmPolicy; cfgIdx++)
923 totalSliceCfgRecvd += macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem;
926 schSliceCfgReq->numOfConfiguredSlice = totalSliceCfgRecvd;
927 MAC_ALLOC(schSliceCfgReq->listOfSlices, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
928 if(schSliceCfgReq->listOfSlices == NULLP)
930 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
935 for(rrmPolicyIdx = 0; rrmPolicyIdx<macSliceCfgReq->numOfRrmPolicy; rrmPolicyIdx++)
937 for(memberListIdx = 0; memberListIdx<macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->numOfRrmPolicyMem; memberListIdx++)
939 if(macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->rRMPolicyMemberList[memberListIdx])
942 MAC_ALLOC(schSliceCfgReq->listOfSlices[cfgIdx], sizeof(SchRrmPolicyOfSlice));
943 if(schSliceCfgReq->listOfSlices[cfgIdx] == NULLP)
945 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
949 memcpy(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, &macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->rRMPolicyMemberList[memberListIdx]->snssai, sizeof(Snssai));
951 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.maxRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.maxRatio;
952 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.minRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.minRatio;
953 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.dedicatedRatio = macSliceCfgReq->listOfRrmPolicy[rrmPolicyIdx]->policyRatio.dedicatedRatio;
962 /*******************************************************************
964 * @brief Processes Slice Cfg Request recived from DU
968 * Function : MacProcSliceCfgReq
971 * Processes Processes Slice Cfg Request recived from DU
973 * @params[in] Post Structure Pointer
974 * MacSliceCfgReq *macSliceCfgReq;
975 * @return ROK - success
978 **********************************************************************/
979 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
983 SchSliceCfgReq *schSliceCfgReq;
985 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
988 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
989 if(schSliceCfgReq == NULLP)
991 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
996 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
998 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
999 ret = SchMessageRouter(&schPst, (void *)schSliceCfgReq);
1002 freeMacSliceCfgReq(macSliceCfgReq, pst);
1006 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
1011 /*******************************************************************
1013 * @brief Processes Slice ReCfg Request recived from DU
1017 * Function : MacProcSliceRecfgReq
1020 * Processes Processes Slice ReCfg Request recived from DU
1022 * @params[in] Post Structure Pointer
1023 * MacSliceCfgReq *macSliceRecfgReq;
1024 * @return ROK - success
1027 **********************************************************************/
1028 uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
1032 SchSliceRecfgReq *schSliceRecfgReq;
1034 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
1035 if(macSliceRecfgReq)
1037 MAC_ALLOC(schSliceRecfgReq, sizeof(SchSliceRecfgReq));
1038 if(schSliceRecfgReq == NULLP)
1040 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceRecfgReq");
1045 if(fillSliceCfgInfo(schSliceRecfgReq, macSliceRecfgReq) == ROK)
1047 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
1048 ret = SchMessageRouter(&schPst, (void *)schSliceRecfgReq);
1051 freeMacSliceCfgReq(macSliceRecfgReq, pst);
1055 DU_LOG("\nINFO --> MAC : Received MacSliceRecfgReq is NULL");
1060 /**********************************************************************
1062 **********************************************************************/