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 /* Function pointer for sending crc ind from MAC to SCH */
42 MacSchCrcIndFunc macSchCrcIndOpts[]=
49 /* Function pointer for sending DL RLC BO Info from MAC to SCH */
50 MacSchDlRlcBoInfoFunc macSchDlRlcBoInfoOpts[]=
52 packMacSchDlRlcBoInfo,
57 /* Function pointer for sending short BSR from MAC to SCH */
58 MacSchBsrFunc macSchBsrOpts[]=
65 /* Function pointer for sending SR Uci ind from MAC to SCH */
66 MacSchSrUciIndFunc macSchSrUciIndOpts[]=
73 /* Function pointer for sending HARQ Uci ind from MAC to SCH */
74 MacSchHarqUciIndFunc macSchHarqUciIndOpts[]=
81 /* Function pointer for sending Slice cfg ind from MAC to SCH */
82 MacSchSliceCfgReqFunc macSchSliceCfgReqOpts[]=
84 packMacSchSliceCfgReq,
89 /* Function pointer for sending Slice cfg ind from MAC to SCH */
90 MacSchSliceReCfgReqFunc macSchSliceReCfgReqOpts[]=
92 packMacSchSliceReCfgReq,
94 packMacSchSliceReCfgReq
96 /*******************************************************************
98 * @brief Sends DL BO Info to SCH
102 * Function : sendDlRlcBoInfoToSch
105 * Sends DL BO Info to SCH
108 * @return ROK - success
111 ****************************************************************/
112 uint8_t sendDlRlcBoInfoToSch(DlRlcBoInfo *dlBoInfo)
116 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_RLC_BO_INFO_TO_SCH);
117 return(*macSchDlRlcBoInfoOpts[pst.selector])(&pst, dlBoInfo);
120 /*******************************************************************
122 * @brief Sends CRC Indication to SCH
126 * Function : sendCrcIndMacToSch
129 * Sends CRC Indication to SCH
132 * @return ROK - success
135 ****************************************************************/
136 uint8_t sendCrcIndMacToSch(CrcIndInfo *crcInd)
140 FILL_PST_MAC_TO_SCH(pst, EVENT_CRC_IND_TO_SCH);
141 return(*macSchCrcIndOpts[pst.selector])(&pst, crcInd);
144 /*******************************************************************
146 * @brief Processes CRC Indication from PHY
150 * Function : fapiMacCrcInd
153 * Processes CRC Indication from PHY
155 * @params[in] Post Structure Pointer
156 * Crc Indication Pointer
157 * @return ROK - success
160 * ****************************************************************/
161 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
164 CrcIndInfo crcIndInfo;
165 DU_LOG("\nDEBUG --> MAC : Received CRC indication");
166 GET_CELL_IDX(crcInd->cellId, cellIdx);
167 /* Considering one pdu and one preamble */
168 crcIndInfo.cellId = macCb.macCell[cellIdx]->cellId;
169 crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
170 crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
171 crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
172 crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
173 crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
175 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, crcInd, sizeof(CrcInd));
176 return(sendCrcIndMacToSch(&crcIndInfo));
179 /*******************************************************************
181 * @brief Process Rx Data Ind at MAC
185 * Function : fapiMacRxDataInd
188 * Process Rx Data Ind at MAC
190 * @params[in] Post structure
192 * @return ROK - success
195 * ****************************************************************/
196 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
199 uint16_t pduIdx, cellIdx = 0;
200 DU_LOG("\nDEBUG --> MAC : Received Rx Data indication");
201 /* TODO : compare the handle received in RxDataInd with handle send in PUSCH
202 * PDU, which is stored in raCb */
204 for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
207 GET_CELL_IDX(rxDataInd->cellId, cellIdx);
208 GET_UE_ID(rxDataInd->pdus[pduIdx].rnti, ueId);
210 if(macCb.macCell[cellIdx] && macCb.macCell[cellIdx]->ueCb[ueId -1].transmissionAction == STOP_TRANSMISSION)
212 DU_LOG("\nINFO --> MAC : UL data transmission not allowed for UE %d", macCb.macCell[cellIdx]->ueCb[ueId -1].ueId);
216 unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
218 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd->pdus[pduIdx].pduData,\
219 rxDataInd->pdus[pduIdx].pduLength);
221 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd, sizeof(RxDataInd));
225 /*******************************************************************
227 * @brief Processes DL data from RLC
231 * Function : MacProcRlcDlData
234 * Processes DL data from RLC
236 * @params[in] Post structure
238 * @return ROK - success
241 * ****************************************************************/
242 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
247 uint8_t *txPdu = NULLP;
248 uint8_t schInfoIdx = 0 ;
249 uint16_t cellIdx = 0, txPduLen = 0;
251 MacDlSlot *currDlSlot = NULLP;
252 DlRlcBoInfo dlBoInfo;
254 memset(&macDlData , 0, sizeof(MacDlData));
255 DU_LOG("\nDEBUG --> MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
256 dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
258 GET_UE_ID(dlData->rnti, ueId);
260 /* Copy the pdus to be muxed into mac Dl data */
261 macDlData.ueId = ueId;
262 macDlData.numPdu = dlData->numPdu;
263 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
265 macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
266 macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
267 macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
270 GET_CELL_IDX(dlData->cellId, cellIdx);
271 /* Store DL data in the scheduled slot */
272 if(macCb.macCell[cellIdx] ==NULLP)
274 DU_LOG("\nERROR --> MAC : MacProcRlcDlData(): macCell does not exists");
277 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
278 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
280 for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->numSchedInfo; schInfoIdx++)
282 if((currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
283 (currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
287 txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize\
288 - TX_PAYLOAD_HDR_LEN;
289 MAC_ALLOC(txPdu, txPduLen);
292 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData");
295 macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
297 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen = txPduLen;
298 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = txPdu;
299 /* Add muxed TB to DL HARQ Proc CB. This will be used if retranmission of
300 * TB is requested in future. */
301 updateNewTbInDlHqProcCb(dlData->slotInfo, &macCb.macCell[cellIdx]->ueCb[ueId -1], \
302 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize, txPdu);
305 for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
307 if(dlData->boStatus[lcIdx].bo)
309 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
310 dlBoInfo.cellId = dlData->boStatus[lcIdx].cellId;
311 GET_CRNTI(dlBoInfo.crnti, dlData->boStatus[lcIdx].ueId);
312 dlBoInfo.lcId = dlData->boStatus[lcIdx].lcId;
313 dlBoInfo.dataVolume = dlData->boStatus[lcIdx].bo;
314 sendDlRlcBoInfoToSch(&dlBoInfo);
319 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
321 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
322 dlData->pduInfo[pduIdx].pduLen);
324 if(pstInfo->selector == ODU_SELECTOR_LWLC)
326 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcData));
331 /*******************************************************************
333 * @brief Builds and Sends UL Data to RLC
337 * Function : macProcUlData
339 * Functionality: Builds and Sends UL Data to RLC
344 * LC Id on which payload was received
345 * Pointer to the payload
347 * @return ROK - success
350 * ****************************************************************/
351 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
352 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
357 /* Filling RLC Ul Data*/
358 MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcData));
361 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
364 memset(ulData, 0, sizeof(RlcData));
365 ulData->cellId = cellId;
367 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
368 ulData->slotInfo.cellId = cellId;
370 /* Filling pdu info */
371 if(lcId != SRB0_LCID)
372 ulData->pduInfo[ulData->numPdu].commCh = false;
374 ulData->pduInfo[ulData->numPdu].commCh = true;
376 ulData->pduInfo[ulData->numPdu].lcId = lcId;
377 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
378 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
381 /* Filling Post and send to RLC */
382 memset(&pst, 0, sizeof(Pst));
383 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
384 MacSendUlDataToRlc(&pst, ulData);
390 /*******************************************************************
392 * @brief Processes BO status from RLC
396 * Function : MacProcRlcBOStatus
399 * Processes BO status from RLC
401 * @params[in] Post structure
403 * @return ROK - success
406 * ****************************************************************/
407 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
409 DlRlcBoInfo dlBoInfo;
411 dlBoInfo.cellId = boStatus->cellId;
412 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
413 dlBoInfo.lcId = boStatus->lcId;
414 dlBoInfo.dataVolume = boStatus->bo;
416 sendDlRlcBoInfoToSch(&dlBoInfo);
418 if(pst->selector == ODU_SELECTOR_LWLC)
420 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
426 /*******************************************************************
428 * @brief Send LC schedule result report to RLC
432 * Function : sendSchRptToRlc
434 * Functionality: Send LC schedule result report to RLC
437 * @return ROK - success
440 * ****************************************************************/
441 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
445 RlcSchedResultRpt *schedRpt = NULLP;
447 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
450 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
454 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
455 schedRpt->cellId = dlInfo.cellId;
456 schedRpt->slotInfo.sfn = slotInfo.sfn;
457 schedRpt->slotInfo.slot = slotInfo.slot;
459 if(dlInfo.dlMsgAlloc[ueIdx])
461 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
462 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
463 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
465 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
466 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
467 schedRpt->lcSch[lcIdx].commCh = false;
472 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
473 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
475 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
476 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
483 /*******************************************************************
485 * @brief Handles cell start reuqest from DU APP
489 * Function : MacProcCellStart
492 * Handles cell start reuqest from DU APP
494 * @params[in] Post structure pointer
496 * @return ROK - success
499 * ****************************************************************/
500 uint8_t MacProcCellStart(Pst *pst, OduCellId *cellId)
502 DU_LOG("\nINFO --> MAC : Handling cell start request");
504 sendToLowerMac(START_REQUEST, 0, cellId);
506 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
512 /*******************************************************************
514 * @brief Handles cell stop from DU APP
518 * Function : MacProcCellStop
521 * Handles cell stop from DU APP
523 * @params[in] Post structure pointer
525 * @return ROK - success
528 * ****************************************************************/
529 uint8_t MacProcCellStop(Pst *pst, OduCellId *cellId)
534 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
535 GET_CELL_IDX(cellId->cellId, cellIdx);
536 if(macCb.macCell[cellIdx])
538 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
542 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
548 /*******************************************************************
550 * @brief Handles DL CCCH Ind from DU APP
554 * Function : MacProcDlCcchInd
557 * Handles DL CCCH Ind from DU APP
559 * @params[in] Post structure pointer
560 * DL CCCH Ind pointer
561 * @return ROK - success
564 * ****************************************************************/
565 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
567 uint8_t ueId = 0, ueIdx = 0;
570 DlRlcBoInfo dlBoInfo;
571 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
573 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
575 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
577 dlBoInfo.cellId = dlCcchIndInfo->cellId;
578 dlBoInfo.crnti = dlCcchIndInfo->crnti;
580 if(dlCcchIndInfo->msgType == RRC_SETUP)
582 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
583 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
584 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
586 /* storing Msg4 Pdu in raCb */
587 GET_UE_ID(dlBoInfo.crnti, ueId);
589 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
591 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
592 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
593 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
594 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
596 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
598 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
599 dlCcchIndInfo->dlCcchMsg[idx];
604 sendDlRlcBoInfoToSch(&dlBoInfo);
606 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
607 dlCcchIndInfo->dlCcchMsgLen);
608 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
613 /*******************************************************************
615 * @brief Sends UL CCCH Ind to DU APP
619 * Function : macProcUlCcchInd
622 * MAC sends UL CCCH Ind to DU APP
624 * @params[in] Post structure pointer
626 * @return ROK - success
629 * ****************************************************************/
630 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
634 UlCcchIndInfo *ulCcchIndInfo = NULLP;
636 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
639 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
643 ulCcchIndInfo->cellId = cellId;
644 ulCcchIndInfo->crnti = crnti;
645 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
646 ulCcchIndInfo->ulCcchMsg = rrcContainer;
649 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
651 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
653 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
654 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
655 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
661 /*******************************************************************
663 * @brief Processes received short BSR
667 * Function : macProcShortBsr
670 * MAC sends Short BSR to SCH
672 * @params[in] cell ID
677 * @return ROK - success
680 * ****************************************************************/
681 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
684 UlBufferStatusRptInd bsrInd;
686 memset(&pst, 0, sizeof(Pst));
687 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
689 bsrInd.cellId = cellId;
690 bsrInd.crnti = crnti;
691 bsrInd.bsrType = SHORT_BSR;
692 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
693 bsrInd.dataVolInfo[0].lcgId = lcgId;
694 bsrInd.dataVolInfo[0].dataVol = bufferSize;
696 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
697 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
700 /*******************************************************************
702 * @brief Processes received short BSR
706 * Function : macProcShortBsr
709 * MAC sends Short BSR to SCH
711 * @params[in] cell ID
716 * @return ROK - success
719 * ****************************************************************/
720 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
721 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
724 UlBufferStatusRptInd bsrInd;
727 memset(&pst, 0, sizeof(Pst));
728 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
730 bsrInd.cellId = cellId;
731 bsrInd.crnti = crnti;
732 bsrInd.bsrType = LONG_BSR;
733 bsrInd.numLcg = numLcg;
735 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
736 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
738 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
739 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
742 /*******************************************************************
744 * @brief Builds and send HARQ UCI Indication to SCH
748 * Function : buildAndSendHarqInd
751 * Builds and send HARQ UCI Indication to SCH
753 * @params[in] harqInfo Pointer
757 * @return ROK - success
760 * ****************************************************************/
761 uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
763 uint16_t harqCounter=0;
765 HarqUciIndInfo harqUciInd;
766 memset(&pst, 0, sizeof(Pst));
767 memset(&harqUciInd, 0, sizeof(HarqUciIndInfo));
769 harqUciInd.cellId = macCb.macCell[cellIdx]->cellId;
770 harqUciInd.crnti = crnti;
771 harqUciInd.slotInd.sfn = slotInd->sfn;
772 harqUciInd.slotInd.slot = slotInd->slot;
773 harqUciInd.numHarq = harqInfo->numHarq;
774 memset(harqUciInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
775 for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
777 harqUciInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
781 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
783 return(*macSchHarqUciIndOpts[pst.selector])(&pst, &harqUciInd);
787 /*******************************************************************
789 * @brief Builds and send SR UCI Indication to SCH
793 * Function : buildAndSendSrInd
796 * Builds and send SR UCI Indication to SCH
798 * @params[in] SrUciIndInfo Pointer
800 * @return ROK - success
803 * ****************************************************************/
804 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
808 SrUciIndInfo srUciInd;
809 memset(&pst, 0, sizeof(Pst));
810 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
812 GET_CELL_IDX(macUciInd->cellId, cellIdx);
813 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
814 srUciInd.crnti = crnti;
815 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
816 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
817 srUciInd.numSrBits++;
818 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
821 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
823 return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
826 /*******************************************************************
828 * @brief Processes UCI Indication from PHY
832 * Function : fapiMacUciInd
835 * Processes UCI Indication from PHY
837 * @params[in] Post Structure Pointer
838 * UCI Indication Pointer
839 * @return ROK - success
842 * ****************************************************************/
843 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
845 uint8_t pduIdx = 0, ret = ROK;
846 uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
850 nPdus = macUciInd->numUcis;
853 switch(macUciInd->pdus[pduIdx].pduType)
857 case UCI_IND_PUCCH_F0F1:
860 DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
861 GET_CELL_IDX(macUciInd->cellId, cellIdx);
862 buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
864 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
866 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
867 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
868 ret = buildAndSendSrInd(macUciInd, crnti);
872 case UCI_IND_PUCCH_F2F3F4:
875 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
885 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
888 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
892 /*******************************************************************
894 * @brief fill Slice Cfg Request info in shared structre
898 * Function : fillSliceCfgInfo
901 * fill Slice Cfg Request info in shared structre
903 * @params[in] SchSliceCfgReq *schSliceCfgReq
904 * MacSliceCfgReq *macSliceCfgReq;
905 * @return ROK - success
908 **********************************************************************/
909 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
913 if(macSliceCfgReq->listOfSliceCfg)
915 schSliceCfgReq->numOfConfiguredSlice = macSliceCfgReq->numOfConfiguredSlice;
916 MAC_ALLOC(schSliceCfgReq->listOfConfirguration, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
917 if(schSliceCfgReq->listOfConfirguration == NULLP)
919 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
922 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
924 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx], sizeof(SchRrmPolicyOfSlice));
925 if(schSliceCfgReq->listOfConfirguration[cfgIdx] == NULLP)
927 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
931 memcpy(&schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai, &macSliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, sizeof(Snssai));
933 if(macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio)
935 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo, sizeof(SchRrmPolicyRatio));
936 if(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo == NULLP)
938 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
941 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMaxRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio;
942 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMinRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio;
943 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyDedicatedRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio;
949 /*******************************************************************
951 * @brief Processes Slice Cfg Request recived from DU
955 * Function : MacProcSliceCfgReq
958 * Processes Processes Slice Cfg Request recived from DU
960 * @params[in] Post Structure Pointer
961 * MacSliceCfgReq *macSliceCfgReq;
962 * @return ROK - success
965 **********************************************************************/
966 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
970 SchSliceCfgReq *schSliceCfgReq;
972 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
975 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
976 if(schSliceCfgReq == NULLP)
978 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
983 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
985 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
986 ret = (*macSchSliceCfgReqOpts[schPst.selector])(&schPst, schSliceCfgReq);
989 freeMacSliceCfgReq(macSliceCfgReq, pst);
993 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
998 /*******************************************************************
1000 * @brief Processes Slice ReCfg Request recived from DU
1004 * Function : MacProcSliceReCfgReq
1007 * Processes Processes Slice ReCfg Request recived from DU
1009 * @params[in] Post Structure Pointer
1010 * MacSliceCfgReq *macSliceReCfgReq;
1011 * @return ROK - success
1014 **********************************************************************/
1015 uint8_t MacProcSliceReCfgReq(Pst *pst, MacSliceCfgReq *macSliceReCfgReq)
1019 SchSliceCfgReq *schSliceReCfgReq;
1021 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
1022 if(macSliceReCfgReq)
1024 MAC_ALLOC(schSliceReCfgReq, sizeof(SchSliceCfgReq));
1025 if(schSliceReCfgReq == NULLP)
1027 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceReCfgReq");
1032 if(fillSliceCfgInfo(schSliceReCfgReq, macSliceReCfgReq) == ROK)
1034 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
1035 ret = (*macSchSliceReCfgReqOpts[schPst.selector])(&schPst, schSliceReCfgReq);
1039 freeMacSliceCfgReq(macSliceReCfgReq, pst);
1043 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
1048 /**********************************************************************
1050 **********************************************************************/