provide follow features implementation:
[o-du/phy.git] / fhi_lib / test / test_xran / chain_tests.cc
diff --git a/fhi_lib/test/test_xran/chain_tests.cc b/fhi_lib/test/test_xran/chain_tests.cc
new file mode 100644 (file)
index 0000000..354d191
--- /dev/null
@@ -0,0 +1,308 @@
+/******************************************************************************\r
+*\r
+*   Copyright (c) 2019 Intel.\r
+*\r
+*   Licensed under the Apache License, Version 2.0 (the "License");\r
+*   you may not use this file except in compliance with the License.\r
+*   You may obtain a copy of the License at\r
+*\r
+*       http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+*   Unless required by applicable law or agreed to in writing, software\r
+*   distributed under the License is distributed on an "AS IS" BASIS,\r
+*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+*   See the License for the specific language governing permissions and\r
+*   limitations under the License.\r
+*\r
+*******************************************************************************/\r
+\r
+\r
+#include "common.hpp"\r
+#include "xran_lib_wrap.hpp"\r
+#include "xran_common.h"\r
+#include "xran_fh_o_du.h"\r
+#include "ethdi.h"\r
+#include "ethernet.h"\r
+#include "xran_transport.h"\r
+#include "xran_cp_api.h"\r
+\r
+#include <stdint.h>\r
+\r
+\r
+\r
+const std::string module_name = "C-Plane";\r
+\r
+const uint8_t m_bitmask[] = { 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };\r
+\r
+\r
+extern "C"\r
+{\r
+\r
+/* external functions in xRAN library */\r
+void tx_cp_dl_cb(struct rte_timer *tim, void *arg);\r
+void tx_cp_ul_cb(struct rte_timer *tim, void *arg);\r
+int xran_process_tx_sym(void *arg);\r
+int process_mbuf(struct rte_mbuf *pkt);\r
+\r
+\r
+/* wrapper functions for performace tests */\r
+void xran_ut_tx_cp_dl()\r
+{\r
+    xranlib->update_tti();\r
+    tx_cp_dl_cb(nullptr, xranlib->get_timer_ctx());\r
+}\r
+\r
+void xran_ut_tx_cp_ul()\r
+{\r
+    xranlib->update_tti();\r
+    tx_cp_ul_cb(nullptr, xranlib->get_timer_ctx());\r
+}\r
+\r
+void xran_ut_tx_up_dl()\r
+{\r
+    xranlib->update_symbol_index();\r
+    xran_process_tx_sym(xranlib->get_timer_ctx());\r
+}\r
+\r
+void xran_ut_tx_cpup_dl()\r
+{\r
+    xranlib->update_symbol_index();\r
+\r
+    if(xranlib->get_symbol_index() == 3)\r
+        tx_cp_dl_cb(nullptr, xranlib->get_timer_ctx());\r
+\r
+    xran_process_tx_sym(xranlib->get_timer_ctx());\r
+}\r
+\r
+#if 0   /* TBD */\r
+void xran_ut_rx_up_ul()\r
+{\r
+    process_mbf(mbuf);\r
+}\r
+#endif\r
+\r
+\r
+/* call back functions */\r
+int send_mbuf_up(struct rte_mbuf *mbuf, uint16_t type)\r
+{\r
+    rte_pktmbuf_free(mbuf);\r
+    return (1);\r
+}\r
+\r
+int send_mbuf_cp_perf(struct rte_mbuf *mbuf, uint16_t type)\r
+{\r
+    rte_pktmbuf_free(mbuf);\r
+    return (1);\r
+}\r
+\r
+#if 0   /* TBD */\r
+int send_mbuf_cp(struct rte_mbuf *mbuf, uint16_t type)\r
+{\r
+#if 0\r
+    xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo);\r
+\r
+    /* Verify the result */\r
+    verify_sections();\r
+#else\r
+    printf("cp\n");\r
+#endif\r
+    return (1);\r
+}\r
+#endif\r
+\r
+void utcp_fh_rx_callback(void *pCallbackTag, xran_status_t status)\r
+{\r
+    return;\r
+}\r
+\r
+void utcp_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status)\r
+{\r
+    rte_pause();\r
+}\r
+\r
+} /* extern "C" */\r
+\r
+\r
+class TestChain: public KernelTests\r
+{\r
+protected:\r
+    struct xran_fh_config   m_xranConf;\r
+    struct xran_fh_init     m_xranInit;\r
+\r
+    bool m_bSub6;\r
+\r
+\r
+    void SetUp() override\r
+    {\r
+        int temp;\r
+        std::string tmpstr;\r
+\r
+\r
+        init_test("TestChain");\r
+\r
+        xranlib->get_cfg_fh(&m_xranConf);\r
+\r
+        tmpstr = get_input_parameter<std::string>("category");\r
+        if(tmpstr == "A")\r
+            m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_A;\r
+        else if(tmpstr == "B")\r
+            m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_B;\r
+        else {\r
+            std::cout << "*** Invalid RU Category [" << tmpstr << "] !!!" << std::endl;\r
+            std::cout << "Set it to Category A... " << std::endl;\r
+            m_xranConf.ru_conf.xranCat = XRAN_CATEGORY_A;\r
+            }\r
+\r
+        m_xranConf.frame_conf.nNumerology = get_input_parameter<int>("mu");\r
+        if(m_xranConf.frame_conf.nNumerology > 3) {\r
+            std::cout << "*** Invalid Numerology [" << m_xranConf.frame_conf.nNumerology << "] !!!" << std::endl;\r
+            m_xranConf.frame_conf.nNumerology   = 0;\r
+            std::cout << "Set it to " << m_xranConf.frame_conf.nNumerology << "..." << std::endl;\r
+            }\r
+\r
+        tmpstr = get_input_parameter<std::string>("duplex");\r
+        if(tmpstr == "FDD")\r
+            m_xranConf.frame_conf.nFrameDuplexType  = 0;\r
+        else if(tmpstr == "TDD") {\r
+            m_xranConf.frame_conf.nFrameDuplexType  = 1;\r
+\r
+            tmpstr = get_input_parameter<std::string>("slot_config");\r
+            temp = xranlib->get_slot_config(tmpstr, &m_xranConf.frame_conf);\r
+            }\r
+        else {\r
+            std::cout << "*** Invalid Duplex type [" << tmpstr << "] !!!" << std::endl;\r
+            std::cout << "Set it to FDD... " << std::endl;\r
+            m_xranConf.frame_conf.nFrameDuplexType  = 0;\r
+            }\r
+\r
+        m_xranConf.nCC = get_input_parameter<int>("num_cc");\r
+        if(m_xranConf.nCC > XRAN_MAX_SECTOR_NR) {\r
+            std::cout << "*** Exceeds maximum number of carriers supported [" << m_xranConf.nCC << "] !!!" << std::endl;\r
+            m_xranConf.nCC = XRAN_MAX_SECTOR_NR;\r
+            std::cout << "Set it to " << m_xranConf.nCC << "..." << std::endl;\r
+            }\r
+        m_xranConf.neAxc = get_input_parameter<int>("num_eaxc");\r
+        if(m_xranConf.neAxc > XRAN_MAX_ANTENNA_NR) {\r
+            std::cout << "*** Exceeds maximum number of antenna supported [" << m_xranConf.neAxc << "] !!!" << std::endl;\r
+            m_xranConf.neAxc = XRAN_MAX_ANTENNA_NR;\r
+            std::cout << "Set it to " << m_xranConf.neAxc << "..." << std::endl;\r
+            }\r
+\r
+        m_bSub6     = get_input_parameter<bool>("sub6");\r
+        temp = get_input_parameter<int>("chbw_dl");\r
+        m_xranConf.nDLRBs = xranlib->get_num_rbs(m_xranConf.frame_conf.nNumerology, temp, m_bSub6);\r
+        temp = get_input_parameter<int>("chbw_ul");\r
+        m_xranConf.nULRBs = xranlib->get_num_rbs(m_xranConf.frame_conf.nNumerology, temp, m_bSub6);\r
+\r
+        m_xranConf.nAntElmTRx = get_input_parameter<int>("antelm_trx");\r
+        m_xranConf.nDLFftSize = get_input_parameter<int>("fftsize_dl");\r
+        m_xranConf.nULFftSize = get_input_parameter<int>("fftsize_ul");\r
+\r
+\r
+        m_xranConf.ru_conf.iqWidth  = get_input_parameter<int>("iq_width");\r
+        m_xranConf.ru_conf.compMeth = get_input_parameter<int>("comp_meth");\r
+\r
+#if 0\r
+        temp = get_input_parameter<int>("fft_size");\r
+        m_xranConf.ru_conf.fftSize  = 0;\r
+        while (temp >>= 1)\r
+            ++m_xranConf.ru_conf.fftSize;\r
+#endif\r
+\r
+    }\r
+\r
+    void TearDown() override\r
+    {\r
+    }\r
+};\r
+\r
+\r
+\r
+\r
+/***************************************************************************\r
+ * Performance Test cases\r
+ ***************************************************************************/\r
+/* C-Plane DL chain (tx_cp_dl_cb) only */\r
+TEST_P(TestChain, CPlaneDLPerf)\r
+{\r
+    xranlib->Init(&m_xranConf);\r
+    xranlib->Open(send_mbuf_cp_perf, send_mbuf_up,\r
+            (void *)utcp_fh_rx_callback, (void *)utcp_fh_rx_prach_callback);\r
+\r
+    performance("C", module_name, xran_ut_tx_cp_dl);\r
+\r
+    xranlib->Close();\r
+    xranlib->Cleanup();\r
+}\r
+\r
+/* C-Plane UL chain (tx_cp_ul_cb) only */\r
+TEST_P(TestChain, CPlaneULPerf)\r
+{\r
+    xranlib->Init(&m_xranConf);\r
+    xranlib->Open(send_mbuf_cp_perf, send_mbuf_up,\r
+            (void *)utcp_fh_rx_callback, (void *)utcp_fh_rx_prach_callback);\r
+\r
+    performance("C", module_name, xran_ut_tx_cp_ul);\r
+\r
+    xranlib->Close();\r
+    xranlib->Cleanup();\r
+}\r
+\r
+/* U-Plane UL chain (process_tx_sym with disable CP) */\r
+TEST_P(TestChain, UPlaneDLPerf)\r
+{\r
+    bool flag_cpen;\r
+\r
+    xranlib->Init(&m_xranConf);\r
+\r
+    /* save current CP enable flag */\r
+    flag_cpen = xranlib->is_cpenable()?true:false;\r
+\r
+    /* need to disable CP to make U-Plane work without CP */\r
+    xranlib->apply_cpenable(false);\r
+    xranlib->Open(send_mbuf_cp_perf, send_mbuf_up,\r
+            (void *)utcp_fh_rx_callback, (void *)utcp_fh_rx_prach_callback);\r
+\r
+    performance("C", module_name, xran_ut_tx_up_dl);\r
+\r
+    xranlib->Close();\r
+    xranlib->Cleanup();\r
+\r
+    /* restore previous CP enable flag */\r
+    xranlib->apply_cpenable(flag_cpen);\r
+}\r
+\r
+/* C-Plane and U-Plane DL chain, U-Plane will be generated by C-Plane config */\r
+TEST_P(TestChain, APlaneDLPerf)\r
+{\r
+    bool flag_cpen;\r
+\r
+    xranlib->Init(&m_xranConf);\r
+\r
+    /* save current CP enable flag */\r
+    flag_cpen = xranlib->is_cpenable()?true:false;\r
+\r
+    /* Enable CP by force to make UP work by CP's section information */\r
+    xranlib->apply_cpenable(true);\r
+    xranlib->Open(send_mbuf_cp_perf, send_mbuf_up,\r
+            (void *)utcp_fh_rx_callback, (void *)utcp_fh_rx_prach_callback);\r
+\r
+    performance("C", module_name, xran_ut_tx_cpup_dl);\r
+\r
+    xranlib->Close();\r
+    xranlib->Cleanup();\r
+\r
+    /* restore previous CP enable flag */\r
+    xranlib->apply_cpenable(flag_cpen);\r
+}\r
+\r
+#if 0       /* TBD */\r
+TEST_P(TestChain, UPlaneULPerf)\r
+{\r
+}\r
+#endif\r
+\r
+\r
+INSTANTIATE_TEST_CASE_P(UnitTest, TestChain,\r
+        testing::ValuesIn(get_sequence(TestChain::get_number_of_cases("TestChain"))));\r
+\r