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 Processes CRC Indication from PHY
95 * Function : fapiMacCrcInd
98 * Processes CRC Indication from PHY
100 * @params[in] Post Structure Pointer
101 * Crc Indication Pointer
102 * @return ROK - success
105 * ****************************************************************/
106 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
109 CrcIndInfo crcIndInfo;
110 DU_LOG("\nDEBUG --> MAC : Received CRC indication");
111 GET_CELL_IDX(crcInd->cellId, cellIdx);
112 /* Considering one pdu and one preamble */
113 crcIndInfo.cellId = macCb.macCell[cellIdx]->cellId;
114 crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
115 crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
116 crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
117 crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
118 crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
120 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, crcInd, sizeof(CrcInd));
121 return(sendCrcIndMacToSch(&crcIndInfo));
124 /*******************************************************************
126 * @brief Process Rx Data Ind at MAC
130 * Function : fapiMacRxDataInd
133 * Process Rx Data Ind at MAC
135 * @params[in] Post structure
137 * @return ROK - success
140 * ****************************************************************/
141 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
144 uint16_t pduIdx, cellIdx = 0;
145 DU_LOG("\nDEBUG --> MAC : Received Rx Data indication");
146 /* TODO : compare the handle received in RxDataInd with handle send in PUSCH
147 * PDU, which is stored in raCb */
149 for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
152 GET_CELL_IDX(rxDataInd->cellId, cellIdx);
153 GET_UE_ID(rxDataInd->pdus[pduIdx].rnti, ueId);
155 if(macCb.macCell[cellIdx] && macCb.macCell[cellIdx]->ueCb[ueId -1].transmissionAction == STOP_TRANSMISSION)
157 DU_LOG("\nINFO --> MAC : UL data transmission not allowed for UE %d", macCb.macCell[cellIdx]->ueCb[ueId -1].ueId);
161 unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
163 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd->pdus[pduIdx].pduData,\
164 rxDataInd->pdus[pduIdx].pduLength);
166 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd, sizeof(RxDataInd));
170 /*******************************************************************
172 * @brief Processes DL data from RLC
176 * Function : MacProcRlcDlData
179 * Processes DL data from RLC
181 * @params[in] Post structure
183 * @return ROK - success
186 * ****************************************************************/
187 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcDlData *dlData)
192 uint8_t *txPdu = NULLP;
193 uint8_t schInfoIdx = 0 ;
194 uint16_t cellIdx = 0, txPduLen = 0;
196 MacDlSlot *currDlSlot = NULLP;
197 DlRlcBoInfo dlBoInfo;
199 memset(&macDlData , 0, sizeof(MacDlData));
200 DU_LOG("\nDEBUG --> MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
201 dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
203 GET_UE_ID(dlData->rnti, ueId);
205 /* Copy the pdus to be muxed into mac Dl data */
206 macDlData.ueId = ueId;
207 macDlData.numPdu = dlData->numPdu;
208 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
210 macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
211 macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
212 macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
215 GET_CELL_IDX(dlData->cellId, cellIdx);
216 /* Store DL data in the scheduled slot */
217 if(macCb.macCell[cellIdx] ==NULLP)
219 DU_LOG("\nERROR --> MAC : MacProcRlcDlData(): macCell does not exists");
222 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
223 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
225 for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->numSchedInfo; schInfoIdx++)
227 if((currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
228 (currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
232 txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize\
233 - TX_PAYLOAD_HDR_LEN;
234 MAC_ALLOC(txPdu, txPduLen);
237 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData");
240 macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
242 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen = txPduLen;
243 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = txPdu;
244 /* Add muxed TB to DL HARQ Proc CB. This will be used if retranmission of
245 * TB is requested in future. */
246 updateNewTbInDlHqProcCb(dlData->slotInfo, &macCb.macCell[cellIdx]->ueCb[ueId -1], \
247 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize, txPdu);
250 for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
252 if(dlData->boStatus[lcIdx].bo)
254 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
255 dlBoInfo.cellId = dlData->boStatus[lcIdx].cellId;
256 GET_CRNTI(dlBoInfo.crnti, dlData->boStatus[lcIdx].ueId);
257 dlBoInfo.lcId = dlData->boStatus[lcIdx].lcId;
258 dlBoInfo.dataVolume = dlData->boStatus[lcIdx].bo;
259 sendDlRlcBoInfoToSch(&dlBoInfo);
264 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
266 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
267 dlData->pduInfo[pduIdx].pduLen);
269 if(pstInfo->selector == ODU_SELECTOR_LWLC)
271 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcDlData));
276 /*******************************************************************
278 * @brief Builds and Sends UL Data to RLC
282 * Function : macProcUlData
284 * Functionality: Builds and Sends UL Data to RLC
289 * LC Id on which payload was received
290 * Pointer to the payload
292 * @return ROK - success
295 * ****************************************************************/
296 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
297 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
302 /* Filling RLC Ul Data*/
303 MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcUlData));
306 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
309 memset(ulData, 0, sizeof(RlcUlData));
310 ulData->cellId = cellId;
312 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
313 ulData->slotInfo.cellId = cellId;
315 /* Filling pdu info */
316 ulData->pduInfo[ulData->numPdu].lcId = lcId;
317 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
318 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
321 /* Filling Post and send to RLC */
322 memset(&pst, 0, sizeof(Pst));
323 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
324 MacSendUlDataToRlc(&pst, ulData);
330 /*******************************************************************
332 * @brief Processes BO status from RLC
336 * Function : MacProcRlcBOStatus
339 * Processes BO status from RLC
341 * @params[in] Post structure
343 * @return ROK - success
346 * ****************************************************************/
347 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
349 DlRlcBoInfo dlBoInfo;
351 dlBoInfo.cellId = boStatus->cellId;
352 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
353 dlBoInfo.lcId = boStatus->lcId;
354 dlBoInfo.dataVolume = boStatus->bo;
356 sendDlRlcBoInfoToSch(&dlBoInfo);
358 if(pst->selector == ODU_SELECTOR_LWLC)
360 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
366 /*******************************************************************
368 * @brief Send LC schedule result report to RLC
372 * Function : sendSchRptToRlc
374 * Functionality: Send LC schedule result report to RLC
377 * @return ROK - success
380 * ****************************************************************/
381 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
385 RlcSchedResultRpt *schedRpt = NULLP;
387 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
390 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
394 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
395 schedRpt->cellId = dlInfo.cellId;
396 schedRpt->slotInfo.sfn = slotInfo.sfn;
397 schedRpt->slotInfo.slot = slotInfo.slot;
399 if(dlInfo.dlMsgAlloc[ueIdx])
401 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
402 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
403 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
405 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
406 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
411 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
412 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
414 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
415 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
422 /*******************************************************************
424 * @brief Handles cell start reuqest from DU APP
428 * Function : MacProcCellStart
431 * Handles cell start reuqest from DU APP
433 * @params[in] Post structure pointer
435 * @return ROK - success
438 * ****************************************************************/
439 uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStart)
441 DU_LOG("\nINFO --> MAC : Handling cell start request");
443 sendToLowerMac(START_REQUEST, 0, cellStart);
445 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStart, \
446 sizeof(CellStartInfo));
451 /*******************************************************************
453 * @brief Handles cell stop from DU APP
457 * Function : MacProcCellStop
460 * Handles cell stop from DU APP
462 * @params[in] Post structure pointer
464 * @return ROK - success
467 * ****************************************************************/
468 uint8_t MacProcCellStop(Pst *pst, CellStopInfo *cellStop)
473 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
474 GET_CELL_IDX(cellStop->cellId, cellIdx);
475 if(macCb.macCell[cellIdx])
477 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
481 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStop, \
482 sizeof(CellStopInfo));
487 /*******************************************************************
489 * @brief Handles DL CCCH Ind from DU APP
493 * Function : MacProcDlCcchInd
496 * Handles DL CCCH Ind from DU APP
498 * @params[in] Post structure pointer
499 * DL CCCH Ind pointer
500 * @return ROK - success
503 * ****************************************************************/
504 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
506 uint8_t ueId = 0, ueIdx = 0;
509 DlRlcBoInfo dlBoInfo;
510 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
512 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
514 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
516 dlBoInfo.cellId = dlCcchIndInfo->cellId;
517 dlBoInfo.crnti = dlCcchIndInfo->crnti;
519 if(dlCcchIndInfo->msgType == RRC_SETUP)
521 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
522 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
523 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
525 /* storing Msg4 Pdu in raCb */
526 GET_UE_ID(dlBoInfo.crnti, ueId);
528 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
530 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
531 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
532 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
533 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
535 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
537 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
538 dlCcchIndInfo->dlCcchMsg[idx];
543 sendDlRlcBoInfoToSch(&dlBoInfo);
545 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
546 dlCcchIndInfo->dlCcchMsgLen);
547 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
552 /*******************************************************************
554 * @brief Sends UL CCCH Ind to DU APP
558 * Function : macProcUlCcchInd
561 * MAC sends UL CCCH Ind to DU APP
563 * @params[in] Post structure pointer
565 * @return ROK - success
568 * ****************************************************************/
569 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
573 UlCcchIndInfo *ulCcchIndInfo = NULLP;
575 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
578 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
582 ulCcchIndInfo->cellId = cellId;
583 ulCcchIndInfo->crnti = crnti;
584 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
585 ulCcchIndInfo->ulCcchMsg = rrcContainer;
588 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
590 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
592 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
593 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
594 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
600 /*******************************************************************
602 * @brief Processes received short BSR
606 * Function : macProcShortBsr
609 * MAC sends Short BSR to SCH
611 * @params[in] cell ID
616 * @return ROK - success
619 * ****************************************************************/
620 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
623 UlBufferStatusRptInd bsrInd;
625 memset(&pst, 0, sizeof(Pst));
626 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
628 bsrInd.cellId = cellId;
629 bsrInd.crnti = crnti;
630 bsrInd.bsrType = SHORT_BSR;
631 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
632 bsrInd.dataVolInfo[0].lcgId = lcgId;
633 bsrInd.dataVolInfo[0].dataVol = bufferSize;
635 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
636 return(SchMessageRouter(&pst, (void *)&bsrInd));
639 /*******************************************************************
641 * @brief Processes received short BSR
645 * Function : macProcShortBsr
648 * MAC sends Short BSR to SCH
650 * @params[in] cell ID
655 * @return ROK - success
658 * ****************************************************************/
659 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
660 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
663 UlBufferStatusRptInd bsrInd;
666 memset(&pst, 0, sizeof(Pst));
667 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
669 bsrInd.cellId = cellId;
670 bsrInd.crnti = crnti;
671 bsrInd.bsrType = LONG_BSR;
672 bsrInd.numLcg = numLcg;
674 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
675 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
677 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
678 return(SchMessageRouter(&pst, (void *)&bsrInd));
681 /*******************************************************************
683 * @brief Builds and send DL HARQ Indication to SCH
687 * Function : buildAndSendHarqInd
690 * Builds and send HARQ UCI Indication to SCH
692 * @params[in] harqInfo Pointer
696 * @return ROK - success
699 * ****************************************************************/
700 uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
702 uint16_t harqCounter=0;
705 memset(&pst, 0, sizeof(Pst));
706 memset(&dlHarqInd, 0, sizeof(DlHarqInd));
708 dlHarqInd.cellId = macCb.macCell[cellIdx]->cellId;
709 dlHarqInd.crnti = crnti;
710 dlHarqInd.slotInd.sfn = slotInd->sfn;
711 dlHarqInd.slotInd.slot = slotInd->slot;
712 dlHarqInd.numHarq = harqInfo->numHarq;
713 memset(dlHarqInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
714 for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
716 dlHarqInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
720 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_HARQ_IND_TO_SCH);
722 return SchMessageRouter(&pst, (void *)&dlHarqInd);
726 /*******************************************************************
728 * @brief Builds and send SR UCI Indication to SCH
732 * Function : buildAndSendSrInd
735 * Builds and send SR UCI Indication to SCH
737 * @params[in] SrUciIndInfo Pointer
739 * @return ROK - success
742 * ****************************************************************/
743 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
747 SrUciIndInfo srUciInd;
748 memset(&pst, 0, sizeof(Pst));
749 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
751 GET_CELL_IDX(macUciInd->cellId, cellIdx);
752 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
753 srUciInd.crnti = crnti;
754 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
755 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
756 srUciInd.numSrBits++;
757 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
760 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
762 return(SchMessageRouter(&pst, (void *)&srUciInd));
765 /*******************************************************************
767 * @brief Processes UCI Indication from PHY
771 * Function : fapiMacUciInd
774 * Processes UCI Indication from PHY
776 * @params[in] Post Structure Pointer
777 * UCI Indication Pointer
778 * @return ROK - success
781 * ****************************************************************/
782 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
784 uint8_t pduIdx = 0, ret = ROK;
785 uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
789 nPdus = macUciInd->numUcis;
792 switch(macUciInd->pdus[pduIdx].pduType)
796 case UCI_IND_PUCCH_F0F1:
799 DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
800 GET_CELL_IDX(macUciInd->cellId, cellIdx);
801 buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
803 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
805 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
806 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
807 ret = buildAndSendSrInd(macUciInd, crnti);
811 case UCI_IND_PUCCH_F2F3F4:
814 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
824 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
827 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
831 /*******************************************************************
833 * @brief fill Slice Cfg Request info in shared structre
837 * Function : fillSliceCfgInfo
840 * fill Slice Cfg Request info in shared structre
842 * @params[in] SchSliceCfgReq *schSliceCfgReq
843 * MacSliceCfgReq *macSliceCfgReq;
844 * @return ROK - success
847 **********************************************************************/
848 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
850 uint8_t cfgIdx = 0, memberListIdx = 0, totalSliceCfgRecvd = 0;
852 if(macSliceCfgReq->listOfRrmPolicy)
854 for(cfgIdx = 0; cfgIdx<macSliceCfgReq->numOfRrmPolicy; cfgIdx++)
856 totalSliceCfgRecvd += macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem;
859 schSliceCfgReq->numOfConfiguredSlice = totalSliceCfgRecvd;
860 MAC_ALLOC(schSliceCfgReq->listOfSlices, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
861 if(schSliceCfgReq->listOfSlices == NULLP)
863 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
866 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
868 for(memberListIdx = 0; memberListIdx<macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem; memberListIdx++)
870 if(macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx])
873 MAC_ALLOC(schSliceCfgReq->listOfSlices[cfgIdx], sizeof(SchRrmPolicyOfSlice));
874 if(schSliceCfgReq->listOfSlices[cfgIdx] == NULLP)
876 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
880 memcpy(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, &macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx]->snssai, sizeof(Snssai));
882 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.maxRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.maxRatio;
883 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.minRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.minRatio;
884 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.dedicatedRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.dedicatedRatio;
892 /*******************************************************************
894 * @brief Processes Slice Cfg Request recived from DU
898 * Function : MacProcSliceCfgReq
901 * Processes Processes Slice Cfg Request recived from DU
903 * @params[in] Post Structure Pointer
904 * MacSliceCfgReq *macSliceCfgReq;
905 * @return ROK - success
908 **********************************************************************/
909 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
913 SchSliceCfgReq *schSliceCfgReq;
915 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
918 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
919 if(schSliceCfgReq == NULLP)
921 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
926 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
928 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
929 ret = SchMessageRouter(&schPst, (void *)schSliceCfgReq);
932 freeMacSliceCfgReq(macSliceCfgReq, pst);
936 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
941 /*******************************************************************
943 * @brief Processes Slice ReCfg Request recived from DU
947 * Function : MacProcSliceRecfgReq
950 * Processes Processes Slice ReCfg Request recived from DU
952 * @params[in] Post Structure Pointer
953 * MacSliceCfgReq *macSliceRecfgReq;
954 * @return ROK - success
957 **********************************************************************/
958 uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
962 SchSliceRecfgReq *schSliceRecfgReq;
964 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
967 MAC_ALLOC(schSliceRecfgReq, sizeof(SchSliceRecfgReq));
968 if(schSliceRecfgReq == NULLP)
970 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceRecfgReq");
975 if(fillSliceCfgInfo(schSliceRecfgReq, macSliceRecfgReq) == ROK)
977 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
978 ret = SchMessageRouter(&schPst, (void *)schSliceRecfgReq);
981 freeMacSliceCfgReq(macSliceRecfgReq, pst);
985 DU_LOG("\nINFO --> MAC : Received MacSliceRecfgReq is NULL");
990 /**********************************************************************
992 **********************************************************************/