1 /******************************************************************************
3 * Copyright (c) 2020 Intel.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
20 * @brief This file consists of parameters that are to be read from ebbu_pool_cfg.xml
21 * to configure the application at system initialization
22 * @file ebbu_pool_cfg.h
24 * @author Intel Corporation
28 #include "ebbu_pool_cfg.h"
30 #include <sys/param.h>
34 static eBbuPoolCfgVarsStruct geBbuPoolCfgVars;
35 char eBbuPoolCfgFileName[512];
37 uint32_t nD2USwitch[EBBU_POOL_MAX_FRAME_FORMAT][EBBU_POOL_TDD_PERIOD] =
39 {0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3}, //FDD
40 {0x1, 0x1, 0x1, 0x3, 0x2, 0x1, 0x1, 0x1, 0x3, 0x2}, //DDDSU
41 {0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2} //DDDDDDDSUU
44 //-------------------------------------------------------------------------------------------
45 /** @ingroup group_test_ebbu_pool
49 * @return eBBUPool Config Local Context Structure Pointer
52 * Returns the eBBUPool Config Local Context Structure Pointer
55 //-------------------------------------------------------------------------------------------
56 peBbuPoolCfgVarsStruct ebbu_pool_cfg_get_ctx(void)
58 return &geBbuPoolCfgVars;
63 //-------------------------------------------------------------------------------------------
64 /** @ingroup group_test_ebbu_pool
71 * Initialize the geBbuPoolCfgVars. This is called at application bootup
74 //-------------------------------------------------------------------------------------------
75 void ebbu_pool_cfg_init_vars(void)
77 memset(&geBbuPoolCfgVars, 0, sizeof(eBbuPoolCfgVarsStruct));
82 //-------------------------------------------------------------------------------------------
83 /** @ingroup group_test_ebbu_pool
85 * @param[in] *pCfgFile Pointer to FILE descriptor to read from
87 * @return 0 if SUCCESS
90 * This function parses the XML file that was opened and reads all the tags and associated
91 * values and stores them
94 //-------------------------------------------------------------------------------------------
95 uint32_t ebbu_pool_cfg_parse_xml(FILE *pCfgFile)
97 // peBbuPoolCfgVarsStruct geBbuPoolCfgVars = ebbu_pool_cfg_get_ctx();
98 uint32_t lineNum = 0, retCode;
101 while(!feof(pCfgFile))
103 fgets(string, 1024, pCfgFile);
105 retCode = cline_parse_line(string);
107 if (retCode != EBBU_POOL_CFG_ERRORCODE__SUCCESS)
109 printf("Something wrong in file %s ErrorCode[%d] at line[%d]: %s\n", eBbuPoolCfgFileName, (int) retCode, (int)lineNum, string);
110 return EBBU_POOL_CFG_ERRORCODE__FAIL;
114 return EBBU_POOL_CFG_ERRORCODE__SUCCESS;
118 //-------------------------------------------------------------------------------------------
119 /** @ingroup group_test_ebbu_pool
123 * @return 0 if SUCCESS
126 * This function searches for tags from xml and applies the values to the eBBUPool test
129 //-------------------------------------------------------------------------------------------
130 uint32_t ebbu_pool_cfg_apply(void)
132 printf("ebbu_pool_cfg_apply\n");
133 peBbuPoolCfgVarsStruct geBbuPoolCfgVars = ebbu_pool_cfg_get_ctx();
134 int rc = EBBU_POOL_CFG_ERRORCODE__SUCCESS;
135 int32_t coreNum, cellNum, iCell;
136 uint32_t cellFrameCfg[EBBU_POOL_MAX_TEST_CELL], cellTtiCfg[EBBU_POOL_MAX_TEST_CELL], cellEventCfg[EBBU_POOL_MAX_TEST_CELL];
140 //----------------------------------------------------
141 // eBbuPool general config
142 //----------------------------------------------------
143 rc |= cline_set_int((const char *) "eBbuPoolMainThreadCore", (int *) &geBbuPoolCfgVars->mainThreadCoreId, 0);
144 rc |= cline_set_int((const char *) "eBbuPoolConsumerSleep", (int *) &geBbuPoolCfgVars->sleepFlag, 1);
146 //----------------------------------------------------
148 //----------------------------------------------------
149 rc |= cline_set_int((const char *) "QueueDepth", (int *) &geBbuPoolCfgVars->queueDepth, 1024);
150 rc |= cline_set_int((const char *) "QueueNum", (int *) &geBbuPoolCfgVars->queueNum, 3);
151 rc |= cline_set_int((const char *) "QueuCtxNum", (int *) &geBbuPoolCfgVars->ququeCtxNum, 1);
153 //----------------------------------------------------
155 //----------------------------------------------------
156 rc |= cline_set_int((const char *) "TimerThreadCore", (int *) &geBbuPoolCfgVars->timerCoreId, 0);
157 rc |= cline_set_int((const char *) "CtrlThreadNum", (int *) &geBbuPoolCfgVars->ctrlThreadNum, 0);
158 rc |= cline_set_int_array((const char *) "CtrlThreadCoreList", EBBU_POOL_MAX_CTRL_THREAD,(int *) &geBbuPoolCfgVars->ctrlThreadCoreId[0], &coreNum);
159 rc |= cline_set_int((const char *) "TestCellNum", (int *) &geBbuPoolCfgVars->testCellNum, 0);
160 rc |= cline_set_int((const char *) "TestCoreNum", (int *) &geBbuPoolCfgVars->testCoreNum, 0);
161 rc |= cline_set_int_array((const char *) "TestCoreList", EBBU_POOL_MAX_TEST_CORE, (int *) &geBbuPoolCfgVars->testCoreList[0], &coreNum);
162 rc |= cline_set_int_array((const char *) "TestCellFrameFormat", EBBU_POOL_MAX_TEST_CELL, (int *) &cellFrameCfg[0], &cellNum);
163 rc |= cline_set_int_array((const char *) "TestCellTti", EBBU_POOL_MAX_TEST_CELL, (int *) &cellTtiCfg[0], &cellNum);
164 rc |= cline_set_int_array((const char *) "TestCellEventNum", EBBU_POOL_MAX_TEST_CELL, (int *) &cellEventCfg[0], &cellNum);
165 rc |= cline_set_int((const char *) "MlogEnable", (int *) &geBbuPoolCfgVars->mlogEnable, 0);
167 if(cellNum > geBbuPoolCfgVars->testCellNum)
168 cellNum = geBbuPoolCfgVars->testCellNum;
170 for(iCell = 0; iCell < cellNum; iCell ++)
172 geBbuPoolCfgVars->sTestCell[iCell].frameFormat = cellFrameCfg[iCell];
173 geBbuPoolCfgVars->sTestCell[iCell].tti = cellTtiCfg[iCell];
174 geBbuPoolCfgVars->sTestCell[iCell].eventPerTti = cellEventCfg[iCell];
178 printf("eBbuPool config completely read: %x\n", rc);
188 //-------------------------------------------------------------------------------------------
189 /** @ingroup group_test_ebbu_pool
193 * @return 0 if SUCCESS
196 * This function is called from main() and initializes the EBBU_POOL_CFG layer. It reads the xml
197 * file and configures the application based on xml tags and values from file.
200 //-------------------------------------------------------------------------------------------
201 uint32_t ebbu_pool_cfg_init_from_xml(void)
203 // peBbuPoolCfgVarsStruct geBbuPoolCfgVars = ebbu_pool_cfg_get_ctx();
205 pCfgFile = fopen(eBbuPoolCfgFileName, "r");
207 ebbu_pool_cfg_init_vars();
211 if (pCfgFile == NULL)
213 printf("ERROR: %s file is not found in directory\n", eBbuPoolCfgFileName);
214 printf(" Please contact Intel to get the correct config file\n");
215 return EBBU_POOL_CFG_ERRORCODE__FAIL;
218 if (ebbu_pool_cfg_parse_xml(pCfgFile) != EBBU_POOL_CFG_ERRORCODE__SUCCESS)
220 printf("Could not Parse the XML File.\n");
222 return EBBU_POOL_CFG_ERRORCODE__FAIL;
224 printf("PhyCfg XML file parsed\n");
226 if (ebbu_pool_cfg_apply() != EBBU_POOL_CFG_ERRORCODE__SUCCESS)
228 printf("Could not Apply the settings from XML File.\n");
230 return EBBU_POOL_CFG_ERRORCODE__FAIL;
234 return EBBU_POOL_CFG_ERRORCODE__SUCCESS;
238 //-------------------------------------------------------------------------------------------
239 /** @ingroup group_test_ebbu_pool
241 * @param[in] argc Number of command line arguments
242 * @param[in] *argv[] Array of command line arguments
247 * This function parses the command line parameters entered while running the eBbuPool test application
248 * and searches for string "cfgfile" and takes the immediate next field and uses it as the
249 * xml file name. If it is not found, it uses default file name "bbdev_cfg.xml" and tries to open
253 //-------------------------------------------------------------------------------------------
254 void ebbu_pool_cfg_set_cfg_filename(int argc, char *argv[], char filename[512])
256 // peBbuPoolCfgVarsStruct geBbuPoolCfgVars = ebbu_pool_cfg_get_ctx();
259 ret = cline_get_string(argc, argv, "cfgfile", eBbuPoolCfgFileName);
261 if (ret != AUX_SUCCESS)
263 printf("ebbu_pool_cfg_set_cfg_filename: Coult not find string 'cfgfile' in command line. Using default File: %s\n", EBBU_POOL_FILE_NAME);
264 strcpy(eBbuPoolCfgFileName, EBBU_POOL_FILE_NAME);
266 strcpy(filename, eBbuPoolCfgFileName);
268 strncpy(eBbuPoolCfgFileName, filename, MIN(strnlen(filename, 511),511) );
269 eBbuPoolCfgFileName[511] = '\0';
270 printf("eBbuPoolCfgFileName %s\n", eBbuPoolCfgFileName);