* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / include / fapi_vendor_extension.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2021 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 #ifndef _FAPI_VENDOR_EXTENSION_H_
20 #define _FAPI_VENDOR_EXTENSION_H_
21
22 #if defined(__cplusplus)
23 extern "C" {
24 #endif
25
26 #include <stdint.h>
27
28 #include "fapi_interface.h"
29
30 #define FAPI_VENDOR_MESSAGE                                 0x10
31 #define FAPI_VENDOR_EXT_SHUTDOWN_REQUEST                    0x11
32 #define FAPI_VENDOR_EXT_SHUTDOWN_RESPONSE                   0x12
33
34 #ifdef DEBUG_MODE
35 #define FAPI_VENDOR_EXT_DL_IQ_SAMPLES                       0x13
36 #define FAPI_VENDOR_EXT_UL_IQ_SAMPLES                       0x14
37 #define FAPI_VENDOR_EXT_START_RESPONSE                      0x15
38 #define FAPI_VENDOR_EXT_ADD_REMOVE_CORE                     0x16
39 #endif
40
41 #define FAPI_VENDOR_EXT_P7_IND                              0x17
42
43 /* ----- WLS Operation --- */
44 #define FAPI_VENDOR_MSG_HEADER_IND                          0x1A
45
46 // PDSCH Payload
47 #define FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ                   0x1B
48
49 #define MAX_SNR_COUNT                                       (255)
50 #define FAPI_VENDOR_MAX_RXRU_NUM                            16
51 #define FAPI_VENDOR_MAX_TXRU_NUM                            4
52 #define FAPI_VENDOR_MAX_SRS_PORT_PER_UE                     2
53 #define FAPI_VENDOR_MAX_NUM_ANT                             64
54
55 enum {
56     USE_VENDOR_EPREXSSB = 1
57 };
58
59 // Linked list header present at the top of all messages
60     typedef struct _fapi_api_queue_elem {
61         struct _fapi_api_queue_elem *p_next;
62         // p_tx_data_elm_list used for TX_DATA.request processing
63         struct _fapi_api_queue_elem *p_tx_data_elm_list;
64         uint8_t msg_type;
65         uint8_t num_message_in_block;
66         uint32_t msg_len;
67         uint32_t align_offset;
68         uint64_t time_stamp;
69     } fapi_api_queue_elem_t,
70     *p_fapi_api_queue_elem_t;
71 /* ----------------------- */
72
73 #ifdef DEBUG_MODE
74 #define FAPI_MAX_IQ_SAMPLE_FILE_SIZE                        576
75 #define FAPI_MAX_IQ_SAMPLE_DL_PORTS                          16
76 #define FAPI_MAX_IQ_SAMPLE_UL_PORTS                           2
77 #define FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS                  16
78 #define FAPI_MAX_IQ_SAMPLE_UL_ANTENNA                        64
79 #define FAPI_MAX_IQ_SAMPLE_BUFFER_SIZE                     4096
80
81 #define FAPI_MAX_NUM_SET_CORE_MASK ( 4 )
82 #define FAPI_MAX_MASK_OPTIONS      ( 4 )
83 #define FAPI_NUM_SPLIT_OPTIONS     ( 22 )
84 #define FAPI_MAX_NUM_CELLS         ( 32 )
85 #define FAPI_MAX_GROUP_NUM         ( 32 )
86 #endif
87
88     typedef struct {
89         uint16_t hopping_id;
90         uint8_t carrier_aggregation_level;
91         uint8_t group_hop_flag;
92         uint8_t sequence_hop_flag;
93         // uint8_t                     nDMRS_type_A_pos;
94         uint8_t prach_nr_of_rx_ru;
95         uint8_t nr_of_dl_ports;
96         uint8_t nr_of_ul_ports;
97         uint16_t urllc_capable;
98         uint16_t urllc_mini_slot_mask;
99         uint8_t ssb_subc_spacing;
100         uint8_t use_vendor_EpreXSSB;  // values: USE_VENDOR_EPREXSSB - use; else don't use
101         uint8_t pad[2];
102     } fapi_config_req_vendor_msg_t;
103
104     typedef struct {
105         uint16_t sfn;
106         uint16_t slot;
107         uint32_t mode;
108 #ifdef DEBUG_MODE
109         uint32_t count;
110         uint32_t period;
111 #endif
112     } fapi_start_req_vendor_msg_t;
113
114     typedef struct {
115         uint16_t sfn;
116         uint16_t slot;
117     } fapi_stop_req_vendor_msg_t;
118
119 // P7 vendor extensions
120     typedef struct {
121         uint8_t nr_of_antenna_ports;
122         uint8_t nr_of_rx_ru;
123         uint8_t pad[2];
124         uint8_t rx_ru_idx[FAPI_VENDOR_MAX_RXRU_NUM];
125         // open for extension for new fields from ULSCHPDUStruct
126     } fapi_vendor_ul_pusch_pdu_t;
127
128     typedef struct {
129         uint8_t nr_of_rx_ru;
130         uint8_t pad[1];
131         uint16_t group_id;
132         uint8_t rx_ru_idx[FAPI_VENDOR_MAX_RXRU_NUM];
133         // open for extension for new fields from ULCCHUCIPDUStruct
134     } fapi_vendor_ul_pucch_pdu_t;
135
136     typedef struct {
137         uint8_t nr_of_rx_ru;
138         uint8_t pad[3];
139         uint8_t rx_ru_idx[FAPI_VENDOR_MAX_RXRU_NUM];
140         // open for extension for new fields from SRSPDUStruct
141     } fapi_vendor_ul_srs_pdu_t;
142
143     typedef struct {
144         uint16_t pdu_type;
145         uint16_t pad;
146         union {
147             fapi_vendor_ul_pusch_pdu_t pusch_pdu;
148             fapi_vendor_ul_pucch_pdu_t pucch_pdu;
149             fapi_vendor_ul_srs_pdu_t srs_pdu;
150             // open for extension for prach vendor type (as in fapi_ul_tti_req_pdu_t)
151         } pdu;
152     } fapi_vendor_ul_tti_req_pdu_t;
153
154     typedef struct {
155         fapi_vendor_ul_tti_req_pdu_t ul_pdus[FAPI_MAX_NUMBER_UL_PDUS_PER_TTI];
156         uint8_t num_ul_pdu;
157         uint8_t pad[3];
158         uint32_t sym;
159         // open for extension for new fields from PULConfigRequestStruct
160     } fapi_vendor_ul_tti_req_t;
161
162     typedef struct {
163         uint16_t epre_ratio_of_pdcch_to_ssb;
164         uint16_t epre_ratio_of_dmrs_to_ssb;
165         // open for extension for new fields from DCIPDUStruct
166     } fapi_vendor_dl_dci_t;
167
168     typedef struct {
169         uint16_t num_dl_dci;
170         uint8_t pad[2];
171         fapi_vendor_dl_dci_t dl_dci[FAPI_MAX_NUMBER_DL_DCI];
172     } fapi_vendor_dl_pdcch_pdu_t;
173
174    typedef struct {
175         uint16_t epre_ratio_of_pdsch_to_ssb;
176         uint16_t epre_ratio_of_dmrs_to_ssb;
177         uint8_t nr_of_antenna_ports;
178         uint8_t pad[3];
179         uint8_t tx_ru_idx[FAPI_VENDOR_MAX_TXRU_NUM];
180         // open for extension for new fields from DLSCHPDUStruct
181     } fapi_vendor_dl_pdsch_pdu_t;
182
183     typedef struct {
184         uint16_t epre_ratio_to_ssb;
185         uint8_t pad[2];
186     } fapi_vendor_csi_rs_pdu_t;
187
188     typedef struct {
189         uint16_t pdu_type;
190         uint16_t pdu_size;
191         union {
192             fapi_vendor_dl_pdcch_pdu_t pdcch_pdu;
193             fapi_vendor_dl_pdsch_pdu_t pdsch_pdu;
194             fapi_vendor_csi_rs_pdu_t csi_rs_pdu;
195             // open for extension for ssb vendor types (as in fapi_dl_tti_req_pdu_t)
196         } pdu;
197     } fapi_vendor_dl_tti_req_pdu_t;
198
199     typedef struct {
200         uint32_t sym;
201         uint16_t lte_crs_carrier_freq_dl;
202         uint8_t lte_crs_present;
203         uint8_t lte_crs_carrier_bandwidth_dl;
204         uint8_t lte_crs_nr_of_crs_ports;
205         uint8_t lte_crs_v_shift;
206         uint8_t pdcch_precoder_en;
207         uint8_t ssb_precoder_en;
208         uint8_t num_pdus;
209         uint8_t pad[3];
210         fapi_vendor_dl_tti_req_pdu_t pdus[FAPI_MAX_PDUS_PER_SLOT];
211         // open for extension for new fields from DLConfigRequestStruct
212     } fapi_vendor_dl_tti_req_t;
213
214     typedef struct {
215         uint16_t pdu_type;
216         uint16_t pdu_size;
217         fapi_vendor_dl_pdcch_pdu_t pdcch_pdu_config;
218     } fapi_vendor_dci_pdu_t;
219
220     typedef struct {
221         uint32_t sym;
222         uint8_t num_pdus;
223         uint8_t pad[3];
224         fapi_vendor_dci_pdu_t pdus[FAPI_MAX_NUMBER_UCI_PDUS_PER_SLOT];
225         // open for extension for new fields from ULDCIRequestStruct
226     } fapi_vendor_ul_dci_req_t;
227
228     typedef struct {
229         uint32_t sym;
230         // open for extension for new fields from TXRequestStruct
231     } fapi_vendor_tx_data_req_t;
232
233     typedef struct {
234         fapi_vendor_dl_tti_req_t dl_tti_req;
235         fapi_vendor_ul_tti_req_t ul_tti_req;
236         fapi_vendor_ul_dci_req_t ul_dci_req;
237         fapi_vendor_tx_data_req_t tx_data_req;
238     } fapi_vendor_p7_msg_t;
239
240 // P7 vendor extensions end
241
242     typedef struct {
243         fapi_msg_t header;
244         fapi_config_req_vendor_msg_t config_req_vendor;
245         fapi_start_req_vendor_msg_t start_req_vendor;
246         fapi_stop_req_vendor_msg_t stop_req_vendor;
247         fapi_vendor_p7_msg_t p7_req_vendor;
248     } fapi_vendor_msg_t; //TODO: union?
249
250     typedef struct {
251         fapi_msg_t header;
252         uint16_t sfn;
253         uint16_t slot;
254         uint32_t test_type;
255     } fapi_vendor_ext_shutdown_req_t;
256
257     typedef struct {
258         fapi_msg_t header;
259         uint16_t sfn;
260         uint16_t slot;
261         uint32_t nStatus;
262     } fapi_vendor_ext_shutdown_res_t;
263
264     typedef struct {
265         int16_t nSNR[MAX_SNR_COUNT];
266         int16_t pad;
267     } fapi_vendor_ext_snr_t;
268
269     typedef struct {
270         uint8_t nr_of_port;
271         uint8_t nr_of_rx_ant;
272         uint16_t nr_of_rbs;
273         uint8_t is_chan_est_pres;
274         uint8_t pad[3];
275         int16_t *p_srs_chan_est[FAPI_VENDOR_MAX_SRS_PORT_PER_UE]
276             [FAPI_VENDOR_MAX_NUM_ANT];
277     } fapi_vendor_ext_srs_pdu_t;
278
279     typedef struct {
280         uint8_t num_pdus;
281         uint8_t pad[3];
282         fapi_vendor_ext_srs_pdu_t srs_pdus[FAPI_MAX_NUMBER_SRS_PDUS_PER_SLOT];
283     } fapi_vendor_ext_srs_ind_t;
284
285     typedef struct {
286         uint32_t carrier_idx;
287         uint32_t sym;
288     } fapi_vendor_ext_slot_ind_t;
289
290     typedef struct {
291         uint32_t carrier_idx;
292         uint32_t sym;
293     } fapi_vendor_ext_rx_data_ind_t;
294
295     typedef struct {
296         uint32_t carrier_idx;
297         uint32_t sym;
298     } fapi_vendor_ext_crc_ind_t;
299
300     typedef struct {
301         uint32_t carrier_idx;
302         uint32_t sym;
303     } fapi_vendor_ext_uci_ind_t;
304
305     typedef struct {
306         fapi_msg_t header;
307         fapi_vendor_ext_snr_t crc_snr;
308         fapi_vendor_ext_snr_t uci_snr;
309         fapi_vendor_ext_srs_ind_t srs_ind;
310         fapi_vendor_ext_slot_ind_t slot_ind;
311         fapi_vendor_ext_rx_data_ind_t rx_data_ind;        
312         fapi_vendor_ext_crc_ind_t crc_ind;
313         fapi_vendor_ext_uci_ind_t uci_ind;
314     } fapi_vendor_p7_ind_msg_t;
315
316 #ifdef DEBUG_MODE
317     typedef struct {
318         uint32_t carrNum;
319         uint32_t numSubframes;
320         uint32_t nIsRadioMode;
321         uint32_t timerModeFreqDomain;
322         uint32_t phaseCompensationEnable;
323         uint32_t startFrameNum;
324         uint32_t startSlotNum;
325         uint32_t startSymNum;
326         char filename_in_ul_iq[FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS]
327             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
328         char filename_in_ul_iq_compressed[FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS]
329             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
330         char filename_in_prach_iq[FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS]
331             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
332         char filename_in_srs_iq[FAPI_MAX_IQ_SAMPLE_UL_ANTENNA]
333             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
334         char filename_out_dl_iq[FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
335         char filename_out_dl_beam[FAPI_MAX_IQ_SAMPLE_DL_PORTS]
336             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
337         char filename_out_ul_beam[FAPI_MAX_IQ_SAMPLE_UL_VIRTUAL_PORTS]
338             [FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
339         char filename_out_dl_iq_compressed[FAPI_MAX_IQ_SAMPLE_FILE_SIZE];
340
341         /* DL Compression add */
342         uint16_t nDLCompressionIdx;
343         uint16_t nDLCompiqWidth;
344         uint16_t nDLCompScaleFactor;
345         uint16_t nDLCompreMask;
346
347         /*nULDecompressionIdx, determine the UL Decompression method, Value:0->4*/
348         /*0:NONE,  1:BLKFLOAT,  2:BLKSCALE,  3:ULAW,  4:MODULATION*/
349         uint16_t nULDecompressionIdx;
350         uint16_t nULDecompiqWidth;
351
352         uint8_t buffer[FAPI_MAX_IQ_SAMPLE_BUFFER_SIZE];
353     } fapi_vendor_ext_iq_samples_info_t;
354
355     typedef struct {
356         fapi_msg_t header;
357         fapi_vendor_ext_iq_samples_info_t iq_samples_info;
358     } fapi_vendor_ext_iq_samples_req_t;
359
360     typedef struct {
361         fapi_msg_t header;
362     } fapi_vendor_ext_dl_iq_samples_res_t;
363
364     typedef struct {
365         fapi_msg_t header;
366     } fapi_vendor_ext_ul_iq_samples_res_t;
367
368     typedef struct {
369         fapi_msg_t header;
370     } fapi_vendor_ext_start_response_t;
371
372     typedef struct {
373         uint32_t eOption;
374         uint64_t nCoreMask[FAPI_MAX_MASK_OPTIONS][FAPI_MAX_NUM_SET_CORE_MASK];
375         uint32_t nMacOptions[FAPI_NUM_SPLIT_OPTIONS];
376         uint8_t  nPuschInterOptions[FAPI_MAX_NUM_CELLS][FAPI_MAX_GROUP_NUM];
377     } fapi_vendor_ext_add_remove_core_info_t;
378
379     typedef struct {
380         fapi_msg_t header;
381         fapi_vendor_ext_add_remove_core_info_t add_remove_core_info;
382     } fapi_vendor_ext_add_remove_core_msg_t;
383 #endif
384
385 #if defined(__cplusplus)
386 }
387 #endif
388 #endif                          // FAPI_VENDOR_EXTENSION_H_