8f9d4068583002fd0d463f769a28f279e42d3a13
[o-du/phy.git] / fhi_lib / app / src / common.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 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 #ifndef _XRAN_APP_COMMON_H_
21 #define _XRAN_APP_COMMON_H_
22
23 #include <stdio.h>
24 #include <unistd.h>
25
26 #include "xran_fh_o_du.h"
27 #include "xran_pkt_up.h"
28
29 #include <rte_common.h>
30 #include <rte_mbuf.h>
31
32 #define VERSIONX                "#DIRTY#"
33
34 #define APP_O_DU  0
35 #define APP_O_RU  1
36
37 enum app_state
38 {
39     APP_RUNNING,
40     APP_STOPPED
41 };
42
43 enum nRChBwOptions
44 {
45     PHY_BW_5_0_MHZ = 5,   PHY_BW_10_0_MHZ = 10, PHY_BW_15_0_MHZ = 15, PHY_BW_20_0_MHZ = 20, PHY_BW_25_0_MHZ = 25,
46     PHY_BW_30_0_MHZ = 30, PHY_BW_40_0_MHZ = 40, PHY_BW_50_0_MHZ = 50, PHY_BW_60_0_MHZ = 60, PHY_BW_70_0_MHZ = 70,
47     PHY_BW_80_0_MHZ = 80, PHY_BW_90_0_MHZ = 90, PHY_BW_100_0_MHZ = 100, PHY_BW_200_0_MHZ = 200, PHY_BW_400_0_MHZ = 400
48 };
49
50 #define N_SC_PER_PRB 12
51 #define N_SYM_PER_SLOT 14
52 #define MAX_ANT_CARRIER_SUPPORTED (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR)
53
54 #define SUBFRAME_DURATION_US       1000
55 //#define SLOTNUM_PER_SUBFRAME       8
56
57 #define SUBFRAMES_PER_SYSTEMFRAME  10
58 #define IQ_PLAYBACK_BUFFER_BYTES (XRAN_NUM_OF_SLOT_IN_TDD_LOOP*N_SYM_PER_SLOT*66*N_SC_PER_PRB*4L)
59 /* PRACH data samples are 32 bits wide, 16bits for I and 16bits for Q. Each packet contains 839 samples for long sequence or 144*14 (max) for short sequence. The payload length is 3356 octets.*/
60 #define PRACH_PLAYBACK_BUFFER_BYTES (144*14*4L)
61
62 #ifdef _DEBUG
63 #define iAssert(p) if(!(p)){fprintf(stderr,\
64     "Assertion failed: %s, file %s, line %d, val %d\n",\
65     #p, __FILE__, __LINE__, p);exit(-1);}
66 #else /* _DEBUG */
67 #define iAssert(p)
68 #endif /* _DEBUG */
69
70 extern int iq_playback_buffer_size_dl;
71 extern int iq_playback_buffer_size_ul;
72
73 extern uint8_t numCCPorts;
74 /* Number of antennas supported by front-end */
75
76 extern uint8_t num_eAxc;
77 /* Number of antennas supported by front-end */
78 extern int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
79 extern int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
80 extern int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
81
82 extern int16_t *p_tx_prach_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
83 extern int32_t tx_prach_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
84 extern int32_t tx_prach_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
85
86 /* Number of antennas supported by front-end */
87 extern int16_t *p_rx_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
88 extern int32_t rx_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
89 extern int32_t rx_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
90
91 extern int16_t *p_prach_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
92 extern int32_t prach_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
93 extern int32_t prach_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
94
95 extern int16_t *p_tx_buffer[MAX_ANT_CARRIER_SUPPORTED];
96 extern int32_t tx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
97
98 extern int16_t *p_rx_buffer[MAX_ANT_CARRIER_SUPPORTED];
99 extern int32_t rx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
100
101 void sys_save_buf_to_file_txt(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
102 void sys_save_buf_to_file(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
103 int  sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
104 uint32_t app_xran_get_scs(uint8_t nMu);
105 uint16_t app_xran_get_num_rbs(uint32_t nNumerology, uint32_t nBandwidth, uint32_t nAbsFrePointA);
106 uint32_t app_xran_cal_nrarfcn(uint32_t nCenterFreq);
107 int32_t app_xran_set_slot_type(uint32_t nPhyInstanceId, uint32_t nFrameDuplexType,
108                 uint32_t nTddPeriod, struct xran_slot_config *psSlotConfig);
109 uint32_t app_xran_get_tti_interval(uint8_t nMu);
110
111
112
113 #endif /*_XRAN_APP_COMMON_H_*/