* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fhi_lib / app / src / config.h
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 #ifndef _SAMPLEAPP__CONFIG_H_
27 #define _SAMPLEAPP__CONFIG_H_
28
29 #include <stdint.h>
30 #include <rte_ether.h>
31 #include "xran_fh_o_du.h"
32 #include "xran_pkt.h"
33
34 /** Run time configuration of application */
35 typedef struct _RuntimeConfig
36 {
37     uint8_t appMode;      /**< Application mode: lls-CU or RU  */
38     uint8_t xranTech;     /**< Radio Access Technology (NR or LTE) */
39     uint8_t xranCat;      /**< xran mode: NR Categoty A, NR Category B, LTE Cat A, LTE Cat B */
40     uint8_t numCC;        /**< Number of CC per ports supported by RU */
41     uint8_t numAxc;       /**< Number of Antenna Carriers per CC */
42     uint8_t numUlAxc;     /**< Number of Antenna Carriers per CC for UL (Cat B) */
43     uint32_t antElmTRx;   /**< Number of antenna elements for TX and RX */
44     uint32_t muMimoUEs;   /**< Number of UEs (with 1 RX ant)/beams */
45
46     uint32_t o_xu_id;     /**< id of O-DU|O-RU with in use case scenario */
47
48     uint32_t DlLayersPerUe; /**< Number of DL layer per UE */
49     uint32_t UlLayersPerUe; /**< Number of UL layer per UE */
50
51     uint32_t ttiPeriod;   /**< TTI period */
52     uint32_t testVect;    /**< Test Signal to send */
53     struct rte_ether_addr o_du_addr[XRAN_VF_MAX]; /**<  O-DU Ethernet Mac Address */
54     struct rte_ether_addr o_ru_addr[XRAN_VF_MAX]; /**<  O-RU Ethernet Mac Address */
55     struct rte_ether_addr tmp_addr; /**<  Temp Ethernet Mac Address */
56
57     uint32_t instance_id;  /**<  Instance ID of application */
58     uint32_t io_core;      /**<  Core used for IO */
59     uint64_t io_worker;           /**<  Mask for worker cores 0-63 */
60     uint64_t io_worker_64_127;    /**<  Mask for worker cores 64-127 */
61     int32_t  io_sleep;     /**< enable sleep on PMD cores */
62     uint32_t system_core;  /* house keeping core */
63     int      iova_mode;    /**< DPDK IOVA Mode */
64
65     uint32_t mtu; /**< maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single
66                        xRAN network layer transaction. supported 1500 bytes and 9600 bytes (Jumbo Frame) */
67     int numSlots;  /**< number of slots in IQ vector */
68     char ant_file[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**<  file to use for test vector */
69     char prach_file[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**<  file to use for test vector */
70
71     char dl_bfw_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file with beamforming weights for DL streams */
72     char ul_bfw_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file with beamforming weights for UL streams */
73
74     char ul_srs_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR][512]; /**< file with SRS content for UL antenna elements */
75
76     /* prach config */
77     uint8_t enablePrach; /**<  enable PRACH */
78     uint8_t prachOffset; /**< Sets the PRACH position in frequency / subcarrier position, n_PRBoffset^RA and is expressed as a physical resource block number.
79                               Set by SIB2, prach-FreqOffset in E-UTRA. */
80
81     uint8_t prachConfigIndex;/**< TS36.211 - Table 5.7.1-2 : PRACH Configuration Index */
82     uint8_t prachConfigIndexLTE;/**< PRACH Configuration Index for LTE in dss case*/
83     uint8_t iqswap;          /**< do swap of IQ before send to ETH */
84     uint8_t nebyteorderswap; /**< do swap of byte order from host byte order to network byte order. ETH */
85     uint8_t compression;     /**< enable use case with compression */
86     uint8_t CompHdrType;     /**< dynamic or static compression header */
87     uint8_t prachCompMethod; /**< compression enable for PRACH */
88     uint8_t prachiqWidth;    /**< IQ width for PRACH */
89
90     uint16_t totalBfWeights; /**< The total number of beamforming weights on RU */
91
92     uint8_t enableSrs; /**< enable SRS (valid for Cat B only) */
93     uint16_t srsSymMask;    /* deprecated */
94     uint16_t srsSlot;       /**< SRS slot within TDD period (special slot), for O-RU emulation */
95     uint8_t  srsNdmOffset;  /**< tti offset to delay the transmission of NDM SRS UP, for O-RU emulation */
96     uint16_t srsNdmTxDuration; /**< symbol duration for NDM SRS UP transmisson, for O-RU emulation */
97
98     uint8_t puschMaskEnable; /**< enable PUSCH mask, which means not tranfer PUSCH in some UL slot */
99     uint8_t puschMaskSlot; /**< PUSCH channel will not tranfer in slot module Frame */
100     uint8_t extType;
101
102     uint16_t maxFrameId; /**< max value of frame id */
103
104     uint16_t Tadv_cp_dl;
105     uint16_t T2a_min_cp_dl;
106     uint16_t T2a_max_cp_dl;
107     uint16_t T2a_min_cp_ul;
108     uint16_t T2a_max_cp_ul;
109     uint16_t T2a_min_up;
110     uint16_t T2a_max_up;
111     uint16_t Ta3_min;
112     uint16_t Ta3_max;
113     uint16_t T1a_min_cp_dl;
114     uint16_t T1a_max_cp_dl;
115     uint16_t T1a_min_cp_ul;
116     uint16_t T1a_max_cp_ul;
117     uint16_t T1a_min_up;
118     uint16_t T1a_max_up;
119     uint16_t Ta4_min;
120     uint16_t Ta4_max;
121
122     uint8_t enableCP;    /**<  enable C-plane */
123     uint8_t cp_vlan_tag; /**<  C-plane vlan tag */
124     uint8_t up_vlan_tag; /**<  U-plane vlan tag */
125
126     int32_t debugStop;
127     int32_t debugStopCount;
128     int32_t bbdevMode;
129     int32_t DynamicSectionEna;
130     int32_t GPS_Alpha;
131     int32_t GPS_Beta;
132
133     uint8_t  mu_number;       /**< Mu numner as per 3GPP */
134     uint32_t nDLAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
135     uint32_t nULAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
136     uint32_t nDLBandwidth;    /**< Carrier bandwidth for in MHz. Value: 5->400 */
137     uint32_t nULBandwidth;    /**< Carrier bandwidth for in MHz. Value: 5->400 */
138     uint32_t nDLFftSize;      /**< DL FFT size */
139     uint32_t nULFftSize;      /**< UL FFT size */
140
141
142     uint8_t nFrameDuplexType;
143     uint8_t nTddPeriod;
144     struct xran_slot_config sSlotConfig[XRAN_MAX_TDD_PERIODICITY];
145
146     struct xran_prb_map* p_PrbMapDl;
147     struct xran_prb_map* p_PrbMapUl;
148     struct xran_prb_map* p_PrbMapSrs;
149
150     uint8_t dssEnable;      /**< enable DSS (extension-9) */
151     uint8_t dssPeriod;      /**< DSS pattern period for LTE/NR */
152     uint8_t technology[XRAN_MAX_DSS_PERIODICITY];   /**< technology array represents slot is LTE(0)/NR(1) */
153
154     uint16_t SlotPrbCCmask[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTIONS_PER_SLOT];
155     uint64_t SlotPrbAntCMask[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTIONS_PER_SLOT];
156     struct xran_prb_map* p_SlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN];
157
158     int32_t RunSlotPrbMapEnabled;
159     struct xran_prb_map* p_RunSlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTOR_NR][XRAN_MAX_ANTENNA_NR];
160     struct xran_prb_map* p_RunSrsSlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTOR_NR][XRAN_MAX_ANTENNA_NR];
161
162     int32_t DU_Port_ID_bitwidth;
163     int32_t BandSector_ID_bitwidth;
164     int32_t CC_ID_bitwidth;
165     int32_t RU_Port_ID_bitwidth;
166     struct o_xu_buffers *p_buff;
167
168     int32_t SlotNum_fileEnabled;
169     char SlotNum_file[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][512]; /**<  file to use for test vector */
170
171     uint16_t max_sections_per_slot;
172     uint16_t max_sections_per_symbol;
173     int32_t RunSlotPrbMapBySymbolEnable;
174 } RuntimeConfig;
175
176 /** use case configuration  */
177 typedef struct _UsecaseConfig
178 {
179     uint8_t  oXuNum;        /**< Number of O-RU/O-DU connected to this instance */
180     uint8_t  appMode;       /**< Application mode: O-DU or O-RU  */
181
182     uint32_t instance_id;  /**< Instance ID of application */
183     uint32_t main_core;    /**< Core used for main() */
184     uint32_t io_core;      /**< Core used for IO */
185     uint64_t io_worker;           /**< Mask for worker cores 0-63 */
186     uint64_t io_worker_64_127;    /**< Mask for worker cores 64-127 */
187     int32_t  io_sleep;     /**< Enable sleep on PMD cores */
188     uint32_t system_core;  /**< System core */
189     int32_t  iova_mode;    /**< DPDK IOVA Mode */
190     int32_t  dpdk_mem_sz;  /**< Total DPDK memory size */
191
192     int32_t EthLinkSpeed;    /**< Ethernet Physical Link speed per O-RU: 10,25,40,100 >*/
193     int32_t EthLinesNumber;  /**< 1, 2, 3 total number of links per O-RU (Fronthaul Ethernet link) */
194     int32_t one_vf_cu_plane;  /**< 1 - C-plane and U-plane use one VF */
195     uint16_t owdmInitEn;     /**< One Way Delay Measurement Initiator if set, Recipient if clear */
196     uint16_t owdmMeasMeth;   /**< One Way Delay Measurement Method:0  REQUEST, 1 REM_REQ, 2 REQ_WFUP, 3 REM_REQ_WFUP */
197     uint16_t owdmNumSamps;   /**< One Way Delay Measurement number of samples per test */
198     uint16_t owdmFltType;    /**< One Way Delay Measurement Filter Type 0: Simple Average */
199     uint64_t owdmRspTo;      /**< One Way Delay Measurement Response Time Out in ns */
200     uint16_t owdmMeasState;  /**< One Way Delay Measurement State 0:INIT, 1:IDLE, 2:ACTIVE, 3:DONE */
201     uint16_t owdmMeasId;     /**< One Way Delay Measurement Id, Seed for the measurementId to be used */
202     uint16_t owdmEnable;     /**< One Way Delay Measurement master enable when set performs measurements on all vfs */
203     uint16_t owdmPlLength;   /**< One Way Delay Measurement Payload length   44<= PiLength <= 1400 bytes */
204
205     int num_vfs;  /**< Total numbers of VFs accrose all O-RU|O-DU */
206     int num_rxq;  /**< Total numbers of HW RX queues for each VF O-RU|O-DU */
207
208     struct rte_ether_addr remote_o_xu_addr[XRAN_PORTS_NUM][XRAN_VF_MAX]; /**<  O-DU Ethernet Mac Address */
209     struct rte_ether_addr remote_o_xu_addr_copy[XRAN_VF_MAX];            /**<  Temp Ethernet Mac Address */
210
211     char o_xu_cfg_file [XRAN_PORTS_NUM][512]; /**< file with config for each O-XU */
212     char o_xu_pcie_bus_addr[XRAN_PORTS_NUM][XRAN_VF_MAX][512]; /**<  VFs used for each O-RU|O-DU */
213
214
215     char o_xu_bbu_cfg_file[512]; /**< file with config for each O-XU */
216
217     char prefix_name[256];
218     uint8_t     dlCpProcBurst; /**< When set to 1, dl cp processing will be done on single symbol. When set to 0, DL CP processing
219                                      will be spread across all allowed symbols and multiple cores to reduce burstiness */
220     int32_t  bbu_offload;     /**< enable packet handling on BBU cores */
221     int32_t  mlogxrandisable;  /**< set to 1 to disable mlog 0 - default mlog enabled */
222 } UsecaseConfig;
223
224 /**
225  * Parse application configuration file.
226  *
227  * @param filename The name of the configuration file to be parsed.
228  * @param config The configuration structure to be filled with parsed data. */
229 int parseConfigFile(const char *filename, RuntimeConfig *config);
230
231 /**
232  * Parse application use case  file.
233  *
234  * @param filename The name of the use case file to be parsed.
235  * @param config The configuration structure to be filled with parsed data. */
236 int parseUsecaseFile(const char *filename, UsecaseConfig *config);
237
238 /**
239  * Parse slot config file.
240  *
241  * @param dir folder name.
242  * @param config The configuration structure to be filled with parsed data. */
243 int32_t parseSlotConfigFile(const char *dir, RuntimeConfig *config);
244 int32_t config_init(RuntimeConfig *p_o_xu_cfg);
245 int32_t config_init2(RuntimeConfig *p_o_xu_cfg);
246 struct xran_prb_map* config_malloc_prb_map(void);
247
248 #endif /* _SAMPLEAPP__CONFIG_H_ */