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 #include "common_def.h"
24 #include "du_app_mac_inf.h"
25 #include "mac_sch_interface.h"
27 #include "sch_utils.h"
29 * @brief Handles retransmission for MSG3
33 * Function : schMsg3RetxSchedulingForUe
35 * This function handles retransmission for MSG3
37 * @param[in] SchRaCb *raCb, RA cb pointer
42 uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb)
46 uint8_t totalCfgSlot = 0;
49 SlotTimingInfo dciTime, msg3Time;
50 SchCellCb *cell = NULLP;
51 SlotTimingInfo currTime;
52 DciInfo *dciInfo = NULLP;
54 currTime = cell->slotInfo;
56 /* Calculating time frame to send DCI for MSG3 Retx*/
57 ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA);
59 /* Consider this slot for sending DCI, only if it is a DL slot */
60 if(schGetSlotSymbFrmt(dciSlot, raCb->cell->slotFrmtBitMap) == DL_SLOT)
63 /* If PDCCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */
64 if(cell->schDlSlotInfo[dciSlot]->pdcchUe != 0)
67 k2Found = schGetMsg3K2(cell, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE);
73 SCH_ALLOC(dciInfo, sizeof(DciInfo));
76 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc");
79 cell->schDlSlotInfo[msg3Time.slot]->ulGrant = dciInfo;
80 SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, sizeof(SchPuschInfo));
81 memset(dciInfo,0,sizeof(DciInfo));
82 schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, dciInfo);
84 raCb->retxMsg3HqProc = NULLP;
88 * @brief Get K2 value for MSG3
92 * Function : schGetMsg3K2
94 * This function gets K2 for MSG3
96 * @param[in] SchCellCb *cell, Cell cb struc pointer
97 * @param[in] SchUlHqProcCb* msg3HqProc, msg3 harq proc pointer
98 * @param[in] uint16_t dlTime, DL time of scheduling
99 * @param[in] SlotTimingInfo *msg3Time, MSG3 timing info
100 * @param[in] bool isRetx, indicates MSG3 retransmission
105 bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx)
107 bool k2Found = false;
108 uint8_t k2TblIdx = 0;
113 uint8_t msg3Delta = 0, msg3MinSchTime = 0;
115 uint8_t totalCfgSlot = 0;
117 SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP;
118 SlotTimingInfo currTime, msg3TempTime;
119 currTime = cell->slotInfo;
120 puschMu = cell->cellCfg.numerology;
127 numK2 = cell->cellCfg.schInitialUlBwp.k2InfoTbl.k2TimingInfo[dlTime].numK2;
128 msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl;
134 numK2 = cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl.k2TimingInfo[dlTime].numK2;
135 msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl;
136 msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology];
137 msg3Delta = puschDeltaTable[puschMu];
140 for(k2TblIdx = 0; k2TblIdx < numK2; k2TblIdx++)
142 k2Index = msg3K2InfoTbl->k2TimingInfo[dlTime].k2Indexes[k2TblIdx];
144 k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
147 if ((msg3HqProc->strtSymbl != cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol) ||
148 (msg3HqProc->numSymbl != cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength))
153 /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */
155 if(k2 >= msg3MinSchTime)
157 ADD_DELTA_TO_TIME(currTime, msg3TempTime, k2);
159 if(schGetSlotSymbFrmt(msg3TempTime.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT)
162 /* If PUSCH is already scheduled on this slot, another PUSCH
163 * pdu cannot be scheduled here */
164 if(cell->schUlSlotInfo[msg3TempTime.slot]->puschUe != 0)
172 msg3Time->slot = msg3TempTime.slot;
173 msg3Time->sfn = msg3TempTime.sfn;
174 msg3Time->slot = msg3TempTime.slot;
178 /**********************************************************************
180 **********************************************************************/