554b00ac23c9f24b34c130a88ee1f038d2ff7b71
[o-du/phy.git] / fhi_lib / test / test_xran / u_plane_performance.cc
1 /******************************************************************************\r
2 *\r
3 *   Copyright (c) 2019 Intel.\r
4 *\r
5 *   Licensed under the Apache License, Version 2.0 (the "License");\r
6 *   you may not use this file except in compliance with the License.\r
7 *   You may obtain a copy of the License at\r
8 *\r
9 *       http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 *   Unless required by applicable law or agreed to in writing, software\r
12 *   distributed under the License is distributed on an "AS IS" BASIS,\r
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 *   See the License for the specific language governing permissions and\r
15 *   limitations under the License.\r
16 *\r
17 *******************************************************************************/\r
18 \r
19 \r
20 #include "common.hpp"\r
21 \r
22 #include "xran_common.h"\r
23 #include "xran_fh_o_du.h"\r
24 #include "ethernet.h"\r
25 \r
26 #include <stdint.h>\r
27 \r
28 const std::string module_name = "u-plane";\r
29 \r
30 class U_planePerf : public KernelTests\r
31 {\r
32 \r
33 protected:\r
34     int32_t request;\r
35     int32_t response;\r
36 \r
37     struct rte_mbuf *test_buffer;\r
38     char * iq_offset;\r
39     struct rte_mempool *test_eth_mbuf_pool;\r
40 \r
41     void SetUp() override\r
42     {\r
43         /* Parameters stored in the functional section will be used. GTest will call\r
44            TEST_P (including SetUp and TearDown) for each case in the section. */\r
45         init_test("u_plane_performace");\r
46         test_eth_mbuf_pool = rte_pktmbuf_pool_create("mempool", NUM_MBUFS,\r
47                 MBUF_CACHE, 0, MBUF_POOL_ELEMENT, rte_socket_id());\r
48 \r
49         /* buffer size defined as the maximum size of all inputs/outputs in BYTE */\r
50         const int buffer_size = 9600;\r
51         test_buffer = (struct rte_mbuf*)rte_pktmbuf_alloc(test_eth_mbuf_pool);\r
52 \r
53         iq_offset = rte_pktmbuf_mtod(test_buffer, char * );\r
54         iq_offset = iq_offset + sizeof(struct ether_hdr) +\r
55                                     sizeof (struct xran_ecpri_hdr) +\r
56                                     sizeof (struct radio_app_common_hdr) +\r
57                                     sizeof(struct data_section_hdr);\r
58     }\r
59 \r
60     /* It's called after an execution of the each test case.*/\r
61     void TearDown() override\r
62     {\r
63         rte_pktmbuf_free(test_buffer);\r
64     }\r
65 \r
66     void fucntional_dl(F function, int32_t* request, int32_t* response)\r
67     {\r
68         enum xran_pkt_dir direction =  XRAN_DIR_DL;\r
69         uint16_t section_id = 0;\r
70         enum xran_input_byte_order iq_buf_byte_order = XRAN_CPU_LE_BYTE_ORDER;\r
71         uint8_t frame_id = 0;\r
72         uint8_t subframe_id  = 0;\r
73         uint8_t slot_id = 0;\r
74         uint8_t symbol_no = 0;\r
75         int prb_start = 0;\r
76         int prb_num = 66;\r
77         uint8_t CC_ID = 0;\r
78         uint8_t RU_Port_ID = 0;\r
79         uint8_t seq_id =0;\r
80         uint32_t do_copy = 0;\r
81 \r
82         int32_t prep_bytes;\r
83 \r
84         prep_bytes = prepare_symbol_ex(direction,\r
85                                     section_id,\r
86                                     test_buffer,\r
87                                     (struct rb_map *)iq_offset,\r
88                                     iq_buf_byte_order,\r
89                                     frame_id,\r
90                                     subframe_id,\r
91                                     slot_id,\r
92                                     symbol_no,\r
93                                     prb_start,\r
94                                     prb_num,\r
95                                     CC_ID,\r
96                                     RU_Port_ID,\r
97                                     seq_id,\r
98                                     do_copy);\r
99 \r
100         //ASSERT_EQ(prep_bytes, 3168);\r
101     }\r
102 };\r
103 \r
104 TEST_P(U_planePerf, Test_DL)\r
105 {\r
106     performance("C", module_name, fucntional_dl, &request, &response);\r
107 }\r
108 \r
109 INSTANTIATE_TEST_CASE_P(UnitTest, U_planePerf,\r
110                         testing::ValuesIn(get_sequence(U_planePerf::get_number_of_cases("u_plane_performance"))));\r
111 \r
112 \r