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 MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
33 packDuMacUeCfgRsp, /* packing for loosely coupled */
34 DuProcMacUeCfgRsp, /* packing for tightly coupled */
35 packDuMacUeCfgRsp /* 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 */
58 /*******************************************************************
60 * @brief Fills mac cell group config to be sent to scheduler
64 * Function : fillMacCellGroupCfg
66 * Functionality: Fills mac cell group config to be sent to sch
68 * @params[in] macCellGrp : mac cell group config at MAC
69 * *macCellGrpCfg : mac cell group cfg to be filled
70 * @return ROK - success
73 * ****************************************************************/
74 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
77 SchSchedReqCfg *schedReqCfg;
80 /* Copy scheduling request config */
81 schedReqCfg = &macCellGrpCfg->schedReqCfg;
82 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
83 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
85 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
86 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
89 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
91 schedReqCfg->addModList[idx].schedReqId = \
92 macCellGrp.schReqCfg.addModList[idx].schedReqId;
93 schedReqCfg->addModList[idx].srProhibitTmr = \
94 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
95 schedReqCfg->addModList[idx].srTransMax = \
96 macCellGrp.schReqCfg.addModList[idx].srTransMax;
98 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
100 /* copy TAG config */
101 tagCfg = &macCellGrpCfg->tagCfg;
102 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
103 if(tagCfg->addModListCount > MAX_NUM_TAGS)
105 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
106 tagCfg->addModListCount, MAX_NUM_TAGS);
109 for(idx = 0; idx < tagCfg->addModListCount; idx++)
111 tagCfg->addModList[idx].tagId = \
112 macCellGrp.tagCfg.addModList[idx].tagId;
113 tagCfg->addModList[idx].timeAlignmentTmr = \
114 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
116 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
118 /* Copy PHR config */
119 if(macCellGrp.phrCfgSetupPres)
121 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
122 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
123 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
124 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
125 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
126 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
127 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
131 /* Copy Drx configuration */
132 macCellGrpCfg->drxCfgPresent = true;
133 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
134 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
135 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
136 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
138 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
139 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
140 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
141 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
142 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
143 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
144 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
145 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
146 drxLongCycleStartOffsetChoice;
147 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
148 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
149 if(macCellGrpCfg->drxCfg.shortDrxPres)
151 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
152 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
154 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
159 /*******************************************************************
161 * @brief Fills phy cell group config to be sent to scheduler
165 * Function : fillPhyCellGroupCfg
167 * Functionality: Fills phy cell group config to be sent to sch
169 * @params[in] macUeCfg : Phy cell group config at MAC
170 * *schPhyCellGrp : phy cell group config to be filled
171 * @return ROK - success
174 * ****************************************************************/
175 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
177 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
178 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
183 /*******************************************************************
185 * @brief Fills PDSCh serving cell config to send to scheduler
189 * Function : fillPdschServCellCfg
191 * Functionality: Fills PDSCh serving cell config to send to scheduler
193 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
194 * *schPdschCfg : Pdsch serving cell config to be filled
195 * @return ROK - success
198 * ****************************************************************/
199 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
201 if(macPdschCfg.maxMimoLayers)
203 if(!schPdschCfg->maxMimoLayers)
205 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
206 if(!schPdschCfg->maxMimoLayers)
208 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
212 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
216 schPdschCfg->maxMimoLayers = NULLP;
219 schPdschCfg->numHarqProcForPdsch = \
220 macPdschCfg.numHarqProcForPdsch;
222 if(macPdschCfg.maxCodeBlkGrpPerTb)
224 if(!schPdschCfg->maxCodeBlkGrpPerTb)
226 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
227 if(!schPdschCfg->maxCodeBlkGrpPerTb)
229 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
233 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
237 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
240 if(macPdschCfg.codeBlkGrpFlushInd)
242 if(!schPdschCfg->codeBlkGrpFlushInd)
244 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
245 if(!schPdschCfg->codeBlkGrpFlushInd)
247 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
251 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
255 schPdschCfg->codeBlkGrpFlushInd = NULLP;
258 if(macPdschCfg.xOverhead)
260 if(!schPdschCfg->xOverhead)
262 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
263 if(!schPdschCfg->xOverhead)
265 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
269 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
273 schPdschCfg->xOverhead = NULLP;
279 /*******************************************************************
281 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
285 * Function : fillInitalUlBwpPuschCfg
288 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
290 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
291 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
292 * @return ROK - success
295 * ****************************************************************/
296 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
300 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
301 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
302 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
303 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
304 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
305 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
307 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
308 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
310 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
311 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
314 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
316 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
317 macPuschCfg.timeDomRsrcAllocList[idx].k2;
318 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
319 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
320 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
321 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
322 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
323 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
326 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
330 /*******************************************************************
332 * @brief Function to fillResrcSetList sent by DU
336 * Function : fillResrcSetList
338 * Functionality: Function to fillResrcSetList sent by DU
340 * @params[in] PucchResrcSetCfg pointer,
341 * SchPucchResrcSetCfg pointer
344 * ****************************************************************/
346 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
348 uint8_t arrIdx, rsrcListIdx;
350 /* ResrcSetToAddModList */
351 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
352 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
354 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
355 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
357 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
358 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
360 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
361 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
362 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
363 resrcListCount; rsrcListIdx++)
365 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
366 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
369 /* ResrcSetToRelList */
370 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
371 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
373 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
377 /*******************************************************************
379 * @brief Function to fillResrcList sent by DU
383 * Function : fillResrcList
385 * Functionality: Function to fillResrcList sent by DU
387 * @params[in] PucchResrcCfg pointer,
388 * SchPucchResrcCfg pointer
389 * @return ROK/RFAILED;
391 * ****************************************************************/
392 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
396 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
397 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
399 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
400 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
401 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
402 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
403 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
404 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
405 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
406 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
407 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
408 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
409 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
411 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
412 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
414 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
417 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
418 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
419 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
420 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
421 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
422 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
425 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
427 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
428 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
430 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
433 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
434 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
435 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
436 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
437 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
438 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
439 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
440 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
443 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
445 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
446 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
448 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
451 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
452 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
453 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
454 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
455 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
456 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
459 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
461 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
462 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
464 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
467 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
468 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
469 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
470 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
471 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
472 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
475 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
477 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
478 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
480 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
483 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
484 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
485 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
486 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
487 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
488 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
489 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
490 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
496 /*******************************************************************
498 * @brief Function to fillPucchFormatCfg sent by DU
502 * Function : fillPucchFormatCfg
504 * Functionality: Function to fillPucchFormatCfg
506 * @params[in] PucchFormatCfg pointer,
507 * SchPucchFormatCfg pointer
510 * ****************************************************************/
512 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
514 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
515 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
516 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
517 schFormatCfg->numSlots = macFormatCfg->numSlots;
518 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
519 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
522 /*******************************************************************
524 * @brief Function to fillPucchSchedReqCfg sent by DU
528 * Function : fillPucchSchedReqCfg
530 * Functionality: Function to fillPucchSchedReqCfg
532 * @params[in] PucchSchedReqCfg pointer,
533 * SchPucchSchedReqCfg pointer
536 * ****************************************************************/
537 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
541 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
542 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
544 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
545 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
546 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
547 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
548 schSchedReqCfg->schedAddModList[arrIdx].offset =\
549 macSchedReqCfg->schedAddModList[arrIdx].offset;
550 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
551 macSchedReqCfg->schedAddModList[arrIdx].resrc;
553 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
554 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
556 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
560 /*******************************************************************
562 * @brief Function to fillMultiCsiCfg sent by DU
566 * Function : fillMultiCsiCfg
568 * Functionality: Function to fillMultiCsiCfg
570 * @params[in] PucchMultiCsiCfg pointer,
571 * SchPucchMultiCsiCfg pointer
574 * ****************************************************************/
576 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
580 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
581 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
583 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
587 /*******************************************************************
589 * @brief Function to fillDlToUlAck sent by DU
593 * Function : fillDlToUlAck
595 * Functionality: Function to fillDlToUlAck
597 * @params[in] PucchDlDataToUlAck pointer,
598 * SchPucchDlDataToUlAck pointer
601 * ****************************************************************/
603 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
607 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
608 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
610 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
614 /*******************************************************************
616 * @brief Function to fillPucchPowerControl sent by DU
620 * Function : fillPucchPowerControl
622 * Functionality: Function to fillPucchPowerControl
624 * @params[in] PucchPowerControl pointer,
625 * SchPucchPowerControl pointer
628 * ****************************************************************/
630 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
634 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
635 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
636 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
637 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
638 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
639 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
640 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
642 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
643 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
645 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
646 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
648 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
649 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
653 /*******************************************************************
655 * @brief Function to fillOtherPucchFormatCfg sent by DU
659 * Function : fillOtherPucchFormatCfg
661 * Functionality: Function to fillOtherPucchFormatCfg
663 * @params[in] PucchFormat
664 * PucchFormatCfg pointer,
665 * SchPucchCfg pointer
668 * ****************************************************************/
670 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
679 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
680 if(schPucchCfg->format1 == NULLP)
682 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
685 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
693 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
694 if(schPucchCfg->format2 == NULLP)
696 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
699 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
707 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
708 if(schPucchCfg->format3 == NULLP)
710 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
713 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
721 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
722 if(schPucchCfg->format4 == NULLP)
724 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
727 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
732 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
738 /*******************************************************************
740 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
744 * Function : fillInitalUlBwpPucchCfg
747 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
749 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
750 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
751 * @return ROK - success
754 * ****************************************************************/
755 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
757 if(macPucchCfg->resrcSet)
759 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
760 if(schPucchCfg->resrcSet == NULLP)
762 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
765 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
766 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
769 if(macPucchCfg->resrc)
771 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
772 if(schPucchCfg->resrc == NULLP)
774 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
777 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
778 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
780 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
785 /* valid for format 1, 2, 3, 4 */
786 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
787 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
788 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
789 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
791 if(macPucchCfg->schedReq)
793 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
794 if(schPucchCfg->schedReq == NULLP)
796 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
799 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
800 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
803 if(macPucchCfg->multiCsiCfg)
805 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
806 if(schPucchCfg->multiCsiCfg == NULLP)
808 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
811 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
812 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
815 //TODO: To add the support for spatial Config
816 schPucchCfg->spatialInfo = NULLP;
818 if(macPucchCfg->dlDataToUlAck)
820 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
821 if(schPucchCfg->dlDataToUlAck == NULLP)
823 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
826 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
827 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
831 if(macPucchCfg->powerControl)
833 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
834 if(schPucchCfg->powerControl == NULLP)
836 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
839 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
840 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
846 /*******************************************************************
848 * @brief function to free Pucch Format
852 * Function : freeSchPucchFormat
855 * function to free Pucch Format
857 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
858 * SchPucchResrcInfo pointer
860 * ****************************************************************/
862 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
866 case PUCCH_FORMAT_0 :
867 if(resrcInfo->SchPucchFormat.format0)
869 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
870 resrcInfo->SchPucchFormat.format0 = NULLP;
874 case PUCCH_FORMAT_1 :
875 if(resrcInfo->SchPucchFormat.format1)
877 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
878 resrcInfo->SchPucchFormat.format1 = NULLP;
882 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
883 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
887 case PUCCH_FORMAT_2 :
888 if(resrcInfo->SchPucchFormat.format2)
890 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
891 resrcInfo->SchPucchFormat.format2 = NULLP;
895 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
896 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
900 case PUCCH_FORMAT_3 :
901 if(resrcInfo->SchPucchFormat.format3)
903 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
904 resrcInfo->SchPucchFormat.format3 = NULLP;
908 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
909 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
913 case PUCCH_FORMAT_4 :
914 if(resrcInfo->SchPucchFormat.format4)
916 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
917 resrcInfo->SchPucchFormat.format4 = NULLP;
921 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
922 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
931 /*******************************************************************
933 * @brief function to free Pucch Resrc Cfg
937 * Function : freePucchResrcCfg
940 * function to free Pucch Resrc Cfg
942 * @params[in] SchPucchResrcCfg pointer,
944 * ****************************************************************/
946 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
950 /* free Resrc To AddMod List */
951 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
953 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
954 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
955 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
957 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
958 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
961 /*******************************************************************
963 * @brief function to free Pucch Sched Req Cfg
967 * Function : freePucchSchedReqCfg
970 * function to free Pucch Sched Req Cfg
972 * @params[in] SchPucchSchedReqCfg pointer,
974 * ****************************************************************/
976 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
980 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
982 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
984 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
985 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
988 /*******************************************************************
990 * @brief function to free Ul Bwp Pucch Cfg
994 * Function : freeUlBwpPucchCfg
997 * function to free Ul Bwp Pucch Cfg
999 * @params[in] SchPucchCfg pointer,
1001 * ****************************************************************/
1003 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1005 if(schPucchCfg->resrcSet)
1007 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1008 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1010 if(schPucchCfg->resrc)
1012 freePucchResrcCfg(schPucchCfg->resrc);
1014 if(schPucchCfg->format1)
1016 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1018 if(schPucchCfg->format2)
1020 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1022 if(schPucchCfg->format3)
1024 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1026 if(schPucchCfg->format4)
1028 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1030 if(schPucchCfg->schedReq)
1032 freePucchSchedReqCfg(schPucchCfg->schedReq);
1034 if(schPucchCfg->spatialInfo)
1036 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1037 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1039 if(schPucchCfg->multiCsiCfg)
1041 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1042 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1044 if(schPucchCfg->dlDataToUlAck)
1046 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1047 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1049 if(schPucchCfg->powerControl)
1051 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1052 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1056 /*******************************************************************
1058 * @brief Fills initail UL BWP config to send to scheduler
1062 * Function : fillInitialUlBwp
1064 * Functionality: Fills initail UL BWP config to send to sch
1066 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1067 * schInitUlBwp : Initial UL BWP cfg to be filled
1068 * @return ROK - success
1071 * ****************************************************************/
1072 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1074 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1075 if(schInitUlBwp->pucchCfgPres)
1077 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1078 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1080 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1081 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1085 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1086 if(schInitUlBwp->puschCfgPres)
1088 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1089 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1091 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1098 /*******************************************************************
1100 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1104 * Function : fillInitDlBwpPdcchCfg
1107 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1109 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1110 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1111 * @return ROK - success
1114 * ****************************************************************/
1115 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1119 /* Fill CORESET info */
1120 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1121 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1123 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1124 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1128 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1130 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1131 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1132 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1133 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1134 schPdcchCfg->cRSetToAddModList[idx].duration = \
1135 macPdcchCfg.cRSetToAddModList[idx].duration;
1136 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1137 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1138 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1139 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1140 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1141 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1144 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1145 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1147 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1148 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1152 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1157 /* Fill Search space info */
1158 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1159 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1161 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1162 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1165 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1167 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1168 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1169 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1170 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1171 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1172 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1173 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1174 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1175 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1176 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1177 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1178 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1179 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1180 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1181 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1182 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1183 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1184 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1185 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1186 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1187 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1188 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1189 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1192 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1193 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1195 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1196 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1199 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1207 /*******************************************************************
1209 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1213 * Function : fillInitDlBwpPdschCfg
1216 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1218 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1219 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1220 * @return ROK - success
1223 * ****************************************************************/
1224 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1228 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1229 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1230 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1231 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1232 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1234 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1235 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1239 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1241 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1243 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1244 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1246 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1249 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1251 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1252 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1253 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1254 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1255 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1256 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1259 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1260 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1261 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1262 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1264 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1266 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1268 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1269 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1274 /*******************************************************************
1276 * @brief Fill Initial DL BWP for SCH UE config
1280 * Function : fillInitialDlBwp
1282 * Functionality: Fill Initial DL BWP for SCH UE config
1284 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1285 * schInitDlBwp : Inital DL BWP cfg to be filled
1286 * @return ROK - success
1289 * ****************************************************************/
1290 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1292 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1293 if(schInitDlBwp->pdcchCfgPres)
1295 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1297 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1302 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1303 if(schInitDlBwp->pdschCfgPres)
1305 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1307 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1314 /*******************************************************************
1316 * @brief Fills Sp Cell config to be sent to scheduler
1320 * Function : fillSpCellCfg
1322 * Functionality: Fills Sp Cell config to be sent to scheduler
1324 * @params[in] macSpCellCfg : SP cell cfg at MAC
1325 * schSpCellCfg : SP cell cfg to be filled
1326 * @return ROK - success
1329 * ****************************************************************/
1330 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1333 SchServCellCfgInfo *servCellCfg;
1335 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1336 servCellCfg = &schSpCellCfg->servCellCfg;
1338 /* Fill initial DL BWP */
1339 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1340 &servCellCfg->initDlBwp) != ROK )
1342 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1346 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1347 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1349 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD [%d] exceeds max limit [%d]",\
1350 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1353 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1355 memcpy(&servCellCfg->dlBwpToAddList[idx], &macSpCellCfg.servCellCfg.dlBwpToAddList[idx], sizeof(DlBwpInfo));
1357 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1358 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1359 servCellCfg->bwpInactivityTmr = NULL;
1360 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1362 /* TODO : This is an optional parameter, not filled currently */
1365 /* Fill PDSCH serving cell config */
1366 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1367 &servCellCfg->pdschServCellCfg) != ROK)
1369 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1373 /* Fill Initail UL BWP */
1374 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1375 &servCellCfg->initUlBwp) != ROK)
1377 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1381 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1382 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1384 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD [%d] exceeds max limit [%d]",\
1385 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1388 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1390 memcpy(&servCellCfg->ulBwpToAddList[idx], &macSpCellCfg.servCellCfg.ulBwpToAddList[idx], sizeof(UlBwpInfo));
1392 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1397 /*******************************************************************
1399 * @brief Fills Sp Cell Reconfig to be sent to scheduler
1403 * Function : fillSpCellRecfg
1405 * Functionality: Fills Sp Cell Reconfig to be sent to scheduler
1407 * @params[in] macSpCellRecfg : SP cell Recfg at MAC
1408 * schSpCellRecfg : SP cell Recfg to be filled
1409 * @return ROK - success
1412 * ****************************************************************/
1413 uint8_t fillSpCellRecfg(SpCellRecfg macSpCellRecfg, SchSpCellRecfg *schSpCellRecfg)
1416 SchServCellRecfgInfo *servCellRecfg;
1418 schSpCellRecfg->servCellIdx = macSpCellRecfg.servCellIdx;
1419 servCellRecfg = &schSpCellRecfg->servCellRecfg;
1421 /* Fill initial DL BWP */
1422 if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
1423 &servCellRecfg->initDlBwp) != ROK )
1425 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1429 servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
1430 if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
1432 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1433 servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
1436 for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
1438 memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
1440 servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
1441 if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
1443 DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
1444 servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
1447 for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
1449 memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
1451 servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
1452 servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
1453 servCellRecfg->bwpInactivityTmr = NULL;
1454 if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
1456 /* TODO : This is an optional parameter, not filled currently */
1459 /* Fill PDSCH serving cell config */
1460 if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
1461 &servCellRecfg->pdschServCellCfg) != ROK)
1463 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1467 /* Fill Initail UL BWP */
1468 if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
1469 &servCellRecfg->initUlBwp) != ROK)
1471 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1475 servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
1476 if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
1478 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1479 servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
1482 for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
1484 memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
1486 servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
1487 if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
1489 DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
1490 servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
1493 for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
1495 memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
1497 servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
1502 /*******************************************************************
1504 * @brief Sends UE configuration to Scheduler
1508 * Function : sendUeReqToSch
1510 * Functionality: sends UE configuration to Scheduler
1512 * @params[in] Pst and Ue configuration
1513 * @return ROK - success
1516 * ****************************************************************/
1518 uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
1523 case EVENT_MAC_UE_CREATE_REQ:
1525 SchUeCfgReq *schUeCfgReq = NULLP;
1526 schUeCfgReq = (SchUeCfgReq *)schUeCfg;
1527 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1528 return(SchMessageRouter(&schPst, (void *)schUeCfgReq));
1530 case EVENT_MAC_UE_RECONFIG_REQ:
1532 SchUeRecfgReq *schUeRecfgReq = NULLP;
1533 schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
1534 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1535 return(SchMessageRouter(&schPst, (void *)schUeRecfgReq));
1539 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1545 /*******************************************************************
1547 * @brief Fills Sch Drb Qos Information
1551 * Function : fillSchDrbQosInfo
1553 * Functionality: Fills Sch Drb Qos Information
1555 * @params[in] macLcCfg : Logical channel Cfg at MAC
1556 * schLcCfg : LC cfg to fill at scheduler
1557 * @return ROK - success
1560 * ****************************************************************/
1561 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1563 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1564 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1566 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1567 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1568 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1569 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1571 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1573 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1574 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1575 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1576 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1577 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1578 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1579 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1580 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1582 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1583 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1584 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1585 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1586 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1587 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1588 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1589 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1590 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1593 /*******************************************************************
1595 * @brief Fill SCH UL logical channel configuration
1599 * Function : fillSchUlLcCfg
1601 * Functionality: Fills Sch Ul Lc configuration
1603 * @params[in] macLcCfg : Logical channel Cfg at MAC
1604 * schLcCfg : LC cfg to fill at scheduler
1607 * ****************************************************************/
1609 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1611 schUlLcCfg->priority= macUlLcCfg->priority;
1612 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1613 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1614 schUlLcCfg->pbr = macUlLcCfg->pbr;
1615 schUlLcCfg->bsd = macUlLcCfg->bsd;
1618 /*******************************************************************
1620 * @brief Fill logical channel configuration
1624 * Function : fillLogicalChannelCfg
1626 * Functionality: Fill logical channel configuration
1628 * @params[in] macLcCfg : Logical channel Cfg at MAC
1629 * schLcCfg : LC cfg to fill at scheduler
1630 * @return ROK - success
1633 * ****************************************************************/
1634 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1638 schLcCfg->lcId = macLcCfg->lcId;
1639 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1640 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1642 if(macLcCfg->drbQos)
1644 if(!schLcCfg->drbQos)
1646 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1647 if(!schLcCfg->drbQos)
1649 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1655 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1662 schLcCfg->drbQos = NULLP;
1667 if(macLcCfg->snssai)
1669 if(!schLcCfg->snssai)
1671 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1672 if(!schLcCfg->snssai)
1674 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1680 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1681 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1683 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1689 schLcCfg->snssai = NULLP;
1696 /*******************************************************************
1698 * @brief Fills Logical channel Cfg List to Add
1702 * Function : fillSchLcCfgList
1704 * Functionality: Fills Logical channel Cfg List to Add
1706 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1707 * @return ROK - success
1710 * ****************************************************************/
1712 uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1716 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1718 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1720 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1723 schUeCfg->numLcsToAdd++;
1728 /*******************************************************************
1730 * @brief Fills Logical channel Recfg List to Add/Mod/Del
1734 * Function : fillSchLcRecfgList
1736 * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
1738 * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
1739 * @return ROK - success
1742 * ****************************************************************/
1744 uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1749 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
1751 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
1753 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1756 schUeRecfg->numLcsToAdd++;
1759 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
1761 schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
1762 schUeRecfg->numLcsToDel++;
1765 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
1767 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
1769 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1772 schUeRecfg->numLcsToMod++;
1777 /*******************************************************************
1779 * @brief Fills and sends UE configuration to Scheduler
1783 * Function : fillSchUeCfg
1785 * Functionality: Fills and sends UE configuration to Scheduler
1787 * @params[in] Ue configuration from DU APP
1788 * @return ROK - success
1791 * ****************************************************************/
1792 uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1796 schUeCfg->cellId = ueCfg->cellId;
1797 schUeCfg->ueId = ueCfg->ueId;
1798 schUeCfg->crnti = ueCfg->crnti;
1799 /* Copy MAC cell group config */
1800 if(ueCfg->macCellGrpCfgPres == true)
1802 schUeCfg->macCellGrpCfgPres = true;
1803 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1804 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1806 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1810 if(ueCfg->phyCellGrpCfgPres == true)
1812 schUeCfg->phyCellGrpCfgPres = true;
1813 /* Copy Physical cell group config */
1814 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1815 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1817 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1822 if(ueCfg->spCellCfgPres == true)
1824 schUeCfg->spCellCfgPres = true;
1825 /* Copy sp cell config */
1826 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1827 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1829 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1833 if(ueCfg->ambrCfg != NULLP)
1835 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1836 if(!schUeCfg->ambrCfg)
1838 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1841 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1845 schUeCfg->ambrCfg = NULLP;
1847 /* Fill DL modulation infor */
1848 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1849 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1850 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1852 /* Fill UL modulation infor */
1853 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1854 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1855 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1857 /* Fill sch Lc Cfg to Add*/
1858 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1861 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1868 /*******************************************************************
1870 * @brief Fills and sends UE Re-configuration to Scheduler
1874 * Function : fillSchUeRecfg
1876 * Functionality: Fills and sends UE Reconfiguration to Scheduler
1878 * @params[in] Ue configuration from DU APP
1879 * @return ROK - success
1882 * ****************************************************************/
1883 uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1887 schUeRecfg->cellId = ueRecfg->cellId;
1888 schUeRecfg->ueId = ueRecfg->ueId;
1889 schUeRecfg->crnti = ueRecfg->crnti;
1890 schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
1891 /* Copy MAC cell group config */
1892 if(ueRecfg->macCellGrpRecfgPres == true)
1894 schUeRecfg->macCellGrpRecfgPres = true;
1895 memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
1896 if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
1898 DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
1902 if(ueRecfg->phyCellGrpRecfgPres == true)
1904 schUeRecfg->phyCellGrpRecfgPres = true;
1905 /* Copy Physical cell group config */
1906 memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
1907 if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
1909 DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
1914 if(ueRecfg->spCellRecfgPres == true)
1916 schUeRecfg->spCellRecfgPres = true;
1917 /* Copy sp cell config */
1918 memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
1919 if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
1921 DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
1925 if(ueRecfg->ambrRecfg != NULLP)
1927 MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
1928 if(!schUeRecfg->ambrRecfg)
1930 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1933 schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
1937 schUeRecfg->ambrRecfg = NULLP;
1939 /* Fill DL modulation infor */
1940 schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
1941 schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
1942 schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
1944 /* Fill UL modulation infor */
1945 schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
1946 schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
1947 schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
1949 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1950 ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
1953 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
1958 schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
1964 /*******************************************************************
1966 * @brief Update UeUlCb Lc List
1970 * Function : updateMacUlCb
1972 * Functionality: Update UeUlCb Lc List
1974 * @params[in] delIdx, UeUlCb pointer
1977 * ****************************************************************/
1979 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1983 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1985 /* Moving the array element to one step ahead */
1986 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1987 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1989 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1991 /*Checking the Memory Leakage of Last Index*/
1992 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
1994 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
1996 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
2000 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
2006 /*******************************************************************
2008 * @brief Update UeDlCb Lc List
2012 * Function : updateMacDlCb
2014 * Functionality: Update UeDlCb Lc List
2016 * @params[in] delIdx, UeDlCb pointer
2019 * ****************************************************************/
2021 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
2025 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
2027 /* Moving the array element to one step ahead */
2028 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
2029 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
2031 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2033 /*Checking the Memory Leakage of Last Index*/
2034 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
2036 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
2038 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
2042 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
2048 /*******************************************************************
2050 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
2054 * Function : updateMacUlLcCtxt
2056 * Functionality: Update UeUlCb Lc List
2058 * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
2059 * ueLcCfg(received from DUAPP)
2060 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2063 * ****************************************************************/
2064 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2066 uint8_t ueLcIdx = 0;
2068 /*Traversing UL LC to be updated/Deleted*/
2069 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
2071 if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2073 /*Modify UL LC CB */
2074 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
2076 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2078 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2081 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2085 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
2087 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2090 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2093 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2094 ueLcCfg->lcId,ueLcIdx);
2097 else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2099 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
2100 (ulInfo->numUlLc)--;
2101 updateMacUlCb(ueLcIdx, ulInfo);
2102 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2108 /*******************************************************************
2110 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
2114 * Function : updateMacDlLcCtxt
2116 * Functionality: Update UeDlCb Lc List
2118 * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
2119 * ueLcCfg(received from DUAPP)
2120 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2123 * ****************************************************************/
2124 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2126 uint8_t ueLcIdx = 0;
2128 /*Traversing DL LC to be updated/Deleted*/
2129 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
2131 if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2133 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2135 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2138 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2142 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
2144 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2147 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2150 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2151 ueLcCfg->lcId,ueLcIdx);
2154 else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2156 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
2157 (dlInfo->numDlLc)--;
2158 updateMacDlCb(ueLcIdx, dlInfo);
2159 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2165 /*******************************************************************
2167 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2171 * Function : fillMacLcCfgList
2173 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2175 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2176 * @return ROK - success
2179 * ****************************************************************/
2181 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
2185 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
2187 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2189 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2191 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2192 if(ueCfg->lcCfgList[lcIdx].drbQos)
2194 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2195 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2197 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2198 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2200 if(ueCfg->lcCfgList[lcIdx].snssai)
2202 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2204 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2206 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2208 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2211 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2212 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2214 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2215 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2219 /*Filling DL LC CB */
2220 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2221 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2222 ueCb->dlInfo.numDlLc++;
2223 /*Filling UL LC CB */
2224 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2225 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
2226 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2227 ueCb->ulInfo.numUlLc++;
2233 /*******************************************************************
2235 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2239 * Function : updateMacLcCfgList
2241 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2243 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2244 * @return ROK - success
2247 * ****************************************************************/
2249 uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2253 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
2255 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2257 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2259 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2260 if(ueRecfg->lcCfgList[lcIdx].drbQos)
2262 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2263 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2265 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2266 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2268 if(ueRecfg->lcCfgList[lcIdx].snssai)
2270 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2272 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2274 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2276 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2279 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2280 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2282 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2283 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2287 /*Filling DL LC CB */
2288 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2289 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2290 ueCb->dlInfo.numDlLc++;
2291 /*Filling UL LC CB */
2292 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2293 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
2294 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2295 ueCb->ulInfo.numUlLc++;
2296 }/*End of Add Config */
2298 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
2300 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2302 updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2303 updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2306 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
2308 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2310 updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2311 updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2317 /*******************************************************************
2319 * @brief Fills MAC UE Cb Cfg
2323 * Function : fillMacUeCb
2325 * Functionality: Fills MAC UE Cb Cfg
2327 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2329 * @return ROK - success
2332 * ****************************************************************/
2334 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
2338 ueCb->ueId = ueCfg->ueId;
2339 ueCb->crnti = ueCfg->crnti;
2340 ueCb->cellCb = macCb.macCell[cellIdx];
2341 if(ueCfg->spCellCfgPres)
2343 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2344 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2347 /*TODO: To check the bsr value during implementation */
2348 if(ueCfg->macCellGrpCfgPres)
2350 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2351 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2352 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2354 ret = fillMacLcCfgList(ueCb, ueCfg);
2357 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2362 /*******************************************************************
2364 * @brief Fills MAC UE Cb Cfg
2368 * Function : updateMacUeCb
2370 * Functionality: updateMacUeCbs MAC UE Cb Cfg
2372 * @params[in] MAC UE Cb Recfg , MAC UE Configuration
2374 * @return ROK - success
2377 * ****************************************************************/
2379 uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
2383 ueCb->ueId = ueRecfg->ueId;
2384 ueCb->crnti = ueRecfg->crnti;
2385 ueCb->cellCb = macCb.macCell[cellIdx];
2386 if(ueRecfg->spCellRecfgPres)
2388 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2389 ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2392 /*TODO: To check the bsr value during implementation */
2393 if(ueRecfg->macCellGrpRecfgPres)
2395 ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
2396 ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
2397 ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
2399 ret = updateMacLcCfgList(ueCb, ueRecfg);
2402 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
2404 ueCb->transmissionAction = ueRecfg->transmissionAction;
2409 /*******************************************************************
2411 * @brief Function to update Mac Ra Cb
2415 * Function : updateMacRaCb
2417 * Functionality: Function to update Mac Ra Cb
2419 * @params[in] cellIdx, Mac Ue Cb
2420 * @return ROK - success
2423 * ****************************************************************/
2425 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2428 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2430 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2434 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2440 /*******************************************************************
2442 * @brief Function to delete Mac Ra Cb
2446 * Function : deleteMacRaCb
2448 * Functionality: Function to delete Mac Ra Cb
2450 * @params[in] cellIdx, Mac Ue Cb
2453 * ****************************************************************/
2455 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2458 MacRaCbInfo *raCb = ueCb->raCb;
2460 if(raCb && (raCb->crnti == ueCb->crnti))
2462 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2463 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2465 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2466 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2468 memset(raCb, 0, sizeof(MacRaCbInfo));
2472 /*******************************************************************
2474 * @brief Creates UE Cb
2478 * Function : createUeCb
2480 * Functionality: Creates UE Cb
2482 * @params[in] MAC UE Configuration
2483 * @return ROK - success
2486 * ****************************************************************/
2487 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2490 uint8_t hqProcIdx = 0;
2492 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2493 &&(ueCb->state == UE_STATE_ACTIVE))
2495 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2500 memset(ueCb, 0, sizeof(MacUeCb));
2501 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2504 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2509 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2510 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2512 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2515 /* If UE has not requested for RACH yet, it means UE context is created for a
2517 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2519 ueCb->state = UE_STATE_ACTIVE;
2520 macCb.macCell[cellIdx]->numActvUe++;
2521 updateMacRaCb(cellIdx, ueCb);
2524 ueCb->state = UE_HANDIN_IN_PROGRESS;
2532 /*******************************************************************
2534 * @brief Modify UE Cb Cfg
2538 * Function : modifyUeCb
2540 * Functionality: modify UE Cb
2542 * @params[in] MAC UE Configuration
2543 * @return ROK - success
2546 * ****************************************************************/
2547 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2551 if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
2552 &&(ueCb->state == UE_STATE_ACTIVE))
2554 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
2555 ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
2558 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2570 /*******************************************************************
2572 * @brief Creates UE Cb and fills ueCfg
2576 * Function : procMacUeCfgData
2578 * Functionality: Creates UE Cb and fills ueCfg
2580 * @params[in] MAC UE Configuration
2581 * @return ROK - success
2584 * ****************************************************************/
2586 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2588 uint8_t ret = ROK, ueId = 0;
2589 uint16_t cellIdx, cellId;
2590 MacUeCb *ueCb = NULLP;
2594 cellId = ueCfg->cellId;
2597 else if(ueRecfg != NULLP)
2599 cellId = ueRecfg->cellId;
2600 ueId = ueRecfg->ueId;
2604 GET_CELL_IDX(cellId, cellIdx);
2606 /* Validate cell id */
2607 if(macCb.macCell[cellIdx]->cellId != cellId)
2609 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
2613 /* Check if max number of UE configured */
2614 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2616 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2620 /* Check if UE already configured */
2621 ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
2625 case EVENT_UE_CONFIG_RSP_TO_MAC:
2627 ret = createUeCb(cellIdx, ueCb, ueCfg);
2629 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2633 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2635 ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
2637 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2648 /*******************************************************************
2650 * @brief Function to store the UeCfg Data
2654 * Function : copyToTmpData
2656 * Functionality: Function to store the UeCfg Data
2658 * @params[in] MacUeCfg pointer
2659 * @return ROK - success
2662 * ****************************************************************/
2664 uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2670 MacUeCfg *tmpData = NULLP;
2672 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2675 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2678 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2679 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2680 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2682 else if(ueRecfg != NULLP)
2684 MacUeRecfg *tmpData = NULLP;
2686 MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
2689 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2692 memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
2693 GET_CELL_IDX(ueRecfg->cellId, cellIdx);
2694 macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
2699 /*******************************************************************
2701 * @brief Handles UE create requst from DU APP
2705 * Function : MacProcUeCreateReq
2707 * Functionality: Handles UE create requst from DU APP
2710 * @return ROK - success
2713 * ****************************************************************/
2714 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2717 SchUeCfgReq schUeCfg;
2718 memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
2720 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2724 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2725 * case of UE in handover */
2726 if(ueCfg->crnti == 0)
2728 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2731 /*Storing received ueCfg in ueCfgTmpData */
2732 ret = copyToTmpData(ueCfg, NULLP);
2735 /*Sending Cfg Req to SCH */
2736 ret = fillSchUeCfg(&schUeCfg, ueCfg);
2738 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2741 /* Fill event and send UE create request to SCH */
2742 ret = sendUeReqToSch(pst, &schUeCfg);
2744 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2749 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2754 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2757 /* FREE shared memory */
2758 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2763 /*******************************************************************
2765 * @brief Fill and Send UE create response from MAC to DU APP
2769 * Function : MacSendUeCreateRsp
2771 * Functionality: Fill and Send UE create response from MAC to DUAPP
2773 * @params[in] MAC UE create result
2774 * SCH UE create response
2775 * @return ROK - success
2778 * ****************************************************************/
2779 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2781 MacUeCfgRsp *cfgRsp;
2784 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2787 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2791 /* Filling UE Config response */
2792 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2793 cfgRsp->cellId = schCfgRsp->cellId;
2794 cfgRsp->ueId = schCfgRsp->ueId;
2795 cfgRsp->result = result;
2797 /* Fill Post structure and send UE Create response*/
2798 memset(&rspPst, 0, sizeof(Pst));
2799 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2800 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2803 /*******************************************************************
2805 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2809 * Function : MacSendUeReconfigRsp
2811 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2813 * @params[in] MAC UE create result
2814 * SCH UE create response
2815 * @return ROK - success
2818 * ****************************************************************/
2819 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
2821 MacUeRecfgRsp *recfgRsp;
2824 MAC_ALLOC_SHRABL_BUF(recfgRsp, sizeof(MacUeRecfgRsp));
2827 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2831 /* Filling UE Config response */
2832 memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
2833 recfgRsp->cellId = schCfgRsp->cellId;
2834 recfgRsp->ueId = schCfgRsp->ueId;
2835 recfgRsp->result = result;
2837 /* Fill Post structure and send UE Create response*/
2838 memset(&rspPst, 0, sizeof(Pst));
2839 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2840 return (*macDuUeRecfgRspOpts[rspPst.selector])(&rspPst, recfgRsp);
2843 /*******************************************************************
2845 * @brief Function to return Mac Ue Cfg pointer
2849 * Function : getMacUeCfg
2852 * Function to return Mac Ue Cfg pointer
2854 * @params[in] cellIdx, ueId
2856 * @return MacUeCfg pointer - success
2859 * ****************************************************************/
2861 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2863 MacUeCfg *ueCfg = NULLP;
2864 if(macCb.macCell[cellIdx])
2866 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2870 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2875 /*******************************************************************
2877 * @brief Function to return Mac Ue Recfg pointer
2881 * Function : getMacUeRecfg
2884 * Function to return Mac Ue Recfg pointer
2886 * @params[in] cellIdx, ueId
2888 * @return MacUeRecfg pointer - success
2891 * ****************************************************************/
2893 MacUeRecfg *getMacUeRecfg(uint16_t cellIdx, uint8_t ueId)
2895 MacUeRecfg *ueRecfg = NULLP;
2896 if(macCb.macCell[cellIdx])
2898 ueRecfg = macCb.macCell[cellIdx]->ueRecfgTmpData[ueId-1];
2902 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeRecfg()");
2907 /*******************************************************************
2909 * @brief Processes UE create response from scheduler
2913 * Function : MacProcSchUeCfgRsp
2916 * Processes UE create response from scheduler
2917 * Sends UE create response to DU APP
2919 * @params[in] Pst : Post structure
2920 * schCfgRsp : Scheduler UE cfg response
2921 * @return ROK - success
2924 * ****************************************************************/
2925 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2927 uint8_t result = MAC_DU_APP_RSP_NOK;
2930 MacUeCfg *ueCfg = NULLP;
2932 #ifdef CALL_FLOW_DEBUG_LOG
2935 case EVENT_UE_CONFIG_RSP_TO_MAC:
2936 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2938 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2939 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2942 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2947 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2948 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2951 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2955 if(schCfgRsp->rsp != RSP_NOK)
2957 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2960 ret = procMacUeCfgData(pst, ueCfg, NULLP);
2963 result = MAC_DU_APP_RSP_OK;
2969 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2971 ret = MacSendUeCreateRsp(result, schCfgRsp);
2972 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2977 /*******************************************************************
2979 * @brief Processes UE create response from scheduler
2983 * Function : MacProcSchUeRecfgRsp
2986 * Processes UE ReConfig response from scheduler
2987 * Sends UE Reconfig response to DU APP
2989 * @params[in] Pst : Post structure
2990 * schRecfgRsp : Scheduler UE Recfg response
2991 * @return ROK - success
2994 * ****************************************************************/
2995 uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
2997 uint8_t result = MAC_DU_APP_RSP_NOK;
3000 MacUeRecfg *ueRecfg = NULLP;
3002 #ifdef CALL_FLOW_DEBUG_LOG
3005 case EVENT_UE_RECONFIG_RSP_TO_MAC:
3006 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
3009 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
3014 GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
3015 ueRecfg = getMacUeRecfg(cellIdx, schRecfgRsp->ueId);
3016 if(ueRecfg == NULLP)
3018 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3023 if(schRecfgRsp->rsp != RSP_NOK)
3025 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
3026 schRecfgRsp->crnti);
3029 ret = procMacUeCfgData(pst, NULLP, ueRecfg);
3032 result = MAC_DU_APP_RSP_OK;
3038 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
3039 schRecfgRsp->crnti);
3041 ret = MacSendUeReconfigRsp(result, schRecfgRsp);
3042 MAC_FREE(ueRecfg, sizeof(MacUeRecfg));
3047 /*******************************************************************
3049 * @brief Handles UE Reconfig requst from DU APP
3053 * Function : MacProcUeReconfigReq
3055 * Functionality: Handles UE Reconfig requst from DU APP
3058 * @return ROK - success
3061 * ****************************************************************/
3062 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg)
3065 SchUeRecfgReq schUeRecfg;
3066 memset(&schUeRecfg, 0, sizeof(SchUeRecfgReq));
3068 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueRecfg->crnti);
3072 /*Storing received ueRecfg in ueCfgTmpData */
3073 ret = copyToTmpData(NULLP, ueRecfg);
3076 /*Sending Cfg Req to SCH */
3077 ret = fillSchUeRecfg(&schUeRecfg, ueRecfg);
3079 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
3082 /* Fill event and send UE Reconfiguration request to SCH */
3083 ret = sendUeReqToSch(pst, &schUeRecfg);
3085 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
3090 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
3095 DU_LOG("\nERROR --> MAC : MAC UE Reconfiguration request processing failed");
3098 /* FREE shared memory */
3099 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(MacUeRecfg));
3103 /*******************************************************************
3105 * @brief Fill and Send UE Delete response from MAC to DU APP
3109 * Function : MacSendUeDeleteRsp
3111 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
3113 * @params[in] MAC UE delete result
3114 * SCH UE delete response
3115 * @return ROK - success
3118 * ****************************************************************/
3120 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, CauseOfResult status)
3122 MacUeDeleteRsp *deleteRsp;
3125 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
3128 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
3132 /* Filling UE delete response */
3133 deleteRsp->cellId = cellId;
3134 GET_UE_ID(crnti, deleteRsp->ueId);
3135 deleteRsp->status = status;
3137 /* Fill Post structure and send UE delete response*/
3138 memset(&rspPst, 0, sizeof(Pst));
3139 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
3140 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
3143 /*******************************************************************
3145 * @brief freeing the Pucch Resrc Cfg
3149 * Function : deletePucchResourcesCfg
3151 * Functionality: freeing the Pucch Resrc Cfg
3153 * @params[in] PucchResrcCfg *resrcCfg
3154 * @return ROK - success
3157 * ****************************************************************/
3159 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
3162 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
3164 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
3166 case PUCCH_FORMAT_0:
3168 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
3171 case PUCCH_FORMAT_1:
3173 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
3176 case PUCCH_FORMAT_2:
3178 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
3181 case PUCCH_FORMAT_3:
3183 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
3186 case PUCCH_FORMAT_4:
3188 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
3196 /*******************************************************************
3198 * @brief Processes UE delete response from scheduler
3202 * Function : MacProcSchUeDeleteRsp
3205 * Processes UE delete from scheduler
3207 * @params[in] Pst : Post structure
3208 * schUeDelRsp : Scheduler UE delete respons
3209 * @return ROK - success
3212 * ****************************************************************/
3214 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
3216 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
3218 uint8_t ret = RFAILED;
3219 CauseOfResult status;
3220 DlHarqEnt *dlHarqEnt;
3222 #ifdef CALL_FLOW_DEBUG_LOG
3223 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
3228 if(schUeDelRsp->rsp == RSP_OK)
3230 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
3231 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
3232 if(macCb.macCell[cellIdx])
3234 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
3237 /*C-RNTI value is out of Acceptable range*/
3238 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
3239 status = UEID_INVALID;
3243 GET_UE_ID(schUeDelRsp->crnti, ueId);
3244 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
3247 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
3249 /*Looping around LCs to free S-NSSAI memory*/
3250 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
3252 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3254 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
3256 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3259 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
3260 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
3263 while(dlHarqEnt->harqProcCb[idx].numTb)
3266 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
3267 dlHarqEnt->harqProcCb[idx].numTb--;
3271 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
3272 macCb.macCell[cellIdx]->numActvUe--;
3273 status = SUCCESSFUL;
3278 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
3279 status = UEID_INVALID;
3285 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
3286 status = CELLID_INVALID;
3290 status = schUeDelRsp->cause;
3292 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, status) != ROK)
3294 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
3300 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
3306 /*******************************************************************
3308 * @brief Sends UE delete req to Scheduler
3312 * Function : sendUeDelReqToSch
3314 * Functionality: sends UE delete req to Scheduler
3316 * @params[in] Pst *pst, MacUeDelete *ueDelete
3317 * @return ROK - success
3320 * ****************************************************************/
3322 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
3324 if(ueDelete != NULLP)
3327 SchUeDelete schUeDel;
3329 memset(&schUeDel, 0, sizeof(SchUeDelete));
3330 schUeDel.cellId = ueDelete->cellId;
3331 schUeDel.crnti = ueDelete->crnti;
3332 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3333 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
3334 return(SchMessageRouter(&schPst, (void *)&schUeDel));
3338 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
3344 /*******************************************************************
3346 * @brief Handles UE Delete requst from DU APP
3350 * Function : MacProcUeDeleteReq
3352 * Functionality: Handles UE Delete requst from DU APP
3354 * @params[in] Pst *pst, MacUeDelete *ueDelete
3355 * @return ROK - success
3358 * ****************************************************************/
3360 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
3364 CauseOfResult status =SUCCESSFUL;
3365 MacUeCb *ueCb = NULLP;
3366 MacCellCb *cellCb = NULLP;
3368 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
3372 GET_CELL_IDX(ueDelete->cellId, cellIdx);
3373 cellCb = macCb.macCell[cellIdx];
3376 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
3377 if(ueCb->crnti == ueDelete->crnti)
3379 ret = sendUeDelReqToSch(pst, ueDelete);
3382 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
3388 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
3389 status = UEID_INVALID;
3394 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
3395 status = CELLID_INVALID;
3398 if(status!= SUCCESSFUL)
3400 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, status);
3401 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3407 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
3413 /*******************************************************************
3415 * @brief Fill and Send UE Reset response from MAC to DU APP
3419 * Function : MacSendUeResetRsp
3421 * Functionality: Fill and Send UE Reset response from MAC to DUAPP
3423 * @params[in] MAC UE Reset result
3424 * SCH UE Reset response
3425 * @return ROK - success
3428 * ****************************************************************/
3430 uint8_t MacSendUeResetRsp(uint16_t cellId, uint16_t ueId, CauseOfResult status)
3432 MacUeResetRsp *ResetRsp;
3435 MAC_ALLOC_SHRABL_BUF(ResetRsp, sizeof(MacUeResetRsp));
3438 DU_LOG("\nERROR --> MAC : Memory allocation for UE Reset response failed");
3442 /* Filling UE Reset response */
3443 ResetRsp->cellId = cellId;
3444 ResetRsp->ueId = ueId;
3445 ResetRsp->status = status;
3447 /* Fill Post structure and send UE Reset response*/
3448 memset(&rspPst, 0, sizeof(Pst));
3449 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RESET_RSP);
3450 return (*macDuUeResetRspOpts[rspPst.selector])(&rspPst, ResetRsp);
3453 /*******************************************************************
3455 * @brief Handles UE Reset request from DU APP
3459 * Function : MacProcUeResetReq
3461 * Functionality: Handles UE Reset requst from DU APP
3463 * @params[in] Pst *pst, MacUeResetReq *ueReset
3464 * @return ROK - success
3467 * ****************************************************************/
3469 uint8_t MacProcUeResetReq(Pst *pst, MacUeResetReq *ueReset)
3472 CauseOfResult status =SUCCESSFUL;
3473 MacUeCb *ueCb = NULLP;
3474 MacCellCb *cellCb = NULLP;
3476 DU_LOG("\nINFO --> MAC : UE Reset Request received for ueId[%d]", ueReset->ueId);
3480 GET_CELL_IDX(ueReset->cellId, cellIdx);
3481 cellCb = macCb.macCell[cellIdx];
3484 ueCb = &cellCb->ueCb[ueReset->ueId-1];
3485 if(ueCb->ueId == ueReset->ueId)
3487 /* TODO := complete the processing of UE reset request*/
3491 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): UE ID [%d] not found in Cell Id [%d]", ueCb->ueId , ueReset->cellId);
3492 status = UEID_INVALID;
3497 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): Cell Id [%d] not found ",ueReset->cellId);
3498 status = CELLID_INVALID;
3501 MacSendUeResetRsp(ueReset->cellId, ueReset->ueId, status);
3502 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReset, sizeof(MacUeResetReq));
3506 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): MAC UE reset request processing failed");
3511 /**********************************************************************
3513 **********************************************************************/