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"
28 typedef struct schCellCb SchCellCb;
29 typedef struct schUeCb SchUeCb;
30 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE);
31 void schUlHqAddToFreeList(SchUlHqProcCb *hqP);
33 * @brief UL Harq entity intialization
37 * Function : schUlHqEntInit
39 * This function intialize UL Harq entity
41 * @param[in] SchCellCb *cellCb, cell cb pointer
42 * @param[in] SchUeCb *ueCb, ue cb pointer
46 void schUlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb)
48 ueCb->ulHqEnt.numHqPrcs = SCH_MAX_NUM_UL_HQ_PROC;
49 ueCb->ulHqEnt.maxHqTx = cellCb->cellCfg.schHqCfg.maxUlDataHqTx;
50 ueCb->ulHqEnt.cell = cellCb;
51 ueCb->ulHqEnt.ue =ueCb;
52 schUlHqEntReset(cellCb, ueCb, &ueCb->ulHqEnt);
55 * @brief UL Harq entity Reset
59 * Function : schUlHqEntReset
61 * This function Reset UL Harq entity
63 * @param[in] SchCellCb *cellCb, cell cb pointer
64 * @param[in] SchUeCb *ueCb, ue cb pointer
65 * @param[in] SchUlHqEnt *hqE, Ul Harq entity pointer
69 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE)
72 SchUlHqProcCb *hqP = NULL;
73 cmLListInit(&hqE->free);
74 cmLListInit(&hqE->inUse);
75 for(count=0; count < hqE->numHqPrcs; count++)
77 hqP = &(hqE->procs[count]);
80 hqP->maxHqTxPerHqP = hqE->maxHqTx;
81 hqP->ulHqEntLnk.node = (PTR)hqP;
82 hqP->ulHqProcLink.node = (PTR)hqP;
83 hqP->ulSlotLnk.node = (PTR)hqP;
84 schUlHqAddToFreeList(hqP);
88 * @brief Add hq process to free list of UL Harq entity
92 * Function : schUlHqAddToFreeList
94 * This function adds hq process to free list of UL Harq entity
96 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
100 void schUlHqAddToFreeList(SchUlHqProcCb *hqP)
102 cmLListAdd2Tail(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
105 * @brief Delete hq process from free list of UL Harq entity
109 * Function : schUlHqDeleteFromFreeList
111 * This function deletes hq process to free list of UL Harq entity
113 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
117 void schUlHqDeleteFromFreeList(SchUlHqProcCb *hqP)
119 if(hqP->hqEnt->free.count == 0)
121 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in free\n");
123 cmLListDelFrm(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
126 * @brief Add hq process to in use list of UL Harq entity
130 * Function : schUlHqAddToInUseList
132 * This function adds hq process to in use list of UL Harq entity
134 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
138 void schUlHqAddToInUseList(SchUlHqProcCb *hqP)
140 cmLListAdd2Tail(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
143 * @brief Delete hq process from in use list of UL Harq entity
147 * Function : schUlHqDeleteFromInUseList
149 * This function deletes hq process to in use list of UL Harq entity
151 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
155 void schUlHqDeleteFromInUseList(SchUlHqProcCb *hqP)
157 if(hqP->hqEnt->inUse.count == 0)
159 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in use\n");
161 cmLListDelFrm(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
164 * @brief Get available Harq process from Harq entity
168 * Function : schUlGetAvlHqProcess
170 * This function fetches hq process from free list and puts in in use list
172 * @param[in] SchCellCb *cellCb, cell cb pointer
173 * @param[in] SchUeCb *ueCb, ue cb pointer
174 * @param[in] SchUlHqProcCb **hqP, Address of UL harq process pointer
179 uint8_t schUlGetAvlHqProcess(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqProcCb **hqP)
182 if (ueCb->ulHqEnt.free.count == 0)
186 tmp = (SchUlHqProcCb*)(cmLListFirst(&(ueCb->ulHqEnt.free))->node);
191 schUlHqDeleteFromFreeList(tmp);
192 schUlHqAddToInUseList(tmp);
194 (*hqP)->maxHqTxPerHqP = ueCb->ulHqEnt.maxHqTx;
198 * @brief Release Harq process from the UL Harq entity
202 * Function : schUlReleaseHqProcess
204 * This function releases Harq process from UL Harq entity
206 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
207 * @param[in] Bool togNdi, indication to togle NDI bit
211 void schUlReleaseHqProcess(SchUlHqProcCb *hqP, Bool togNdi)
215 hqP->tbInfo.ndi ^= 1;
217 cmLListDeleteLList(&hqP->ulLcPrbEst.dedLcList);
218 cmLListDeleteLList(&hqP->ulLcPrbEst.defLcList);
219 schUlHqDeleteFromInUseList(hqP);
220 schUlHqAddToFreeList(hqP);
223 * @brief Handles NACK for UL Harq process
227 * Function : schUlHqProcessNack
229 * This function handle NACK for UL Harq process
231 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
235 void schUlHqProcessNack(SchUlHqProcCb *hqP)
237 if (hqP->tbInfo.txCntr < hqP->maxHqTxPerHqP)
239 cmLListAdd2Tail(&(hqP->hqEnt->ue->ulRetxHqList), &hqP->ulHqProcLink);
240 addUeToBeScheduled(hqP->hqEnt->cell, hqP->hqEnt->ue->ueId);
244 schUlReleaseHqProcess(hqP, TRUE);
248 * @brief Handles ACK for UL Harq process
252 * Function : schUlHqProcessAck
254 * This function handles ACK for UL Harq process
256 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
260 void schUlHqProcessAck(SchUlHqProcCb *hqP)
262 schUlReleaseHqProcess(hqP, TRUE);
264 /**********************************************************************
266 **********************************************************************/