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 uint16_t cellIdx = 0, txPduLen = 0;
195 MacDlSlot *currDlSlot = NULLP;
196 DlRlcBoInfo dlBoInfo;
198 memset(&macDlData , 0, sizeof(MacDlData));
199 DU_LOG("\nDEBUG --> MAC: Received DL data for sfn=%d slot=%d numPdu= %d", \
200 dlData->slotInfo.sfn, dlData->slotInfo.slot, dlData->numPdu);
202 GET_UE_ID(dlData->rnti, ueId);
204 /* Copy the pdus to be muxed into mac Dl data */
205 macDlData.ueId = ueId;
206 macDlData.numPdu = dlData->numPdu;
207 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
209 macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
210 macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
211 macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
214 GET_CELL_IDX(dlData->cellId, cellIdx);
215 /* Store DL data in the scheduled slot */
216 if(macCb.macCell[cellIdx] ==NULLP)
218 DU_LOG("\nERROR --> MAC : MacProcRlcDlData(): macCell does not exists");
221 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlData->slotInfo.slot];
222 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1])
224 if(currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg)
226 txPduLen = currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg->codeword[0].tbSize\
227 - TX_PAYLOAD_HDR_LEN;
228 MAC_ALLOC(txPdu, txPduLen);
231 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcRlcDlData");
234 macMuxPdu(&macDlData, NULLP, txPdu, txPduLen);
236 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPduLen = txPduLen;
237 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdu = txPdu;
238 /* Add muxed TB to DL HARQ Proc CB. This will be used if retranmission of
239 * TB is requested in future. */
240 updateNewTbInDlHqProcCb(dlData->slotInfo, &macCb.macCell[cellIdx]->ueCb[ueId -1], \
241 currDlSlot->dlInfo.dlMsgAlloc[ueId-1]->dlMsgPdschCfg->codeword[0].tbSize, txPdu);
245 for(lcIdx = 0; lcIdx < dlData->numLc; lcIdx++)
247 if(dlData->boStatus[lcIdx].bo)
249 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
250 dlBoInfo.cellId = dlData->boStatus[lcIdx].cellId;
251 GET_CRNTI(dlBoInfo.crnti, dlData->boStatus[lcIdx].ueId);
252 dlBoInfo.lcId = dlData->boStatus[lcIdx].lcId;
253 dlBoInfo.dataVolume = dlData->boStatus[lcIdx].bo;
254 sendDlRlcBoInfoToSch(&dlBoInfo);
259 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
261 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
262 dlData->pduInfo[pduIdx].pduLen);
264 if(pstInfo->selector == ODU_SELECTOR_LWLC)
266 MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcDlData));
271 /*******************************************************************
273 * @brief Builds and Sends UL Data to RLC
277 * Function : macProcUlData
279 * Functionality: Builds and Sends UL Data to RLC
284 * LC Id on which payload was received
285 * Pointer to the payload
287 * @return ROK - success
290 * ****************************************************************/
291 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
292 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
297 /* Filling RLC Ul Data*/
298 MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcUlData));
301 DU_LOG("\nERROR --> MAC : Memory allocation failed while sending UL data to RLC");
304 memset(ulData, 0, sizeof(RlcUlData));
305 ulData->cellId = cellId;
307 memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotTimingInfo));
308 ulData->slotInfo.cellId = cellId;
310 /* Filling pdu info */
311 ulData->pduInfo[ulData->numPdu].lcId = lcId;
312 ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
313 ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
316 /* Filling Post and send to RLC */
317 memset(&pst, 0, sizeof(Pst));
318 FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
319 MacSendUlDataToRlc(&pst, ulData);
325 /*******************************************************************
327 * @brief Processes BO status from RLC
331 * Function : MacProcRlcBOStatus
334 * Processes BO status from RLC
336 * @params[in] Post structure
338 * @return ROK - success
341 * ****************************************************************/
342 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
344 DlRlcBoInfo dlBoInfo;
346 dlBoInfo.cellId = boStatus->cellId;
347 GET_CRNTI(dlBoInfo.crnti, boStatus->ueId);
348 dlBoInfo.lcId = boStatus->lcId;
349 dlBoInfo.dataVolume = boStatus->bo;
351 sendDlRlcBoInfoToSch(&dlBoInfo);
353 if(pst->selector == ODU_SELECTOR_LWLC)
355 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
361 /*******************************************************************
363 * @brief Send LC schedule result report to RLC
367 * Function : sendSchRptToRlc
369 * Functionality: Send LC schedule result report to RLC
372 * @return ROK - success
375 * ****************************************************************/
376 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx)
380 RlcSchedResultRpt *schedRpt = NULLP;
382 MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
385 DU_LOG("\nERROR --> MAC: Memory allocation failure in sendSchResultRepToRlc");
389 DU_LOG("\nDEBUG --> MAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
390 schedRpt->cellId = dlInfo.cellId;
391 schedRpt->slotInfo.sfn = slotInfo.sfn;
392 schedRpt->slotInfo.slot = slotInfo.slot;
394 if(dlInfo.dlMsgAlloc[ueIdx])
396 schedRpt->rnti = dlInfo.dlMsgAlloc[ueIdx]->crnti;
397 schedRpt->numLc = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].numLc;
398 for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
400 schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].lcSchInfo[lcIdx].lcId;
401 schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc[ueIdx]->transportBlock[0].lcSchInfo[lcIdx].schBytes;
406 FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
407 if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
409 DU_LOG("\nERROR --> MAC: Failed to send Schedule result report to RLC");
410 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
417 /*******************************************************************
419 * @brief Handles cell start reuqest from DU APP
423 * Function : MacProcCellStart
426 * Handles cell start reuqest from DU APP
428 * @params[in] Post structure pointer
430 * @return ROK - success
433 * ****************************************************************/
434 uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStart)
436 DU_LOG("\nINFO --> MAC : Handling cell start request");
438 sendToLowerMac(START_REQUEST, 0, cellStart);
440 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStart, \
441 sizeof(CellStartInfo));
446 /*******************************************************************
448 * @brief Handles cell stop from DU APP
452 * Function : MacProcCellStop
455 * Handles cell stop from DU APP
457 * @params[in] Post structure pointer
459 * @return ROK - success
462 * ****************************************************************/
463 uint8_t MacProcCellStop(Pst *pst, CellStopInfo *cellStop)
468 DU_LOG("\nINFO --> MAC : Sending cell stop request to Lower Mac");
469 GET_CELL_IDX(cellStop->cellId, cellIdx);
470 if(macCb.macCell[cellIdx])
472 macCb.macCell[cellIdx]->state = CELL_TO_BE_STOPPED;
476 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStop, \
477 sizeof(CellStopInfo));
482 /*******************************************************************
484 * @brief Handles DL CCCH Ind from DU APP
488 * Function : MacProcDlCcchInd
491 * Handles DL CCCH Ind from DU APP
493 * @params[in] Post structure pointer
494 * DL CCCH Ind pointer
495 * @return ROK - success
498 * ****************************************************************/
499 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
501 uint8_t ueId = 0, ueIdx = 0;
504 DlRlcBoInfo dlBoInfo;
505 memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
507 DU_LOG("\nDEBUG --> MAC : Handling DL CCCH IND");
509 GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
511 dlBoInfo.cellId = dlCcchIndInfo->cellId;
512 dlBoInfo.crnti = dlCcchIndInfo->crnti;
514 if(dlCcchIndInfo->msgType == RRC_SETUP)
516 dlBoInfo.lcId = SRB0_LCID; // SRB ID 0 for msg4
517 /* (MSG4 pdu + 3 bytes sub-header) + (Contention resolution id MAC CE + 1 byte sub-header) */
518 dlBoInfo.dataVolume = (dlCcchIndInfo->dlCcchMsgLen + 3) + (MAX_CRI_SIZE + 1);
520 /* storing Msg4 Pdu in raCb */
521 GET_UE_ID(dlBoInfo.crnti, ueId);
523 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
525 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
526 MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
527 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
528 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
530 for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
532 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
533 dlCcchIndInfo->dlCcchMsg[idx];
538 sendDlRlcBoInfoToSch(&dlBoInfo);
540 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
541 dlCcchIndInfo->dlCcchMsgLen);
542 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
547 /*******************************************************************
549 * @brief Sends UL CCCH Ind to DU APP
553 * Function : macProcUlCcchInd
556 * MAC sends UL CCCH Ind to DU APP
558 * @params[in] Post structure pointer
560 * @return ROK - success
563 * ****************************************************************/
564 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
568 UlCcchIndInfo *ulCcchIndInfo = NULLP;
570 MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
573 DU_LOG("\nERROR --> MAC: Memory failed in macProcUlCcchInd");
577 ulCcchIndInfo->cellId = cellId;
578 ulCcchIndInfo->crnti = crnti;
579 ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
580 ulCcchIndInfo->ulCcchMsg = rrcContainer;
583 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
585 if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
587 DU_LOG("\nERROR --> MAC: Failed to send UL CCCH Ind to DU APP");
588 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
589 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
595 /*******************************************************************
597 * @brief Processes received short BSR
601 * Function : macProcShortBsr
604 * MAC sends Short BSR to SCH
606 * @params[in] cell ID
611 * @return ROK - success
614 * ****************************************************************/
615 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
618 UlBufferStatusRptInd bsrInd;
620 memset(&pst, 0, sizeof(Pst));
621 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
623 bsrInd.cellId = cellId;
624 bsrInd.crnti = crnti;
625 bsrInd.bsrType = SHORT_BSR;
626 bsrInd.numLcg = 1; /* short bsr reports one lcg at a time */
627 bsrInd.dataVolInfo[0].lcgId = lcgId;
628 bsrInd.dataVolInfo[0].dataVol = bufferSize;
630 FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
631 return(SchMessageRouter(&pst, (void *)&bsrInd));
634 /*******************************************************************
636 * @brief Processes received short BSR
640 * Function : macProcShortBsr
643 * MAC sends Short BSR to SCH
645 * @params[in] cell ID
650 * @return ROK - success
653 * ****************************************************************/
654 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
655 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
658 UlBufferStatusRptInd bsrInd;
661 memset(&pst, 0, sizeof(Pst));
662 memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
664 bsrInd.cellId = cellId;
665 bsrInd.crnti = crnti;
666 bsrInd.bsrType = LONG_BSR;
667 bsrInd.numLcg = numLcg;
669 for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
670 memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
672 FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
673 return(SchMessageRouter(&pst, (void *)&bsrInd));
676 /*******************************************************************
678 * @brief Builds and send DL HARQ Indication to SCH
682 * Function : buildAndSendHarqInd
685 * Builds and send HARQ UCI Indication to SCH
687 * @params[in] harqInfo Pointer
691 * @return ROK - success
694 * ****************************************************************/
695 uint8_t buildAndSendHarqInd(HarqInfoF0F1 *harqInfo, uint8_t crnti, uint16_t cellIdx, SlotTimingInfo *slotInd)
697 uint16_t harqCounter=0;
700 memset(&pst, 0, sizeof(Pst));
701 memset(&dlHarqInd, 0, sizeof(DlHarqInd));
703 dlHarqInd.cellId = macCb.macCell[cellIdx]->cellId;
704 dlHarqInd.crnti = crnti;
705 dlHarqInd.slotInd.sfn = slotInd->sfn;
706 dlHarqInd.slotInd.slot = slotInd->slot;
707 dlHarqInd.numHarq = harqInfo->numHarq;
708 memset(dlHarqInd.harqPayload, 0, MAX_SR_BITS_IN_BYTES);
709 for(harqCounter = 0; harqCounter < harqInfo->numHarq; harqCounter++)
711 dlHarqInd.harqPayload[harqCounter] = harqInfo->harqValue[harqCounter];
715 FILL_PST_MAC_TO_SCH(pst, EVENT_DL_HARQ_IND_TO_SCH);
717 return SchMessageRouter(&pst, (void *)&dlHarqInd);
721 /*******************************************************************
723 * @brief Builds and send SR UCI Indication to SCH
727 * Function : buildAndSendSrInd
730 * Builds and send SR UCI Indication to SCH
732 * @params[in] SrUciIndInfo Pointer
734 * @return ROK - success
737 * ****************************************************************/
738 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
742 SrUciIndInfo srUciInd;
743 memset(&pst, 0, sizeof(Pst));
744 memset(&srUciInd, 0, sizeof(SrUciIndInfo));
746 GET_CELL_IDX(macUciInd->cellId, cellIdx);
747 srUciInd.cellId = macCb.macCell[cellIdx]->cellId;
748 srUciInd.crnti = crnti;
749 srUciInd.slotInd.sfn = macUciInd->slotInd.sfn;
750 srUciInd.slotInd.slot = macUciInd->slotInd.slot;
751 srUciInd.numSrBits++;
752 memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
755 FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
757 return(SchMessageRouter(&pst, (void *)&srUciInd));
760 /*******************************************************************
762 * @brief Processes UCI Indication from PHY
766 * Function : fapiMacUciInd
769 * Processes UCI Indication from PHY
771 * @params[in] Post Structure Pointer
772 * UCI Indication Pointer
773 * @return ROK - success
776 * ****************************************************************/
777 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
779 uint8_t pduIdx = 0, ret = ROK;
780 uint16_t nPdus = 0, crnti = 0, cellIdx = 0;
784 nPdus = macUciInd->numUcis;
787 switch(macUciInd->pdus[pduIdx].pduType)
791 case UCI_IND_PUCCH_F0F1:
794 DU_LOG("\nDEBUG --> MAC : Received HARQ UCI Indication\n");
795 GET_CELL_IDX(macUciInd->cellId, cellIdx);
796 buildAndSendHarqInd(&macUciInd->pdus[pduIdx].uci.uciPucchF0F1.harqInfo, macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti, cellIdx, &macUciInd->slotInd);
798 if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
800 DU_LOG("\nDEBUG --> MAC : Received SR UCI indication");
801 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti;
802 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)
845 uint8_t cfgIdx = 0, memberListIdx = 0, totalSliceCfgRecvd = 0;
847 if(macSliceCfgReq->listOfRrmPolicy)
849 for(cfgIdx = 0; cfgIdx<macSliceCfgReq->numOfRrmPolicy; cfgIdx++)
851 totalSliceCfgRecvd += macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem;
854 schSliceCfgReq->numOfConfiguredSlice = totalSliceCfgRecvd;
855 MAC_ALLOC(schSliceCfgReq->listOfSlices, schSliceCfgReq->numOfConfiguredSlice *sizeof(SchRrmPolicyOfSlice*));
856 if(schSliceCfgReq->listOfSlices == NULLP)
858 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
861 for(cfgIdx = 0; cfgIdx<schSliceCfgReq->numOfConfiguredSlice; cfgIdx++)
863 for(memberListIdx = 0; memberListIdx<macSliceCfgReq->listOfRrmPolicy[cfgIdx]->numOfRrmPolicyMem; memberListIdx++)
865 if(macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx])
868 MAC_ALLOC(schSliceCfgReq->listOfSlices[cfgIdx], sizeof(SchRrmPolicyOfSlice));
869 if(schSliceCfgReq->listOfSlices[cfgIdx] == NULLP)
871 DU_LOG("\nERROR --> MAC : Memory allocation failed in fillSliceCfgInfo");
875 memcpy(&schSliceCfgReq->listOfSlices[cfgIdx]->snssai, &macSliceCfgReq->listOfRrmPolicy[cfgIdx]->rRMPolicyMemberList[memberListIdx]->snssai, sizeof(Snssai));
877 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.maxRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.maxRatio;
878 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.minRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.minRatio;
879 schSliceCfgReq->listOfSlices[cfgIdx]->rrmPolicyRatioInfo.dedicatedRatio = macSliceCfgReq->listOfRrmPolicy[cfgIdx]->policyRatio.dedicatedRatio;
887 /*******************************************************************
889 * @brief Processes Slice Cfg Request recived from DU
893 * Function : MacProcSliceCfgReq
896 * Processes Processes Slice Cfg Request recived from DU
898 * @params[in] Post Structure Pointer
899 * MacSliceCfgReq *macSliceCfgReq;
900 * @return ROK - success
903 **********************************************************************/
904 uint8_t MacProcSliceCfgReq(Pst *pst, MacSliceCfgReq *macSliceCfgReq)
908 SchSliceCfgReq *schSliceCfgReq;
910 DU_LOG("\nINFO --> MAC : Received Slice Cfg request from DU APP");
913 MAC_ALLOC(schSliceCfgReq, sizeof(SchSliceCfgReq));
914 if(schSliceCfgReq == NULLP)
916 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceCfgReq");
921 if(fillSliceCfgInfo(schSliceCfgReq, macSliceCfgReq) == ROK)
923 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_CFG_REQ_TO_SCH);
924 ret = SchMessageRouter(&schPst, (void *)schSliceCfgReq);
927 freeMacSliceCfgReq(macSliceCfgReq, pst);
931 DU_LOG("\nINFO --> MAC : Received MacSliceCfgReq is NULL");
936 /*******************************************************************
938 * @brief Processes Slice ReCfg Request recived from DU
942 * Function : MacProcSliceRecfgReq
945 * Processes Processes Slice ReCfg Request recived from DU
947 * @params[in] Post Structure Pointer
948 * MacSliceCfgReq *macSliceRecfgReq;
949 * @return ROK - success
952 **********************************************************************/
953 uint8_t MacProcSliceRecfgReq(Pst *pst, MacSliceRecfgReq *macSliceRecfgReq)
957 SchSliceRecfgReq *schSliceRecfgReq;
959 DU_LOG("\nINFO --> MAC : Received Slice ReCfg request from DU APP");
962 MAC_ALLOC(schSliceRecfgReq, sizeof(SchSliceRecfgReq));
963 if(schSliceRecfgReq == NULLP)
965 DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcSliceRecfgReq");
970 if(fillSliceCfgInfo(schSliceRecfgReq, macSliceRecfgReq) == ROK)
972 FILL_PST_MAC_TO_SCH(schPst, EVENT_SLICE_RECFG_REQ_TO_SCH);
973 ret = SchMessageRouter(&schPst, (void *)schSliceRecfgReq);
976 freeMacSliceCfgReq(macSliceRecfgReq, pst);
980 DU_LOG("\nINFO --> MAC : Received MacSliceRecfgReq is NULL");
985 /**********************************************************************
987 **********************************************************************/