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->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 cellCb->api->SchInitUlHqProcCb(hqP);
88 schUlHqAddToFreeList(hqP);
93 * @brief Add hq process to free list of UL Harq entity
97 * Function : schUlHqAddToFreeList
99 * This function adds hq process to free list of UL Harq entity
101 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
105 void schUlHqAddToFreeList(SchUlHqProcCb *hqP)
107 cmLListAdd2Tail(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
110 * @brief Delete hq process from free list of UL Harq entity
114 * Function : schUlHqDeleteFromFreeList
116 * This function deletes hq process to free list of UL Harq entity
118 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
122 void schUlHqDeleteFromFreeList(SchUlHqProcCb *hqP)
124 if(hqP->hqEnt->free.count == 0)
126 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in free\n");
128 cmLListDelFrm(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
131 * @brief Add hq process to in use list of UL Harq entity
135 * Function : schUlHqAddToInUseList
137 * This function adds hq process to in use list of UL Harq entity
139 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
143 void schUlHqAddToInUseList(SchUlHqProcCb *hqP)
145 cmLListAdd2Tail(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
148 * @brief Delete hq process from in use list of UL Harq entity
152 * Function : schUlHqDeleteFromInUseList
154 * This function deletes hq process to in use list of UL Harq entity
156 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
160 void schUlHqDeleteFromInUseList(SchUlHqProcCb *hqP)
162 if(hqP->hqEnt->inUse.count == 0)
164 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in use\n");
166 cmLListDelFrm(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
169 * @brief Get available Harq process from Harq entity
173 * Function : schUlGetAvlHqProcess
175 * This function fetches hq process from free list and puts in in use list
177 * @param[in] SchCellCb *cellCb, cell cb pointer
178 * @param[in] SchUeCb *ueCb, ue cb pointer
179 * @param[in] SchUlHqProcCb **hqP, Address of UL harq process pointer
184 uint8_t schUlGetAvlHqProcess(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqProcCb **hqP)
187 if (ueCb->ulHqEnt.free.count == 0)
191 tmp = (SchUlHqProcCb*)(cmLListFirst(&(ueCb->ulHqEnt.free))->node);
196 schUlHqDeleteFromFreeList(tmp);
197 schUlHqAddToInUseList(tmp);
199 (*hqP)->maxHqTxPerHqP = ueCb->ulHqEnt.maxHqTx;
203 * @brief Release Harq process from the UL Harq entity
207 * Function : schUlReleaseHqProcess
209 * This function releases Harq process from UL Harq entity
211 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
212 * @param[in] Bool togNdi, indication to togle NDI bit
216 void schUlReleaseHqProcess(SchUlHqProcCb *hqP, Bool togNdi)
218 SchCellCb *cellCb = NULLP;
221 hqP->tbInfo.ndi ^= 1;
224 cellCb = hqP->hqEnt->cell;
225 cellCb->api->SchFreeUlHqProcCb(hqP);
227 schUlHqDeleteFromInUseList(hqP);
228 schUlHqAddToFreeList(hqP);
231 * @brief Handles NACK for UL Harq process
235 * Function : schUlHqProcessNack
237 * This function handle NACK for UL Harq process
239 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
243 void schUlHqProcessNack(SchUlHqProcCb *hqP)
245 if (hqP->tbInfo.txCntr < hqP->maxHqTxPerHqP)
247 hqP->hqEnt->cell->api->SchAddToUlHqRetxList(hqP);
251 schUlReleaseHqProcess(hqP, TRUE);
255 * @brief Handles ACK for UL Harq process
259 * Function : schUlHqProcessAck
261 * This function handles ACK for UL Harq process
263 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
267 void schUlHqProcessAck(SchUlHqProcCb *hqP)
269 schUlReleaseHqProcess(hqP, TRUE);
273 * @brief Deletes HARQ Entity
277 * Function : schUlHqEntDelete
279 * This function deletes HARQ entity and its member paremeters
281 * @param[in] Pointer to UE
285 void schUlHqEntDelete(SchUeCb *ueCb)
290 cmLListDeleteLList(&ueCb->ulHqEnt.free);
291 cmLListDeleteLList(&ueCb->ulHqEnt.inUse);
292 for(count=0; count < ueCb->ulHqEnt.numHqPrcs; count++)
294 hqP = &(ueCb->ulHqEnt.procs[count]);
295 ueCb->cellCb->api->SchDeleteUlHqProcCb(hqP);
297 memset(&ueCb->ulHqEnt, 0, sizeof(SchUlHqEnt));
300 /**********************************************************************
302 **********************************************************************/