O-RAN E Maintenance Release contribution for ODULOW
[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 iqswap;          /**< do swap of IQ before send to ETH */
83     uint8_t nebyteorderswap; /**< do swap of byte order from host byte order to network byte order. ETH */
84     uint8_t compression;     /**< enable use case with compression */
85     uint8_t CompHdrType;     /**< dynamic or static compression header */
86     uint8_t prachCompMethod; /**< compression enable for PRACH */
87     uint8_t prachiqWidth;    /**< IQ width for PRACH */
88
89     uint16_t totalBfWeights; /**< The total number of beamforming weights on RU */
90
91     uint8_t enableSrs; /**< enable SRS (valid for Cat B only) */
92     uint16_t srsSymMask; /**< SRS symbol mask [014] within S/U slot [0-13] def is  13 */
93
94     uint8_t puschMaskEnable; /**< enable PUSCH mask, which means not tranfer PUSCH in some UL slot */
95     uint8_t puschMaskSlot; /**< PUSCH channel will not tranfer in slot module Frame */
96
97     uint16_t maxFrameId; /**< max value of frame id */
98
99     uint16_t Tadv_cp_dl;
100     uint16_t T2a_min_cp_dl;
101     uint16_t T2a_max_cp_dl;
102     uint16_t T2a_min_cp_ul;
103     uint16_t T2a_max_cp_ul;
104     uint16_t T2a_min_up;
105     uint16_t T2a_max_up;
106     uint16_t Ta3_min;
107     uint16_t Ta3_max;
108     uint16_t T1a_min_cp_dl;
109     uint16_t T1a_max_cp_dl;
110     uint16_t T1a_min_cp_ul;
111     uint16_t T1a_max_cp_ul;
112     uint16_t T1a_min_up;
113     uint16_t T1a_max_up;
114     uint16_t Ta4_min;
115     uint16_t Ta4_max;
116
117     uint8_t enableCP;    /**<  enable C-plane */
118     uint8_t cp_vlan_tag; /**<  C-plane vlan tag */
119     uint8_t up_vlan_tag; /**<  U-plane vlan tag */
120
121     int32_t debugStop;
122     int32_t debugStopCount;
123     int32_t bbdevMode;
124     int32_t DynamicSectionEna;
125     int32_t GPS_Alpha;
126     int32_t GPS_Beta;
127
128     uint8_t  mu_number;       /**< Mu numner as per 3GPP */
129     uint32_t nDLAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
130     uint32_t nULAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
131     uint32_t nDLBandwidth;    /**< Carrier bandwidth for in MHz. Value: 5->400 */
132     uint32_t nULBandwidth;    /**< Carrier bandwidth for in MHz. Value: 5->400 */
133     uint32_t nDLFftSize;      /**< DL FFT size */
134     uint32_t nULFftSize;      /**< UL FFT size */
135
136
137     uint8_t nFrameDuplexType;
138     uint8_t nTddPeriod;
139     struct xran_slot_config sSlotConfig[XRAN_MAX_TDD_PERIODICITY];
140
141     struct xran_prb_map* p_PrbMapDl;
142     struct xran_prb_map* p_PrbMapUl;
143     struct xran_prb_map* p_PrbMapSrs;
144
145     uint16_t SlotPrbCCmask[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTIONS_PER_SLOT];
146     uint64_t SlotPrbAntCMask[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTIONS_PER_SLOT];
147     struct xran_prb_map* p_SlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN];
148
149     int32_t RunSlotPrbMapEnabled;
150     struct xran_prb_map* p_RunSlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTOR_NR][XRAN_MAX_ANTENNA_NR];
151     struct xran_prb_map* p_RunSrsSlotPrbMap[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][XRAN_MAX_SECTOR_NR][XRAN_MAX_ANTENNA_NR];
152
153     int32_t DU_Port_ID_bitwidth;
154     int32_t BandSector_ID_bitwidth;
155     int32_t CC_ID_bitwidth;
156     int32_t RU_Port_ID_bitwidth;
157     struct o_xu_buffers *p_buff;
158
159     int32_t SlotNum_fileEnabled;
160     char SlotNum_file[XRAN_DIR_MAX][XRAN_N_FE_BUF_LEN][512]; /**<  file to use for test vector */
161
162     uint16_t max_sections_per_slot;
163     uint16_t max_sections_per_symbol;
164 } RuntimeConfig;
165
166 /** use case configuration  */
167 typedef struct _UsecaseConfig
168 {
169     uint8_t  oXuNum;        /**< Number of O-RU/O-DU connected to this instance */
170     uint8_t  appMode;       /**< Application mode: O-DU or O-RU  */
171
172     uint32_t instance_id;  /**< Instance ID of application */
173     uint32_t main_core;    /**< Core used for main() */
174     uint32_t io_core;      /**< Core used for IO */
175     uint64_t io_worker;           /**< Mask for worker cores 0-63 */
176     uint64_t io_worker_64_127;    /**< Mask for worker cores 64-127 */
177     int32_t  io_sleep;     /**< Enable sleep on PMD cores */
178     uint32_t system_core;  /**< System core */
179     int32_t  iova_mode;    /**< DPDK IOVA Mode */
180     int32_t  dpdk_mem_sz;  /**< Total DPDK memory size */
181
182     int32_t EthLinkSpeed;    /**< Ethernet Physical Link speed per O-RU: 10,25,40,100 >*/
183     int32_t EthLinesNumber;  /**< 1, 2, 3 total number of links per O-RU (Fronthaul Ethernet link) */
184     int32_t one_vf_cu_plane;  /**< 1 - C-plane and U-plane use one VF */
185     uint16_t owdmInitEn;     /**< One Way Delay Measurement Initiator if set, Recipient if clear */
186     uint16_t owdmMeasMeth;   /**< One Way Delay Measurement Method:0  REQUEST, 1 REM_REQ, 2 REQ_WFUP, 3 REM_REQ_WFUP */
187     uint16_t owdmNumSamps;   /**< One Way Delay Measurement number of samples per test */
188     uint16_t owdmFltType;    /**< One Way Delay Measurement Filter Type 0: Simple Average */
189     uint64_t owdmRspTo;      /**< One Way Delay Measurement Response Time Out in ns */
190     uint16_t owdmMeasState;  /**< One Way Delay Measurement State 0:INIT, 1:IDLE, 2:ACTIVE, 3:DONE */
191     uint16_t owdmMeasId;     /**< One Way Delay Measurement Id, Seed for the measurementId to be used */
192     uint16_t owdmEnable;     /**< One Way Delay Measurement master enable when set performs measurements on all vfs */
193     uint16_t owdmPlLength;   /**< One Way Delay Measurement Payload length   44<= PiLength <= 1400 bytes */
194
195     int num_vfs;  /**< Total numbers of VFs accrose all O-RU|O-DU */
196     int num_rxq;  /**< Total numbers of HW RX queues for each VF O-RU|O-DU */
197
198     struct rte_ether_addr remote_o_xu_addr[XRAN_PORTS_NUM][XRAN_VF_MAX]; /**<  O-DU Ethernet Mac Address */
199     struct rte_ether_addr remote_o_xu_addr_copy[XRAN_VF_MAX];            /**<  Temp Ethernet Mac Address */
200
201     char o_xu_cfg_file [XRAN_PORTS_NUM][512]; /**< file with config for each O-XU */
202     char o_xu_pcie_bus_addr[XRAN_PORTS_NUM][XRAN_VF_MAX][512]; /**<  VFs used for each O-RU|O-DU */
203
204     char prefix_name[256];
205
206 } UsecaseConfig;
207
208 /**
209  * Parse application configuration file.
210  *
211  * @param filename The name of the configuration file to be parsed.
212  * @param config The configuration structure to be filled with parsed data. */
213 int parseConfigFile(char *filename, RuntimeConfig *config);
214
215 /**
216  * Parse application use case  file.
217  *
218  * @param filename The name of the use case file to be parsed.
219  * @param config The configuration structure to be filled with parsed data. */
220 int parseUsecaseFile(char *filename, UsecaseConfig *config);
221
222 /**
223  * Parse slot config file.
224  *
225  * @param dir folder name.
226  * @param config The configuration structure to be filled with parsed data. */
227 int32_t parseSlotConfigFile(char *dir, RuntimeConfig *config);
228 int32_t config_init(RuntimeConfig *p_o_xu_cfg);
229 struct xran_prb_map* config_malloc_prb_map(void);
230
231 #endif /* _SAMPLEAPP__CONFIG_H_ */