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"
29 #include "du_app_mac_inf.h"
33 /* function pointers for packing slot ind from mac to sch */
34 MacSchUeCreateReqFunc macSchUeCreateReqOpts[] =
36 packMacSchUeCreateReq, /* packing for loosely coupled */
37 macSchUeCreateReq, /* packing for tightly coupled */
38 packMacSchUeCreateReq /* packing for light weight loosely coupled */
41 DuMacUeCreateRspFunc DuMacUeCreateRspOpts[] =
43 packDuMacUeCreateRsp, /* packing for loosely coupled */
44 duHandleMacUeCreateRsp, /* packing for tightly coupled */
45 packDuMacUeCreateRsp, /* packing for light weight loosly coupled */
48 /*******************************************************************
50 * @brief Fills mac cell group config to be sent to scheduler
54 * Function : fillMacCellGroupCfg
56 * Functionality: Fills mac cell group config to be sent to sch
58 * @params[in] macCellGrp : mac cell group config at MAC
59 * *macCellGrpCfg : mac cell group cfg to be filled
60 * @return ROK - success
63 * ****************************************************************/
64 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
67 SchSchedReqCfg *schedReqCfg;
70 /* Copy scheduling request config */
71 schedReqCfg = &macCellGrpCfg->schedReqCfg;
72 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
73 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
75 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
76 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
79 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
81 schedReqCfg->addModList[idx].schedReqId = \
82 macCellGrp.schReqCfg.addModList[idx].schedReqId;
83 schedReqCfg->addModList[idx].srProhibitTmr = \
84 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
85 schedReqCfg->addModList[idx].srTransMax = \
86 macCellGrp.schReqCfg.addModList[idx].srTransMax;
88 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
91 tagCfg = &macCellGrpCfg->tagCfg;
92 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
93 if(tagCfg->addModListCount > MAX_NUM_TAGS)
95 DU_LOG("\nMAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
96 tagCfg->addModListCount, MAX_NUM_TAGS);
99 for(idx = 0; idx < tagCfg->addModListCount; idx++)
101 tagCfg->addModList[idx].tagId = \
102 macCellGrp.tagCfg.addModList[idx].tagId;
103 tagCfg->addModList[idx].timeAlignmentTmr = \
104 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
106 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
108 /* Copy PHR config */
109 if(macCellGrp.phrCfgSetupPres)
111 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
112 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
113 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
114 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
115 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
116 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
117 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
123 /*******************************************************************
125 * @brief Fills phy cell group config to be sent to scheduler
129 * Function : fillPhyCellGroupCfg
131 * Functionality: Fills phy cell group config to be sent to sch
133 * @params[in] macUeCfg : Phy cell group config at MAC
134 * *schPhyCellGrp : phy cell group config to be filled
135 * @return ROK - success
138 * ****************************************************************/
139 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
141 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
142 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
147 /*******************************************************************
149 * @brief Fills PDSCh serving cell config to send to scheduler
153 * Function : fillPdschServCellCfg
155 * Functionality: Fills PDSCh serving cell config to send to scheduler
157 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
158 * *schPdschCfg : Pdsch serving cell config to be filled
159 * @return ROK - success
162 * ****************************************************************/
163 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
165 schPdschCfg->maxMimoLayers = NULL;
166 if(macPdschCfg.maxMimoLayers)
168 /* TODO : Optional parameter */
171 schPdschCfg->numHarqProcForPdsch = \
172 macPdschCfg.numHarqProcForPdsch;
174 schPdschCfg->maxCodeBlkGrpPerTb = NULL;
175 if(macPdschCfg.maxCodeBlkGrpPerTb)
177 /* TODO : Optional parameter */
180 schPdschCfg->codeBlkGrpFlushInd = NULL;
181 if(macPdschCfg.codeBlkGrpFlushInd)
183 /* TODO : Optional parameter */
186 schPdschCfg->xOverhead = NULL;
187 if(macPdschCfg.xOverhead)
189 /* TODO : Optional parameter */
195 /*******************************************************************
197 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
201 * Function : fillInitalUlBwpPuschCfg
204 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
206 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
207 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
208 * @return ROK - success
211 * ****************************************************************/
212 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
216 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
217 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
218 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
219 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
220 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
222 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
223 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
225 DU_LOG("\nMAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
226 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
229 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
231 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
232 macPuschCfg.timeDomRsrcAllocList[idx].k2;
233 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
234 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
235 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
236 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
237 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
238 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
241 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
245 /*******************************************************************
247 * @brief Fills initail UL BWP config to send to scheduler
251 * Function : fillInitialUlBwp
253 * Functionality: Fills initail UL BWP config to send to sch
255 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
256 * schInitUlBwp : Initial UL BWP cfg to be filled
257 * @return ROK - success
260 * ****************************************************************/
261 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
263 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
264 if(schInitUlBwp->pucchCfgPres)
266 /* TODO : Optional parameter */
269 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
270 if(schInitUlBwp->puschCfgPres)
272 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
274 DU_LOG("\nMAC : fillInitalUlBwpPuschCfg() failed");
281 /*******************************************************************
283 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
287 * Function : fillInitDlBwpPdcchCfg
290 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
292 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
293 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
294 * @return ROK - success
297 * ****************************************************************/
298 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
302 /* Fill CORESET info */
303 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
304 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
306 DU_LOG("\nMAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
307 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
311 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
313 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
314 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
315 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
316 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
317 schPdcchCfg->cRSetToAddModList[idx].duration = \
318 macPdcchCfg.cRSetToAddModList[idx].duration;
319 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
320 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
321 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
322 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
323 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
324 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
327 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
328 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
330 DU_LOG("\nMAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
331 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
335 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
340 /* Fill Search space info */
341 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
342 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
344 DU_LOG("\nMAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
345 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
348 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
350 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
351 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
352 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
353 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
354 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
355 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
356 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
357 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
358 MONITORING_SYMB_WITHIN_SLOT_SIZE);
359 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
360 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
361 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
362 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
363 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
364 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
365 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
366 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
367 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
368 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
369 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
370 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
371 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
372 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
375 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
376 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
378 DU_LOG("\nMAC : Number of search space to release [%d] exceeds max [%d]", \
379 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
382 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
390 /*******************************************************************
392 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
396 * Function : fillInitDlBwpPdschCfg
399 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
401 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
402 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
403 * @return ROK - success
406 * ****************************************************************/
407 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
411 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
412 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
413 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
414 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
415 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
417 DU_LOG("\nMAC : Number of time domain resource allocation [%d], exceeds\
418 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
422 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
424 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
425 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
426 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
427 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
428 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
429 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
432 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
433 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
434 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
439 /*******************************************************************
441 * @brief Fill Initial DL BWP for SCH UE config
445 * Function : fillInitialDlBwp
447 * Functionality: Fill Initial DL BWP for SCH UE config
449 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
450 * schInitDlBwp : Inital DL BWP cfg to be filled
451 * @return ROK - success
454 * ****************************************************************/
455 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
457 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
458 if(schInitDlBwp->pdcchCfgPres)
460 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
462 DU_LOG("\nMAC : fillInitDlBwpPdcchCfg() failed");
467 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
468 if(schInitDlBwp->pdschCfgPres)
470 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
472 DU_LOG("\nMAC : fillInitDlBwpPdschCfg() failed");
479 /*******************************************************************
481 * @brief Fills Sp Cell config to be sent to scheduler
485 * Function : fillSpCellCfg
487 * Functionality: Fills Sp Cell config to be sent to scheduler
489 * @params[in] macSpCellCfg : SP cell cfg at MAC
490 * schSpCellCfg : SP cell cfg to be filled
491 * @return ROK - success
494 * ****************************************************************/
495 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
498 SchServCellCfgInfo *servCellCfg;
500 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
501 servCellCfg = &schSpCellCfg->servCellCfg;
503 /* Fill initial DL BWP */
504 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
505 &servCellCfg->initDlBwp) != ROK )
507 DU_LOG("\nMAC : fillInitialDlBwp() failed");
511 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
512 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
514 DU_LOG("\nMAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
515 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
518 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
520 /* TODO : As of now numDlBwpToAdd = 0 */
523 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
524 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
525 servCellCfg->bwpInactivityTmr = NULL;
526 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
528 /* TODO : This is an optional parameter, not filled currently */
531 /* Fill PDSCH serving cell config */
532 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
533 &servCellCfg->pdschServCellCfg) != ROK)
535 DU_LOG("\nMAC : fillPdschServCellCfg() failed");
539 /* Fill Initail UL BWP */
540 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
541 &servCellCfg->initUlBwp) != ROK)
543 DU_LOG("\nMAC : fillInitialUlBwp() failed");
547 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
548 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
550 DU_LOG("\nMAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
551 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
554 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
556 /* TODO : As of now numDlBwpToAdd = 0 */
558 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
564 /*******************************************************************
566 * @brief Fill logical channel configuration
570 * Function : fillLogicalChannelCfg
572 * Functionality: Fill logical channel configuration
574 * @params[in] macLcCfg : Logical channel Cfg at MAC
575 * schLcCfg : LC cfg to fill at scheduler
576 * @return ROK - success
579 * ****************************************************************/
580 uint8_t fillLogicalChannelCfg(LcCfg macLcCfg, SchLcCfg *schLcCfg)
582 schLcCfg->lcId = macLcCfg.lcId;
583 schLcCfg->dlLcCfg.lcp = macLcCfg.dlLcCfg.lcp;
585 schLcCfg->drbQos = NULL;
588 /* TODO : Optional Parameter */
591 schLcCfg->snssai = NULL;
594 /* TODO : Optional Parameter */
597 schLcCfg->ulLcCfg = NULL;
600 /* TODO : Optional Parameter */
606 /*******************************************************************
608 * @brief Fills and sends UE configuration to Scheduler
612 * Function : sendAddUeCreateReqToSch
614 * Functionality: Fills and sends UE configuration to Scheduler
616 * @params[in] Ue configuration from DU APP
617 * @return ROK - success
620 * ****************************************************************/
621 uint8_t sendAddUeCreateReqToSch(MacUeCfg *ueCfg)
627 schUeCfg.cellId = ueCfg->cellId;
628 schUeCfg.crnti = ueCfg->crnti;
630 /* Copy MAC cell group config */
631 memset(&schUeCfg.macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
632 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg.macCellGrpCfg) != ROK)
634 DU_LOG("\nMAC : fillMacCellGroupCfg() failed");
638 /* Copy Physical cell group config */
639 memset(&schUeCfg.phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
640 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg.phyCellGrpCfg) != ROK)
642 DU_LOG("\nMAC : fillPhyCellGroupCfg() failed");
646 /* Copy sp cell config */
647 memset(&schUeCfg.spCellCfg, 0, sizeof(SchSpCellCfg));
648 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg.spCellCfg) != ROK)
650 DU_LOG("\nMAC : fillSpCellCfg() failed");
654 schUeCfg.aggrMaxBitRate = NULL;
655 if(ueCfg->maxAggrBitRate != NULL)
658 MAC_ALLOC(schUeCfg.aggrMaxBitRate, sizeof(SchAggrMaxBitRate));
659 if(!schUeCfg.aggrMaxBitRate)
661 DU_LOG("\nMAC : Memory allocation failed in sendAddUeCreateReqToSch");
664 schUeCfg.aggrMaxBitRate->ulBitRate = ueCfg->maxAggrBitRate->ulBits;
665 schUeCfg.aggrMaxBitRate->dlBitRate = ueCfg->maxAggrBitRate->dlBits;
668 schUeCfg.numLc = ueCfg->numLcs;
669 if(schUeCfg.numLc > MAX_NUM_LOGICAL_CHANNELS)
671 DU_LOG("\nMAC : Number of Logical channels %d exceeds max limit %d",\
672 schUeCfg.numLc, MAX_NUM_LOGICAL_CHANNELS);
674 for(idx = 0; idx < schUeCfg.numLc; idx++)
676 if(fillLogicalChannelCfg(ueCfg->lcCfgList[idx], &schUeCfg.lcCfgList[idx]) != ROK)
678 DU_LOG("\nMAC : fillLogicalChannelCfg() failed");
683 fillMacToSchPst(&pst);
684 pst.event = EVENT_UE_CREATE_REQ_TO_SCH;
686 return(*macSchUeCreateReqOpts[pst.selector])(&pst, &schUeCfg);
689 /*******************************************************************
691 * @brief Creates UE Cb and fills ueCfg
695 * Function : createUeCb
697 * Functionality: Creates UE Cb and fills ueCfg
699 * @params[in] MAC UE Configuration
700 * @return ROK - success
703 * ****************************************************************/
704 uint8_t createUeCb(MacUeCfg *ueCfg)
706 uint16_t ueIdx, lcIdx;
709 /* Validate cell id */
710 if(macCb.macCell->cellId != ueCfg->cellId)
712 DU_LOG("\nMAC : Cell Id %d not configured", ueCfg->cellId);
716 /* Check if max number of UE configured */
717 if(macCb.macCell->numActvUe > MAX_UE)
719 DU_LOG("MAC : Max number of UE [%d] already configured", MAX_UE);
723 /* Check if UE already configured */
724 ueCb = &macCb.macCell->ueCb[ueCfg->ueIdx];
727 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti) &&\
728 (ueCb->state == UE_STATE_ACTIVE))
730 DU_LOG("\n MAC : CRNTI %d already configured ", ueCfg->crnti);
735 /* Fill received Ue Configuration in UeCb */
736 memset(ueCb, 0, sizeof(MacUeCb));
738 ueCb->crnti = ueCfg->crnti;
739 ueCb->cellCb = macCb.macCell;
740 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
741 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
742 ueCb->state = UE_STATE_ACTIVE;
745 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer)
748 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_1MS;
751 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_5MS;
754 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_10MS;
757 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_16MS;
760 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_20MS;
763 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_32MS;
766 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_40MS;
769 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_60MS;
772 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_80MS;
775 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_128MS;
778 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_160MS;
781 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_320MS;
784 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_640MS;
787 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_1280MS;
790 ueCb->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR_2560MS;
793 DU_LOG("\nMAC : Invalid BSR Periodic Timer");
797 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer)
800 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_10MS;
803 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_20MS;
806 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_40MS;
809 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_80MS;
812 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_160MS;
815 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_320MS;
818 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_640MS;
821 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_1280MS;
824 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_2560MS;
827 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_5120MS;
830 ueCb->bsrTmrCfg.retxTimer = RETX_BSR_TMR_10240MS;
833 DU_LOG("\nMAC : Invalid BSR retransmission timer");
837 switch(ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer)
840 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_20MS;
843 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_40MS;
846 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_64MS;
849 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_128MS;
852 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_512MS;
855 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_1024MS;
858 ueCb->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR_2560MS;
861 DU_LOG("\nMAC : Invalid SR delay timer");
866 if(ueCfg->numLcs > MAX_NUM_LOGICAL_CHANNELS)
868 DU_LOG("\nMAC : Number of LC to configure[%d] exceeds limit[%d]",\
869 ueCfg->numLcs, MAX_NUM_LOGICAL_CHANNELS);
873 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
875 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
876 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = LC_STATE_ACTIVE;
877 ueCb->dlInfo.numDlLc++;
881 for(ueIdx = 0; ueIdx < MAX_UE; ueIdx++)
883 if(macCb.macCell->macRaCb[ueIdx].crnti == ueCb->crnti)
885 ueCb->raCb = &macCb.macCell->macRaCb[ueIdx];
890 macCb.macCell->numActvUe++;
895 /*******************************************************************
897 * @brief Handles UE create requst from DU APP
901 * Function : MacHdlUeCreateReq
903 * Functionality: Handles UE create requst from DU APP
906 * @return ROK - success
909 * ****************************************************************/
910 uint8_t MacHdlUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
914 DU_LOG("\nMAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
918 ret = createUeCb(ueCfg);
921 ret = sendAddUeCreateReqToSch(ueCfg);
924 DU_LOG("\nMAC : Failed to send UE Create request to scheduler");
929 DU_LOG("\nMAC : Failed to create MAC UE Cb ");
934 DU_LOG("\nMAC : MAC UE Create request processing failed");
937 /* FREE shared memory */
938 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
943 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
948 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
951 DU_LOG("\nMAC: Memory allocation for UE config response failed");
955 /* Filling UE Config response */
956 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
957 cfgRsp->cellId = schCfgRsp->cellId;
958 cfgRsp->ueIdx = schCfgRsp->ueIdx;
959 cfgRsp->result = result;
961 /* Filling Post structure */
962 memset(&rspPst, 0, sizeof(Pst));
963 rspPst.selector = ODU_SELECTOR_LWLC;
964 rspPst.srcEnt = ENTRG;
965 rspPst.dstEnt = ENTDUAPP;
967 rspPst.srcInst = macCb.macInst;
968 rspPst.dstProcId = macCb.procId;
969 rspPst.srcProcId = macCb.procId;
970 rspPst.region = MAC_MEM_REGION;
971 rspPst.pool = MAC_POOL;
972 rspPst.event = EVENT_MAC_UE_CREATE_RSP;
974 return DuMacUeCreateRspOpts[rspPst.selector](&rspPst, cfgRsp);
979 /*******************************************************************
981 * @brief Processes UE create response from scheduler
985 * Function : MacProcSchUeCfgRsp
988 * Processes UE create response from scheduler
989 * Sends UE create response to DU APP
991 * @params[in] Pst : Post structure
992 * schCfgRsp : Scheduler UE cfg response
993 * @return ROK - success
996 * ****************************************************************/
997 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
999 uint8_t result = MAC_DU_APP_RSP_NOK;
1002 if(schCfgRsp->rsp == RSP_NOK)
1004 DU_LOG("\nMAC : SCH UE Create Response : FAILURE [CRNTI %d]", schCfgRsp->crnti);
1005 memset(&macCb.macCell->ueCb[schCfgRsp->ueIdx], 0, sizeof(MacUeCb));
1006 macCb.macCell->numActvUe--;
1007 result = MAC_DU_APP_RSP_NOK;
1011 DU_LOG("\nMAC : SCH UE Create Response : SUCCESS [CRNTI %d]", schCfgRsp->crnti);
1012 result = MAC_DU_APP_RSP_OK;
1014 ret = MacSendUeCreateRsp(result, schCfgRsp);
1019 /**********************************************************************
1021 **********************************************************************/