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 /*******************************************************************
54 * @brief Fills mac cell group config to be sent to scheduler
58 * Function : fillMacCellGroupCfg
60 * Functionality: Fills mac cell group config to be sent to sch
62 * @params[in] macCellGrp : mac cell group config at MAC
63 * *macCellGrpCfg : mac cell group cfg to be filled
64 * @return ROK - success
67 * ****************************************************************/
68 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
71 SchSchedReqCfg *schedReqCfg;
74 /* Copy scheduling request config */
75 schedReqCfg = &macCellGrpCfg->schedReqCfg;
76 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
77 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
79 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
80 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
83 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
85 schedReqCfg->addModList[idx].schedReqId = \
86 macCellGrp.schReqCfg.addModList[idx].schedReqId;
87 schedReqCfg->addModList[idx].srProhibitTmr = \
88 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
89 schedReqCfg->addModList[idx].srTransMax = \
90 macCellGrp.schReqCfg.addModList[idx].srTransMax;
92 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
95 tagCfg = &macCellGrpCfg->tagCfg;
96 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
97 if(tagCfg->addModListCount > MAX_NUM_TAGS)
99 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
100 tagCfg->addModListCount, MAX_NUM_TAGS);
103 for(idx = 0; idx < tagCfg->addModListCount; idx++)
105 tagCfg->addModList[idx].tagId = \
106 macCellGrp.tagCfg.addModList[idx].tagId;
107 tagCfg->addModList[idx].timeAlignmentTmr = \
108 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
110 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
112 /* Copy PHR config */
113 if(macCellGrp.phrCfgSetupPres)
115 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
116 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
117 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
118 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
119 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
120 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
121 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
125 /* Copy Drx configuration */
126 macCellGrpCfg->drxCfgPresent = true;
127 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
128 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
129 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
130 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
132 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
133 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
134 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
135 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
136 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
137 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
138 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
139 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
140 drxLongCycleStartOffsetChoice;
141 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
142 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
143 if(macCellGrpCfg->drxCfg.shortDrxPres)
145 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
146 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
148 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
153 /*******************************************************************
155 * @brief Fills phy cell group config to be sent to scheduler
159 * Function : fillPhyCellGroupCfg
161 * Functionality: Fills phy cell group config to be sent to sch
163 * @params[in] macUeCfg : Phy cell group config at MAC
164 * *schPhyCellGrp : phy cell group config to be filled
165 * @return ROK - success
168 * ****************************************************************/
169 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
171 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
172 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
177 /*******************************************************************
179 * @brief Fills PDSCh serving cell config to send to scheduler
183 * Function : fillPdschServCellCfg
185 * Functionality: Fills PDSCh serving cell config to send to scheduler
187 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
188 * *schPdschCfg : Pdsch serving cell config to be filled
189 * @return ROK - success
192 * ****************************************************************/
193 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
195 if(macPdschCfg.maxMimoLayers)
197 if(!schPdschCfg->maxMimoLayers)
199 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
200 if(!schPdschCfg->maxMimoLayers)
202 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
206 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
210 schPdschCfg->maxMimoLayers = NULLP;
213 schPdschCfg->numHarqProcForPdsch = \
214 macPdschCfg.numHarqProcForPdsch;
216 if(macPdschCfg.maxCodeBlkGrpPerTb)
218 if(!schPdschCfg->maxCodeBlkGrpPerTb)
220 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
221 if(!schPdschCfg->maxCodeBlkGrpPerTb)
223 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
227 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
231 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
234 if(macPdschCfg.codeBlkGrpFlushInd)
236 if(!schPdschCfg->codeBlkGrpFlushInd)
238 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
239 if(!schPdschCfg->codeBlkGrpFlushInd)
241 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
245 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
249 schPdschCfg->codeBlkGrpFlushInd = NULLP;
252 if(macPdschCfg.xOverhead)
254 if(!schPdschCfg->xOverhead)
256 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
257 if(!schPdschCfg->xOverhead)
259 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
263 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
267 schPdschCfg->xOverhead = NULLP;
273 /*******************************************************************
275 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
279 * Function : fillInitalUlBwpPuschCfg
282 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
284 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
285 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
286 * @return ROK - success
289 * ****************************************************************/
290 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
294 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
295 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
296 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
297 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
298 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
299 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
301 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
302 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
304 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
305 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
308 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
310 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
311 macPuschCfg.timeDomRsrcAllocList[idx].k2;
312 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
313 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
314 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
315 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
316 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
317 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
320 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
324 /*******************************************************************
326 * @brief Function to fillResrcSetList sent by DU
330 * Function : fillResrcSetList
332 * Functionality: Function to fillResrcSetList sent by DU
334 * @params[in] PucchResrcSetCfg pointer,
335 * SchPucchResrcSetCfg pointer
338 * ****************************************************************/
340 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
342 uint8_t arrIdx, rsrcListIdx;
344 /* ResrcSetToAddModList */
345 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
346 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
348 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
349 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
351 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
352 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
354 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
355 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
356 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
357 resrcListCount; rsrcListIdx++)
359 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
360 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
363 /* ResrcSetToRelList */
364 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
365 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
367 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
371 /*******************************************************************
373 * @brief Function to fillResrcList sent by DU
377 * Function : fillResrcList
379 * Functionality: Function to fillResrcList sent by DU
381 * @params[in] PucchResrcCfg pointer,
382 * SchPucchResrcCfg pointer
383 * @return ROK/RFAILED;
385 * ****************************************************************/
386 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
390 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
391 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
393 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
394 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
395 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
396 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
397 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
398 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
399 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
400 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
401 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
402 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
403 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
405 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
406 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
408 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
411 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
412 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
413 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
414 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
415 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
416 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
419 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
421 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
422 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
424 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
427 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
428 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
429 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
430 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
431 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
432 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
433 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
434 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
437 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
439 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
440 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
442 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
445 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
446 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
447 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
448 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
449 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
450 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
453 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
455 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
456 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
458 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
461 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
462 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
463 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
464 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
465 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
466 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
469 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
471 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
472 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
474 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
477 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
478 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
479 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
480 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
481 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
482 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
483 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
484 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
490 /*******************************************************************
492 * @brief Function to fillPucchFormatCfg sent by DU
496 * Function : fillPucchFormatCfg
498 * Functionality: Function to fillPucchFormatCfg
500 * @params[in] PucchFormatCfg pointer,
501 * SchPucchFormatCfg pointer
504 * ****************************************************************/
506 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
508 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
509 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
510 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
511 schFormatCfg->numSlots = macFormatCfg->numSlots;
512 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
513 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
516 /*******************************************************************
518 * @brief Function to fillPucchSchedReqCfg sent by DU
522 * Function : fillPucchSchedReqCfg
524 * Functionality: Function to fillPucchSchedReqCfg
526 * @params[in] PucchSchedReqCfg pointer,
527 * SchPucchSchedReqCfg pointer
530 * ****************************************************************/
531 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
535 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
536 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
538 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
539 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
540 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
541 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
542 schSchedReqCfg->schedAddModList[arrIdx].offset =\
543 macSchedReqCfg->schedAddModList[arrIdx].offset;
544 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
545 macSchedReqCfg->schedAddModList[arrIdx].resrc;
547 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
548 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
550 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
554 /*******************************************************************
556 * @brief Function to fillMultiCsiCfg sent by DU
560 * Function : fillMultiCsiCfg
562 * Functionality: Function to fillMultiCsiCfg
564 * @params[in] PucchMultiCsiCfg pointer,
565 * SchPucchMultiCsiCfg pointer
568 * ****************************************************************/
570 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
574 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
575 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
577 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
581 /*******************************************************************
583 * @brief Function to fillDlToUlAck sent by DU
587 * Function : fillDlToUlAck
589 * Functionality: Function to fillDlToUlAck
591 * @params[in] PucchDlDataToUlAck pointer,
592 * SchPucchDlDataToUlAck pointer
595 * ****************************************************************/
597 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
601 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
602 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
604 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
608 /*******************************************************************
610 * @brief Function to fillPucchPowerControl sent by DU
614 * Function : fillPucchPowerControl
616 * Functionality: Function to fillPucchPowerControl
618 * @params[in] PucchPowerControl pointer,
619 * SchPucchPowerControl pointer
622 * ****************************************************************/
624 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
628 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
629 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
630 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
631 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
632 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
633 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
634 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
636 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
637 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
639 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
640 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
642 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
643 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
647 /*******************************************************************
649 * @brief Function to fillOtherPucchFormatCfg sent by DU
653 * Function : fillOtherPucchFormatCfg
655 * Functionality: Function to fillOtherPucchFormatCfg
657 * @params[in] PucchFormat
658 * PucchFormatCfg pointer,
659 * SchPucchCfg pointer
662 * ****************************************************************/
664 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
673 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
674 if(schPucchCfg->format1 == NULLP)
676 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
679 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
687 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
688 if(schPucchCfg->format2 == NULLP)
690 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
693 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
701 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
702 if(schPucchCfg->format3 == NULLP)
704 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
707 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
715 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
716 if(schPucchCfg->format4 == NULLP)
718 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
721 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
726 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
732 /*******************************************************************
734 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
738 * Function : fillInitalUlBwpPucchCfg
741 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
743 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
744 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
745 * @return ROK - success
748 * ****************************************************************/
749 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
751 if(macPucchCfg->resrcSet)
753 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
754 if(schPucchCfg->resrcSet == NULLP)
756 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
759 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
760 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
763 if(macPucchCfg->resrc)
765 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
766 if(schPucchCfg->resrc == NULLP)
768 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
771 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
772 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
774 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
779 /* valid for format 1, 2, 3, 4 */
780 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
781 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
782 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
783 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
785 if(macPucchCfg->schedReq)
787 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
788 if(schPucchCfg->schedReq == NULLP)
790 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
793 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
794 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
797 if(macPucchCfg->multiCsiCfg)
799 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
800 if(schPucchCfg->multiCsiCfg == NULLP)
802 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
805 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
806 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
809 //TODO: To add the support for spatial Config
810 schPucchCfg->spatialInfo = NULLP;
812 if(macPucchCfg->dlDataToUlAck)
814 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
815 if(schPucchCfg->dlDataToUlAck == NULLP)
817 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
820 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
821 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
825 if(macPucchCfg->powerControl)
827 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
828 if(schPucchCfg->powerControl == NULLP)
830 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
833 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
834 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
840 /*******************************************************************
842 * @brief function to free Pucch Format
846 * Function : freeSchPucchFormat
849 * function to free Pucch Format
851 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
852 * SchPucchResrcInfo pointer
854 * ****************************************************************/
856 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
860 case PUCCH_FORMAT_0 :
861 if(resrcInfo->SchPucchFormat.format0)
863 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
864 resrcInfo->SchPucchFormat.format0 = NULLP;
868 case PUCCH_FORMAT_1 :
869 if(resrcInfo->SchPucchFormat.format1)
871 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
872 resrcInfo->SchPucchFormat.format1 = NULLP;
876 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
877 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
881 case PUCCH_FORMAT_2 :
882 if(resrcInfo->SchPucchFormat.format2)
884 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
885 resrcInfo->SchPucchFormat.format2 = NULLP;
889 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
890 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
894 case PUCCH_FORMAT_3 :
895 if(resrcInfo->SchPucchFormat.format3)
897 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
898 resrcInfo->SchPucchFormat.format3 = NULLP;
902 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
903 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
907 case PUCCH_FORMAT_4 :
908 if(resrcInfo->SchPucchFormat.format4)
910 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
911 resrcInfo->SchPucchFormat.format4 = NULLP;
915 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
916 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
925 /*******************************************************************
927 * @brief function to free Pucch Resrc Cfg
931 * Function : freePucchResrcCfg
934 * function to free Pucch Resrc Cfg
936 * @params[in] SchPucchResrcCfg pointer,
938 * ****************************************************************/
940 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
944 /* free Resrc To AddMod List */
945 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
947 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
948 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
949 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
951 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
952 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
955 /*******************************************************************
957 * @brief function to free Pucch Sched Req Cfg
961 * Function : freePucchSchedReqCfg
964 * function to free Pucch Sched Req Cfg
966 * @params[in] SchPucchSchedReqCfg pointer,
968 * ****************************************************************/
970 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
974 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
976 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
978 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
979 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
982 /*******************************************************************
984 * @brief function to free Ul Bwp Pucch Cfg
988 * Function : freeUlBwpPucchCfg
991 * function to free Ul Bwp Pucch Cfg
993 * @params[in] SchPucchCfg pointer,
995 * ****************************************************************/
997 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
999 if(schPucchCfg->resrcSet)
1001 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1002 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1004 if(schPucchCfg->resrc)
1006 freePucchResrcCfg(schPucchCfg->resrc);
1008 if(schPucchCfg->format1)
1010 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1012 if(schPucchCfg->format2)
1014 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1016 if(schPucchCfg->format3)
1018 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1020 if(schPucchCfg->format4)
1022 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1024 if(schPucchCfg->schedReq)
1026 freePucchSchedReqCfg(schPucchCfg->schedReq);
1028 if(schPucchCfg->spatialInfo)
1030 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1031 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1033 if(schPucchCfg->multiCsiCfg)
1035 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1036 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1038 if(schPucchCfg->dlDataToUlAck)
1040 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1041 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1043 if(schPucchCfg->powerControl)
1045 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1046 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1050 /*******************************************************************
1052 * @brief Fills initail UL BWP config to send to scheduler
1056 * Function : fillInitialUlBwp
1058 * Functionality: Fills initail UL BWP config to send to sch
1060 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1061 * schInitUlBwp : Initial UL BWP cfg to be filled
1062 * @return ROK - success
1065 * ****************************************************************/
1066 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1068 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1069 if(schInitUlBwp->pucchCfgPres)
1071 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1072 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1074 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1075 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1079 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1080 if(schInitUlBwp->puschCfgPres)
1082 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1083 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1085 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1092 /*******************************************************************
1094 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1098 * Function : fillInitDlBwpPdcchCfg
1101 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1103 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1104 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1105 * @return ROK - success
1108 * ****************************************************************/
1109 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1113 /* Fill CORESET info */
1114 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1115 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1117 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1118 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1122 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1124 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1125 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1126 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1127 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1128 schPdcchCfg->cRSetToAddModList[idx].duration = \
1129 macPdcchCfg.cRSetToAddModList[idx].duration;
1130 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1131 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1132 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1133 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1134 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1135 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1138 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1139 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1141 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1142 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1146 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1151 /* Fill Search space info */
1152 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1153 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1155 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1156 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1159 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1161 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1162 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1163 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1164 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1165 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1166 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1167 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1168 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1169 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1170 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1171 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1172 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1173 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1174 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1175 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1176 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1177 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1178 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1179 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1180 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1181 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1182 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1183 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1186 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1187 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1189 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1190 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1193 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1201 /*******************************************************************
1203 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1207 * Function : fillInitDlBwpPdschCfg
1210 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1212 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1213 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1214 * @return ROK - success
1217 * ****************************************************************/
1218 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1222 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1223 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1224 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1225 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1226 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1228 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1229 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1233 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1235 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1237 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1238 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1240 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1243 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1245 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1246 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1247 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1248 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1249 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1250 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1253 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1254 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1255 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1256 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1258 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1260 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1262 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1263 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1268 /*******************************************************************
1270 * @brief Fill Initial DL BWP for SCH UE config
1274 * Function : fillInitialDlBwp
1276 * Functionality: Fill Initial DL BWP for SCH UE config
1278 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1279 * schInitDlBwp : Inital DL BWP cfg to be filled
1280 * @return ROK - success
1283 * ****************************************************************/
1284 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1286 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1287 if(schInitDlBwp->pdcchCfgPres)
1289 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1291 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1296 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1297 if(schInitDlBwp->pdschCfgPres)
1299 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1301 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1308 /*******************************************************************
1310 * @brief Fills Sp Cell config to be sent to scheduler
1314 * Function : fillSpCellCfg
1316 * Functionality: Fills Sp Cell config to be sent to scheduler
1318 * @params[in] macSpCellCfg : SP cell cfg at MAC
1319 * schSpCellCfg : SP cell cfg to be filled
1320 * @return ROK - success
1323 * ****************************************************************/
1324 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1327 SchServCellCfgInfo *servCellCfg;
1329 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1330 servCellCfg = &schSpCellCfg->servCellCfg;
1332 /* Fill initial DL BWP */
1333 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1334 &servCellCfg->initDlBwp) != ROK )
1336 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1340 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1341 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1343 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD [%d] exceeds max limit [%d]",\
1344 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1347 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1349 memcpy(&servCellCfg->dlBwpToAddList[idx], &macSpCellCfg.servCellCfg.dlBwpToAddList[idx], sizeof(DlBwpInfo));
1351 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1352 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1353 servCellCfg->bwpInactivityTmr = NULL;
1354 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1356 /* TODO : This is an optional parameter, not filled currently */
1359 /* Fill PDSCH serving cell config */
1360 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1361 &servCellCfg->pdschServCellCfg) != ROK)
1363 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1367 /* Fill Initail UL BWP */
1368 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1369 &servCellCfg->initUlBwp) != ROK)
1371 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1375 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1376 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1378 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD [%d] exceeds max limit [%d]",\
1379 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1382 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1384 memcpy(&servCellCfg->ulBwpToAddList[idx], &macSpCellCfg.servCellCfg.ulBwpToAddList[idx], sizeof(UlBwpInfo));
1386 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1391 /*******************************************************************
1393 * @brief Fills Sp Cell Reconfig to be sent to scheduler
1397 * Function : fillSpCellRecfg
1399 * Functionality: Fills Sp Cell Reconfig to be sent to scheduler
1401 * @params[in] macSpCellRecfg : SP cell Recfg at MAC
1402 * schSpCellRecfg : SP cell Recfg to be filled
1403 * @return ROK - success
1406 * ****************************************************************/
1407 uint8_t fillSpCellRecfg(SpCellRecfg macSpCellRecfg, SchSpCellRecfg *schSpCellRecfg)
1410 SchServCellRecfgInfo *servCellRecfg;
1412 schSpCellRecfg->servCellIdx = macSpCellRecfg.servCellIdx;
1413 servCellRecfg = &schSpCellRecfg->servCellRecfg;
1415 /* Fill initial DL BWP */
1416 if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
1417 &servCellRecfg->initDlBwp) != ROK )
1419 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1423 servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
1424 if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
1426 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1427 servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
1430 for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
1432 memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
1434 servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
1435 if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
1437 DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
1438 servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
1441 for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
1443 memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
1445 servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
1446 servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
1447 servCellRecfg->bwpInactivityTmr = NULL;
1448 if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
1450 /* TODO : This is an optional parameter, not filled currently */
1453 /* Fill PDSCH serving cell config */
1454 if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
1455 &servCellRecfg->pdschServCellCfg) != ROK)
1457 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1461 /* Fill Initail UL BWP */
1462 if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
1463 &servCellRecfg->initUlBwp) != ROK)
1465 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1469 servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
1470 if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
1472 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1473 servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
1476 for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
1478 memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
1480 servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
1481 if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
1483 DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
1484 servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
1487 for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
1489 memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
1491 servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
1496 /*******************************************************************
1498 * @brief Sends UE configuration to Scheduler
1502 * Function : sendUeReqToSch
1504 * Functionality: sends UE configuration to Scheduler
1506 * @params[in] Pst and Ue configuration
1507 * @return ROK - success
1510 * ****************************************************************/
1512 uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
1517 case EVENT_MAC_UE_CREATE_REQ:
1519 SchUeCfgReq *schUeCfgReq = NULLP;
1520 schUeCfgReq = (SchUeCfgReq *)schUeCfg;
1521 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1522 return(SchMessageRouter(&schPst, (void *)schUeCfgReq));
1524 case EVENT_MAC_UE_RECONFIG_REQ:
1526 SchUeRecfgReq *schUeRecfgReq = NULLP;
1527 schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
1528 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1529 return(SchMessageRouter(&schPst, (void *)schUeRecfgReq));
1533 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1539 /*******************************************************************
1541 * @brief Fills Sch Drb Qos Information
1545 * Function : fillSchDrbQosInfo
1547 * Functionality: Fills Sch Drb Qos Information
1549 * @params[in] macLcCfg : Logical channel Cfg at MAC
1550 * schLcCfg : LC cfg to fill at scheduler
1551 * @return ROK - success
1554 * ****************************************************************/
1555 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1557 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1558 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1560 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1561 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1562 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1563 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1565 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1567 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1568 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1569 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1570 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1571 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1572 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1573 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1574 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1576 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1577 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1578 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1579 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1580 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1581 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1582 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1583 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1584 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1587 /*******************************************************************
1589 * @brief Fill SCH UL logical channel configuration
1593 * Function : fillSchUlLcCfg
1595 * Functionality: Fills Sch Ul Lc configuration
1597 * @params[in] macLcCfg : Logical channel Cfg at MAC
1598 * schLcCfg : LC cfg to fill at scheduler
1601 * ****************************************************************/
1603 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1605 schUlLcCfg->priority= macUlLcCfg->priority;
1606 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1607 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1608 schUlLcCfg->pbr = macUlLcCfg->pbr;
1609 schUlLcCfg->bsd = macUlLcCfg->bsd;
1612 /*******************************************************************
1614 * @brief Fill logical channel configuration
1618 * Function : fillLogicalChannelCfg
1620 * Functionality: Fill logical channel configuration
1622 * @params[in] macLcCfg : Logical channel Cfg at MAC
1623 * schLcCfg : LC cfg to fill at scheduler
1624 * @return ROK - success
1627 * ****************************************************************/
1628 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1632 schLcCfg->lcId = macLcCfg->lcId;
1633 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1634 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1636 if(macLcCfg->drbQos)
1638 if(!schLcCfg->drbQos)
1640 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1641 if(!schLcCfg->drbQos)
1643 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1649 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1656 schLcCfg->drbQos = NULLP;
1661 if(macLcCfg->snssai)
1663 if(!schLcCfg->snssai)
1665 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1666 if(!schLcCfg->snssai)
1668 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1674 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1675 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1677 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1683 schLcCfg->snssai = NULLP;
1690 /*******************************************************************
1692 * @brief Fills Logical channel Cfg List to Add
1696 * Function : fillSchLcCfgList
1698 * Functionality: Fills Logical channel Cfg List to Add
1700 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1701 * @return ROK - success
1704 * ****************************************************************/
1706 uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1710 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1712 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1714 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1717 schUeCfg->numLcsToAdd++;
1722 /*******************************************************************
1724 * @brief Fills Logical channel Recfg List to Add/Mod/Del
1728 * Function : fillSchLcRecfgList
1730 * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
1732 * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
1733 * @return ROK - success
1736 * ****************************************************************/
1738 uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1743 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
1745 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
1747 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1750 schUeRecfg->numLcsToAdd++;
1753 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
1755 schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
1756 schUeRecfg->numLcsToDel++;
1759 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
1761 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
1763 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1766 schUeRecfg->numLcsToMod++;
1771 /*******************************************************************
1773 * @brief Fills and sends UE configuration to Scheduler
1777 * Function : fillSchUeCfg
1779 * Functionality: Fills and sends UE configuration to Scheduler
1781 * @params[in] Ue configuration from DU APP
1782 * @return ROK - success
1785 * ****************************************************************/
1786 uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1790 schUeCfg->cellId = ueCfg->cellId;
1791 schUeCfg->ueId = ueCfg->ueId;
1792 schUeCfg->crnti = ueCfg->crnti;
1793 /* Copy MAC cell group config */
1794 if(ueCfg->macCellGrpCfgPres == true)
1796 schUeCfg->macCellGrpCfgPres = true;
1797 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1798 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1800 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1804 if(ueCfg->phyCellGrpCfgPres == true)
1806 schUeCfg->phyCellGrpCfgPres = true;
1807 /* Copy Physical cell group config */
1808 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1809 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1811 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1816 if(ueCfg->spCellCfgPres == true)
1818 schUeCfg->spCellCfgPres = true;
1819 /* Copy sp cell config */
1820 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1821 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1823 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1827 if(ueCfg->ambrCfg != NULLP)
1829 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1830 if(!schUeCfg->ambrCfg)
1832 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1835 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1839 schUeCfg->ambrCfg = NULLP;
1841 /* Fill DL modulation infor */
1842 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1843 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1844 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1846 /* Fill UL modulation infor */
1847 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1848 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1849 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1851 /* Fill sch Lc Cfg to Add*/
1852 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1855 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1862 /*******************************************************************
1864 * @brief Fills and sends UE Re-configuration to Scheduler
1868 * Function : fillSchUeRecfg
1870 * Functionality: Fills and sends UE Reconfiguration to Scheduler
1872 * @params[in] Ue configuration from DU APP
1873 * @return ROK - success
1876 * ****************************************************************/
1877 uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1881 schUeRecfg->cellId = ueRecfg->cellId;
1882 schUeRecfg->ueId = ueRecfg->ueId;
1883 schUeRecfg->crnti = ueRecfg->crnti;
1884 schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
1885 /* Copy MAC cell group config */
1886 if(ueRecfg->macCellGrpRecfgPres == true)
1888 schUeRecfg->macCellGrpRecfgPres = true;
1889 memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
1890 if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
1892 DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
1896 if(ueRecfg->phyCellGrpRecfgPres == true)
1898 schUeRecfg->phyCellGrpRecfgPres = true;
1899 /* Copy Physical cell group config */
1900 memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
1901 if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
1903 DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
1908 if(ueRecfg->spCellRecfgPres == true)
1910 schUeRecfg->spCellRecfgPres = true;
1911 /* Copy sp cell config */
1912 memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
1913 if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
1915 DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
1919 if(ueRecfg->ambrRecfg != NULLP)
1921 MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
1922 if(!schUeRecfg->ambrRecfg)
1924 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1927 schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
1931 schUeRecfg->ambrRecfg = NULLP;
1933 /* Fill DL modulation infor */
1934 schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
1935 schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
1936 schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
1938 /* Fill UL modulation infor */
1939 schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
1940 schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
1941 schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
1943 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1944 ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
1947 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
1952 schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
1958 /*******************************************************************
1960 * @brief Update UeUlCb Lc List
1964 * Function : updateMacUlCb
1966 * Functionality: Update UeUlCb Lc List
1968 * @params[in] delIdx, UeUlCb pointer
1971 * ****************************************************************/
1973 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1977 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1979 /* Moving the array element to one step ahead */
1980 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1981 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1983 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1985 /*Checking the Memory Leakage of Last Index*/
1986 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
1988 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
1990 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
1994 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
2000 /*******************************************************************
2002 * @brief Update UeDlCb Lc List
2006 * Function : updateMacDlCb
2008 * Functionality: Update UeDlCb Lc List
2010 * @params[in] delIdx, UeDlCb pointer
2013 * ****************************************************************/
2015 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
2019 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
2021 /* Moving the array element to one step ahead */
2022 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
2023 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
2025 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2027 /*Checking the Memory Leakage of Last Index*/
2028 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
2030 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
2032 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
2036 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
2042 /*******************************************************************
2044 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
2048 * Function : updateMacUlLcCtxt
2050 * Functionality: Update UeUlCb Lc List
2052 * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
2053 * ueLcCfg(received from DUAPP)
2054 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2057 * ****************************************************************/
2058 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2060 uint8_t ueLcIdx = 0;
2062 /*Traversing UL LC to be updated/Deleted*/
2063 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
2065 if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2067 /*Modify UL LC CB */
2068 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
2070 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2072 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2075 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2079 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
2081 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2084 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2087 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2088 ueLcCfg->lcId,ueLcIdx);
2091 else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2093 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
2094 (ulInfo->numUlLc)--;
2095 updateMacUlCb(ueLcIdx, ulInfo);
2096 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2102 /*******************************************************************
2104 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
2108 * Function : updateMacDlLcCtxt
2110 * Functionality: Update UeDlCb Lc List
2112 * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
2113 * ueLcCfg(received from DUAPP)
2114 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2117 * ****************************************************************/
2118 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2120 uint8_t ueLcIdx = 0;
2122 /*Traversing DL LC to be updated/Deleted*/
2123 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
2125 if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2127 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2129 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2132 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2136 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
2138 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2141 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2144 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2145 ueLcCfg->lcId,ueLcIdx);
2148 else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2150 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
2151 (dlInfo->numDlLc)--;
2152 updateMacDlCb(ueLcIdx, dlInfo);
2153 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2159 /*******************************************************************
2161 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2165 * Function : fillMacLcCfgList
2167 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2169 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2170 * @return ROK - success
2173 * ****************************************************************/
2175 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
2179 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
2181 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2183 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2185 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2186 if(ueCfg->lcCfgList[lcIdx].drbQos)
2188 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2189 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2191 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2192 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2194 if(ueCfg->lcCfgList[lcIdx].snssai)
2196 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2198 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2200 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2202 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2205 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2206 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2208 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2209 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2213 /*Filling DL LC CB */
2214 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2215 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2216 ueCb->dlInfo.numDlLc++;
2217 /*Filling UL LC CB */
2218 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2219 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
2220 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2221 ueCb->ulInfo.numUlLc++;
2227 /*******************************************************************
2229 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2233 * Function : updateMacLcCfgList
2235 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2237 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2238 * @return ROK - success
2241 * ****************************************************************/
2243 uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2247 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
2249 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2251 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2253 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2254 if(ueRecfg->lcCfgList[lcIdx].drbQos)
2256 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2257 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2259 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2260 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2262 if(ueRecfg->lcCfgList[lcIdx].snssai)
2264 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2266 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2268 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2270 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2273 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2274 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2276 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2277 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2281 /*Filling DL LC CB */
2282 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2283 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2284 ueCb->dlInfo.numDlLc++;
2285 /*Filling UL LC CB */
2286 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2287 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
2288 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2289 ueCb->ulInfo.numUlLc++;
2290 }/*End of Add Config */
2292 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
2294 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2296 updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2297 updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2300 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
2302 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2304 updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2305 updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2311 /*******************************************************************
2313 * @brief Fills MAC UE Cb Cfg
2317 * Function : fillMacUeCb
2319 * Functionality: Fills MAC UE Cb Cfg
2321 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2323 * @return ROK - success
2326 * ****************************************************************/
2328 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
2332 ueCb->ueId = ueCfg->ueId;
2333 ueCb->crnti = ueCfg->crnti;
2334 ueCb->cellCb = macCb.macCell[cellIdx];
2335 if(ueCfg->spCellCfgPres)
2337 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2338 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2341 /*TODO: To check the bsr value during implementation */
2342 if(ueCfg->macCellGrpCfgPres)
2344 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2345 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2346 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2348 ret = fillMacLcCfgList(ueCb, ueCfg);
2351 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2356 /*******************************************************************
2358 * @brief Fills MAC UE Cb Cfg
2362 * Function : updateMacUeCb
2364 * Functionality: updateMacUeCbs MAC UE Cb Cfg
2366 * @params[in] MAC UE Cb Recfg , MAC UE Configuration
2368 * @return ROK - success
2371 * ****************************************************************/
2373 uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
2377 ueCb->ueId = ueRecfg->ueId;
2378 ueCb->crnti = ueRecfg->crnti;
2379 ueCb->cellCb = macCb.macCell[cellIdx];
2380 if(ueRecfg->spCellRecfgPres)
2382 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2383 ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2386 /*TODO: To check the bsr value during implementation */
2387 if(ueRecfg->macCellGrpRecfgPres)
2389 ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
2390 ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
2391 ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
2393 ret = updateMacLcCfgList(ueCb, ueRecfg);
2396 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
2398 ueCb->transmissionAction = ueRecfg->transmissionAction;
2403 /*******************************************************************
2405 * @brief Function to update Mac Ra Cb
2409 * Function : updateMacRaCb
2411 * Functionality: Function to update Mac Ra Cb
2413 * @params[in] cellIdx, Mac Ue Cb
2414 * @return ROK - success
2417 * ****************************************************************/
2419 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2422 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2424 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2428 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2434 /*******************************************************************
2436 * @brief Function to delete Mac Ra Cb
2440 * Function : deleteMacRaCb
2442 * Functionality: Function to delete Mac Ra Cb
2444 * @params[in] cellIdx, Mac Ue Cb
2447 * ****************************************************************/
2449 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2452 MacRaCbInfo *raCb = ueCb->raCb;
2454 if(raCb && (raCb->crnti == ueCb->crnti))
2456 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2457 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2459 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2460 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2462 memset(raCb, 0, sizeof(MacRaCbInfo));
2466 /*******************************************************************
2468 * @brief Creates UE Cb
2472 * Function : createUeCb
2474 * Functionality: Creates UE Cb
2476 * @params[in] MAC UE Configuration
2477 * @return ROK - success
2480 * ****************************************************************/
2481 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2484 uint8_t hqProcIdx = 0;
2486 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2487 &&(ueCb->state == UE_STATE_ACTIVE))
2489 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2494 memset(ueCb, 0, sizeof(MacUeCb));
2495 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2498 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2503 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2504 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2506 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2509 /* If UE has not requested for RACH yet, it means UE context is created for a
2511 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2513 ueCb->state = UE_STATE_ACTIVE;
2514 macCb.macCell[cellIdx]->numActvUe++;
2515 updateMacRaCb(cellIdx, ueCb);
2518 ueCb->state = UE_HANDIN_IN_PROGRESS;
2526 /*******************************************************************
2528 * @brief Modify UE Cb Cfg
2532 * Function : modifyUeCb
2534 * Functionality: modify UE Cb
2536 * @params[in] MAC UE Configuration
2537 * @return ROK - success
2540 * ****************************************************************/
2541 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2545 if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
2546 &&(ueCb->state == UE_STATE_ACTIVE))
2548 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
2549 ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
2552 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2564 /*******************************************************************
2566 * @brief Creates UE Cb and fills ueCfg
2570 * Function : procMacUeCfgData
2572 * Functionality: Creates UE Cb and fills ueCfg
2574 * @params[in] MAC UE Configuration
2575 * @return ROK - success
2578 * ****************************************************************/
2580 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2582 uint8_t ret = ROK, ueId = 0;
2583 uint16_t cellIdx, cellId;
2584 MacUeCb *ueCb = NULLP;
2588 cellId = ueCfg->cellId;
2591 else if(ueRecfg != NULLP)
2593 cellId = ueRecfg->cellId;
2594 ueId = ueRecfg->ueId;
2598 GET_CELL_IDX(cellId, cellIdx);
2600 /* Validate cell id */
2601 if(macCb.macCell[cellIdx]->cellId != cellId)
2603 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
2607 /* Check if max number of UE configured */
2608 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2610 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2614 /* Check if UE already configured */
2615 ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
2619 case EVENT_UE_CONFIG_RSP_TO_MAC:
2621 ret = createUeCb(cellIdx, ueCb, ueCfg);
2623 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2627 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2629 ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
2631 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2642 /*******************************************************************
2644 * @brief Function to store the UeCfg Data
2648 * Function : copyToTmpData
2650 * Functionality: Function to store the UeCfg Data
2652 * @params[in] MacUeCfg pointer
2653 * @return ROK - success
2656 * ****************************************************************/
2658 uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2664 MacUeCfg *tmpData = NULLP;
2666 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2669 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2672 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2673 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2674 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2676 else if(ueRecfg != NULLP)
2678 MacUeRecfg *tmpData = NULLP;
2680 MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
2683 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2686 memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
2687 GET_CELL_IDX(ueRecfg->cellId, cellIdx);
2688 macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
2693 /*******************************************************************
2695 * @brief Handles UE create requst from DU APP
2699 * Function : MacProcUeCreateReq
2701 * Functionality: Handles UE create requst from DU APP
2704 * @return ROK - success
2707 * ****************************************************************/
2708 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2711 SchUeCfgReq schUeCfg;
2712 memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
2714 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2718 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2719 * case of UE in handover */
2720 if(ueCfg->crnti == 0)
2722 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2725 /*Storing received ueCfg in ueCfgTmpData */
2726 ret = copyToTmpData(ueCfg, NULLP);
2729 /*Sending Cfg Req to SCH */
2730 ret = fillSchUeCfg(&schUeCfg, ueCfg);
2732 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2735 /* Fill event and send UE create request to SCH */
2736 ret = sendUeReqToSch(pst, &schUeCfg);
2738 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2743 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2748 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2751 /* FREE shared memory */
2752 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2757 /*******************************************************************
2759 * @brief Fill and Send UE create response from MAC to DU APP
2763 * Function : MacSendUeCreateRsp
2765 * Functionality: Fill and Send UE create response from MAC to DUAPP
2767 * @params[in] MAC UE create result
2768 * SCH UE create response
2769 * @return ROK - success
2772 * ****************************************************************/
2773 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2775 MacUeCfgRsp *cfgRsp;
2778 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2781 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2785 /* Filling UE Config response */
2786 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2787 cfgRsp->cellId = schCfgRsp->cellId;
2788 cfgRsp->ueId = schCfgRsp->ueId;
2789 cfgRsp->result = result;
2791 /* Fill Post structure and send UE Create response*/
2792 memset(&rspPst, 0, sizeof(Pst));
2793 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2794 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2797 /*******************************************************************
2799 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2803 * Function : MacSendUeReconfigRsp
2805 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2807 * @params[in] MAC UE create result
2808 * SCH UE create response
2809 * @return ROK - success
2812 * ****************************************************************/
2813 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
2815 MacUeRecfgRsp *recfgRsp;
2818 MAC_ALLOC_SHRABL_BUF(recfgRsp, sizeof(MacUeRecfgRsp));
2821 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2825 /* Filling UE Config response */
2826 memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
2827 recfgRsp->cellId = schCfgRsp->cellId;
2828 recfgRsp->ueId = schCfgRsp->ueId;
2829 recfgRsp->result = result;
2831 /* Fill Post structure and send UE Create response*/
2832 memset(&rspPst, 0, sizeof(Pst));
2833 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2834 return (*macDuUeRecfgRspOpts[rspPst.selector])(&rspPst, recfgRsp);
2837 /*******************************************************************
2839 * @brief Function to return Mac Ue Cfg pointer
2843 * Function : getMacUeCfg
2846 * Function to return Mac Ue Cfg pointer
2848 * @params[in] cellIdx, ueId
2850 * @return MacUeCfg pointer - success
2853 * ****************************************************************/
2855 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2857 MacUeCfg *ueCfg = NULLP;
2858 if(macCb.macCell[cellIdx])
2860 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2864 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2869 /*******************************************************************
2871 * @brief Function to return Mac Ue Recfg pointer
2875 * Function : getMacUeRecfg
2878 * Function to return Mac Ue Recfg pointer
2880 * @params[in] cellIdx, ueId
2882 * @return MacUeRecfg pointer - success
2885 * ****************************************************************/
2887 MacUeRecfg *getMacUeRecfg(uint16_t cellIdx, uint8_t ueId)
2889 MacUeRecfg *ueRecfg = NULLP;
2890 if(macCb.macCell[cellIdx])
2892 ueRecfg = macCb.macCell[cellIdx]->ueRecfgTmpData[ueId-1];
2896 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeRecfg()");
2901 /*******************************************************************
2903 * @brief Processes UE create response from scheduler
2907 * Function : MacProcSchUeCfgRsp
2910 * Processes UE create response from scheduler
2911 * Sends UE create response to DU APP
2913 * @params[in] Pst : Post structure
2914 * schCfgRsp : Scheduler UE cfg response
2915 * @return ROK - success
2918 * ****************************************************************/
2919 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2921 uint8_t result = MAC_DU_APP_RSP_NOK;
2924 MacUeCfg *ueCfg = NULLP;
2926 #ifdef CALL_FLOW_DEBUG_LOG
2929 case EVENT_UE_CONFIG_RSP_TO_MAC:
2930 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2932 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2933 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2936 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2941 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2942 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2945 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2949 if(schCfgRsp->rsp != RSP_NOK)
2951 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2954 ret = procMacUeCfgData(pst, ueCfg, NULLP);
2957 result = MAC_DU_APP_RSP_OK;
2963 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2965 ret = MacSendUeCreateRsp(result, schCfgRsp);
2966 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2971 /*******************************************************************
2973 * @brief Processes UE create response from scheduler
2977 * Function : MacProcSchUeRecfgRsp
2980 * Processes UE ReConfig response from scheduler
2981 * Sends UE Reconfig response to DU APP
2983 * @params[in] Pst : Post structure
2984 * schRecfgRsp : Scheduler UE Recfg response
2985 * @return ROK - success
2988 * ****************************************************************/
2989 uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
2991 uint8_t result = MAC_DU_APP_RSP_NOK;
2994 MacUeRecfg *ueRecfg = NULLP;
2996 #ifdef CALL_FLOW_DEBUG_LOG
2999 case EVENT_UE_RECONFIG_RSP_TO_MAC:
3000 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
3003 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
3008 GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
3009 ueRecfg = getMacUeRecfg(cellIdx, schRecfgRsp->ueId);
3010 if(ueRecfg == NULLP)
3012 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3017 if(schRecfgRsp->rsp != RSP_NOK)
3019 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
3020 schRecfgRsp->crnti);
3023 ret = procMacUeCfgData(pst, NULLP, ueRecfg);
3026 result = MAC_DU_APP_RSP_OK;
3032 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
3033 schRecfgRsp->crnti);
3035 ret = MacSendUeReconfigRsp(result, schRecfgRsp);
3036 MAC_FREE(ueRecfg, sizeof(MacUeRecfg));
3041 /*******************************************************************
3043 * @brief Handles UE Reconfig requst from DU APP
3047 * Function : MacProcUeReconfigReq
3049 * Functionality: Handles UE Reconfig requst from DU APP
3052 * @return ROK - success
3055 * ****************************************************************/
3056 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg)
3059 SchUeRecfgReq schUeRecfg;
3060 memset(&schUeRecfg, 0, sizeof(SchUeRecfgReq));
3062 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueRecfg->crnti);
3066 /*Storing received ueRecfg in ueCfgTmpData */
3067 ret = copyToTmpData(NULLP, ueRecfg);
3070 /*Sending Cfg Req to SCH */
3071 ret = fillSchUeRecfg(&schUeRecfg, ueRecfg);
3073 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
3076 /* Fill event and send UE Reconfiguration request to SCH */
3077 ret = sendUeReqToSch(pst, &schUeRecfg);
3079 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
3084 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
3089 DU_LOG("\nERROR --> MAC : MAC UE Reconfiguration request processing failed");
3092 /* FREE shared memory */
3093 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(MacUeRecfg));
3097 /*******************************************************************
3099 * @brief Fill and Send UE Delete response from MAC to DU APP
3103 * Function : MacSendUeDeleteRsp
3105 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
3107 * @params[in] MAC UE delete result
3108 * SCH UE delete response
3109 * @return ROK - success
3112 * ****************************************************************/
3114 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
3116 MacUeDeleteRsp *deleteRsp;
3119 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
3122 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
3126 /* Filling UE delete response */
3127 deleteRsp->cellId = cellId;
3128 GET_UE_ID(crnti, deleteRsp->ueId);
3129 deleteRsp->result = result;
3131 /* Fill Post structure and send UE delete response*/
3132 memset(&rspPst, 0, sizeof(Pst));
3133 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
3134 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
3137 /*******************************************************************
3139 * @brief freeing the Pucch Resrc Cfg
3143 * Function : deletePucchResourcesCfg
3145 * Functionality: freeing the Pucch Resrc Cfg
3147 * @params[in] PucchResrcCfg *resrcCfg
3148 * @return ROK - success
3151 * ****************************************************************/
3153 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
3156 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
3158 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
3160 case PUCCH_FORMAT_0:
3162 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
3165 case PUCCH_FORMAT_1:
3167 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
3170 case PUCCH_FORMAT_2:
3172 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
3175 case PUCCH_FORMAT_3:
3177 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
3180 case PUCCH_FORMAT_4:
3182 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
3190 /*******************************************************************
3192 * @brief Processes UE delete response from scheduler
3196 * Function : MacProcSchUeDeleteRsp
3199 * Processes UE delete from scheduler
3201 * @params[in] Pst : Post structure
3202 * schUeDelRsp : Scheduler UE delete respons
3203 * @return ROK - success
3206 * ****************************************************************/
3208 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
3210 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
3212 uint8_t ret = RFAILED;
3213 UeDeleteStatus result;
3214 DlHarqEnt *dlHarqEnt;
3216 #ifdef CALL_FLOW_DEBUG_LOG
3217 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
3222 if(schUeDelRsp->rsp == RSP_OK)
3224 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
3225 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
3226 if(macCb.macCell[cellIdx])
3228 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
3231 /*C-RNTI value is out of Acceptable range*/
3232 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
3233 result = UEID_INVALID;
3237 GET_UE_ID(schUeDelRsp->crnti, ueId);
3238 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
3241 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
3243 /*Looping around LCs to free S-NSSAI memory*/
3244 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
3246 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3248 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
3250 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3253 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
3254 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
3257 while(dlHarqEnt->harqProcCb[idx].numTb)
3260 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
3261 dlHarqEnt->harqProcCb[idx].numTb--;
3265 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
3266 macCb.macCell[cellIdx]->numActvUe--;
3267 result = DEL_SUCCESSFUL;
3272 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
3273 result = UEID_INVALID;
3279 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
3280 result = CELLID_INVALID;
3285 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID;
3287 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
3289 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
3294 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
3300 /*******************************************************************
3302 * @brief Sends UE delete req to Scheduler
3306 * Function : sendUeDelReqToSch
3308 * Functionality: sends UE delete req to Scheduler
3310 * @params[in] Pst *pst, MacUeDelete *ueDelete
3311 * @return ROK - success
3314 * ****************************************************************/
3316 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
3318 if(ueDelete != NULLP)
3321 SchUeDelete schUeDel;
3323 memset(&schUeDel, 0, sizeof(SchUeDelete));
3324 schUeDel.cellId = ueDelete->cellId;
3325 schUeDel.crnti = ueDelete->crnti;
3326 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3327 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
3328 return(SchMessageRouter(&schPst, (void *)&schUeDel));
3332 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
3338 /*******************************************************************
3340 * @brief Handles UE Delete requst from DU APP
3344 * Function : MacProcUeDeleteReq
3346 * Functionality: Handles UE Delete requst from DU APP
3348 * @params[in] Pst *pst, MacUeDelete *ueDelete
3349 * @return ROK - success
3352 * ****************************************************************/
3354 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
3358 UeDeleteStatus result=DEL_SUCCESSFUL;
3359 MacUeCb *ueCb = NULLP;
3360 MacCellCb *cellCb = NULLP;
3362 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
3366 GET_CELL_IDX(ueDelete->cellId, cellIdx);
3367 cellCb = macCb.macCell[cellIdx];
3370 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
3371 if(ueCb->crnti == ueDelete->crnti)
3373 ret = sendUeDelReqToSch(pst, ueDelete);
3376 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
3382 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
3383 result = UEID_INVALID;
3388 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
3389 result = CELLID_INVALID;
3392 if(result != DEL_SUCCESSFUL)
3394 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
3395 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3401 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
3407 /**********************************************************************
3409 **********************************************************************/