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 DL HARQ Ind from MAC to SCH */
74 MacSchDlHarqIndFunc macSchDlHarqIndOpts[]=
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, RlcDlData *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(RlcDlData));
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(RlcUlData));
361 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
364 memset(ulData, 0, sizeof(RlcUlData));
365 ulData->cellId = cellId;
367 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
368 ulData->slotInfo.cellId = cellId;
370 /* Filling pdu info */
371 ulData->pduInfo[ulData->numPdu].lcId = lcId;
372 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
373 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
376 /* Filling Post and send to RLC */
377 memset(&pst, 0, sizeof(Pst));
378 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
379 MacSendUlDataToRlc(&pst, ulData);
385 /*******************************************************************
387 * @brief Processes BO status from RLC
391 * Function : MacProcRlcBOStatus
394 * Processes BO status from RLC
396 * @params[in] Post structure
398 * @return ROK - success
401 * ****************************************************************/
402 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
404 DlRlcBoInfo dlBoInfo;
406 dlBoInfo.cellId = boStatus->cellId;
407 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
408 dlBoInfo.lcId = boStatus->lcId;
409 dlBoInfo.dataVolume = boStatus->bo;
411 sendDlRlcBoInfoToSch(&dlBoInfo);
413 if(pst->selector == ODU_SELECTOR_LWLC)
415 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
421 /*******************************************************************
423 * @brief Send LC schedule result report to RLC
427 * Function : sendSchRptToRlc
429 * Functionality: Send LC schedule result report to RLC
432 * @return ROK - success
435 * ****************************************************************/
436 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
440 RlcSchedResultRpt *schedRpt = NULLP;
442 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
445 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
449 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
450 schedRpt->cellId = dlInfo.cellId;
451 schedRpt->slotInfo.sfn = slotInfo.sfn;
452 schedRpt->slotInfo.slot = slotInfo.slot;
454 if(dlInfo.dlMsgAlloc[ueIdx])
456 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
457 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
458 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
460 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
461 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
466 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
467 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
469 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
470 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
477 /*******************************************************************
479 * @brief Handles cell start reuqest from DU APP
483 * Function : MacProcCellStart
486 * Handles cell start reuqest from DU APP
488 * @params[in] Post structure pointer
490 * @return ROK - success
493 * ****************************************************************/
494 uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStart)
496 DU_LOG("\nINFO --> MAC : Handling cell start request");
498 sendToLowerMac(START_REQUEST, 0, cellStart);
500 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStart, \
501 sizeof(CellStartInfo));
506 /*******************************************************************
508 * @brief Handles cell stop from DU APP
512 * Function : MacProcCellStop
515 * Handles cell stop from DU APP
517 * @params[in] Post structure pointer
519 * @return ROK - success
522 * ****************************************************************/
523 uint8_t MacProcCellStop(Pst *pst, CellStopInfo *cellStop)
528 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
529 GET_CELL_IDX(cellStop->cellId, cellIdx);
530 if(macCb.macCell[cellIdx])
532 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
536 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStop, \
537 sizeof(CellStopInfo));
542 /*******************************************************************
544 * @brief Handles DL CCCH Ind from DU APP
548 * Function : MacProcDlCcchInd
551 * Handles DL CCCH Ind from DU APP
553 * @params[in] Post structure pointer
554 * DL CCCH Ind pointer
555 * @return ROK - success
558 * ****************************************************************/
559 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
561 uint8_t ueId = 0, ueIdx = 0;
564 DlRlcBoInfo dlBoInfo;
565 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
567 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
569 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
571 dlBoInfo.cellId = dlCcchIndInfo->cellId;
572 dlBoInfo.crnti = dlCcchIndInfo->crnti;
574 if(dlCcchIndInfo->msgType == RRC_SETUP)
576 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
577 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
578 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
580 /* storing Msg4 Pdu in raCb */
581 GET_UE_ID(dlBoInfo.crnti, ueId);
583 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
585 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
586 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
587 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
588 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
590 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
592 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
593 dlCcchIndInfo->dlCcchMsg[idx];
598 sendDlRlcBoInfoToSch(&dlBoInfo);
600 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
601 dlCcchIndInfo->dlCcchMsgLen);
602 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
607 /*******************************************************************
609 * @brief Sends UL CCCH Ind to DU APP
613 * Function : macProcUlCcchInd
616 * MAC sends UL CCCH Ind to DU APP
618 * @params[in] Post structure pointer
620 * @return ROK - success
623 * ****************************************************************/
624 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
628 UlCcchIndInfo *ulCcchIndInfo = NULLP;
630 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
633 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
637 ulCcchIndInfo->cellId = cellId;
638 ulCcchIndInfo->crnti = crnti;
639 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
640 ulCcchIndInfo->ulCcchMsg = rrcContainer;
643 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
645 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
647 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
648 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
649 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
655 /*******************************************************************
657 * @brief Processes received short BSR
661 * Function : macProcShortBsr
664 * MAC sends Short BSR to SCH
666 * @params[in] cell ID
671 * @return ROK - success
674 * ****************************************************************/
675 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
678 UlBufferStatusRptInd bsrInd;
680 memset(&pst, 0, sizeof(Pst));
681 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
683 bsrInd.cellId = cellId;
684 bsrInd.crnti = crnti;
685 bsrInd.bsrType = SHORT_BSR;
686 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
687 bsrInd.dataVolInfo[0].lcgId = lcgId;
688 bsrInd.dataVolInfo[0].dataVol = bufferSize;
690 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
691 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
694 /*******************************************************************
696 * @brief Processes received short BSR
700 * Function : macProcShortBsr
703 * MAC sends Short BSR to SCH
705 * @params[in] cell ID
710 * @return ROK - success
713 * ****************************************************************/
714 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
715 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
718 UlBufferStatusRptInd bsrInd;
721 memset(&pst, 0, sizeof(Pst));
722 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
724 bsrInd.cellId = cellId;
725 bsrInd.crnti = crnti;
726 bsrInd.bsrType = LONG_BSR;
727 bsrInd.numLcg = numLcg;
729 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
730 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
732 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
733 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
736 /*******************************************************************
738 * @brief Builds and send DL HARQ Indication to SCH
742 * Function : buildAndSendHarqInd
745 * Builds and send HARQ UCI Indication to SCH
747 * @params[in] harqInfo Pointer
751 * @return ROK - success
754 * ****************************************************************/
755 uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
757 uint16_t harqCounter=0;
760 memset(&pst, 0, sizeof(Pst));
761 memset(&dlHarqInd, 0, sizeof(DlHarqInd));
763 dlHarqInd.cellId = macCb.macCell[cellIdx]->cellId;
764 dlHarqInd.crnti = crnti;
765 dlHarqInd.slotInd.sfn = slotInd->sfn;
766 dlHarqInd.slotInd.slot = slotInd->slot;
767 dlHarqInd.numHarq = harqInfo->numHarq;
768 memset(dlHarqInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
769 for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
771 dlHarqInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
775 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_HARQ_IND_TO_SCH);
777 return(*macSchDlHarqIndOpts[pst.selector])(&pst, &dlHarqInd);
781 /*******************************************************************
783 * @brief Builds and send SR UCI Indication to SCH
787 * Function : buildAndSendSrInd
790 * Builds and send SR UCI Indication to SCH
792 * @params[in] SrUciIndInfo Pointer
794 * @return ROK - success
797 * ****************************************************************/
798 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
802 SrUciIndInfo srUciInd;
803 memset(&pst, 0, sizeof(Pst));
804 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
806 GET_CELL_IDX(macUciInd->cellId, cellIdx);
807 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
808 srUciInd.crnti = crnti;
809 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
810 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
811 srUciInd.numSrBits++;
812 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
815 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
817 return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
820 /*******************************************************************
822 * @brief Processes UCI Indication from PHY
826 * Function : fapiMacUciInd
829 * Processes UCI Indication from PHY
831 * @params[in] Post Structure Pointer
832 * UCI Indication Pointer
833 * @return ROK - success
836 * ****************************************************************/
837 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
839 uint8_t pduIdx = 0, ret = ROK;
840 uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
844 nPdus = macUciInd->numUcis;
847 switch(macUciInd->pdus[pduIdx].pduType)
851 case UCI_IND_PUCCH_F0F1:
854 DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
855 GET_CELL_IDX(macUciInd->cellId, cellIdx);
856 buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
858 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
860 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
861 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
862 ret = buildAndSendSrInd(macUciInd, crnti);
866 case UCI_IND_PUCCH_F2F3F4:
869 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
879 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
882 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
886 /*******************************************************************
888 * @brief fill Slice Cfg Request info in shared structre
892 * Function : fillSliceCfgInfo
895 * fill Slice Cfg Request info in shared structre
897 * @params[in] SchSliceCfgReq *schSliceCfgReq
898 * MacSliceCfgReq *macSliceCfgReq;
899 * @return ROK - success
902 **********************************************************************/
903 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
905 uint8_t cfgIdx = 0, memberListIdx = 0, totalSliceCfgRecvd = 0;
907 if(macSliceCfgReq->listOfRrmPolicy)
909 for(cfgIdx = 0; cfgIdx<macSliceCfgReq->numOfRrmPolicy; cfgIdx++)
911 totalSliceCfgRecvd += macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem;
914 schSliceCfgReq->numOfConfiguredSlice = totalSliceCfgRecvd;
915 MAC_ALLOC(schSliceCfgReq->listOfSlices, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
916 if(schSliceCfgReq->listOfSlices == NULLP)
918 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
921 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
923 for(memberListIdx = 0; memberListIdx<macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem; memberListIdx++)
925 if(macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx])
928 MAC_ALLOC(schSliceCfgReq->listOfSlices[cfgIdx], sizeof(SchRrmPolicyOfSlice));
929 if(schSliceCfgReq->listOfSlices[cfgIdx] == NULLP)
931 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
935 memcpy(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, &macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx]->snssai, sizeof(Snssai));
937 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.maxRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.maxRatio;
938 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.minRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.minRatio;
939 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.dedicatedRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.dedicatedRatio;
947 /*******************************************************************
949 * @brief Processes Slice Cfg Request recived from DU
953 * Function : MacProcSliceCfgReq
956 * Processes Processes Slice Cfg Request recived from DU
958 * @params[in] Post Structure Pointer
959 * MacSliceCfgReq *macSliceCfgReq;
960 * @return ROK - success
963 **********************************************************************/
964 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
968 SchSliceCfgReq *schSliceCfgReq;
970 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
973 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
974 if(schSliceCfgReq == NULLP)
976 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
981 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
983 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
984 ret = (*macSchSliceCfgReqOpts[schPst.selector])(&schPst, schSliceCfgReq);
987 freeMacSliceCfgReq(macSliceCfgReq, pst);
991 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
996 /*******************************************************************
998 * @brief Processes Slice ReCfg Request recived from DU
1002 * Function : MacProcSliceRecfgReq
1005 * Processes Processes Slice ReCfg Request recived from DU
1007 * @params[in] Post Structure Pointer
1008 * MacSliceCfgReq *macSliceRecfgReq;
1009 * @return ROK - success
1012 **********************************************************************/
1013 uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
1017 SchSliceRecfgReq *schSliceRecfgReq;
1019 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
1020 if(macSliceRecfgReq)
1022 MAC_ALLOC(schSliceRecfgReq, sizeof(SchSliceRecfgReq));
1023 if(schSliceRecfgReq == NULLP)
1025 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceRecfgReq");
1030 if(fillSliceCfgInfo(schSliceRecfgReq, macSliceRecfgReq) == ROK)
1032 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
1033 ret = (*macSchSliceRecfgReqOpts[schPst.selector])(&schPst, schSliceRecfgReq);
1036 freeMacSliceCfgReq(macSliceRecfgReq, pst);
1040 DU_LOG("\nINFO --> MAC : Received MacSliceRecfgReq is NULL");
1045 /**********************************************************************
1047 **********************************************************************/