Front Haul Interface Library update to third seed code contribution
[o-du/phy.git] / fhi_lib / test / test_xran / c_plane_tests.cc
index 891880d..8319306 100644 (file)
-/******************************************************************************\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
-const std::string module_name = "C-Plane";\r
-\r
-const uint8_t m_bitmask[] = { 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };\r
-\r
-extern "C"\r
-{\r
-\r
-/* wrapper function for performace tests to reset mbuf */\r
-int xran_ut_prepare_cp(struct rte_mbuf *mbuf, struct xran_cp_gen_params *params,\r
-                        uint8_t cc_id, uint8_t ant_id, uint8_t seq_id)\r
-{\r
-    rte_pktmbuf_reset(mbuf);\r
-    return(xran_prepare_ctrl_pkt(mbuf, params, cc_id, ant_id, seq_id));\r
-}\r
-\r
-\r
-void cput_fh_rx_callback(void *pCallbackTag, xran_status_t status)\r
-{\r
-    return;\r
-}\r
-\r
-void cput_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status)\r
-{\r
-    rte_pause();\r
-}\r
-\r
-} /* extern "C" */\r
-\r
-\r
-\r
-class C_plane: public KernelTests\r
-{\r
-private:\r
-    struct xran_section_gen_info *m_pSectGenInfo = NULL;\r
-    struct xran_section_gen_info *m_pSectResult = NULL;\r
-\r
-\r
-protected:\r
-    int m_maxSections = 8;  /*  not used */\r
-    int m_numSections;\r
-\r
-    struct rte_mbuf *m_pTestBuffer;\r
-\r
-    struct xran_cp_gen_params m_params;\r
-    struct xran_recv_packet_info m_pktInfo;\r
-    struct xran_cp_gen_params m_result;\r
-\r
-    uint8_t     m_dir;\r
-    std::string m_dirStr;\r
-    uint8_t     m_sectionType;\r
-\r
-    uint8_t     m_ccId, m_antId;\r
-    uint8_t     m_seqId;\r
-    uint8_t     m_frameId, m_subframeId, m_slotId;\r
-    uint8_t     m_symStart, m_symNum;\r
-    uint16_t    *m_prbStart = NULL, *m_prbNum = NULL;\r
-\r
-    uint8_t     m_iqWidth, m_compMethod;\r
-    uint16_t    m_beamId;\r
-    uint16_t    m_reMask = 0xfff;\r
-    uint16_t    m_sectionId;\r
-    uint8_t     m_filterIndex;\r
-    uint16_t    m_timeOffset;\r
-    uint8_t     m_fftSize;\r
-    uint8_t     m_scs;\r
-    uint16_t    m_cpLength;\r
-    int         m_freqOffset;\r
-\r
-    uint16_t  m_ext1_dst_len = 0;\r
-    int8_t   *m_p_ext1_dst   = NULL;\r
-    int16_t  *m_p_bfw_iq_src = NULL;\r
-\r
-    struct xran_sectionext1_info m_ext1;\r
-    struct xran_sectionext2_info m_ext2;\r
-    struct xran_sectionext4_info m_ext4;\r
-    struct xran_sectionext5_info m_ext5;\r
-\r
-    int16_t m_bfwIQ[XRAN_MAX_BFW_N*2];\r
-\r
-\r
-    void SetUp() override\r
-    {\r
-        int i, j;\r
-\r
-        init_test("C_Plane");\r
-\r
-        m_numSections   = get_input_parameter<int>("num_sections");\r
-        ASSERT_FALSE(m_numSections == 0);\r
-\r
-        m_dirStr        = get_input_parameter<std::string>("direction");\r
-\r
-        if(!m_dirStr.compare("DL")) m_dir = XRAN_DIR_DL;\r
-        else if(!m_dirStr.compare("UL")) m_dir = XRAN_DIR_UL;\r
-        else FAIL() << "Invalid direction!";\r
-\r
-        m_sectionType   = get_input_parameter<uint8_t>("section_type");\r
-        m_ccId          = get_input_parameter<uint8_t>("cc_id");\r
-        m_antId         = get_input_parameter<uint8_t>("ant_id");\r
-        m_seqId         = get_input_parameter<uint16_t>("seq_id");\r
-\r
-        m_frameId       = get_input_parameter<uint8_t>("frame_id");\r
-        m_subframeId    = get_input_parameter<uint8_t>("subframe_id");\r
-        m_slotId        = get_input_parameter<uint8_t>("slot_id");\r
-        m_symStart      = get_input_parameter<uint8_t>("symbol_start");\r
-        m_compMethod    = get_input_parameter<uint8_t>("comp_method");\r
-        m_iqWidth       = get_input_parameter<uint8_t>("iq_width");\r
-\r
-        m_sectionId     = get_input_parameter<uint8_t>("section_id");\r
-        m_symNum        = get_input_parameter<uint8_t>("symbol_num");\r
-        m_beamId        = get_input_parameter<uint16_t>("beam_id");\r
-\r
-        /* reading configurations of start prb and the number of prbs  */\r
-        std::vector<int> prbstart = get_input_parameter<std::vector<int>>("prb_start");\r
-        std::vector<int> prbnum = get_input_parameter<std::vector<int>>("prb_num");\r
-        /* number of sections and  the pair of start/number of prb shall be matched */\r
-        ASSERT_TRUE((m_numSections == prbstart.size())\r
-                    && (m_numSections == prbnum.size())\r
-                    && (prbstart.size() == prbnum.size()));\r
-\r
-        m_prbStart  = new uint16_t [m_numSections];\r
-        m_prbNum    = new uint16_t [m_numSections];\r
-        for(i=0; i < m_numSections; i++) {\r
-            m_prbStart[i] = prbstart[i];\r
-            m_prbNum[i] = prbnum[i];\r
-            }\r
-\r
-        switch(m_sectionType) {\r
-            case XRAN_CP_SECTIONTYPE_1:\r
-                m_filterIndex = XRAN_FILTERINDEX_STANDARD;\r
-                break;\r
-\r
-            case XRAN_CP_SECTIONTYPE_3:\r
-                m_filterIndex   = get_input_parameter<uint8_t>("filter_index");\r
-                m_timeOffset    = get_input_parameter<uint16_t>("time_offset");\r
-                m_fftSize       = get_input_parameter<uint8_t>("fft_size");\r
-                m_scs           = get_input_parameter<uint8_t>("scs");\r
-                m_cpLength      = get_input_parameter<uint16_t>("cp_length");\r
-                m_freqOffset    = get_input_parameter<int>("freq_offset");\r
-                break;\r
-\r
-            default:\r
-                FAIL() << "Invalid Section Type - " << m_sectionType << "\n";\r
-            }\r
-\r
-        /* allocate and prepare required data storage */\r
-        m_pSectGenInfo = new struct xran_section_gen_info [m_numSections];\r
-        ASSERT_NE(m_pSectGenInfo, nullptr);\r
-        m_params.sections = m_pSectGenInfo;\r
-\r
-        m_pSectResult = new struct xran_section_gen_info [m_numSections];\r
-        ASSERT_NE(m_pSectResult, nullptr);\r
-        m_result.sections = m_pSectResult;\r
-\r
-        m_ext1_dst_len   = 9600;\r
-        m_p_ext1_dst   = new int8_t [m_ext1_dst_len];\r
-        m_p_bfw_iq_src = new int16_t [9600/2];\r
-\r
-        /* allocating an mbuf for packet generatrion */\r
-        m_pTestBuffer = xran_ethdi_mbuf_alloc();\r
-\r
-        ASSERT_FALSE(m_pTestBuffer == NULL);\r
-    }\r
-\r
-    void TearDown() override\r
-    {\r
-        int i, j;\r
-\r
-        if(m_pTestBuffer != NULL)\r
-            rte_pktmbuf_free(m_pTestBuffer);\r
-\r
-        if(m_prbStart)\r
-            delete[] m_prbStart;\r
-        if(m_prbNum)\r
-            delete[] m_prbNum;\r
-\r
-        if(m_p_bfw_iq_src)\r
-            delete[] m_p_bfw_iq_src;\r
-\r
-        if(m_p_ext1_dst)\r
-            delete[] m_p_ext1_dst;\r
-\r
-        if(m_pSectGenInfo)\r
-            delete[] m_pSectGenInfo;\r
-\r
-        if(m_pSectResult) {\r
-            delete[] m_pSectResult;\r
-            }\r
-\r
-    }\r
-\r
-    int prepare_sections(bool extflag);\r
-    int prepare_extensions(int sect_num);\r
-    void verify_sections(void);\r
-\r
-};\r
-\r
-\r
-\r
-int C_plane::prepare_extensions(int sect_num)\r
-{\r
-    int i, numext;\r
-    int N;\r
-\r
-\r
-    N = 8;\r
-\r
-    // extension 1\r
-    m_ext1.bfwNumber  = 4*N; // 4 ant, 8 UEs\r
-    m_ext1.bfwiqWidth = 16;\r
-    m_ext1.bfwCompMeth    = XRAN_BFWCOMPMETHOD_NONE;\r
-                            /* XRAN_BFWCOMPMETHOD_BLKFLOAT\r
-                             * XRAN_BFWCOMPMETHOD_BLKSCALE\r
-                             * XRAN_BFWCOMPMETHOD_ULAW\r
-                             * XRAN_BFWCOMPMETHOD_BEAMSPACE\r
-                             */\r
-    m_ext1.p_bfwIQ = m_bfwIQ;\r
-\r
-    switch (m_ext1.bfwCompMeth) {\r
-        case XRAN_BFWCOMPMETHOD_BLKFLOAT:\r
-            m_ext1.bfwCompParam.exponent = 0xa;\r
-            break;\r
-        case XRAN_BFWCOMPMETHOD_BLKSCALE:\r
-            m_ext1.bfwCompParam.blockScaler = 0xa5;\r
-            break;\r
-        case XRAN_BFWCOMPMETHOD_ULAW:\r
-            m_ext1.bfwCompParam.compBitWidthShift = 0x55;\r
-        case XRAN_BFWCOMPMETHOD_BEAMSPACE:\r
-            for(i=0; i<N; i++)\r
-                m_ext1.bfwCompParam.activeBeamspaceCoeffMask[i] = 0xa0 + i;\r
-            break;\r
-        }\r
-\r
-    for(i=0; i<N*4; i++) {\r
-        m_ext1.p_bfwIQ[i*2]     = 0xcafe;\r
-        m_ext1.p_bfwIQ[i*2+1]   = 0xbeef;\r
-        }\r
-\r
-    // extension 2\r
-    m_ext2.bfAzPtWidth        = 7;\r
-    m_ext2.bfAzPt             = 0x55 & m_bitmask[m_ext2.bfAzPtWidth];\r
-    m_ext2.bfZePtWidth        = 7;\r
-    m_ext2.bfZePt             = 0xaa & m_bitmask[m_ext2.bfAzPtWidth];\r
-    m_ext2.bfAz3ddWidth       = 7;\r
-    m_ext2.bfAz3dd            = 0x5a & m_bitmask[m_ext2.bfAzPtWidth];\r
-    m_ext2.bfZe3ddWidth       = 7;\r
-    m_ext2.bfZe3dd            = 0xa5 & m_bitmask[m_ext2.bfAzPtWidth];\r
-    m_ext2.bfAzSI             = 0x2 & m_bitmask[3];\r
-    m_ext2.bfZeSI             = 0x5 & m_bitmask[3];\r
-\r
-    // extension 4\r
-    m_ext4.csf                = 1;\r
-    m_ext4.modCompScaler      = 0x5aa5;\r
-\r
-    // extension 5\r
-    m_ext5.num_sets = 2;\r
-    for(i=0; i<m_ext5.num_sets; i++) {\r
-        m_ext5.mc[i].csf              = i%2;\r
-        m_ext5.mc[i].mcScaleReMask    = 0xa5a + i;\r
-        m_ext5.mc[i].mcScaleOffset    = 0x5a5a + i;\r
-        }\r
-\r
-    numext = 0;\r
-\r
-    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_1;\r
-    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext1);\r
-    m_params.sections[sect_num].exData[numext].data = &m_ext1;\r
-    numext++;\r
-\r
-    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_2;\r
-    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext2);\r
-    m_params.sections[sect_num].exData[numext].data = &m_ext2;\r
-    numext++;\r
-\r
-    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_4;\r
-    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext4);\r
-    m_params.sections[sect_num].exData[numext].data = &m_ext4;\r
-    numext++;\r
-\r
-    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_5;\r
-    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext5);\r
-    m_params.sections[sect_num].exData[numext].data = &m_ext5;\r
-    numext++;\r
-\r
-    m_params.sections[sect_num].exDataSize = numext;\r
-\r
-    return (0);\r
-}\r
-\r
-int C_plane::prepare_sections(bool extflag)\r
-{\r
-  int numsec;\r
-\r
-\r
-    /* Preparing input data for packet generation */\r
-    m_params.dir                  = m_dir;\r
-    m_params.sectionType          = m_sectionType;\r
-\r
-    m_params.hdr.filterIdx        = m_filterIndex;\r
-    m_params.hdr.frameId          = m_frameId;\r
-    m_params.hdr.subframeId       = m_subframeId;\r
-    m_params.hdr.slotId           = m_slotId;\r
-    m_params.hdr.startSymId       = m_symStart;\r
-    m_params.hdr.iqWidth          = XRAN_CONVERT_IQWIDTH(m_iqWidth);\r
-    m_params.hdr.compMeth         = m_compMethod;\r
-\r
-    switch(m_sectionType) {\r
-        case XRAN_CP_SECTIONTYPE_1:\r
-            break;\r
-\r
-        case XRAN_CP_SECTIONTYPE_3:\r
-            m_params.hdr.timeOffset   = m_timeOffset;\r
-            m_params.hdr.fftSize      = m_fftSize;\r
-            m_params.hdr.scs          = m_scs;\r
-            m_params.hdr.cpLength     = m_cpLength;\r
-            break;\r
-\r
-        default:\r
-            return (-1);\r
-        }\r
-\r
-    for(numsec=0; numsec < m_numSections; numsec++) {\r
-        m_params.sections[numsec].info.type         = m_params.sectionType;       // for database\r
-        m_params.sections[numsec].info.startSymId   = m_params.hdr.startSymId;    // for database\r
-        m_params.sections[numsec].info.iqWidth      = m_params.hdr.iqWidth;       // for database\r
-        m_params.sections[numsec].info.compMeth     = m_params.hdr.compMeth;      // for database\r
-        m_params.sections[numsec].info.id           = m_sectionId++;\r
-        m_params.sections[numsec].info.rb           = XRAN_RBIND_EVERY;\r
-        m_params.sections[numsec].info.symInc       = XRAN_SYMBOLNUMBER_NOTINC;\r
-        m_params.sections[numsec].info.startPrbc    = m_prbStart[numsec];\r
-        m_params.sections[numsec].info.numPrbc      = m_prbNum[numsec];\r
-        m_params.sections[numsec].info.numSymbol    = m_symNum;\r
-        m_params.sections[numsec].info.reMask       = m_reMask;\r
-        m_params.sections[numsec].info.beamId       = m_beamId;\r
-        switch(m_sectionType) {\r
-            case XRAN_CP_SECTIONTYPE_1:\r
-                break;\r
-\r
-            case XRAN_CP_SECTIONTYPE_3:\r
-                m_params.sections[numsec].info.freqOffset   = m_freqOffset;\r
-                break;\r
-\r
-            default:\r
-                return (-1);\r
-            }\r
-\r
-        /* section extension */\r
-        if(/*extflag == true*/0) {\r
-            m_params.sections[numsec].info.ef       = 1;\r
-            prepare_extensions(numsec);\r
-            }\r
-        else {\r
-            m_params.sections[numsec].info.ef       = 0;\r
-            m_params.sections[numsec].exDataSize    = 0;\r
-            }\r
-        }\r
-\r
-    m_params.numSections        = numsec;\r
-\r
-    return (0);\r
-}\r
-\r
-\r
-void C_plane::verify_sections(void)\r
-{\r
-  int i,j;\r
-\r
-    /* Verify the result */\r
-    EXPECT_TRUE(m_result.dir            == m_params.dir);\r
-    EXPECT_TRUE(m_result.sectionType    == m_params.sectionType);\r
-\r
-    EXPECT_TRUE(m_result.hdr.filterIdx  == m_params.hdr.filterIdx);\r
-    EXPECT_TRUE(m_result.hdr.frameId    == m_params.hdr.frameId);\r
-    EXPECT_TRUE(m_result.hdr.subframeId == m_params.hdr.subframeId);\r
-    EXPECT_TRUE(m_result.hdr.slotId     == m_params.hdr.slotId);\r
-    EXPECT_TRUE(m_result.hdr.startSymId == m_params.hdr.startSymId);\r
-    EXPECT_TRUE(m_result.hdr.iqWidth    == m_params.hdr.iqWidth);\r
-    EXPECT_TRUE(m_result.hdr.compMeth   == m_params.hdr.compMeth);\r
-\r
-    switch(m_sectionType) {\r
-        case XRAN_CP_SECTIONTYPE_1:\r
-            break;\r
-\r
-        case XRAN_CP_SECTIONTYPE_3:\r
-            EXPECT_TRUE(m_result.hdr.fftSize    == m_params.hdr.fftSize);\r
-            EXPECT_TRUE(m_result.hdr.scs        == m_params.hdr.scs);\r
-            EXPECT_TRUE(m_result.hdr.cpLength   == m_params.hdr.cpLength);\r
-            break;\r
-\r
-        default:\r
-            FAIL() << "Invalid Section Type - " << m_sectionType << "\n";\r
-        }\r
-\r
-    ASSERT_TRUE(m_result.numSections    == m_params.numSections);\r
-    for(i=0; i < m_result.numSections; i++) {\r
-        EXPECT_TRUE(m_result.sections[i].info.id        == m_params.sections[i].info.id);\r
-        EXPECT_TRUE(m_result.sections[i].info.rb        == XRAN_RBIND_EVERY);\r
-        EXPECT_TRUE(m_result.sections[i].info.symInc    == XRAN_SYMBOLNUMBER_NOTINC);\r
-        EXPECT_TRUE(m_result.sections[i].info.startPrbc == m_params.sections[i].info.startPrbc);\r
-        EXPECT_TRUE(m_result.sections[i].info.numPrbc   == m_params.sections[i].info.numPrbc);\r
-        EXPECT_TRUE(m_result.sections[i].info.numSymbol == m_params.sections[i].info.numSymbol);\r
-        EXPECT_TRUE(m_result.sections[i].info.reMask    == m_params.sections[i].info.reMask);\r
-        EXPECT_TRUE(m_result.sections[i].info.beamId    == m_params.sections[i].info.beamId);\r
-        EXPECT_TRUE(m_result.sections[i].info.ef        == m_params.sections[i].info.ef);\r
-\r
-        switch(m_sectionType) {\r
-            case XRAN_CP_SECTIONTYPE_1:\r
-                break;\r
-\r
-            case XRAN_CP_SECTIONTYPE_3:\r
-                EXPECT_TRUE(m_result.sections[i].info.freqOffset  == m_params.sections[i].info.freqOffset);\r
-                break;\r
-\r
-            default:\r
-                FAIL() << "Invalid Section Type - " << m_sectionType << "\n";\r
-            }\r
-\r
-        if(m_params.sections[i].info.ef) {\r
-     //       printf("[%d] %d ==  %d\n",i,  m_result.sections[i].exDataSize, m_params.sections[i].exDataSize);\r
-            EXPECT_TRUE(m_result.sections[i].exDataSize == m_params.sections[i].exDataSize);\r
-\r
-            for(j=0; j < m_params.sections[i].exDataSize; j++) {\r
-                EXPECT_TRUE(m_result.sections[i].exData[j].type == m_params.sections[i].exData[j].type);\r
-\r
-                switch(m_params.sections[i].exData[j].type) {\r
-                    case XRAN_CP_SECTIONEXTCMD_1:\r
-                        {\r
-                        struct xran_sectionext1_info *ext1_params, *ext1_result;\r
-                        int iq_size, parm_size, N;\r
-\r
-                        ext1_params = (struct xran_sectionext1_info *)m_params.sections[i].exData[j].data;\r
-                        ext1_result = (struct xran_sectionext1_info *)m_result.sections[i].exData[j].data;\r
-\r
-                        EXPECT_TRUE(ext1_result->bfwiqWidth == ext1_params->bfwiqWidth);\r
-                        EXPECT_TRUE(ext1_result->bfwCompMeth    == ext1_params->bfwCompMeth);\r
-\r
-                        N = ext1_params->bfwNumber;\r
-                        switch(ext1_params->bfwCompMeth) {\r
-                            case XRAN_BFWCOMPMETHOD_BLKFLOAT:\r
-                                EXPECT_TRUE(ext1_result->bfwCompParam.exponent == ext1_params->bfwCompParam.exponent);\r
-                                break;\r
-\r
-                            case XRAN_BFWCOMPMETHOD_BLKSCALE:\r
-                                EXPECT_TRUE(ext1_result->bfwCompParam.blockScaler == ext1_params->bfwCompParam.blockScaler);\r
-                                break;\r
-\r
-                            case XRAN_BFWCOMPMETHOD_ULAW:\r
-                                EXPECT_TRUE(ext1_result->bfwCompParam.compBitWidthShift == ext1_params->bfwCompParam.compBitWidthShift);\r
-                                break;\r
-\r
-                            case XRAN_BFWCOMPMETHOD_BEAMSPACE:\r
-                                parm_size = N>>3; if(N%8) parm_size++; parm_size *= 8;\r
-                                EXPECT_TRUE(std::memcmp(ext1_result->bfwCompParam.activeBeamspaceCoeffMask, ext1_params->bfwCompParam.activeBeamspaceCoeffMask, parm_size));\r
-                                break;\r
-                            }\r
-\r
-                        /* Get the number of BF weights */\r
-                        iq_size = N*ext1_params->bfwiqWidth*2;  // total in bits\r
-                        parm_size = iq_size>>3;                 // total in bytes (/8)\r
-                        if(iq_size%8) parm_size++;              // round up\r
-                        EXPECT_TRUE(std::memcmp(ext1_result->p_bfwIQ, ext1_params->p_bfwIQ, parm_size));\r
-\r
-                        }\r
-                        break;\r
-\r
-                    case XRAN_CP_SECTIONEXTCMD_2:\r
-                        {\r
-                        struct xran_sectionext2_info *ext2_params, *ext2_result;\r
-\r
-                        ext2_params = (struct xran_sectionext2_info *)m_params.sections[i].exData[j].data;\r
-                        ext2_result = (struct xran_sectionext2_info *)m_result.sections[i].exData[j].data;\r
-\r
-                        if(ext2_params->bfAzPtWidth) {\r
-                            EXPECT_TRUE(ext2_result->bfAzPtWidth    == ext2_params->bfAzPtWidth);\r
-                            EXPECT_TRUE(ext2_result->bfAzPt         == ext2_params->bfAzPt);\r
-                            }\r
-\r
-                        if(ext2_params->bfZePtWidth) {\r
-                            EXPECT_TRUE(ext2_result->bfZePtWidth    == ext2_params->bfZePtWidth);\r
-                            EXPECT_TRUE(ext2_result->bfZePt         == ext2_params->bfZePt);\r
-                            }\r
-                        if(ext2_params->bfAz3ddWidth) {\r
-                            EXPECT_TRUE(ext2_result->bfAz3ddWidth   == ext2_params->bfAz3ddWidth);\r
-                            EXPECT_TRUE(ext2_result->bfAz3dd        == ext2_params->bfAz3dd);\r
-                            }\r
-                        if(ext2_params->bfZe3ddWidth) {\r
-                            EXPECT_TRUE(ext2_result->bfZe3ddWidth   == ext2_params->bfZe3ddWidth);\r
-                            EXPECT_TRUE(ext2_result->bfZe3dd        == ext2_params->bfZe3dd);\r
-                            }\r
-\r
-                        EXPECT_TRUE(ext2_result->bfAzSI == ext2_params->bfAzSI);\r
-                        EXPECT_TRUE(ext2_result->bfZeSI == ext2_params->bfZeSI);\r
-                        }\r
-                        break;\r
-\r
-                    case XRAN_CP_SECTIONEXTCMD_4:\r
-                        {\r
-                        struct xran_sectionext4_info *ext4_params, *ext4_result;\r
-\r
-                        ext4_params = (struct xran_sectionext4_info *)m_params.sections[i].exData[j].data;\r
-                        ext4_result = (struct xran_sectionext4_info *)m_result.sections[i].exData[j].data;\r
-\r
-                        EXPECT_TRUE(ext4_result->csf            == ext4_params->csf);\r
-                        EXPECT_TRUE(ext4_result->modCompScaler  == ext4_params->modCompScaler);\r
-                        }\r
-                        break;\r
-                    case XRAN_CP_SECTIONEXTCMD_5:\r
-                        {\r
-                        struct xran_sectionext5_info *ext5_params, *ext5_result;\r
-                        int idx;\r
-\r
-                        ext5_params = (struct xran_sectionext5_info *)m_params.sections[i].exData[j].data;\r
-                        ext5_result = (struct xran_sectionext5_info *)m_result.sections[i].exData[j].data;\r
-\r
-                        EXPECT_TRUE(ext5_result->num_sets == ext5_params->num_sets);\r
-                        for(idx=0; idx < ext5_params->num_sets; idx++) {\r
-                            EXPECT_TRUE(ext5_result->mc[idx].csf == ext5_params->mc[idx].csf);\r
-                            EXPECT_TRUE(ext5_result->mc[idx].mcScaleReMask == ext5_params->mc[idx].mcScaleReMask);\r
-                            EXPECT_TRUE(ext5_result->mc[idx].mcScaleOffset == ext5_params->mc[idx].mcScaleOffset);\r
-                            }\r
-                        }\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-    return;\r
-}\r
-\r
-\r
-/***************************************************************************\r
- * Functional Test cases\r
- ***************************************************************************/\r
-\r
-TEST_P(C_plane, Section_Ext1)\r
-{\r
-    int i = 0, idRb;\r
-    int32_t len = 0;\r
-    int16_t *ptr = NULL;\r
-    int32_t nRbs = 36;\r
-    int32_t nAntElm = 32;\r
-    int8_t  iqWidth = 16;\r
-    int8_t  compMethod = XRAN_COMPMETHOD_NONE;\r
-    int8_t  *p_ext1_dst  = NULL;\r
-    int16_t *bfw_payload = NULL;\r
-    int32_t expected_len = (3+1)*nRbs + nAntElm*nRbs*4;\r
-\r
-    struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;\r
-    struct xran_sectionext1_info m_ext1;\r
-    struct xran_cp_radioapp_section_ext1 *p_ext1;\r
-\r
-    /* Configure section information */\r
-    if(prepare_sections(false) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-    }\r
-    ptr = m_p_bfw_iq_src;\r
-\r
-    for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){\r
-        ptr[idRb] = i;\r
-        i++;\r
-    }\r
-\r
-    len = xran_cp_populate_section_ext_1(m_p_ext1_dst,\r
-                                         m_ext1_dst_len,\r
-                                         m_p_bfw_iq_src,\r
-                                         nRbs,\r
-                                         nAntElm,\r
-                                         iqWidth,\r
-                                         compMethod);\r
-\r
-    ASSERT_TRUE(len == expected_len);\r
-\r
-    p_ext1_dst = m_p_ext1_dst;\r
-    idRb = 0;\r
-    do {\r
-        p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;\r
-        bfw_payload = (int16_t*)(p_ext1+1);\r
-        p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;\r
-        idRb++;\r
-    }while(p_ext1->ef != XRAN_EF_F_LAST);\r
-\r
-    ASSERT_TRUE(idRb == nRbs);\r
-\r
-    /* Update section information */\r
-    memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));\r
-    m_ext1.bfwNumber      = nAntElm;\r
-    m_ext1.bfwiqWidth     = iqWidth;\r
-    m_ext1.bfwCompMeth    = compMethod;\r
-    m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;\r
-    m_ext1.bfwIQ_sz       = len;\r
-\r
-    loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;\r
-    loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);\r
-    loc_pSectGenInfo->exData[0].data = &m_ext1;\r
-\r
-    loc_pSectGenInfo->info.ef       = 1;\r
-    loc_pSectGenInfo->exDataSize    = 1;\r
-\r
-    m_params.numSections    = 1;\r
-\r
-    /* Generating C-Plane packet */\r
-    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Parsing generated packet */\r
-    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Verify the result */\r
-    //verify_sections();\r
-}\r
-\r
-TEST_P(C_plane, Section_Ext1_9bit)\r
-{\r
-    int i = 0, idRb;\r
-    int32_t len = 0;\r
-    int16_t *ptr = NULL;\r
-    int32_t nRbs = 36;\r
-    int32_t nAntElm = 32;\r
-    int8_t  iqWidth = 9;\r
-    int8_t  compMethod = XRAN_COMPMETHOD_BLKFLOAT;\r
-    int8_t  *p_ext1_dst  = NULL;\r
-    int16_t *bfw_payload = NULL;\r
-    int32_t expected_len = ((nAntElm/16*4*iqWidth)+1)*nRbs + /* bfwCompParam + IQ = */\r
-                            sizeof(struct xran_cp_radioapp_section_ext1)*nRbs; /* ext1 Headers */\r
-\r
-    struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;\r
-    struct xran_sectionext1_info m_ext1;\r
-    struct xran_cp_radioapp_section_ext1 *p_ext1;\r
-\r
-    /* Configure section information */\r
-    if(prepare_sections(false) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-    }\r
-    ptr = m_p_bfw_iq_src;\r
-\r
-    for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){\r
-        ptr[idRb] = i;\r
-        i++;\r
-    }\r
-\r
-    len = xran_cp_populate_section_ext_1(m_p_ext1_dst,\r
-                                         m_ext1_dst_len,\r
-                                         m_p_bfw_iq_src,\r
-                                         nRbs,\r
-                                         nAntElm,\r
-                                         iqWidth,\r
-                                         compMethod);\r
-\r
-    ASSERT_TRUE(len == expected_len);\r
-\r
-    p_ext1_dst = m_p_ext1_dst;\r
-    idRb = 0;\r
-    do {\r
-        p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;\r
-        bfw_payload = (int16_t*)(p_ext1+1);\r
-        p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;\r
-        idRb++;\r
-    }while(p_ext1->ef != XRAN_EF_F_LAST);\r
-\r
-    ASSERT_TRUE(idRb == nRbs);\r
-\r
-    /* Update section information */\r
-    memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));\r
-    m_ext1.bfwNumber      = nAntElm;\r
-    m_ext1.bfwiqWidth     = iqWidth;\r
-    m_ext1.bfwCompMeth    = compMethod;\r
-    m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;\r
-    m_ext1.bfwIQ_sz       = len;\r
-\r
-    loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;\r
-    loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);\r
-    loc_pSectGenInfo->exData[0].data = &m_ext1;\r
-\r
-    loc_pSectGenInfo->info.ef       = 1;\r
-    loc_pSectGenInfo->exDataSize    = 1;\r
-\r
-    m_params.numSections    = 1;\r
-\r
-    /* Generating C-Plane packet */\r
-    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Parsing generated packet */\r
-    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Verify the result */\r
-    //verify_sections();\r
-}\r
-\r
-\r
-\r
-TEST_P(C_plane, PacketGen)\r
-{\r
-  int i;\r
-\r
-\r
-    /* Configure section information */\r
-    if(prepare_sections(false) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-        }\r
-\r
-    /* Generating C-Plane packet */\r
-    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Parsing generated packet */\r
-    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Verify the result */\r
-    verify_sections();\r
-}\r
-\r
-\r
-TEST_P(C_plane, PacketGen_Ext)\r
-{\r
-  int i;\r
-\r
-\r
-    /* Configure section information */\r
-    if(prepare_sections(true) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-        }\r
-\r
-    /* Generating C-Plane packet */\r
-    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Parsing generated packet */\r
-    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);\r
-\r
-    /* Verify the result */\r
-    verify_sections();\r
-}\r
-\r
-\r
-/***************************************************************************\r
- * Performance Test cases\r
- ***************************************************************************/\r
-TEST_P(C_plane, Perf)\r
-{\r
-    /* Configure section information */\r
-    if(prepare_sections(false) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-        }\r
-\r
-    /* using wrapper function to reset mbuf */\r
-    performance("C", module_name,\r
-            &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);\r
-}\r
-\r
-TEST_P(C_plane, Perf_Ext)\r
-{\r
-    /* Configure section information */\r
-    if(prepare_sections(true) < 0) {\r
-        FAIL() << "Invalid Section configuration\n";\r
-        }\r
-\r
-    /* using wrapper function to reset mbuf */\r
-    performance("C", module_name,\r
-            &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);\r
-}\r
-\r
-\r
-INSTANTIATE_TEST_CASE_P(UnitTest, C_plane,\r
-        testing::ValuesIn(get_sequence(C_plane::get_number_of_cases("C_Plane"))));\r
-\r
+/******************************************************************************
+*
+*   Copyright (c) 2019 Intel.
+*
+*   Licensed under the Apache License, Version 2.0 (the "License");
+*   you may not use this file except in compliance with the License.
+*   You may obtain a copy of the License at
+*
+*       http://www.apache.org/licenses/LICENSE-2.0
+*
+*   Unless required by applicable law or agreed to in writing, software
+*   distributed under the License is distributed on an "AS IS" BASIS,
+*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*   See the License for the specific language governing permissions and
+*   limitations under the License.
+*
+*******************************************************************************/
+
+
+#include "common.hpp"
+#include "xran_lib_wrap.hpp"
+#include "xran_common.h"
+#include "xran_fh_o_du.h"
+#include "ethdi.h"
+#include "ethernet.h"
+#include "xran_transport.h"
+#include "xran_cp_api.h"
+
+#include <stdint.h>
+
+
+const std::string module_name = "C-Plane";
+
+const uint8_t m_bitmask[] = { 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
+
+extern "C"
+{
+
+/* wrapper function for performace tests to reset mbuf */
+int xran_ut_prepare_cp(struct rte_mbuf *mbuf, struct xran_cp_gen_params *params,
+                        uint8_t cc_id, uint8_t ant_id, uint8_t seq_id)
+{
+    rte_pktmbuf_reset(mbuf);
+    return(xran_prepare_ctrl_pkt(mbuf, params, cc_id, ant_id, seq_id));
+}
+
+
+void cput_fh_rx_callback(void *pCallbackTag, xran_status_t status)
+{
+    return;
+}
+
+void cput_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status)
+{
+    rte_pause();
+}
+
+} /* extern "C" */
+
+
+
+class C_plane: public KernelTests
+{
+private:
+    struct xran_section_gen_info *m_pSectGenInfo = NULL;
+    struct xran_section_gen_info *m_pSectResult = NULL;
+
+
+protected:
+    int m_maxSections = 8;  /*  not used */
+    int m_numSections;
+
+    struct rte_mbuf *m_pTestBuffer;
+
+    struct xran_cp_gen_params m_params;
+    struct xran_recv_packet_info m_pktInfo;
+    struct xran_cp_gen_params m_result;
+
+    uint8_t     m_dir;
+    std::string m_dirStr;
+    uint8_t     m_sectionType;
+
+    uint8_t     m_ccId, m_antId;
+    uint8_t     m_seqId;
+    uint8_t     m_frameId, m_subframeId, m_slotId;
+    uint8_t     m_symStart, m_symNum;
+    uint16_t    *m_prbStart = NULL, *m_prbNum = NULL;
+
+    uint8_t     m_iqWidth, m_compMethod;
+    uint16_t    m_beamId;
+    uint16_t    m_reMask = 0xfff;
+    uint16_t    m_sectionId;
+    uint8_t     m_filterIndex;
+    uint16_t    m_timeOffset;
+    uint8_t     m_fftSize;
+    uint8_t     m_scs;
+    uint16_t    m_cpLength;
+    int         m_freqOffset;
+
+    uint16_t  m_ext1_dst_len = 0;
+    int8_t   *m_p_ext1_dst   = NULL;
+    int16_t  *m_p_bfw_iq_src = NULL;
+
+    struct xran_sectionext1_info m_ext1;
+    struct xran_sectionext2_info m_ext2;
+    struct xran_sectionext4_info m_ext4;
+    struct xran_sectionext5_info m_ext5;
+
+    int16_t m_bfwIQ[XRAN_MAX_BFW_N*2];
+
+
+    void SetUp() override
+    {
+        int i, j;
+
+        init_test("C_Plane");
+
+        m_numSections   = get_input_parameter<int>("num_sections");
+        ASSERT_FALSE(m_numSections == 0);
+
+        m_dirStr        = get_input_parameter<std::string>("direction");
+
+        if(!m_dirStr.compare("DL")) m_dir = XRAN_DIR_DL;
+        else if(!m_dirStr.compare("UL")) m_dir = XRAN_DIR_UL;
+        else FAIL() << "Invalid direction!";
+
+        m_sectionType   = get_input_parameter<uint8_t>("section_type");
+        m_ccId          = get_input_parameter<uint8_t>("cc_id");
+        m_antId         = get_input_parameter<uint8_t>("ant_id");
+        m_seqId         = get_input_parameter<uint16_t>("seq_id");
+
+        m_frameId       = get_input_parameter<uint8_t>("frame_id");
+        m_subframeId    = get_input_parameter<uint8_t>("subframe_id");
+        m_slotId        = get_input_parameter<uint8_t>("slot_id");
+        m_symStart      = get_input_parameter<uint8_t>("symbol_start");
+        m_compMethod    = get_input_parameter<uint8_t>("comp_method");
+        m_iqWidth       = get_input_parameter<uint8_t>("iq_width");
+
+        m_sectionId     = get_input_parameter<uint8_t>("section_id");
+        m_symNum        = get_input_parameter<uint8_t>("symbol_num");
+        m_beamId        = get_input_parameter<uint16_t>("beam_id");
+
+        /* reading configurations of start prb and the number of prbs  */
+        std::vector<int> prbstart = get_input_parameter<std::vector<int>>("prb_start");
+        std::vector<int> prbnum = get_input_parameter<std::vector<int>>("prb_num");
+        /* number of sections and  the pair of start/number of prb shall be matched */
+        ASSERT_TRUE((m_numSections == prbstart.size())
+                    && (m_numSections == prbnum.size())
+                    && (prbstart.size() == prbnum.size()));
+
+        m_prbStart  = new uint16_t [m_numSections];
+        m_prbNum    = new uint16_t [m_numSections];
+        for(i=0; i < m_numSections; i++) {
+            m_prbStart[i] = prbstart[i];
+            m_prbNum[i] = prbnum[i];
+            }
+
+        switch(m_sectionType) {
+            case XRAN_CP_SECTIONTYPE_1:
+                m_filterIndex = XRAN_FILTERINDEX_STANDARD;
+                break;
+
+            case XRAN_CP_SECTIONTYPE_3:
+                m_filterIndex   = get_input_parameter<uint8_t>("filter_index");
+                m_timeOffset    = get_input_parameter<uint16_t>("time_offset");
+                m_fftSize       = get_input_parameter<uint8_t>("fft_size");
+                m_scs           = get_input_parameter<uint8_t>("scs");
+                m_cpLength      = get_input_parameter<uint16_t>("cp_length");
+                m_freqOffset    = get_input_parameter<int>("freq_offset");
+                break;
+
+            default:
+                FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
+            }
+
+        /* allocate and prepare required data storage */
+        m_pSectGenInfo = new struct xran_section_gen_info [m_numSections];
+        ASSERT_NE(m_pSectGenInfo, nullptr);
+        m_params.sections = m_pSectGenInfo;
+
+        m_pSectResult = new struct xran_section_gen_info [m_numSections];
+        ASSERT_NE(m_pSectResult, nullptr);
+        m_result.sections = m_pSectResult;
+
+        m_ext1_dst_len   = 9600;
+        m_p_ext1_dst   = new int8_t [m_ext1_dst_len];
+        m_p_bfw_iq_src = new int16_t [9600/2];
+
+        /* allocating an mbuf for packet generatrion */
+        m_pTestBuffer = xran_ethdi_mbuf_alloc();
+
+        ASSERT_FALSE(m_pTestBuffer == NULL);
+    }
+
+    void TearDown() override
+    {
+        int i, j;
+
+        if(m_pTestBuffer != NULL)
+            rte_pktmbuf_free(m_pTestBuffer);
+
+        if(m_prbStart)
+            delete[] m_prbStart;
+        if(m_prbNum)
+            delete[] m_prbNum;
+
+        if(m_p_bfw_iq_src)
+            delete[] m_p_bfw_iq_src;
+
+        if(m_p_ext1_dst)
+            delete[] m_p_ext1_dst;
+
+        if(m_pSectGenInfo)
+            delete[] m_pSectGenInfo;
+
+        if(m_pSectResult) {
+            delete[] m_pSectResult;
+            }
+
+    }
+
+    int prepare_sections(bool extflag);
+    int prepare_extensions(int sect_num);
+    void verify_sections(void);
+
+};
+
+
+
+int C_plane::prepare_extensions(int sect_num)
+{
+    int i, numext;
+    int N;
+
+
+    N = 8;
+
+    // extension 1
+    m_ext1.bfwNumber  = 4*N; // 4 ant, 8 UEs
+    m_ext1.bfwiqWidth = 16;
+    m_ext1.bfwCompMeth    = XRAN_BFWCOMPMETHOD_NONE;
+                            /* XRAN_BFWCOMPMETHOD_BLKFLOAT
+                             * XRAN_BFWCOMPMETHOD_BLKSCALE
+                             * XRAN_BFWCOMPMETHOD_ULAW
+                             * XRAN_BFWCOMPMETHOD_BEAMSPACE
+                             */
+    m_ext1.p_bfwIQ = m_bfwIQ;
+
+    switch (m_ext1.bfwCompMeth) {
+        case XRAN_BFWCOMPMETHOD_BLKFLOAT:
+            m_ext1.bfwCompParam.exponent = 0xa;
+            break;
+        case XRAN_BFWCOMPMETHOD_BLKSCALE:
+            m_ext1.bfwCompParam.blockScaler = 0xa5;
+            break;
+        case XRAN_BFWCOMPMETHOD_ULAW:
+            m_ext1.bfwCompParam.compBitWidthShift = 0x55;
+        case XRAN_BFWCOMPMETHOD_BEAMSPACE:
+            for(i=0; i<N; i++)
+                m_ext1.bfwCompParam.activeBeamspaceCoeffMask[i] = 0xa0 + i;
+            break;
+        }
+
+    for(i=0; i<N*4; i++) {
+        m_ext1.p_bfwIQ[i*2]     = 0xcafe;
+        m_ext1.p_bfwIQ[i*2+1]   = 0xbeef;
+        }
+
+    // extension 2
+    m_ext2.bfAzPtWidth        = 7;
+    m_ext2.bfAzPt             = 0x55 & m_bitmask[m_ext2.bfAzPtWidth];
+    m_ext2.bfZePtWidth        = 7;
+    m_ext2.bfZePt             = 0xaa & m_bitmask[m_ext2.bfAzPtWidth];
+    m_ext2.bfAz3ddWidth       = 7;
+    m_ext2.bfAz3dd            = 0x5a & m_bitmask[m_ext2.bfAzPtWidth];
+    m_ext2.bfZe3ddWidth       = 7;
+    m_ext2.bfZe3dd            = 0xa5 & m_bitmask[m_ext2.bfAzPtWidth];
+    m_ext2.bfAzSI             = 0x2 & m_bitmask[3];
+    m_ext2.bfZeSI             = 0x5 & m_bitmask[3];
+
+    // extension 4
+    m_ext4.csf                = 1;
+    m_ext4.modCompScaler      = 0x5aa5;
+
+    // extension 5
+    m_ext5.num_sets = 2;
+    for(i=0; i<m_ext5.num_sets; i++) {
+        m_ext5.mc[i].csf              = i%2;
+        m_ext5.mc[i].mcScaleReMask    = 0xa5a + i;
+        m_ext5.mc[i].mcScaleOffset    = 0x5a5a + i;
+        }
+
+    numext = 0;
+
+    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_1;
+    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext1);
+    m_params.sections[sect_num].exData[numext].data = &m_ext1;
+    numext++;
+
+    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_2;
+    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext2);
+    m_params.sections[sect_num].exData[numext].data = &m_ext2;
+    numext++;
+
+    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_4;
+    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext4);
+    m_params.sections[sect_num].exData[numext].data = &m_ext4;
+    numext++;
+
+    m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_5;
+    m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext5);
+    m_params.sections[sect_num].exData[numext].data = &m_ext5;
+    numext++;
+
+    m_params.sections[sect_num].exDataSize = numext;
+
+    return (0);
+}
+
+int C_plane::prepare_sections(bool extflag)
+{
+  int numsec;
+
+
+    /* Preparing input data for packet generation */
+    m_params.dir                  = m_dir;
+    m_params.sectionType          = m_sectionType;
+
+    m_params.hdr.filterIdx        = m_filterIndex;
+    m_params.hdr.frameId          = m_frameId;
+    m_params.hdr.subframeId       = m_subframeId;
+    m_params.hdr.slotId           = m_slotId;
+    m_params.hdr.startSymId       = m_symStart;
+    m_params.hdr.iqWidth          = XRAN_CONVERT_IQWIDTH(m_iqWidth);
+    m_params.hdr.compMeth         = m_compMethod;
+
+    switch(m_sectionType) {
+        case XRAN_CP_SECTIONTYPE_1:
+            break;
+
+        case XRAN_CP_SECTIONTYPE_3:
+            m_params.hdr.timeOffset   = m_timeOffset;
+            m_params.hdr.fftSize      = m_fftSize;
+            m_params.hdr.scs          = m_scs;
+            m_params.hdr.cpLength     = m_cpLength;
+            break;
+
+        default:
+            return (-1);
+        }
+
+    for(numsec=0; numsec < m_numSections; numsec++) {
+        m_params.sections[numsec].info.type         = m_params.sectionType;       // for database
+        m_params.sections[numsec].info.startSymId   = m_params.hdr.startSymId;    // for database
+        m_params.sections[numsec].info.iqWidth      = m_params.hdr.iqWidth;       // for database
+        m_params.sections[numsec].info.compMeth     = m_params.hdr.compMeth;      // for database
+        m_params.sections[numsec].info.id           = m_sectionId++;
+        m_params.sections[numsec].info.rb           = XRAN_RBIND_EVERY;
+        m_params.sections[numsec].info.symInc       = XRAN_SYMBOLNUMBER_NOTINC;
+        m_params.sections[numsec].info.startPrbc    = m_prbStart[numsec];
+        m_params.sections[numsec].info.numPrbc      = m_prbNum[numsec];
+        m_params.sections[numsec].info.numSymbol    = m_symNum;
+        m_params.sections[numsec].info.reMask       = m_reMask;
+        m_params.sections[numsec].info.beamId       = m_beamId;
+        switch(m_sectionType) {
+            case XRAN_CP_SECTIONTYPE_1:
+                break;
+
+            case XRAN_CP_SECTIONTYPE_3:
+                m_params.sections[numsec].info.freqOffset   = m_freqOffset;
+                break;
+
+            default:
+                return (-1);
+            }
+
+        /* section extension */
+        if(/*extflag == true*/0) {
+            m_params.sections[numsec].info.ef       = 1;
+            prepare_extensions(numsec);
+            }
+        else {
+            m_params.sections[numsec].info.ef       = 0;
+            m_params.sections[numsec].exDataSize    = 0;
+            }
+        }
+
+    m_params.numSections        = numsec;
+
+    return (0);
+}
+
+
+void C_plane::verify_sections(void)
+{
+  int i,j;
+
+    /* Verify the result */
+    EXPECT_TRUE(m_result.dir            == m_params.dir);
+    EXPECT_TRUE(m_result.sectionType    == m_params.sectionType);
+
+    EXPECT_TRUE(m_result.hdr.filterIdx  == m_params.hdr.filterIdx);
+    EXPECT_TRUE(m_result.hdr.frameId    == m_params.hdr.frameId);
+    EXPECT_TRUE(m_result.hdr.subframeId == m_params.hdr.subframeId);
+    EXPECT_TRUE(m_result.hdr.slotId     == m_params.hdr.slotId);
+    EXPECT_TRUE(m_result.hdr.startSymId == m_params.hdr.startSymId);
+    EXPECT_TRUE(m_result.hdr.iqWidth    == m_params.hdr.iqWidth);
+    EXPECT_TRUE(m_result.hdr.compMeth   == m_params.hdr.compMeth);
+
+    switch(m_sectionType) {
+        case XRAN_CP_SECTIONTYPE_1:
+            break;
+
+        case XRAN_CP_SECTIONTYPE_3:
+            EXPECT_TRUE(m_result.hdr.fftSize    == m_params.hdr.fftSize);
+            EXPECT_TRUE(m_result.hdr.scs        == m_params.hdr.scs);
+            EXPECT_TRUE(m_result.hdr.cpLength   == m_params.hdr.cpLength);
+            break;
+
+        default:
+            FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
+        }
+
+    ASSERT_TRUE(m_result.numSections    == m_params.numSections);
+    for(i=0; i < m_result.numSections; i++) {
+        EXPECT_TRUE(m_result.sections[i].info.id        == m_params.sections[i].info.id);
+        EXPECT_TRUE(m_result.sections[i].info.rb        == XRAN_RBIND_EVERY);
+        EXPECT_TRUE(m_result.sections[i].info.symInc    == XRAN_SYMBOLNUMBER_NOTINC);
+        EXPECT_TRUE(m_result.sections[i].info.startPrbc == m_params.sections[i].info.startPrbc);
+        EXPECT_TRUE(m_result.sections[i].info.numPrbc   == m_params.sections[i].info.numPrbc);
+        EXPECT_TRUE(m_result.sections[i].info.numSymbol == m_params.sections[i].info.numSymbol);
+        EXPECT_TRUE(m_result.sections[i].info.reMask    == m_params.sections[i].info.reMask);
+        EXPECT_TRUE(m_result.sections[i].info.beamId    == m_params.sections[i].info.beamId);
+        EXPECT_TRUE(m_result.sections[i].info.ef        == m_params.sections[i].info.ef);
+
+        switch(m_sectionType) {
+            case XRAN_CP_SECTIONTYPE_1:
+                break;
+
+            case XRAN_CP_SECTIONTYPE_3:
+                EXPECT_TRUE(m_result.sections[i].info.freqOffset  == m_params.sections[i].info.freqOffset);
+                break;
+
+            default:
+                FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
+            }
+
+        if(m_params.sections[i].info.ef) {
+     //       printf("[%d] %d ==  %d\n",i,  m_result.sections[i].exDataSize, m_params.sections[i].exDataSize);
+            EXPECT_TRUE(m_result.sections[i].exDataSize == m_params.sections[i].exDataSize);
+
+            for(j=0; j < m_params.sections[i].exDataSize; j++) {
+                EXPECT_TRUE(m_result.sections[i].exData[j].type == m_params.sections[i].exData[j].type);
+
+                switch(m_params.sections[i].exData[j].type) {
+                    case XRAN_CP_SECTIONEXTCMD_1:
+                        {
+                        struct xran_sectionext1_info *ext1_params, *ext1_result;
+                        int iq_size, parm_size, N;
+
+                        ext1_params = (struct xran_sectionext1_info *)m_params.sections[i].exData[j].data;
+                        ext1_result = (struct xran_sectionext1_info *)m_result.sections[i].exData[j].data;
+
+                        EXPECT_TRUE(ext1_result->bfwiqWidth == ext1_params->bfwiqWidth);
+                        EXPECT_TRUE(ext1_result->bfwCompMeth    == ext1_params->bfwCompMeth);
+
+                        N = ext1_params->bfwNumber;
+                        switch(ext1_params->bfwCompMeth) {
+                            case XRAN_BFWCOMPMETHOD_BLKFLOAT:
+                                EXPECT_TRUE(ext1_result->bfwCompParam.exponent == ext1_params->bfwCompParam.exponent);
+                                break;
+
+                            case XRAN_BFWCOMPMETHOD_BLKSCALE:
+                                EXPECT_TRUE(ext1_result->bfwCompParam.blockScaler == ext1_params->bfwCompParam.blockScaler);
+                                break;
+
+                            case XRAN_BFWCOMPMETHOD_ULAW:
+                                EXPECT_TRUE(ext1_result->bfwCompParam.compBitWidthShift == ext1_params->bfwCompParam.compBitWidthShift);
+                                break;
+
+                            case XRAN_BFWCOMPMETHOD_BEAMSPACE:
+                                parm_size = N>>3; if(N%8) parm_size++; parm_size *= 8;
+                                EXPECT_TRUE(std::memcmp(ext1_result->bfwCompParam.activeBeamspaceCoeffMask, ext1_params->bfwCompParam.activeBeamspaceCoeffMask, parm_size));
+                                break;
+                            }
+
+                        /* Get the number of BF weights */
+                        iq_size = N*ext1_params->bfwiqWidth*2;  // total in bits
+                        parm_size = iq_size>>3;                 // total in bytes (/8)
+                        if(iq_size%8) parm_size++;              // round up
+                        EXPECT_TRUE(std::memcmp(ext1_result->p_bfwIQ, ext1_params->p_bfwIQ, parm_size));
+
+                        }
+                        break;
+
+                    case XRAN_CP_SECTIONEXTCMD_2:
+                        {
+                        struct xran_sectionext2_info *ext2_params, *ext2_result;
+
+                        ext2_params = (struct xran_sectionext2_info *)m_params.sections[i].exData[j].data;
+                        ext2_result = (struct xran_sectionext2_info *)m_result.sections[i].exData[j].data;
+
+                        if(ext2_params->bfAzPtWidth) {
+                            EXPECT_TRUE(ext2_result->bfAzPtWidth    == ext2_params->bfAzPtWidth);
+                            EXPECT_TRUE(ext2_result->bfAzPt         == ext2_params->bfAzPt);
+                            }
+
+                        if(ext2_params->bfZePtWidth) {
+                            EXPECT_TRUE(ext2_result->bfZePtWidth    == ext2_params->bfZePtWidth);
+                            EXPECT_TRUE(ext2_result->bfZePt         == ext2_params->bfZePt);
+                            }
+                        if(ext2_params->bfAz3ddWidth) {
+                            EXPECT_TRUE(ext2_result->bfAz3ddWidth   == ext2_params->bfAz3ddWidth);
+                            EXPECT_TRUE(ext2_result->bfAz3dd        == ext2_params->bfAz3dd);
+                            }
+                        if(ext2_params->bfZe3ddWidth) {
+                            EXPECT_TRUE(ext2_result->bfZe3ddWidth   == ext2_params->bfZe3ddWidth);
+                            EXPECT_TRUE(ext2_result->bfZe3dd        == ext2_params->bfZe3dd);
+                            }
+
+                        EXPECT_TRUE(ext2_result->bfAzSI == ext2_params->bfAzSI);
+                        EXPECT_TRUE(ext2_result->bfZeSI == ext2_params->bfZeSI);
+                        }
+                        break;
+
+                    case XRAN_CP_SECTIONEXTCMD_4:
+                        {
+                        struct xran_sectionext4_info *ext4_params, *ext4_result;
+
+                        ext4_params = (struct xran_sectionext4_info *)m_params.sections[i].exData[j].data;
+                        ext4_result = (struct xran_sectionext4_info *)m_result.sections[i].exData[j].data;
+
+                        EXPECT_TRUE(ext4_result->csf            == ext4_params->csf);
+                        EXPECT_TRUE(ext4_result->modCompScaler  == ext4_params->modCompScaler);
+                        }
+                        break;
+                    case XRAN_CP_SECTIONEXTCMD_5:
+                        {
+                        struct xran_sectionext5_info *ext5_params, *ext5_result;
+                        int idx;
+
+                        ext5_params = (struct xran_sectionext5_info *)m_params.sections[i].exData[j].data;
+                        ext5_result = (struct xran_sectionext5_info *)m_result.sections[i].exData[j].data;
+
+                        EXPECT_TRUE(ext5_result->num_sets == ext5_params->num_sets);
+                        for(idx=0; idx < ext5_params->num_sets; idx++) {
+                            EXPECT_TRUE(ext5_result->mc[idx].csf == ext5_params->mc[idx].csf);
+                            EXPECT_TRUE(ext5_result->mc[idx].mcScaleReMask == ext5_params->mc[idx].mcScaleReMask);
+                            EXPECT_TRUE(ext5_result->mc[idx].mcScaleOffset == ext5_params->mc[idx].mcScaleOffset);
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+
+    return;
+}
+
+
+/***************************************************************************
+ * Functional Test cases
+ ***************************************************************************/
+
+TEST_P(C_plane, Section_Ext1)
+{
+    int i = 0, idRb;
+    int32_t len = 0;
+    int16_t *ptr = NULL;
+    int32_t nRbs = 36;
+    int32_t nAntElm = 32;
+    int8_t  iqWidth = 16;
+    int8_t  compMethod = XRAN_COMPMETHOD_NONE;
+    int8_t  *p_ext1_dst  = NULL;
+    int16_t *bfw_payload = NULL;
+    int32_t expected_len = (3+1)*nRbs + nAntElm*nRbs*4;
+
+    struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;
+    struct xran_sectionext1_info m_ext1;
+    struct xran_cp_radioapp_section_ext1 *p_ext1;
+
+    /* Configure section information */
+    if(prepare_sections(false) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+    }
+    ptr = m_p_bfw_iq_src;
+
+    for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){
+        ptr[idRb] = i;
+        i++;
+    }
+
+    len = xran_cp_populate_section_ext_1(m_p_ext1_dst,
+                                         m_ext1_dst_len,
+                                         m_p_bfw_iq_src,
+                                         nRbs,
+                                         nAntElm,
+                                         iqWidth,
+                                         compMethod);
+
+    ASSERT_TRUE(len == expected_len);
+
+    p_ext1_dst = m_p_ext1_dst;
+    idRb = 0;
+    do {
+        p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;
+        bfw_payload = (int16_t*)(p_ext1+1);
+        p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;
+        idRb++;
+    }while(p_ext1->ef != XRAN_EF_F_LAST);
+
+    ASSERT_TRUE(idRb == nRbs);
+
+    /* Update section information */
+    memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));
+    m_ext1.bfwNumber      = nAntElm;
+    m_ext1.bfwiqWidth     = iqWidth;
+    m_ext1.bfwCompMeth    = compMethod;
+    m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;
+    m_ext1.bfwIQ_sz       = len;
+
+    loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;
+    loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);
+    loc_pSectGenInfo->exData[0].data = &m_ext1;
+
+    loc_pSectGenInfo->info.ef       = 1;
+    loc_pSectGenInfo->exDataSize    = 1;
+
+    m_params.numSections    = 1;
+
+    /* Generating C-Plane packet */
+    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
+
+    /* Parsing generated packet */
+    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
+
+    /* Verify the result */
+    //verify_sections();
+}
+
+TEST_P(C_plane, Section_Ext1_9bit)
+{
+    int i = 0, idRb;
+    int32_t len = 0;
+    int16_t *ptr = NULL;
+    int32_t nRbs = 36;
+    int32_t nAntElm = 32;
+    int8_t  iqWidth = 9;
+    int8_t  compMethod = XRAN_COMPMETHOD_BLKFLOAT;
+    int8_t  *p_ext1_dst  = NULL;
+    int16_t *bfw_payload = NULL;
+    int32_t expected_len = ((nAntElm/16*4*iqWidth)+1)*nRbs + /* bfwCompParam + IQ = */
+                            sizeof(struct xran_cp_radioapp_section_ext1)*nRbs; /* ext1 Headers */
+
+    struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;
+    struct xran_sectionext1_info m_ext1;
+    struct xran_cp_radioapp_section_ext1 *p_ext1;
+
+    /* Configure section information */
+    if(prepare_sections(false) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+    }
+    ptr = m_p_bfw_iq_src;
+
+    for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){
+        ptr[idRb] = i;
+        i++;
+    }
+
+    len = xran_cp_populate_section_ext_1(m_p_ext1_dst,
+                                         m_ext1_dst_len,
+                                         m_p_bfw_iq_src,
+                                         nRbs,
+                                         nAntElm,
+                                         iqWidth,
+                                         compMethod);
+
+    ASSERT_TRUE(len == expected_len);
+
+    p_ext1_dst = m_p_ext1_dst;
+    idRb = 0;
+    do {
+        p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;
+        bfw_payload = (int16_t*)(p_ext1+1);
+        p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;
+        idRb++;
+    }while(p_ext1->ef != XRAN_EF_F_LAST);
+
+    ASSERT_TRUE(idRb == nRbs);
+
+    /* Update section information */
+    memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));
+    m_ext1.bfwNumber      = nAntElm;
+    m_ext1.bfwiqWidth     = iqWidth;
+    m_ext1.bfwCompMeth    = compMethod;
+    m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;
+    m_ext1.bfwIQ_sz       = len;
+
+    loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;
+    loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);
+    loc_pSectGenInfo->exData[0].data = &m_ext1;
+
+    loc_pSectGenInfo->info.ef       = 1;
+    loc_pSectGenInfo->exDataSize    = 1;
+
+    m_params.numSections    = 1;
+
+    /* Generating C-Plane packet */
+    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
+
+    /* Parsing generated packet */
+    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
+
+    /* Verify the result */
+    //verify_sections();
+}
+
+
+
+TEST_P(C_plane, PacketGen)
+{
+  int i;
+
+
+    /* Configure section information */
+    if(prepare_sections(false) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+        }
+
+    /* Generating C-Plane packet */
+    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
+
+    /* Parsing generated packet */
+    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
+
+    /* Verify the result */
+    verify_sections();
+}
+
+
+TEST_P(C_plane, PacketGen_Ext)
+{
+  int i;
+
+
+    /* Configure section information */
+    if(prepare_sections(true) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+        }
+
+    /* Generating C-Plane packet */
+    ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
+
+    /* Parsing generated packet */
+    EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
+
+    /* Verify the result */
+    verify_sections();
+}
+
+
+/***************************************************************************
+ * Performance Test cases
+ ***************************************************************************/
+TEST_P(C_plane, Perf)
+{
+    /* Configure section information */
+    if(prepare_sections(false) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+        }
+
+    /* using wrapper function to reset mbuf */
+    performance("C", module_name,
+            &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);
+}
+
+TEST_P(C_plane, Perf_Ext)
+{
+    /* Configure section information */
+    if(prepare_sections(true) < 0) {
+        FAIL() << "Invalid Section configuration\n";
+        }
+
+    /* using wrapper function to reset mbuf */
+    performance("C", module_name,
+            &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);
+}
+
+
+INSTANTIATE_TEST_CASE_P(UnitTest, C_plane,
+        testing::ValuesIn(get_sequence(C_plane::get_number_of_cases("C_Plane"))));
+