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].duUeF1apId);
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 == SRB1_LCID || lcId == SRB2_LCID)
360 ulData->pduInfo[ulData->numPdu].commCh = true;
362 ulData->pduInfo[ulData->numPdu].lcId = lcId;
363 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
364 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
367 /* Filling Post and send to RLC */
368 memset(&pst, 0, sizeof(Pst));
369 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
370 MacSendUlDataToRlc(&pst, ulData);
376 /*******************************************************************
378 * @brief Processes BO status from RLC
382 * Function : MacProcRlcBOStatus
385 * Processes BO status from RLC
387 * @params[in] Post structure
389 * @return ROK - success
392 * ****************************************************************/
393 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
395 DlRlcBoInfo dlBoInfo;
397 dlBoInfo.cellId = boStatus->cellId;
398 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
399 dlBoInfo.lcId = boStatus->lcId;
400 dlBoInfo.dataVolume = boStatus->bo;
402 sendDlRlcBoInfoToSch(&dlBoInfo);
404 if(pst->selector == ODU_SELECTOR_LWLC)
406 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
412 /*******************************************************************
414 * @brief Send LC schedule result report to RLC
418 * Function : sendSchRptToRlc
420 * Functionality: Send LC schedule result report to RLC
423 * @return ROK - success
426 * ****************************************************************/
427 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
431 RlcSchedResultRpt *schedRpt = NULLP;
433 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
436 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
440 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
441 schedRpt->cellId = dlInfo.cellId;
442 schedRpt->slotInfo.sfn = slotInfo.sfn;
443 schedRpt->slotInfo.slot = slotInfo.slot;
445 if(dlInfo.dlMsgAlloc[ueIdx])
447 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
448 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].numLc;
449 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
451 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].lcId;
452 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].lcSchInfo[lcIdx].schBytes;
453 schedRpt->lcSch[lcIdx].commCh = false;
458 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
459 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
461 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
462 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
469 /*******************************************************************
471 * @brief Handles cell start reuqest from DU APP
475 * Function : MacProcCellStart
478 * Handles cell start reuqest from DU APP
480 * @params[in] Post structure pointer
482 * @return ROK - success
485 * ****************************************************************/
486 uint8_t MacProcCellStart(Pst *pst, OduCellId *cellId)
488 DU_LOG("\nINFO --> MAC : Handling cell start request");
490 sendToLowerMac(START_REQUEST, 0, cellId);
492 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
498 /*******************************************************************
500 * @brief Handles cell stop from DU APP
504 * Function : MacProcCellStop
507 * Handles cell stop from DU APP
509 * @params[in] Post structure pointer
511 * @return ROK - success
514 * ****************************************************************/
515 uint8_t MacProcCellStop(Pst *pst, OduCellId *cellId)
520 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
521 GET_CELL_IDX(cellId->cellId, cellIdx);
522 if(macCb.macCell[cellIdx])
524 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
528 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, \
534 /*******************************************************************
536 * @brief Handles DL CCCH Ind from DU APP
540 * Function : MacProcDlCcchInd
543 * Handles DL CCCH Ind from DU APP
545 * @params[in] Post structure pointer
546 * DL CCCH Ind pointer
547 * @return ROK - success
550 * ****************************************************************/
551 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
553 uint8_t ueId = 0, ueIdx = 0;
556 DlRlcBoInfo dlBoInfo;
557 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
559 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
561 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
563 dlBoInfo.cellId = dlCcchIndInfo->cellId;
564 dlBoInfo.crnti = dlCcchIndInfo->crnti;
566 if(dlCcchIndInfo->msgType == RRC_SETUP)
568 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
569 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
570 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
572 /* storing Msg4 Pdu in raCb */
573 GET_UE_ID(dlBoInfo.crnti, ueId);
575 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
577 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
578 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
579 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
580 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
582 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
584 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
585 dlCcchIndInfo->dlCcchMsg[idx];
590 sendDlRlcBoInfoToSch(&dlBoInfo);
592 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
593 dlCcchIndInfo->dlCcchMsgLen);
594 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
599 /*******************************************************************
601 * @brief Sends UL CCCH Ind to DU APP
605 * Function : macProcUlCcchInd
608 * MAC sends UL CCCH Ind to DU APP
610 * @params[in] Post structure pointer
612 * @return ROK - success
615 * ****************************************************************/
616 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
620 UlCcchIndInfo *ulCcchIndInfo = NULLP;
622 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
625 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
629 ulCcchIndInfo->cellId = cellId;
630 ulCcchIndInfo->crnti = crnti;
631 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
632 ulCcchIndInfo->ulCcchMsg = rrcContainer;
635 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
637 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
639 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
640 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
641 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
647 /*******************************************************************
649 * @brief Processes received short BSR
653 * Function : macProcShortBsr
656 * MAC sends Short BSR to SCH
658 * @params[in] cell ID
663 * @return ROK - success
666 * ****************************************************************/
667 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
670 UlBufferStatusRptInd bsrInd;
672 memset(&pst, 0, sizeof(Pst));
673 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
675 bsrInd.cellId = cellId;
676 bsrInd.crnti = crnti;
677 bsrInd.bsrType = SHORT_BSR;
678 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
679 bsrInd.dataVolInfo[0].lcgId = lcgId;
680 bsrInd.dataVolInfo[0].dataVol = bufferSize;
682 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
683 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
686 /*******************************************************************
688 * @brief Processes received short BSR
692 * Function : macProcShortBsr
695 * MAC sends Short BSR to SCH
697 * @params[in] cell ID
702 * @return ROK - success
705 * ****************************************************************/
706 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
707 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
710 UlBufferStatusRptInd bsrInd;
713 memset(&pst, 0, sizeof(Pst));
714 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
716 bsrInd.cellId = cellId;
717 bsrInd.crnti = crnti;
718 bsrInd.bsrType = LONG_BSR;
719 bsrInd.numLcg = numLcg;
721 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
722 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
724 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
725 return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
728 /*******************************************************************
730 * @brief Builds and send SR UCI Indication to SCH
734 * Function : buildAndSendSrInd
737 * Builds and send SR UCI Indication to SCH
739 * @params[in] SrUciIndInfo Pointer
741 * @return ROK - success
744 * ****************************************************************/
745 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
749 SrUciIndInfo srUciInd;
750 memset(&pst, 0, sizeof(Pst));
751 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
753 GET_CELL_IDX(macUciInd->cellId, cellIdx);
754 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
755 srUciInd.crnti = crnti;
756 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
757 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
758 srUciInd.numSrBits++;
759 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
762 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
764 return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
767 /*******************************************************************
769 * @brief Processes UCI Indication from PHY
773 * Function : fapiMacUciInd
776 * Processes UCI Indication from PHY
778 * @params[in] Post Structure Pointer
779 * UCI Indication Pointer
780 * @return ROK - success
783 * ****************************************************************/
784 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
786 uint8_t pduIdx = 0, ret = ROK;
787 uint16_t nPdus = 0, crnti = 0;
791 nPdus = macUciInd->numUcis;
794 switch(macUciInd->pdus[pduIdx].pduType)
798 case UCI_IND_PUCCH_F0F1:
799 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
801 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
802 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
803 ret = buildAndSendSrInd(macUciInd, crnti);
806 case UCI_IND_PUCCH_F2F3F4:
809 DU_LOG("\nERROR --> MAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
819 DU_LOG("\nERROR --> MAC: Received Uci Ind is NULL at FapiMacUciInd()");
822 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macUciInd, sizeof(UciInd));
826 /*******************************************************************
828 * @brief fill Slice Cfg Request info in shared structre
832 * Function : fillSliceCfgInfo
835 * fill Slice Cfg Request info in shared structre
837 * @params[in] SchSliceCfgReq *schSliceCfgReq
838 * MacSliceCfgReq *macSliceCfgReq;
839 * @return ROK - success
842 **********************************************************************/
843 uint8_t fillSliceCfgInfo(SchSliceCfgReq *schSliceCfgReq, MacSliceCfgReq *macSliceCfgReq)
847 if(macSliceCfgReq->listOfSliceCfg)
849 schSliceCfgReq->numOfConfiguredSlice = macSliceCfgReq->numOfConfiguredSlice;
850 MAC_ALLOC(schSliceCfgReq->listOfConfirguration, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
851 if(schSliceCfgReq->listOfConfirguration == NULLP)
853 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
856 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
858 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx], sizeof(SchRrmPolicyOfSlice));
859 if(schSliceCfgReq->listOfConfirguration[cfgIdx] == NULLP)
861 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
865 memcpy(&schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai, &macSliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, sizeof(Snssai));
867 if(macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio)
869 MAC_ALLOC(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo, sizeof(SchRrmPolicyRatio));
870 if(schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo == NULLP)
872 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
875 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMaxRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio;
876 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyMinRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio;
877 schSliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo->policyDedicatedRatio = macSliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio;
883 /*******************************************************************
885 * @brief Processes Slice Cfg Request recived from DU
889 * Function : MacProcSliceCfgReq
892 * Processes Processes Slice Cfg Request recived from DU
894 * @params[in] Post Structure Pointer
895 * MacSliceCfgReq *macSliceCfgReq;
896 * @return ROK - success
899 **********************************************************************/
900 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
904 SchSliceCfgReq *schSliceCfgReq;
906 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
909 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
910 if(schSliceCfgReq == NULLP)
912 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
917 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
919 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
920 ret = (*macSchSliceCfgReqOpts[schPst.selector])(&schPst, schSliceCfgReq);
923 freeMacSliceCfgReq(macSliceCfgReq, pst);
927 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
932 /*******************************************************************
934 * @brief Processes Slice ReCfg Request recived from DU
938 * Function : MacProcSliceReCfgReq
941 * Processes Processes Slice ReCfg Request recived from DU
943 * @params[in] Post Structure Pointer
944 * MacSliceCfgReq *macSliceReCfgReq;
945 * @return ROK - success
948 **********************************************************************/
949 uint8_t MacProcSliceReCfgReq(Pst *pst, MacSliceCfgReq *macSliceReCfgReq)
953 SchSliceCfgReq *schSliceReCfgReq;
955 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
958 MAC_ALLOC(schSliceReCfgReq, sizeof(SchSliceCfgReq));
959 if(schSliceReCfgReq == NULLP)
961 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceReCfgReq");
966 if(fillSliceCfgInfo(schSliceReCfgReq, macSliceReCfgReq) == ROK)
968 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
969 ret = (*macSchSliceReCfgReqOpts[schPst.selector])(&schPst, schSliceReCfgReq);
973 freeMacSliceCfgReq(macSliceReCfgReq, pst);
977 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
982 /**********************************************************************
984 **********************************************************************/