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"
28 #include "sch_utils.h"
32 typedef struct schCellCb SchCellCb;
33 typedef struct schUeCb SchUeCb;
34 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE);
35 void schUlHqAddToFreeList(SchUlHqProcCb *hqP);
37 * @brief UL Harq entity intialization
41 * Function : schUlHqEntInit
43 * This function intialize UL Harq entity
45 * @param[in] SchCellCb *cellCb, cell cb pointer
46 * @param[in] SchUeCb *ueCb, ue cb pointer
50 void schUlHqEntInit(SchCellCb *cellCb, SchUeCb *ueCb)
52 ueCb->ulHqEnt.numHqPrcs = SCH_MAX_NUM_UL_HQ_PROC;
53 ueCb->ulHqEnt.maxHqTx = cellCb->schHqCfg.maxUlDataHqTx;
54 ueCb->ulHqEnt.cell = cellCb;
55 ueCb->ulHqEnt.ue =ueCb;
56 schUlHqEntReset(cellCb, ueCb, &ueCb->ulHqEnt);
59 * @brief UL Harq entity Reset
63 * Function : schUlHqEntReset
65 * This function Reset UL Harq entity
67 * @param[in] SchCellCb *cellCb, cell cb pointer
68 * @param[in] SchUeCb *ueCb, ue cb pointer
69 * @param[in] SchUlHqEnt *hqE, Ul Harq entity pointer
73 void schUlHqEntReset(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqEnt *hqE)
76 SchUlHqProcCb *hqP = NULL;
77 cmLListInit(&hqE->free);
78 cmLListInit(&hqE->inUse);
79 for(count=0; count < hqE->numHqPrcs; count++)
81 hqP = &(hqE->procs[count]);
84 hqP->maxHqTxPerHqP = hqE->maxHqTx;
85 hqP->ulHqEntLnk.node = (PTR)hqP;
86 hqP->ulHqProcLink.node = (PTR)hqP;
87 hqP->ulSlotLnk.node = (PTR)hqP;
88 cellCb->api->SchInitUlHqProcCb(hqP);
89 schUlHqAddToFreeList(hqP);
94 * @brief Add hq process to free list of UL Harq entity
98 * Function : schUlHqAddToFreeList
100 * This function adds hq process to free list of UL Harq entity
102 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
106 void schUlHqAddToFreeList(SchUlHqProcCb *hqP)
108 cmLListAdd2Tail(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
111 * @brief Delete hq process from free list of UL Harq entity
115 * Function : schUlHqDeleteFromFreeList
117 * This function deletes hq process to free list of UL Harq entity
119 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
123 void schUlHqDeleteFromFreeList(SchUlHqProcCb *hqP)
125 if(hqP->hqEnt->free.count == 0)
127 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in free\n");
129 cmLListDelFrm(&(hqP->hqEnt->free), &hqP->ulHqEntLnk);
132 * @brief Add hq process to in use list of UL Harq entity
136 * Function : schUlHqAddToInUseList
138 * This function adds hq process to in use list of UL Harq entity
140 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
144 void schUlHqAddToInUseList(SchUlHqProcCb *hqP)
146 cmLListAdd2Tail(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
149 * @brief Delete hq process from in use list of UL Harq entity
153 * Function : schUlHqDeleteFromInUseList
155 * This function deletes hq process to in use list of UL Harq entity
157 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
161 void schUlHqDeleteFromInUseList(SchUlHqProcCb *hqP)
163 if(hqP->hqEnt->inUse.count == 0)
165 DU_LOG("\n ERROR schUlHqDeleteFromInUseList no proc in in use\n");
167 cmLListDelFrm(&(hqP->hqEnt->inUse), &hqP->ulHqEntLnk);
170 * @brief Get available Harq process from Harq entity
174 * Function : schUlGetAvlHqProcess
176 * This function fetches hq process from free list and puts in in use list
178 * @param[in] SchCellCb *cellCb, cell cb pointer
179 * @param[in] SchUeCb *ueCb, ue cb pointer
180 * @param[in] SchUlHqProcCb **hqP, Address of UL harq process pointer
185 uint8_t schUlGetAvlHqProcess(SchCellCb *cellCb, SchUeCb *ueCb, SchUlHqProcCb **hqP)
188 if (ueCb->ulHqEnt.free.count == 0)
192 tmp = (SchUlHqProcCb*)(cmLListFirst(&(ueCb->ulHqEnt.free))->node);
197 schUlHqDeleteFromFreeList(tmp);
198 schUlHqAddToInUseList(tmp);
200 (*hqP)->maxHqTxPerHqP = ueCb->ulHqEnt.maxHqTx;
204 * @brief Release Harq process from the UL Harq entity
208 * Function : schUlReleaseHqProcess
210 * This function releases Harq process from UL Harq entity
212 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
213 * @param[in] Bool togNdi, indication to togle NDI bit
217 void schUlReleaseHqProcess(SchUlHqProcCb *hqP, Bool togNdi)
219 SchCellCb *cellCb = NULLP;
222 hqP->tbInfo.ndi ^= 1;
225 cellCb = hqP->hqEnt->cell;
226 cellCb->api->SchFreeUlHqProcCb(hqP);
228 schUlHqDeleteFromInUseList(hqP);
229 schUlHqAddToFreeList(hqP);
232 * @brief Handles NACK for UL Harq process
236 * Function : schUlHqProcessNack
238 * This function handle NACK for UL Harq process
240 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
244 void schUlHqProcessNack(SchUlHqProcCb *hqP)
246 if (hqP->tbInfo.txCntr < hqP->maxHqTxPerHqP)
248 hqP->hqEnt->cell->api->SchAddToUlHqRetxList(hqP);
252 schUlReleaseHqProcess(hqP, TRUE);
256 * @brief Handles ACK for UL Harq process
260 * Function : schUlHqProcessAck
262 * This function handles ACK for UL Harq process
264 * @param[in] SchUlHqProcCb *hqP, UL harq process pointer
268 void schUlHqProcessAck(SchUlHqProcCb *hqP)
270 schUlReleaseHqProcess(hqP, TRUE);
274 * @brief Deletes HARQ Entity
278 * Function : schUlHqEntDelete
280 * This function deletes HARQ entity and its member paremeters
282 * @param[in] Pointer to UE
286 void schUlHqEntDelete(SchUeCb *ueCb)
291 cmLListDeleteLList(&ueCb->ulHqEnt.free);
292 cmLListDeleteLList(&ueCb->ulHqEnt.inUse);
293 for(count=0; count < ueCb->ulHqEnt.numHqPrcs; count++)
295 hqP = &(ueCb->ulHqEnt.procs[count]);
296 ueCb->cellCb->api->SchDeleteUlHqProcCb(hqP);
298 memset(&ueCb->ulHqEnt, 0, sizeof(SchUlHqEnt));
301 /**********************************************************************
303 **********************************************************************/