Implementation of function for filling k0 and k1 table [Issue-ID: ODUHIGH-341]
[o-du/l2.git] / src / 5gnrsch / sch_utils.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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
19 /************************************************************************
20  
21      Name:     sch_utils.c
22   
23      Type:     C source file
24   
25      Desc:     C source code for scheduler utilities
26   
27      File:     sch_utils.c
28   
29 **********************************************************************/
30
31 /** @file sch_utils.c
32 @brief This file implements the schedulers util functions.
33 */
34
35 /* header files */
36 #include "common_def.h"
37 #include "du_app_mac_inf.h"
38 #include "lrg.h"
39 #include "tfu.h"
40 #include "tfu.x"           /* TFU types */
41 #include "lrg.x"           /* layer management typedefs for MAC */
42 #include "mac_sch_interface.h"
43 #include "sch.h"
44 #include "sch_utils.h"
45 #include "math.h"
46
47 #ifdef NR_TDD
48 /* spec-38.213 Table 13-4 for SCS=30KHz */
49 /* Note: Picking Table 13-4 and not 13-6 since band supported is n78 and
50  * corresponding minimum B/W is 10 MHz */
51 int8_t coresetIdxTable[MAX_CORESET_INDEX][4] = {
52 {   1,   24,   2,   0}, /* index 0  */
53 {   1,   24,   2,   1}, /* index 1  */
54 {   1,   24,   2,   2}, /* index 2  */
55 {   1,   24,   2,   3}, /* index 3  */
56 {   1,   24,   2,   4}, /* index 4  */
57 {   1,   24,   3,   0}, /* index 5  */
58 {   1,   24,   3,   1}, /* index 6  */
59 {   1,   24,   3,   2}, /* index 7  */
60 {   1,   24,   3,   3}, /* index 8  */
61 {   1,   24,   3,   4}, /* index 9  */
62 {   1,   48,   1,  12}, /* index 10 */
63 {   1,   48,   1,  14}, /* index 11 */
64 {   1,   48,   1,  16}, /* index 12 */
65 {   1,   48,   2,  12}, /* index 13 */
66 {   1,   48,   2,  14}, /* index 14 */
67 {   1,   48,   2,  16}, /* index 15 */
68 };
69 #else
70 /* spec-38.213 Table 13-1 for SCS=15KHz */
71 int8_t coresetIdxTable[MAX_CORESET_INDEX][4] = {
72 {   1,   24,   2,   0}, /* index 0  */
73 {   1,   24,   2,   2}, /* index 1  */
74 {   1,   24,   2,   4}, /* index 2  */
75 {   1,   24,   3,   0}, /* index 3  */
76 {   1,   24,   3,   2}, /* index 4  */
77 {   1,   24,   3,   4}, /* index 5  */
78 {   1,   48,   1,  12}, /* index 6  */
79 {   1,   48,   1,  16}, /* index 7  */
80 {   1,   48,   2,  12}, /* index 8  */
81 {   1,   48,   2,  16}, /* index 9  */
82 {   1,   48,   3,  12}, /* index 10 */
83 {   1,   48,   3,  16}, /* index 11 */
84 {   1,   96,   1,  38}, /* index 12 */
85 {   1,   96,   2,  38}, /* index 13 */
86 {   1,   96,   3,  38}, /* index 14 */
87 {   0,    0,   0,   0}, /* index 15 */
88 };
89 #endif
90
91 /* spec-38.213 Table 13-11 */
92 /* m value is scaled to 2, when using it in formula, divide by 2 */
93 /* firstSymbol will vary depends on i, hence not filled */
94 int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4] = {
95 {   0,    1,   2,   0}, /* index 0  */
96 {   0,    2,   1,   0}, /* index 1  */
97 {   2,    1,   2,   0}, /* index 2  */
98 {   2,    2,   1,   0}, /* index 3  */
99 {   5,    1,   2,   0}, /* index 4  */
100 {   5,    2,   1,   0}, /* index 5  */
101 {   7,    1,   2,   0}, /* index 6  */
102 {   7,    2,   1,   0}, /* index 7  */
103 {   0,    1,   4,   0}, /* index 8  */
104 {   5,    1,   4,   0}, /* index 9  */
105 {   0,    1,   2,   0}, /* index 10 */
106 {   0,    1,   2,   0}, /* index 11 */
107 {   2,    1,   2,   0}, /* index 12 */
108 {   2,    1,   2,   0}, /* index 13 */
109 {   5,    1,   2,   0}, /* index 14 */
110 {   5,    1,   2,   0}, /* index 15 */
111 };
112
113 /* RACH tables */
114
115 /* spec-38.211 Table 6.3.3.2-1 */
116 /* Lra, delFRa, delF, numRb, k' */
117 uint16_t numRbForPrachTable[MAX_RACH_NUM_RB_IDX][5] = {
118 {   839,  1.25,  15,   6,   7    }, /* index 0 */
119 {   839,  1.25,  30,   3,   1    }, /* index 1 */
120 {   839,  1.25,  60,   2,   133  }, /* index 2 */
121 {   839,  5,     15,   24,  12   }, /* index 3 */
122 {   839,  5,     30,   12,  10   }, /* index 4 */
123 {   839,  5,     60,   6,   7    }, /* index 5 */
124 {   139,  15,    15,   12,  2    }, /* index 6 */
125 {   139,  15,    30,   6,   2    }, /* index 7 */
126 {   139,  15,    60,   3,   2    }, /* index 8 */
127 {   139,  30,    15,   24,  2    }, /* index 9 */
128 {   139,  30,    30,   12,  2    }, /* index 10 */
129 {   139,  30,    60,   6,   2    }, /* index 11 */
130 {   139,  60,    60,   12,  2    }, /* index 12 */
131 {   139,  60,    120,  6,   2    }, /* index 13 */
132 {   139,  120,   60,   24,  2    }, /* index 14 */
133 {   139,  120,   120,  12,  2    }, /* index 15 */
134 };
135
136 #ifdef NR_TDD
137
138 /* prach config index Table 6.3.3.2-3 spec 38.211 
139  * PRACH format given as follows:
140  * 0 = 0
141  * 1 = 1
142  * 2 = 2
143  * 3 = 3
144  * 4 = A1
145  * 5 = A2
146  * 6 = A3
147  * 7 = B1
148  * 8 = B4
149  * 9 = C0
150  * 10 = C2
151  * 11 = A1/B1
152  * 12 = A2/B2
153  * 13 = A3/B3 
154  * Subframe num is represented considering 0-9 bits and
155  * value 1 corresponds to the subframe that is valid 
156  */
157
158 uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8] = {
159 { 0, 16,  1,  512,  0,  0,  0,  0 }, /* index 0   */
160 { 0,  8,  1,  512,  0,  0,  0,  0 }, /* index 1   */
161 { 0,  4,  1,  512,  0,  0,  0,  0 }, /* index 2   */
162 { 0,  2,  0,  512,  0,  0,  0,  0 }, /* index 3   */
163 { 0,  2,  1,  512,  0,  0,  0,  0 }, /* index 4   */
164 { 0,  2,  0,   16,  0,  0,  0,  0 }, /* index 5   */
165 { 0,  2,  1,   16,  0,  0,  0,  0 }, /* index 6   */
166 { 0,  1,  0,  512,  0,  0,  0,  0 }, /* index 7   */
167 { 0,  1,  0,  256,  0,  0,  0,  0 }, /* index 8   */
168 { 0,  1,  0,  128,  0,  0,  0,  0 }, /* index 9   */
169 { 0,  1,  0,   64,  0,  0,  0,  0 }, /* index 10  */
170 { 0,  1,  0,   32,  0,  0,  0,  0 }, /* index 11  */
171 { 0,  1,  0,   16,  0,  0,  0,  0 }, /* index 12  */
172 { 0,  1,  0,    8,  0,  0,  0,  0 }, /* index 13  */
173 { 0,  1,  0,    4,  0,  0,  0,  0 }, /* index 14  */
174 { 0,  1,  0,   66,  0,  0,  0,  0 }, /* index 15  */
175 { 0,  1,  0,   66,  7,  0,  0,  0 }, /* index 16  */
176 { 0,  1,  0,  528,  0,  0,  0,  0 }, /* index 17  */
177 { 0,  1,  0,  264,  0,  0,  0,  0 }, /* index 18  */
178 { 0,  1,  0,  132,  0,  0,  0,  0 }, /* index 19  */
179 { 0,  1,  0,  768,  0,  0,  0,  0 }, /* index 20  */
180 { 0,  1,  0,  784,  0,  0,  0,  0 }, /* index 21  */
181 { 0,  1,  0,  536,  0,  0,  0,  0 }, /* index 22  */
182 { 0,  1,  0,  896,  0,  0,  0,  0 }, /* index 23  */
183 { 0,  1,  0,  792,  0,  0,  0,  0 }, /* index 24  */
184 { 0,  1,  0,  960,  0,  0,  0,  0 }, /* index 25  */
185 { 0,  1,  0,  594,  0,  0,  0,  0 }, /* index 26  */
186 { 0,  1,  0,  682,  0,  0,  0,  0 }, /* index 27  */
187 { 1, 16,  1,  128,  0,  0,  0,  0 }, /* index 28  */
188 { 1,  8,  1,  128,  0,  0,  0,  0 }, /* index 29  */
189 { 1,  4,  1,  128,  0,  0,  0,  0 }, /* index 30  */
190 { 1,  2,  0,  128,  0,  0,  0,  0 }, /* index 31  */
191 { 1,  2,  1,  128,  0,  0,  0,  0 }, /* index 32  */
192 { 1,  1,  0,  128,  0,  0,  0,  0 }, /* index 33  */
193 { 2, 16,  1,   64,  0,  0,  0,  0 }, /* index 34  */
194 { 2,  8,  1,   64,  0,  0,  0,  0 }, /* index 35  */
195 { 2,  4,  1,   64,  0,  0,  0,  0 }, /* index 36  */
196 { 2,  2,  0,   64,  7,  0,  0,  0 }, /* index 37  */
197 { 2,  2,  1,   64,  7,  0,  0,  0 }, /* index 38  */
198 { 2,  1,  0,   64,  7,  0,  0,  0 }, /* index 39  */
199 { 3, 16,  1,  512,  0,  0,  0,  0 }, /* index 40  */
200 { 3,  8,  1,  512,  0,  0,  0,  0 }, /* index 41  */
201 { 3,  4,  1,  512,  0,  0,  0,  0 }, /* index 42  */
202 { 3,  2,  0,  512,  0,  0,  0,  0 }, /* index 43  */
203 { 3,  2,  1,  512,  0,  0,  0,  0 }, /* index 44  */
204 { 3,  2,  0,   16,  0,  0,  0,  0 }, /* index 45  */
205 { 3,  2,  1,   16,  0,  0,  0,  0 }, /* index 46  */
206 { 3,  1,  0,  512,  0,  0,  0,  0 }, /* index 47  */
207 { 3,  1,  0,  256,  0,  0,  0,  0 }, /* index 48  */
208 { 3,  1,  0,  128,  0,  0,  0,  0 }, /* index 49  */
209 { 3,  1,  0,   64,  0,  0,  0,  0 }, /* index 50  */
210 { 3,  1,  0,   32,  0,  0,  0,  0 }, /* index 51  */
211 { 3,  1,  0,   16,  0,  0,  0,  0 }, /* index 52  */
212 { 3,  1,  0,    8,  0,  0,  0,  0 }, /* index 53  */
213 { 3,  1,  0,    4,  0,  0,  0,  0 }, /* index 54  */
214 { 3,  1,  0,   66,  0,  0,  0,  0 }, /* index 55  */
215 { 3,  1,  0,   66,  7,  0,  0,  0 }, /* index 56  */
216 { 3,  1,  0,  528,  0,  0,  0,  0 }, /* index 57  */
217 { 3,  1,  0,  264,  0,  0,  0,  0 }, /* index 58  */
218 { 3,  1,  0,  132,  0,  0,  0,  0 }, /* index 59  */
219 { 3,  1,  0,  768,  0,  0,  0,  0 }, /* index 60  */
220 { 3,  1,  0,  784,  0,  0,  0,  0 }, /* index 61  */
221 { 3,  1,  0,  536,  0,  0,  0,  0 }, /* index 62  */
222 { 3,  1,  0,  896,  0,  0,  0,  0 }, /* index 63  */
223 { 3,  1,  0,  792,  0,  0,  0,  0 }, /* index 64  */
224 { 3,  1,  0,  594,  0,  0,  0,  0 }, /* index 65  */
225 { 3,  1,  0,  682,  0,  0,  0,  0 }, /* index 66  */
226 { 4, 16,  1,  512,  0,  2,  6,  2 }, /* index 67  */
227 { 4,  8,  1,  512,  0,  2,  6,  2 }, /* index 68  */
228 { 4,  4,  1,  512,  0,  1,  6,  2 }, /* index 69  */
229 { 4,  2,  1,  512,  0,  1,  6,  2 }, /* index 70  */
230 { 4,  2,  1,  528,  7,  1,  3,  2 }, /* index 71  */
231 { 4,  2,  1,  640,  7,  1,  3,  2 }, /* index 72  */
232 { 4,  2,  1,  640,  0,  1,  6,  2 }, /* index 73  */
233 { 4,  2,  1,  768,  0,  2,  6,  2 }, /* index 74  */
234 { 4,  2,  1,  528,  0,  2,  6,  2 }, /* index 75  */
235 { 4,  2,  1,  924,  0,  1,  6,  2 }, /* index 76  */
236 { 4,  1,  0,  512,  0,  2,  6,  2 }, /* index 77  */
237 { 4,  1,  0,  512,  7,  1,  3,  2 }, /* index 78  */
238 { 4,  1,  0,  512,  0,  1,  6,  2 }, /* index 79  */
239 { 4,  1,  0,  768,  0,  2,  6,  2 }, /* index 80  */
240 { 4,  1,  0,  528,  0,  1,  6,  2 }, /* index 81  */
241 { 4,  1,  0,  640,  7,  1,  3,  2 }, /* index 82  */
242 { 4,  1,  0,  792,  0,  1,  6,  2 }, /* index 83  */
243 { 4,  1,  0,  792,  0,  2,  6,  2 }, /* index 84  */
244 { 4,  1,  0,  682,  0,  1,  6,  2 }, /* index 85  */
245 { 4,  1,  0, 1023,  7,  1,  3,  2 }, /* index 86  */
246 { 5, 16,  1,  512,  0,  2,  3,  4 }, /* index 87  */
247 { 5,  8,  1,  512,  0,  2,  3,  4 }, /* index 88  */
248 { 5,  4,  1,  512,  0,  1,  3,  4 }, /* index 89  */
249 { 5,  2,  1,  640,  0,  1,  3,  4 }, /* index 90  */
250 { 5,  2,  1,  768,  0,  2,  3,  4 }, /* index 91  */
251 { 5,  2,  1,  640,  9,  1,  1,  4 }, /* index 92  */
252 { 5,  2,  1,  528,  9,  1,  1,  4 }, /* index 93  */
253 { 5,  2,  1,  528,  0,  2,  3,  4 }, /* index 94  */
254 { 5,  2,  1,  924,  0,  1,  3,  4 }, /* index 95  */
255 { 5,  1,  0,    4,  0,  1,  3,  4 }, /* index 96  */
256 { 5,  1,  0,  128,  0,  1,  3,  4 }, /* index 97  */
257 { 5,  2,  1,  512,  0,  1,  3,  4 }, /* index 98  */
258 { 5,  1,  0,  512,  0,  2,  3,  4 }, /* index 99  */
259 { 5,  1,  0,  512,  9,  1,  1,  4 }, /* index 100  */
260 { 5,  1,  0,  512,  0,  1,  3,  4 }, /* index 101  */
261 { 5,  1,  0,  132,  0,  1,  3,  4 }, /* index 102  */
262 { 5,  1,  0,  768,  0,  2,  3,  4 }, /* index 103  */
263 { 5,  1,  0,  528,  0,  1,  3,  4 }, /* index 104  */
264 { 5,  1,  0,  640,  9,  1,  1,  4 }, /* index 105  */
265 { 5,  1,  0,  792,  0,  1,  3,  4 }, /* index 106  */
266 { 5,  1,  0,  792,  0,  2,  3,  4 }, /* index 107  */
267 { 5,  1,  0,  682,  0,  1,  3,  4 }, /* index 108  */
268 { 5,  1,  0, 1023,  9,  1,  1,  4 }, /* index 109  */
269 { 6, 16,  1,  512,  0,  2,  2,  6 }, /* index 110  */
270 { 6,  8,  1,  512,  0,  2,  2,  6 }, /* index 111  */
271 { 6,  4,  1,  512,  0,  1,  2,  6 }, /* index 112  */
272 { 6,  2,  1,  528,  7,  1,  1,  6 }, /* index 113  */
273 { 6,  2,  1,  640,  7,  1,  1,  6 }, /* index 114  */
274 { 6,  2,  1,  640,  0,  1,  2,  6 }, /* index 115  */
275 { 6,  2,  1,  528,  0,  2,  2,  6 }, /* index 116  */
276 { 6,  2,  1,  768,  0,  2,  2,  6 }, /* index 117  */
277 { 6,  2,  1,  924,  0,  1,  2,  6 }, /* index 118  */
278 { 6,  1,  0,    4,  0,  1,  2,  6 }, /* index 119  */
279 { 6,  1,  0,  128,  0,  1,  2,  6 }, /* index 120  */
280 { 6,  2,  1,  512,  0,  1,  2,  6 }, /* index 121  */
281 { 6,  1,  0,  512,  0,  2,  2,  6 }, /* index 122  */
282 { 6,  1,  0,  512,  7,  1,  1,  6 }, /* index 123  */
283 { 6,  1,  0,  512,  0,  1,  2,  6 }, /* index 124  */
284 { 6,  1,  0,  132,  0,  1,  2,  6 }, /* index 125  */
285 { 6,  1,  0,  768,  0,  2,  2,  6 }, /* index 126  */
286 { 6,  1,  0,  528,  0,  1,  2,  6 }, /* index 127  */
287 { 6,  1,  0,  640,  7,  1,  1,  6 }, /* index 128  */
288 { 6,  1,  0,  792,  0,  1,  2,  6 }, /* index 129  */
289 { 6,  1,  0,  792,  0,  2,  2,  6 }, /* index 130  */
290 { 6,  1,  0,  682,  0,  1,  2,  6 }, /* index 131  */
291 { 6,  1,  0, 1023,  7,  1,  1,  6 }, /* index 132  */
292 { 7,  4,  1,  512,  2,  1,  6,  2 }, /* index 133  */
293 { 7,  2,  1,  512,  2,  1,  6,  2 }, /* index 134  */
294 { 7,  2,  1,  640,  2,  1,  6,  2 }, /* index 135  */
295 { 7,  2,  1,  528,  8,  1,  3,  2 }, /* index 136  */
296 { 7,  2,  1,  528,  2,  2,  6,  2 }, /* index 137  */
297 { 7,  1,  0,  512,  2,  2,  6,  2 }, /* index 138  */
298 { 7,  1,  0,  512,  8,  1,  3,  2 }, /* index 139  */
299 { 7,  1,  0,  512,  2,  1,  6,  2 }, /* index 140  */
300 { 7,  1,  0,  768,  2,  2,  6,  2 }, /* index 141  */
301 { 7,  1,  0,  528,  2,  1,  6,  2 }, /* index 142  */
302 { 7,  1,  0,  640,  8,  1,  3,  2 }, /* index 143  */
303 { 7,  1,  0,  682,  2,  1,  6,  2 }, /* index 144  */
304 { 8, 16,  1,  512,  0,  2,  1, 12 }, /* index 145  */
305 { 8,  8,  1,  512,  0,  2,  1, 12 }, /* index 146  */
306 { 8,  4,  1,  512,  2,  1,  1, 12 }, /* index 147  */
307 { 8,  2,  1,  512,  0,  1,  1, 12 }, /* index 148  */
308 { 8,  2,  1,  512,  2,  1,  1, 12 }, /* index 149  */
309 { 8,  2,  1,  640,  2,  1,  1, 12 }, /* index 150  */
310 { 8,  2,  1,  528,  2,  1,  1, 12 }, /* index 151  */
311 { 8,  2,  1,  528,  0,  2,  1, 12 }, /* index 152  */
312 { 8,  2,  1,  768,  0,  2,  1, 12 }, /* index 153  */
313 { 8,  2,  1,  924,  0,  1,  1, 12 }, /* index 154  */
314 { 8,  1,  0,    2,  0,  1,  1, 12 }, /* index 155  */
315 { 8,  1,  0,    4,  0,  1,  1, 12 }, /* index 156  */
316 { 8,  1,  0,   16,  0,  1,  1, 12 }, /* index 157  */
317 { 8,  1,  0,  128,  0,  1,  1, 12 }, /* index 158  */
318 { 8,  1,  0,  512,  0,  1,  1, 12 }, /* index 159  */
319 { 8,  1,  0,  512,  2,  1,  1, 12 }, /* index 160  */
320 { 8,  1,  0,  512,  0,  2,  1, 12 }, /* index 161  */
321 { 8,  1,  0,  528,  2,  1,  1, 12 }, /* index 162  */
322 { 8,  1,  0,  640,  2,  1,  1, 12 }, /* index 163  */
323 { 8,  1,  0,  768,  0,  2,  1, 12 }, /* index 164  */
324 { 8,  1,  0,  792,  2,  1,  1, 12 }, /* index 165  */
325 { 8,  1,  0,  682,  2,  1,  1, 12 }, /* index 166  */
326 { 8,  1,  0, 1023,  0,  2,  1, 12 }, /* index 167  */
327 { 8,  1,  0, 1023,  2,  1,  1, 12 }, /* index 168  */
328 { 9, 16,  1,  512,  2,  2,  6,  2 }, /* index 169  */
329 { 9,  8,  1,  512,  2,  2,  6,  2 }, /* index 170  */
330 { 9,  4,  1,  512,  2,  1,  6,  2 }, /* index 171  */
331 { 9,  2,  1,  512,  2,  1,  6,  2 }, /* index 172  */
332 { 9,  2,  1,  768,  2,  2,  6,  2 }, /* index 173  */
333 { 9,  2,  1,  640,  2,  1,  6,  2 }, /* index 174  */
334 { 9,  2,  1,  640,  8,  1,  3,  2 }, /* index 175  */
335 { 9,  2,  1,  528,  8,  1,  3,  2 }, /* index 176  */
336 { 9,  2,  1,  528,  2,  2,  6,  2 }, /* index 177  */
337 { 9,  2,  1,  924,  2,  1,  6,  2 }, /* index 178  */
338 { 9,  1,  0,  512,  2,  2,  6,  2 }, /* index 179  */
339 { 9,  1,  0,  512,  8,  1,  3,  2 }, /* index 180  */
340 { 9,  1,  0,  512,  2,  1,  6,  2 }, /* index 181  */
341 { 9,  1,  0,  768,  2,  2,  6,  2 }, /* index 182  */
342 { 9,  1,  0,  528,  2,  1,  6,  2 }, /* index 183  */
343 { 9,  1,  0,  640,  8,  1,  3,  2 }, /* index 184  */
344 { 9,  1,  0,  792,  2,  1,  6,  2 }, /* index 185  */
345 { 9,  1,  0,  792,  2,  2,  6,  2 }, /* index 186  */
346 { 9,  1,  0,  682,  2,  1,  6,  2 }, /* index 187  */
347 { 9,  1,  0, 1023,  8,  1,  3,  2 }, /* index 188  */
348 {10, 16,  1,  512,  2,  2,  2,  6 }, /* index 189  */
349 {10,  8,  1,  512,  2,  2,  2,  6 }, /* index 190  */
350 {10,  4,  1,  512,  2,  1,  2,  6 }, /* index 191  */
351 {10,  2,  1,  512,  2,  1,  2,  6 }, /* index 192  */
352 {10,  2,  1,  768,  2,  2,  2,  6 }, /* index 193  */
353 {10,  2,  1,  640,  2,  1,  2,  6 }, /* index 194  */
354 {10,  2,  1,  640,  8,  1,  1,  6 }, /* index 195  */
355 {10,  2,  1,  528,  8,  1,  1,  6 }, /* index 196  */
356 {10,  2,  1,  528,  2,  2,  2,  6 }, /* index 197  */
357 {10,  2,  1,  924,  2,  1,  2,  6 }, /* index 198  */
358 {10,  8,  1,  512,  8,  2,  1,  6 }, /* index 199  */
359 {10,  4,  1,  512,  8,  1,  1,  6 }, /* index 200  */
360 {10,  1,  0,  512,  2,  2,  2,  6 }, /* index 201  */
361 {10,  1,  0,  512,  8,  1,  1,  6 }, /* index 202  */
362 {10,  1,  0,  512,  2,  1,  2,  6 }, /* index 203  */
363 {10,  1,  0,  768,  2,  2,  2,  6 }, /* index 204  */
364 {10,  1,  0,  528,  2,  1,  2,  6 }, /* index 205  */
365 {10,  1,  0,  640,  8,  1,  1,  6 }, /* index 206  */
366 {10,  1,  0,  792,  2,  1,  2,  6 }, /* index 207  */
367 {10,  1,  0,  792,  2,  2,  2,  6 }, /* index 208  */
368 {10,  1,  0,  682,  2,  1,  2,  6 }, /* index 209  */
369 {10,  1,  0, 1023,  8,  1,  1,  6 }, /* index 210  */
370 {11,  2,  1,  512,  2,  1,  6,  2 }, /* index 211  */
371 {11,  2,  1,  528,  8,  1,  3,  2 }, /* index 212  */
372 {11,  2,  1,  640,  8,  1,  3,  2 }, /* index 213  */
373 {11,  2,  1,  640,  2,  1,  6,  2 }, /* index 214  */
374 {11,  2,  1,  528,  2,  2,  6,  2 }, /* index 215  */
375 {11,  2,  1,  768,  2,  2,  6,  2 }, /* index 216  */
376 {11,  1,  0,  512,  2,  2,  6,  2 }, /* index 217  */
377 {11,  1,  0,  512,  8,  1,  3,  2 }, /* index 218  */
378 {11,  1,  0,  512,  2,  1,  6,  2 }, /* index 219  */
379 {11,  1,  0,  768,  2,  2,  6,  2 }, /* index 220  */
380 {11,  1,  0,  528,  2,  1,  6,  2 }, /* index 221  */
381 {11,  1,  0,  640,  8,  1,  3,  2 }, /* index 222  */
382 {11,  1,  0,  792,  2,  2,  6,  2 }, /* index 223  */
383 {11,  1,  0,  682,  2,  1,  6,  2 }, /* index 224  */
384 {11,  1,  0, 1023,  8,  1,  3,  2 }, /* index 225  */
385 {12,  2,  1,  512,  0,  1,  3,  4 }, /* index 226  */
386 {12,  2,  1,  528,  6,  1,  2,  4 }, /* index 227  */
387 {12,  2,  1,  640,  6,  1,  2,  4 }, /* index 228  */
388 {12,  2,  1,  528,  0,  2,  3,  4 }, /* index 229  */
389 {12,  2,  1,  768,  0,  2,  3,  4 }, /* index 230  */
390 {12,  1,  0,  512,  0,  2,  3,  4 }, /* index 231  */
391 {12,  1,  0,  512,  6,  1,  2,  4 }, /* index 232  */
392 {12,  1,  0,  512,  0,  1,  3,  4 }, /* index 233  */
393 {12,  1,  0,  768,  0,  2,  3,  4 }, /* index 234  */
394 {12,  1,  0,  528,  0,  1,  3,  4 }, /* index 235  */
395 {12,  1,  0,  640,  6,  1,  2,  4 }, /* index 236  */
396 {12,  1,  0,  792,  0,  1,  3,  4 }, /* index 237  */
397 {12,  1,  0,  792,  0,  2,  3,  4 }, /* index 238  */
398 {12,  1,  0,  682,  0,  1,  3,  4 }, /* index 239  */
399 {12,  1,  0, 1023,  6,  1,  2,  4 }, /* index 240  */
400 {13,  2,  1,  512,  0,  1,  2,  6 }, /* index 241  */
401 {13,  2,  1,  528,  2,  1,  2,  6 }, /* index 242  */
402 {13,  2,  1,  640,  0,  1,  2,  6 }, /* index 243  */
403 {13,  2,  1,  640,  2,  1,  2,  6 }, /* index 244  */
404 {13,  2,  1,  528,  0,  2,  2,  6 }, /* index 245  */
405 {13,  2,  1,  768,  0,  2,  2,  6 }, /* index 246  */
406 {13,  1,  0,  512,  0,  2,  2,  6 }, /* index 247  */
407 {13,  1,  0,  512,  2,  1,  2,  6 }, /* index 248  */
408 {13,  1,  0,  512,  0,  1,  2,  6 }, /* index 249  */
409 {13,  1,  0,  768,  0,  2,  2,  6 }, /* index 250  */
410 {13,  1,  0,  528,  0,  1,  2,  6 }, /* index 251  */
411 {13,  1,  0,  640,  2,  1,  2,  6 }, /* index 252  */
412 {13,  1,  0,  792,  0,  2,  2,  6 }, /* index 253  */
413 {13,  1,  0,  682,  0,  1,  2,  6 }, /* index 254  */
414 {13,  1,  0, 1023,  2,  1,  2,  6 }  /* index 255  */
415 };
416
417 #else
418 /* prach config index Table 6.3.3.2-2 spec 38.211 
419  * PRACH format given as follows:
420  * 0 = 0
421  * 1 = 1
422  * 2 = 2
423  * 3 = 3
424  * 4 = A1
425  * 5 = A2
426  * 6 = A3
427  * 7 = B1
428  * 8 = B4
429  * 9 = C0
430  * 10 = C2
431  * 11 = A1/B1
432  * 12 = A2/B2
433  * 13 = A3/B3 
434  * Subframe num is represented considering 0-9 bits and
435  * value 1 corresponds to the subframe that is valid 
436  */
437
438 uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8] = {
439 { 0, 16,  1,    2,  0,  0,  0,  0 }, /* index 0   */
440 { 0, 16,  1,   16,  0,  0,  0,  0 }, /* index 1   */
441 { 0, 16,  1,  128,  0,  0,  0,  0 }, /* index 2   */
442 { 0, 16,  1,  512,  0,  0,  0,  0 }, /* index 3   */
443 { 0,  8,  1,    2,  0,  0,  0,  0 }, /* index 4   */
444 { 0,  8,  1,   16,  0,  0,  0,  0 }, /* index 5   */
445 { 0,  8,  1,  128,  0,  0,  0,  0 }, /* index 6   */
446 { 0,  8,  1,  512,  0,  0,  0,  0 }, /* index 7   */
447 { 0,  4,  1,    2,  0,  0,  0,  0 }, /* index 8   */
448 { 0,  4,  1,   16,  0,  0,  0,  0 }, /* index 9   */
449 { 0,  4,  1,  128,  0,  0,  0,  0 }, /* index 10  */
450 { 0,  4,  1,  512,  0,  0,  0,  0 }, /* index 11  */
451 { 0,  2,  1,    2,  0,  0,  0,  0 }, /* index 12  */
452 { 0,  2,  1,   16,  0,  0,  0,  0 }, /* index 13  */
453 { 0,  2,  1,  128,  0,  0,  0,  0 }, /* index 14  */
454 { 0,  2,  1,  512,  0,  0,  0,  0 }, /* index 15  */
455 { 0,  1,  0,    2,  0,  0,  0,  0 }, /* index 16  */
456 { 0,  1,  0,   16,  0,  0,  0,  0 }, /* index 17  */
457 { 0,  1,  0,  128,  0,  0,  0,  0 }, /* index 18  */
458 { 0,  1,  0,   66,  0,  0,  0,  0 }, /* index 19  */
459 { 0,  1,  0,  132,  0,  0,  0,  0 }, /* index 20  */
460 { 0,  1,  0,  264,  0,  0,  0,  0 }, /* index 21  */
461 { 0,  1,  0,  146,  0,  0,  0,  0 }, /* index 22  */
462 { 0,  1,  0,  292,  0,  0,  0,  0 }, /* index 23  */
463 { 0,  1,  0,  584,  0,  0,  0,  0 }, /* index 24  */
464 { 0,  1,  0,  341,  0,  0,  0,  0 }, /* index 25  */
465 { 0,  1,  0,  682,  0,  0,  0,  0 }, /* index 26  */
466 { 0,  1,  0, 1023,  0,  0,  0,  0 }, /* index 27  */
467 { 1, 16,  1,    2,  0,  0,  0,  0 }, /* index 28  */
468 { 1, 16,  1,   16,  0,  0,  0,  0 }, /* index 29  */
469 { 1, 16,  1,  128,  0,  0,  0,  0 }, /* index 30  */
470 { 1, 16,  1,  512,  0,  0,  0,  0 }, /* index 31  */
471 { 1,  8,  1,    2,  0,  0,  0,  0 }, /* index 32  */
472 { 1,  8,  1,   16,  0,  0,  0,  0 }, /* index 33  */
473 { 1,  8,  1,  128,  0,  0,  0,  0 }, /* index 34  */
474 { 1,  8,  1,  512,  0,  0,  0,  0 }, /* index 35  */
475 { 1,  4,  1,    2,  0,  0,  0,  0 }, /* index 36  */
476 { 1,  4,  1,   16,  0,  0,  0,  0 }, /* index 37  */
477 { 1,  4,  1,  128,  0,  0,  0,  0 }, /* index 38  */
478 { 1,  4,  1,  512,  0,  0,  0,  0 }, /* index 39  */
479 { 1,  2,  1,    2,  0,  0,  0,  0 }, /* index 40  */
480 { 1,  2,  1,   16,  0,  0,  0,  0 }, /* index 41  */
481 { 1,  2,  1,  128,  0,  0,  0,  0 }, /* index 42  */
482 { 1,  2,  1,  512,  0,  0,  0,  0 }, /* index 43  */
483 { 1,  1,  0,    2,  0,  0,  0,  0 }, /* index 44  */
484 { 1,  1,  0,   16,  0,  0,  0,  0 }, /* index 45  */
485 { 1,  1,  0,  128,  0,  0,  0,  0 }, /* index 46  */
486 { 1,  1,  0,   64,  0,  0,  0,  0 }, /* index 47  */
487 { 1,  1,  0,  132,  0,  0,  0,  0 }, /* index 48  */
488 { 1,  1,  0,  264,  0,  0,  0,  0 }, /* index 49  */
489 { 1,  1,  0,  146,  0,  0,  0,  0 }, /* index 50  */
490 { 1,  1,  0,  292,  0,  0,  0,  0 }, /* index 51  */
491 { 1,  1,  0,  584,  0,  0,  0,  0 }, /* index 52  */
492 { 2, 16,  1,    2,  0,  0,  0,  0 }, /* index 53  */
493 { 2,  8,  1,    2,  0,  0,  0,  0 }, /* index 54  */
494 { 2,  4,  0,    2,  0,  0,  0,  0 }, /* index 55  */
495 { 2,  2,  0,    2,  0,  0,  0,  0 }, /* index 56  */
496 { 2,  2,  0,   32,  0,  0,  0,  0 }, /* index 57  */
497 { 2,  1,  0,    2,  0,  0,  0,  0 }, /* index 58  */
498 { 2,  1,  0,   32,  0,  0,  0,  0 }, /* index 59  */
499 { 3, 16,  1,    2,  0,  0,  0,  0 }, /* index 60  */
500 { 3, 16,  1,   16,  0,  0,  0,  0 }, /* index 61  */
501 { 3, 16,  1,  128,  0,  0,  0,  0 }, /* index 62  */
502 { 3, 16,  1,  512,  0,  0,  0,  0 }, /* index 63  */
503 { 3,  8,  1,    2,  0,  0,  0,  0 }, /* index 64  */
504 { 3,  8,  1,   16,  0,  0,  0,  0 }, /* index 65  */
505 { 3,  8,  1,  128,  0,  0,  0,  0 }, /* index 66  */
506 { 3,  4,  1,    2,  0,  0,  0,  0 }, /* index 67  */
507 { 3,  4,  1,   16,  0,  0,  0,  0 }, /* index 68  */
508 { 3,  4,  1,  128,  0,  0,  0,  0 }, /* index 69  */
509 { 3,  4,  1,  512,  0,  0,  0,  0 }, /* index 70  */
510 { 3,  2,  1,    2,  0,  0,  0,  0 }, /* index 71  */
511 { 3,  2,  1,   16,  0,  0,  0,  0 }, /* index 72  */
512 { 3,  2,  1,  128,  0,  0,  0,  0 }, /* index 73  */
513 { 3,  2,  1,  512,  0,  0,  0,  0 }, /* index 74  */
514 { 3,  1,  0,    2,  0,  0,  0,  0 }, /* index 75  */
515 { 3,  1,  0,   16,  0,  0,  0,  0 }, /* index 76  */
516 { 3,  1,  0,  128,  0,  0,  0,  0 }, /* index 77  */
517 { 3,  1,  0,   66,  0,  0,  0,  0 }, /* index 78  */
518 { 3,  1,  0,  132,  0,  0,  0,  0 }, /* index 79  */
519 { 3,  1,  0,  264,  0,  0,  0,  0 }, /* index 80  */
520 { 3,  1,  0,  146,  0,  0,  0,  0 }, /* index 81  */
521 { 3,  1,  0,  292,  0,  0,  0,  0 }, /* index 82  */
522 { 3,  1,  0,  584,  0,  0,  0,  0 }, /* index 83  */
523 { 3,  1,  0,  341,  0,  0,  0,  0 }, /* index 84  */
524 { 3,  1,  0,  682,  0,  0,  0,  0 }, /* index 85  */
525 { 3,  1,  0, 1023,  0,  0,  0,  0 }, /* index 86  */
526 { 4, 16,  0,  528,  0,  1,  6,  2 }, /* index 87  */
527 { 4, 16,  1,   16,  0,  2,  6,  2 }, /* index 88  */
528 { 4,  8,  0,  528,  0,  1,  6,  2 }, /* index 89  */
529 { 4,  8,  1,   16,  0,  2,  6,  2 }, /* index 90  */
530 { 4,  4,  0,  528,  0,  1,  6,  2 }, /* index 91  */
531 { 4,  4,  1,  528,  0,  1,  6,  2 }, /* index 92  */
532 { 4,  4,  0,   16,  0,  2,  6,  2 }, /* index 93  */
533 { 4,  2,  0,  528,  0,  1,  6,  2 }, /* index 94  */
534 { 4,  2,  0,    2,  0,  2,  6,  2 }, /* index 95  */
535 { 4,  2,  0,   16,  0,  2,  6,  2 }, /* index 96  */
536 { 4,  2,  0,  128,  0,  2,  6,  2 }, /* index 97  */
537 { 4,  1,  0,   16,  0,  1,  6,  2 }, /* index 98  */
538 { 4,  1,  0,   66,  0,  1,  6,  2 }, /* index 99  */
539 { 4,  1,  0,  528,  0,  1,  6,  2 }, /* index 100  */
540 { 4,  1,  0,    2,  0,  2,  6,  2 }, /* index 101  */
541 { 4,  1,  0,  128,  0,  2,  6,  2 }, /* index 102  */
542 { 4,  1,  0,  132,  0,  2,  6,  2 }, /* index 103  */
543 { 4,  1,  0,  146,  0,  2,  6,  2 }, /* index 104  */
544 { 4,  1,  0,  341,  0,  2,  6,  2 }, /* index 105  */
545 { 4,  1,  0, 1023,  0,  2,  6,  2 }, /* index 106  */
546 { 4,  1,  0,  682,  0,  2,  6,  2 }, /* index 107  */
547 {11,  2,  0,  528,  0,  1,  7,  2 }, /* index 108  */
548 {11,  2,  0,   16,  0,  2,  7,  2 }, /* index 109  */
549 {11,  1,  0,   16,  0,  1,  7,  2 }, /* index 110  */
550 {11,  1,  0,   66,  0,  1,  7,  2 }, /* index 111  */
551 {11,  1,  0,  528,  0,  1,  7,  2 }, /* index 112  */
552 {11,  1,  0,    2,  0,  2,  7,  2 }, /* index 113  */
553 {11,  1,  0,  128,  0,  2,  7,  2 }, /* index 114  */
554 {11,  1,  0,  146,  0,  2,  7,  2 }, /* index 115  */
555 {11,  1,  0,  341,  0,  2,  7,  2 }, /* index 116  */
556 { 5, 16,  1,  580,  0,  1,  3,  4 }, /* index 117  */
557 { 5, 16,  1,   16,  0,  2,  3,  4 }, /* index 118  */
558 { 5,  8,  1,  580,  0,  1,  3,  4 }, /* index 119  */
559 { 5,  8,  1,   16,  0,  2,  3,  4 }, /* index 120  */
560 { 5,  4,  0,  580,  0,  1,  3,  4 }, /* index 121  */
561 { 5,  4,  0,   16,  0,  2,  3,  4 }, /* index 122  */
562 { 5,  2,  1,  580,  0,  1,  3,  4 }, /* index 123  */
563 { 5,  2,  0,    2,  0,  2,  3,  4 }, /* index 124  */
564 { 5,  2,  0,   16,  0,  2,  3,  4 }, /* index 125  */
565 { 5,  2,  0,  128,  0,  2,  3,  4 }, /* index 126  */
566 { 5,  1,  0,   16,  0,  1,  3,  4 }, /* index 127  */
567 { 5,  1,  0,   66,  0,  1,  3,  4 }, /* index 128  */
568 { 5,  1,  0,  528,  0,  1,  3,  4 }, /* index 129  */
569 { 5,  1,  0,    2,  0,  2,  3,  4 }, /* index 130  */
570 { 5,  1,  0,  128,  0,  2,  3,  4 }, /* index 131  */
571 { 5,  1,  0,  132,  0,  2,  3,  4 }, /* index 132  */
572 { 5,  1,  0,  146,  0,  2,  3,  4 }, /* index 133  */
573 { 5,  1,  0,  341,  0,  2,  3,  4 }, /* index 134  */
574 { 5,  1,  0, 1023,  0,  2,  3,  4 }, /* index 135  */
575 { 5,  1,  0,  682,  0,  2,  3,  4 }, /* index 136  */
576 {12,  2,  1,  580,  0,  1,  3,  4 }, /* index 137  */
577 {12,  2,  0,   16,  0,  2,  3,  4 }, /* index 138  */
578 {12,  1,  0,   16,  0,  1,  3,  4 }, /* index 139  */
579 {12,  1,  0,   66,  0,  1,  3,  4 }, /* index 140  */
580 {12,  1,  0,  528,  0,  1,  3,  4 }, /* index 141  */
581 {12,  1,  0,    2,  0,  2,  3,  4 }, /* index 142  */
582 {12,  1,  0,  128,  0,  2,  3,  4 }, /* index 143  */
583 {12,  1,  0,  146,  0,  2,  3,  4 }, /* index 144  */
584 {12,  1,  0,  341,  0,  2,  3,  4 }, /* index 145  */
585 {12,  1,  0, 1023,  0,  2,  3,  4 }, /* index 146  */
586 { 6, 16,  1,  528,  0,  1,  2,  6 }, /* index 147  */
587 { 6, 16,  1,   16,  0,  2,  2,  6 }, /* index 148  */
588 { 6,  8,  1,  528,  0,  1,  2,  6 }, /* index 149  */
589 { 6,  8,  1,   16,  0,  2,  2,  6 }, /* index 150  */
590 { 6,  4,  0,  528,  0,  1,  2,  6 }, /* index 151  */
591 { 6,  4,  0,   16,  0,  2,  2,  6 }, /* index 152  */
592 { 6,  2,  1,  580,  0,  2,  2,  6 }, /* index 153  */
593 { 6,  2,  0,    2,  0,  2,  2,  6 }, /* index 154  */
594 { 6,  2,  0,   16,  0,  2,  2,  6 }, /* index 155  */
595 { 6,  2,  0,  128,  0,  2,  2,  6 }, /* index 156  */
596 { 6,  1,  0,   16,  0,  1,  2,  6 }, /* index 157  */
597 { 6,  1,  0,   66,  0,  1,  2,  6 }, /* index 158  */
598 { 6,  1,  0,  528,  0,  1,  2,  6 }, /* index 159  */
599 { 6,  1,  0,    2,  0,  2,  2,  6 }, /* index 160  */
600 { 6,  1,  0,  128,  0,  2,  2,  6 }, /* index 161  */
601 { 6,  1,  0,  132,  0,  2,  2,  6 }, /* index 162  */
602 { 6,  1,  0,  146,  0,  2,  2,  6 }, /* index 163  */
603 { 6,  1,  0,  341,  0,  2,  2,  6 }, /* index 164  */
604 { 6,  1,  0, 1023,  0,  2,  2,  6 }, /* index 165  */
605 { 6,  1,  0,  682,  0,  2,  2,  6 }, /* index 166  */
606 {13,  2,  1,  580,  0,  2,  2,  6 }, /* index 167  */
607 {13,  2,  0,   16,  0,  2,  2,  6 }, /* index 168  */
608 {13,  1,  0,   16,  0,  1,  2,  6 }, /* index 169  */
609 {13,  1,  0,   66,  0,  1,  2,  6 }, /* index 170  */
610 {13,  1,  0,  528,  0,  1,  2,  6 }, /* index 171  */
611 {13,  1,  0,    2,  0,  2,  2,  6 }, /* index 172  */
612 {13,  1,  0,  128,  0,  2,  2,  6 }, /* index 173  */
613 {13,  1,  0,  146,  0,  2,  2,  6 }, /* index 174  */
614 {13,  1,  0,  341,  0,  2,  2,  6 }, /* index 175  */
615 {13,  1,  0, 1023,  0,  2,  2,  6 }, /* index 176  */
616 { 7, 16,  0,  528,  0,  1,  7,  2 }, /* index 177  */
617 { 7, 16,  1,   16,  0,  2,  7,  2 }, /* index 178  */
618 { 7,  8,  0,  528,  0,  1,  7,  2 }, /* index 179  */
619 { 7,  8,  1,   16,  0,  2,  7,  2 }, /* index 180  */
620 { 7,  4,  0,  528,  0,  1,  7,  2 }, /* index 181  */
621 { 7,  4,  1,  528,  0,  1,  7,  2 }, /* index 182  */
622 { 7,  4,  0,   16,  0,  2,  7,  2 }, /* index 183  */
623 { 7,  2,  0,  528,  0,  1,  7,  2 }, /* index 184  */
624 { 7,  2,  0,    2,  0,  2,  7,  2 }, /* index 185  */
625 { 7,  2,  0,   16,  0,  2,  7,  2 }, /* index 186  */
626 { 7,  2,  0,  128,  0,  2,  7,  2 }, /* index 187  */
627 { 7,  1,  0,   16,  0,  1,  7,  2 }, /* index 188  */
628 { 7,  1,  0,   66,  0,  1,  7,  2 }, /* index 189  */
629 { 7,  1,  0,  528,  0,  1,  7,  2 }, /* index 190  */
630 { 7,  1,  0,    2,  0,  2,  7,  2 }, /* index 191  */
631 { 7,  1,  0,  128,  0,  2,  7,  2 }, /* index 192  */
632 { 7,  1,  0,  132,  0,  2,  7,  2 }, /* index 193  */
633 { 7,  1,  0,  146,  0,  2,  7,  2 }, /* index 194  */
634 { 7,  1,  0,  341,  0,  2,  7,  2 }, /* index 195  */
635 { 7,  1,  0, 1023,  0,  2,  7,  2 }, /* index 196  */
636 { 7,  1,  0,  682,  0,  2,  7,  2 }, /* index 197  */
637 { 8, 16,  0,  528,  0,  2,  1, 12 }, /* index 198  */
638 { 8, 16,  1,   16,  0,  2,  1, 12 }, /* index 199  */
639 { 8,  8,  0,  528,  0,  2,  1, 12 }, /* index 200  */
640 { 8,  8,  1,   16,  0,  2,  1, 12 }, /* index 201  */
641 { 8,  4,  0,  528,  0,  2,  1, 12 }, /* index 202  */
642 { 8,  4,  0,   16,  0,  2,  1, 12 }, /* index 203  */
643 { 8,  4,  1,  528,  0,  2,  1, 12 }, /* index 204  */
644 { 8,  2,  0,  528,  0,  2,  1, 12 }, /* index 205  */
645 { 8,  2,  0,    2,  0,  2,  1, 12 }, /* index 206  */
646 { 8,  2,  0,   16,  0,  2,  1, 12 }, /* index 207  */
647 { 8,  2,  0,  128,  0,  2,  1, 12 }, /* index 208  */
648 { 8,  1,  0,    2,  0,  2,  1, 12 }, /* index 209  */
649 { 8,  1,  0,   16,  0,  2,  1, 12 }, /* index 210  */
650 { 8,  1,  0,  128,  0,  2,  1, 12 }, /* index 211  */
651 { 8,  1,  0,   66,  0,  2,  1, 12 }, /* index 212  */
652 { 8,  1,  0,  132,  0,  2,  1, 12 }, /* index 213  */
653 { 8,  1,  0,  528,  0,  2,  1, 12 }, /* index 214  */
654 { 8,  1,  0,  146,  0,  2,  1, 12 }, /* index 215  */
655 { 8,  1,  0,  341,  0,  2,  1, 12 }, /* index 216  */
656 { 8,  1,  0, 1023,  0,  2,  1, 12 }, /* index 217  */
657 { 8,  1,  0,  682,  0,  2,  1, 12 }, /* index 218  */
658 { 9,  8,  1,   16,  0,  2,  7,  2 }, /* index 219  */
659 { 9,  4,  1,  528,  0,  1,  7,  2 }, /* index 220  */
660 { 9,  4,  0,   16,  0,  2,  7,  2 }, /* index 221  */
661 { 9,  2,  0,  528,  0,  1,  7,  2 }, /* index 222  */
662 { 9,  2,  0,    2,  0,  2,  7,  2 }, /* index 223  */
663 { 9,  2,  0,   16,  0,  2,  7,  2 }, /* index 224  */
664 { 9,  2,  0,  128,  0,  2,  7,  2 }, /* index 225  */
665 { 9,  1,  0,   16,  0,  1,  7,  2 }, /* index 226  */
666 { 9,  1,  0,   66,  0,  1,  7,  2 }, /* index 227  */
667 { 9,  1,  0,  528,  0,  1,  7,  2 }, /* index 228  */
668 { 9,  1,  0,    2,  0,  2,  7,  2 }, /* index 229  */
669 { 9,  1,  0,  128,  0,  2,  7,  2 }, /* index 230  */
670 { 9,  1,  0,  132,  0,  2,  7,  2 }, /* index 231  */
671 { 9,  1,  0,  146,  0,  2,  7,  2 }, /* index 232  */
672 { 9,  1,  0,  341,  0,  2,  7,  2 }, /* index 233  */
673 { 9,  1,  0, 1023,  0,  2,  7,  2 }, /* index 234  */
674 { 9,  1,  0,  682,  0,  2,  7,  2 }, /* index 235  */
675 {10, 16,  1,  528,  0,  1,  2,  6 }, /* index 236  */
676 {10, 16,  1,   16,  0,  2,  2,  6 }, /* index 237  */
677 {10,  8,  1,  528,  0,  1,  2,  6 }, /* index 238  */
678 {10,  8,  1,   16,  0,  2,  2,  6 }, /* index 239  */
679 {10,  4,  0,  528,  0,  1,  2,  6 }, /* index 240  */
680 {10,  4,  0,   16,  0,  2,  2,  6 }, /* index 241  */
681 {10,  2,  1,  580,  0,  2,  2,  6 }, /* index 242  */
682 {10,  2,  0,    2,  0,  2,  2,  6 }, /* index 243  */
683 {10,  2,  0,   16,  0,  2,  2,  6 }, /* index 244  */
684 {10,  2,  0,  128,  0,  2,  2,  6 }, /* index 245  */
685 {10,  1,  0,   16,  0,  1,  2,  6 }, /* index 246  */
686 {10,  1,  0,   66,  0,  1,  2,  6 }, /* index 247  */
687 {10,  1,  0,  528,  0,  1,  2,  6 }, /* index 248  */
688 {10,  1,  0,    2,  0,  2,  2,  6 }, /* index 249  */
689 {10,  1,  0,  128,  0,  2,  2,  6 }, /* index 250  */
690 {10,  1,  0,  132,  0,  2,  2,  6 }, /* index 251  */
691 {10,  1,  0,  146,  0,  2,  2,  6 }, /* index 252  */
692 {10,  1,  0,  341,  0,  2,  2,  6 }, /* index 253  */
693 {10,  1,  0, 1023,  0,  2,  2,  6 }, /* index 254  */
694 {10,  1,  0,  682,  0,  2,  2,  6 }  /* index 255  */
695 };
696 #endif
697
698 /* Defintion of delta value Table 6.1.2.1.1-5 spec 38.214 */
699 uint8_t puschDeltaTable[MAX_MU_PUSCH] = { 2, 3, 4, 6 };
700
701 uint16_t tbSizeTable[TOTAL_TBSIZE_VALUES] = {
702          24,    32,    40,    48,    56,    64,    72,    80,    88,    96, \
703         104,   112,   120,   128,   136,   144,   152,   160,   168,   176, \
704         184,   192,   208,   224,   240,   256,   272,   288,   304,   320, \
705         336,   352,   368,   384,   408,   432,   456,   480,   504,   528, \
706         552,   576,   608,   640,   672,   704,   736,   768,   808,   848, \
707         888,   928,   984,  1032,  1064,  1128,  1160,  1192,  1224,  1256, \
708        1288,  1320,  1352,  1416,  1480,  1544,  1608,  1672,  1736,  1800, \
709        1864,  1928,  2024,  2088,  2152,  2216,  2280,  2408,  2472,  2536, \
710        2600,  2664,  2728,  2792,  2856,  2976,  3104,  3240,  3368,  3496, \
711        3624,  3752,  3824 };
712
713 uint16_t mcsTable[32][3] = {
714       {   0,   2,   120},   /* mcs index  0 */ 
715       {   1,   2,   157},   /* mcs index  1 */ 
716       {   2,   2,   193},   /* mcs index  2 */ 
717       {   3,   2,   251},   /* mcs index  3 */ 
718       {   4,   2,   308},   /* mcs index  4 */ 
719       {   5,   2,   379},   /* mcs index  5 */ 
720       {   6,   2,   449},   /* mcs index  6 */ 
721       {   7,   2,   526},   /* mcs index  7 */ 
722       {   8,   2,   602},   /* mcs index  8 */ 
723       {   9,   2,   679},   /* mcs index  9 */ 
724       {  10,   4,   340},   /* mcs index 10 */ 
725       {  11,   4,   378},   /* mcs index 11 */ 
726       {  12,   4,   434},   /* mcs index 12 */ 
727       {  13,   4,   490},   /* mcs index 13 */ 
728       {  14,   4,   553},   /* mcs index 14 */ 
729       {  15,   4,   616},   /* mcs index 15 */
730       {  16,   4,   658},   /* mcs index 16 */
731       {  17,   6,   438},   /* mcs index 17 */
732       {  18,   6,   466},   /* mcs index 18 */
733       {  19,   6,   517},   /* mcs index 19 */
734       {  20,   6,   567},   /* mcs index 20 */
735       {  21,   6,   616},   /* mcs index 21 */
736       {  22,   6,   666},   /* mcs index 22 */
737       {  23,   6,   719},   /* mcs index 23 */
738       {  24,   6,   772},   /* mcs index 24 */
739       {  25,   6,   822},   /* mcs index 25 */
740       {  26,   6,   873},   /* mcs index 26 */
741       {  27,   6,   910},   /* mcs index 27 */
742       {  28,   6,   948},   /* mcs index 28 */
743       {  29,   2,     0},   /* mcs index 29 */
744       {  30,   4,     0},   /* mcs index 30 */
745       {  31,   6,     0}};  /* mcs index 31 */
746
747 /* PUCCH resource sets before dedicated PUCCH resource configuration */
748 /* Table 9.2.1-1 spec 38.213      */ 
749 uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4] = {
750 { 0,  12,  2,  0 }, /* index  0 */
751 { 0,  12,  2,  0 }, /* index  1 */
752 { 0,  12,  2,  3 }, /* index  2 */
753 { 1,  10,  4,  0 }, /* index  3 */
754 { 1,  10,  4,  0 }, /* index  4 */
755 { 1,  10,  4,  2 }, /* index  5 */
756 { 1,  10,  4,  4 }, /* index  6 */
757 { 1,   4, 10,  0 }, /* index  7 */
758 { 1,   4, 10,  0 }, /* index  8 */
759 { 1,   4, 10,  2 }, /* index  9 */
760 { 1,   4, 10,  4 }, /* index 10 */
761 { 1,   0, 14,  0 }, /* index 11 */
762 { 1,   0, 14,  0 }, /* index 12 */
763 { 1,   0, 14,  2 }, /* index 13 */
764 { 1,   0, 14,  4 }, /* index 14 */
765 { 1,   0, 14,  0 }, /* index 15 */
766 };
767
768 uint8_t defaultUlAckTbl[DEFAULT_UL_ACK_LIST_COUNT]= {1, 2, 3 , 4, 5, 6, 7, 8};
769 /**
770  * @brief frequency domain allocation function. 
771  *
772  * @details
773  *
774  *     Function: schCalcTbSize
775  *     
776  *     This function finds the TBSize from table Table 5.1.3.2-1 spec 38.214
777  *     
778  *  @param[in]  payLoadSize - size of payload in bytes
779  *  @return     TBsize from the Table in bytes
780  **/
781 uint16_t schCalcTbSize(uint32_t payLoadSize)
782 {
783    uint8_t tbsIndex = 0;
784    uint16_t maxTbSize;
785
786    maxTbSize = tbSizeTable[TOTAL_TBSIZE_VALUES -1]/8;
787    if(payLoadSize >= maxTbSize)
788       return maxTbSize;
789
790    payLoadSize = payLoadSize*8;
791    while(payLoadSize > tbSizeTable[tbsIndex])
792    {
793       tbsIndex++;
794    }
795
796    /* return the TBsize in bytes */
797    return (tbSizeTable[tbsIndex]/8);
798 }
799
800 /**
801  * @brief frequency domain allocation function. 
802  *
803  * @details
804  *
805  *     Function: schCalcNumPrb
806  *     
807  *     This function calculates the number of PRbs 
808  *     
809  *  @param[in]  tbSize in bytes
810  *  @param[in]  mcs
811  *  @param[in]  number of symbols
812  *  @return   number PRBs
813  **/
814 uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols)
815 {
816    uint16_t numPrb = 0;
817    uint16_t nre = 0;
818    uint16_t nreDash = 0;
819    uint8_t  qm     = mcsTable[mcs][1];
820    uint16_t rValue = mcsTable[mcs][2];
821    uint8_t  numLayer = 1;       /* v value */
822    uint8_t  numDmrsRePerPrb = 12;
823
824    tbSize = tbSize * 8; //Calculate tbSize in bits
825
826    /* formula used for calculation of rbSize, 38.214 section 5.1.3.2 *
827     * Ninfo = S . Nre . R . Qm . v                                       *
828     * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh                       *
829     * Nre = min(156,Nre') . nPrb                                     */
830
831    nre = ceil( (float)tbSize * 1024 / (qm * rValue * numLayer));
832
833    nreDash = ceil( (12 * numSymbols) - numDmrsRePerPrb - 0);
834
835    if (nreDash > 156)
836       nre = 156;
837
838    numPrb = ceil((float)nre / nreDash);   
839    return numPrb;
840 }
841
842 /**
843 * @brief calculation of transport block size.
844 *
845 * @details
846 *
847 *     Function: schCalcTbSizeFromNPrb
848 *
849 *     This function calculates the transport block size
850 *
851 *  @param[in]  nPrb is num PRB
852 *  @param[in]  mcs
853 *  @param[in]  number of symbols
854 *  @return   tbSize
855 **/
856 uint16_t schCalcTbSizeFromNPrb(uint16_t numPrb, uint16_t mcs, uint8_t numSymbols)
857 {   
858    uint8_t  qm     = mcsTable[mcs][1];
859    uint16_t rValue = mcsTable[mcs][2];
860    uint16_t tbsIndex = 0;
861    uint32_t tbSize = 0;
862    uint32_t nre = 0;
863    uint32_t nreDash = 0;
864    uint32_t nInfo = 0;
865    uint32_t n = 0;
866    uint32_t nInfoDash = 0;
867    uint32_t c = 0;
868    const uint8_t  numLayer = 1;
869    const uint16_t numRbSc = 12;
870    const uint16_t numDmrsRes = 12;
871    const uint16_t sf = 1;
872 //   uint16_t numPrbOvrHead = 0;
873    
874   /* formula used for calculation of rbSize, 38.214 section 5.1.3.2  *
875    * Ninfo = Nre . R . Qm . v   where [ NInfo is tbSize]             *
876    * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh                        *
877    * Nre = min(156,Nre') . nPrb                                      */
878
879    nreDash = MIN(156, ceil( (numRbSc * numSymbols) - numDmrsRes - 0));
880    nre = nreDash * numPrb;
881    nInfo = ceil(nre * qm * numLayer * rValue/(1024.0 * sf));
882
883    if(nInfo <= 3824)
884    {
885       n = MAX(3, (uint32_t)cmLog2(nInfo) - 6);
886       nInfoDash = MAX(24, (1<<n)*(nInfo/(1<<n)));
887       while(nInfoDash > tbSizeTable[tbsIndex])
888       {
889          tbsIndex++;
890       }
891       tbSize = tbSizeTable[tbsIndex];
892    }
893    else
894    {
895       n = (uint32_t)cmLog2(nInfo - 24) - 5;
896       nInfoDash = MAX(3840, (1<<n)*ceil((nInfo - 24)/(1<<n)));
897
898       if(rValue<256)
899       {
900          c = ceil((nInfoDash + 24)/3816);
901          tbSize = 8 * c * ceil((nInfoDash + 24)/(8 * c)) - 24;
902       }
903       else
904       {
905          if(nInfoDash > 8424)
906          {
907             c = ceil((nInfoDash + 24)/8424);
908             tbSize = 8 * c * ceil((nInfoDash + 24)/(8 * c)) - 24;
909          }
910          else
911          {
912             tbSize = 8 * ceil((nInfoDash + 24)/(8)) - 24;
913          }
914       }
915    }
916    return tbSize;
917 }
918 /**
919  * @brief fetching ueCb from cellCb
920  *
921  * @details
922  *
923  *     Function: schGetUeCb
924  *
925  *     This function fetched UeCb based on crnti from cellCb
926  *
927  *  @param[in]  cellCb
928  *  @param[in]  crnti
929  *  @return     ueCb
930  **/
931 SchUeCb* schGetUeCb(SchCellCb *cellCb, uint16_t crnti)
932 {
933    uint16_t ueIdx;
934    GET_UE_IDX(crnti, ueIdx);
935    return &(cellCb->ueCb[ueIdx -1]);
936 }
937
938 /**
939  * @brief initialize UL slot info
940  *
941  * @details
942  *
943  *     Function: schInitUlSlot
944  *
945  *     This function intializes UL slot of the cell
946  *
947  *  @param[in]  schUlSlotInfo
948  *  @return     void
949  **/
950 void schInitUlSlot(SchUlSlotInfo *schUlSlotInfo)
951 {
952    memset(schUlSlotInfo, 0, sizeof(SchUlSlotInfo));
953    schUlSlotInfo->totalPrb = MAX_NUM_RB;
954    for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
955    {
956       schUlSlotInfo->assignedPrb[itr] = 0;
957    }
958    schUlSlotInfo->resAllocBitMap = 0;
959    schUlSlotInfo->puschCurrentPrb = PUSCH_START_RB;
960    schUlSlotInfo->schPuschInfo = NULLP;
961
962 }
963
964 /**
965  * @brief initialize DL slot info
966  *
967  * @details
968  *
969  *     Function: schInitDlSlot
970  *
971  *     This function intializes DL slot of the cell
972  *
973  *  @param[in]  schDlSlotInfo
974  *  @return     void
975  **/
976 void schInitDlSlot(SchDlSlotInfo *schDlSlotInfo)
977 {
978    memset(schDlSlotInfo, 0, sizeof(SchDlSlotInfo));
979    schDlSlotInfo->totalPrb = MAX_NUM_RB;
980    for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
981    {
982       schDlSlotInfo->assignedPrb[itr] = 0;
983    }
984    schDlSlotInfo->resAllocBitMap = 0; 
985    for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
986    {
987       memset(&schDlSlotInfo->ssbInfo[itr], 0, sizeof(SsbInfo));
988    }
989 #if 0
990    //make allocation for SSB
991    if(cell->firstSsbTransmitted)
992    {
993       //TODO check if this slot and sfn are for ssb
994
995    }
996 #endif
997 }
998
999 #ifdef NR_TDD
1000
1001 /**
1002  * @brief determines slot/symbol format
1003  *
1004  * @details
1005  *
1006  *     Function : schGetSlotSymbFrmt 
1007  *      
1008  *      This API is invoked to determine if current slot is DL or UL
1009  *           
1010  *  @param[in]  uint16_t slot
1011  *  @param[in]  uint32_t bitMap from cellCb
1012  *  @return  SlotConfig
1013  *      -# DL    - 0 
1014  *      -# UL    - 1
1015  *      -# FLEXI - 2
1016  **/
1017 SlotConfig schGetSlotSymbFrmt(uint16_t slot, uint32_t bitMap)
1018 {
1019    uint32_t offset = (slot)*2;
1020    return (bitMap & 0x3<<offset)>>offset;
1021 #if 0
1022    SlotConfig slotFrmt;
1023    int mask1 = 0, mask2 = 0;
1024
1025    slot = (slot%n)*2;//n num of slots in defined periodicity or num of symbols
1026    mask1 = 1<<(slot);
1027    mask2 = 1<<(slot+1);
1028    slotFrmt = ((mask1 & bitMap)>>slot) + (2*((mask2 & bitMap)>>(slot+1)));
1029
1030    //printf("\n\n\n\n*****FormatType:%d Slot:%d****\n\n\n\n", slotFrmt, slot/2);
1031
1032    return slotFrmt;
1033 #endif
1034 }
1035
1036 /**
1037  * @brief Determine total length of configured slot pattern for specific 
1038  *    periodicity for TDD
1039  *
1040  * @details
1041  *
1042  *     Function : calculateSlotPatternLength 
1043  *      
1044  *      Determine total length of configured slot pattern for specific periodicity based
1045  *      on slot duration for TDD
1046  *           
1047  *  @param[in]  uint8_t scs, uint8_t periodicity 
1048  *
1049  *  @return uint8_t slotPatternLength 
1050  **/
1051
1052 uint8_t calculateSlotPatternLength(uint8_t scs, uint8_t periodicity)
1053 {
1054    uint8_t slotPatternLength =0;
1055    float   slotDuration = 0;
1056    
1057    /* Calculating the slot duration with the help of SCS.
1058     * This will provides the slot duration in ms like 1, 0.5, 0.25, 0.125. 
1059     * If scs value is SCS_30KHZ its enum value is 1, 
1060     * slotDuration = pow(0.5, 1);
1061     * slotDuration = 0.5 */
1062
1063    slotDuration = pow(0.5,scs);
1064
1065    /* Calculating length of pattern based on Transmission Periodicity. 
1066     * If periodicity = TX_PRDCTY_MS_5,
1067     * slotPatternLength = 5/0.5 
1068     * slotPatternLength = 10 i.e. {length of slot pattern DDDDDDDFUU}*/
1069
1070    switch(periodicity)
1071    {
1072       case TX_PRDCTY_MS_0P5:
1073          slotPatternLength = 0.5/slotDuration;
1074          break;
1075       case TX_PRDCTY_MS_0P625:
1076          slotPatternLength = 0.625/slotDuration;
1077          break;
1078       case TX_PRDCTY_MS_1:
1079          slotPatternLength = 1/slotDuration;
1080          break;
1081       case TX_PRDCTY_MS_1P25:
1082          slotPatternLength = 1.25/slotDuration;
1083          break;
1084       case TX_PRDCTY_MS_2:
1085          slotPatternLength = 2/slotDuration;
1086          break;
1087       case TX_PRDCTY_MS_2P5:
1088          slotPatternLength = 2.5/slotDuration;
1089          break;
1090       case TX_PRDCTY_MS_5:
1091          slotPatternLength = 5/slotDuration;
1092          break;
1093       case TX_PRDCTY_MS_10:
1094          slotPatternLength = 10/slotDuration;
1095          break;
1096    }
1097    return slotPatternLength;
1098 }
1099 #endif
1100 /**********************************************************************
1101          End of file
1102 **********************************************************************/