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 /* This file contains UE management handling functionality for MAC */
21 /* header include files (.h) */
22 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "mac_sch_interface.h"
27 #include "lwr_mac_upr_inf.h"
29 #include "mac_utils.h"
31 MacDuUeCreateRspFunc macDuUeCreateRspOpts[] =
33 packDuMacUeCreateRsp, /* packing for loosely coupled */
34 DuProcMacUeCreateRsp, /* packing for tightly coupled */
35 packDuMacUeCreateRsp /* packing for light weight loosly coupled */
38 MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] =
40 packDuMacUeRecfgRsp, /* packing for loosely coupled */
41 DuProcMacUeRecfgRsp, /* packing for tightly coupled */
42 packDuMacUeRecfgRsp /* packing for light weight loosly coupled */
45 MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] =
47 packDuMacUeDeleteRsp, /* packing for loosely coupled */
48 DuProcMacUeDeleteRsp, /* packing for tightly coupled */
49 packDuMacUeDeleteRsp /* packing for light weight loosly coupled */
52 MacDuUeResetRspFunc macDuUeResetRspOpts[] =
54 packDuMacUeResetRsp, /* packing for loosely coupled */
55 DuProcMacUeResetRsp, /* packing for tightly coupled */
56 packDuMacUeResetRsp /* packing for light weight loosly coupled */
59 MacDuUeSyncStatusIndFunc macDuUeSyncStatusIndOpts[] =
61 packDuMacUeSyncStatusInd, /* packing for loosely coupled */
62 DuProcMacUeSyncStatusInd, /* packing for tightly coupled */
63 packDuMacUeSyncStatusInd /* packing for light weight loosly coupled */
66 /*******************************************************************
68 * @brief Fill and Send UE Sync Status Indication from MAC to DU APP
72 * Function : MacSendUeSyncStatusInd
74 * Functionality: Fill and Send UE Sync Status Indication from MAC to DUAPP
76 * @params[in] uint16_t cellId, uint16_t ueId, SyncStatus status
77 * @return ROK - success
80 * ****************************************************************/
82 uint8_t MacSendUeSyncStatusInd(uint16_t cellId, uint16_t ueId, SyncStatus status)
84 MacUeSyncStatusInd *ueSyncStatusInd;
87 MAC_ALLOC_SHRABL_BUF(ueSyncStatusInd, sizeof(MacUeSyncStatusInd));
90 DU_LOG("\nERROR --> MAC : Memory allocation for UE Sync Status Indication failed");
94 /* Filling UE Sync Status Indication */
95 ueSyncStatusInd->cellId = cellId;
96 ueSyncStatusInd->ueId = ueId;
97 ueSyncStatusInd->status = status;
99 /* Fill Post structure and send UE Sync Status Indication */
100 memset(&rspPst, 0, sizeof(Pst));
101 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_SYNC_STATUS_IND);
102 return (*macDuUeSyncStatusIndOpts[rspPst.selector])(&rspPst, ueSyncStatusInd);
105 /*******************************************************************
107 * @brief Fills mac cell group config to be sent to scheduler
111 * Function : fillMacCellGroupCfg
113 * Functionality: Fills mac cell group config to be sent to sch
115 * @params[in] macCellGrp : mac cell group config at MAC
116 * *macCellGrpCfg : mac cell group cfg to be filled
117 * @return ROK - success
120 * ****************************************************************/
121 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
124 SchSchedReqCfg *schedReqCfg;
127 /* Copy scheduling request config */
128 schedReqCfg = &macCellGrpCfg->schedReqCfg;
129 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
130 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
132 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
133 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
136 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
138 schedReqCfg->addModList[idx].schedReqId = \
139 macCellGrp.schReqCfg.addModList[idx].schedReqId;
140 schedReqCfg->addModList[idx].srProhibitTmr = \
141 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
142 schedReqCfg->addModList[idx].srTransMax = \
143 macCellGrp.schReqCfg.addModList[idx].srTransMax;
145 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
147 /* copy TAG config */
148 tagCfg = &macCellGrpCfg->tagCfg;
149 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
150 if(tagCfg->addModListCount > MAX_NUM_TAGS)
152 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
153 tagCfg->addModListCount, MAX_NUM_TAGS);
156 for(idx = 0; idx < tagCfg->addModListCount; idx++)
158 tagCfg->addModList[idx].tagId = \
159 macCellGrp.tagCfg.addModList[idx].tagId;
160 tagCfg->addModList[idx].timeAlignmentTmr = \
161 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
163 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
165 /* Copy PHR config */
166 if(macCellGrp.phrCfgSetupPres)
168 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
169 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
170 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
171 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
172 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
173 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
174 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
178 /* Copy Drx configuration */
179 macCellGrpCfg->drxCfgPresent = true;
180 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
181 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
182 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
183 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
185 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
186 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
187 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
188 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
189 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
190 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
191 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
192 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
193 drxLongCycleStartOffsetChoice;
194 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
195 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
196 if(macCellGrpCfg->drxCfg.shortDrxPres)
198 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
199 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
201 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
206 /*******************************************************************
208 * @brief Fills phy cell group config to be sent to scheduler
212 * Function : fillPhyCellGroupCfg
214 * Functionality: Fills phy cell group config to be sent to sch
216 * @params[in] macUeCfg : Phy cell group config at MAC
217 * *schPhyCellGrp : phy cell group config to be filled
218 * @return ROK - success
221 * ****************************************************************/
222 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
224 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
225 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
230 /*******************************************************************
232 * @brief Fills PDSCh serving cell config to send to scheduler
236 * Function : fillPdschServCellCfg
238 * Functionality: Fills PDSCh serving cell config to send to scheduler
240 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
241 * *schPdschCfg : Pdsch serving cell config to be filled
242 * @return ROK - success
245 * ****************************************************************/
246 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
248 if(macPdschCfg.maxMimoLayers)
250 if(!schPdschCfg->maxMimoLayers)
252 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
253 if(!schPdschCfg->maxMimoLayers)
255 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
259 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
263 schPdschCfg->maxMimoLayers = NULLP;
266 schPdschCfg->numHarqProcForPdsch = \
267 macPdschCfg.numHarqProcForPdsch;
269 if(macPdschCfg.maxCodeBlkGrpPerTb)
271 if(!schPdschCfg->maxCodeBlkGrpPerTb)
273 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
274 if(!schPdschCfg->maxCodeBlkGrpPerTb)
276 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
280 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
284 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
287 if(macPdschCfg.codeBlkGrpFlushInd)
289 if(!schPdschCfg->codeBlkGrpFlushInd)
291 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
292 if(!schPdschCfg->codeBlkGrpFlushInd)
294 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
298 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
302 schPdschCfg->codeBlkGrpFlushInd = NULLP;
305 if(macPdschCfg.xOverhead)
307 if(!schPdschCfg->xOverhead)
309 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
310 if(!schPdschCfg->xOverhead)
312 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
316 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
320 schPdschCfg->xOverhead = NULLP;
326 /*******************************************************************
328 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
332 * Function : fillInitalUlBwpPuschCfg
335 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
337 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
338 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
339 * @return ROK - success
342 * ****************************************************************/
343 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
347 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
348 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
349 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
350 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
351 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
352 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
354 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
355 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
357 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
358 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
361 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
363 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
364 macPuschCfg.timeDomRsrcAllocList[idx].k2;
365 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
366 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
367 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
368 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
369 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
370 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
373 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
377 /*******************************************************************
379 * @brief Function to fillResrcSetList sent by DU
383 * Function : fillResrcSetList
385 * Functionality: Function to fillResrcSetList sent by DU
387 * @params[in] PucchResrcSetCfg pointer,
388 * SchPucchResrcSetCfg pointer
391 * ****************************************************************/
393 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
395 uint8_t arrIdx, rsrcListIdx;
397 /* ResrcSetToAddModList */
398 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
399 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
401 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
402 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
404 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
405 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
407 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
408 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
409 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
410 resrcListCount; rsrcListIdx++)
412 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
413 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
416 /* ResrcSetToRelList */
417 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
418 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
420 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
424 /*******************************************************************
426 * @brief Function to fillResrcList sent by DU
430 * Function : fillResrcList
432 * Functionality: Function to fillResrcList sent by DU
434 * @params[in] PucchResrcCfg pointer,
435 * SchPucchResrcCfg pointer
436 * @return ROK/RFAILED;
438 * ****************************************************************/
439 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
443 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
444 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
446 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
447 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
448 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
449 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
450 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
451 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
452 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
453 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
454 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
455 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
456 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
458 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
459 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
461 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
464 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
465 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
466 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
467 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
468 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
469 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
472 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
474 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
475 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
477 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
480 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
481 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
482 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
483 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
484 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
485 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
486 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
487 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
490 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
492 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
493 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
495 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
498 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
499 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
500 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
501 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
502 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
503 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
506 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
508 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
509 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
511 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
514 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
515 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
516 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
517 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
518 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
519 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
522 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
524 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
525 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
527 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
530 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
531 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
532 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
533 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
534 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
535 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
536 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
537 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
543 /*******************************************************************
545 * @brief Function to fillPucchFormatCfg sent by DU
549 * Function : fillPucchFormatCfg
551 * Functionality: Function to fillPucchFormatCfg
553 * @params[in] PucchFormatCfg pointer,
554 * SchPucchFormatCfg pointer
557 * ****************************************************************/
559 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
561 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
562 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
563 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
564 schFormatCfg->numSlots = macFormatCfg->numSlots;
565 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
566 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
569 /*******************************************************************
571 * @brief Function to fillPucchSchedReqCfg sent by DU
575 * Function : fillPucchSchedReqCfg
577 * Functionality: Function to fillPucchSchedReqCfg
579 * @params[in] PucchSchedReqCfg pointer,
580 * SchPucchSchedReqCfg pointer
583 * ****************************************************************/
584 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
588 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
589 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
591 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
592 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
593 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
594 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
595 schSchedReqCfg->schedAddModList[arrIdx].offset =\
596 macSchedReqCfg->schedAddModList[arrIdx].offset;
597 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
598 macSchedReqCfg->schedAddModList[arrIdx].resrc;
600 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
601 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
603 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
607 /*******************************************************************
609 * @brief Function to fillMultiCsiCfg sent by DU
613 * Function : fillMultiCsiCfg
615 * Functionality: Function to fillMultiCsiCfg
617 * @params[in] PucchMultiCsiCfg pointer,
618 * SchPucchMultiCsiCfg pointer
621 * ****************************************************************/
623 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
627 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
628 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
630 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
634 /*******************************************************************
636 * @brief Function to fillDlToUlAck sent by DU
640 * Function : fillDlToUlAck
642 * Functionality: Function to fillDlToUlAck
644 * @params[in] PucchDlDataToUlAck pointer,
645 * SchPucchDlDataToUlAck pointer
648 * ****************************************************************/
650 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
654 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
655 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
657 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
661 /*******************************************************************
663 * @brief Function to fillPucchPowerControl sent by DU
667 * Function : fillPucchPowerControl
669 * Functionality: Function to fillPucchPowerControl
671 * @params[in] PucchPowerControl pointer,
672 * SchPucchPowerControl pointer
675 * ****************************************************************/
677 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
681 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
682 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
683 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
684 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
685 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
686 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
687 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
689 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
690 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
692 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
693 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
695 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
696 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
700 /*******************************************************************
702 * @brief Function to fillOtherPucchFormatCfg sent by DU
706 * Function : fillOtherPucchFormatCfg
708 * Functionality: Function to fillOtherPucchFormatCfg
710 * @params[in] PucchFormat
711 * PucchFormatCfg pointer,
712 * SchPucchCfg pointer
715 * ****************************************************************/
717 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
726 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
727 if(schPucchCfg->format1 == NULLP)
729 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
732 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
740 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
741 if(schPucchCfg->format2 == NULLP)
743 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
746 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
754 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
755 if(schPucchCfg->format3 == NULLP)
757 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
760 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
768 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
769 if(schPucchCfg->format4 == NULLP)
771 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
774 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
779 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
785 /*******************************************************************
787 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
791 * Function : fillInitalUlBwpPucchCfg
794 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
796 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
797 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
798 * @return ROK - success
801 * ****************************************************************/
802 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
804 if(macPucchCfg->resrcSet)
806 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
807 if(schPucchCfg->resrcSet == NULLP)
809 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
812 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
813 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
816 if(macPucchCfg->resrc)
818 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
819 if(schPucchCfg->resrc == NULLP)
821 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
824 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
825 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
827 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
832 /* valid for format 1, 2, 3, 4 */
833 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
834 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
835 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
836 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
838 if(macPucchCfg->schedReq)
840 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
841 if(schPucchCfg->schedReq == NULLP)
843 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
846 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
847 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
850 if(macPucchCfg->multiCsiCfg)
852 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
853 if(schPucchCfg->multiCsiCfg == NULLP)
855 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
858 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
859 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
862 //TODO: To add the support for spatial Config
863 schPucchCfg->spatialInfo = NULLP;
865 if(macPucchCfg->dlDataToUlAck)
867 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
868 if(schPucchCfg->dlDataToUlAck == NULLP)
870 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
873 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
874 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
878 if(macPucchCfg->powerControl)
880 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
881 if(schPucchCfg->powerControl == NULLP)
883 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
886 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
887 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
893 /*******************************************************************
895 * @brief function to free Pucch Format
899 * Function : freeSchPucchFormat
902 * function to free Pucch Format
904 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
905 * SchPucchResrcInfo pointer
907 * ****************************************************************/
909 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
913 case PUCCH_FORMAT_0 :
914 if(resrcInfo->SchPucchFormat.format0)
916 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
917 resrcInfo->SchPucchFormat.format0 = NULLP;
921 case PUCCH_FORMAT_1 :
922 if(resrcInfo->SchPucchFormat.format1)
924 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
925 resrcInfo->SchPucchFormat.format1 = NULLP;
929 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
930 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
934 case PUCCH_FORMAT_2 :
935 if(resrcInfo->SchPucchFormat.format2)
937 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
938 resrcInfo->SchPucchFormat.format2 = NULLP;
942 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
943 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
947 case PUCCH_FORMAT_3 :
948 if(resrcInfo->SchPucchFormat.format3)
950 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
951 resrcInfo->SchPucchFormat.format3 = NULLP;
955 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
956 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
960 case PUCCH_FORMAT_4 :
961 if(resrcInfo->SchPucchFormat.format4)
963 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
964 resrcInfo->SchPucchFormat.format4 = NULLP;
968 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
969 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
978 /*******************************************************************
980 * @brief function to free Pucch Resrc Cfg
984 * Function : freePucchResrcCfg
987 * function to free Pucch Resrc Cfg
989 * @params[in] SchPucchResrcCfg pointer,
991 * ****************************************************************/
993 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
997 /* free Resrc To AddMod List */
998 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
1000 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
1001 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
1002 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
1004 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
1005 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
1008 /*******************************************************************
1010 * @brief function to free Pucch Sched Req Cfg
1014 * Function : freePucchSchedReqCfg
1017 * function to free Pucch Sched Req Cfg
1019 * @params[in] SchPucchSchedReqCfg pointer,
1021 * ****************************************************************/
1023 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
1025 uint8_t schedReqIdx;
1027 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
1029 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
1031 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
1032 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
1035 /*******************************************************************
1037 * @brief function to free Ul Bwp Pucch Cfg
1041 * Function : freeUlBwpPucchCfg
1044 * function to free Ul Bwp Pucch Cfg
1046 * @params[in] SchPucchCfg pointer,
1048 * ****************************************************************/
1050 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1052 if(schPucchCfg->resrcSet)
1054 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1055 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1057 if(schPucchCfg->resrc)
1059 freePucchResrcCfg(schPucchCfg->resrc);
1061 if(schPucchCfg->format1)
1063 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1065 if(schPucchCfg->format2)
1067 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1069 if(schPucchCfg->format3)
1071 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1073 if(schPucchCfg->format4)
1075 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1077 if(schPucchCfg->schedReq)
1079 freePucchSchedReqCfg(schPucchCfg->schedReq);
1081 if(schPucchCfg->spatialInfo)
1083 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1084 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1086 if(schPucchCfg->multiCsiCfg)
1088 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1089 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1091 if(schPucchCfg->dlDataToUlAck)
1093 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1094 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1096 if(schPucchCfg->powerControl)
1098 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1099 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1103 /*******************************************************************
1105 * @brief Fills initail UL BWP config to send to scheduler
1109 * Function : fillInitialUlBwp
1111 * Functionality: Fills initail UL BWP config to send to sch
1113 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1114 * schInitUlBwp : Initial UL BWP cfg to be filled
1115 * @return ROK - success
1118 * ****************************************************************/
1119 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1121 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1122 if(schInitUlBwp->pucchCfgPres)
1124 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1125 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1127 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1128 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1132 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1133 if(schInitUlBwp->puschCfgPres)
1135 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1136 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1138 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1145 /*******************************************************************
1147 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1151 * Function : fillInitDlBwpPdcchCfg
1154 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1156 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1157 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1158 * @return ROK - success
1161 * ****************************************************************/
1162 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1166 /* Fill CORESET info */
1167 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1168 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1170 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1171 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1175 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1177 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1178 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1179 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1180 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1181 schPdcchCfg->cRSetToAddModList[idx].duration = \
1182 macPdcchCfg.cRSetToAddModList[idx].duration;
1183 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1184 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1185 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1186 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1187 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1188 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1191 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1192 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1194 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1195 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1199 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1204 /* Fill Search space info */
1205 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1206 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1208 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1209 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1212 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1214 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1215 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1216 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1217 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1218 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1219 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1220 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1221 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1222 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1223 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1224 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1225 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1226 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1227 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1228 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1229 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1230 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1231 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1232 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1233 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1234 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1235 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1236 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1239 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1240 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1242 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1243 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1246 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1254 /*******************************************************************
1256 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1260 * Function : fillInitDlBwpPdschCfg
1263 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1265 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1266 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1267 * @return ROK - success
1270 * ****************************************************************/
1271 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1275 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1276 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1277 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1278 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1279 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1281 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1282 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1286 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1288 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1290 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1291 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1293 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1296 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1298 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1299 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1300 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1301 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1302 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1303 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1306 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1307 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1308 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1309 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1311 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1313 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1315 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1316 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1321 /*******************************************************************
1323 * @brief Fill Initial DL BWP for SCH UE config
1327 * Function : fillInitialDlBwp
1329 * Functionality: Fill Initial DL BWP for SCH UE config
1331 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1332 * schInitDlBwp : Inital DL BWP cfg to be filled
1333 * @return ROK - success
1336 * ****************************************************************/
1337 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1339 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1340 if(schInitDlBwp->pdcchCfgPres)
1342 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1344 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1349 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1350 if(schInitDlBwp->pdschCfgPres)
1352 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1354 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1361 /*******************************************************************
1363 * @brief Fills Sp Cell config to be sent to scheduler
1367 * Function : fillSpCellCfg
1369 * Functionality: Fills Sp Cell config to be sent to scheduler
1371 * @params[in] macSpCellCfg : SP cell cfg at MAC
1372 * schSpCellCfg : SP cell cfg to be filled
1373 * @return ROK - success
1376 * ****************************************************************/
1377 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1380 SchServCellCfgInfo *servCellCfg;
1382 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1383 servCellCfg = &schSpCellCfg->servCellCfg;
1385 /* Fill initial DL BWP */
1386 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1387 &servCellCfg->initDlBwp) != ROK )
1389 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1393 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1394 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1396 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD [%d] exceeds max limit [%d]",\
1397 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1400 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1402 memcpy(&servCellCfg->dlBwpToAddList[idx], &macSpCellCfg.servCellCfg.dlBwpToAddList[idx], sizeof(DlBwpInfo));
1404 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1405 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1406 servCellCfg->bwpInactivityTmr = NULL;
1407 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1409 /* TODO : This is an optional parameter, not filled currently */
1412 /* Fill PDSCH serving cell config */
1413 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1414 &servCellCfg->pdschServCellCfg) != ROK)
1416 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1420 /* Fill Initail UL BWP */
1421 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1422 &servCellCfg->initUlBwp) != ROK)
1424 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1428 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1429 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1431 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD [%d] exceeds max limit [%d]",\
1432 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1435 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1437 memcpy(&servCellCfg->ulBwpToAddList[idx], &macSpCellCfg.servCellCfg.ulBwpToAddList[idx], sizeof(UlBwpInfo));
1439 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1444 /*******************************************************************
1446 * @brief Fills Sp Cell Reconfig to be sent to scheduler
1450 * Function : fillSpCellRecfg
1452 * Functionality: Fills Sp Cell Reconfig to be sent to scheduler
1454 * @params[in] macSpCellRecfg : SP cell Recfg at MAC
1455 * schSpCellRecfg : SP cell Recfg to be filled
1456 * @return ROK - success
1459 * ****************************************************************/
1460 uint8_t fillSpCellRecfg(SpCellRecfg macSpCellRecfg, SchSpCellRecfg *schSpCellRecfg)
1463 SchServCellRecfgInfo *servCellRecfg;
1465 schSpCellRecfg->servCellIdx = macSpCellRecfg.servCellIdx;
1466 servCellRecfg = &schSpCellRecfg->servCellRecfg;
1468 /* Fill initial DL BWP */
1469 if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
1470 &servCellRecfg->initDlBwp) != ROK )
1472 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1476 servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
1477 if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
1479 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1480 servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
1483 for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
1485 memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
1487 servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
1488 if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
1490 DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
1491 servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
1494 for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
1496 memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
1498 servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
1499 servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
1500 servCellRecfg->bwpInactivityTmr = NULL;
1501 if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
1503 /* TODO : This is an optional parameter, not filled currently */
1506 /* Fill PDSCH serving cell config */
1507 if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
1508 &servCellRecfg->pdschServCellCfg) != ROK)
1510 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1514 /* Fill Initail UL BWP */
1515 if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
1516 &servCellRecfg->initUlBwp) != ROK)
1518 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1522 servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
1523 if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
1525 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1526 servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
1529 for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
1531 memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
1533 servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
1534 if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
1536 DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
1537 servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
1540 for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
1542 memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
1544 servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
1549 /*******************************************************************
1551 * @brief Sends UE configuration to Scheduler
1555 * Function : sendUeReqToSch
1557 * Functionality: sends UE configuration to Scheduler
1559 * @params[in] Pst and Ue configuration
1560 * @return ROK - success
1563 * ****************************************************************/
1565 uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
1570 case EVENT_MAC_UE_CREATE_REQ:
1572 SchUeCfgReq *schUeCfgReq = NULLP;
1573 schUeCfgReq = (SchUeCfgReq *)schUeCfg;
1574 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1575 return(SchMessageRouter(&schPst, (void *)schUeCfgReq));
1577 case EVENT_MAC_UE_RECONFIG_REQ:
1579 SchUeRecfgReq *schUeRecfgReq = NULLP;
1580 schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
1581 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1582 return(SchMessageRouter(&schPst, (void *)schUeRecfgReq));
1586 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1592 /*******************************************************************
1594 * @brief Fills Sch Drb Qos Information
1598 * Function : fillSchDrbQosInfo
1600 * Functionality: Fills Sch Drb Qos Information
1602 * @params[in] macLcCfg : Logical channel Cfg at MAC
1603 * schLcCfg : LC cfg to fill at scheduler
1604 * @return ROK - success
1607 * ****************************************************************/
1608 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1610 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1611 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1613 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1614 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1615 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1616 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1618 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1620 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1621 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1622 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1623 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1624 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1625 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1626 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1627 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1629 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1630 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1631 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1632 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1633 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1634 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1635 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1636 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1637 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1640 /*******************************************************************
1642 * @brief Fill SCH UL logical channel configuration
1646 * Function : fillSchUlLcCfg
1648 * Functionality: Fills Sch Ul Lc configuration
1650 * @params[in] macLcCfg : Logical channel Cfg at MAC
1651 * schLcCfg : LC cfg to fill at scheduler
1654 * ****************************************************************/
1656 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1658 schUlLcCfg->priority= macUlLcCfg->priority;
1659 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1660 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1661 schUlLcCfg->pbr = macUlLcCfg->pbr;
1662 schUlLcCfg->bsd = macUlLcCfg->bsd;
1665 /*******************************************************************
1667 * @brief Fill logical channel configuration
1671 * Function : fillLogicalChannelCfg
1673 * Functionality: Fill logical channel configuration
1675 * @params[in] macLcCfg : Logical channel Cfg at MAC
1676 * schLcCfg : LC cfg to fill at scheduler
1677 * @return ROK - success
1680 * ****************************************************************/
1681 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1685 schLcCfg->lcId = macLcCfg->lcId;
1686 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1687 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1689 if(macLcCfg->drbQos)
1691 if(!schLcCfg->drbQos)
1693 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1694 if(!schLcCfg->drbQos)
1696 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1702 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1709 schLcCfg->drbQos = NULLP;
1714 if(macLcCfg->snssai)
1716 if(!schLcCfg->snssai)
1718 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1719 if(!schLcCfg->snssai)
1721 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1727 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1728 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1730 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1736 schLcCfg->snssai = NULLP;
1743 /*******************************************************************
1745 * @brief Fills Logical channel Cfg List to Add
1749 * Function : fillSchLcCfgList
1751 * Functionality: Fills Logical channel Cfg List to Add
1753 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1754 * @return ROK - success
1757 * ****************************************************************/
1759 uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
1763 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1765 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1767 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1770 schUeCfg->numLcsToAdd++;
1775 /*******************************************************************
1777 * @brief Fills Logical channel Recfg List to Add/Mod/Del
1781 * Function : fillSchLcRecfgList
1783 * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
1785 * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
1786 * @return ROK - success
1789 * ****************************************************************/
1791 uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1796 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
1798 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
1800 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1803 schUeRecfg->numLcsToAdd++;
1806 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
1808 schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
1809 schUeRecfg->numLcsToDel++;
1812 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
1814 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
1816 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1819 schUeRecfg->numLcsToMod++;
1824 /*******************************************************************
1826 * @brief Fills and sends UE configuration to Scheduler
1830 * Function : fillSchUeCfg
1832 * Functionality: Fills and sends UE configuration to Scheduler
1834 * @params[in] Ue configuration from DU APP
1835 * @return ROK - success
1838 * ****************************************************************/
1839 uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
1843 schUeCfg->cellId = ueCfg->cellId;
1844 schUeCfg->crnti = ueCfg->crnti;
1845 /* Copy MAC cell group config */
1846 if(ueCfg->macCellGrpCfgPres == true)
1848 schUeCfg->macCellGrpCfgPres = true;
1849 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1850 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1852 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1856 if(ueCfg->phyCellGrpCfgPres == true)
1858 schUeCfg->phyCellGrpCfgPres = true;
1859 /* Copy Physical cell group config */
1860 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1861 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1863 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1868 if(ueCfg->spCellCfgPres == true)
1870 schUeCfg->spCellCfgPres = true;
1871 /* Copy sp cell config */
1872 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1873 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1875 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1879 if(ueCfg->ambrCfg != NULLP)
1881 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1882 if(!schUeCfg->ambrCfg)
1884 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1887 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1891 schUeCfg->ambrCfg = NULLP;
1893 /* Fill DL modulation infor */
1894 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1895 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1896 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1898 /* Fill UL modulation infor */
1899 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1900 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1901 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1903 /* Fill sch Lc Cfg to Add*/
1904 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1907 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1914 /*******************************************************************
1916 * @brief Fills and sends UE Re-configuration to Scheduler
1920 * Function : fillSchUeRecfg
1922 * Functionality: Fills and sends UE Reconfiguration to Scheduler
1924 * @params[in] Ue configuration from DU APP
1925 * @return ROK - success
1928 * ****************************************************************/
1929 uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1933 schUeRecfg->cellId = ueRecfg->cellId;
1934 schUeRecfg->crnti = ueRecfg->crnti;
1935 schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
1936 /* Copy MAC cell group config */
1937 if(ueRecfg->macCellGrpRecfgPres == true)
1939 schUeRecfg->macCellGrpRecfgPres = true;
1940 memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
1941 if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
1943 DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
1947 if(ueRecfg->phyCellGrpRecfgPres == true)
1949 schUeRecfg->phyCellGrpRecfgPres = true;
1950 /* Copy Physical cell group config */
1951 memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
1952 if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
1954 DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
1959 if(ueRecfg->spCellRecfgPres == true)
1961 schUeRecfg->spCellRecfgPres = true;
1962 /* Copy sp cell config */
1963 memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
1964 if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
1966 DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
1970 if(ueRecfg->ambrRecfg != NULLP)
1972 MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
1973 if(!schUeRecfg->ambrRecfg)
1975 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1978 schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
1982 schUeRecfg->ambrRecfg = NULLP;
1984 /* Fill DL modulation infor */
1985 schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
1986 schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
1987 schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
1989 /* Fill UL modulation infor */
1990 schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
1991 schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
1992 schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
1994 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1995 ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
1998 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
2003 schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
2009 /*******************************************************************
2011 * @brief Update UeUlCb Lc List
2015 * Function : updateMacUlCb
2017 * Functionality: Update UeUlCb Lc List
2019 * @params[in] delIdx, UeUlCb pointer
2022 * ****************************************************************/
2024 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
2028 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
2030 /* Moving the array element to one step ahead */
2031 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
2032 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
2034 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2036 /*Checking the Memory Leakage of Last Index*/
2037 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
2039 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
2041 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
2045 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
2051 /*******************************************************************
2053 * @brief Update UeDlCb Lc List
2057 * Function : updateMacDlCb
2059 * Functionality: Update UeDlCb Lc List
2061 * @params[in] delIdx, UeDlCb pointer
2064 * ****************************************************************/
2066 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
2070 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
2072 /* Moving the array element to one step ahead */
2073 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
2074 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
2076 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2078 /*Checking the Memory Leakage of Last Index*/
2079 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
2081 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
2083 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
2087 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
2093 /*******************************************************************
2095 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
2099 * Function : updateMacUlLcCtxt
2101 * Functionality: Update UeUlCb Lc List
2103 * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
2104 * ueLcCfg(received from DUAPP)
2105 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2108 * ****************************************************************/
2109 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2111 uint8_t ueLcIdx = 0;
2113 /*Traversing UL LC to be updated/Deleted*/
2114 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
2116 if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2118 /*Modify UL LC CB */
2119 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
2121 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2123 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2126 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2130 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
2132 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2135 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2138 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2139 ueLcCfg->lcId,ueLcIdx);
2142 else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2144 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
2145 (ulInfo->numUlLc)--;
2146 updateMacUlCb(ueLcIdx, ulInfo);
2147 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2153 /*******************************************************************
2155 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
2159 * Function : updateMacDlLcCtxt
2161 * Functionality: Update UeDlCb Lc List
2163 * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
2164 * ueLcCfg(received from DUAPP)
2165 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2168 * ****************************************************************/
2169 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2171 uint8_t ueLcIdx = 0;
2173 /*Traversing DL LC to be updated/Deleted*/
2174 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
2176 if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2178 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2180 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2183 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2187 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
2189 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2192 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2195 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2196 ueLcCfg->lcId,ueLcIdx);
2199 else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2201 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
2202 (dlInfo->numDlLc)--;
2203 updateMacDlCb(ueLcIdx, dlInfo);
2204 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2210 /*******************************************************************
2212 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2216 * Function : fillMacLcCfgList
2218 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2220 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2221 * @return ROK - success
2224 * ****************************************************************/
2226 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCreateReq *ueCfg)
2230 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
2232 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2234 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2236 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2237 if(ueCfg->lcCfgList[lcIdx].drbQos)
2239 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2240 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2242 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2243 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2245 if(ueCfg->lcCfgList[lcIdx].snssai)
2247 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2249 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2251 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2253 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2256 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2257 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2259 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2260 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2264 /*Filling DL LC CB */
2265 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2266 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2267 ueCb->dlInfo.numDlLc++;
2268 /*Filling UL LC CB */
2269 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2270 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
2271 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2272 ueCb->ulInfo.numUlLc++;
2278 /*******************************************************************
2280 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2284 * Function : updateMacLcCfgList
2286 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2288 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2289 * @return ROK - success
2292 * ****************************************************************/
2294 uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2298 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
2300 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2302 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2304 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2305 if(ueRecfg->lcCfgList[lcIdx].drbQos)
2307 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2308 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2310 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2311 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2313 if(ueRecfg->lcCfgList[lcIdx].snssai)
2315 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2317 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2319 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2321 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2324 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2325 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2327 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2328 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2332 /*Filling DL LC CB */
2333 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2334 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2335 ueCb->dlInfo.numDlLc++;
2336 /*Filling UL LC CB */
2337 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2338 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
2339 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2340 ueCb->ulInfo.numUlLc++;
2341 }/*End of Add Config */
2343 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
2345 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2347 updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2348 updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2351 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
2353 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2355 updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2356 updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2362 /*******************************************************************
2364 * @brief Fills MAC UE Cb Cfg
2368 * Function : fillMacUeCb
2370 * Functionality: Fills MAC UE Cb Cfg
2372 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2374 * @return ROK - success
2377 * ****************************************************************/
2379 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCreateReq *ueCfg, uint8_t cellIdx)
2383 ueCb->ueId = ueCfg->ueId;
2384 ueCb->crnti = ueCfg->crnti;
2385 ueCb->cellCb = macCb.macCell[cellIdx];
2386 if(ueCfg->spCellCfgPres)
2388 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2389 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2392 /*TODO: To check the bsr value during implementation */
2393 if(ueCfg->macCellGrpCfgPres)
2395 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2396 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2397 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2399 ret = fillMacLcCfgList(ueCb, ueCfg);
2402 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2407 /*******************************************************************
2409 * @brief Fills MAC UE Cb Cfg
2413 * Function : updateMacUeCb
2415 * Functionality: updateMacUeCbs MAC UE Cb Cfg
2417 * @params[in] MAC UE Cb Recfg , MAC UE Configuration
2419 * @return ROK - success
2422 * ****************************************************************/
2424 uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
2428 ueCb->ueId = ueRecfg->ueId;
2429 ueCb->crnti = ueRecfg->crnti;
2430 ueCb->cellCb = macCb.macCell[cellIdx];
2431 if(ueRecfg->spCellRecfgPres)
2433 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2434 ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2437 /*TODO: To check the bsr value during implementation */
2438 if(ueRecfg->macCellGrpRecfgPres)
2440 ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
2441 ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
2442 ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
2444 ret = updateMacLcCfgList(ueCb, ueRecfg);
2447 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
2449 ueCb->transmissionAction = ueRecfg->transmissionAction;
2454 /*******************************************************************
2456 * @brief Function to update Mac Ra Cb
2460 * Function : updateMacRaCb
2462 * Functionality: Function to update Mac Ra Cb
2464 * @params[in] cellIdx, Mac Ue Cb
2465 * @return ROK - success
2468 * ****************************************************************/
2470 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2473 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2475 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2479 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2485 /*******************************************************************
2487 * @brief Function to delete Mac Ra Cb
2491 * Function : deleteMacRaCb
2493 * Functionality: Function to delete Mac Ra Cb
2495 * @params[in] cellIdx, Mac Ue Cb
2498 * ****************************************************************/
2500 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2503 MacRaCbInfo *raCb = ueCb->raCb;
2505 if(raCb && (raCb->crnti == ueCb->crnti))
2507 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2508 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2510 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2511 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2513 memset(raCb, 0, sizeof(MacRaCbInfo));
2517 /*******************************************************************
2519 * @brief Creates UE Cb
2523 * Function : createUeCb
2525 * Functionality: Creates UE Cb
2527 * @params[in] MAC UE Configuration
2528 * @return ROK - success
2531 * ****************************************************************/
2532 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCreateReq *ueCfg)
2535 uint8_t hqProcIdx = 0;
2537 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2538 &&(ueCb->state == UE_STATE_ACTIVE))
2540 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2545 memset(ueCb, 0, sizeof(MacUeCb));
2546 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2549 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2554 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2555 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2557 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2560 /* If UE has not requested for RACH yet, it means UE context is created for a
2562 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2564 ueCb->state = UE_STATE_ACTIVE;
2565 macCb.macCell[cellIdx]->numActvUe++;
2566 updateMacRaCb(cellIdx, ueCb);
2569 ueCb->state = UE_HANDIN_IN_PROGRESS;
2577 /*******************************************************************
2579 * @brief Modify UE Cb Cfg
2583 * Function : modifyUeCb
2585 * Functionality: modify UE Cb
2587 * @params[in] MAC UE Configuration
2588 * @return ROK - success
2591 * ****************************************************************/
2592 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2596 if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
2597 &&(ueCb->state == UE_STATE_ACTIVE))
2599 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
2600 ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
2603 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2615 /*******************************************************************
2617 * @brief Creates UE Cb and fills ueCfg
2621 * Function : procMacUeCfgData
2623 * Functionality: Creates UE Cb and fills ueCfg
2625 * @params[in] MAC UE Configuration
2626 * @return ROK - success
2629 * ****************************************************************/
2631 uint8_t procMacUeCfgData(Pst *pst, MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
2633 uint8_t ret = ROK, ueId = 0;
2634 uint16_t cellIdx, cellId;
2635 MacUeCb *ueCb = NULLP;
2639 cellId = ueCfg->cellId;
2642 else if(ueRecfg != NULLP)
2644 cellId = ueRecfg->cellId;
2645 ueId = ueRecfg->ueId;
2649 GET_CELL_IDX(cellId, cellIdx);
2651 /* Validate cell id */
2652 if(macCb.macCell[cellIdx]->cellId != cellId)
2654 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
2658 /* Check if max number of UE configured */
2659 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2661 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2665 /* Check if UE already configured */
2666 ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
2670 case EVENT_UE_CONFIG_RSP_TO_MAC:
2672 ret = createUeCb(cellIdx, ueCb, ueCfg);
2674 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2678 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2680 ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
2682 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2693 /*******************************************************************
2695 * @brief Function to store the UeCfg Data
2699 * Function : copyToTmpData
2701 * Functionality: Function to store the UeCfg Data
2703 * @params[in] MacUeCreateReq pointer
2704 * @return ROK - success
2707 * ****************************************************************/
2709 uint8_t copyToTmpData(MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
2715 MacUeCreateReq *tmpData = NULLP;
2717 MAC_ALLOC(tmpData, sizeof(MacUeCreateReq));
2720 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2723 memcpy(tmpData, ueCfg, sizeof(MacUeCreateReq));
2724 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2725 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2727 else if(ueRecfg != NULLP)
2729 MacUeRecfg *tmpData = NULLP;
2731 MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
2734 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2737 memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
2738 GET_CELL_IDX(ueRecfg->cellId, cellIdx);
2739 macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
2744 /*******************************************************************
2746 * @brief Handles UE create requst from DU APP
2750 * Function : MacProcUeCreateReq
2752 * Functionality: Handles UE create requst from DU APP
2755 * @return ROK - success
2758 * ****************************************************************/
2759 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCreateReq *ueCfg)
2762 SchUeCfgReq schUeCfg;
2763 memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
2765 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2769 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2770 * case of UE in handover */
2771 if(ueCfg->crnti == 0)
2773 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2776 /*Storing received ueCfg in ueCfgTmpData */
2777 ret = copyToTmpData(ueCfg, NULLP);
2780 /*Sending Cfg Req to SCH */
2781 ret = fillSchUeCfg(&schUeCfg, ueCfg);
2783 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2786 /* Fill event and send UE create request to SCH */
2787 ret = sendUeReqToSch(pst, &schUeCfg);
2789 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2794 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2799 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2802 /* FREE shared memory */
2803 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCreateReq));
2808 /*******************************************************************
2810 * @brief Fill and Send UE create response from MAC to DU APP
2814 * Function : MacSendUeCreateRsp
2816 * Functionality: Fill and Send UE create response from MAC to DUAPP
2818 * @params[in] MAC UE create result
2819 * SCH UE create response
2820 * @return ROK - success
2823 * ****************************************************************/
2824 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2826 MacUeCreateRsp *cfgRsp;
2829 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCreateRsp));
2832 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2836 /* Filling UE Config response */
2837 memset(cfgRsp, 0, sizeof(MacUeCreateRsp));
2838 cfgRsp->cellId = schCfgRsp->cellId;
2839 GET_UE_ID(schCfgRsp->crnti, cfgRsp->ueId);
2840 cfgRsp->result = result;
2842 /* Fill Post structure and send UE Create response*/
2843 memset(&rspPst, 0, sizeof(Pst));
2844 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2845 return (*macDuUeCreateRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2848 /*******************************************************************
2850 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2854 * Function : MacSendUeReconfigRsp
2856 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2858 * @params[in] MAC UE create result
2859 * SCH UE create response
2860 * @return ROK - success
2863 * ****************************************************************/
2864 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
2866 MacUeRecfgRsp *recfgRsp;
2869 MAC_ALLOC_SHRABL_BUF(recfgRsp, sizeof(MacUeRecfgRsp));
2872 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2876 /* Filling UE Config response */
2877 memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
2878 recfgRsp->cellId = schCfgRsp->cellId;
2879 GET_UE_ID(schCfgRsp->crnti, recfgRsp->ueId);
2880 recfgRsp->result = result;
2882 /* Fill Post structure and send UE Create response*/
2883 memset(&rspPst, 0, sizeof(Pst));
2884 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2885 return (*macDuUeRecfgRspOpts[rspPst.selector])(&rspPst, recfgRsp);
2888 /*******************************************************************
2890 * @brief Function to return Mac Ue Cfg pointer
2894 * Function : getMacUeCfg
2897 * Function to return Mac Ue Cfg pointer
2899 * @params[in] cellIdx, ueId
2901 * @return MacUeCreateReq pointer - success
2904 * ****************************************************************/
2906 MacUeCreateReq *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2908 MacUeCreateReq *ueCfg = NULLP;
2909 if(macCb.macCell[cellIdx])
2911 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2915 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2920 /*******************************************************************
2922 * @brief Function to return Mac Ue Recfg pointer
2926 * Function : getMacUeRecfg
2929 * Function to return Mac Ue Recfg pointer
2931 * @params[in] cellIdx, ueId
2933 * @return MacUeRecfg pointer - success
2936 * ****************************************************************/
2938 MacUeRecfg *getMacUeRecfg(uint16_t cellIdx, uint8_t ueId)
2940 MacUeRecfg *ueRecfg = NULLP;
2941 if(macCb.macCell[cellIdx])
2943 ueRecfg = macCb.macCell[cellIdx]->ueRecfgTmpData[ueId-1];
2947 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeRecfg()");
2952 /*******************************************************************
2954 * @brief Processes UE create response from scheduler
2958 * Function : MacProcSchUeCfgRsp
2961 * Processes UE create response from scheduler
2962 * Sends UE create response to DU APP
2964 * @params[in] Pst : Post structure
2965 * schCfgRsp : Scheduler UE cfg response
2966 * @return ROK - success
2969 * ****************************************************************/
2970 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2972 uint8_t result = MAC_DU_APP_RSP_NOK;
2974 uint16_t cellIdx = 0, ueId = 0;
2975 MacUeCreateReq *ueCfg = NULLP;
2977 #ifdef CALL_FLOW_DEBUG_LOG
2980 case EVENT_UE_CONFIG_RSP_TO_MAC:
2981 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2983 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2984 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2987 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2992 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2993 GET_UE_ID(schCfgRsp->crnti, ueId);
2994 ueCfg = getMacUeCfg(cellIdx, ueId);
2997 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3001 if(schCfgRsp->rsp != RSP_NOK)
3003 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
3006 ret = procMacUeCfgData(pst, ueCfg, NULLP);
3009 result = MAC_DU_APP_RSP_OK;
3015 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
3017 ret = MacSendUeCreateRsp(result, schCfgRsp);
3018 MAC_FREE(ueCfg, sizeof(MacUeCreateReq));
3023 /*******************************************************************
3025 * @brief Processes UE create response from scheduler
3029 * Function : MacProcSchUeRecfgRsp
3032 * Processes UE ReConfig response from scheduler
3033 * Sends UE Reconfig response to DU APP
3035 * @params[in] Pst : Post structure
3036 * schRecfgRsp : Scheduler UE Recfg response
3037 * @return ROK - success
3040 * ****************************************************************/
3041 uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
3043 uint8_t result = MAC_DU_APP_RSP_NOK;
3045 uint16_t cellIdx = 0, ueId = 0;
3046 MacUeRecfg *ueRecfg = NULLP;
3048 #ifdef CALL_FLOW_DEBUG_LOG
3051 case EVENT_UE_RECONFIG_RSP_TO_MAC:
3052 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
3055 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
3060 GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
3061 GET_UE_ID(schRecfgRsp->crnti, ueId);
3062 ueRecfg = getMacUeRecfg(cellIdx, ueId);
3063 if(ueRecfg == NULLP)
3065 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3070 if(schRecfgRsp->rsp != RSP_NOK)
3072 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
3073 schRecfgRsp->crnti);
3076 ret = procMacUeCfgData(pst, NULLP, ueRecfg);
3079 result = MAC_DU_APP_RSP_OK;
3085 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
3086 schRecfgRsp->crnti);
3088 ret = MacSendUeReconfigRsp(result, schRecfgRsp);
3089 MAC_FREE(ueRecfg, sizeof(MacUeRecfg));
3094 /*******************************************************************
3096 * @brief Handles UE Reconfig requst from DU APP
3100 * Function : MacProcUeReconfigReq
3102 * Functionality: Handles UE Reconfig requst from DU APP
3105 * @return ROK - success
3108 * ****************************************************************/
3109 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg)
3112 SchUeRecfgReq schUeRecfg;
3113 memset(&schUeRecfg, 0, sizeof(SchUeRecfgReq));
3115 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueRecfg->crnti);
3119 /*Storing received ueRecfg in ueCfgTmpData */
3120 ret = copyToTmpData(NULLP, ueRecfg);
3123 /*Sending Cfg Req to SCH */
3124 ret = fillSchUeRecfg(&schUeRecfg, ueRecfg);
3126 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
3129 /* Fill event and send UE Reconfiguration request to SCH */
3130 ret = sendUeReqToSch(pst, &schUeRecfg);
3132 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
3137 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
3142 DU_LOG("\nERROR --> MAC : MAC UE Reconfiguration request processing failed");
3145 /* FREE shared memory */
3146 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(MacUeRecfg));
3150 /*******************************************************************
3152 * @brief Fill and Send UE Delete response from MAC to DU APP
3156 * Function : MacSendUeDeleteRsp
3158 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
3160 * @params[in] MAC UE delete result
3161 * SCH UE delete response
3162 * @return ROK - success
3165 * ****************************************************************/
3167 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, CauseOfResult status)
3169 MacUeDeleteRsp *deleteRsp;
3172 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
3175 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
3179 /* Filling UE delete response */
3180 deleteRsp->cellId = cellId;
3181 GET_UE_ID(crnti, deleteRsp->ueId);
3182 deleteRsp->status = status;
3184 /* Fill Post structure and send UE delete response*/
3185 memset(&rspPst, 0, sizeof(Pst));
3186 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
3187 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
3190 /*******************************************************************
3192 * @brief freeing the Pucch Resrc Cfg
3196 * Function : deletePucchResourcesCfg
3198 * Functionality: freeing the Pucch Resrc Cfg
3200 * @params[in] PucchResrcCfg *resrcCfg
3201 * @return ROK - success
3204 * ****************************************************************/
3206 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
3209 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
3211 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
3213 case PUCCH_FORMAT_0:
3215 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
3218 case PUCCH_FORMAT_1:
3220 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
3223 case PUCCH_FORMAT_2:
3225 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
3228 case PUCCH_FORMAT_3:
3230 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
3233 case PUCCH_FORMAT_4:
3235 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
3243 /*******************************************************************
3245 * @brief Processes UE delete response from scheduler
3249 * Function : MacProcSchUeDeleteRsp
3252 * Processes UE delete from scheduler
3254 * @params[in] Pst : Post structure
3255 * schUeDelRsp : Scheduler UE delete respons
3256 * @return ROK - success
3259 * ****************************************************************/
3261 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
3263 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
3265 uint8_t ret = RFAILED;
3266 CauseOfResult status;
3267 DlHarqEnt *dlHarqEnt;
3269 #ifdef CALL_FLOW_DEBUG_LOG
3270 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
3275 if(schUeDelRsp->rsp == RSP_OK)
3277 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
3278 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
3279 if(macCb.macCell[cellIdx])
3281 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
3284 /*C-RNTI value is out of Acceptable range*/
3285 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
3286 status = UEID_INVALID;
3290 GET_UE_ID(schUeDelRsp->crnti, ueId);
3291 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
3294 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
3296 /*Looping around LCs to free S-NSSAI memory*/
3297 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
3299 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3301 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
3303 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3306 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
3307 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
3310 while(dlHarqEnt->harqProcCb[idx].numTb)
3313 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
3314 dlHarqEnt->harqProcCb[idx].numTb--;
3318 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
3319 macCb.macCell[cellIdx]->numActvUe--;
3320 status = SUCCESSFUL;
3325 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
3326 status = UEID_INVALID;
3332 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
3333 status = CELLID_INVALID;
3337 status = schUeDelRsp->cause;
3339 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, status) != ROK)
3341 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
3347 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
3353 /*******************************************************************
3355 * @brief Sends UE delete req to Scheduler
3359 * Function : sendUeDelReqToSch
3361 * Functionality: sends UE delete req to Scheduler
3363 * @params[in] Pst *pst, MacUeDelete *ueDelete
3364 * @return ROK - success
3367 * ****************************************************************/
3369 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
3371 if(ueDelete != NULLP)
3374 SchUeDelete schUeDel;
3376 memset(&schUeDel, 0, sizeof(SchUeDelete));
3377 schUeDel.cellId = ueDelete->cellId;
3378 schUeDel.crnti = ueDelete->crnti;
3379 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3380 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
3381 return(SchMessageRouter(&schPst, (void *)&schUeDel));
3385 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
3391 /*******************************************************************
3393 * @brief Handles UE Delete requst from DU APP
3397 * Function : MacProcUeDeleteReq
3399 * Functionality: Handles UE Delete requst from DU APP
3401 * @params[in] Pst *pst, MacUeDelete *ueDelete
3402 * @return ROK - success
3405 * ****************************************************************/
3407 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
3411 CauseOfResult status =SUCCESSFUL;
3412 MacUeCb *ueCb = NULLP;
3413 MacCellCb *cellCb = NULLP;
3415 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
3419 GET_CELL_IDX(ueDelete->cellId, cellIdx);
3420 cellCb = macCb.macCell[cellIdx];
3423 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
3424 if(ueCb->crnti == ueDelete->crnti)
3426 ret = sendUeDelReqToSch(pst, ueDelete);
3429 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
3435 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
3436 status = UEID_INVALID;
3441 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
3442 status = CELLID_INVALID;
3445 if(status!= SUCCESSFUL)
3447 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, status);
3448 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3454 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
3460 /*******************************************************************
3462 * @brief Fill and Send UE Reset response from MAC to DU APP
3466 * Function : MacSendUeResetRsp
3468 * Functionality: Fill and Send UE Reset response from MAC to DUAPP
3470 * @params[in] MAC UE Reset result
3471 * SCH UE Reset response
3472 * @return ROK - success
3475 * ****************************************************************/
3477 uint8_t MacSendUeResetRsp(uint16_t cellId, uint16_t ueId, CauseOfResult status)
3479 MacUeResetRsp *ResetRsp;
3482 MAC_ALLOC_SHRABL_BUF(ResetRsp, sizeof(MacUeResetRsp));
3485 DU_LOG("\nERROR --> MAC : Memory allocation for UE Reset response failed");
3489 /* Filling UE Reset response */
3490 ResetRsp->cellId = cellId;
3491 ResetRsp->ueId = ueId;
3492 ResetRsp->status = status;
3494 /* Fill Post structure and send UE Reset response*/
3495 memset(&rspPst, 0, sizeof(Pst));
3496 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RESET_RSP);
3497 return (*macDuUeResetRspOpts[rspPst.selector])(&rspPst, ResetRsp);
3500 /*******************************************************************
3502 * @brief Handles UE Reset request from DU APP
3506 * Function : MacProcUeResetReq
3508 * Functionality: Handles UE Reset requst from DU APP
3510 * @params[in] Pst *pst, MacUeResetReq *ueReset
3511 * @return ROK - success
3514 * ****************************************************************/
3516 uint8_t MacProcUeResetReq(Pst *pst, MacUeResetReq *ueReset)
3519 CauseOfResult status =SUCCESSFUL;
3520 MacUeCb *ueCb = NULLP;
3521 MacCellCb *cellCb = NULLP;
3523 DU_LOG("\nINFO --> MAC : UE Reset Request received for ueId[%d]", ueReset->ueId);
3527 GET_CELL_IDX(ueReset->cellId, cellIdx);
3528 cellCb = macCb.macCell[cellIdx];
3531 ueCb = &cellCb->ueCb[ueReset->ueId-1];
3532 if(ueCb->ueId == ueReset->ueId)
3534 /* TODO := complete the processing of UE reset request*/
3538 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): UE ID [%d] not found in Cell Id [%d]", ueCb->ueId , ueReset->cellId);
3539 status = UEID_INVALID;
3544 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): Cell Id [%d] not found ",ueReset->cellId);
3545 status = CELLID_INVALID;
3548 MacSendUeResetRsp(ueReset->cellId, ueReset->ueId, status);
3549 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReset, sizeof(MacUeResetReq));
3553 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): MAC UE reset request processing failed");
3558 /**********************************************************************
3560 **********************************************************************/