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 /* function pointers for packing slot ind from mac to sch */
32 MacSchAddUeConfigReqFunc macSchAddUeConfigReqOpts[] =
34 packMacSchAddUeConfigReq, /* packing for loosely coupled */
35 MacSchAddUeConfigReq, /* packing for tightly coupled */
36 packMacSchAddUeConfigReq /* packing for light weight loosely coupled */
39 MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
41 packDuMacUeCfgRsp, /* packing for loosely coupled */
42 DuProcMacUeCfgRsp, /* packing for tightly coupled */
43 packDuMacUeCfgRsp /* packing for light weight loosly coupled */
46 MacSchModUeConfigReqFunc macSchModUeConfigReqOpts[] =
48 packMacSchModUeConfigReq, /* packing for loosely coupled */
49 MacSchModUeConfigReq, /* packing for tightly coupled */
50 packMacSchModUeConfigReq /* packing for light weight loosely coupled */
53 /*******************************************************************
55 * @brief Fills mac cell group config to be sent to scheduler
59 * Function : fillMacCellGroupCfg
61 * Functionality: Fills mac cell group config to be sent to sch
63 * @params[in] macCellGrp : mac cell group config at MAC
64 * *macCellGrpCfg : mac cell group cfg to be filled
65 * @return ROK - success
68 * ****************************************************************/
69 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
72 SchSchedReqCfg *schedReqCfg;
75 /* Copy scheduling request config */
76 schedReqCfg = &macCellGrpCfg->schedReqCfg;
77 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
78 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
80 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
81 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
84 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
86 schedReqCfg->addModList[idx].schedReqId = \
87 macCellGrp.schReqCfg.addModList[idx].schedReqId;
88 schedReqCfg->addModList[idx].srProhibitTmr = \
89 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
90 schedReqCfg->addModList[idx].srTransMax = \
91 macCellGrp.schReqCfg.addModList[idx].srTransMax;
93 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
96 tagCfg = &macCellGrpCfg->tagCfg;
97 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
98 if(tagCfg->addModListCount > MAX_NUM_TAGS)
100 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
101 tagCfg->addModListCount, MAX_NUM_TAGS);
104 for(idx = 0; idx < tagCfg->addModListCount; idx++)
106 tagCfg->addModList[idx].tagId = \
107 macCellGrp.tagCfg.addModList[idx].tagId;
108 tagCfg->addModList[idx].timeAlignmentTmr = \
109 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
111 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
113 /* Copy PHR config */
114 if(macCellGrp.phrCfgSetupPres)
116 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
117 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
118 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
119 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
120 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
121 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
122 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
128 /*******************************************************************
130 * @brief Fills phy cell group config to be sent to scheduler
134 * Function : fillPhyCellGroupCfg
136 * Functionality: Fills phy cell group config to be sent to sch
138 * @params[in] macUeCfg : Phy cell group config at MAC
139 * *schPhyCellGrp : phy cell group config to be filled
140 * @return ROK - success
143 * ****************************************************************/
144 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
146 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
147 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
152 /*******************************************************************
154 * @brief Fills PDSCh serving cell config to send to scheduler
158 * Function : fillPdschServCellCfg
160 * Functionality: Fills PDSCh serving cell config to send to scheduler
162 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
163 * *schPdschCfg : Pdsch serving cell config to be filled
164 * @return ROK - success
167 * ****************************************************************/
168 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
170 if(macPdschCfg.maxMimoLayers)
172 if(!schPdschCfg->maxMimoLayers)
174 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
175 if(!schPdschCfg->maxMimoLayers)
177 DU_LOG("\nMAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
181 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
185 schPdschCfg->maxMimoLayers = NULLP;
188 schPdschCfg->numHarqProcForPdsch = \
189 macPdschCfg.numHarqProcForPdsch;
191 if(macPdschCfg.maxCodeBlkGrpPerTb)
193 if(!schPdschCfg->maxCodeBlkGrpPerTb)
195 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
196 if(!schPdschCfg->maxCodeBlkGrpPerTb)
198 DU_LOG("\nMAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
202 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
206 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
209 if(macPdschCfg.codeBlkGrpFlushInd)
211 if(!schPdschCfg->codeBlkGrpFlushInd)
213 MAC_ALLOC_SHRABL_BUF(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
214 if(!schPdschCfg->codeBlkGrpFlushInd)
216 DU_LOG("\nMAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
220 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
224 schPdschCfg->codeBlkGrpFlushInd = NULLP;
227 if(macPdschCfg.xOverhead)
229 if(!schPdschCfg->xOverhead)
231 MAC_ALLOC_SHRABL_BUF(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
232 if(!schPdschCfg->xOverhead)
234 DU_LOG("\nMAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
238 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
242 schPdschCfg->xOverhead = NULLP;
248 /*******************************************************************
250 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
254 * Function : fillInitalUlBwpPuschCfg
257 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
259 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
260 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
261 * @return ROK - success
264 * ****************************************************************/
265 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
269 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
270 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
271 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
272 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
273 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
274 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
276 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
277 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
279 DU_LOG("\nMAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
280 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
283 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
285 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
286 macPuschCfg.timeDomRsrcAllocList[idx].k2;
287 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
288 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
289 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
290 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
291 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
292 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
295 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
299 /*******************************************************************
301 * @brief Fills initail UL BWP config to send to scheduler
305 * Function : fillInitialUlBwp
307 * Functionality: Fills initail UL BWP config to send to sch
309 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
310 * schInitUlBwp : Initial UL BWP cfg to be filled
311 * @return ROK - success
314 * ****************************************************************/
315 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
317 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
318 if(schInitUlBwp->pucchCfgPres)
320 /* TODO : Optional parameter */
323 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
324 if(schInitUlBwp->puschCfgPres)
326 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
328 DU_LOG("\nMAC : fillInitalUlBwpPuschCfg() failed");
335 /*******************************************************************
337 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
341 * Function : fillInitDlBwpPdcchCfg
344 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
346 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
347 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
348 * @return ROK - success
351 * ****************************************************************/
352 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
356 /* Fill CORESET info */
357 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
358 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
360 DU_LOG("\nMAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
361 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
365 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
367 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
368 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
369 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
370 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
371 schPdcchCfg->cRSetToAddModList[idx].duration = \
372 macPdcchCfg.cRSetToAddModList[idx].duration;
373 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
374 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
375 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
376 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
377 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
378 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
381 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
382 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
384 DU_LOG("\nMAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
385 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
389 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
394 /* Fill Search space info */
395 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
396 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
398 DU_LOG("\nMAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
399 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
402 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
404 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
405 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
406 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
407 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
408 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
409 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
410 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
411 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
412 MONITORING_SYMB_WITHIN_SLOT_SIZE);
413 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
414 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
415 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
416 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
417 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
418 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
419 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
420 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
421 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
422 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
423 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
424 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
425 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
426 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
429 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
430 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
432 DU_LOG("\nMAC : Number of search space to release [%d] exceeds max [%d]", \
433 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
436 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
444 /*******************************************************************
446 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
450 * Function : fillInitDlBwpPdschCfg
453 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
455 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
456 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
457 * @return ROK - success
460 * ****************************************************************/
461 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
465 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
466 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
467 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
468 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
469 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
471 DU_LOG("\nMAC : Number of time domain resource allocation [%d], exceeds\
472 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
476 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
478 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
479 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
480 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
481 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
482 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
483 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
486 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
487 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
488 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
489 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
491 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
493 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
495 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
496 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
501 /*******************************************************************
503 * @brief Fill Initial DL BWP for SCH UE config
507 * Function : fillInitialDlBwp
509 * Functionality: Fill Initial DL BWP for SCH UE config
511 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
512 * schInitDlBwp : Inital DL BWP cfg to be filled
513 * @return ROK - success
516 * ****************************************************************/
517 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
519 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
520 if(schInitDlBwp->pdcchCfgPres)
522 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
524 DU_LOG("\nMAC : fillInitDlBwpPdcchCfg() failed");
529 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
530 if(schInitDlBwp->pdschCfgPres)
532 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
534 DU_LOG("\nMAC : fillInitDlBwpPdschCfg() failed");
541 /*******************************************************************
543 * @brief Fills Sp Cell config to be sent to scheduler
547 * Function : fillSpCellCfg
549 * Functionality: Fills Sp Cell config to be sent to scheduler
551 * @params[in] macSpCellCfg : SP cell cfg at MAC
552 * schSpCellCfg : SP cell cfg to be filled
553 * @return ROK - success
556 * ****************************************************************/
557 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
560 SchServCellCfgInfo *servCellCfg;
562 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
563 servCellCfg = &schSpCellCfg->servCellCfg;
565 /* Fill initial DL BWP */
566 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
567 &servCellCfg->initDlBwp) != ROK )
569 DU_LOG("\nMAC : fillInitialDlBwp() failed");
573 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
574 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
576 DU_LOG("\nMAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
577 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
580 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
582 /* TODO : As of now numDlBwpToAdd = 0 */
585 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
586 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
587 servCellCfg->bwpInactivityTmr = NULL;
588 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
590 /* TODO : This is an optional parameter, not filled currently */
593 /* Fill PDSCH serving cell config */
594 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
595 &servCellCfg->pdschServCellCfg) != ROK)
597 DU_LOG("\nMAC : fillPdschServCellCfg() failed");
601 /* Fill Initail UL BWP */
602 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
603 &servCellCfg->initUlBwp) != ROK)
605 DU_LOG("\nMAC : fillInitialUlBwp() failed");
609 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
610 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
612 DU_LOG("\nMAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
613 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
616 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
618 /* TODO : As of now numDlBwpToAdd = 0 */
620 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
625 /*******************************************************************
627 * @brief Sends UE configuration to Scheduler
631 * Function : sendUeReqToSch
633 * Functionality: sends UE configuration to Scheduler
635 * @params[in] Pst and Ue configuration
636 * @return ROK - success
639 * ****************************************************************/
641 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
646 case EVENT_MAC_UE_CREATE_REQ:
647 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
648 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
650 case EVENT_MAC_UE_RECONFIG_REQ:
651 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
652 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
654 DU_LOG("\n Invalid Pst received %d", pst->event);
659 /*******************************************************************
661 * @brief Fills Sch Drb Qos Information
665 * Function : fillSchDrbQosInfo
667 * Functionality: Fills Sch Drb Qos Information
669 * @params[in] macLcCfg : Logical channel Cfg at MAC
670 * schLcCfg : LC cfg to fill at scheduler
671 * @return ROK - success
674 * ****************************************************************/
675 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
677 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
678 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
680 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
681 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
682 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
683 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
685 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
687 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
688 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
689 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
690 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
691 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
692 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
693 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
694 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
696 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
697 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
698 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
699 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
700 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
701 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
702 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
703 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
704 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
707 /*******************************************************************
709 * @brief Fill SCH UL logical channel configuration
713 * Function : fillSchUlLcCfg
715 * Functionality: Fills Sch Ul Lc configuration
717 * @params[in] macLcCfg : Logical channel Cfg at MAC
718 * schLcCfg : LC cfg to fill at scheduler
721 * ****************************************************************/
723 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
725 schUlLcCfg->priority= macUlLcCfg->priority;
726 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
727 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
728 schUlLcCfg->pbr = macUlLcCfg->pbr;
729 schUlLcCfg->bsd = macUlLcCfg->bsd;
732 /*******************************************************************
734 * @brief Fill logical channel configuration
738 * Function : fillLogicalChannelCfg
740 * Functionality: Fill logical channel configuration
742 * @params[in] macLcCfg : Logical channel Cfg at MAC
743 * schLcCfg : LC cfg to fill at scheduler
744 * @return ROK - success
747 * ****************************************************************/
748 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
752 schLcCfg->lcId = macLcCfg->lcId;
753 schLcCfg->configType = macLcCfg->configType;
754 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
755 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
759 if(!schLcCfg->drbQos)
761 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
762 if(!schLcCfg->drbQos)
764 DU_LOG("\nMAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
770 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
777 schLcCfg->drbQos = NULLP;
784 if(!schLcCfg->snssai)
786 MAC_ALLOC(schLcCfg->snssai, sizeof(SchSnssai));
787 if(!schLcCfg->snssai)
789 DU_LOG("\nMAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
795 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
796 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
798 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
803 schLcCfg->snssai = NULLP;
804 /*Freeing the previously allocated buffer in case of failure */
807 MAC_FREE(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
808 schLcCfg->drbQos = NULLP;
815 schLcCfg->snssai = NULLP;
822 /*******************************************************************
824 * @brief Fills Logical channel Cfg List to Add/Mod/Del
828 * Function : fillSchLcCfgList
830 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
832 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
833 * @return ROK - success
836 * ****************************************************************/
838 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
842 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
844 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
846 DU_LOG("\nMAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
854 /*******************************************************************
856 * @brief Fills and sends UE configuration to Scheduler
860 * Function : fillSchUeCfg
862 * Functionality: Fills and sends UE configuration to Scheduler
864 * @params[in] Ue configuration from DU APP
865 * @return ROK - success
868 * ****************************************************************/
869 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
873 schUeCfg->cellId = ueCfg->cellId;
874 schUeCfg->crnti = ueCfg->crnti;
876 /* Copy MAC cell group config */
877 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
878 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
880 DU_LOG("\nMAC : fillMacCellGroupCfg() failed");
884 /* Copy Physical cell group config */
885 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
886 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
888 DU_LOG("\nMAC : fillPhyCellGroupCfg() failed");
892 /* Copy sp cell config */
893 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
894 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
896 DU_LOG("\nMAC : fillSpCellCfg() failed");
900 if(ueCfg->ambrCfg != NULLP)
902 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
903 if(!schUeCfg->ambrCfg)
905 DU_LOG("\nMAC : Memory allocation failed in sendReconfigReqToSch");
908 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
909 schUeCfg->ambrCfg->dlBr = ueCfg->ambrCfg->dlBr;
912 schUeCfg->ambrCfg = NULLP;
914 /* Fill DL modulation infor */
915 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
916 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
917 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
919 /* Fill UL modulation infor */
920 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
921 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
922 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
924 /* Fill sch Lc Cfg to Add/ Mod/ Del */
925 ret = fillSchLcCfgList(schUeCfg, ueCfg);
928 DU_LOG("\nMAC : Failed to copy LCs at fillSchUeCfg()");
934 /*******************************************************************
936 * @brief Update UeUlCb Lc List
940 * Function : updateMacUlCb
942 * Functionality: Update UeUlCb Lc List
944 * @params[in] delIdx, UeUlCb pointer
947 * ****************************************************************/
949 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
953 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
955 /* Moving the array element to one step ahead */
956 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
957 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
961 /*******************************************************************
963 * @brief Update UeDlCb Lc List
967 * Function : updateMacDlCb
969 * Functionality: Update UeDlCb Lc List
971 * @params[in] delIdx, UeDlCb pointer
974 * ****************************************************************/
976 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
980 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
982 /* Moving the array element to one step ahead */
983 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
984 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
988 /*******************************************************************
990 * @brief Fills Logical channel Cfg List to Add/Mod/Del
994 * Function : fillMacLcCfgList
996 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
998 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
999 * @return ROK - success
1002 * ****************************************************************/
1004 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1006 uint8_t lcIdx, ueLcIdx;
1008 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1010 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1012 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1014 /*Filling DL LC CB */
1015 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1016 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1017 ueCb->dlInfo.numDlLc++;
1018 /*Filling UL LC CB */
1019 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1020 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1021 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1022 ueCb->ulInfo.numUlLc++;
1023 }/*End of Add Config */
1026 //searching for Lc to be Mod
1027 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++)
1029 if(ueCb->ulInfo.lcCb[ueLcIdx].lcId == ueCfg->lcCfgList[lcIdx].lcId)
1031 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
1033 /*Nothing to Modify in DL LC CB */
1034 /*Modify UL LC CB */
1035 ueCb->ulInfo.lcCb[ueLcIdx].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1036 DU_LOG("\nMAC: Successfully Modified LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1039 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
1041 memset(&ueCb->dlInfo.lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1042 (ueCb->dlInfo.numDlLc)--;
1043 updateMacDlCb(ueLcIdx, &ueCb->dlInfo);
1045 memset(&ueCb->ulInfo.lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1046 (ueCb->ulInfo.numUlLc)--;
1047 updateMacUlCb(ueLcIdx, &ueCb->ulInfo);
1048 DU_LOG("\nMAC: Successfully Deleted LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1053 }/*End of Mod Config */
1059 /*******************************************************************
1061 * @brief Fills MAC UE Cb Cfg
1065 * Function : fillMacUeCb
1067 * Functionality: Fills MAC UE Cb Cfg
1069 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1071 * @return ROK - success
1074 * ****************************************************************/
1076 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1080 ueCb->ueIdx = ueCfg->ueIdx;
1081 ueCb->crnti = ueCfg->crnti;
1082 ueCb->cellCb = macCb.macCell[cellIdx];
1083 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1084 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1085 ueCb->state = UE_STATE_ACTIVE;
1086 /*TODO: To check the bsr value during implementation */
1087 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
1088 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
1089 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
1090 ret = fillMacLcCfgList(ueCb, ueCfg);
1093 DU_LOG("\nMAC: Failed while filing MAC LC List at fillMacUeCb()");
1098 /*******************************************************************
1100 * @brief Function to update Mac Ra Cb
1104 * Function : updateMacRaCb
1106 * Functionality: Function to update Mac Ra Cb
1108 * @params[in] cellIdx, Mac Ue Cb
1109 * @return ROK - success
1112 * ****************************************************************/
1114 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1118 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1120 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1122 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
1129 /*******************************************************************
1131 * @brief Function to delete Mac Ra Cb
1135 * Function : deleteMacRaCb
1137 * Functionality: Function to delete Mac Ra Cb
1139 * @params[in] cellIdx, Mac Ue Cb
1142 * ****************************************************************/
1144 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1148 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1150 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1152 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
1154 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
1155 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
1157 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
1159 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
1160 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
1162 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
1169 /*******************************************************************
1171 * @brief Creates UE Cb
1175 * Function : createUeCb
1177 * Functionality: Creates UE Cb
1179 * @params[in] MAC UE Configuration
1180 * @return ROK - success
1183 * ****************************************************************/
1184 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1188 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1189 &&(ueCb->state == UE_STATE_ACTIVE))
1191 DU_LOG("\n MAC : CRNTI %d already configured ", ueCfg->crnti);
1196 memset(ueCb, 0, sizeof(MacUeCb));
1197 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1200 DU_LOG("\nMAC : Failed to create Ue Cb at createUeCb()");
1205 macCb.macCell[cellIdx]->numActvUe++;
1206 updateMacRaCb(cellIdx, ueCb);
1214 /*******************************************************************
1216 * @brief Modify UE Cb Cfg
1220 * Function : modifyUeCb
1222 * Functionality: modify UE Cb
1224 * @params[in] MAC UE Configuration
1225 * @return ROK - success
1228 * ****************************************************************/
1229 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1233 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1234 &&(ueCb->state == UE_STATE_ACTIVE))
1236 DU_LOG("\n MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
1237 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1240 DU_LOG("\nMAC : Failed to modify MacUeCb at modifyUeCb()");
1245 deleteMacRaCb(cellIdx, ueCb);
1253 /*******************************************************************
1255 * @brief Creates UE Cb and fills ueCfg
1259 * Function : procMacUeCfgData
1261 * Functionality: Creates UE Cb and fills ueCfg
1263 * @params[in] MAC UE Configuration
1264 * @return ROK - success
1267 * ****************************************************************/
1269 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
1273 MacUeCb *ueCb = NULLP;
1276 GET_CELL_IDX(ueCfg->cellId, cellIdx);
1278 /* Validate cell id */
1279 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
1281 DU_LOG("\nMAC : Cell Id %d not configured", ueCfg->cellId);
1285 /* Check if max number of UE configured */
1286 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
1288 DU_LOG("MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
1292 /* Check if UE already configured */
1293 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
1296 case EVENT_UE_CONFIG_RSP_TO_MAC:
1297 ret = createUeCb(cellIdx, ueCb, ueCfg);
1299 DU_LOG("\nMAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
1301 case EVENT_UE_RECONFIG_RSP_TO_MAC:
1302 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
1304 DU_LOG("\nMAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
1313 /*******************************************************************
1315 * @brief Function to store the UeCfg Data
1319 * Function : copyToTmpData
1321 * Functionality: Function to store the UeCfg Data
1323 * @params[in] MacUeCfg pointer
1324 * @return ROK - success
1327 * ****************************************************************/
1329 uint8_t copyToTmpData(MacUeCfg *ueCfg)
1332 MacUeCfg *tmpData = NULLP;
1334 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
1337 DU_LOG("\nMAC: Memory Alloc Failed at copyToTmpData()");
1340 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
1341 GET_CELL_IDX(ueCfg->cellId, cellIdx);
1342 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueIdx-1] = tmpData;
1346 /*******************************************************************
1348 * @brief Handles UE create requst from DU APP
1352 * Function : MacProcUeCreateReq
1354 * Functionality: Handles UE create requst from DU APP
1357 * @return ROK - success
1360 * ****************************************************************/
1361 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
1365 memset(&schUeCfg, 0, sizeof(SchUeCfg));
1367 DU_LOG("\nMAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
1371 /*Storing received ueCfg in ueCfgTmpData */
1372 ret = copyToTmpData(ueCfg);
1375 /*Sending Cfg Req to SCH */
1376 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
1378 DU_LOG("\nMAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
1381 /* Fill event and send UE create request to SCH */
1382 ret = sendUeReqToSch(pst, &schUeCfg);
1384 DU_LOG("\nMAC : Failed to send UE Create request to SCH");
1389 DU_LOG("\nMAC : Failed to store MAC UE CFG ");
1394 DU_LOG("\nMAC : MAC UE Create request processing failed");
1397 /* FREE shared memory */
1398 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
1403 /*******************************************************************
1405 * @brief Fill and Send UE create response from MAC to DU APP
1409 * Function : MacSendUeCreateRsp
1411 * Functionality: Fill and Send UE create response from MAC to DUAPP
1413 * @params[in] MAC UE create result
1414 * SCH UE create response
1415 * @return ROK - success
1418 * ****************************************************************/
1419 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
1421 MacUeCfgRsp *cfgRsp;
1424 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
1427 DU_LOG("\nMAC: Memory allocation for UE config response failed");
1431 /* Filling UE Config response */
1432 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
1433 cfgRsp->cellId = schCfgRsp->cellId;
1434 cfgRsp->ueIdx = schCfgRsp->ueIdx;
1435 cfgRsp->result = result;
1437 /* Fill Post structure and send UE Create response*/
1438 memset(&rspPst, 0, sizeof(Pst));
1439 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
1440 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
1443 /*******************************************************************
1445 * @brief Fill and Send UE Reconfig response from MAC to DU APP
1449 * Function : MacSendUeReconfigRsp
1451 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
1453 * @params[in] MAC UE create result
1454 * SCH UE create response
1455 * @return ROK - success
1458 * ****************************************************************/
1459 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
1461 MacUeCfgRsp *cfgRsp;
1464 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
1467 DU_LOG("\nMAC: Memory allocation for UE Reconfig response failed");
1471 /* Filling UE Config response */
1472 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
1473 cfgRsp->cellId = schCfgRsp->cellId;
1474 cfgRsp->ueIdx = schCfgRsp->ueIdx;
1475 cfgRsp->result = result;
1477 /* Fill Post structure and send UE Create response*/
1478 memset(&rspPst, 0, sizeof(Pst));
1479 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
1480 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
1483 /*******************************************************************
1485 * @brief Function to return Mac Ue Cfg pointer
1489 * Function : getMacUeCfg
1492 * Function to return Mac Ue Cfg pointer
1494 * @params[in] cellIdx, ueIdx
1496 * @return MacUeCfg pointer - success
1499 * ****************************************************************/
1501 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueIdx)
1503 MacUeCfg *ueCfg = NULLP;
1504 if(macCb.macCell[cellIdx])
1506 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueIdx-1];
1510 DU_LOG("\nMAC: Failed to get macCellCb in getMacUeCfg()");
1515 /*******************************************************************
1517 * @brief Processes UE create response from scheduler
1521 * Function : MacProcSchUeCfgRsp
1524 * Processes UE create response from scheduler
1525 * Sends UE create response to DU APP
1527 * @params[in] Pst : Post structure
1528 * schCfgRsp : Scheduler UE cfg response
1529 * @return ROK - success
1532 * ****************************************************************/
1533 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
1535 uint8_t result = MAC_DU_APP_RSP_NOK;
1538 MacUeCfg *ueCfg = NULLP;
1540 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
1541 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueIdx);
1544 DU_LOG("\nMAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
1550 case EVENT_UE_CONFIG_RSP_TO_MAC:
1552 if(schCfgRsp->rsp != RSP_NOK)
1554 DU_LOG("\nMAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
1557 ret = procMacUeCfgData(pst, ueCfg);
1560 result = MAC_DU_APP_RSP_OK;
1566 DU_LOG("\nMAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
1568 ret = MacSendUeCreateRsp(result, schCfgRsp);
1572 case EVENT_UE_RECONFIG_RSP_TO_MAC:
1574 if(schCfgRsp->rsp != RSP_NOK)
1576 DU_LOG("\nMAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
1579 ret = procMacUeCfgData(pst, ueCfg);
1582 result = MAC_DU_APP_RSP_OK;
1588 DU_LOG("\nMAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
1590 ret = MacSendUeReconfigRsp(result, schCfgRsp);
1597 MAC_FREE(ueCfg, sizeof(MacUeCfg));
1603 /*******************************************************************
1605 * @brief Handles UE Reconfig requst from DU APP
1609 * Function : MacProcUeReconfigReq
1611 * Functionality: Handles UE Reconfig requst from DU APP
1614 * @return ROK - success
1617 * ****************************************************************/
1618 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
1622 memset(&schUeCfg, 0, sizeof(SchUeCfg));
1624 DU_LOG("\nMAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
1628 /*Storing received ueCfg in ueCfgTmpData */
1629 ret = copyToTmpData(ueCfg);
1632 /*Sending Cfg Req to SCH */
1633 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
1635 DU_LOG("\nMAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
1638 /* Fill event and send UE create request to SCH */
1639 ret = sendUeReqToSch(pst, &schUeCfg);
1641 DU_LOG("\nMAC : Failed to send UE Reconfig Request to SCH");
1646 DU_LOG("\nMAC : Failed to store MAC UE Cb ");
1651 DU_LOG("\nMAC : MAC UE Create request processing failed");
1654 /* FREE shared memory */
1655 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
1660 /**********************************************************************
1662 **********************************************************************/