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"
31 typedef struct schCellCb SchCellCb;
32 typedef struct schUeCb SchUeCb;
33 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE);
34 void schUlHqAddToFreeList(SchUlHqProcCb *hqP);
36 * @brief UL Harq entity intialization
40 * Function : schUlHqEntInit
42 * This function intialize UL Harq entity
44 * @param[in] SchCellCb *cellCb, cell cb pointer
45 * @param[in] SchUeCb *ueCb, ue cb pointer
49 void schUlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb)
51 ueCb->ulHqEnt.numHqPrcs = SCH_MAX_NUM_UL_HQ_PROC;
52 ueCb->ulHqEnt.maxHqTx = cellCb->cellCfg.schHqCfg.maxUlDataHqTx;
53 ueCb->ulHqEnt.cell = cellCb;
54 ueCb->ulHqEnt.ue =ueCb;
55 schUlHqEntReset(cellCb, ueCb, &ueCb->ulHqEnt);
58 * @brief UL Harq entity Reset
62 * Function : schUlHqEntReset
64 * This function Reset UL Harq entity
66 * @param[in] SchCellCb *cellCb, cell cb pointer
67 * @param[in] SchUeCb *ueCb, ue cb pointer
68 * @param[in] SchUlHqEnt *hqE, Ul Harq entity pointer
72 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE)
75 SchUlHqProcCb *hqP = NULL;
76 cmLListInit(&hqE->free);
77 cmLListInit(&hqE->inUse);
78 for(count=0; count < hqE->numHqPrcs; count++)
80 hqP = &(hqE->procs[count]);
83 hqP->maxHqTxPerHqP = hqE->maxHqTx;
84 hqP->ulHqEntLnk.node = (PTR)hqP;
85 hqP->ulHqProcLink.node = (PTR)hqP;
86 hqP->ulSlotLnk.node = (PTR)hqP;
87 schUlHqAddToFreeList(hqP);
91 * @brief Add hq process to free list of UL Harq entity
95 * Function : schUlHqAddToFreeList
97 * This function adds hq process to free list of UL Harq entity
99 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
103 void schUlHqAddToFreeList(SchUlHqProcCb *hqP)
105 cmLListAdd2Tail(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
108 * @brief Delete hq process from free list of UL Harq entity
112 * Function : schUlHqDeleteFromFreeList
114 * This function deletes hq process to free list of UL Harq entity
116 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
120 void schUlHqDeleteFromFreeList(SchUlHqProcCb *hqP)
122 if(hqP->hqEnt->free.count == 0)
124 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in free\n");
126 cmLListDelFrm(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
129 * @brief Add hq process to in use list of UL Harq entity
133 * Function : schUlHqAddToInUseList
135 * This function adds hq process to in use list of UL Harq entity
137 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
141 void schUlHqAddToInUseList(SchUlHqProcCb *hqP)
143 cmLListAdd2Tail(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
146 * @brief Delete hq process from in use list of UL Harq entity
150 * Function : schUlHqDeleteFromInUseList
152 * This function deletes hq process to in use list of UL Harq entity
154 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
158 void schUlHqDeleteFromInUseList(SchUlHqProcCb *hqP)
160 if(hqP->hqEnt->inUse.count == 0)
162 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in use\n");
164 cmLListDelFrm(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
167 * @brief Get available Harq process from Harq entity
171 * Function : schUlGetAvlHqProcess
173 * This function fetches hq process from free list and puts in in use list
175 * @param[in] SchCellCb *cellCb, cell cb pointer
176 * @param[in] SchUeCb *ueCb, ue cb pointer
177 * @param[in] SchUlHqProcCb **hqP, Address of UL harq process pointer
182 uint8_t schUlGetAvlHqProcess(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqProcCb **hqP)
185 if (ueCb->ulHqEnt.free.count == 0)
189 tmp = (SchUlHqProcCb*)(cmLListFirst(&(ueCb->ulHqEnt.free))->node);
194 schUlHqDeleteFromFreeList(tmp);
195 schUlHqAddToInUseList(tmp);
197 (*hqP)->maxHqTxPerHqP = ueCb->ulHqEnt.maxHqTx;
201 * @brief Release Harq process from the UL Harq entity
205 * Function : schUlReleaseHqProcess
207 * This function releases Harq process from UL Harq entity
209 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
210 * @param[in] Bool togNdi, indication to togle NDI bit
214 void schUlReleaseHqProcess(SchUlHqProcCb *hqP, Bool togNdi)
218 hqP->tbInfo.ndi ^= 1;
220 cmLListDeleteLList(&hqP->ulLcPrbEst.dedLcList);
221 cmLListDeleteLList(&hqP->ulLcPrbEst.defLcList);
222 schUlHqDeleteFromInUseList(hqP);
223 schUlHqAddToFreeList(hqP);
226 * @brief Handles NACK for UL Harq process
230 * Function : schUlHqProcessNack
232 * This function handle NACK for UL Harq process
234 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
238 void schUlHqProcessNack(SchUlHqProcCb *hqP)
240 if (hqP->tbInfo.txCntr < hqP->maxHqTxPerHqP)
242 cmLListAdd2Tail(&(hqP->hqEnt->ue->ulRetxHqList), &hqP->ulHqProcLink);
244 if(hqP->hqEnt->ue->ueDrxInfoPres == true)
246 schDrxStrtUlHqRttTmr(hqP);
251 addUeToBeScheduled(hqP->hqEnt->cell, hqP->hqEnt->ue->ueId);
256 schUlReleaseHqProcess(hqP, TRUE);
260 * @brief Handles ACK for UL Harq process
264 * Function : schUlHqProcessAck
266 * This function handles ACK for UL Harq process
268 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
272 void schUlHqProcessAck(SchUlHqProcCb *hqP)
274 schUlReleaseHqProcess(hqP, TRUE);
276 /**********************************************************************
278 **********************************************************************/