* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fhi_lib / app / src / config.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 Intel.
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  * @brief
21  * @file
22  * @ingroup
23  * @author Intel Corporation
24  **/
25
26 #include <inttypes.h>
27 #include <immintrin.h>
28 #include "rte_common.h"
29 #include "config.h"
30 #include "common.h"
31 #include "debug.h"
32
33 #include <rte_ethdev.h>
34
35 #define MAX_LINE_SIZE 512
36 /* Configuration file maximum supported line length */
37
38 #define KEY_APP_MODE        "appMode"
39 #define KEY_XRAN_MODE       "xranMode"
40 #define KEY_XRAN_TECH       "xranRanTech"
41 #define KEY_MU_NUMBER       "mu"
42 #define KEY_NDLABSFREPOINTA "nDLAbsFrePointA"
43 #define KEY_NULABSFREPOINTA "nULAbsFrePointA"
44 #define KEY_NDLBANDWIDTH    "nDLBandwidth"
45 #define KEY_NULBANDWIDTH    "nULBandwidth"
46 #define KEY_NDLFFTSIZE      "nDLFftSize"
47 #define KEY_NULFFTSIZE      "nULFftSize"
48
49 #define KEY_DU_PORT_ID_BITWIDTH    "DU_Port_ID_bitwidth"
50 #define KEY_BANDSECTOR_ID_BITWIDTH "BandSector_ID_bitwidth"
51 #define KEY_CC_ID_BITWIDTH         "CC_ID_bitwidth"
52 #define KEY_RU_PORT_ID_BITWIDTH    "RU_Port_ID_bitwidth"
53
54 #define KEY_NFRAMEDUPLEXTYPE "nFrameDuplexType"
55 #define KEY_NTDDPERIOD       "nTddPeriod"
56
57 #define KEY_SSLOTCONFIG     "sSlotConfig"
58
59 #define KEY_XU_NUM          "oXuNum"
60 #define KEY_XU_ETH_LINK_SPD "oXuEthLinkSpeed"
61 #define KEY_XU_ETH_LINE_NUM "oXuLinesNumber"
62 #define KEY_XU_CP_ON_ONE_VF "oXuCPon1Vf"
63 #define KEY_XU_RXQ_VF       "oXuRxqNumber"
64 #define KEY_OWDM_INIT_EN    "oXuOwdmInitEn"
65 #define KEY_OWDM_MEAS_METH  "oXuOwdmMeasMeth"
66 #define KEY_OWDM_NUM_SAMPS  "oXuOwdmNumSamps"
67 #define KEY_OWDM_FLTR_TYPE  "oXuOwdmFltrType"
68 #define KEY_OWDM_RSP_TO     "oXuOwdmRespTimeOut"
69 #define KEY_OWDM_MEAS_ST    "oXuOwdmMeasState"
70 #define KEY_OWDM_MEAS_ID    "oXuOwdmMeasId"
71 #define KEY_OWDM_EN         "oXuOwdmEnabled"
72 #define KEY_OWDM_PL_LENGTH  "oXuOwdmPlLength"
73 #define KEY_CC_PER_PORT_NUM "ccNum"
74 #define KEY_ANT_NUM         "antNum"
75 #define KEY_UL_ANT_NUM      "antNumUL"
76
77 #define KEY_ANT_ELM_TRX_NUM "antElmTRx"
78
79 #define KEY_MU_MIMO_UES_NUM "muMimoUEs"
80 #define KEY_DLLAYERS_PER_UE "DlLayersPerUe"
81 #define KEY_ULLAYERS_PER_UE "UlLayersPerUe"
82 #define KEY_FILE_DLBFWUE    "DlBfwUe"
83 #define KEY_FILE_ULBFWUE    "UlBfwUe"
84
85 #define KEY_FILE_O_XU_CFG   "oXuCfgFile"
86 #define KEY_FILE_O_XU_BBU_CFG   "oXuBbuCfgFile"
87 #define KEY_O_XU_PCIE_BUS   "PciBusAddoXu"
88 #define KEY_O_XU_REM_MAC    "oXuRem"
89 #define KEY_DL_CP_BURST     "dlCpProcBurst"
90 #define KEY_XRAN_MLOG_DIS   "xranMlogDisable"
91
92 #define KEY_FILE_ULSRS      "antSrsC"
93
94
95 #define KEY_TTI_PERIOD      "ttiPeriod"
96
97 #define KEY_MTU_SIZE        "MTUSize"
98 #define KEY_MAIN_CORE        "mainCore"
99 #define KEY_IO_CORE         "ioCore"
100 #define KEY_IO_WORKER       "ioWorker"
101 #define KEY_IO_WORKER_64_127 "ioWorker_64_127"
102 #define KEY_IO_SLEEP        "ioSleep"
103 #define KEY_SYSTEM_CORE     "systemCore"
104 #define KEY_IOVA_MODE       "iovaMode"
105 #define KEY_DPDK_MEM_SZ      "dpdkMemorySize"
106
107 #define KEY_INSTANCE_ID     "instanceId"
108
109 #define KEY_DU_MAC          "duMac"
110 #define KEY_RU_MAC          "ruMac"
111
112 #define KEY_FILE_NUMSLOTS   "numSlots"
113 #define KEY_FILE_AxC        "antC"
114 #define KEY_FILE_PRACH_AxC  "antPrachC"
115
116 #define KEY_FILE_SLOT_TX     "SlotNumTx"
117 #define KEY_FILE_SLOT_RX     "SlotNumRx"
118
119 #define KEY_PRACH_ENABLE   "rachEnable"
120 #define KEY_SRS_ENABLE     "srsEnable"
121 #define KEY_PUSCH_MASK_ENABLE "puschMaskEnable"
122 #define KEY_PUSCH_MASK_SLOT "puschMaskSlot"
123
124 #define KEY_PRACH_CFGIDX   "prachConfigIndex"
125 #define KEY_PRACH_CFGIDX_LTE   "prachConfigIndexLTE"
126 #define KEY_SRS_SYM_IDX    "srsSym"
127 #define KEY_SRS_SLOT        "srsSlot"
128 #define KEY_SRS_NDM_OFFSET  "srsNdmOffset"
129 #define KEY_SRS_NDM_TXDUR   "srsNdmTxDuration"
130
131 #define KEY_MAX_FRAME_ID   "maxFrameId"
132
133
134 #define KEY_IQ_SWAP        "iqswap"
135 #define KEY_HTONS_SWAP     "nebyteorderswap"
136 #define KEY_COMPRESSION    "compression"
137 #define KEY_COMP_TYPE      "compType"
138 #define KEY_PRACH_COMPMETH "prachCompMethod"
139 #define KEY_PRACH_IQ       "prachiqWidth"
140
141
142 #define KEY_BFW_NUM        "totalBFWeights"
143
144 #define KEY_TADV_CP_DL     "Tadv_cp_dl"
145 #define KEY_T2A_MIN_CP_DL  "T2a_min_cp_dl"
146 #define KEY_T2A_MAX_CP_DL  "T2a_max_cp_dl"
147 #define KEY_T2A_MIN_CP_UL  "T2a_min_cp_ul"
148 #define KEY_T2A_MAX_CP_UL  "T2a_max_cp_ul"
149 #define KEY_T2A_MIN_UP     "T2a_min_up"
150 #define KEY_T2A_MAX_UP     "T2a_max_up"
151 #define KEY_TA3_MIN        "Ta3_min"
152 #define KEY_TA3_MAX        "Ta3_max"
153 #define KEY_T1A_MIN_CP_DL  "T1a_min_cp_dl"
154 #define KEY_T1A_MAX_CP_DL  "T1a_max_cp_dl"
155 #define KEY_T1A_MIN_CP_UL  "T1a_min_cp_ul"
156 #define KEY_T1A_MAX_CP_UL  "T1a_max_cp_ul"
157 #define KEY_T1A_MIN_UP     "T1a_min_up"
158 #define KEY_T1A_MAX_UP     "T1a_max_up"
159 #define KEY_TA4_MIN        "Ta4_min"
160 #define KEY_TA4_MAX        "Ta4_max"
161
162
163 #define KEY_CP_ENABLE      "CPenable"
164 #define KEY_CP_VTAG        "c_plane_vlan_tag"
165 #define KEY_UP_VTAG        "u_plane_vlan_tag"
166 #define KEY_DEBUG_STOP     "debugStop"
167 #define KEY_DEBUG_STOP_CNT "debugStopCount"
168 #define KEY_BBDEV_MODE     "bbdevMode"
169 #define KEY_DYNA_SEC_ENA   "DynamicSectionEna"
170 #define EXT_TYPE           "extType"
171 #define KEY_ALPHA          "Gps_Alpha"
172 #define KEY_BETA           "Gps_Beta"
173
174 #define KEY_NPRBELEM_DL       "nPrbElemDl"
175 #define KEY_PRBELEM_DL        "PrbElemDl"
176 #define KEY_PRBELEM_DL_CC_M   "PrbElemDlCCMask"
177 #define KEY_PRBELEM_DL_ANT_M  "PrbElemDlAntCMask"
178 #define KEY_EXTBFW_DL         "ExtBfwDl"
179
180 #define KEY_NPRBELEM_UL       "nPrbElemUl"
181 #define KEY_PRBELEM_UL        "PrbElemUl"
182 #define KEY_PRBELEM_UL_CC_M   "PrbElemUlCCMask"
183 #define KEY_PRBELEM_UL_ANT_M  "PrbElemUlAntCMask"
184 #define KEY_EXTBFW_UL         "ExtBfwUl"
185 #define KEY_NPRBELEM_SRS       "nPrbElemSrs"
186 #define KEY_PRBELEM_SRS        "PrbElemSrs"
187 #define KEY_MAX_SEC_SYM        "max_sections_per_symbol"
188 #define KEY_MAX_SEC_SLOT       "max_sections_per_slot"
189 #define KEY_PRBMAP_BY_SYMB     "RunSlotPrbMapBySymbolEna"
190
191 #define KEY_DSS_ENABLE       "dssEnable"
192 #define KEY_DSS_PERIOD       "dssPeriod"
193 #define KEY_TECHNOLOGY       "technology"
194 typedef int (*fillConfigStruct_fn)(void* cbPram, const char *key, const char *value);
195
196 struct slot_cfg_to_pars {
197     RuntimeConfig *config;
198     int32_t direction;
199     int32_t slot_idx;
200 };
201
202 /**
203  * Set runtime configuration parameters to their defaults.
204  *
205  * @todo Initialize missing parameters.
206  */
207 //static void init_config(RuntimeConfig* config)
208 //{
209 //    memset(config , 0, sizeof(RuntimeConfig));
210 //}
211
212 static int32_t
213 parseFileViaCb (char *filename, fillConfigStruct_fn cbFn, void* cbParm);
214
215 /** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - **/
216
217 static void trim(char* input)
218 {
219     uint32_t i;
220     for (i = 0; i<strlen(input); i++)
221         if (input[i] == ' ' || input[i] == '\n' || input[i] == '\t')
222             input[i] = '\0';
223 }
224
225
226 static int fillConfigStruct(RuntimeConfig *config, const char *key, const char *value)
227 {
228     static uint32_t section_idx_dl  = 0;
229     static uint32_t section_idx_ul  = 0;
230     static uint32_t section_idx_srs = 0;
231
232     if (strcmp(key, KEY_APP_MODE) == 0){
233         config->appMode = atoi(value);
234     } else if (strcmp(key, KEY_XRAN_TECH) == 0) {
235         config->xranTech = atoi(value);
236     } else if (strcmp(key, KEY_XRAN_MODE) == 0) {
237         config->xranCat = atoi(value);
238     } else if (strcmp(key, KEY_CC_PER_PORT_NUM) == 0) {
239         config->numCC= atoi(value);
240     } else if (strcmp(key, KEY_MU_NUMBER) == 0) {
241         config->mu_number= atoi(value);
242         printf("mu_number: %d\n",config->mu_number);
243     } else if (strcmp(key, KEY_NDLABSFREPOINTA) == 0) {
244         config->nDLAbsFrePointA = atoi(value);
245         printf("nDLAbsFrePointA: %d\n",config->nDLAbsFrePointA);
246     } else if (strcmp(key, KEY_NULABSFREPOINTA) == 0) {
247         config->nULAbsFrePointA = atoi(value);
248         printf("nULAbsFrePointA: %d\n",config->nULAbsFrePointA);
249     } else if (strcmp(key, KEY_NDLBANDWIDTH) == 0) {
250         config->nDLBandwidth = atoi(value);
251         printf("nDLBandwidth: %d\n",config->nDLBandwidth);
252     } else if (strcmp(key, KEY_NULBANDWIDTH) == 0) {
253         config->nULBandwidth = atoi(value);
254         printf("nULBandwidth: %d\n",config->nULBandwidth);
255     } else if (strcmp(key, KEY_NDLFFTSIZE) == 0) {
256         config->nDLFftSize = atoi(value);
257         printf("nDLFftSize: %d\n",config->nDLFftSize);
258     } else if (strcmp(key, KEY_NULFFTSIZE) == 0) {
259         config->nULFftSize = atoi(value);
260         printf("nULFftSize: %d\n",config->nULFftSize);
261     } else if (strcmp(key, KEY_NFRAMEDUPLEXTYPE) == 0) {
262         config->nFrameDuplexType = atoi(value);
263         printf("nFrameDuplexType: %d\n",config->nFrameDuplexType);
264     } else if (strcmp(key, KEY_DU_PORT_ID_BITWIDTH) == 0) {
265         config->DU_Port_ID_bitwidth = atoi(value);
266         printf("DU_Port_ID_bitwidth: %d\n",config->DU_Port_ID_bitwidth);
267     } else if (strcmp(key, KEY_BANDSECTOR_ID_BITWIDTH) == 0) {
268         config->BandSector_ID_bitwidth = atoi(value);
269         printf("BandSector_ID_bitwidth: %d\n",config->BandSector_ID_bitwidth);
270     } else if (strcmp(key, KEY_CC_ID_BITWIDTH) == 0) {
271         config->CC_ID_bitwidth = atoi(value);
272         printf("CC_ID_bitwidth: %d\n",config->CC_ID_bitwidth);
273     } else if (strcmp(key, KEY_RU_PORT_ID_BITWIDTH) == 0) {
274         config->RU_Port_ID_bitwidth = atoi(value);
275         printf("RU_Port_ID_bitwidth: %d\n",config->RU_Port_ID_bitwidth);
276     } else if (strcmp(key, KEY_NTDDPERIOD) == 0) {
277         config->nTddPeriod = atoi(value);
278         printf("nTddPeriod: %d\n",config->nTddPeriod);
279         if (config->nTddPeriod > XRAN_MAX_TDD_PERIODICITY)
280         {
281             printf("nTddPeriod is larger than max allowed, invalid!\n");
282             config->nTddPeriod = XRAN_MAX_TDD_PERIODICITY;
283         }
284     } else if (strncmp(key, KEY_SSLOTCONFIG, strlen(KEY_SSLOTCONFIG)) == 0) {
285         unsigned int slot_num = 0;
286         int i = 0;
287         sscanf(key,"sSlotConfig%u",&slot_num);
288         if (slot_num >= config->nTddPeriod){
289             printf("slot_num %d exceeds TddPeriod\n",slot_num);
290         }
291         else{
292             sscanf(value, "%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx",
293                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[0],
294                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[1],
295                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[2],
296                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[3],
297                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[4],
298                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[5],
299                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[6],
300                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[7],
301                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[8],
302                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[9],
303                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[10],
304                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[11],
305                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[12],
306                                            (uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[13]);
307             printf("sSlotConfig%d: ",slot_num);
308             for (i = 0; i< 14; i++){
309                 printf("%d ",config->sSlotConfig[slot_num].nSymbolType[i]);
310             }
311             printf("\n");
312         }
313     } else if (strcmp(key, KEY_ANT_NUM) == 0) {
314         config->numAxc = atoi(value);
315     } else if (strcmp(key, KEY_UL_ANT_NUM) == 0) {
316         config->numUlAxc = atoi(value);
317     }else if (strcmp(key, KEY_ANT_ELM_TRX_NUM) == 0) {
318         config->antElmTRx = atoi(value);
319         printf("antElmTRx %d\n", config->antElmTRx);
320     } else if (strcmp(key, KEY_MU_MIMO_UES_NUM) == 0) {
321         config->muMimoUEs = atoi(value);
322     } else if (strcmp(key, KEY_DLLAYERS_PER_UE) == 0) {
323         config->DlLayersPerUe = atoi(value);
324     } else if (strcmp(key, KEY_ULLAYERS_PER_UE) == 0) {
325         config->UlLayersPerUe = atoi(value);
326     } else if (strcmp(key, KEY_TTI_PERIOD) == 0) {
327         config->ttiPeriod = atoi(value);
328     } else if (strcmp(key, KEY_IQ_SWAP) == 0) {
329         config->iqswap = atoi(value);
330     } else if (strcmp(key, KEY_HTONS_SWAP) == 0) {
331         config->nebyteorderswap = atoi(value);
332     } else if (strcmp(key, KEY_COMPRESSION) == 0) {
333         config->compression = atoi(value);
334     } else if (strcmp(key, KEY_COMP_TYPE) == 0) {
335         config->CompHdrType = atoi(value);
336     } else if (strcmp(key, KEY_PRACH_COMPMETH) == 0) {
337         config->prachCompMethod = atoi(value);
338     } else if (strcmp(key, KEY_PRACH_IQ) == 0) {
339         config->prachiqWidth = atoi(value);  
340     } else if (strcmp(key, KEY_MTU_SIZE) == 0) {
341         config->mtu = atoi(value);
342         printf("mtu %d\n", config->mtu);
343     } else if (strcmp(key, KEY_IO_SLEEP) == 0) {
344         config->io_sleep = atoi(value);
345         printf("io_sleep %d \n", config->io_sleep);
346     } else if (strcmp(key, KEY_IO_CORE) == 0) {
347         config->io_core = atoi(value);
348         printf("io_core %d [core id]\n", config->io_core);
349     } else if (strcmp(key, KEY_MAIN_CORE) == 0) {
350         config->io_core = atoi(value);
351         printf("io_core %d [core id]\n", config->io_core);
352     } else if (strcmp(key, KEY_IO_WORKER) == 0) {
353         config->io_worker = strtoll(value, NULL, 0);
354         printf("io_worker 0x%lx [mask]\n", config->io_worker);
355     } else if (strcmp(key, KEY_IO_WORKER_64_127) == 0) {
356         config->io_worker_64_127 = strtoll(value, NULL, 0);
357         printf("io_worker_64_127 0x%lx [mask]\n", config->io_worker_64_127);
358     } else if (strcmp(key, KEY_SYSTEM_CORE) == 0) {
359         config->system_core = atoi(value);
360         printf("system core %d [core id]\n", config->system_core);
361     } else if (strcmp(key, KEY_IOVA_MODE) == 0) {
362         config->iova_mode = atoi(value);
363         printf("iova_mode %d\n", config->iova_mode);
364     } else if (strcmp(key, KEY_INSTANCE_ID) == 0) {
365         config->instance_id = atoi(value);
366         printf("instance_id %d\n", config->instance_id);
367     } else if (strncmp(key, KEY_DU_MAC, strlen(KEY_DU_MAC)) == 0) {
368         unsigned int vf_num = 0;
369         sscanf(key,"duMac%02u",&vf_num);
370         if (vf_num >= XRAN_VF_MAX) {
371             printf("duMac%d exceeds max antenna supported\n",vf_num);
372         } else {
373             printf("duMac%d: %s\n",vf_num, value);
374             sscanf(value, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[0],
375                                                (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[1],
376                                                (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[2],
377                                                (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[3],
378                                                (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[4],
379                                                (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[5]);
380
381             printf("[vf %d]O-DU MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
382                 vf_num,
383                 config->o_du_addr[vf_num].addr_bytes[0],
384                 config->o_du_addr[vf_num].addr_bytes[1],
385                 config->o_du_addr[vf_num].addr_bytes[2],
386                 config->o_du_addr[vf_num].addr_bytes[3],
387                 config->o_du_addr[vf_num].addr_bytes[4],
388                 config->o_du_addr[vf_num].addr_bytes[5]);
389         }
390     } else if (strncmp(key, KEY_RU_MAC, strlen(KEY_RU_MAC)) == 0) {
391         unsigned int vf_num = 0;
392         sscanf(key,"ruMac%02u",&vf_num);
393         if (vf_num >= XRAN_VF_MAX) {
394             printf("ruMac%d exceeds max antenna supported\n",vf_num);
395         } else {
396             printf("ruMac%d: %s\n",vf_num, value);
397
398             sscanf(value, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[0],
399                                                (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[1],
400                                                (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[2],
401                                                (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[3],
402                                                (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[4],
403                                                (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[5]);
404
405             printf("[vf %d]RU MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
406                 vf_num,
407                 config->o_ru_addr[vf_num].addr_bytes[0],
408                 config->o_ru_addr[vf_num].addr_bytes[1],
409                 config->o_ru_addr[vf_num].addr_bytes[2],
410                 config->o_ru_addr[vf_num].addr_bytes[3],
411                 config->o_ru_addr[vf_num].addr_bytes[4],
412                 config->o_ru_addr[vf_num].addr_bytes[5]);
413         }
414     } else if (strcmp(key, KEY_FILE_NUMSLOTS) == 0) {
415         config->numSlots = atoi(value);
416         printf("numSlots: %d\n",config->numSlots);
417     }else if (strncmp(key, KEY_FILE_AxC, strlen(KEY_FILE_AxC)) == 0) {
418         unsigned int ant_num = 0;
419         sscanf(key,"antC%02u",&ant_num);
420         if (ant_num >= MAX_ANT_CARRIER_SUPPORTED) {
421             printf("antC%d exceeds max antenna supported\n",ant_num);
422         } else {
423             strncpy(&config->ant_file[ant_num][0], value, strlen(value));
424             printf("antC%d: %s\n",ant_num, config->ant_file[ant_num]);
425         }
426     } else if (strncmp(key, KEY_FILE_DLBFWUE, strlen(KEY_FILE_DLBFWUE)) == 0) {
427         unsigned int ue_num = 0;
428         sscanf(key,"DlBfwUe%02u",&ue_num);
429         if (ue_num >= MAX_ANT_CARRIER_SUPPORTED) {
430             printf("DlBfwUe%d exceeds max streams supported\n",ue_num);
431         } else {
432             strncpy(&config->dl_bfw_file[ue_num][0], value, strlen(value));
433             printf("DlBfwUe%d: %s\n",ue_num, config->dl_bfw_file[ue_num]);
434         }
435     }else if (strncmp(key, KEY_FILE_ULBFWUE, strlen(KEY_FILE_ULBFWUE)) == 0) {
436         unsigned int ue_num = 0;
437         sscanf(key,"UlBfwUe%02u",&ue_num);
438         if (ue_num >= MAX_ANT_CARRIER_SUPPORTED) {
439             printf("UlBfwUe%d exceeds max streams supported\n",ue_num);
440         } else {
441             strncpy(&config->ul_bfw_file[ue_num][0], value, strlen(value));
442             printf("UlBfwUe%d: %s\n",ue_num, config->ul_bfw_file[ue_num]);
443         }
444     }else if (strncmp(key, KEY_FILE_ULSRS, strlen(KEY_FILE_ULSRS)) == 0) {
445         unsigned int srs_ant = 0;
446         sscanf(key,"antSrsC%02u",&srs_ant);
447         if (srs_ant >= MAX_ANT_CARRIER_SUPPORTED_CAT_B) {
448             printf("antSrsC%d exceeds max ant elemnets supported [%d]\n", srs_ant, MAX_ANT_CARRIER_SUPPORTED_CAT_B);
449         } else {
450             strncpy(&config->ul_srs_file[srs_ant][0], value, strlen(value));
451             printf("antSrsC%d: %s\n",srs_ant, config->ul_srs_file[srs_ant]);
452         }
453     } else if (strncmp(key, KEY_FILE_SLOT_TX, strlen(KEY_FILE_SLOT_TX)) == 0) {
454         unsigned int slot_num = 0;
455         unsigned int direction = XRAN_DIR_DL;
456         sscanf(key,"SlotNumTx%02u",&slot_num);
457         if (slot_num >= XRAN_N_FE_BUF_LEN) {
458             printf("SlotNumTx%d exceeds max slots supported\n",slot_num);
459         } else {
460             config->SlotNum_fileEnabled = 1;
461             strncpy(&config->SlotNum_file[direction][slot_num][0], value, strlen(value));
462             printf("SlotNumTx%d: %s\n",slot_num, config->SlotNum_file[direction][slot_num]);
463         }
464     }else if (strncmp(key, KEY_FILE_SLOT_RX, strlen(KEY_FILE_SLOT_RX)) == 0) {
465         unsigned int slot_num = 0;
466         unsigned int direction = XRAN_DIR_UL;
467         sscanf(key,"SlotNumRx%02u",&slot_num);
468         if (slot_num >= XRAN_N_FE_BUF_LEN) {
469             printf("SlotNumRx%d exceeds max slots supported\n",slot_num);
470         } else {
471             config->SlotNum_fileEnabled = 1;
472             strncpy(&config->SlotNum_file[direction][slot_num][0], value, strlen(value));
473             printf("SlotNumRx%d: %s\n",slot_num, config->SlotNum_file[direction][slot_num]);
474         }
475     } else if (strcmp(key, KEY_PRACH_ENABLE) == 0) {
476         config->enablePrach = atoi(value);
477         printf("Prach enable: %d\n",config->enablePrach);
478     }else if (strcmp(key, KEY_MAX_FRAME_ID) == 0) {
479         config->maxFrameId = atoi(value);
480         printf("maxFrameId: %d\n",config->maxFrameId);
481     } else if (strcmp(key, KEY_SRS_ENABLE) == 0) {
482         config->enableSrs = atoi(value);
483         printf("Srs enable: %d\n",config->enableSrs);
484     } else if (strcmp(key, KEY_SRS_SYM_IDX) == 0) {
485         config->srsSymMask = atoi(value);
486         printf("Srs symbol [0-13]: %d\n",config->srsSymMask);
487     } else if (strcmp(key, KEY_SRS_SLOT) == 0) {
488         config->srsSlot = atoi(value);
489         printf("Srs slot: %d\n",config->srsSlot);
490     } else if (strcmp(key, KEY_SRS_NDM_OFFSET) == 0) {
491         config->srsNdmOffset = atoi(value);
492         printf("Srs NDM Offset: %d\n",config->srsNdmOffset);
493     } else if (strcmp(key, KEY_SRS_NDM_TXDUR) == 0) {
494         config->srsNdmTxDuration = atoi(value);
495         printf("Srs NDM TX duration: %d\n",config->srsNdmTxDuration);
496     } else if (strcmp(key, KEY_PUSCH_MASK_ENABLE) == 0) {
497         config->puschMaskEnable = atoi(value);
498         printf("PUSCH mask enable: %d\n",config->puschMaskEnable);
499     } else if (strcmp(key, KEY_PUSCH_MASK_SLOT) == 0) {
500         config->puschMaskSlot = atoi(value);
501         printf("PUSCH mask enable: %d\n",config->puschMaskSlot);
502     } else if (strcmp(key, KEY_PRACH_CFGIDX) == 0) {
503         config->prachConfigIndex = atoi(value);
504         printf("Prach config index: %d\n",config->prachConfigIndex);
505     } else if (strcmp(key, KEY_PRACH_CFGIDX_LTE) == 0) {
506         config->prachConfigIndexLTE = atoi(value);
507         printf("Prach config index LTE for DSS: %d\n",config->prachConfigIndexLTE);
508     } else if (strncmp(key, KEY_FILE_PRACH_AxC, strlen(KEY_FILE_PRACH_AxC)) == 0) {
509         unsigned int ant_num = 0;
510         sscanf(key,"antPrachC%02u",&ant_num);
511         if (ant_num >= MAX_ANT_CARRIER_SUPPORTED)
512         {
513             printf("antC%d exceeds max antenna supported\n",ant_num);
514         }
515         else{
516             strncpy(&config->prach_file[ant_num][0], value, strlen(value));
517             printf("antPrachC%d: %s\n",ant_num, config->prach_file[ant_num]);
518         }
519     } else if (strcmp(key, KEY_BFW_NUM) == 0) {
520         config->totalBfWeights = atoi(value);
521         printf("%s : %d\n",KEY_BFW_NUM, config->totalBfWeights);
522         /* timing */
523     } else if (strcmp(key, KEY_TADV_CP_DL ) == 0) {
524         config->Tadv_cp_dl = atoi(value);
525         printf("Tadv_cp_dl: %d\n",config->Tadv_cp_dl);
526     } else if (strcmp(key, KEY_T2A_MIN_CP_DL ) == 0) {
527         config->T2a_min_cp_dl = atoi(value);
528         printf("T2a_min_cp_dl: %d\n",config->T2a_min_cp_dl);
529     } else if (strcmp(key, KEY_T2A_MAX_CP_DL ) == 0) {
530         config->T2a_max_cp_dl = atoi(value);
531         printf("T2a_max_cp_dl: %d\n",config->T2a_max_cp_dl);
532     } else if (strcmp(key, KEY_T2A_MIN_CP_UL ) == 0) {
533         config->T2a_min_cp_ul = atoi(value);
534         printf("T2a_min_cp_ul: %d\n",config->T2a_min_cp_ul);
535     } else if (strcmp(key, KEY_T2A_MAX_CP_UL ) == 0) {
536         config->T2a_max_cp_ul = atoi(value);
537         printf("T2a_max_cp_ul: %d\n",config->T2a_max_cp_ul);
538     } else if (strcmp(key, KEY_T2A_MIN_UP ) == 0) {
539         config->T2a_min_up = atoi(value);
540         printf("T2a_min_up: %d\n",config->T2a_min_up);
541     } else if (strcmp(key, KEY_T2A_MAX_UP ) == 0) {
542         config->T2a_max_up = atoi(value);
543         printf("T2a_max_up: %d\n",config->T2a_max_up);
544     } else if (strcmp(key, KEY_TA3_MIN ) == 0) {
545         config->Ta3_min = atoi(value);
546         printf("Ta3_min: %d\n",config->Ta3_min);
547     } else if (strcmp(key, KEY_TA3_MAX ) == 0) {
548         config->Ta3_max = atoi(value);
549         printf("Ta3_max: %d\n",config->Ta3_max);
550     } else if (strcmp(key, KEY_T1A_MIN_CP_DL ) == 0) {
551         config->T1a_min_cp_dl = atoi(value);
552         printf("T1a_min_cp_dl: %d\n",config->T1a_min_cp_dl);
553     } else if (strcmp(key, KEY_T1A_MAX_CP_DL ) == 0) {
554         config->T1a_max_cp_dl = atoi(value);
555         printf("T1a_max_cp_dl: %d\n",config->T1a_max_cp_dl);
556     } else if (strcmp(key, KEY_T1A_MIN_CP_UL ) == 0) {
557         config->T1a_min_cp_ul = atoi(value);
558         printf("T1a_min_cp_ul: %d\n",config->T1a_min_cp_ul);
559     } else if (strcmp(key, KEY_T1A_MAX_CP_UL ) == 0) {
560         config->T1a_max_cp_ul = atoi(value);
561         printf("T1a_max_cp_ul: %d\n",config->T1a_max_cp_ul);
562     } else if (strcmp(key, KEY_T1A_MIN_UP ) == 0) {
563         config->T1a_min_up = atoi(value);
564         printf("T1a_min_up: %d\n",config->T1a_min_up);
565     } else if (strcmp(key, KEY_T1A_MAX_UP ) == 0) {
566         config->T1a_max_up = atoi(value);
567         printf("T1a_max_up: %d\n",config->T1a_max_up);
568     } else if (strcmp(key, KEY_TA4_MIN ) == 0) {
569         config->Ta4_min = atoi(value);
570         printf("Ta4_min: %d\n",config->Ta4_min);
571     } else if (strcmp(key, KEY_TA4_MAX ) == 0) {
572         config->Ta4_max = atoi(value);
573         printf("Ta4_max: %d\n",config->Ta4_max);
574         /* end of timing */
575     } else if (strcmp(key, KEY_CP_ENABLE ) == 0) {
576         config->enableCP = atoi(value);
577         printf("CPenable: %d\n",config->enableCP);
578     } else if (strcmp(key, KEY_DEBUG_STOP ) == 0) {
579         config->debugStop = atoi(value);
580         printf("debugStop: %d\n",config->debugStop);
581     } else if (strcmp(key, KEY_DEBUG_STOP_CNT) == 0) {
582         config->debugStopCount = atoi(value);
583         printf("debugStopCount: %d\n",config->debugStopCount);
584     } else if (strcmp(key, KEY_BBDEV_MODE) == 0) {
585         config->bbdevMode = atoi(value);
586         printf("bbdevMode: %d\n",config->debugStopCount);
587     } else if (strcmp(key, KEY_DYNA_SEC_ENA) == 0) {
588         config->DynamicSectionEna = atoi(value);
589         printf("DynamicSectionEna: %d\n",config->DynamicSectionEna);
590     } else if (strcmp(key, EXT_TYPE) == 0) {
591         config->extType = atoi(value);
592         printf("ExtType: %d\n",config->extType);
593     } else if (strcmp(key, KEY_ALPHA) == 0) {
594         config->GPS_Alpha = atoi(value);
595         printf("GPS_Alpha: %d\n",config->GPS_Alpha);
596     } else if (strcmp(key, KEY_BETA) == 0) {
597         config->GPS_Beta = atoi(value);
598         printf("GPS_Beta: %d\n",config->GPS_Beta);
599     } else if (strcmp(key, KEY_CP_VTAG ) == 0) {
600         config->cp_vlan_tag = atoi(value);
601         printf("cp_vlan_tag: %d\n",config->cp_vlan_tag);
602     } else if (strcmp(key, KEY_UP_VTAG ) == 0) {
603         config->up_vlan_tag = atoi(value);
604         printf("up_vlan_tag: %d\n",config->up_vlan_tag);
605     } else if (strcmp(key, KEY_MAX_SEC_SYM ) == 0) {
606         config->max_sections_per_symbol = atoi(value);
607         printf("max_sections_per_symbol: %d\n",config->max_sections_per_symbol);
608     } else if (strcmp(key, KEY_MAX_SEC_SLOT ) == 0) {
609         config->max_sections_per_slot = atoi(value);
610         printf("max_sections_per_slot: %d\n",config->max_sections_per_slot);
611     } else if (strcmp(key, KEY_NPRBELEM_UL ) == 0) {
612         config->p_PrbMapUl->nPrbElm = atoi(value);
613         if (config->p_PrbMapUl->nPrbElm > XRAN_MAX_SECTIONS_PER_SLOT)
614         {
615             printf("nTddPeriod is larger than max allowed, invalid!\n");
616             config->p_PrbMapUl->nPrbElm = XRAN_MAX_SECTIONS_PER_SLOT;
617         }
618         printf("nPrbElemUl: %d\n",config->p_PrbMapUl->nPrbElm);
619     } else if (strncmp(key, KEY_PRBELEM_UL, strlen(KEY_PRBELEM_UL)) == 0) {
620         sscanf(key,"PrbElemUl%u",&section_idx_ul);
621         if (section_idx_ul >= config->p_PrbMapUl->nPrbElm){
622             printf("section_idx %d exceeds nPrbElemUl\n",section_idx_ul);
623         }
624         else{
625             struct xran_prb_elm *pPrbElem = &config->p_PrbMapUl->prbMap[section_idx_ul];
626             sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
627                 (int16_t*)&pPrbElem->nRBStart,
628                 (int16_t*)&pPrbElem->nRBSize,
629                 (int16_t*)&pPrbElem->nStartSymb,
630                 (int16_t*)&pPrbElem->numSymb,
631                 (int16_t*)&pPrbElem->nBeamIndex,
632                 (int16_t*)&pPrbElem->bf_weight_update,
633                 (int16_t*)&pPrbElem->compMethod,
634                 (int16_t*)&pPrbElem->iqWidth,
635                 (int16_t*)&pPrbElem->BeamFormingType);
636             printf("nPrbElemUl%d: ",section_idx_ul);
637             printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
638                 pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
639         }
640     } else if(strncmp(key, KEY_EXTBFW_UL, strlen(KEY_EXTBFW_UL)) == 0) {
641         sscanf(key, "ExtBfwUl%u", &section_idx_ul);
642         if(section_idx_ul >= config->p_PrbMapUl->nPrbElm) {
643             printf("section_idx %d of bfw exceeds nPrbElemUl\n",section_idx_ul);
644         }
645         else{
646             struct xran_prb_elm *pPrbElem = &config->p_PrbMapUl->prbMap[section_idx_ul];
647             sscanf(value, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
648                 (uint8_t*)&pPrbElem->bf_weight.numBundPrb,
649                 (uint8_t*)&pPrbElem->bf_weight.numSetBFWs,
650                 (uint8_t*)&pPrbElem->bf_weight.RAD,
651                 (uint8_t*)&pPrbElem->bf_weight.disableBFWs,
652                 (uint8_t*)&pPrbElem->bf_weight.bfwIqWidth,
653                 (uint8_t*)&pPrbElem->bf_weight.bfwCompMeth,
654                 (uint8_t*)&pPrbElem->bf_weight.extType);
655             printf(KEY_EXTBFW_UL"%d: ", section_idx_ul);
656             printf("numBundPrb %d, numSetBFW %d, RAD %d, disableBFW %d, bfwIqWidth %d, bfwCompMeth %d, extType %d\n",
657                 pPrbElem->bf_weight.numBundPrb, pPrbElem->bf_weight.numSetBFWs, pPrbElem->bf_weight.RAD, pPrbElem->bf_weight.disableBFWs, pPrbElem->bf_weight.bfwIqWidth, pPrbElem->bf_weight.bfwCompMeth, pPrbElem->bf_weight.extType);
658         }
659     }else if (strcmp(key, KEY_NPRBELEM_DL ) == 0) {
660         config->p_PrbMapDl->nPrbElm = atoi(value);
661         if (config->p_PrbMapDl->nPrbElm > XRAN_MAX_SECTIONS_PER_SLOT)
662         {
663             printf("nPrbElm is larger than max allowed, invalid!\n");
664             config->p_PrbMapDl->nPrbElm = XRAN_MAX_SECTIONS_PER_SLOT;
665         }
666         printf("nPrbElemDl: %d\n",config->p_PrbMapDl->nPrbElm);
667     } else if (strncmp(key, KEY_PRBELEM_DL, strlen(KEY_PRBELEM_DL)) == 0) {
668         sscanf(key,"PrbElemDl%u",&section_idx_dl);
669         if (section_idx_dl >= config->p_PrbMapDl->nPrbElm){
670             printf("section_idx %d exceeds nPrbElemDl\n",section_idx_dl);
671         }
672         else{
673             struct xran_prb_elm *pPrbElem = &config->p_PrbMapDl->prbMap[section_idx_dl];
674             sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
675                 (int16_t*)&pPrbElem->nRBStart,
676                 (int16_t*)&pPrbElem->nRBSize,
677                 (int16_t*)&pPrbElem->nStartSymb,
678                 (int16_t*)&pPrbElem->numSymb,
679                 (int16_t*)&pPrbElem->nBeamIndex,
680                 (int16_t*)&pPrbElem->bf_weight_update,
681                 (int16_t*)&pPrbElem->compMethod,
682                 (int16_t*)&pPrbElem->iqWidth,
683                 (int16_t*)&pPrbElem->BeamFormingType,
684                 (int16_t*)&pPrbElem->ScaleFactor,
685                 (int16_t*)&pPrbElem->reMask);
686             printf("nPrbElemDl%d: ",section_idx_dl);
687             printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d ScaleFactor %d reMask %d\n",
688                 pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType, pPrbElem->ScaleFactor, pPrbElem->reMask);
689         }
690     } else if(strncmp(key, KEY_EXTBFW_DL, strlen(KEY_EXTBFW_DL)) == 0) {
691         sscanf(key, "ExtBfwDl%u", &section_idx_dl);
692         if(section_idx_dl >= config->p_PrbMapDl->nPrbElm) {
693             printf("section_idx %d of bfw exceeds nPrbElemUl\n",section_idx_dl);
694         }
695         else{
696             struct xran_prb_elm *pPrbElem = &config->p_PrbMapDl->prbMap[section_idx_dl];
697             sscanf(value, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
698                 (uint8_t*)&pPrbElem->bf_weight.numBundPrb,
699                 (uint8_t*)&pPrbElem->bf_weight.numSetBFWs,
700                 (uint8_t*)&pPrbElem->bf_weight.RAD,
701                 (uint8_t*)&pPrbElem->bf_weight.disableBFWs,
702                 (uint8_t*)&pPrbElem->bf_weight.bfwIqWidth,
703                 (uint8_t*)&pPrbElem->bf_weight.bfwCompMeth,
704                 (uint8_t*)&pPrbElem->bf_weight.extType);
705             printf(KEY_EXTBFW_DL"%d: ", section_idx_dl);
706             printf("numBundPrb %d, numSetBFW %d, RAD %d, disableBFW %d, bfwIqWidth %d, bfwCompMeth %d, extType %d\n",
707                 pPrbElem->bf_weight.numBundPrb, pPrbElem->bf_weight.numSetBFWs, pPrbElem->bf_weight.RAD, pPrbElem->bf_weight.disableBFWs, pPrbElem->bf_weight.bfwIqWidth, pPrbElem->bf_weight.bfwCompMeth, pPrbElem->bf_weight.extType);
708         }
709     } else if (strcmp(key, KEY_NPRBELEM_SRS ) == 0) {
710         config->p_PrbMapSrs->nPrbElm = atoi(value);
711         if (config->p_PrbMapSrs->nPrbElm > XRAN_MAX_SECTIONS_PER_SLOT)
712         {
713             printf("nPrbElm is larger than max allowed, invalid!\n");
714             config->p_PrbMapSrs->nPrbElm = XRAN_MAX_SECTIONS_PER_SLOT;
715         }
716         printf("nPrbElemSrs: %d\n",config->p_PrbMapSrs->nPrbElm);
717     } else if (strncmp(key, KEY_PRBELEM_SRS, strlen(KEY_PRBELEM_SRS)) == 0) {
718         sscanf(key,"PrbElemSrs%u",&section_idx_srs);
719         if (section_idx_srs >= config->p_PrbMapSrs->nPrbElm) {
720             printf("section_idx %d exceeds nPrbElemSrs\n",section_idx_srs);
721         }else {
722             struct xran_prb_elm *pPrbElem = &config->p_PrbMapSrs->prbMap[section_idx_srs];
723             sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
724                 (int16_t*)&pPrbElem->nRBStart,
725                 (int16_t*)&pPrbElem->nRBSize,
726                 (int16_t*)&pPrbElem->nStartSymb,
727                 (int16_t*)&pPrbElem->numSymb,
728                 (int16_t*)&pPrbElem->nBeamIndex,
729                 (int16_t*)&pPrbElem->bf_weight_update,
730                 (int16_t*)&pPrbElem->compMethod,
731                 (int16_t*)&pPrbElem->iqWidth,
732                 (int16_t*)&pPrbElem->BeamFormingType);
733             printf("nPrbElemSrs%d: ",section_idx_srs);
734             printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
735                 pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
736         }
737     } else if (strcmp(key, KEY_PRBMAP_BY_SYMB ) == 0) {
738         config->RunSlotPrbMapBySymbolEnable = atoi(value);
739         printf("RunSlotPrbMapBySymbolEnable: %d\n",config->RunSlotPrbMapBySymbolEnable);
740     } else if (strcmp(key, KEY_DSS_ENABLE ) == 0) {
741         config->dssEnable =  atoi(value);
742         printf("dssEnable: %d\n",config->dssEnable);
743     } else if (strcmp(key, KEY_DSS_PERIOD ) == 0) {
744         config->dssPeriod =  atoi(value);
745         printf("dssPeriod: %d\n",config->dssPeriod);
746     } else if (strcmp(key, KEY_TECHNOLOGY ) == 0) {
747         int i = 0;
748         sscanf(value, "%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx",
749                                                     (uint8_t *)&config->technology[0],
750                                                     (uint8_t *)&config->technology[1],
751                                                     (uint8_t *)&config->technology[2],
752                                                     (uint8_t *)&config->technology[3],
753                                                     (uint8_t *)&config->technology[4],
754                                                     (uint8_t *)&config->technology[5],
755                                                     (uint8_t *)&config->technology[6],
756                                                     (uint8_t *)&config->technology[7],
757                                                     (uint8_t *)&config->technology[8],
758                                                     (uint8_t *)&config->technology[9],
759                                                     (uint8_t *)&config->technology[10],
760                                                     (uint8_t *)&config->technology[11],
761                                                     (uint8_t *)&config->technology[12],
762                                                     (uint8_t *)&config->technology[13],
763                                                     (uint8_t *)&config->technology[14]);
764         printf("technology:");
765         for( i=0; i<config->dssPeriod; i++) {
766            printf("%d ",config->technology[i]);
767         }
768         printf("\n");
769     }else {
770         printf("Unsupported configuration key [%s]\n", key);
771         return -1;
772     }
773     return 0;
774 }
775
776 static int
777 fillUsecaseStruct(UsecaseConfig *config, const char *key, const char *value)
778 {
779     if (strcmp(key, KEY_APP_MODE) == 0){
780         config->appMode = atoi(value);
781         printf("appMode %d \n", config->appMode);
782     } else if (strcmp(key, KEY_XU_NUM) == 0){
783         config->oXuNum = atoi(value);
784         printf("oXuNum %d \n", config->oXuNum);
785     } else if (strcmp(key, KEY_XU_ETH_LINK_SPD) == 0){
786         config->EthLinkSpeed = atoi(value);
787         printf("EthLinkSpeed %d \n", config->EthLinkSpeed);
788     } else if (strcmp(key, KEY_XU_ETH_LINE_NUM) == 0){
789         config->EthLinesNumber = atoi(value);
790         printf("EthLinkSpeed %d \n", config->EthLinesNumber);
791     } else if (strcmp(key, KEY_XU_RXQ_VF) == 0){
792         config->num_rxq = atoi(value);
793         printf("oXuRxqNumber %d \n", config->num_rxq);
794     } else if (strcmp(key, KEY_XU_CP_ON_ONE_VF) == 0) {
795         config->one_vf_cu_plane = atoi(value);
796         printf("oXuCPon1Vf %d \n", config->one_vf_cu_plane);
797     } else if (strcmp(key, KEY_IO_SLEEP) == 0) {
798         config->io_sleep = atoi(value);
799         printf("io_sleep %d \n", config->io_sleep);
800     } else if (strcmp(key, KEY_IO_CORE) == 0) {
801         config->io_core = atoi(value);
802         printf("io_core %d [core id]\n", config->io_core);
803     } else if (strcmp(key, KEY_MAIN_CORE) == 0) {
804         config->main_core = atoi(value);
805         printf("main_core %d [core id]\n", config->main_core);
806     } else if (strcmp(key, KEY_IO_WORKER) == 0) {
807         config->io_worker = strtoll(value, NULL, 0);
808         printf("io_worker 0x%lx [mask]\n", config->io_worker);
809     } else if (strcmp(key, KEY_IO_WORKER_64_127) == 0) {
810         config->io_worker_64_127 = strtoll(value, NULL, 0);
811         printf("io_worker_64_127 0x%lx [mask]\n", config->io_worker_64_127);
812     } else if (strcmp(key, KEY_SYSTEM_CORE) == 0) {
813         config->system_core = atoi(value);
814         printf("system core %d [core id]\n", config->system_core);
815     } else if (strcmp(key, KEY_IOVA_MODE) == 0) {
816         config->iova_mode = atoi(value);
817         printf("iova_mode %d\n", config->iova_mode);
818     } else if (strcmp(key, KEY_DPDK_MEM_SZ) == 0) {
819         config->dpdk_mem_sz = atoi(value);
820         printf("dpdk_mem_sz %d\n", config->dpdk_mem_sz);
821     } else if (strcmp(key, KEY_INSTANCE_ID) == 0) {
822         config->instance_id = atoi(value);
823         printf("instance_id %d\n", config->instance_id);
824     }else if (strncmp(key, KEY_FILE_O_XU_CFG, strlen(KEY_FILE_O_XU_CFG)) == 0) {
825         unsigned int o_xu_id = 0;
826         sscanf(key,"oXuCfgFile%02u",&o_xu_id);
827         if (o_xu_id >= XRAN_PORTS_NUM) {
828             printf("oXuCfgFile%d exceeds max O-XU supported\n",o_xu_id);
829         } else {
830             strncpy(&config->o_xu_cfg_file[o_xu_id][0], value, strlen(value));
831             printf("oXuCfgFile%d: %s\n",o_xu_id, config->o_xu_cfg_file[o_xu_id]);
832         }
833     } else if (strncmp(key, KEY_FILE_O_XU_BBU_CFG, strlen(KEY_FILE_O_XU_BBU_CFG)) == 0) {
834         strncpy(&config->o_xu_bbu_cfg_file[0], value, strlen(value));
835         printf("oXuBbuCfgFile: %s\n", config->o_xu_bbu_cfg_file);
836     } else if (strncmp(key, KEY_OWDM_INIT_EN, strlen(KEY_OWDM_INIT_EN)) == 0) {
837         config->owdmInitEn = atoi(value);
838         printf("owdmInitEn %d\n", config->owdmInitEn);
839     } else if (strncmp(key, KEY_OWDM_MEAS_METH, strlen(KEY_OWDM_MEAS_METH)) == 0) {
840         config->owdmMeasMeth =  atoi(value);
841         printf("owdmMeasMeth %d\n", config->owdmMeasMeth);
842     } else if (strncmp(key, KEY_OWDM_NUM_SAMPS, strlen(KEY_OWDM_NUM_SAMPS)) == 0) {
843         config->owdmNumSamps =  atoi(value);
844         printf("owdmNumSamps %d\n", config->owdmNumSamps);
845     } else if (strncmp(key, KEY_OWDM_FLTR_TYPE, strlen(KEY_OWDM_FLTR_TYPE)) == 0) {
846         config->owdmFltType =  atoi(value);
847         printf("owdmFltType %d\n", config->owdmFltType);
848     } else if (strncmp(key, KEY_OWDM_RSP_TO, strlen(KEY_OWDM_RSP_TO)) == 0) {
849         config->owdmRspTo =  atol(value);
850         printf("owdmRspTo %lu\n", config->owdmRspTo);
851     } else if (strncmp(key, KEY_OWDM_MEAS_ID, strlen(KEY_OWDM_MEAS_ID)) == 0) {
852         config->owdmMeasId =  atoi(value);
853         printf("owdmMeasId %d\n", config->owdmMeasId);
854     } else if (strncmp(key, KEY_OWDM_EN, strlen(KEY_OWDM_EN)) == 0) {
855         config->owdmEnable =  atoi(value);
856         printf("owdmEnable %d\n", config->owdmEnable);
857     } else if (strncmp(key, KEY_OWDM_PL_LENGTH, strlen(KEY_OWDM_PL_LENGTH)) == 0) {
858         config->owdmPlLength = atoi(value);
859         printf("owdmPlLength %d\n", config->owdmPlLength);
860     } else if (strncmp(key, KEY_OWDM_MEAS_ST, strlen(KEY_OWDM_MEAS_ST)) == 0) {
861         config->owdmMeasState =  atoi(value);
862         printf("owdmMeasState %d\n", config->owdmMeasState);
863     } else if (strncmp(key, KEY_O_XU_PCIE_BUS, strlen(KEY_O_XU_PCIE_BUS)) == 0) {
864         unsigned int o_xu_id = 0;
865         unsigned int vf_num = 0;
866         sscanf(key,"PciBusAddoXu%02uVf%02u",&o_xu_id, &vf_num);
867         if (o_xu_id >= XRAN_PORTS_NUM || vf_num >= XRAN_VF_MAX){
868             printf("PciBusAddoXu%dVf%d exceeds max O-XU supported\n",o_xu_id, vf_num);
869         } else {
870             strncpy(&config->o_xu_pcie_bus_addr[o_xu_id][vf_num][0], value, strlen(value));
871             printf("PciBusAddoXu%dVf%d: %s\n",o_xu_id, vf_num, &config->o_xu_pcie_bus_addr[o_xu_id][vf_num][0]);
872         }
873     } else if (strncmp(key, KEY_O_XU_REM_MAC, strlen(KEY_O_XU_REM_MAC)) == 0) {
874         unsigned int xu_num = 0;
875         unsigned int vf_num = 0;
876
877         sscanf(key,"oXuRem%02uMac%02u",&xu_num, &vf_num);
878
879         if (xu_num >= XRAN_PORTS_NUM || vf_num >= XRAN_VF_MAX) {
880             printf("oXuRem%02uMac%02u exceeds max supported\n",xu_num, vf_num);
881         } else {
882             printf("oXuRem%02uMac%02u: %s\n",xu_num, vf_num, value);
883             sscanf(value, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[0],
884                                                (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[1],
885                                                (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[2],
886                                                (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[3],
887                                                (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[4],
888                                                (uint8_t*)&config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[5]);
889
890             printf("[xu %d vf %d]RU MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
891                 xu_num,
892                 vf_num,
893                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[0],
894                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[1],
895                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[2],
896                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[3],
897                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[4],
898                 config->remote_o_xu_addr[xu_num][vf_num].addr_bytes[5]);
899         }
900     }
901     else if (strncmp(key, KEY_DL_CP_BURST, strlen(KEY_DL_CP_BURST)) == 0) {
902         config->dlCpProcBurst = atoi(value);
903         printf("dlCpProcBurst %d\n", config->dlCpProcBurst);
904     } else if (strncmp(key, KEY_XRAN_MLOG_DIS, strlen(KEY_XRAN_MLOG_DIS)) == 0) {
905         config->mlogxrandisable = atoi(value);
906         printf("xranMlogDisable %d\n", config->mlogxrandisable);
907     } else {
908         printf("Unsupported configuration key [%s]\n", key);
909         return -1;
910     }
911
912     return 0;
913 }
914
915 static int
916 fillSlotStructAsCb(void* cbParam, const char *key, const char *value)
917 {
918     struct slot_cfg_to_pars *p_slot_cfg = (struct slot_cfg_to_pars*) cbParam;
919     RuntimeConfig *config  = p_slot_cfg->config;
920     int32_t  direction     = p_slot_cfg->direction;
921     int32_t  slot_idx      = p_slot_cfg->slot_idx;
922     uint32_t section_idx   = 0;
923
924     //printf("Dir %d slot %d\n", direction, slot_idx);
925
926     if (strcmp(key, KEY_NPRBELEM_UL ) == 0) {
927         config->p_SlotPrbMap[direction][slot_idx]->nPrbElm = atoi(value);
928         if (config->p_SlotPrbMap[direction][slot_idx]->nPrbElm > XRAN_MAX_SECTIONS_PER_SLOT)
929         {
930             printf("nTddPeriod is larger than max allowed, invalid!\n");
931             config->p_SlotPrbMap[direction][slot_idx]->nPrbElm  = XRAN_MAX_SECTIONS_PER_SLOT;
932         }
933         printf("nPrbElemUl: %d\n",config->p_SlotPrbMap[direction][slot_idx]->nPrbElm );
934     } else if (strncmp(key, KEY_PRBELEM_UL_ANT_M, strlen(KEY_PRBELEM_UL_ANT_M)) == 0) {
935         sscanf(key,"PrbElemUlAntCMask%u",&section_idx);
936         if (section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm){
937             printf("section_idx %d exceeds nPrbElemul\n",section_idx);
938         }
939         else{
940             sscanf(value, "%lx",(uint64_t*)&config->SlotPrbAntCMask[direction][slot_idx][section_idx]);
941             printf("%s%u 0x%lx\n",KEY_PRBELEM_UL_ANT_M, section_idx, config->SlotPrbAntCMask[direction][slot_idx][section_idx]);
942         }
943     }  else if (strncmp(key, KEY_PRBELEM_UL_CC_M, strlen(KEY_PRBELEM_UL_CC_M)) == 0) {
944         sscanf(key,"PrbElemUlCCMask%u",&section_idx);
945         if (section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm){
946             printf("section_idx %d exceeds nPrbElemUL\n",section_idx);
947         }
948         else{
949             sscanf(value, "%02hx",(uint16_t*)&config->SlotPrbCCmask[direction][slot_idx][section_idx]);
950             printf("%s%u 0x%02x\n",KEY_PRBELEM_UL_CC_M, section_idx, config->SlotPrbCCmask[direction][slot_idx][section_idx]);
951         }
952     } else if (strncmp(key, KEY_PRBELEM_UL, strlen(KEY_PRBELEM_UL)) == 0) {
953         sscanf(key,"PrbElemUl%u",&section_idx);
954         if (section_idx >=  config->p_SlotPrbMap[direction][slot_idx]->nPrbElm) {
955             printf("section_idx %d exceeds nPrbElemUl\n",section_idx);
956         }
957         else {
958             struct xran_prb_elm *pPrbElem = &config->p_SlotPrbMap[direction][slot_idx]->prbMap[section_idx];
959             sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
960                 (int16_t*)&pPrbElem->nRBStart,
961                 (int16_t*)&pPrbElem->nRBSize,
962                 (int16_t*)&pPrbElem->nStartSymb,
963                 (int16_t*)&pPrbElem->numSymb,
964                 (int16_t*)&pPrbElem->nBeamIndex,
965                 (int16_t*)&pPrbElem->bf_weight_update,
966                 (int16_t*)&pPrbElem->compMethod,
967                 (int16_t*)&pPrbElem->iqWidth,
968                 (int16_t*)&pPrbElem->BeamFormingType);
969             printf("nPrbElemUl%d: ",section_idx);
970             printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
971                 pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
972         }
973     } else if(strncmp(key, KEY_EXTBFW_UL, strlen(KEY_EXTBFW_UL)) == 0) {
974         sscanf(key, "ExtBfwUl%u", &section_idx);
975         if(section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm) {
976             printf("section_idx %d of bfw exceeds nPrbElemUl\n",section_idx);
977         }else{
978             struct xran_prb_elm *pPrbElem = &config->p_SlotPrbMap[direction][slot_idx]->prbMap[section_idx];
979             sscanf(value, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
980                 (uint8_t*)&pPrbElem->bf_weight.numBundPrb,
981                 (uint8_t*)&pPrbElem->bf_weight.numSetBFWs,
982                 (uint8_t*)&pPrbElem->bf_weight.RAD,
983                 (uint8_t*)&pPrbElem->bf_weight.disableBFWs,
984                 (uint8_t*)&pPrbElem->bf_weight.bfwIqWidth,
985                 (uint8_t*)&pPrbElem->bf_weight.bfwCompMeth,
986                 (uint8_t*)&pPrbElem->bf_weight.extType);
987             printf(KEY_EXTBFW_UL"%d: ", section_idx);
988             printf("numBundPrb %d, numSetBFW %d, RAD %d, disableBFW %d, bfwIqWidth %d, bfwCompMeth %d, extType %d\n",
989                 pPrbElem->bf_weight.numBundPrb, pPrbElem->bf_weight.numSetBFWs, pPrbElem->bf_weight.RAD, pPrbElem->bf_weight.disableBFWs, pPrbElem->bf_weight.bfwIqWidth, pPrbElem->bf_weight.bfwCompMeth, pPrbElem->bf_weight.extType);
990         }
991     }else if (strcmp(key, KEY_NPRBELEM_DL ) == 0) {
992         config->p_SlotPrbMap[direction][slot_idx]->nPrbElm = atoi(value);
993         if (config->p_SlotPrbMap[direction][slot_idx]->nPrbElm > XRAN_MAX_SECTIONS_PER_SLOT)
994         {
995             printf("nTddPeriod is larger than max allowed, invalid!\n");
996             config->p_SlotPrbMap[direction][slot_idx]->nPrbElm = XRAN_MAX_SECTIONS_PER_SLOT;
997         }
998         printf("nPrbElemDl: %d\n",config->p_SlotPrbMap[direction][slot_idx]->nPrbElm);
999     } else if (strncmp(key, KEY_PRBELEM_DL_ANT_M, strlen(KEY_PRBELEM_DL_ANT_M)) == 0) {
1000         sscanf(key,"PrbElemDlAntCMask%u",&section_idx);
1001         if (section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm){
1002             printf("section_idx %d exceeds nPrbElemDl\n",section_idx);
1003         }
1004         else{
1005             sscanf(value, "%lx",(uint64_t*)&config->SlotPrbAntCMask[direction][slot_idx][section_idx]);
1006             printf("%s%u 0x%lx\n",KEY_PRBELEM_DL_ANT_M, section_idx, config->SlotPrbAntCMask[direction][slot_idx][section_idx]);
1007         }
1008     }  else if (strncmp(key, KEY_PRBELEM_DL_CC_M, strlen(KEY_PRBELEM_DL_CC_M)) == 0) {
1009         sscanf(key,"PrbElemDlCCMask%u",&section_idx);
1010         if (section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm){
1011             printf("section_idx %d exceeds nPrbElemDl\n",section_idx);
1012         }
1013         else{
1014             sscanf(value, "%02hx",(uint16_t*)&config->SlotPrbCCmask[direction][slot_idx][section_idx]);
1015             printf("%s%u 0x%02x\n",KEY_PRBELEM_DL_CC_M, section_idx, config->SlotPrbCCmask[direction][slot_idx][section_idx]);
1016         }
1017     } else if (strncmp(key, KEY_PRBELEM_DL, strlen(KEY_PRBELEM_DL)) == 0) {
1018         sscanf(key,"PrbElemDl%u",&section_idx);
1019         if (section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm){
1020             printf("section_idx %d exceeds nPrbElemDl\n",section_idx);
1021         }
1022         else{
1023             struct xran_prb_elm *pPrbElem = &config->p_SlotPrbMap[direction][slot_idx]->prbMap[section_idx];
1024             sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
1025                 (int16_t*)&pPrbElem->nRBStart,
1026                 (int16_t*)&pPrbElem->nRBSize,
1027                 (int16_t*)&pPrbElem->nStartSymb,
1028                 (int16_t*)&pPrbElem->numSymb,
1029                 (int16_t*)&pPrbElem->nBeamIndex,
1030                 (int16_t*)&pPrbElem->bf_weight_update,
1031                 (int16_t*)&pPrbElem->compMethod,
1032                 (int16_t*)&pPrbElem->iqWidth,
1033                 (int16_t*)&pPrbElem->BeamFormingType);
1034             printf("nPrbElemDl%d: ",section_idx);
1035             printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
1036                 pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
1037         }
1038     } else if(strncmp(key, KEY_EXTBFW_DL, strlen(KEY_EXTBFW_DL)) == 0) {
1039         sscanf(key, "ExtBfwDl%u", &section_idx);
1040         if(section_idx >= config->p_SlotPrbMap[direction][slot_idx]->nPrbElm) {
1041             printf("section_idx %d of bfw exceeds nPrbElemUl\n",section_idx);
1042         }
1043         else{
1044             struct xran_prb_elm *pPrbElem = &config->p_SlotPrbMap[direction][slot_idx]->prbMap[section_idx];
1045             sscanf(value, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
1046                 (uint8_t*)&pPrbElem->bf_weight.numBundPrb,
1047                 (uint8_t*)&pPrbElem->bf_weight.numSetBFWs,
1048                 (uint8_t*)&pPrbElem->bf_weight.RAD,
1049                 (uint8_t*)&pPrbElem->bf_weight.disableBFWs,
1050                 (uint8_t*)&pPrbElem->bf_weight.bfwIqWidth,
1051                 (uint8_t*)&pPrbElem->bf_weight.bfwCompMeth,
1052                 (uint8_t*)&pPrbElem->bf_weight.extType);
1053             printf(KEY_EXTBFW_DL"%d: ",section_idx);
1054             printf("numBundPrb %d, numSetBFW %d, RAD %d, disableBFW %d, bfwIqWidth %d, bfwCompMeth %d, extType %d\n",
1055                 pPrbElem->bf_weight.numBundPrb, pPrbElem->bf_weight.numSetBFWs, pPrbElem->bf_weight.RAD, pPrbElem->bf_weight.disableBFWs, pPrbElem->bf_weight.bfwIqWidth, pPrbElem->bf_weight.bfwCompMeth, pPrbElem->bf_weight.extType);
1056         }
1057     } else {
1058         printf("Unsupported configuration key [%s]\n", key);
1059         return -1;
1060     }
1061
1062     return 0;
1063 }
1064
1065 struct xran_prb_map*
1066 config_malloc_prb_map(void)
1067 {
1068     //uint32_t size = sizeof(struct xran_prb_map)  + (XRAN_MAX_SECTIONS_PER_SLOT -1) * sizeof(struct xran_prb_elm);
1069     uint32_t size = sizeof(struct xran_prb_map)  + (8) * sizeof(struct xran_prb_elm);
1070     void *ret = NULL;
1071
1072     ret = malloc(size);
1073
1074     if(ret) {
1075         memset(ret, 0, size);
1076         return (struct xran_prb_map*)ret;
1077     } else {
1078         rte_panic("xran_prb_map alloc failed");
1079     }
1080 }
1081
1082 int32_t
1083 config_init(RuntimeConfig *p_o_xu_cfg)
1084 {
1085     int32_t i, j;
1086     memset(p_o_xu_cfg, 0, sizeof(RuntimeConfig));
1087
1088     p_o_xu_cfg->p_PrbMapDl  = config_malloc_prb_map();
1089     p_o_xu_cfg->p_PrbMapUl  = config_malloc_prb_map();
1090     p_o_xu_cfg->p_PrbMapSrs = config_malloc_prb_map();
1091
1092     for (i= 0; i < XRAN_DIR_MAX; i++){
1093         for (j= 0; j < XRAN_N_FE_BUF_LEN; j++){
1094            p_o_xu_cfg->p_SlotPrbMap[i][j] = config_malloc_prb_map();
1095         }
1096     }
1097
1098 #if 0
1099     for (i = 0; i < XRAN_DIR_MAX; i++) {
1100         for (j = 0; j < XRAN_N_FE_BUF_LEN; j++) {
1101             for (k = 0; k < XRAN_MAX_SECTOR_NR; k++) {
1102                 for (z = 0; z < XRAN_MAX_ANTENNA_NR; z++) {
1103                     p_o_xu_cfg->p_RunSlotPrbMap[i][j][k][z] = config_malloc_prb_map();
1104                     p_o_xu_cfg->p_RunSrsSlotPrbMap[i][j][k][z] = config_malloc_prb_map();
1105                 }
1106             }
1107         }
1108     }
1109 #endif
1110
1111     return 0;
1112 }
1113
1114
1115 int32_t
1116 config_init2(RuntimeConfig *p_o_xu_cfg)
1117 {
1118     int32_t i, j, k, z;
1119     for (i = 0; i < XRAN_DIR_MAX; i++) {
1120         for (j = 0; j < XRAN_N_FE_BUF_LEN; j++) {
1121             for (k = 0; k < p_o_xu_cfg->numCC; k++) {
1122                 for (z = 0; z < p_o_xu_cfg->numAxc; z++) {
1123                     p_o_xu_cfg->p_RunSlotPrbMap[i][j][k][z] = config_malloc_prb_map();
1124                     p_o_xu_cfg->p_RunSrsSlotPrbMap[i][j][k][z] = config_malloc_prb_map();
1125                 }
1126             }
1127         }
1128     }
1129
1130     return 0;
1131 }
1132
1133 int
1134 parseConfigFile(const char *filename, RuntimeConfig *config)
1135 {
1136     char inputLine[MAX_LINE_SIZE] = {0};
1137     int inputLen = 0;
1138     int i;
1139     int lineNum = 0;
1140     char key[MAX_LINE_SIZE] = {0};
1141     char value[MAX_LINE_SIZE] = {0};
1142     FILE *file = fopen(filename, "r");
1143
1144     if (NULL == file) {
1145         log_err("Error while opening config file from: %s", filename);
1146         return -1;
1147     }
1148
1149 //    init_config(config);
1150
1151     for (;;) {
1152         if (fgets(inputLine, MAX_LINE_SIZE, file) == NULL) {
1153             if (lineNum > 0) {
1154                 printf("%d lines of config file has been read.\n", lineNum);
1155                 break;
1156             } else {
1157                 printf("Configuration file reading error has occurred.\n");
1158                 fclose(file);
1159                 return -1;
1160             }
1161         }
1162
1163
1164         lineNum++;
1165         inputLen = strlen(inputLine);
1166
1167         for (i=0; i<inputLen; i++)
1168             if (inputLine[i] == '#') {
1169                 inputLine[i] = '\0';
1170                 inputLen = i + 1;
1171                 break;
1172             }
1173
1174         for (i=0; i<inputLen; i++)
1175             if (inputLine[i] == '=') {
1176                 strncpy(key, inputLine, i);
1177                 key[i] = '\0';
1178                 trim(key);
1179                 if ((i + 1 > inputLen - 1) || (i - 2 > inputLen)) {
1180                     log_err("Parsing config file error at line %d", lineNum);
1181                     fclose(file);
1182                     return -1;
1183                 }
1184                 strncpy(value, &inputLine[i+1], (sizeof(value) - 1));
1185                 value[inputLen-i-2] = '\0';
1186                 trim(value);
1187
1188                 if (strlen(key) == 0 || strlen(value) == 0) {
1189                     printf("Parsing config file error at line %d", lineNum);
1190                     fclose(file);
1191                     return -1;
1192                 }
1193
1194                 if (fillConfigStruct(config, key, value) != 0) {
1195                     fclose(file);
1196                     return -1;
1197                 }
1198
1199                 break;
1200             }
1201
1202         memset(&inputLine[0], 0, sizeof(MAX_LINE_SIZE));
1203         memset(&key[0], 0, sizeof(MAX_LINE_SIZE));
1204         memset(&value[0], 0, sizeof(MAX_LINE_SIZE));
1205     }
1206     fclose(file);
1207
1208     return 0;
1209 }
1210
1211 int32_t
1212 parseSlotConfigFile(const char *dir, RuntimeConfig *config)
1213 {
1214     int32_t ret     = 0;
1215     char filename[512];
1216     size_t len;
1217     int32_t slot_idx = 0;
1218     int32_t direction = 0;
1219     struct slot_cfg_to_pars slot_cfg_param;
1220
1221     for (direction = 0; direction < XRAN_DIR_MAX; direction++) {
1222         for (slot_idx = 0; slot_idx  < config->numSlots; slot_idx++){
1223             memset(filename, 0, sizeof(filename));
1224             printf("dir (%s)\n",dir);
1225             len = strlen(dir) + 1;
1226             if (len > 511) {
1227                 printf("parseSlotConfigFile: Name of directory, %s is too long.  Maximum is 511 characters!!\n", dir);
1228                 return -1;
1229             } else {
1230                 strncpy(filename, dir, len);
1231             }
1232             strncat(filename, "/", 1);
1233             len +=1;
1234             len = (sizeof(filename)) - len;
1235
1236             if(len > strlen(config->SlotNum_file[direction][slot_idx])){
1237                 strncat(filename, config->SlotNum_file[direction][slot_idx], RTE_MIN (len, strlen(config->SlotNum_file[direction][slot_idx])));
1238             } else {
1239                 printf("File name error\n");
1240                 return -1;
1241             }
1242             printf("slot_file[%d][%d] (%s)\n",direction, slot_idx, filename);
1243             printf("\n=================== Slot%s %d===================\n", ((direction == XRAN_DIR_UL) ? "RX" : "TX"), slot_idx);
1244
1245             slot_cfg_param.direction = direction;
1246             slot_cfg_param.slot_idx  = slot_idx;
1247             slot_cfg_param.config    = config;
1248
1249             if (parseFileViaCb(filename, fillSlotStructAsCb,  (void*)&slot_cfg_param)) {
1250                 printf("Configuration file error\n");
1251                 return -1;
1252             }
1253         }
1254     }
1255
1256     return ret;
1257 }
1258
1259 int32_t
1260 parseFileViaCb (char *filename, fillConfigStruct_fn cbFn, void* cbParm)
1261 {
1262     char inputLine[MAX_LINE_SIZE] = {0};
1263     int inputLen = 0;
1264     int i;
1265     int lineNum = 0;
1266     char key[MAX_LINE_SIZE] = {0};
1267     char value[MAX_LINE_SIZE] = {0};
1268     FILE *file = fopen(filename, "r");
1269
1270     if (NULL == file) {
1271         log_err("Error while opening config file from: %s", filename);
1272         return -1;
1273     }
1274
1275     for (;;) {
1276         if (fgets(inputLine, MAX_LINE_SIZE, file) == NULL) {
1277             if (lineNum > 0) {
1278                 printf("%d lines of config file has been read.\n", lineNum);
1279                 break;
1280             } else {
1281                 printf("Configuration file reading error has occurred.\n");
1282                 fclose(file);
1283                 return -1;
1284             }
1285         }
1286
1287
1288         lineNum++;
1289         inputLen = strlen(inputLine);
1290
1291         for (i=0; i<inputLen; i++)
1292             if (inputLine[i] == '#') {
1293                 inputLine[i] = '\0';
1294                 inputLen = i + 1;
1295                 break;
1296             }
1297
1298         for (i=0; i<inputLen; i++)
1299             if (inputLine[i] == '=') {
1300                 strncpy(key, inputLine, i);
1301                 key[i] = '\0';
1302                 trim(key);
1303                 if ((i + 1 > inputLen - 1) || (i - 2 > inputLen)) {
1304                     log_err("Parsing config file error at line %d", lineNum);
1305                     fclose(file);
1306                     return -1;
1307                 }
1308                 strncpy(value, &inputLine[i+1], (sizeof(value) - 1));
1309                 value[inputLen-i-2] = '\0';
1310                 trim(value);
1311
1312                 if (strlen(key) == 0 || strlen(value) == 0) {
1313                     printf("Parsing config file error at line %d", lineNum);
1314                     fclose(file);
1315                     return -1;
1316                 }
1317
1318                 if(cbFn){
1319                     if (cbFn(cbParm, key, value) != 0) {
1320                         fclose(file);
1321                         return -1;
1322                     }
1323                 } else {
1324                     printf("cbFn==NULL\n");
1325                     fclose(file);
1326                     return -1;
1327                 }
1328
1329                 break;
1330             }
1331
1332         memset(&inputLine[0], 0, sizeof(MAX_LINE_SIZE));
1333         memset(&key[0], 0, sizeof(MAX_LINE_SIZE));
1334         memset(&value[0], 0, sizeof(MAX_LINE_SIZE));
1335     }
1336     fclose(file);
1337
1338     return 0;
1339 }
1340
1341 int parseUsecaseFile(const char *filename, UsecaseConfig *usecase_cfg)
1342 {
1343     char inputLine[MAX_LINE_SIZE] = {0};
1344     int inputLen = 0;
1345     int i;
1346     int lineNum = 0;
1347     char key[MAX_LINE_SIZE] = {0};
1348     char value[MAX_LINE_SIZE] = {0};
1349     FILE *file = fopen(filename, "r");
1350
1351     if (NULL == file) {
1352         log_err("Error while opening config file from: %s", filename);
1353         return -1;
1354     }
1355
1356     for (;;) {
1357         if (fgets(inputLine, MAX_LINE_SIZE, file) == NULL) {
1358             if (lineNum > 0) {
1359                 printf("%d lines of config file has been read.\n", lineNum);
1360                 break;
1361             } else {
1362                 printf("Configuration file reading error has occurred.\n");
1363                 fclose(file);
1364                 return -1;
1365             }
1366         }
1367
1368
1369         lineNum++;
1370         inputLen = strlen(inputLine);
1371
1372         for (i=0; i<inputLen; i++)
1373             if (inputLine[i] == '#') {
1374                 inputLine[i] = '\0';
1375                 inputLen = i + 1;
1376                 break;
1377             }
1378
1379         for (i=0; i<inputLen; i++)
1380             if (inputLine[i] == '=') {
1381                 strncpy(key, inputLine, i);
1382                 key[i] = '\0';
1383                 trim(key);
1384                 if ((i + 1 > inputLen - 1) || (i - 2 > inputLen)) {
1385                     log_err("Parsing config file error at line %d", lineNum);
1386                     fclose(file);
1387                     return -1;
1388                 }
1389                 strncpy(value, &inputLine[i+1], (sizeof(value) - 1));
1390                 value[inputLen-i-2] = '\0';
1391                 trim(value);
1392
1393                 if (strlen(key) == 0 || strlen(value) == 0) {
1394                     printf("Parsing config file error at line %d", lineNum);
1395                     fclose(file);
1396                     return -1;
1397                 }
1398
1399                 if (fillUsecaseStruct(usecase_cfg, key, value) != 0) {
1400                     fclose(file);
1401                     return -1;
1402                 }
1403
1404                 break;
1405             }
1406
1407         memset(&inputLine[0], 0, sizeof(MAX_LINE_SIZE));
1408         memset(&key[0], 0, sizeof(MAX_LINE_SIZE));
1409         memset(&value[0], 0, sizeof(MAX_LINE_SIZE));
1410     }
1411     fclose(file);
1412
1413     return 0;
1414 }