Front Haul Interface Library first seed code contribution
[o-du/phy.git] / fhi_lib / app / common / 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 #include <stdio.h>
20 #include <unistd.h>
21
22 #include "xran_pkt_up.h"
23
24 #include <rte_common.h>
25 #include <rte_mbuf.h>
26
27 #define APP_LLS_CU 0
28 #define APP_RU     1
29
30 enum app_state
31 {
32     APP_RUNNING,
33     APP_STOPPED
34 };
35
36 #define NUM_OF_PRB_IN_FULL_BAND (66)
37 #define N_SC_PER_PRB 12
38 #define N_SYM_PER_SLOT 14
39 #define N_FULLBAND_SC (NUM_OF_PRB_IN_FULL_BAND*N_SC_PER_PRB)
40 #define MAX_ANT_CARRIER_SUPPORTED 16
41 // 0.125, just for testing
42 #define SLOTNUM_PER_SUBFRAME      8
43 #define SUBFRAMES_PER_SYSTEMFRAME  10
44 #define PDSCH_PAYLOAD_SIZE (N_FULLBAND_SC*4)
45 #define NUM_OF_SLOT_IN_TDD_LOOP         (80)
46 #define IQ_PLAYBACK_BUFFER_BYTES (NUM_OF_SLOT_IN_TDD_LOOP*N_SYM_PER_SLOT*N_FULLBAND_SC*4L)
47 /* PRACH data samples are 32 bits wide, 16bits for I and 16bits for Q. Each packet contains 839 samples. The payload length is 3356 octets.*/
48 #define PRACH_PLAYBACK_BUFFER_BYTES (10*839*4L)
49
50 #ifdef _DEBUG
51 #define iAssert(p) if(!(p)){fprintf(stderr,\
52     "Assertion failed: %s, file %s, line %d, val %d\n",\
53     #p, __FILE__, __LINE__, p);exit(-1);}
54 #else /* _DEBUG */
55 #define iAssert(p)
56 #endif /* _DEBUG */
57
58 struct send_symbol_cb_args
59 {
60     struct rb_map *samp_buf;
61     uint8_t *symb_id;
62 };
63
64 struct pkt_dump
65 {
66     int num_samp;
67     int num_bytes;
68     uint8_t symb;
69     struct ecpri_seq_id seq;
70 } __rte_packed;
71
72 extern uint8_t numCCPorts;
73 /* Number of antennas supported by front-end */
74
75 extern uint8_t num_eAxc;
76 /* Number of antennas supported by front-end */
77 extern int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
78 extern int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
79 extern int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
80
81 /* Number of antennas supported by front-end */
82 extern int16_t *p_rx_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
83 extern int32_t rx_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
84 extern int32_t rx_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
85
86 extern int16_t *p_prach_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
87 extern int32_t prach_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
88 extern int32_t prach_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
89
90 extern int16_t *p_tx_buffer[MAX_ANT_CARRIER_SUPPORTED];
91 extern int32_t tx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
92
93 extern int16_t *p_rx_buffer[MAX_ANT_CARRIER_SUPPORTED];
94 extern int32_t rx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
95
96 void sys_save_buf_to_file_txt(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
97 void sys_save_buf_to_file(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
98 int  sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
99