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 *******************************************************************************/
18 /* This file stores handler for MAC and SCH configuration requests */
19 /* header include files (.h) */
20 #include "common_def.h"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "lwr_mac_upr_inf.h"
27 #include "rlc_mac_inf.h"
28 #include "mac_upr_inf_api.h"
30 #include "lwr_mac_fsm.h"
31 #include "mac_utils.h"
32 #include "lwr_mac_phy.h"
34 uint8_t ssbPeriodicity[6] = {5, 10, 20, 40, 80, 160};
36 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg);
38 packMacCellCfgConfirm packMacCellCfmOpts[] =
40 packMacCellCfgCfm, /* packing for loosely coupled */
41 duHandleMacCellCfgCfm, /* packing for tightly coupled */
42 packMacCellCfgCfm, /* packing for light weight loosly coupled */
45 SchCellCfgFunc SchCellCfgOpts[] =
47 packSchCellCfg, /* packing for loosely coupled */
48 SchHdlCellCfgReq, /* packing for tightly coupled */
49 packSchCellCfg /* packing for light weight loosly coupled */
52 MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
54 packMacSchCellDeleteReq, /* packing for loosely coupled */
55 MacSchCellDeleteReq, /* packing for tightly coupled */
56 packMacSchCellDeleteReq /* packing for light weight loosely coupled */
59 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
61 packDuMacCellDeleteRsp, /* packing for loosely coupled */
62 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
63 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
66 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
68 packDuMacSliceCfgRsp, /* packing for loosely coupled */
69 DuProcMacSliceCfgRsp, /* packing for tightly coupled */
70 packDuMacSliceCfgRsp /* packing for light weight loosly coupled */
73 MacDuSliceReCfgRspFunc macDuSliceReCfgRspOpts[] =
75 packDuMacSliceReCfgRsp, /* packing for loosely coupled */
76 DuProcMacSliceReCfgRsp, /* packing for tightly coupled */
77 packDuMacSliceReCfgRsp /* packing for light weight loosly coupled */
81 * @brief Layer Manager Configuration request handler for Scheduler
85 * Function : MacSchGenCfgReq
87 * This function receives general configurations for Scheduler
88 * from DU APP and forwards to Scheduler.
90 * @param[in] Pst *pst, the post structure
91 * @param[in] RgMngmt *cfg, the configuration parameter's structure
95 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
97 printf("\nReceived Scheduler gen config at MAC");
98 pst->dstInst = DEFAULT_CELLS + 1;
99 SchProcGenCfgReq(pst, cfg);
105 * @brief Layer Manager Configuration response from Scheduler
109 * Function : SchSendCfgCfm
111 * This function sends general configurations response from
112 * Scheduler to DU APP.
114 * @param[in] Pst *pst, the post structure
115 * @param[in] RgMngmt *cfm, the configuration confirm structure
119 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
121 DU_LOG("\nDEBUG --> Sending Scheduler config confirm to DU APP");
122 pst->dstEnt = ENTDUAPP;
125 pst->selector = ODU_SELECTOR_LC;
126 RgMiLrgSchCfgCfm(pst, cfm);
132 * @brief Layer Manager Configuration request handler.
136 * Function : MacProcCellCfgReq
138 * This function handles the gNB and cell configuration
139 * request received from DU APP.
140 * This API unapcks and forwards the config towards SCH
142 * @param[in] Pst *pst
143 * @param[in] MacCellCfg *macCellCfg
147 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
151 uint8_t ret = ROK, sliceIdx = 0;
152 MacCellCb *macCellCb;
154 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
156 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
157 if(macCellCb == NULLP)
159 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
162 memset(macCellCb, 0, sizeof(MacCellCb));
164 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
165 macCb.macCell[cellIdx] = macCellCb;
166 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
167 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
169 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
170 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
171 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
173 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
176 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
177 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
179 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
180 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
182 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
184 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
188 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
190 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
192 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
194 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
195 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
197 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
200 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
206 /* Send cell cfg to scheduler */
207 ret = MacSchCellCfgReq(pst, macCellCfg);
210 MacCellCfgCfm macCellCfgCfm;
211 macCellCfgCfm.rsp = RSP_NOK;
212 macCellCfgCfm.cellId = macCellCfg->cellId;
214 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
215 cfmPst.selector = ODU_SELECTOR_LC;
217 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
221 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
224 } /* end of MacProcCellCfgReq */
227 * @brief Layer Manager Configuration request handler.
231 * Function : MacSchCellCfgReq
233 * This function sends cell configuration to SCH
235 * @param[in] Pst *pst
236 * @param[in] MacCellCfg *macCellCfg
240 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
242 SchCellCfg schCellCfg;
244 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
246 memset(&cfgPst, 0, sizeof(Pst));
247 memset(&schCellCfg, 0, sizeof(SchCellCfg));
248 schCellCfg.cellId = macCellCfg->cellId;
249 schCellCfg.phyCellId = macCellCfg->phyCellId;
250 schCellCfg.numerology = macCellCfg->numerology;
251 schCellCfg.dupMode = macCellCfg->dupType;
252 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
253 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
254 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
256 /* fill ssb scheduler parameters */
257 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
258 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
259 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
260 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
261 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
262 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
264 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
267 /* fill SIB1 scheduler parameters */
268 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
269 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
270 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
271 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
272 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
274 /* fill RACH config params */
275 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
276 schCellCfg.schRachCfg.prachSubcSpacing = \
277 macCellCfg->prachCfg.prachSubcSpacing;
278 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
279 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
280 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
281 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
282 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
283 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
284 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
285 schCellCfg.schRachCfg.prachMultCarrBand = \
286 macCellCfg->prachCfg.prachMultCarrBand;
287 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
288 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
289 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
291 /* fill initial DL BWP */
292 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
293 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
294 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
295 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
296 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
297 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
298 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
299 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
300 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
301 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
302 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
303 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
304 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
305 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
306 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
307 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
308 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
309 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
310 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
311 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
312 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
313 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
314 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
315 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
316 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
317 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
319 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
320 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
321 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
322 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
323 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
324 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
325 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
326 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
329 /* fill initial UL BWP */
330 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
331 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
332 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
333 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
334 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
335 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
336 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
338 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
339 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
340 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
341 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
342 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
343 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
344 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
345 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
348 if(macCellCfg->plmnInfoList.snssai)
350 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
351 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
352 if(!schCellCfg.plmnInfoList.snssai)
354 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
357 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
359 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
361 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
362 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
364 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
367 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
373 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
376 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
378 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
380 } /* end of MacSchCellCfgReq */
383 /*******************************************************************
385 * @brief Sends Cell config confirm to DU APP
389 * Function : MacSendCellCfgCfm
392 * Sends Cell config confirm to DU APP
394 * @params[in] Response status
397 * ****************************************************************/
398 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
402 MacCellCfgCfm macCellCfgCfm;
404 memset(&pst, 0, sizeof(Pst));
406 GET_CELL_IDX(cellId, cellIdx);
407 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
408 macCellCfgCfm.rsp = response;
411 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
412 pst.selector = ODU_SELECTOR_LC;
414 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
419 * @brief Layer Manager Configuration response handler.
423 * Function : MacProcSchCellCfgCfm
425 * This function processes cell configuration to SCH
427 * @param[in] Pst *pst
428 * @param[in] SchCellCfgCfm *schCellCfgCfm
432 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
434 uint16_t *cellId = NULLP;
436 #ifdef CALL_FLOW_DEBUG_LOG
437 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
440 if(schCellCfgCfm->rsp == RSP_OK)
442 cellId = &schCellCfgCfm->cellId;
443 #ifdef INTEL_TIMER_MODE
444 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
446 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
451 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
456 /*******************************************************************
458 * @brief MAC handler for config response from PHY
462 * Function : fapiMacConfigRsp
465 * Processes config response from PHY and sends cell config
471 * ****************************************************************/
472 void fapiMacConfigRsp(uint16_t cellId)
474 /* TODO : Processing of config response from PHY */
476 /* Send cell config cfm to DU APP */
477 MacSendCellCfgCfm(cellId, RSP_OK);
480 /*******************************************************************
482 * @brief Fill and Send Cell Delete response from MAC to DU APP
486 * Function : MacSendCellDeleteRsp
488 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
490 * @params[in] MAC Cell delete result
491 * SCH Cell delete response
492 * @return ROK - success
495 * ****************************************************************/
496 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
498 MacCellDeleteRsp *deleteRsp=NULLP;
501 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
504 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
508 /* Filling CELL delete response */
510 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
511 deleteRsp->cellId = cellId;
512 deleteRsp->result = result;
514 /* Fill Post structure and send CELL delete response*/
515 memset(&rspPst, 0, sizeof(Pst));
516 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
517 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
520 /*******************************************************************
522 * @brief Processes CELL delete response from scheduler
526 * Function : MacProcSchCellDeleteRsp
529 * Processes CELL delete from scheduler
531 * @params[in] Pst : Post structure
532 * schCellDelRsp : Scheduler CELL delete respons
533 * @return ROK - success
536 * * ****************************************************************/
537 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
539 uint8_t ret = ROK, sliceIdx = 0;
541 CellDeleteStatus status;
543 #ifdef CALL_FLOW_DEBUG_LOG
544 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
549 if(schCellDelRsp->rsp == RSP_OK)
551 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
552 schCellDelRsp->cellId);
553 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
554 if(macCb.macCell[cellIdx])
556 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
558 status = SUCCESSFUL_RSP;
559 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
561 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
563 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
565 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
566 numSupportedSlice * sizeof(Snssai*));
568 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
569 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
570 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
574 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
575 status = CELL_ID_INVALID;
581 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
582 status = CELL_ID_INVALID;
588 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
589 status = CELL_ID_INVALID;
592 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
594 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
601 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
607 /*******************************************************************
609 * @brief Sends Cell delete req to Scheduler
613 * Function : sendCellDelReqToSch
615 * Functionality: sends Cell delete req to Scheduler
617 * @params[in] SchCellDelete *schCellDel
618 * @return ROK - success
621 * ****************************************************************/
623 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
626 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
627 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
630 /*******************************************************************
632 * @brief Handles CELL Delete requst from DU APP
636 * Function : MacProcCellDeleteReq
638 * Functionality: Handles CELL Delete requst from DU APP
640 * @params[in] Pst *pst, MacCellDelete *cellDelete
641 * @return ROK - success
645 * ****************************************************************/
646 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
648 uint8_t ret = ROK, cellIdx=0;
649 SchCellDelete schCellDelete;
651 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
655 GET_CELL_IDX(cellDelete->cellId, cellIdx);
656 if(macCb.macCell[cellIdx])
658 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
660 memset(&schCellDelete, 0, sizeof(SchCellDelete));
661 schCellDelete.cellId = cellDelete->cellId;
662 ret = sendCellDelReqToSch(&schCellDelete);
665 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
671 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
678 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
685 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
686 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
688 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
693 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
697 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
704 * @brief free the temporary slice cfg stored in macCb.
708 * Function : freeMacSliceCfgReq
710 * free the temporary slice cfg stored in macCb
716 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
722 if(cfgReq->numOfConfiguredSlice)
724 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
726 if(cfgReq->listOfSliceCfg[cfgIdx])
728 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
730 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
732 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
734 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
738 * @brief fill Mac Slice Config Rsp
742 * Function : fillMacSliceCfgRsp
744 * This function fill Mac Slice Config Rsp
746 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
751 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
754 bool sliceFound = false;
757 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
758 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
759 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
761 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
765 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
768 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
773 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
774 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
776 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
780 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
781 if(sliceFound == true)
782 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
785 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
786 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
793 * @brief send slice cfg response to duapp.
797 * Function : MacSendSliceConfigRsp
799 * sends slice cfg response to duapp
801 * @param[in] MacSliceCfgRsp macSliceCfgRsp
805 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
809 memset(&rspPst, 0, sizeof(Pst));
810 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
811 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
815 * @brief free the slice cfg rsp received from sch.
819 * Function : freeSchSliceCfgRsp
821 * This free the slice cfg rsp received from sch
823 * @param[in] SchSliceCfgRsp *sliceCfgrsp
827 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
833 if(schSliceCfgRsp->numSliceCfgRsp)
835 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
837 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
839 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
845 * @brief Mac process the slice cfg rsp received from sch.
849 * Function : MacProcSchSliceCfgRsp
851 * This function process the slice cfg rsp received from sch
853 * @param[in] Pst *pst
854 * @param[in] SchSliceCfgRsp *sliceCfgrsp
858 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
860 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
864 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
865 if(macSliceCfgRsp == NULLP)
867 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
870 if(schSliceCfgRsp->listOfSliceCfgRsp)
872 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
874 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
877 MacSendSliceConfigRsp(macSliceCfgRsp);
879 freeSchSliceCfgRsp(schSliceCfgRsp);
885 * @brief send slice cfg response to duapp.
889 * Function : MacSendSliceReconfigRsp
891 * sends slice cfg response to duapp
893 * @param[in] MacSliceCfgRsp macSliceRecfgRsp
897 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
901 memset(&rspPst, 0, sizeof(Pst));
902 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
903 return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
908 * @brief Mac process the slice cfg rsp received from sch.
912 * Function : MacProcSchSliceReCfgRsp
914 * This function process the slice cfg rsp received from sch
916 * @param[in] Pst *pst
917 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
921 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
923 MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
927 MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
928 if(macSliceReCfgRsp == NULLP)
930 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
934 if(schSliceRecfgRsp->listOfSliceCfgRsp)
936 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
938 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
941 MacSendSliceReconfigRsp(macSliceReCfgRsp);
943 freeSchSliceCfgRsp(schSliceRecfgRsp);
947 /**********************************************************************
949 **********************************************************************/