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"
36 /* This file contains message handling functionality for MAC */
40 /* Function pointer for sending crc ind from MAC to SCH */
41 MacSchCrcIndFunc macSchCrcIndOpts[]=
48 /* Function pointer for sending DL RLC BO Info from MAC to SCH */
49 MacSchDlRlcBoInfoFunc macSchDlRlcBoInfoOpts[]=
51 packMacSchDlRlcBoInfo,
56 /* Function pointer for sending short BSR from MAC to SCH */
57 MacSchBsrFunc macSchBsrOpts[]=
64 /* Function pointer for sending SR Uci ind from MAC to SCH */
65 MacSchSrUciIndFunc macSchSrUciIndOpts[]=
72 /* Function pointer for sending Slice cfg ind from MAC to SCH */
73 MacSchSliceCfgReqFunc macSchSliceCfgReqOpts[]=
75 packMacSchSliceCfgReq,
80 /* Function pointer for sending Slice cfg ind from MAC to SCH */
81 MacSchSliceReCfgReqFunc macSchSliceReCfgReqOpts[]=
83 packMacSchSliceReCfgReq,
85 packMacSchSliceReCfgReq
87 /*******************************************************************
89 * @brief Sends DL BO Info to SCH
93 * Function : sendDlRlcBoInfoToSch
96 * Sends DL BO Info to SCH
99 * @return ROK - success
102 ****************************************************************/
103 uint8_t sendDlRlcBoInfoToSch(DlRlcBoInfo *dlBoInfo)
107 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_RLC_BO_INFO_TO_SCH);
108 return(*macSchDlRlcBoInfoOpts[pst.selector])(&pst, dlBoInfo);
111 /*******************************************************************
113 * @brief Sends CRC Indication to SCH
117 * Function : sendCrcIndMacToSch
120 * Sends CRC Indication to SCH
123 * @return ROK - success
126 ****************************************************************/
127 uint8_t sendCrcIndMacToSch(CrcIndInfo *crcInd)
131 FILL_PST_MAC_TO_SCH(pst, EVENT_CRC_IND_TO_SCH);
132 return(*macSchCrcIndOpts[pst.selector])(&pst, crcInd);
135 /*******************************************************************
137 * @brief Processes CRC Indication from PHY
141 * Function : fapiMacCrcInd
144 * Processes CRC Indication from PHY
146 * @params[in] Post Structure Pointer
147 * Crc Indication Pointer
148 * @return ROK - success
151 * ****************************************************************/
152 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
155 CrcIndInfo crcIndInfo;
156 DU_LOG("\nDEBUG --> MAC : Received CRC indication");
157 GET_CELL_IDX(crcInd->cellId, cellIdx);
158 /* Considering one pdu and one preamble */
159 crcIndInfo.cellId = macCb.macCell[cellIdx]->cellId;
160 crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
161 crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
162 crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
163 crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
164 crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
166 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, crcInd, sizeof(CrcInd));
167 return(sendCrcIndMacToSch(&crcIndInfo));
170 /*******************************************************************
172 * @brief Process Rx Data Ind at MAC
176 * Function : fapiMacRxDataInd
179 * Process Rx Data Ind at MAC
181 * @params[in] Post structure
183 * @return ROK - success
186 * ****************************************************************/
187 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
190 uint16_t pduIdx, cellIdx = 0;
191 DU_LOG("\nDEBUG --> MAC : Received Rx Data indication");
192 /* TODO : compare the handle received in RxDataInd with handle send in PUSCH
193 * PDU, which is stored in raCb */
195 for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
198 GET_CELL_IDX(rxDataInd->cellId, cellIdx);
199 GET_UE_ID(rxDataInd->pdus[pduIdx].rnti, ueId);
201 if(macCb.macCell[cellIdx] && macCb.macCell[cellIdx]->ueCb[ueId -1].transmissionAction == STOP_TRANSMISSION)
203 DU_LOG("\nINFO --> MAC : UL data transmission not allowed for UE %d", macCb.macCell[cellIdx]->ueCb[ueId -1].ueId);
207 unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
209 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd->pdus[pduIdx].pduData,\
210 rxDataInd->pdus[pduIdx].pduLength);
212 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, rxDataInd, sizeof(RxDataInd));
216 /*******************************************************************
218 * @brief Processes DL data from RLC
222 * Function : MacProcRlcDlData
225 * Processes DL data from RLC
227 * @params[in] Post structure
229 * @return ROK - success
232 * ****************************************************************/
233 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
238 uint8_t *txPdu = NULLP;
239 uint8_t schInfoIdx = 0 ;
240 uint16_t cellIdx = 0, txPduLen = 0;
242 MacDlSlot *currDlSlot = NULLP;
243 DlRlcBoInfo dlBoInfo;
245 memset(&macDlData , 0, sizeof(MacDlData));
246 DU_LOG("\nDEBUG --> MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
247 dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
249 GET_UE_ID(dlData->rnti, ueId);
251 /* Copy the pdus to be muxed into mac Dl data */
252 macDlData.ueId = ueId;
253 macDlData.numPdu = dlData->numPdu;
254 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
256 macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
257 macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
258 macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
261 GET_CELL_IDX(dlData->cellId, cellIdx);
262 /* Store DL data in the scheduled slot */
263 if(macCb.macCell[cellIdx] ==NULLP)
265 DU_LOG("\nERROR --> MAC : MacProcRlcDlData(): macCell does not exists");
268 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
269 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
271 for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->numSchedInfo; schInfoIdx++)
273 if((currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
274 (currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
278 txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[0].tbSize\
279 - TX_PAYLOAD_HDR_LEN;
280 MAC_ALLOC(txPdu, txPduLen);
283 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData");
286 macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
288 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen = txPduLen;
289 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = txPdu;
292 for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
294 if(dlData->boStatus[lcIdx].bo)
296 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
297 dlBoInfo.cellId = dlData->boStatus[lcIdx].cellId;
298 GET_CRNTI(dlBoInfo.crnti, dlData->boStatus[lcIdx].ueId);
299 dlBoInfo.lcId = dlData->boStatus[lcIdx].lcId;
300 dlBoInfo.dataVolume = dlData->boStatus[lcIdx].bo;
301 sendDlRlcBoInfoToSch(&dlBoInfo);
306 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
308 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
309 dlData->pduInfo[pduIdx].pduLen);
311 if(pstInfo->selector == ODU_SELECTOR_LWLC)
313 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcData));
318 /*******************************************************************
320 * @brief Builds and Sends UL Data to RLC
324 * Function : macProcUlData
326 * Functionality: Builds and Sends UL Data to RLC
331 * LC Id on which payload was received
332 * Pointer to the payload
334 * @return ROK - success
337 * ****************************************************************/
338 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
339 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
344 /* Filling RLC Ul Data*/
345 MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcData));
348 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
351 memset(ulData, 0, sizeof(RlcData));
352 ulData->cellId = cellId;
354 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
355 ulData->slotInfo.cellId = cellId;
357 /* Filling pdu info */
358 if(lcId != SRB0_LCID)
359 ulData->pduInfo[ulData->numPdu].commCh = false;
361 ulData->pduInfo[ulData->numPdu].commCh = true;
363 ulData->pduInfo[ulData->numPdu].lcId = lcId;
364 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
365 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
368 /* Filling Post and send to RLC */
369 memset(&pst, 0, sizeof(Pst));
370 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
371 MacSendUlDataToRlc(&pst, ulData);
377 /*******************************************************************
379 * @brief Processes BO status from RLC
383 * Function : MacProcRlcBOStatus
386 * Processes BO status from RLC
388 * @params[in] Post structure
390 * @return ROK - success
393 * ****************************************************************/
394 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
396 DlRlcBoInfo dlBoInfo;
398 dlBoInfo.cellId = boStatus->cellId;
399 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
400 dlBoInfo.lcId = boStatus->lcId;
401 dlBoInfo.dataVolume = boStatus->bo;
403 sendDlRlcBoInfoToSch(&dlBoInfo);
405 if(pst->selector == ODU_SELECTOR_LWLC)
407 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
413 /*******************************************************************
415 * @brief Send LC schedule result report to RLC
419 * Function : sendSchRptToRlc
421 * Functionality: Send LC schedule result report to RLC
424 * @return ROK - success
427 * ****************************************************************/
428 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
432 RlcSchedResultRpt *schedRpt = NULLP;
434 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
437 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
441 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
442 schedRpt->cellId = dlInfo.cellId;
443 schedRpt->slotInfo.sfn = slotInfo.sfn;
444 schedRpt->slotInfo.slot = slotInfo.slot;
446 if(dlInfo.dlMsgAlloc[ueIdx])
448 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
449 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
450 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
452 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
453 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
454 schedRpt->lcSch[lcIdx].commCh = false;
459 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
460 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
462 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
463 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
470 /*******************************************************************
472 * @brief Handles cell start reuqest from DU APP
476 * Function : MacProcCellStart
479 * Handles cell start reuqest from DU APP
481 * @params[in] Post structure pointer
483 * @return ROK - success
486 * ****************************************************************/
487 uint8_t MacProcCellStart(Pst *pst, OduCellId *cellId)
489 DU_LOG("\nINFO --> MAC : Handling cell start request");
491 sendToLowerMac(START_REQUEST, 0, cellId);
493 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
499 /*******************************************************************
501 * @brief Handles cell stop from DU APP
505 * Function : MacProcCellStop
508 * Handles cell stop from DU APP
510 * @params[in] Post structure pointer
512 * @return ROK - success
515 * ****************************************************************/
516 uint8_t MacProcCellStop(Pst *pst, OduCellId *cellId)
521 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
522 GET_CELL_IDX(cellId->cellId, cellIdx);
523 if(macCb.macCell[cellIdx])
525 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
529 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
535 /*******************************************************************
537 * @brief Handles DL CCCH Ind from DU APP
541 * Function : MacProcDlCcchInd
544 * Handles DL CCCH Ind from DU APP
546 * @params[in] Post structure pointer
547 * DL CCCH Ind pointer
548 * @return ROK - success
551 * ****************************************************************/
552 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
554 uint8_t ueId = 0, ueIdx = 0;
557 DlRlcBoInfo dlBoInfo;
558 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
560 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
562 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
564 dlBoInfo.cellId = dlCcchIndInfo->cellId;
565 dlBoInfo.crnti = dlCcchIndInfo->crnti;
567 if(dlCcchIndInfo->msgType == RRC_SETUP)
569 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
570 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
571 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
573 /* storing Msg4 Pdu in raCb */
574 GET_UE_ID(dlBoInfo.crnti, ueId);
576 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
578 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
579 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
580 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
581 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
583 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
585 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
586 dlCcchIndInfo->dlCcchMsg[idx];
591 sendDlRlcBoInfoToSch(&dlBoInfo);
593 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
594 dlCcchIndInfo->dlCcchMsgLen);
595 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
600 /*******************************************************************
602 * @brief Sends UL CCCH Ind to DU APP
606 * Function : macProcUlCcchInd
609 * MAC sends UL CCCH Ind to DU APP
611 * @params[in] Post structure pointer
613 * @return ROK - success
616 * ****************************************************************/
617 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
621 UlCcchIndInfo *ulCcchIndInfo = NULLP;
623 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
626 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
630 ulCcchIndInfo->cellId = cellId;
631 ulCcchIndInfo->crnti = crnti;
632 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
633 ulCcchIndInfo->ulCcchMsg = rrcContainer;
636 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
638 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
640 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
641 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
642 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
648 /*******************************************************************
650 * @brief Processes received short BSR
654 * Function : macProcShortBsr
657 * MAC sends Short BSR to SCH
659 * @params[in] cell ID
664 * @return ROK - success
667 * ****************************************************************/
668 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
671 UlBufferStatusRptInd bsrInd;
673 memset(&pst, 0, sizeof(Pst));
674 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
676 bsrInd.cellId = cellId;
677 bsrInd.crnti = crnti;
678 bsrInd.bsrType = SHORT_BSR;
679 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
680 bsrInd.dataVolInfo[0].lcgId = lcgId;
681 bsrInd.dataVolInfo[0].dataVol = bufferSize;
683 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
684 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
687 /*******************************************************************
689 * @brief Processes received short BSR
693 * Function : macProcShortBsr
696 * MAC sends Short BSR to SCH
698 * @params[in] cell ID
703 * @return ROK - success
706 * ****************************************************************/
707 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
708 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
711 UlBufferStatusRptInd bsrInd;
714 memset(&pst, 0, sizeof(Pst));
715 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
717 bsrInd.cellId = cellId;
718 bsrInd.crnti = crnti;
719 bsrInd.bsrType = LONG_BSR;
720 bsrInd.numLcg = numLcg;
722 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
723 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
725 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
726 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
729 /*******************************************************************
731 * @brief Builds and send SR UCI Indication to SCH
735 * Function : buildAndSendSrInd
738 * Builds and send SR UCI Indication to SCH
740 * @params[in] SrUciIndInfo Pointer
742 * @return ROK - success
745 * ****************************************************************/
746 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
750 SrUciIndInfo srUciInd;
751 memset(&pst, 0, sizeof(Pst));
752 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
754 GET_CELL_IDX(macUciInd->cellId, cellIdx);
755 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
756 srUciInd.crnti = crnti;
757 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
758 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
759 srUciInd.numSrBits++;
760 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
763 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
765 return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
768 /*******************************************************************
770 * @brief Processes UCI Indication from PHY
774 * Function : fapiMacUciInd
777 * Processes UCI Indication from PHY
779 * @params[in] Post Structure Pointer
780 * UCI Indication Pointer
781 * @return ROK - success
784 * ****************************************************************/
785 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
787 uint8_t pduIdx = 0, ret = ROK;
788 uint16_t nPdus = 0, crnti = 0;
792 nPdus = macUciInd->numUcis;
795 switch(macUciInd->pdus[pduIdx].pduType)
799 case UCI_IND_PUCCH_F0F1:
800 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
802 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
803 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
804 ret = buildAndSendSrInd(macUciInd, crnti);
807 case UCI_IND_PUCCH_F2F3F4:
810 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
820 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
823 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
827 /*******************************************************************
829 * @brief fill Slice Cfg Request info in shared structre
833 * Function : fillSliceCfgInfo
836 * fill Slice Cfg Request info in shared structre
838 * @params[in] SchSliceCfgReq *schSliceCfgReq
839 * MacSliceCfgReq *macSliceCfgReq;
840 * @return ROK - success
843 **********************************************************************/
844 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
848 if(macSliceCfgReq->listOfSliceCfg)
850 schSliceCfgReq->numOfConfiguredSlice = macSliceCfgReq->numOfConfiguredSlice;
851 MAC_ALLOC(schSliceCfgReq->listOfConfirguration, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
852 if(schSliceCfgReq->listOfConfirguration == NULLP)
854 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
857 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
859 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx], sizeof(SchRrmPolicyOfSlice));
860 if(schSliceCfgReq->listOfConfirguration[cfgIdx] == NULLP)
862 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
866 memcpy(&schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai, &macSliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, sizeof(Snssai));
868 if(macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio)
870 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo, sizeof(SchRrmPolicyRatio));
871 if(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo == NULLP)
873 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
876 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMaxRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio;
877 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMinRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio;
878 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyDedicatedRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio;
884 /*******************************************************************
886 * @brief Processes Slice Cfg Request recived from DU
890 * Function : MacProcSliceCfgReq
893 * Processes Processes Slice Cfg Request recived from DU
895 * @params[in] Post Structure Pointer
896 * MacSliceCfgReq *macSliceCfgReq;
897 * @return ROK - success
900 **********************************************************************/
901 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
905 SchSliceCfgReq *schSliceCfgReq;
907 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
910 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
911 if(schSliceCfgReq == NULLP)
913 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
918 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
920 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
921 ret = (*macSchSliceCfgReqOpts[schPst.selector])(&schPst, schSliceCfgReq);
924 freeMacSliceCfgReq(macSliceCfgReq, pst);
928 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
933 /*******************************************************************
935 * @brief Processes Slice ReCfg Request recived from DU
939 * Function : MacProcSliceReCfgReq
942 * Processes Processes Slice ReCfg Request recived from DU
944 * @params[in] Post Structure Pointer
945 * MacSliceCfgReq *macSliceReCfgReq;
946 * @return ROK - success
949 **********************************************************************/
950 uint8_t MacProcSliceReCfgReq(Pst *pst, MacSliceCfgReq *macSliceReCfgReq)
954 SchSliceCfgReq *schSliceReCfgReq;
956 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
959 MAC_ALLOC(schSliceReCfgReq, sizeof(SchSliceCfgReq));
960 if(schSliceReCfgReq == NULLP)
962 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceReCfgReq");
967 if(fillSliceCfgInfo(schSliceReCfgReq, macSliceReCfgReq) == ROK)
969 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
970 ret = (*macSchSliceReCfgReqOpts[schPst.selector])(&schPst, schSliceReCfgReq);
974 freeMacSliceCfgReq(macSliceReCfgReq, pst);
978 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
983 /**********************************************************************
985 **********************************************************************/