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 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
47 packDuMacCellDeleteRsp, /* packing for loosely coupled */
48 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
49 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
52 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
54 packDuMacSliceCfgRsp, /* packing for loosely coupled */
55 DuProcMacSliceCfgRsp, /* packing for tightly coupled */
56 packDuMacSliceCfgRsp /* packing for light weight loosly coupled */
59 MacDuSliceRecfgRspFunc macDuSliceRecfgRspOpts[] =
61 packDuMacSliceRecfgRsp, /* packing for loosely coupled */
62 DuProcMacSliceRecfgRsp, /* packing for tightly coupled */
63 packDuMacSliceRecfgRsp /* packing for light weight loosly coupled */
67 * @brief Layer Manager Configuration request handler for Scheduler
71 * Function : MacSchGenCfgReq
73 * This function receives general configurations for Scheduler
74 * from DU APP and forwards to Scheduler.
76 * @param[in] Pst *pst, the post structure
77 * @param[in] RgMngmt *cfg, the configuration parameter's structure
81 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
85 DU_LOG("\nINFO --> MAC : Received Scheduler gen config at MAC");
86 memset(&schPst, 0, sizeof(Pst));
87 FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
89 return(SchMessageRouter(&schPst, (void *)cfg));
93 * @brief Layer Manager Configuration response from Scheduler
97 * Function : SchSendCfgCfm
99 * This function sends general configurations response from
100 * Scheduler to DU APP.
102 * @param[in] Pst *pst, the post structure
103 * @param[in] RgMngmt *cfm, the configuration confirm structure
107 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm)
109 DU_LOG("\nDEBUG --> MAC : Sending Scheduler config confirm to DU APP");
110 pst->dstEnt = ENTDUAPP;
113 pst->selector = ODU_SELECTOR_LC;
114 RgMiLrgSchCfgCfm(pst, cfm);
120 * @brief Layer Manager Configuration request handler.
124 * Function : MacProcCellCfgReq
126 * This function handles the gNB and cell configuration
127 * request received from DU APP.
128 * This API unapcks and forwards the config towards SCH
130 * @param[in] Pst *pst
131 * @param[in] MacCellCfg *macCellCfg
135 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
138 uint16_t cellIdx, scsInKhz = 0;
139 uint8_t ret = ROK, plmnIdx = 0,sliceIdx = 0;
140 MacCellCb *macCellCb;
142 memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
144 MAC_ALLOC(macCellCb, sizeof(MacCellCb));
145 if(macCellCb == NULLP)
147 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of macCellCfg\n");
150 memset(macCellCb, 0, sizeof(MacCellCb));
152 GET_CELL_IDX(macCellCfg->cellId, cellIdx);
153 macCb.macCell[cellIdx] = macCellCb;
154 macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
155 scsInKhz = convertScsEnumValToScsVal(macCellCfg->cellCfg.subCarrSpacing);
157 /*Ref : 3GPP 38.211 Table 4.2-1: SCS = (2 ^ numerology * 15kHz)*/
158 macCb.macCell[cellIdx]->numerology = log2(scsInKhz/BASE_SCS);
159 macCb.macCell[cellIdx]->numOfSlots = 10 * (1 << (macCb.macCell[cellIdx]->numerology));
160 memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
162 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \
163 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
164 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu == NULLP)
166 DU_LOG("\nERROR --> MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
169 memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, macCellCfg->cellCfg.sib1Cfg.sib1Pdu, \
170 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
172 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
174 macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice;
175 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice\
177 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP)
179 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
183 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai)
185 for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++)
187 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
189 MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
190 if(!macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
192 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacProcCellCfgReq");
195 memcpy(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx],\
201 /* Send cell cfg to scheduler */
202 ret = MacSchCellCfgReq(pst, macCellCfg);
205 MacCellCfgCfm macCellCfgCfm;
206 macCellCfgCfm.rsp = RSP_NOK;
207 macCellCfgCfm.cellId = macCellCfg->cellId;
209 FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
210 cfmPst.selector = ODU_SELECTOR_LC;
212 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
216 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
219 } /* end of MacProcCellCfgReq */
222 * @brief Layer Manager Configuration request handler.
226 * Function : MacSchCellCfgReq
228 * This function sends cell configuration to SCH
230 * @param[in] Pst *pst
231 * @param[in] MacCellCfg *macCellCfg
235 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
237 SchCellCfg schCellCfg;
239 uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, sliceIdx=0, plmnIdx = 0;
241 memset(&cfgPst, 0, sizeof(Pst));
242 memset(&schCellCfg, 0, sizeof(SchCellCfg));
243 schCellCfg.cellId = macCellCfg->cellId;
244 schCellCfg.phyCellId = macCellCfg->cellCfg.phyCellId;
246 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
248 schCellCfg.plmnInfoList[plmnIdx].plmn = macCellCfg->cellCfg.plmnInfoList[plmnIdx].plmn;
249 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai)
251 schCellCfg.plmnInfoList[plmnIdx].numSliceSupport = macCellCfg->cellCfg.plmnInfoList[plmnIdx].numSupportedSlice;
252 MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai, schCellCfg.plmnInfoList[plmnIdx].numSliceSupport * sizeof(Snssai*));
253 if(!schCellCfg.plmnInfoList[plmnIdx].snssai)
255 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
258 for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList[plmnIdx].numSliceSupport; sliceIdx++)
260 if(macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
262 MAC_ALLOC(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
263 if(!schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx])
265 DU_LOG("\nERROR --> MAC: Memory allocation failed at MacSchCellCfgReq");
268 memcpy(schCellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], macCellCfg->cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
274 schCellCfg.dupMode = macCellCfg->cellCfg.dupType;
275 schCellCfg.dlBandwidth = macCellCfg->carrCfg.dlBw;
276 schCellCfg.ulBandwidth = macCellCfg->carrCfg.ulBw;
278 schCellCfg.dlCfgCommon.schFreqInfoDlSib.offsetToPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
279 schCellCfg.dlCfgCommon.schFreqInfoDlSib.schSpcCarrier[0].subCarrierSpacing = macCellCfg->ssbCfg.scsCmn;
281 /* fill initial DL BWP */
282 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->cellCfg.initialDlBwp.bwp.firstPrb;
283 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->cellCfg.initialDlBwp.bwp.numPrb;
284 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.scs = macCellCfg->cellCfg.initialDlBwp.bwp.scs;
285 schCellCfg.dlCfgCommon.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->cellCfg.initialDlBwp.bwp.cyclicPrefix;
287 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
288 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
289 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
290 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
291 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
292 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
293 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
294 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration;
295 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
296 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
297 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
298 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
299 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
300 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
301 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
302 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
303 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
304 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
305 schCellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
306 macCellCfg->cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
308 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->cellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc;
309 for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->cellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
311 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
312 macCellCfg->cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
313 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
314 macCellCfg->cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
315 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
316 macCellCfg->cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
317 schCellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
318 macCellCfg->cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
321 /* fill SIB1 scheduler parameters */
322 schCellCfg.dlCfgCommon.schPcchCfg.numPO = macCellCfg->cellCfg.sib1Cfg.pagingCfg.numPO;
323 schCellCfg.dlCfgCommon.schPcchCfg.poPresent = macCellCfg->cellCfg.sib1Cfg.pagingCfg.poPresent;
324 if(schCellCfg.dlCfgCommon.schPcchCfg.poPresent)
326 memcpy(schCellCfg.dlCfgCommon.schPcchCfg.pagingOcc, macCellCfg->cellCfg.sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
329 /* fill initial UL BWP */
330 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->cellCfg.initialUlBwp.bwp.firstPrb;
331 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->cellCfg.initialUlBwp.bwp.numPrb;
332 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.scs = macCellCfg->cellCfg.initialUlBwp.bwp.scs;
333 schCellCfg.ulCfgCommon.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->cellCfg.initialUlBwp.bwp.cyclicPrefix;
334 /* fill RACH config params */
335 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
336 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1Fdm = macCellCfg->prachCfg.msg1Fdm;
337 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
338 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.zeroCorrZoneCfg = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
339 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.prachCfgGeneric.raRspWindow = macCellCfg->prachCfg.raRspWindow;
341 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
342 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.ssbPerRach = macCellCfg->prachCfg.ssbPerRach;
343 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
344 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.raContResTmr = macCellCfg->prachCfg.raContResTmr;
345 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
346 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.rootSeqIdx = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
347 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.numRootSeq = macCellCfg->prachCfg.fdm[0].numRootSeq;
348 schCellCfg.ulCfgCommon.schInitialUlBwp.schRachCfg.msg1SubcSpacing = \
349 macCellCfg->prachCfg.prachSubcSpacing;
351 schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchResourceCommon = \
352 macCellCfg->cellCfg.initialUlBwp.pucchCommon.pucchResourceCommon;
353 schCellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon.pucchGroupHopping = \
354 macCellCfg->cellCfg.initialUlBwp.pucchCommon.pucchGroupHopping;
355 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
356 macCellCfg->cellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
357 for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->cellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
359 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
360 macCellCfg->cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
361 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
362 macCellCfg->cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
363 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
364 macCellCfg->cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
365 schCellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
366 macCellCfg->cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
370 memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
373 /* fill ssb scheduler parameters */
374 for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
376 schCellCfg.ssbPosInBurst[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
378 schCellCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
379 schCellCfg.ssbFrequency = macCellCfg->cellCfg.ssbFreq;
380 schCellCfg.dmrsTypeAPos = macCellCfg->ssbCfg.dmrsTypeAPos;
381 schCellCfg.ssbScs = macCellCfg->cellCfg.subCarrSpacing;
382 schCellCfg.pdcchCfgSib1.coresetZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex;
383 schCellCfg.pdcchCfgSib1.searchSpaceZeroIndex = macCellCfg->cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex;
384 schCellCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
385 schCellCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
386 schCellCfg.sib1PduLen = macCellCfg->cellCfg.sib1Cfg.sib1PduLen;
388 FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
390 return(SchMessageRouter(&cfgPst, (void *)&schCellCfg));
391 } /* end of MacSchCellCfgReq */
394 /*******************************************************************
396 * @brief Sends Cell config confirm to DU APP
400 * Function : MacSendCellCfgCfm
403 * Sends Cell config confirm to DU APP
405 * @params[in] Response status
408 * ****************************************************************/
409 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
413 MacCellCfgCfm macCellCfgCfm;
415 memset(&pst, 0, sizeof(Pst));
417 GET_CELL_IDX(cellId, cellIdx);
418 macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
419 macCellCfgCfm.rsp = response;
422 FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
423 pst.selector = ODU_SELECTOR_LC;
425 (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
430 * @brief Layer Manager Configuration response handler.
434 * Function : MacProcSchCellCfgCfm
436 * This function processes cell configuration to SCH
438 * @param[in] Pst *pst
439 * @param[in] SchCellCfgCfm *schCellCfgCfm
443 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
445 uint16_t *cellId = NULLP;
447 #ifdef CALL_FLOW_DEBUG_LOG
448 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
451 if(schCellCfgCfm->rsp == RSP_OK)
453 cellId = &schCellCfgCfm->cellId;
454 #ifdef INTEL_TIMER_MODE
455 sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
457 sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
462 MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
467 /*******************************************************************
469 * @brief MAC handler for config response from PHY
473 * Function : fapiMacConfigRsp
476 * Processes config response from PHY and sends cell config
482 * ****************************************************************/
483 void fapiMacConfigRsp(uint16_t cellId)
485 /* TODO : Processing of config response from PHY */
487 /* Send cell config cfm to DU APP */
488 MacSendCellCfgCfm(cellId, RSP_OK);
491 /*******************************************************************
493 * @brief Fill and Send Cell Delete response from MAC to DU APP
497 * Function : MacSendCellDeleteRsp
499 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
501 * @params[in] MAC Cell delete result
502 * SCH Cell delete response
503 * @return ROK - success
506 * ****************************************************************/
507 uint8_t MacSendCellDeleteRsp(CauseOfResult status, uint8_t cellId)
509 MacCellDeleteRsp *deleteRsp=NULLP;
512 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
515 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
519 /* Filling CELL delete response */
521 memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
522 deleteRsp->cellId = cellId;
523 deleteRsp->status = status;
525 /* Fill Post structure and send CELL delete response*/
526 memset(&rspPst, 0, sizeof(Pst));
527 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
528 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
531 /*******************************************************************
533 * @brief Processes CELL delete response from scheduler
537 * Function : MacProcSchCellDeleteRsp
540 * Processes CELL delete from scheduler
542 * @params[in] Pst : Post structure
543 * schCellDelRsp : Scheduler CELL delete respons
544 * @return ROK - success
547 * * ****************************************************************/
548 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
550 uint8_t ret = ROK, sliceIdx = 0, plmnIdx = 0;
554 #ifdef CALL_FLOW_DEBUG_LOG
555 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
560 if(schCellDelRsp->rsp == RSP_OK)
562 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
563 schCellDelRsp->cellId);
564 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
565 if(macCb.macCell[cellIdx])
567 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
570 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
572 if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai)
574 for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice; sliceIdx++)
576 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
578 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].\
579 numSupportedSlice * sizeof(Snssai*));
582 MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1Pdu, \
583 macCb.macCell[cellIdx]->macCellCfg.cellCfg.sib1Cfg.sib1PduLen);
584 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
588 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
589 cause = CELLID_INVALID;
595 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
596 cause = CELLID_INVALID;
602 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
603 cause = CELLID_INVALID;
606 if(MacSendCellDeleteRsp(cause, schCellDelRsp->cellId) != ROK)
608 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
615 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
621 /*******************************************************************
623 * @brief Sends Cell delete req to Scheduler
627 * Function : sendCellDelReqToSch
629 * Functionality: sends Cell delete req to Scheduler
631 * @params[in] SchCellDelete *schCellDel
632 * @return ROK - success
635 * ****************************************************************/
637 uint8_t sendCellDelReqToSch(SchCellDeleteReq *schCellDelReq)
640 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
641 return(SchMessageRouter(&schPst, (void *)schCellDelReq));
644 /*******************************************************************
646 * @brief Handles CELL Delete requst from DU APP
650 * Function : MacProcCellDeleteReq
652 * Functionality: Handles CELL Delete requst from DU APP
654 * @params[in] Pst *pst, MacCellDelete *cellDelete
655 * @return ROK - success
659 * ****************************************************************/
660 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDeleteReq *cellDelete)
662 uint8_t ret = ROK, cellIdx=0;
663 SchCellDeleteReq schCellDelete;
665 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
669 GET_CELL_IDX(cellDelete->cellId, cellIdx);
670 if(macCb.macCell[cellIdx])
672 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
674 memset(&schCellDelete, 0, sizeof(SchCellDeleteReq ));
675 schCellDelete.cellId = cellDelete->cellId;
676 ret = sendCellDelReqToSch(&schCellDelete);
679 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
685 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
692 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
699 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
700 if(MacSendCellDeleteRsp(CELLID_INVALID, cellDelete->cellId) != ROK)
702 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
707 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDeleteReq));
711 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
718 * @brief free the temporary slice cfg stored in macCb.
722 * Function : freeMacSliceCfgReq
724 * free the temporary slice cfg stored in macCb
730 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
732 uint8_t policyIdx = 0, memberListIdx=0;
734 if(cfgReq->numOfRrmPolicy)
736 if(cfgReq->listOfRrmPolicy)
738 for(policyIdx = 0; policyIdx<cfgReq->numOfRrmPolicy; policyIdx++)
740 if(cfgReq->listOfRrmPolicy[policyIdx])
742 if(cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
744 if(cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
746 for(memberListIdx = 0; memberListIdx<cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
748 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
750 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
751 cfgReq->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
754 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
757 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfRrmPolicy, cfgReq->numOfRrmPolicy * sizeof(MacSliceRrmPolicy*));
764 * @brief send slice cfg response to duapp.
768 * Function : MacSendSliceConfigRsp
770 * sends slice cfg response to duapp
772 * @param[in] MacSliceCfgRsp macSliceCfgRsp
776 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
780 memset(&rspPst, 0, sizeof(Pst));
781 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
782 return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
787 * @brief Mac process the slice cfg rsp received from sch.
791 * Function : MacProcSchSliceCfgRsp
793 * This function process the slice cfg rsp received from sch
795 * @param[in] Pst *pst
796 * @param[in] SchSliceCfgRsp *sliceCfgrsp
801 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
803 MacSliceCfgRsp *macSliceCfgRsp = NULLP;
807 MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
808 if(macSliceCfgRsp == NULLP)
810 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
813 macSliceCfgRsp->snssai = schSliceCfgRsp->snssai;
814 if(schSliceCfgRsp->rsp == RSP_OK)
815 macSliceCfgRsp->rsp = MAC_DU_APP_RSP_OK;
818 macSliceCfgRsp->rsp = MAC_DU_APP_RSP_NOK;
820 macSliceCfgRsp->cause = schSliceCfgRsp->cause;
821 MacSendSliceConfigRsp(macSliceCfgRsp);
827 * @brief send slice cfg response to duapp.
831 * Function : MacSendSliceReconfigRsp
833 * sends slice cfg response to duapp
835 * @param[in] MacSliceRecfgRsp macSliceRecfgRsp
839 uint8_t MacSendSliceReconfigRsp(MacSliceRecfgRsp *macSliceRecfgRsp)
843 memset(&rspPst, 0, sizeof(Pst));
844 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
845 return (*macDuSliceRecfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
850 * @brief Mac process the slice cfg rsp received from sch.
854 * Function : MacProcSchSliceRecfgRsp
856 * This function process the slice cfg rsp received from sch
858 * @param[in] Pst *pst
859 * @param[in] SchSliceCfgRsp *schSliceRecfgRsp
863 uint8_t MacProcSchSliceRecfgRsp(Pst *pst, SchSliceRecfgRsp *schSliceRecfgRsp)
865 MacSliceRecfgRsp *macSliceRecfgRsp = NULLP;
869 MAC_ALLOC_SHRABL_BUF(macSliceRecfgRsp, sizeof(MacSliceRecfgRsp));
870 if(macSliceRecfgRsp == NULLP)
872 DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchSliceRecfgRsp");
876 macSliceRecfgRsp->snssai = schSliceRecfgRsp->snssai;
877 if(schSliceRecfgRsp->rsp == RSP_OK)
878 macSliceRecfgRsp->rsp = MAC_DU_APP_RSP_OK;
881 macSliceRecfgRsp->rsp = MAC_DU_APP_RSP_NOK;
883 macSliceRecfgRsp->cause = schSliceRecfgRsp->cause;
884 MacSendSliceReconfigRsp(macSliceRecfgRsp);
890 * @brief Mac process the downlink pcch indication received from DUAPP
894 * Function : MacProcDlPcchInd
896 * This function process the downlink pcch indication received from DUAPP
898 * @param[in] Pst *pst
899 * @param[in] DlPcchInd *pcchInd
903 uint8_t MacProcDlPcchInd(Pst *pst, DlPcchInd *pcchInd)
905 uint8_t ret = RFAILED;
906 uint16_t cellIdx = 0;
908 SchPageInd *schPageInd = NULLP;
912 DU_LOG("\nINFO --> MAC : Received DL PCCH IND from DU_APP for cellId[%d]", pcchInd->cellId);
914 GET_CELL_IDX(pcchInd->cellId, cellIdx);
916 if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != pcchInd->cellId)
918 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): CellId[%d] does not exist", pcchInd->cellId);
922 if((pcchInd->pcchPdu == NULLP) || (pcchInd->pduLen <= 0))
924 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Pcch pdu is null");
928 MAC_ALLOC(schPageInd, sizeof(SchPageInd));
929 if(schPageInd == NULLP)
931 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
935 schPageInd->cellId = pcchInd->cellId;
936 schPageInd->pf = pcchInd->pf;
937 schPageInd->i_s = pcchInd->i_s;
938 schPageInd->pduLen = pcchInd->pduLen;
940 MAC_ALLOC(schPageInd->pagePdu, pcchInd->pduLen);
941 if(schPageInd->pagePdu == NULLP)
943 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Failed to allocate memory");
944 MAC_FREE(schPageInd, sizeof(SchPageInd));
948 memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
950 FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
951 ret = SchMessageRouter(&schPst, (void *)schPageInd);
956 if((pcchInd->pcchPdu) && (pcchInd->pduLen > 0))
958 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
960 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(DlPcchInd));
964 DU_LOG("\nERROR --> MAC : MacProcDlPcchInd(): Received Null pointer");
970 * @brief Mac process the downlink Broadcast Req received from DUAPP
974 * Function : MacProcDlBroadcastReq
976 * This function process the downlink Broadcast Req received from DUAPP
978 * @param[in] Pst *pst
979 * @param[in] DlBroadcastReq *dlBroadcastReq
983 uint8_t MacProcDlBroadcastReq(Pst *pst, MacDlBroadcastReq *dlBroadcastReq)
985 uint8_t ret = ROK, idx=0;
986 uint16_t cellIdx = 0;
990 DU_LOG("\nINFO --> MAC : Received DL braodcast req from DU_APP for cellId[%d]", dlBroadcastReq->cellId);
992 GET_CELL_IDX(dlBroadcastReq->cellId, cellIdx);
994 if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != dlBroadcastReq->cellId)
997 DU_LOG("\nERROR --> MAC : MacProcDlBroadcastReq(): CellId[%d] does not exist", dlBroadcastReq->cellId);
1001 /*TODO - Complete the processing of DL Broadcast Request*/
1003 for(idx = 0; idx<dlBroadcastReq->numSiBlock; idx++)
1005 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlBroadcastReq->siSchedulingInfo[idx]->siAreaID, sizeof(uint8_t));
1006 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlBroadcastReq->siSchedulingInfo[idx], sizeof(SiSchedulingInfo));
1008 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlBroadcastReq, sizeof(MacDlBroadcastReq));
1013 DU_LOG("\nERROR --> MAC : MacProcDlBroadcastReq(): Received Null pointer");
1019 * @brief Mac process the statistics Req received from DUAPP
1023 * Function : MacProcStatsReq
1025 * This function process the statistics request from duapp
1027 * @param[in] Pst *pst
1028 * @param[in] StatsReq *statsReq
1032 uint8_t MacProcStatsReq(Pst *pst, MacStatsReq *macStatsReq)
1034 uint8_t macStatsIdx = 0, schStatsIdx = 0;
1035 uint8_t ret = RFAILED;
1036 bool measTypeInvalid = false;
1038 SchStatsReq *schStatsReq = NULLP;
1039 CauseOfResult cause;
1043 DU_LOG("\nINFO --> MAC : Received Statistics Request from DU_APP");
1045 MAC_ALLOC(schStatsReq, sizeof(SchStatsReq));
1046 if(schStatsReq == NULLP)
1048 DU_LOG("\nERROR --> MAC : MacProcStatsReq: Failed to allocate memory");
1049 cause = RESOURCE_UNAVAILABLE;
1053 schStatsReq->numStats = 0;
1054 for(macStatsIdx=0; macStatsIdx < macStatsReq->numStats; macStatsIdx++)
1056 /* Checking each measurement type to send only SCH related
1057 * measurement config to SCH
1058 * This will be useful in future when some measurement type will
1059 * be configured for SCH and rest for only MAC */
1060 switch(macStatsReq->statsList[macStatsIdx].type)
1062 case MAC_DL_TOTAL_PRB_USAGE:
1064 schStatsReq->statsList[schStatsIdx].type = SCH_DL_TOTAL_PRB_USAGE;
1067 case MAC_UL_TOTAL_PRB_USAGE:
1069 schStatsReq->statsList[schStatsIdx].type = SCH_UL_TOTAL_PRB_USAGE;
1074 DU_LOG("\nERROR --> MAC : MacProcStatsReq: Invalid measurement type [%d]", \
1075 macStatsReq->statsList[macStatsIdx].type);
1076 measTypeInvalid = true;
1080 if(!measTypeInvalid)
1082 schStatsReq->statsList[schStatsIdx].periodicity = macStatsReq->statsList[macStatsIdx].periodicity;
1084 measTypeInvalid = false;
1087 schStatsReq->numStats = schStatsIdx;
1089 /* If no measurement types are valid, it is failure scenario.
1090 * Even if one measurement type is valid, send to SCH */
1091 if(schStatsReq->numStats)
1093 FILL_PST_MAC_TO_SCH(schPst, EVENT_STATISTICS_REQ_TO_SCH);
1094 ret = SchMessageRouter(&schPst, (void *)schStatsReq);
1098 cause = PARAM_INVALID;
1101 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macStatsReq, sizeof(MacStatsReq));
1105 DU_LOG("\nERROR --> MAC : MacProcStatsReq(): Received Null pointer");
1106 cause = PARAM_INVALID;
1111 /* Send negative acknowledgment to DU APP. TBD in next gerrit */
1116 /**********************************************************************
1118 **********************************************************************/