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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for scheduler utilities
29 **********************************************************************/
32 @brief This file implements the schedulers util functions.
36 #include "sch_utils.h"
38 /* spec-38.213 Table 13-1 */
39 int8_t coresetIdxTable[MAX_CORESET_INDEX][4] = {
40 { 1, 24, 2, 0}, /* index 0 */
41 { 1, 24, 2, 2}, /* index 1 */
42 { 1, 24, 2, 4}, /* index 2 */
43 { 1, 24, 3, 0}, /* index 3 */
44 { 1, 24, 3, 2}, /* index 4 */
45 { 1, 24, 3, 4}, /* index 5 */
46 { 1, 48, 1, 12}, /* index 6 */
47 { 1, 48, 1, 16}, /* index 7 */
48 { 1, 48, 2, 12}, /* index 8 */
49 { 1, 48, 2, 16}, /* index 9 */
50 { 1, 48, 3, 12}, /* index 10 */
51 { 1, 48, 3, 16}, /* index 11 */
52 { 1, 96, 1, 38}, /* index 12 */
53 { 1, 96, 2, 38}, /* index 13 */
54 { 1, 96, 3, 38}, /* index 14 */
55 { 0, 0, 0, 0}, /* index 15 */
58 /* spec-38.213 Table 13-11 */
59 /* m value is scaled to 2, when using it in formula, divide by 2 */
60 /* firstSymbol will vary depends on i, hence not filled */
61 int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4] = {
62 { 0, 1, 2, 0}, /* index 0 */
63 { 0, 2, 1, 0}, /* index 1 */
64 { 2, 1, 2, 0}, /* index 2 */
65 { 2, 2, 1, 0}, /* index 3 */
66 { 5, 1, 2, 0}, /* index 4 */
67 { 5, 2, 1, 0}, /* index 5 */
68 { 7, 1, 2, 0}, /* index 6 */
69 { 7, 2, 1, 0}, /* index 7 */
70 { 0, 1, 4, 0}, /* index 8 */
71 { 5, 1, 4, 0}, /* index 9 */
72 { 0, 1, 2, 0}, /* index 10 */
73 { 0, 1, 2, 0}, /* index 11 */
74 { 2, 1, 2, 0}, /* index 12 */
75 { 2, 1, 2, 0}, /* index 13 */
76 { 5, 1, 2, 0}, /* index 14 */
77 { 5, 1, 2, 0}, /* index 15 */
82 /* spec-38.211 Table 6.3.3.2-1 */
83 /* Lra, delFRa, delF, numRb, k' */
84 uint16_t numRbForPrachTable[MAX_RACH_NUM_RB_IDX][5] = {
85 { 839, 1.25, 15, 6, 7 }, /* index 0 */
86 { 839, 1.25, 30, 3, 1 }, /* index 1 */
87 { 839, 1.25, 60, 2, 133 }, /* index 2 */
88 { 839, 5, 15, 24, 12 }, /* index 3 */
89 { 839, 5, 30, 12, 10 }, /* index 4 */
90 { 839, 5, 60, 6, 7 }, /* index 5 */
91 { 139, 15, 15, 12, 2 }, /* index 6 */
92 { 139, 15, 30, 6, 2 }, /* index 7 */
93 { 139, 15, 60, 3, 2 }, /* index 8 */
94 { 139, 30, 15, 24, 2 }, /* index 9 */
95 { 139, 30, 30, 12, 2 }, /* index 10 */
96 { 139, 30, 60, 6, 2 }, /* index 11 */
97 { 139, 60, 60, 12, 2 }, /* index 12 */
98 { 139, 60, 120, 6, 2 }, /* index 13 */
99 { 139, 120, 60, 24, 2 }, /* index 14 */
100 { 139, 120, 120, 12, 2 }, /* index 15 */
103 /* prach config index Table 6.3.3.2-2 spec 38.211
104 * PRACH format given as follows:
119 * Subframe num is represented considering 0-9 bits and
120 * value 1 corresponds to the subframe that is valid
122 //Sphoorthi TODO: complete this table
124 uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8] = {
125 { 0, 16, 1, 2, 0, 0, 0, 0 }, /* index 0 */
126 { 0, 16, 1, 16, 0, 0, 0, 0 }, /* index 1 */
127 { 0, 16, 1, 128, 0, 0, 0, 0 }, /* index 2 */
128 { 0, 16, 1, 512, 0, 0, 0, 0 }, /* index 3 */
129 { 0, 8, 1, 2, 0, 0, 0, 0 }, /* index 4 */
130 { 0, 8, 1, 16, 0, 0, 0, 0 }, /* index 5 */
131 { 0, 8, 1, 128, 0, 0, 0, 0 }, /* index 6 */
132 { 0, 8, 1, 512, 0, 0, 0, 0 }, /* index 7 */
133 { 0, 4, 1, 2, 0, 0, 0, 0 }, /* index 8 */
134 { 0, 4, 1, 16, 0, 0, 0, 0 }, /* index 9 */
135 { 0, 4, 1, 128, 0, 0, 0, 0 }, /* index 10 */
136 { 0, 4, 1, 512, 0, 0, 0, 0 }, /* index 11 */
137 { 0, 2, 1, 2, 0, 0, 0, 0 }, /* index 12 */
138 { 0, 2, 1, 16, 0, 0, 0, 0 }, /* index 13 */
139 { 0, 2, 1, 128, 0, 0, 0, 0 }, /* index 14 */
140 { 0, 2, 1, 512, 0, 0, 0, 0 }, /* index 15 */
141 { 0, 1, 0, 2, 0, 0, 0, 0 }, /* index 16 */
142 { 0, 1, 0, 16, 0, 0, 0, 0 }, /* index 17 */
143 { 0, 1, 0, 128, 0, 0, 0, 0 }, /* index 18 */
144 { 0, 1, 0, 66, 0, 0, 0, 0 }, /* index 19 */
145 { 0, 1, 0, 132, 0, 0, 0, 0 }, /* index 20 */
146 { 0, 1, 0, 264, 0, 0, 0, 0 }, /* index 21 */
147 { 0, 1, 0, 146, 0, 0, 0, 0 }, /* index 22 */
148 { 0, 1, 0, 292, 0, 0, 0, 0 }, /* index 23 */
149 { 0, 1, 0, 584, 0, 0, 0, 0 }, /* index 24 */
150 { 0, 1, 0, 341, 0, 0, 0, 0 }, /* index 25 */
151 { 0, 1, 0, 682, 0, 0, 0, 0 }, /* index 26 */
152 { 0, 1, 0, 1023, 0, 0, 0, 0 }, /* index 27 */
153 { 1, 16, 1, 2, 0, 0, 0, 0 }, /* index 28 */
154 { 1, 16, 1, 16, 0, 0, 0, 0 }, /* index 29 */
155 { 1, 16, 1, 128, 0, 0, 0, 0 }, /* index 30 */
156 { 1, 16, 1, 512, 0, 0, 0, 0 }, /* index 31 */
157 { 1, 8, 1, 2, 0, 0, 0, 0 }, /* index 32 */
158 { 1, 8, 1, 16, 0, 0, 0, 0 }, /* index 33 */
159 { 1, 8, 1, 128, 0, 0, 0, 0 }, /* index 34 */
160 { 1, 8, 1, 512, 0, 0, 0, 0 }, /* index 35 */
161 { 1, 4, 1, 2, 0, 0, 0, 0 }, /* index 36 */
162 { 1, 4, 1, 16, 0, 0, 0, 0 }, /* index 37 */
163 { 1, 4, 1, 128, 0, 0, 0, 0 }, /* index 38 */
164 { 1, 4, 1, 512, 0, 0, 0, 0 }, /* index 39 */
165 { 1, 2, 1, 2, 0, 0, 0, 0 }, /* index 40 */
166 { 1, 2, 1, 16, 0, 0, 0, 0 }, /* index 41 */
167 { 1, 2, 1, 128, 0, 0, 0, 0 }, /* index 42 */
168 { 1, 2, 1, 512, 0, 0, 0, 0 }, /* index 43 */
169 { 1, 1, 0, 2, 0, 0, 0, 0 }, /* index 44 */
170 { 1, 1, 0, 16, 0, 0, 0, 0 }, /* index 45 */
171 { 1, 1, 0, 128, 0, 0, 0, 0 }, /* index 46 */
172 { 1, 1, 0, 64, 0, 0, 0, 0 }, /* index 47 */
173 { 1, 1, 0, 132, 0, 0, 0, 0 }, /* index 48 */
174 { 1, 1, 0, 264, 0, 0, 0, 0 }, /* index 49 */
175 { 1, 1, 0, 146, 0, 0, 0, 0 }, /* index 50 */
176 { 1, 1, 0, 292, 0, 0, 0, 0 }, /* index 51 */
177 { 1, 1, 0, 584, 0, 0, 0, 0 }, /* index 52 */
178 { 2, 16, 1, 2, 0, 0, 0, 0 }, /* index 53 */
179 { 2, 8, 1, 2, 0, 0, 0, 0 }, /* index 54 */
180 { 2, 4, 0, 2, 0, 0, 0, 0 }, /* index 55 */
181 { 2, 2, 0, 2, 0, 0, 0, 0 }, /* index 56 */
182 { 2, 2, 0, 32, 0, 0, 0, 0 }, /* index 57 */
183 { 2, 1, 0, 2, 0, 0, 0, 0 }, /* index 58 */
184 { 2, 1, 0, 32, 0, 0, 0, 0 }, /* index 59 */
185 { 3, 16, 1, 2, 0, 0, 0, 0 }, /* index 60 */
186 { 3, 16, 1, 16, 0, 0, 0, 0 }, /* index 61 */
187 { 3, 16, 1, 128, 0, 0, 0, 0 }, /* index 62 */
188 { 3, 16, 1, 512, 0, 0, 0, 0 }, /* index 63 */
189 { 3, 8, 1, 2, 0, 0, 0, 0 }, /* index 64 */
190 { 3, 8, 1, 16, 0, 0, 0, 0 }, /* index 65 */
191 { 3, 8, 1, 128, 0, 0, 0, 0 }, /* index 66 */
192 { 3, 4, 1, 2, 0, 0, 0, 0 }, /* index 67 */
193 { 3, 4, 1, 16, 0, 0, 0, 0 }, /* index 68 */
194 { 3, 4, 1, 128, 0, 0, 0, 0 }, /* index 69 */
195 { 3, 4, 1, 512, 0, 0, 0, 0 }, /* index 70 */
196 { 3, 2, 1, 2, 0, 0, 0, 0 }, /* index 71 */
197 { 3, 2, 1, 16, 0, 0, 0, 0 }, /* index 72 */
198 { 3, 2, 1, 128, 0, 0, 0, 0 }, /* index 73 */
199 { 3, 2, 1, 512, 0, 0, 0, 0 }, /* index 74 */
200 { 3, 1, 0, 2, 0, 0, 0, 0 }, /* index 75 */
201 { 3, 1, 0, 16, 0, 0, 0, 0 }, /* index 76 */
202 { 3, 1, 0, 128, 0, 0, 0, 0 }, /* index 77 */
203 { 3, 1, 0, 66, 0, 0, 0, 0 }, /* index 78 */
204 { 3, 1, 0, 132, 0, 0, 0, 0 }, /* index 79 */
205 { 3, 1, 0, 264, 0, 0, 0, 0 }, /* index 80 */
206 { 3, 1, 0, 146, 0, 0, 0, 0 }, /* index 81 */
207 { 3, 1, 0, 292, 0, 0, 0, 0 }, /* index 82 */
208 { 3, 1, 0, 584, 0, 0, 0, 0 }, /* index 83 */
209 { 3, 1, 0, 341, 0, 0, 0, 0 }, /* index 84 */
210 { 3, 1, 0, 682, 0, 0, 0, 0 }, /* index 85 */
211 { 3, 1, 0, 1023, 0, 0, 0, 0 }, /* index 86 */
212 { 4, 16, 0, 528, 0, 1, 6, 2 }, /* index 87 */
213 { 4, 16, 1, 16, 0, 2, 6, 2 }, /* index 88 */
214 { 4, 8, 0, 528, 0, 1, 6, 2 }, /* index 89 */
215 { 4, 8, 1, 16, 0, 2, 6, 2 }, /* index 90 */
216 { 4, 4, 0, 528, 0, 1, 6, 2 }, /* index 91 */
217 { 4, 4, 1, 528, 0, 1, 6, 2 }, /* index 92 */
218 { 4, 4, 0, 16, 0, 2, 6, 2 }, /* index 93 */
219 { 4, 2, 0, 528, 0, 1, 6, 2 }, /* index 94 */
220 { 4, 2, 0, 2, 0, 2, 6, 2 }, /* index 95 */
221 { 4, 2, 0, 16, 0, 2, 6, 2 }, /* index 96 */
222 { 4, 2, 0, 128, 0, 2, 6, 2 }, /* index 97 */
223 { 4, 1, 0, 16, 0, 1, 6, 2 }, /* index 98 */
224 { 4, 1, 0, 66, 0, 1, 6, 2 }, /* index 99 */
225 { 4, 1, 0, 528, 0, 1, 6, 2 }, /* index 100 */
226 { 4, 1, 0, 2, 0, 2, 6, 2 }, /* index 101 */
227 { 4, 1, 0, 128, 0, 2, 6, 2 }, /* index 102 */
228 { 4, 1, 0, 132, 0, 2, 6, 2 }, /* index 103 */
229 { 4, 1, 0, 146, 0, 2, 6, 2 }, /* index 104 */
230 { 4, 1, 0, 341, 0, 2, 6, 2 }, /* index 105 */
231 { 4, 1, 0, 1023, 0, 2, 6, 2 }, /* index 106 */
232 { 4, 1, 0, 682, 0, 2, 6, 2 }, /* index 107 */
233 {11, 2, 0, 528, 0, 1, 7, 2 }, /* index 108 */
234 {11, 2, 0, 16, 0, 2, 7, 2 }, /* index 109 */
235 {11, 1, 0, 16, 0, 1, 7, 2 }, /* index 110 */
236 {11, 1, 0, 66, 0, 1, 7, 2 }, /* index 111 */
237 {11, 1, 0, 528, 0, 1, 7, 2 }, /* index 112 */
238 {11, 1, 0, 2, 0, 2, 7, 2 }, /* index 113 */
239 {11, 1, 0, 128, 0, 2, 7, 2 }, /* index 114 */
240 {11, 1, 0, 146, 0, 2, 7, 2 }, /* index 115 */
241 {11, 1, 0, 341, 0, 2, 7, 2 }, /* index 116 */
242 { 5, 16, 1, 580, 0, 1, 3, 4 }, /* index 117 */
243 { 5, 16, 1, 16, 0, 2, 3, 4 }, /* index 118 */
244 { 5, 8, 1, 580, 0, 1, 3, 4 }, /* index 119 */
245 { 5, 8, 1, 16, 0, 2, 3, 4 }, /* index 120 */
246 { 5, 4, 0, 580, 0, 1, 3, 4 }, /* index 121 */
247 { 5, 4, 0, 16, 0, 2, 3, 4 }, /* index 122 */
248 { 5, 2, 1, 580, 0, 1, 3, 4 }, /* index 123 */
249 { 5, 2, 0, 2, 0, 2, 3, 4 }, /* index 124 */
250 { 5, 2, 0, 16, 0, 2, 3, 4 }, /* index 125 */
255 * @brief frequency domain allocation function.
259 * Function : freqDomResourceAlloc
261 * This function does allocation in frequency domain resource. using
262 * bitwise operator, the bits are set for the PRBs.
264 * @param[in] startPrb - start PRB from where the freq alloc starts.
265 * @param[in] prbSize - number of PRBs to be allocted.
266 * @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
269 void freqDomResourceAlloc(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
271 uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
272 uint8_t firstByte = 1;
273 uint8_t numBits,startBit,byteCount = 0;
277 /* when the startPrb is not in this byteCount */
285 /* max bytecount is 6 nearly equal to 45 bits*/
289 /* when we are filling the second byte, then the start should be equal to 0 */
295 /* calculate the number of bits to be set in this byte */
296 if((remBits+startPrb) <= 8)
299 numBits = 8 - startBit;
301 /* bit operation to set the bits */
302 SET_BITS((startBit % 8),numBits,freqDomain[byteCount])
305 /* the ramaining bits should be subtracted with the numBits set in this byte */
311 /**********************************************************************
313 **********************************************************************/