* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fhi_lib / test / test_xran / u_plane_performance.cc
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 #include "common.hpp"
21
22 #include "xran_common.h"
23 #include "xran_up_api.h"
24 #include "xran_fh_o_du.h"
25 #include "ethernet.h"
26
27 #include <stdint.h>
28
29 const std::string module_name = "U-Plane";
30
31     /*union xran_test {
32                 struct {
33             struct xran_cp_radioapp_common_header cmnhdr;
34             struct xran_radioapp_udComp_header udComp;
35             uint8_t     reserved;
36                 }field;
37                 struct {
38                         uint32_t     data_one;
39                         uint32_t     data_two;
40                 }all_data;
41     };*/
42     void fucntional_dl(struct rte_mbuf *test_buffer, char * iq_offset)
43     {
44         enum xran_pkt_dir direction =  XRAN_DIR_DL;
45         uint16_t section_id = 7;
46         uint16_t num_sections = 1;
47         enum xran_input_byte_order iq_buf_byte_order = XRAN_CPU_LE_BYTE_ORDER;
48         uint8_t frame_id = 99;
49         uint8_t subframe_id  = 9;
50         uint8_t slot_id = 10;
51         uint8_t symbol_no = 7;
52         int prb_start = 0;
53         int prb_num = 66;
54         uint8_t CC_ID = 0;
55         uint8_t RU_Port_ID = 0;
56         uint8_t seq_id =0;
57         uint32_t do_copy = 0;
58         uint8_t compMeth = 0;
59         enum xran_comp_hdr_type staticEn = XRAN_COMP_HDR_TYPE_DYNAMIC;
60         uint8_t iqWidth =  16;
61
62                 
63         prepare_symbol_ex(direction,
64                                 section_id,
65                                 test_buffer,
66                                 (uint8_t *)iq_offset,
67                                 compMeth,
68                                 iqWidth,
69                                 iq_buf_byte_order,
70                                 frame_id,
71                                 subframe_id,
72                                 slot_id,
73                                 symbol_no,
74                                 prb_start,
75                                 prb_num,
76                                 CC_ID,
77                                 RU_Port_ID,
78                                 seq_id,
79                                 do_copy,
80                                 staticEn,
81                                 num_sections,
82                                 0);
83                 
84                 /*union xran_cp_radioapp_section_ext11 *ext11 = NULL;
85                 struct xran_sectionext11_info *params = NULL;
86                 int i;
87                 ext11 = (union xran_cp_radioapp_section_ext11 *)(iq_offset);
88                 params = (struct xran_sectionext11_info *)(iq_offset+100);
89                 
90                 params->RAD = 1;
91                 params->disableBFWs = 1;
92                 params->numBundPrb = 1;
93                 params->bfwCompMeth = 2;
94                 
95         for(i = 0; i< 10000; i++)
96                 {
97                         ext11->data_field.data_field1 = (XRAN_CP_SECTIONEXTCMD_11 << 24) | (params->RAD << 7) | (params->disableBFWs << 8);
98                         //ext11->data_field.data_field1 = (XRAN_CP_SECTIONEXTCMD_11 << 24)'
99             //ext11->all_bits.RAD          = params->RAD;
100             //ext11->all_bits.disableBFWs  = params->disableBFWs;
101                         ext11->data_field.data_field2 = (params->bfwCompMeth << 4) | params->numBundPrb;
102             //ext11->all_bits.numBundPrb   = params->numBundPrb;
103             //ext11->all_bits.bfwCompMeth  = params->bfwCompMeth;
104                         
105                 }*/
106                 //printf("ext11->data_field.data_field1 is %d\n", ext11->data_field.data_field1);
107         //ASSERT_EQ(prep_bytes, 3168);
108     }    
109 class U_planePerf : public KernelTests
110 {
111
112 protected:
113     int32_t request;
114     int32_t response;
115
116     struct rte_mbuf *test_buffer;
117     char * iq_offset;
118
119     void SetUp() override
120     {
121         /* Parameters stored in the functional section will be used. GTest will call
122            TEST_P (including SetUp and TearDown) for each case in the section. */
123         init_test("u_plane_performace");
124         test_buffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
125
126         /* buffer size defined as the maximum size of all inputs/outputs in BYTE */
127         if(test_buffer == NULL) {
128             std::cout << __func__ << ":" << __LINE__ << " Failed to allocatte a packet buffer!" << std::endl;
129             return;
130         }
131         iq_offset = rte_pktmbuf_mtod(test_buffer, char * );
132         iq_offset = iq_offset + sizeof(struct rte_ether_hdr) +
133                                     sizeof (struct xran_ecpri_hdr) +
134                                     sizeof (struct radio_app_common_hdr) +
135                                     sizeof(struct data_section_hdr);
136     }
137
138     /* It's called after an execution of the each test case.*/
139     void TearDown() override
140     {
141         rte_pktmbuf_free(test_buffer);
142     }
143
144
145 };
146
147 TEST_P(U_planePerf, Perf)
148 {
149     performance("C", module_name, &fucntional_dl, test_buffer, iq_offset);
150 }
151
152 INSTANTIATE_TEST_CASE_P(UnitTest, U_planePerf,
153                         testing::ValuesIn(get_sequence(U_planePerf::get_number_of_cases("u_plane_performance"))));
154
155