1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains UE management handling functionality for MAC */
21 /* header include files (.h) */
22 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "mac_sch_interface.h"
27 #include "lwr_mac_upr_inf.h"
29 #include "mac_utils.h"
31 MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
33 packDuMacUeCfgRsp, /* packing for loosely coupled */
34 DuProcMacUeCfgRsp, /* packing for tightly coupled */
35 packDuMacUeCfgRsp /* packing for light weight loosly coupled */
38 MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] =
40 packDuMacUeRecfgRsp, /* packing for loosely coupled */
41 DuProcMacUeRecfgRsp, /* packing for tightly coupled */
42 packDuMacUeRecfgRsp /* packing for light weight loosly coupled */
45 MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] =
47 packDuMacUeDeleteRsp, /* packing for loosely coupled */
48 DuProcMacUeDeleteRsp, /* packing for tightly coupled */
49 packDuMacUeDeleteRsp /* packing for light weight loosly coupled */
52 MacDuUeResetRspFunc macDuUeResetRspOpts[] =
54 packDuMacUeResetRsp, /* packing for loosely coupled */
55 DuProcMacUeResetRsp, /* packing for tightly coupled */
56 packDuMacUeResetRsp /* packing for light weight loosly coupled */
59 MacDuUeSyncStatusIndFunc macDuUeSyncStatusIndOpts[] =
61 packDuMacUeSyncStatusInd, /* packing for loosely coupled */
62 DuProcMacUeSyncStatusInd, /* packing for tightly coupled */
63 packDuMacUeSyncStatusInd /* packing for light weight loosly coupled */
66 /*******************************************************************
68 * @brief Fill and Send UE Sync Status Indication from MAC to DU APP
72 * Function : MacSendUeSyncStatusInd
74 * Functionality: Fill and Send UE Sync Status Indication from MAC to DUAPP
76 * @params[in] uint16_t cellId, uint16_t ueId, SyncStatus status
77 * @return ROK - success
80 * ****************************************************************/
82 uint8_t MacSendUeSyncStatusInd(uint16_t cellId, uint16_t ueId, SyncStatus status)
84 MacUeSyncStatusInd *ueSyncStatusInd;
87 MAC_ALLOC_SHRABL_BUF(ueSyncStatusInd, sizeof(MacUeSyncStatusInd));
90 DU_LOG("\nERROR --> MAC : Memory allocation for UE Sync Status Indication failed");
94 /* Filling UE Sync Status Indication */
95 ueSyncStatusInd->cellId = cellId;
96 ueSyncStatusInd->ueId = ueId;
97 ueSyncStatusInd->status = status;
99 /* Fill Post structure and send UE Sync Status Indication */
100 memset(&rspPst, 0, sizeof(Pst));
101 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_SYNC_STATUS_IND);
102 return (*macDuUeSyncStatusIndOpts[rspPst.selector])(&rspPst, ueSyncStatusInd);
105 /*******************************************************************
107 * @brief Fills mac cell group config to be sent to scheduler
111 * Function : fillMacCellGroupCfg
113 * Functionality: Fills mac cell group config to be sent to sch
115 * @params[in] macCellGrp : mac cell group config at MAC
116 * *macCellGrpCfg : mac cell group cfg to be filled
117 * @return ROK - success
120 * ****************************************************************/
121 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
124 SchSchedReqCfg *schedReqCfg;
127 /* Copy scheduling request config */
128 schedReqCfg = &macCellGrpCfg->schedReqCfg;
129 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
130 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
132 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
133 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
136 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
138 schedReqCfg->addModList[idx].schedReqId = \
139 macCellGrp.schReqCfg.addModList[idx].schedReqId;
140 schedReqCfg->addModList[idx].srProhibitTmr = \
141 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
142 schedReqCfg->addModList[idx].srTransMax = \
143 macCellGrp.schReqCfg.addModList[idx].srTransMax;
145 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
147 /* copy TAG config */
148 tagCfg = &macCellGrpCfg->tagCfg;
149 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
150 if(tagCfg->addModListCount > MAX_NUM_TAGS)
152 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
153 tagCfg->addModListCount, MAX_NUM_TAGS);
156 for(idx = 0; idx < tagCfg->addModListCount; idx++)
158 tagCfg->addModList[idx].tagId = \
159 macCellGrp.tagCfg.addModList[idx].tagId;
160 tagCfg->addModList[idx].timeAlignmentTmr = \
161 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
163 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
165 /* Copy PHR config */
166 if(macCellGrp.phrCfgSetupPres)
168 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
169 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
170 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
171 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
172 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
173 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
174 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
178 /* Copy Drx configuration */
179 macCellGrpCfg->drxCfgPresent = true;
180 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs;
181 if(!macCellGrp.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
182 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
183 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
185 macCellGrpCfg->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
186 macCellGrp.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
187 macCellGrpCfg->drxCfg.drxInactivityTimer = macCellGrp.drxCfg.drxInactivityTimer;
188 macCellGrpCfg->drxCfg.drxHarqRttTimerDl = macCellGrp.drxCfg.drxHarqRttTimerDl;
189 macCellGrpCfg->drxCfg.drxHarqRttTimerUl = macCellGrp.drxCfg.drxHarqRttTimerUl;
190 macCellGrpCfg->drxCfg.drxRetransmissionTimerDl = macCellGrp.drxCfg.drxRetransmissionTimerDl;
191 macCellGrpCfg->drxCfg.drxRetransmissionTimerUl = macCellGrp.drxCfg.drxRetransmissionTimerUl;
192 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellGrp.drxCfg.drxLongCycleStartOffset.\
193 drxLongCycleStartOffsetChoice;
194 macCellGrpCfg->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellGrp.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
195 macCellGrpCfg->drxCfg.shortDrxPres = macCellGrp.drxCfg.shortDrxPres;
196 if(macCellGrpCfg->drxCfg.shortDrxPres)
198 macCellGrpCfg->drxCfg.shortDrx.drxShortCycle = macCellGrp.drxCfg.shortDrx.drxShortCycle;
199 macCellGrpCfg->drxCfg.shortDrx.drxShortCycleTimer = macCellGrp.drxCfg.shortDrx.drxShortCycleTimer;
201 macCellGrpCfg->drxCfg.drxSlotOffset = macCellGrp.drxCfg.drxSlotOffset;
206 /*******************************************************************
208 * @brief Fills phy cell group config to be sent to scheduler
212 * Function : fillPhyCellGroupCfg
214 * Functionality: Fills phy cell group config to be sent to sch
216 * @params[in] macUeCfg : Phy cell group config at MAC
217 * *schPhyCellGrp : phy cell group config to be filled
218 * @return ROK - success
221 * ****************************************************************/
222 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
224 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
225 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
230 /*******************************************************************
232 * @brief Fills PDSCh serving cell config to send to scheduler
236 * Function : fillPdschServCellCfg
238 * Functionality: Fills PDSCh serving cell config to send to scheduler
240 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
241 * *schPdschCfg : Pdsch serving cell config to be filled
242 * @return ROK - success
245 * ****************************************************************/
246 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
248 if(macPdschCfg.maxMimoLayers)
250 if(!schPdschCfg->maxMimoLayers)
252 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
253 if(!schPdschCfg->maxMimoLayers)
255 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
259 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
263 schPdschCfg->maxMimoLayers = NULLP;
266 schPdschCfg->numHarqProcForPdsch = \
267 macPdschCfg.numHarqProcForPdsch;
269 if(macPdschCfg.maxCodeBlkGrpPerTb)
271 if(!schPdschCfg->maxCodeBlkGrpPerTb)
273 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
274 if(!schPdschCfg->maxCodeBlkGrpPerTb)
276 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
280 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
284 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
287 if(macPdschCfg.codeBlkGrpFlushInd)
289 if(!schPdschCfg->codeBlkGrpFlushInd)
291 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
292 if(!schPdschCfg->codeBlkGrpFlushInd)
294 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
298 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
302 schPdschCfg->codeBlkGrpFlushInd = NULLP;
305 if(macPdschCfg.xOverhead)
307 if(!schPdschCfg->xOverhead)
309 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
310 if(!schPdschCfg->xOverhead)
312 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
316 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
320 schPdschCfg->xOverhead = NULLP;
326 /*******************************************************************
328 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
332 * Function : fillInitalUlBwpPuschCfg
335 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
337 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
338 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
339 * @return ROK - success
342 * ****************************************************************/
343 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
347 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
348 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
349 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
350 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
351 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
352 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
354 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
355 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
357 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
358 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
361 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
363 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
364 macPuschCfg.timeDomRsrcAllocList[idx].k2;
365 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
366 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
367 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
368 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
369 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
370 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
373 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
377 /*******************************************************************
379 * @brief Function to fillResrcSetList sent by DU
383 * Function : fillResrcSetList
385 * Functionality: Function to fillResrcSetList sent by DU
387 * @params[in] PucchResrcSetCfg pointer,
388 * SchPucchResrcSetCfg pointer
391 * ****************************************************************/
393 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
395 uint8_t arrIdx, rsrcListIdx;
397 /* ResrcSetToAddModList */
398 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
399 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
401 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
402 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
404 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
405 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
407 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
408 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
409 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
410 resrcListCount; rsrcListIdx++)
412 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
413 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
416 /* ResrcSetToRelList */
417 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
418 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
420 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
424 /*******************************************************************
426 * @brief Function to fillResrcList sent by DU
430 * Function : fillResrcList
432 * Functionality: Function to fillResrcList sent by DU
434 * @params[in] PucchResrcCfg pointer,
435 * SchPucchResrcCfg pointer
436 * @return ROK/RFAILED;
438 * ****************************************************************/
439 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
443 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
444 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
446 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
447 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
448 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
449 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
450 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
451 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
452 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
453 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
454 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
455 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
456 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
458 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
459 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
461 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
464 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
465 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
466 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
467 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
468 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
469 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
472 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
474 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
475 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
477 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
480 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
481 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
482 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
483 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
484 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
485 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
486 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
487 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
490 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
492 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
493 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
495 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
498 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
499 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
500 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
501 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
502 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
503 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
506 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
508 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
509 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
511 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
514 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
515 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
516 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
517 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
518 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
519 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
522 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
524 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
525 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
527 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
530 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
531 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
532 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
533 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
534 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
535 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
536 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
537 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
543 /*******************************************************************
545 * @brief Function to fillPucchFormatCfg sent by DU
549 * Function : fillPucchFormatCfg
551 * Functionality: Function to fillPucchFormatCfg
553 * @params[in] PucchFormatCfg pointer,
554 * SchPucchFormatCfg pointer
557 * ****************************************************************/
559 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
561 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
562 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
563 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
564 schFormatCfg->numSlots = macFormatCfg->numSlots;
565 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
566 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
569 /*******************************************************************
571 * @brief Function to fillPucchSchedReqCfg sent by DU
575 * Function : fillPucchSchedReqCfg
577 * Functionality: Function to fillPucchSchedReqCfg
579 * @params[in] PucchSchedReqCfg pointer,
580 * SchPucchSchedReqCfg pointer
583 * ****************************************************************/
584 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
588 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
589 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
591 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
592 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
593 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
594 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
595 schSchedReqCfg->schedAddModList[arrIdx].offset =\
596 macSchedReqCfg->schedAddModList[arrIdx].offset;
597 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
598 macSchedReqCfg->schedAddModList[arrIdx].resrc;
600 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
601 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
603 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
607 /*******************************************************************
609 * @brief Function to fillMultiCsiCfg sent by DU
613 * Function : fillMultiCsiCfg
615 * Functionality: Function to fillMultiCsiCfg
617 * @params[in] PucchMultiCsiCfg pointer,
618 * SchPucchMultiCsiCfg pointer
621 * ****************************************************************/
623 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
627 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
628 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
630 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
634 /*******************************************************************
636 * @brief Function to fillDlToUlAck sent by DU
640 * Function : fillDlToUlAck
642 * Functionality: Function to fillDlToUlAck
644 * @params[in] PucchDlDataToUlAck pointer,
645 * SchPucchDlDataToUlAck pointer
648 * ****************************************************************/
650 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
654 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
655 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
657 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
661 /*******************************************************************
663 * @brief Function to fillPucchPowerControl sent by DU
667 * Function : fillPucchPowerControl
669 * Functionality: Function to fillPucchPowerControl
671 * @params[in] PucchPowerControl pointer,
672 * SchPucchPowerControl pointer
675 * ****************************************************************/
677 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
681 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
682 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
683 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
684 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
685 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
686 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
687 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
689 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
690 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
692 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
693 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
695 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
696 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
700 /*******************************************************************
702 * @brief Function to fillOtherPucchFormatCfg sent by DU
706 * Function : fillOtherPucchFormatCfg
708 * Functionality: Function to fillOtherPucchFormatCfg
710 * @params[in] PucchFormat
711 * PucchFormatCfg pointer,
712 * SchPucchCfg pointer
715 * ****************************************************************/
717 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
726 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
727 if(schPucchCfg->format1 == NULLP)
729 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
732 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
740 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
741 if(schPucchCfg->format2 == NULLP)
743 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
746 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
754 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
755 if(schPucchCfg->format3 == NULLP)
757 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
760 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
768 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
769 if(schPucchCfg->format4 == NULLP)
771 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
774 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
779 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
785 /*******************************************************************
787 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
791 * Function : fillInitalUlBwpPucchCfg
794 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
796 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
797 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
798 * @return ROK - success
801 * ****************************************************************/
802 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
804 if(macPucchCfg->resrcSet)
806 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
807 if(schPucchCfg->resrcSet == NULLP)
809 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
812 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
813 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
816 if(macPucchCfg->resrc)
818 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
819 if(schPucchCfg->resrc == NULLP)
821 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
824 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
825 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
827 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
832 /* valid for format 1, 2, 3, 4 */
833 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
834 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
835 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
836 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
838 if(macPucchCfg->schedReq)
840 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
841 if(schPucchCfg->schedReq == NULLP)
843 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
846 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
847 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
850 if(macPucchCfg->multiCsiCfg)
852 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
853 if(schPucchCfg->multiCsiCfg == NULLP)
855 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
858 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
859 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
862 //TODO: To add the support for spatial Config
863 schPucchCfg->spatialInfo = NULLP;
865 if(macPucchCfg->dlDataToUlAck)
867 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
868 if(schPucchCfg->dlDataToUlAck == NULLP)
870 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
873 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
874 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
878 if(macPucchCfg->powerControl)
880 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
881 if(schPucchCfg->powerControl == NULLP)
883 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
886 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
887 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
893 /*******************************************************************
895 * @brief function to free Pucch Format
899 * Function : freeSchPucchFormat
902 * function to free Pucch Format
904 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
905 * SchPucchResrcInfo pointer
907 * ****************************************************************/
909 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
913 case PUCCH_FORMAT_0 :
914 if(resrcInfo->SchPucchFormat.format0)
916 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
917 resrcInfo->SchPucchFormat.format0 = NULLP;
921 case PUCCH_FORMAT_1 :
922 if(resrcInfo->SchPucchFormat.format1)
924 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
925 resrcInfo->SchPucchFormat.format1 = NULLP;
929 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
930 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
934 case PUCCH_FORMAT_2 :
935 if(resrcInfo->SchPucchFormat.format2)
937 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
938 resrcInfo->SchPucchFormat.format2 = NULLP;
942 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
943 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
947 case PUCCH_FORMAT_3 :
948 if(resrcInfo->SchPucchFormat.format3)
950 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
951 resrcInfo->SchPucchFormat.format3 = NULLP;
955 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
956 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
960 case PUCCH_FORMAT_4 :
961 if(resrcInfo->SchPucchFormat.format4)
963 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
964 resrcInfo->SchPucchFormat.format4 = NULLP;
968 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
969 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
978 /*******************************************************************
980 * @brief function to free Pucch Resrc Cfg
984 * Function : freePucchResrcCfg
987 * function to free Pucch Resrc Cfg
989 * @params[in] SchPucchResrcCfg pointer,
991 * ****************************************************************/
993 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
997 /* free Resrc To AddMod List */
998 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
1000 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
1001 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
1002 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
1004 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
1005 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
1008 /*******************************************************************
1010 * @brief function to free Pucch Sched Req Cfg
1014 * Function : freePucchSchedReqCfg
1017 * function to free Pucch Sched Req Cfg
1019 * @params[in] SchPucchSchedReqCfg pointer,
1021 * ****************************************************************/
1023 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
1025 uint8_t schedReqIdx;
1027 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
1029 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
1031 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
1032 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
1035 /*******************************************************************
1037 * @brief function to free Ul Bwp Pucch Cfg
1041 * Function : freeUlBwpPucchCfg
1044 * function to free Ul Bwp Pucch Cfg
1046 * @params[in] SchPucchCfg pointer,
1048 * ****************************************************************/
1050 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1052 if(schPucchCfg->resrcSet)
1054 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1055 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1057 if(schPucchCfg->resrc)
1059 freePucchResrcCfg(schPucchCfg->resrc);
1061 if(schPucchCfg->format1)
1063 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1065 if(schPucchCfg->format2)
1067 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1069 if(schPucchCfg->format3)
1071 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1073 if(schPucchCfg->format4)
1075 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1077 if(schPucchCfg->schedReq)
1079 freePucchSchedReqCfg(schPucchCfg->schedReq);
1081 if(schPucchCfg->spatialInfo)
1083 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1084 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1086 if(schPucchCfg->multiCsiCfg)
1088 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1089 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1091 if(schPucchCfg->dlDataToUlAck)
1093 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1094 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1096 if(schPucchCfg->powerControl)
1098 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1099 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1103 /*******************************************************************
1105 * @brief Fills initail UL BWP config to send to scheduler
1109 * Function : fillInitialUlBwp
1111 * Functionality: Fills initail UL BWP config to send to sch
1113 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1114 * schInitUlBwp : Initial UL BWP cfg to be filled
1115 * @return ROK - success
1118 * ****************************************************************/
1119 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1121 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1122 if(schInitUlBwp->pucchCfgPres)
1124 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1125 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1127 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1128 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1132 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1133 if(schInitUlBwp->puschCfgPres)
1135 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1136 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1138 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1145 /*******************************************************************
1147 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1151 * Function : fillInitDlBwpPdcchCfg
1154 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1156 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1157 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1158 * @return ROK - success
1161 * ****************************************************************/
1162 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1166 /* Fill CORESET info */
1167 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1168 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1170 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1171 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1175 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1177 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1178 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1179 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1180 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1181 schPdcchCfg->cRSetToAddModList[idx].duration = \
1182 macPdcchCfg.cRSetToAddModList[idx].duration;
1183 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1184 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1185 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1186 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1187 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1188 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1191 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1192 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1194 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1195 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1199 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1204 /* Fill Search space info */
1205 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1206 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1208 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1209 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1212 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1214 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1215 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1216 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1217 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1218 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1219 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1220 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1221 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1222 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1223 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1224 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1225 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1226 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1227 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1228 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1229 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1230 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1231 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1232 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1233 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1234 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1235 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1236 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1239 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1240 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1242 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1243 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1246 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1254 /*******************************************************************
1256 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1260 * Function : fillInitDlBwpPdschCfg
1263 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1265 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1266 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1267 * @return ROK - success
1270 * ****************************************************************/
1271 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1275 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1276 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1277 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1278 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1279 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1281 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1282 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1286 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1288 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1290 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1291 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1293 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1296 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1298 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1299 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1300 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1301 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1302 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1303 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1306 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1307 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1308 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1309 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1311 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1313 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1315 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1316 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1321 /*******************************************************************
1323 * @brief Fill Initial DL BWP for SCH UE config
1327 * Function : fillInitialDlBwp
1329 * Functionality: Fill Initial DL BWP for SCH UE config
1331 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1332 * schInitDlBwp : Inital DL BWP cfg to be filled
1333 * @return ROK - success
1336 * ****************************************************************/
1337 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1339 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1340 if(schInitDlBwp->pdcchCfgPres)
1342 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1344 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1349 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1350 if(schInitDlBwp->pdschCfgPres)
1352 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1354 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1361 /*******************************************************************
1363 * @brief Fills Sp Cell config to be sent to scheduler
1367 * Function : fillSpCellCfg
1369 * Functionality: Fills Sp Cell config to be sent to scheduler
1371 * @params[in] macSpCellCfg : SP cell cfg at MAC
1372 * schSpCellCfg : SP cell cfg to be filled
1373 * @return ROK - success
1376 * ****************************************************************/
1377 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1380 SchServCellCfgInfo *servCellCfg;
1382 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1383 servCellCfg = &schSpCellCfg->servCellCfg;
1385 /* Fill initial DL BWP */
1386 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1387 &servCellCfg->initDlBwp) != ROK )
1389 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1393 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1394 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1396 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD [%d] exceeds max limit [%d]",\
1397 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1400 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1402 memcpy(&servCellCfg->dlBwpToAddList[idx], &macSpCellCfg.servCellCfg.dlBwpToAddList[idx], sizeof(DlBwpInfo));
1404 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1405 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1406 servCellCfg->bwpInactivityTmr = NULL;
1407 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1409 /* TODO : This is an optional parameter, not filled currently */
1412 /* Fill PDSCH serving cell config */
1413 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1414 &servCellCfg->pdschServCellCfg) != ROK)
1416 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1420 /* Fill Initail UL BWP */
1421 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1422 &servCellCfg->initUlBwp) != ROK)
1424 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1428 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1429 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1431 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD [%d] exceeds max limit [%d]",\
1432 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1435 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1437 memcpy(&servCellCfg->ulBwpToAddList[idx], &macSpCellCfg.servCellCfg.ulBwpToAddList[idx], sizeof(UlBwpInfo));
1439 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1444 /*******************************************************************
1446 * @brief Fills Sp Cell Reconfig to be sent to scheduler
1450 * Function : fillSpCellRecfg
1452 * Functionality: Fills Sp Cell Reconfig to be sent to scheduler
1454 * @params[in] macSpCellRecfg : SP cell Recfg at MAC
1455 * schSpCellRecfg : SP cell Recfg to be filled
1456 * @return ROK - success
1459 * ****************************************************************/
1460 uint8_t fillSpCellRecfg(SpCellRecfg macSpCellRecfg, SchSpCellRecfg *schSpCellRecfg)
1463 SchServCellRecfgInfo *servCellRecfg;
1465 schSpCellRecfg->servCellIdx = macSpCellRecfg.servCellIdx;
1466 servCellRecfg = &schSpCellRecfg->servCellRecfg;
1468 /* Fill initial DL BWP */
1469 if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
1470 &servCellRecfg->initDlBwp) != ROK )
1472 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1476 servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
1477 if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
1479 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1480 servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
1483 for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
1485 memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
1487 servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
1488 if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
1490 DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
1491 servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
1494 for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
1496 memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
1498 servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
1499 servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
1500 servCellRecfg->bwpInactivityTmr = NULL;
1501 if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
1503 /* TODO : This is an optional parameter, not filled currently */
1506 /* Fill PDSCH serving cell config */
1507 if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
1508 &servCellRecfg->pdschServCellCfg) != ROK)
1510 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1514 /* Fill Initail UL BWP */
1515 if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
1516 &servCellRecfg->initUlBwp) != ROK)
1518 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1522 servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
1523 if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
1525 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1526 servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
1529 for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
1531 memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
1533 servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
1534 if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
1536 DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
1537 servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
1540 for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
1542 memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
1544 servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
1549 /*******************************************************************
1551 * @brief Sends UE configuration to Scheduler
1555 * Function : sendUeReqToSch
1557 * Functionality: sends UE configuration to Scheduler
1559 * @params[in] Pst and Ue configuration
1560 * @return ROK - success
1563 * ****************************************************************/
1565 uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
1570 case EVENT_MAC_UE_CREATE_REQ:
1572 SchUeCfgReq *schUeCfgReq = NULLP;
1573 schUeCfgReq = (SchUeCfgReq *)schUeCfg;
1574 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1575 return(SchMessageRouter(&schPst, (void *)schUeCfgReq));
1577 case EVENT_MAC_UE_RECONFIG_REQ:
1579 SchUeRecfgReq *schUeRecfgReq = NULLP;
1580 schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
1581 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1582 return(SchMessageRouter(&schPst, (void *)schUeRecfgReq));
1586 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1592 /*******************************************************************
1594 * @brief Fills Sch Drb Qos Information
1598 * Function : fillSchDrbQosInfo
1600 * Functionality: Fills Sch Drb Qos Information
1602 * @params[in] macLcCfg : Logical channel Cfg at MAC
1603 * schLcCfg : LC cfg to fill at scheduler
1604 * @return ROK - success
1607 * ****************************************************************/
1608 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1610 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1611 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1613 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1614 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1615 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1616 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1618 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1620 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1621 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1622 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1623 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1624 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1625 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1626 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1627 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1629 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1630 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1631 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1632 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1633 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1634 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1635 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1636 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1637 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1640 /*******************************************************************
1642 * @brief Fill SCH UL logical channel configuration
1646 * Function : fillSchUlLcCfg
1648 * Functionality: Fills Sch Ul Lc configuration
1650 * @params[in] macLcCfg : Logical channel Cfg at MAC
1651 * schLcCfg : LC cfg to fill at scheduler
1654 * ****************************************************************/
1656 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1658 schUlLcCfg->priority= macUlLcCfg->priority;
1659 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1660 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1661 schUlLcCfg->pbr = macUlLcCfg->pbr;
1662 schUlLcCfg->bsd = macUlLcCfg->bsd;
1665 /*******************************************************************
1667 * @brief Fill logical channel configuration
1671 * Function : fillLogicalChannelCfg
1673 * Functionality: Fill logical channel configuration
1675 * @params[in] macLcCfg : Logical channel Cfg at MAC
1676 * schLcCfg : LC cfg to fill at scheduler
1677 * @return ROK - success
1680 * ****************************************************************/
1681 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1685 schLcCfg->lcId = macLcCfg->lcId;
1686 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1687 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1689 if(macLcCfg->drbQos)
1691 if(!schLcCfg->drbQos)
1693 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1694 if(!schLcCfg->drbQos)
1696 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1702 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1709 schLcCfg->drbQos = NULLP;
1714 if(macLcCfg->snssai)
1716 if(!schLcCfg->snssai)
1718 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1719 if(!schLcCfg->snssai)
1721 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1727 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1728 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1730 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1736 schLcCfg->snssai = NULLP;
1743 /*******************************************************************
1745 * @brief Fills Logical channel Cfg List to Add
1749 * Function : fillSchLcCfgList
1751 * Functionality: Fills Logical channel Cfg List to Add
1753 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1754 * @return ROK - success
1757 * ****************************************************************/
1759 uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1763 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1765 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1767 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1770 schUeCfg->numLcsToAdd++;
1775 /*******************************************************************
1777 * @brief Fills Logical channel Recfg List to Add/Mod/Del
1781 * Function : fillSchLcRecfgList
1783 * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
1785 * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
1786 * @return ROK - success
1789 * ****************************************************************/
1791 uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1796 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
1798 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
1800 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1803 schUeRecfg->numLcsToAdd++;
1806 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
1808 schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
1809 schUeRecfg->numLcsToDel++;
1812 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
1814 if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
1816 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1819 schUeRecfg->numLcsToMod++;
1824 /*******************************************************************
1826 * @brief Fills and sends UE configuration to Scheduler
1830 * Function : fillSchUeCfg
1832 * Functionality: Fills and sends UE configuration to Scheduler
1834 * @params[in] Ue configuration from DU APP
1835 * @return ROK - success
1838 * ****************************************************************/
1839 uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
1843 schUeCfg->cellId = ueCfg->cellId;
1844 schUeCfg->ueId = ueCfg->ueId;
1845 schUeCfg->crnti = ueCfg->crnti;
1846 /* Copy MAC cell group config */
1847 if(ueCfg->macCellGrpCfgPres == true)
1849 schUeCfg->macCellGrpCfgPres = true;
1850 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1851 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1853 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1857 if(ueCfg->phyCellGrpCfgPres == true)
1859 schUeCfg->phyCellGrpCfgPres = true;
1860 /* Copy Physical cell group config */
1861 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1862 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1864 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1869 if(ueCfg->spCellCfgPres == true)
1871 schUeCfg->spCellCfgPres = true;
1872 /* Copy sp cell config */
1873 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1874 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1876 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1880 if(ueCfg->ambrCfg != NULLP)
1882 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1883 if(!schUeCfg->ambrCfg)
1885 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1888 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1892 schUeCfg->ambrCfg = NULLP;
1894 /* Fill DL modulation infor */
1895 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1896 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1897 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1899 /* Fill UL modulation infor */
1900 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1901 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1902 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1904 /* Fill sch Lc Cfg to Add*/
1905 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1908 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1915 /*******************************************************************
1917 * @brief Fills and sends UE Re-configuration to Scheduler
1921 * Function : fillSchUeRecfg
1923 * Functionality: Fills and sends UE Reconfiguration to Scheduler
1925 * @params[in] Ue configuration from DU APP
1926 * @return ROK - success
1929 * ****************************************************************/
1930 uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
1934 schUeRecfg->cellId = ueRecfg->cellId;
1935 schUeRecfg->ueId = ueRecfg->ueId;
1936 schUeRecfg->crnti = ueRecfg->crnti;
1937 schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
1938 /* Copy MAC cell group config */
1939 if(ueRecfg->macCellGrpRecfgPres == true)
1941 schUeRecfg->macCellGrpRecfgPres = true;
1942 memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
1943 if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
1945 DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
1949 if(ueRecfg->phyCellGrpRecfgPres == true)
1951 schUeRecfg->phyCellGrpRecfgPres = true;
1952 /* Copy Physical cell group config */
1953 memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
1954 if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
1956 DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
1961 if(ueRecfg->spCellRecfgPres == true)
1963 schUeRecfg->spCellRecfgPres = true;
1964 /* Copy sp cell config */
1965 memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
1966 if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
1968 DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
1972 if(ueRecfg->ambrRecfg != NULLP)
1974 MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
1975 if(!schUeRecfg->ambrRecfg)
1977 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1980 schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
1984 schUeRecfg->ambrRecfg = NULLP;
1986 /* Fill DL modulation infor */
1987 schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
1988 schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
1989 schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
1991 /* Fill UL modulation infor */
1992 schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
1993 schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
1994 schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
1996 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1997 ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
2000 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
2005 schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
2011 /*******************************************************************
2013 * @brief Update UeUlCb Lc List
2017 * Function : updateMacUlCb
2019 * Functionality: Update UeUlCb Lc List
2021 * @params[in] delIdx, UeUlCb pointer
2024 * ****************************************************************/
2026 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
2030 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
2032 /* Moving the array element to one step ahead */
2033 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
2034 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
2036 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2038 /*Checking the Memory Leakage of Last Index*/
2039 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
2041 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
2043 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
2047 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
2053 /*******************************************************************
2055 * @brief Update UeDlCb Lc List
2059 * Function : updateMacDlCb
2061 * Functionality: Update UeDlCb Lc List
2063 * @params[in] delIdx, UeDlCb pointer
2066 * ****************************************************************/
2068 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
2072 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
2074 /* Moving the array element to one step ahead */
2075 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
2076 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
2078 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2080 /*Checking the Memory Leakage of Last Index*/
2081 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
2083 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
2085 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
2089 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
2095 /*******************************************************************
2097 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
2101 * Function : updateMacUlLcCtxt
2103 * Functionality: Update UeUlCb Lc List
2105 * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
2106 * ueLcCfg(received from DUAPP)
2107 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2110 * ****************************************************************/
2111 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2113 uint8_t ueLcIdx = 0;
2115 /*Traversing UL LC to be updated/Deleted*/
2116 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
2118 if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2120 /*Modify UL LC CB */
2121 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
2123 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2125 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2128 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2132 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
2134 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2137 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2140 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2141 ueLcCfg->lcId,ueLcIdx);
2144 else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2146 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
2147 (ulInfo->numUlLc)--;
2148 updateMacUlCb(ueLcIdx, ulInfo);
2149 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2155 /*******************************************************************
2157 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
2161 * Function : updateMacDlLcCtxt
2163 * Functionality: Update UeDlCb Lc List
2165 * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
2166 * ueLcCfg(received from DUAPP)
2167 * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
2170 * ****************************************************************/
2171 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
2173 uint8_t ueLcIdx = 0;
2175 /*Traversing DL LC to be updated/Deleted*/
2176 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
2178 if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
2180 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2182 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
2185 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
2189 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
2191 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
2194 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
2197 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
2198 ueLcCfg->lcId,ueLcIdx);
2201 else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
2203 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
2204 (dlInfo->numDlLc)--;
2205 updateMacDlCb(ueLcIdx, dlInfo);
2206 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
2212 /*******************************************************************
2214 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2218 * Function : fillMacLcCfgList
2220 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2222 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2223 * @return ROK - success
2226 * ****************************************************************/
2228 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
2232 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
2234 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2236 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2238 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2239 if(ueCfg->lcCfgList[lcIdx].drbQos)
2241 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2242 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2244 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2245 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2247 if(ueCfg->lcCfgList[lcIdx].snssai)
2249 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2251 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2253 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2255 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2258 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2259 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2261 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2262 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2266 /*Filling DL LC CB */
2267 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2268 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2269 ueCb->dlInfo.numDlLc++;
2270 /*Filling UL LC CB */
2271 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
2272 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
2273 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2274 ueCb->ulInfo.numUlLc++;
2280 /*******************************************************************
2282 * @brief Fills Logical channel Cfg List to Add/Mod/Del
2286 * Function : updateMacLcCfgList
2288 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
2290 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2291 * @return ROK - success
2294 * ****************************************************************/
2296 uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2300 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
2302 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2304 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2306 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
2307 if(ueRecfg->lcCfgList[lcIdx].drbQos)
2309 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
2310 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2312 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
2313 ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
2315 if(ueRecfg->lcCfgList[lcIdx].snssai)
2317 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
2319 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
2321 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
2323 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
2326 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
2327 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2329 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
2330 ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
2334 /*Filling DL LC CB */
2335 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2336 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
2337 ueCb->dlInfo.numDlLc++;
2338 /*Filling UL LC CB */
2339 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
2340 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
2341 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
2342 ueCb->ulInfo.numUlLc++;
2343 }/*End of Add Config */
2345 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
2347 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2349 updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2350 updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
2353 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
2355 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
2357 updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2358 updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
2364 /*******************************************************************
2366 * @brief Fills MAC UE Cb Cfg
2370 * Function : fillMacUeCb
2372 * Functionality: Fills MAC UE Cb Cfg
2374 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
2376 * @return ROK - success
2379 * ****************************************************************/
2381 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
2385 ueCb->ueId = ueCfg->ueId;
2386 ueCb->crnti = ueCfg->crnti;
2387 ueCb->cellCb = macCb.macCell[cellIdx];
2388 if(ueCfg->spCellCfgPres)
2390 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2391 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2394 /*TODO: To check the bsr value during implementation */
2395 if(ueCfg->macCellGrpCfgPres)
2397 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2398 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2399 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2401 ret = fillMacLcCfgList(ueCb, ueCfg);
2404 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2409 /*******************************************************************
2411 * @brief Fills MAC UE Cb Cfg
2415 * Function : updateMacUeCb
2417 * Functionality: updateMacUeCbs MAC UE Cb Cfg
2419 * @params[in] MAC UE Cb Recfg , MAC UE Configuration
2421 * @return ROK - success
2424 * ****************************************************************/
2426 uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
2430 ueCb->ueId = ueRecfg->ueId;
2431 ueCb->crnti = ueRecfg->crnti;
2432 ueCb->cellCb = macCb.macCell[cellIdx];
2433 if(ueRecfg->spCellRecfgPres)
2435 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
2436 ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
2439 /*TODO: To check the bsr value during implementation */
2440 if(ueRecfg->macCellGrpRecfgPres)
2442 ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
2443 ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
2444 ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
2446 ret = updateMacLcCfgList(ueCb, ueRecfg);
2449 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
2451 ueCb->transmissionAction = ueRecfg->transmissionAction;
2456 /*******************************************************************
2458 * @brief Function to update Mac Ra Cb
2462 * Function : updateMacRaCb
2464 * Functionality: Function to update Mac Ra Cb
2466 * @params[in] cellIdx, Mac Ue Cb
2467 * @return ROK - success
2470 * ****************************************************************/
2472 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2475 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2477 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2481 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2487 /*******************************************************************
2489 * @brief Function to delete Mac Ra Cb
2493 * Function : deleteMacRaCb
2495 * Functionality: Function to delete Mac Ra Cb
2497 * @params[in] cellIdx, Mac Ue Cb
2500 * ****************************************************************/
2502 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2505 MacRaCbInfo *raCb = ueCb->raCb;
2507 if(raCb && (raCb->crnti == ueCb->crnti))
2509 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2510 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2512 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2513 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
2515 memset(raCb, 0, sizeof(MacRaCbInfo));
2519 /*******************************************************************
2521 * @brief Creates UE Cb
2525 * Function : createUeCb
2527 * Functionality: Creates UE Cb
2529 * @params[in] MAC UE Configuration
2530 * @return ROK - success
2533 * ****************************************************************/
2534 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2537 uint8_t hqProcIdx = 0;
2539 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2540 &&(ueCb->state == UE_STATE_ACTIVE))
2542 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2547 memset(ueCb, 0, sizeof(MacUeCb));
2548 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2551 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2556 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2557 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2559 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2562 /* If UE has not requested for RACH yet, it means UE context is created for a
2564 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2566 ueCb->state = UE_STATE_ACTIVE;
2567 macCb.macCell[cellIdx]->numActvUe++;
2568 updateMacRaCb(cellIdx, ueCb);
2571 ueCb->state = UE_HANDIN_IN_PROGRESS;
2579 /*******************************************************************
2581 * @brief Modify UE Cb Cfg
2585 * Function : modifyUeCb
2587 * Functionality: modify UE Cb
2589 * @params[in] MAC UE Configuration
2590 * @return ROK - success
2593 * ****************************************************************/
2594 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
2598 if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
2599 &&(ueCb->state == UE_STATE_ACTIVE))
2601 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
2602 ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
2605 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2617 /*******************************************************************
2619 * @brief Creates UE Cb and fills ueCfg
2623 * Function : procMacUeCfgData
2625 * Functionality: Creates UE Cb and fills ueCfg
2627 * @params[in] MAC UE Configuration
2628 * @return ROK - success
2631 * ****************************************************************/
2633 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2635 uint8_t ret = ROK, ueId = 0;
2636 uint16_t cellIdx, cellId;
2637 MacUeCb *ueCb = NULLP;
2641 cellId = ueCfg->cellId;
2644 else if(ueRecfg != NULLP)
2646 cellId = ueRecfg->cellId;
2647 ueId = ueRecfg->ueId;
2651 GET_CELL_IDX(cellId, cellIdx);
2653 /* Validate cell id */
2654 if(macCb.macCell[cellIdx]->cellId != cellId)
2656 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
2660 /* Check if max number of UE configured */
2661 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2663 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2667 /* Check if UE already configured */
2668 ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
2672 case EVENT_UE_CONFIG_RSP_TO_MAC:
2674 ret = createUeCb(cellIdx, ueCb, ueCfg);
2676 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2680 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2682 ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
2684 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2695 /*******************************************************************
2697 * @brief Function to store the UeCfg Data
2701 * Function : copyToTmpData
2703 * Functionality: Function to store the UeCfg Data
2705 * @params[in] MacUeCfg pointer
2706 * @return ROK - success
2709 * ****************************************************************/
2711 uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
2717 MacUeCfg *tmpData = NULLP;
2719 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2722 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2725 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2726 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2727 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2729 else if(ueRecfg != NULLP)
2731 MacUeRecfg *tmpData = NULLP;
2733 MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
2736 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2739 memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
2740 GET_CELL_IDX(ueRecfg->cellId, cellIdx);
2741 macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
2746 /*******************************************************************
2748 * @brief Handles UE create requst from DU APP
2752 * Function : MacProcUeCreateReq
2754 * Functionality: Handles UE create requst from DU APP
2757 * @return ROK - success
2760 * ****************************************************************/
2761 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2764 SchUeCfgReq schUeCfg;
2765 memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
2767 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2771 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2772 * case of UE in handover */
2773 if(ueCfg->crnti == 0)
2775 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2778 /*Storing received ueCfg in ueCfgTmpData */
2779 ret = copyToTmpData(ueCfg, NULLP);
2782 /*Sending Cfg Req to SCH */
2783 ret = fillSchUeCfg(&schUeCfg, ueCfg);
2785 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2788 /* Fill event and send UE create request to SCH */
2789 ret = sendUeReqToSch(pst, &schUeCfg);
2791 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2796 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2801 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2804 /* FREE shared memory */
2805 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2810 /*******************************************************************
2812 * @brief Fill and Send UE create response from MAC to DU APP
2816 * Function : MacSendUeCreateRsp
2818 * Functionality: Fill and Send UE create response from MAC to DUAPP
2820 * @params[in] MAC UE create result
2821 * SCH UE create response
2822 * @return ROK - success
2825 * ****************************************************************/
2826 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2828 MacUeCfgRsp *cfgRsp;
2831 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2834 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2838 /* Filling UE Config response */
2839 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2840 cfgRsp->cellId = schCfgRsp->cellId;
2841 cfgRsp->ueId = schCfgRsp->ueId;
2842 cfgRsp->result = result;
2844 /* Fill Post structure and send UE Create response*/
2845 memset(&rspPst, 0, sizeof(Pst));
2846 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2847 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2850 /*******************************************************************
2852 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2856 * Function : MacSendUeReconfigRsp
2858 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2860 * @params[in] MAC UE create result
2861 * SCH UE create response
2862 * @return ROK - success
2865 * ****************************************************************/
2866 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
2868 MacUeRecfgRsp *recfgRsp;
2871 MAC_ALLOC_SHRABL_BUF(recfgRsp, sizeof(MacUeRecfgRsp));
2874 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2878 /* Filling UE Config response */
2879 memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
2880 recfgRsp->cellId = schCfgRsp->cellId;
2881 recfgRsp->ueId = schCfgRsp->ueId;
2882 recfgRsp->result = result;
2884 /* Fill Post structure and send UE Create response*/
2885 memset(&rspPst, 0, sizeof(Pst));
2886 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2887 return (*macDuUeRecfgRspOpts[rspPst.selector])(&rspPst, recfgRsp);
2890 /*******************************************************************
2892 * @brief Function to return Mac Ue Cfg pointer
2896 * Function : getMacUeCfg
2899 * Function to return Mac Ue Cfg pointer
2901 * @params[in] cellIdx, ueId
2903 * @return MacUeCfg pointer - success
2906 * ****************************************************************/
2908 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2910 MacUeCfg *ueCfg = NULLP;
2911 if(macCb.macCell[cellIdx])
2913 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2917 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2922 /*******************************************************************
2924 * @brief Function to return Mac Ue Recfg pointer
2928 * Function : getMacUeRecfg
2931 * Function to return Mac Ue Recfg pointer
2933 * @params[in] cellIdx, ueId
2935 * @return MacUeRecfg pointer - success
2938 * ****************************************************************/
2940 MacUeRecfg *getMacUeRecfg(uint16_t cellIdx, uint8_t ueId)
2942 MacUeRecfg *ueRecfg = NULLP;
2943 if(macCb.macCell[cellIdx])
2945 ueRecfg = macCb.macCell[cellIdx]->ueRecfgTmpData[ueId-1];
2949 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeRecfg()");
2954 /*******************************************************************
2956 * @brief Processes UE create response from scheduler
2960 * Function : MacProcSchUeCfgRsp
2963 * Processes UE create response from scheduler
2964 * Sends UE create response to DU APP
2966 * @params[in] Pst : Post structure
2967 * schCfgRsp : Scheduler UE cfg response
2968 * @return ROK - success
2971 * ****************************************************************/
2972 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2974 uint8_t result = MAC_DU_APP_RSP_NOK;
2977 MacUeCfg *ueCfg = NULLP;
2979 #ifdef CALL_FLOW_DEBUG_LOG
2982 case EVENT_UE_CONFIG_RSP_TO_MAC:
2983 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2985 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2986 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2989 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2994 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2995 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2998 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3002 if(schCfgRsp->rsp != RSP_NOK)
3004 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
3007 ret = procMacUeCfgData(pst, ueCfg, NULLP);
3010 result = MAC_DU_APP_RSP_OK;
3016 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
3018 ret = MacSendUeCreateRsp(result, schCfgRsp);
3019 MAC_FREE(ueCfg, sizeof(MacUeCfg));
3024 /*******************************************************************
3026 * @brief Processes UE create response from scheduler
3030 * Function : MacProcSchUeRecfgRsp
3033 * Processes UE ReConfig response from scheduler
3034 * Sends UE Reconfig response to DU APP
3036 * @params[in] Pst : Post structure
3037 * schRecfgRsp : Scheduler UE Recfg response
3038 * @return ROK - success
3041 * ****************************************************************/
3042 uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
3044 uint8_t result = MAC_DU_APP_RSP_NOK;
3047 MacUeRecfg *ueRecfg = NULLP;
3049 #ifdef CALL_FLOW_DEBUG_LOG
3052 case EVENT_UE_RECONFIG_RSP_TO_MAC:
3053 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
3056 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
3061 GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
3062 ueRecfg = getMacUeRecfg(cellIdx, schRecfgRsp->ueId);
3063 if(ueRecfg == NULLP)
3065 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
3070 if(schRecfgRsp->rsp != RSP_NOK)
3072 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
3073 schRecfgRsp->crnti);
3076 ret = procMacUeCfgData(pst, NULLP, ueRecfg);
3079 result = MAC_DU_APP_RSP_OK;
3085 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
3086 schRecfgRsp->crnti);
3088 ret = MacSendUeReconfigRsp(result, schRecfgRsp);
3089 MAC_FREE(ueRecfg, sizeof(MacUeRecfg));
3094 /*******************************************************************
3096 * @brief Handles UE Reconfig requst from DU APP
3100 * Function : MacProcUeReconfigReq
3102 * Functionality: Handles UE Reconfig requst from DU APP
3105 * @return ROK - success
3108 * ****************************************************************/
3109 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeRecfg *ueRecfg)
3112 SchUeRecfgReq schUeRecfg;
3113 memset(&schUeRecfg, 0, sizeof(SchUeRecfgReq));
3115 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueRecfg->crnti);
3119 /*Storing received ueRecfg in ueCfgTmpData */
3120 ret = copyToTmpData(NULLP, ueRecfg);
3123 /*Sending Cfg Req to SCH */
3124 ret = fillSchUeRecfg(&schUeRecfg, ueRecfg);
3126 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
3129 /* Fill event and send UE Reconfiguration request to SCH */
3130 ret = sendUeReqToSch(pst, &schUeRecfg);
3132 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
3137 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
3142 DU_LOG("\nERROR --> MAC : MAC UE Reconfiguration request processing failed");
3145 /* FREE shared memory */
3146 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(MacUeRecfg));
3150 /*******************************************************************
3152 * @brief Fill and Send UE Delete response from MAC to DU APP
3156 * Function : MacSendUeDeleteRsp
3158 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
3160 * @params[in] MAC UE delete result
3161 * SCH UE delete response
3162 * @return ROK - success
3165 * ****************************************************************/
3167 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, CauseOfResult status)
3169 MacUeDeleteRsp *deleteRsp;
3172 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
3175 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
3179 /* Filling UE delete response */
3180 deleteRsp->cellId = cellId;
3181 GET_UE_ID(crnti, deleteRsp->ueId);
3182 deleteRsp->status = status;
3184 /* Fill Post structure and send UE delete response*/
3185 memset(&rspPst, 0, sizeof(Pst));
3186 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
3187 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
3190 /*******************************************************************
3192 * @brief freeing the Pucch Resrc Cfg
3196 * Function : deletePucchResourcesCfg
3198 * Functionality: freeing the Pucch Resrc Cfg
3200 * @params[in] PucchResrcCfg *resrcCfg
3201 * @return ROK - success
3204 * ****************************************************************/
3206 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
3209 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
3211 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
3213 case PUCCH_FORMAT_0:
3215 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
3218 case PUCCH_FORMAT_1:
3220 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
3223 case PUCCH_FORMAT_2:
3225 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
3228 case PUCCH_FORMAT_3:
3230 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
3233 case PUCCH_FORMAT_4:
3235 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
3243 /*******************************************************************
3245 * @brief Processes UE delete response from scheduler
3249 * Function : MacProcSchUeDeleteRsp
3252 * Processes UE delete from scheduler
3254 * @params[in] Pst : Post structure
3255 * schUeDelRsp : Scheduler UE delete respons
3256 * @return ROK - success
3259 * ****************************************************************/
3261 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
3263 uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
3265 uint8_t ret = RFAILED;
3266 CauseOfResult status;
3267 DlHarqEnt *dlHarqEnt;
3269 #ifdef CALL_FLOW_DEBUG_LOG
3270 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
3275 if(schUeDelRsp->rsp == RSP_OK)
3277 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
3278 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
3279 if(macCb.macCell[cellIdx])
3281 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
3284 /*C-RNTI value is out of Acceptable range*/
3285 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
3286 status = UEID_INVALID;
3290 GET_UE_ID(schUeDelRsp->crnti, ueId);
3291 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
3294 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
3296 /*Looping around LCs to free S-NSSAI memory*/
3297 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
3299 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3301 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
3303 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
3306 dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
3307 for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
3310 while(dlHarqEnt->harqProcCb[idx].numTb)
3313 MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
3314 dlHarqEnt->harqProcCb[idx].numTb--;
3318 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
3319 macCb.macCell[cellIdx]->numActvUe--;
3320 status = SUCCESSFUL;
3325 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
3326 status = UEID_INVALID;
3332 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
3333 status = CELLID_INVALID;
3337 status = schUeDelRsp->cause;
3339 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, status) != ROK)
3341 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
3347 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
3353 /*******************************************************************
3355 * @brief Sends UE delete req to Scheduler
3359 * Function : sendUeDelReqToSch
3361 * Functionality: sends UE delete req to Scheduler
3363 * @params[in] Pst *pst, MacUeDelete *ueDelete
3364 * @return ROK - success
3367 * ****************************************************************/
3369 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
3371 if(ueDelete != NULLP)
3374 SchUeDelete schUeDel;
3376 memset(&schUeDel, 0, sizeof(SchUeDelete));
3377 schUeDel.cellId = ueDelete->cellId;
3378 schUeDel.crnti = ueDelete->crnti;
3379 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3380 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
3381 return(SchMessageRouter(&schPst, (void *)&schUeDel));
3385 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
3391 /*******************************************************************
3393 * @brief Handles UE Delete requst from DU APP
3397 * Function : MacProcUeDeleteReq
3399 * Functionality: Handles UE Delete requst from DU APP
3401 * @params[in] Pst *pst, MacUeDelete *ueDelete
3402 * @return ROK - success
3405 * ****************************************************************/
3407 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
3411 CauseOfResult status =SUCCESSFUL;
3412 MacUeCb *ueCb = NULLP;
3413 MacCellCb *cellCb = NULLP;
3415 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
3419 GET_CELL_IDX(ueDelete->cellId, cellIdx);
3420 cellCb = macCb.macCell[cellIdx];
3423 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
3424 if(ueCb->crnti == ueDelete->crnti)
3426 ret = sendUeDelReqToSch(pst, ueDelete);
3429 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
3435 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
3436 status = UEID_INVALID;
3441 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
3442 status = CELLID_INVALID;
3445 if(status!= SUCCESSFUL)
3447 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, status);
3448 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
3454 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
3460 /*******************************************************************
3462 * @brief Fill and Send UE Reset response from MAC to DU APP
3466 * Function : MacSendUeResetRsp
3468 * Functionality: Fill and Send UE Reset response from MAC to DUAPP
3470 * @params[in] MAC UE Reset result
3471 * SCH UE Reset response
3472 * @return ROK - success
3475 * ****************************************************************/
3477 uint8_t MacSendUeResetRsp(uint16_t cellId, uint16_t ueId, CauseOfResult status)
3479 MacUeResetRsp *ResetRsp;
3482 MAC_ALLOC_SHRABL_BUF(ResetRsp, sizeof(MacUeResetRsp));
3485 DU_LOG("\nERROR --> MAC : Memory allocation for UE Reset response failed");
3489 /* Filling UE Reset response */
3490 ResetRsp->cellId = cellId;
3491 ResetRsp->ueId = ueId;
3492 ResetRsp->status = status;
3494 /* Fill Post structure and send UE Reset response*/
3495 memset(&rspPst, 0, sizeof(Pst));
3496 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RESET_RSP);
3497 return (*macDuUeResetRspOpts[rspPst.selector])(&rspPst, ResetRsp);
3500 /*******************************************************************
3502 * @brief Handles UE Reset request from DU APP
3506 * Function : MacProcUeResetReq
3508 * Functionality: Handles UE Reset requst from DU APP
3510 * @params[in] Pst *pst, MacUeResetReq *ueReset
3511 * @return ROK - success
3514 * ****************************************************************/
3516 uint8_t MacProcUeResetReq(Pst *pst, MacUeResetReq *ueReset)
3519 CauseOfResult status =SUCCESSFUL;
3520 MacUeCb *ueCb = NULLP;
3521 MacCellCb *cellCb = NULLP;
3523 DU_LOG("\nINFO --> MAC : UE Reset Request received for ueId[%d]", ueReset->ueId);
3527 GET_CELL_IDX(ueReset->cellId, cellIdx);
3528 cellCb = macCb.macCell[cellIdx];
3531 ueCb = &cellCb->ueCb[ueReset->ueId-1];
3532 if(ueCb->ueId == ueReset->ueId)
3534 /* TODO := complete the processing of UE reset request*/
3538 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): UE ID [%d] not found in Cell Id [%d]", ueCb->ueId , ueReset->cellId);
3539 status = UEID_INVALID;
3544 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): Cell Id [%d] not found ",ueReset->cellId);
3545 status = CELLID_INVALID;
3548 MacSendUeResetRsp(ueReset->cellId, ueReset->ueId, status);
3549 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReset, sizeof(MacUeResetReq));
3553 DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): MAC UE reset request processing failed");
3558 /**********************************************************************
3560 **********************************************************************/