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)
99 printf("\nReceived Scheduler gen config at MAC");
100 memset(&schPst, 0, sizeof(Pst));
101 FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
102 SchProcGenCfgReq(&schPst, cfg);
108 * @brief Layer Manager Configuration response from Scheduler
112 * Function : SchSendCfgCfm
114 * This function sends general configurations response from
115 * Scheduler to DU APP.
117 * @param[in] Pst *pst, the post structure
118 * @param[in] RgMngmt *cfm, the configuration confirm structure
122 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
124 DU_LOG("\nDEBUG --> Sending Scheduler config confirm to DU APP");
125 pst->dstEnt = ENTDUAPP;
128 pst->selector = ODU_SELECTOR_LC;
129 RgMiLrgSchCfgCfm(pst, cfm);
135 * @brief Layer Manager Configuration request handler.
139 * Function : MacProcCellCfgReq
141 * This function handles the gNB and cell configuration
142 * request received from DU APP.
143 * This API unapcks and forwards the config towards SCH
145 * @param[in] Pst *pst
146 * @param[in] MacCellCfg *macCellCfg
150 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
154 uint8_t ret = ROK, sliceIdx = 0;
155 MacCellCb *macCellCb;
157 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
159 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
160 if(macCellCb == NULLP)
162 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
165 memset(macCellCb, 0, sizeof(MacCellCb));
167 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
168 macCb.macCell[cellIdx] = macCellCb;
169 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
170 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
172 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
173 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
174 if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
176 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
179 memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
180 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
182 macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
183 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
185 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
187 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
191 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
193 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
195 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
197 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
198 if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
200 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
203 memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
209 /* Send cell cfg to scheduler */
210 ret = MacSchCellCfgReq(pst, macCellCfg);
213 MacCellCfgCfm macCellCfgCfm;
214 macCellCfgCfm.rsp = RSP_NOK;
215 macCellCfgCfm.cellId = macCellCfg->cellId;
217 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
218 cfmPst.selector = ODU_SELECTOR_LC;
220 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
224 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
227 } /* end of MacProcCellCfgReq */
230 * @brief Layer Manager Configuration request handler.
234 * Function : MacSchCellCfgReq
236 * This function sends cell configuration to SCH
238 * @param[in] Pst *pst
239 * @param[in] MacCellCfg *macCellCfg
243 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
245 SchCellCfg schCellCfg;
247 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
249 memset(&cfgPst, 0, sizeof(Pst));
250 memset(&schCellCfg, 0, sizeof(SchCellCfg));
251 schCellCfg.cellId = macCellCfg->cellId;
252 schCellCfg.phyCellId = macCellCfg->phyCellId;
253 schCellCfg.numerology = macCellCfg->numerology;
254 schCellCfg.dupMode = macCellCfg->dupType;
255 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
256 schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
257 schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
259 /* fill ssb scheduler parameters */
260 schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
261 schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
262 schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
263 schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
264 schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
265 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
267 schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
269 schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
271 /* fill SIB1 scheduler parameters */
272 schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
273 schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
274 schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
275 schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
276 schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
277 schCellCfg.sib1SchCfg.pageCfg.numPO = macCellCfg->sib1Cfg.pagingCfg.numPO;
278 schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
280 if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
282 memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
285 /* fill RACH config params */
286 schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
287 schCellCfg.schRachCfg.prachSubcSpacing = \
288 macCellCfg->prachCfg.prachSubcSpacing;
289 schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
290 schCellCfg.schRachCfg.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
291 schCellCfg.schRachCfg.rootSeqLen = macCellCfg->prachCfg.rootSeqLen;
292 schCellCfg.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
293 schCellCfg.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
294 schCellCfg.schRachCfg.k1 = macCellCfg->prachCfg.fdm[0].k1;
295 schCellCfg.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
296 schCellCfg.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
297 schCellCfg.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
298 schCellCfg.schRachCfg.prachMultCarrBand = macCellCfg->prachCfg.prachMultCarrBand;
299 schCellCfg.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
300 schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
301 schCellCfg.schRachCfg.raRspWindow = macCellCfg->prachCfg.raRspWindow;
303 /* fill initial DL BWP */
304 schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
305 schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
306 schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
307 schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
308 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
309 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
310 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
311 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
312 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
313 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
314 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
315 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
316 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
317 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
318 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
319 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
320 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
321 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
322 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
323 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
324 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
325 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
326 schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
327 macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
328 schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
329 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
331 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
332 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
333 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
334 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
335 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
336 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
337 schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
338 macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
341 /* fill initial UL BWP */
342 schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
343 schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
344 schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
345 schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
346 schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
347 macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
348 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
350 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
351 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
352 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
353 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
354 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
355 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
356 schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
357 macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
360 if(macCellCfg->plmnInfoList.snssai)
362 schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
363 MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
364 if(!schCellCfg.plmnInfoList.snssai)
366 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
369 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
371 if(macCellCfg->plmnInfoList.snssai[sliceIdx])
373 MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
374 if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
376 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
379 memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
385 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
388 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
390 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
392 } /* end of MacSchCellCfgReq */
395 /*******************************************************************
397 * @brief Sends Cell config confirm to DU APP
401 * Function : MacSendCellCfgCfm
404 * Sends Cell config confirm to DU APP
406 * @params[in] Response status
409 * ****************************************************************/
410 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
414 MacCellCfgCfm macCellCfgCfm;
416 memset(&pst, 0, sizeof(Pst));
418 GET_CELL_IDX(cellId, cellIdx);
419 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
420 macCellCfgCfm.rsp = response;
423 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
424 pst.selector = ODU_SELECTOR_LC;
426 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
431 * @brief Layer Manager Configuration response handler.
435 * Function : MacProcSchCellCfgCfm
437 * This function processes cell configuration to SCH
439 * @param[in] Pst *pst
440 * @param[in] SchCellCfgCfm *schCellCfgCfm
444 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
446 uint16_t *cellId = NULLP;
448 #ifdef CALL_FLOW_DEBUG_LOG
449 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
452 if(schCellCfgCfm->rsp == RSP_OK)
454 cellId = &schCellCfgCfm->cellId;
455 #ifdef INTEL_TIMER_MODE
456 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
458 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
463 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
468 /*******************************************************************
470 * @brief MAC handler for config response from PHY
474 * Function : fapiMacConfigRsp
477 * Processes config response from PHY and sends cell config
483 * ****************************************************************/
484 void fapiMacConfigRsp(uint16_t cellId)
486 /* TODO : Processing of config response from PHY */
488 /* Send cell config cfm to DU APP */
489 MacSendCellCfgCfm(cellId, RSP_OK);
492 /*******************************************************************
494 * @brief Fill and Send Cell Delete response from MAC to DU APP
498 * Function : MacSendCellDeleteRsp
500 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
502 * @params[in] MAC Cell delete result
503 * SCH Cell delete response
504 * @return ROK - success
507 * ****************************************************************/
508 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
510 MacCellDeleteRsp *deleteRsp=NULLP;
513 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
516 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
520 /* Filling CELL delete response */
522 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
523 deleteRsp->cellId = cellId;
524 deleteRsp->result = result;
526 /* Fill Post structure and send CELL delete response*/
527 memset(&rspPst, 0, sizeof(Pst));
528 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
529 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
532 /*******************************************************************
534 * @brief Processes CELL delete response from scheduler
538 * Function : MacProcSchCellDeleteRsp
541 * Processes CELL delete from scheduler
543 * @params[in] Pst : Post structure
544 * schCellDelRsp : Scheduler CELL delete respons
545 * @return ROK - success
548 * * ****************************************************************/
549 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
551 uint8_t ret = ROK, sliceIdx = 0;
553 CellDeleteStatus status;
555 #ifdef CALL_FLOW_DEBUG_LOG
556 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
561 if(schCellDelRsp->rsp == RSP_OK)
563 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
564 schCellDelRsp->cellId);
565 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
566 if(macCb.macCell[cellIdx])
568 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
570 status = SUCCESSFUL_RSP;
571 if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
573 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
575 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
577 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
578 numSupportedSlice * sizeof(Snssai*));
580 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
581 macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
582 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
586 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
587 status = CELL_ID_INVALID;
593 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
594 status = CELL_ID_INVALID;
600 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
601 status = CELL_ID_INVALID;
604 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
606 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
613 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
619 /*******************************************************************
621 * @brief Sends Cell delete req to Scheduler
625 * Function : sendCellDelReqToSch
627 * Functionality: sends Cell delete req to Scheduler
629 * @params[in] SchCellDelete *schCellDel
630 * @return ROK - success
633 * ****************************************************************/
635 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
638 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
639 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
642 /*******************************************************************
644 * @brief Handles CELL Delete requst from DU APP
648 * Function : MacProcCellDeleteReq
650 * Functionality: Handles CELL Delete requst from DU APP
652 * @params[in] Pst *pst, MacCellDelete *cellDelete
653 * @return ROK - success
657 * ****************************************************************/
658 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
660 uint8_t ret = ROK, cellIdx=0;
661 SchCellDelete schCellDelete;
663 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
667 GET_CELL_IDX(cellDelete->cellId, cellIdx);
668 if(macCb.macCell[cellIdx])
670 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
672 memset(&schCellDelete, 0, sizeof(SchCellDelete));
673 schCellDelete.cellId = cellDelete->cellId;
674 ret = sendCellDelReqToSch(&schCellDelete);
677 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
683 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
690 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
697 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
698 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
700 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
705 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
709 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
716 * @brief free the temporary slice cfg stored in macCb.
720 * Function : freeMacSliceCfgReq
722 * free the temporary slice cfg stored in macCb
728 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
734 if(cfgReq->numOfConfiguredSlice)
736 for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
738 if(cfgReq->listOfSliceCfg[cfgIdx])
740 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
742 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
744 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
746 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
750 * @brief fill Mac Slice Config Rsp
754 * Function : fillMacSliceCfgRsp
756 * This function fill Mac Slice Config Rsp
758 * @param[in] SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
763 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
766 bool sliceFound = false;
769 macSliceCfgRsp->numSliceCfgRsp = schSliceCfgRsp->numSliceCfgRsp;
770 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp, macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
771 if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
773 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
777 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
780 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
785 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
786 if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
788 DU_LOG("\nERROR --> MAC : Memory allocation failedi in fillMacSliceCfgRsp");
792 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
793 if(sliceFound == true)
794 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_OK;
797 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = MAC_DU_APP_RSP_NOK;
798 macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_PRESENT;
805 * @brief send slice cfg response to duapp.
809 * Function : MacSendSliceConfigRsp
811 * sends slice cfg response to duapp
813 * @param[in] MacSliceCfgRsp macSliceCfgRsp
817 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
821 memset(&rspPst, 0, sizeof(Pst));
822 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
823 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
827 * @brief free the slice cfg rsp received from sch.
831 * Function : freeSchSliceCfgRsp
833 * This free the slice cfg rsp received from sch
835 * @param[in] SchSliceCfgRsp *sliceCfgrsp
839 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
845 if(schSliceCfgRsp->numSliceCfgRsp)
847 for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
849 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
851 MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
857 * @brief Mac process the slice cfg rsp received from sch.
861 * Function : MacProcSchSliceCfgRsp
863 * This function process the slice cfg rsp received from sch
865 * @param[in] Pst *pst
866 * @param[in] SchSliceCfgRsp *sliceCfgrsp
870 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
872 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
876 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
877 if(macSliceCfgRsp == NULLP)
879 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
882 if(schSliceCfgRsp->listOfSliceCfgRsp)
884 if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
886 DU_LOG("\nERROR --> MAC : Failed to fill the slice cfg response");
889 MacSendSliceConfigRsp(macSliceCfgRsp);
891 freeSchSliceCfgRsp(schSliceCfgRsp);
897 * @brief send slice cfg response to duapp.
901 * Function : MacSendSliceReconfigRsp
903 * sends slice cfg response to duapp
905 * @param[in] MacSliceCfgRsp macSliceRecfgRsp
909 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
913 memset(&rspPst, 0, sizeof(Pst));
914 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
915 return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
920 * @brief Mac process the slice cfg rsp received from sch.
924 * Function : MacProcSchSliceReCfgRsp
926 * This function process the slice cfg rsp received from sch
928 * @param[in] Pst *pst
929 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
933 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
935 MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
939 MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
940 if(macSliceReCfgRsp == NULLP)
942 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
946 if(schSliceRecfgRsp->listOfSliceCfgRsp)
948 if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
950 DU_LOG("\nERROR --> MAC : Failed to fill the slice Recfg response");
953 MacSendSliceReconfigRsp(macSliceReCfgRsp);
955 freeSchSliceCfgRsp(schSliceRecfgRsp);
959 /**********************************************************************
961 **********************************************************************/