Front Haul Interface Library update to third seed code contribution
[o-du/phy.git] / fhi_lib / test / test_xran / u_plane_performance.cc
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 #include "common.hpp"
21
22 #include "xran_common.h"
23 #include "xran_fh_o_du.h"
24 #include "ethernet.h"
25
26 #include <stdint.h>
27
28 const std::string module_name = "u-plane";
29
30 class U_planePerf : public KernelTests
31 {
32
33 protected:
34     int32_t request;
35     int32_t response;
36
37     struct rte_mbuf *test_buffer;
38     char * iq_offset;
39     struct rte_mempool *test_eth_mbuf_pool;
40
41     void SetUp() override
42     {
43         /* Parameters stored in the functional section will be used. GTest will call
44            TEST_P (including SetUp and TearDown) for each case in the section. */
45         init_test("u_plane_performace");
46         test_eth_mbuf_pool = rte_pktmbuf_pool_create("mempool", NUM_MBUFS,
47                 MBUF_CACHE, 0, MBUF_POOL_ELEMENT, rte_socket_id());
48
49         /* buffer size defined as the maximum size of all inputs/outputs in BYTE */
50         const int buffer_size = 9600;
51         test_buffer = (struct rte_mbuf*)rte_pktmbuf_alloc(test_eth_mbuf_pool);
52
53         iq_offset = rte_pktmbuf_mtod(test_buffer, char * );
54         iq_offset = iq_offset + sizeof(struct ether_hdr) +
55                                     sizeof (struct xran_ecpri_hdr) +
56                                     sizeof (struct radio_app_common_hdr) +
57                                     sizeof(struct data_section_hdr);
58     }
59
60     /* It's called after an execution of the each test case.*/
61     void TearDown() override
62     {
63         rte_pktmbuf_free(test_buffer);
64     }
65
66     void fucntional_dl(F function, int32_t* request, int32_t* response)
67     {
68         enum xran_pkt_dir direction =  XRAN_DIR_DL;
69         uint16_t section_id = 0;
70         enum xran_input_byte_order iq_buf_byte_order = XRAN_CPU_LE_BYTE_ORDER;
71         uint8_t frame_id = 0;
72         uint8_t subframe_id  = 0;
73         uint8_t slot_id = 0;
74         uint8_t symbol_no = 0;
75         int prb_start = 0;
76         int prb_num = 66;
77         uint8_t CC_ID = 0;
78         uint8_t RU_Port_ID = 0;
79         uint8_t seq_id =0;
80         uint32_t do_copy = 0;
81
82         int32_t prep_bytes;
83
84         prep_bytes = prepare_symbol_ex(direction,
85                                     section_id,
86                                     test_buffer,
87                                     (struct rb_map *)iq_offset,
88                                     iq_buf_byte_order,
89                                     frame_id,
90                                     subframe_id,
91                                     slot_id,
92                                     symbol_no,
93                                     prb_start,
94                                     prb_num,
95                                     CC_ID,
96                                     RU_Port_ID,
97                                     seq_id,
98                                     do_copy);
99
100         //ASSERT_EQ(prep_bytes, 3168);
101     }
102 };
103
104 TEST_P(U_planePerf, Test_DL)
105 {
106     performance("C", module_name, fucntional_dl, &request, &response);
107 }
108
109 INSTANTIATE_TEST_CASE_P(UnitTest, U_planePerf,
110                         testing::ValuesIn(get_sequence(U_planePerf::get_number_of_cases("u_plane_performance"))));
111
112