1 /******************************************************************************
3 * Copyright (c) 2020 Intel.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 *******************************************************************************/
21 #include "xran_lib_wrap.hpp"
22 #include "xran_common.h"
23 #include "xran_fh_o_du.h"
26 #include "xran_transport.h"
27 #include "xran_cp_api.h"
33 const std::string module_name = "C-Plane";
35 const uint8_t m_bitmask[] = { 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
41 /* external functions in xRAN library */
42 void tx_cp_dl_cb(struct rte_timer *tim, void *arg);
43 void tx_cp_ul_cb(struct rte_timer *tim, void *arg);
44 int xran_process_tx_sym(void *arg);
45 int process_mbuf(struct rte_mbuf *pkt, void *arg, struct xran_eaxc_info *p_cid);
48 /* wrapper functions for performace tests */
49 void xran_ut_tx_cp_dl()
51 xranlib->update_tti();
52 tx_cp_dl_cb(nullptr, xranlib->get_timer_ctx());
55 void xran_ut_tx_cp_ul()
57 xranlib->update_tti();
58 tx_cp_ul_cb(nullptr, xranlib->get_timer_ctx());
61 void xran_ut_tx_up_dl()
63 xranlib->update_symbol_index();
64 xran_process_tx_sym(xranlib->get_timer_ctx());
67 void xran_ut_tx_cpup_dl()
69 xranlib->update_symbol_index();
71 if(xranlib->get_symbol_index() == 3)
72 tx_cp_dl_cb(nullptr, xranlib->get_timer_ctx());
74 xran_process_tx_sym(xranlib->get_timer_ctx());
78 void xran_ut_rx_up_ul()
85 /* call back functions */
86 int send_mbuf_up(struct rte_mbuf *mbuf, uint16_t type, uint16_t vf_id)
88 rte_pktmbuf_free(mbuf);
93 int send_mbuf_cp_perf(struct rte_mbuf *mbuf, uint16_t type, uint16_t vf_id)
95 rte_pktmbuf_free(mbuf);
96 /* TODO: need to free chained mbufs */
101 int send_mbuf_cp(struct rte_mbuf *mbuf, uint16_t type)
104 xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo);
106 /* Verify the result */
115 void utcp_fh_rx_callback(void *pCallbackTag, xran_status_t status)
120 void utcp_fh_bfw_callback(void *pCallbackTag, xran_status_t status)
125 void utcp_fh_srs_callback(void *pCallbackTag, xran_status_t status)
130 void utcp_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status)
138 class TestChain: public KernelTests
141 struct xran_fh_config m_xranConf;
142 struct xran_fh_init m_xranInit;
147 void SetUp() override
153 init_test("TestChain");
155 xranlib->get_cfg_fh(&m_xranConf);
157 tmpstr = get_input_parameter<std::string>("category");
159 m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_A;
160 else if(tmpstr == "B")
161 m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_B;
163 std::cout << "*** Invalid RU Category [" << tmpstr << "] !!!" << std::endl;
164 std::cout << "Set it to Category A... " << std::endl;
165 m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_A;
168 m_xranConf.frame_conf.nNumerology = get_input_parameter<int>("mu");
169 if(m_xranConf.frame_conf.nNumerology > 3) {
170 std::cout << "*** Invalid Numerology [" << m_xranConf.frame_conf.nNumerology << "] !!!" << std::endl;
171 m_xranConf.frame_conf.nNumerology = 0;
172 std::cout << "Set it to " << m_xranConf.frame_conf.nNumerology << "..." << std::endl;
175 tmpstr = get_input_parameter<std::string>("duplex");
177 m_xranConf.frame_conf.nFrameDuplexType = 0;
178 else if(tmpstr == "TDD") {
179 m_xranConf.frame_conf.nFrameDuplexType = 1;
181 tmpstr = get_input_parameter<std::string>("slot_config");
182 temp = xranlib->get_slot_config(tmpstr, &m_xranConf.frame_conf);
185 std::cout << "*** Invalid Duplex type [" << tmpstr << "] !!!" << std::endl;
186 std::cout << "Set it to FDD... " << std::endl;
187 m_xranConf.frame_conf.nFrameDuplexType = 0;
190 m_xranConf.nCC = get_input_parameter<int>("num_cc");
191 if(m_xranConf.nCC > XRAN_MAX_SECTOR_NR) {
192 std::cout << "*** Exceeds maximum number of carriers supported [" << m_xranConf.nCC << "] !!!" << std::endl;
193 m_xranConf.nCC = XRAN_MAX_SECTOR_NR;
194 std::cout << "Set it to " << m_xranConf.nCC << "..." << std::endl;
196 m_xranConf.neAxc = get_input_parameter<int>("num_eaxc");
197 if(m_xranConf.neAxc > XRAN_MAX_ANTENNA_NR) {
198 std::cout << "*** Exceeds maximum number of antenna supported [" << m_xranConf.neAxc << "] !!!" << std::endl;
199 m_xranConf.neAxc = XRAN_MAX_ANTENNA_NR;
200 std::cout << "Set it to " << m_xranConf.neAxc << "..." << std::endl;
203 m_bSub6 = get_input_parameter<bool>("sub6");
204 temp = get_input_parameter<int>("chbw_dl");
205 m_xranConf.nDLRBs = xranlib->get_num_rbs(m_xranConf.frame_conf.nNumerology, temp, m_bSub6);
206 temp = get_input_parameter<int>("chbw_ul");
207 m_xranConf.nULRBs = xranlib->get_num_rbs(m_xranConf.frame_conf.nNumerology, temp, m_bSub6);
209 m_xranConf.nAntElmTRx = get_input_parameter<int>("antelm_trx");
210 m_xranConf.nDLFftSize = get_input_parameter<int>("fftsize_dl");
211 m_xranConf.nULFftSize = get_input_parameter<int>("fftsize_ul");
214 m_xranConf.ru_conf.iqWidth = get_input_parameter<int>("iq_width");
215 m_xranConf.ru_conf.compMeth = get_input_parameter<int>("comp_meth");
218 temp = get_input_parameter<int>("fft_size");
219 m_xranConf.ru_conf.fftSize = 0;
221 ++m_xranConf.ru_conf.fftSize;
226 void TearDown() override
234 /***************************************************************************
235 * Performance Test cases
236 ***************************************************************************/
237 /* C-Plane DL chain (tx_cp_dl_cb) only */
238 TEST_P(TestChain, CPlaneDLPerf)
240 xranlib->Init(0, &m_xranConf);
241 xranlib->Open(0, send_mbuf_cp_perf, send_mbuf_up,
242 (void *)utcp_fh_rx_callback, (void *)utcp_fh_bfw_callback, (void *)utcp_fh_rx_prach_callback, (void *)utcp_fh_srs_callback);
244 performance("C", module_name, xran_ut_tx_cp_dl);
250 /* C-Plane UL chain (tx_cp_ul_cb) only */
251 TEST_P(TestChain, CPlaneULPerf)
253 xranlib->Init(0, &m_xranConf);
254 xranlib->Open(0, send_mbuf_cp_perf, send_mbuf_up,
255 (void *)utcp_fh_rx_callback, (void *)utcp_fh_bfw_callback, (void *)utcp_fh_rx_prach_callback, (void *)utcp_fh_srs_callback);
257 performance("C", module_name, xran_ut_tx_cp_ul);
263 /* U-Plane UL chain (process_tx_sym with disable CP) */
264 TEST_P(TestChain, UPlaneDLPerf)
268 xranlib->Init(0, &m_xranConf);
270 /* save current CP enable flag */
271 flag_cpen = xranlib->is_cpenable()?true:false;
273 /* need to disable CP to make U-Plane work without CP */
274 xranlib->apply_cpenable(false);
275 xranlib->Open(0, send_mbuf_cp_perf, send_mbuf_up,
276 (void *)utcp_fh_rx_callback, (void *)utcp_fh_bfw_callback, (void *)utcp_fh_rx_prach_callback, (void *)utcp_fh_srs_callback);
278 performance("C", module_name, xran_ut_tx_up_dl);
283 /* restore previous CP enable flag */
284 xranlib->apply_cpenable(flag_cpen);
287 /* C-Plane and U-Plane DL chain, U-Plane will be generated by C-Plane config */
288 TEST_P(TestChain, APlaneDLPerf)
292 xranlib->Init(0, &m_xranConf);
294 /* save current CP enable flag */
295 flag_cpen = xranlib->is_cpenable()?true:false;
297 /* Enable CP by force to make UP work by CP's section information */
298 xranlib->apply_cpenable(true);
299 xranlib->Open(0, send_mbuf_cp_perf, send_mbuf_up,
300 (void *)utcp_fh_rx_callback, (void *)utcp_fh_bfw_callback, (void *)utcp_fh_rx_prach_callback, (void *)utcp_fh_srs_callback);
302 performance("C", module_name, xran_ut_tx_cpup_dl);
307 /* restore previous CP enable flag */
308 xranlib->apply_cpenable(flag_cpen);
312 TEST_P(TestChain, UPlaneULPerf)
318 INSTANTIATE_TEST_CASE_P(UnitTest, TestChain,
319 testing::ValuesIn(get_sequence(TestChain::get_number_of_cases("TestChain"))));