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_common.h"
22 #include "xran_fh_o_du.h"
24 #include "xran_transport.h"
25 #include "xran_cp_api.h"
30 const std::string module_name = "Prach_test";
33 class PrachPerf : public KernelTests
37 struct xran_section_gen_info *m_pSectResult = NULL;
40 struct xran_fh_config m_xranConf;
41 struct xran_device_ctx m_xran_dev_ctx;
42 struct xran_prach_config *m_pPRACHConfig;
43 struct xran_prach_cp_config *m_pPrachCPConfig;
45 struct xran_section_gen_info *m_pSectGenInfo = NULL;
46 int m_maxSections = 8; /* not used */
49 struct rte_mbuf *m_pTestBuffer;
51 struct xran_cp_gen_params m_params;
52 struct xran_recv_packet_info m_pktInfo;
53 struct xran_cp_gen_params m_result;
57 uint8_t m_sectionType;
59 uint8_t m_ccId, m_antId;
61 uint8_t m_frameId, m_subframeId, m_slotId;
62 uint8_t m_symStart, m_symNum;
63 uint16_t *m_prbStart = NULL, *m_prbNum = NULL;
65 uint8_t m_iqWidth, m_compMethod;
67 uint16_t m_reMask = 0xfff;
69 uint8_t m_filterIndex;
70 //uint16_t m_timeOffset;
73 //define reference values
80 uint16_t m_timeOffset;
82 uint8_t m_nrofPrachInSlot;
83 uint8_t m_occassionsInPrachSlot;
84 uint8_t m_y[XRAN_PRACH_CANDIDATE_Y];
85 uint8_t m_isPRACHslot[XRAN_PRACH_CANDIDATE_SLOT];
86 int m_prach_start_symbol;
87 int m_prach_last_symbol;
93 init_test("prach_performance");
94 memset(&m_xranConf, 0, sizeof(struct xran_fh_config));
95 memset(&m_xran_dev_ctx, 0, sizeof(struct xran_device_ctx));
96 m_pPRACHConfig = &m_xranConf.prach_conf;
97 m_pPrachCPConfig = &m_xran_dev_ctx.PrachCPConfig;
99 //initialize input parameters
100 m_xranConf.frame_conf.nNumerology = get_input_parameter<uint8_t>("Numerology");
101 m_xranConf.frame_conf.nFrameDuplexType = get_input_parameter<uint8_t>("FrameDuplexType");
102 m_xranConf.log_level = get_input_parameter<uint32_t>("loglevel");
104 m_pPRACHConfig->nPrachConfIdx = get_input_parameter<uint8_t>("PrachConfIdx");
105 m_pPRACHConfig->nPrachFreqStart = get_input_parameter<uint16_t>("PrachFreqStart");
106 m_pPRACHConfig->nPrachFreqOffset = get_input_parameter<int32_t>("PrachFreqOffset");
107 m_pPRACHConfig->nPrachSubcSpacing = get_input_parameter<uint8_t>("PrachSubcSpacing");
110 m_frameId = get_input_parameter<uint8_t>("frameId");
111 m_subframeId = get_input_parameter<uint8_t>("subframeId");
112 m_slotId = get_input_parameter<uint8_t>("slotId");
113 m_beamId = get_input_parameter<uint16_t>("beamId");
114 m_ccId = get_input_parameter<uint8_t>("ccId");
115 m_antId = get_input_parameter<uint8_t>("antId");
117 //initialize reference output
118 m_startSymId = get_reference_parameter<uint8_t>("startSymId");
119 m_x = get_reference_parameter<uint8_t>("x_value");
120 m_filterIdx = get_reference_parameter<uint8_t>("filterIdx");
121 m_startPrbc = get_reference_parameter<uint16_t>("startPrbc");
122 m_numPrbc = get_reference_parameter<uint8_t>("numPrbc");
123 m_timeOffset = get_reference_parameter<uint16_t>("timeOffset");
124 m_freqOffset = get_reference_parameter<uint32_t>("freqOffset");
125 m_nrofPrachInSlot = get_reference_parameter<uint8_t>("nrofPrachInSlot");
127 //get the values from a vector
128 std::vector<uint8_t> y_vec = get_reference_parameter<std::vector<uint8_t>>("y_value");
129 for(int i=0; i < XRAN_PRACH_CANDIDATE_Y; i++) {
133 m_numSymbol = get_reference_parameter<uint8_t>("numSymbol");
134 m_occassionsInPrachSlot = get_reference_parameter<uint8_t>("occassionsInPrachSlot");
136 std::vector<uint8_t> index_vec = get_reference_parameter<std::vector<uint8_t>>("isPRACHslot");
137 m_SlotNrNum = get_reference_parameter<uint8_t>("SlotNrNum");
138 for(int i = 0; i < XRAN_PRACH_CANDIDATE_SLOT; i++){
141 for(int i=0; i<m_SlotNrNum;i++){
142 m_isPRACHslot[index_vec[i]]=1;
146 m_prach_start_symbol = get_reference_parameter<int>("prach_start_symbol");
147 m_prach_last_symbol = get_reference_parameter<int>("prach_last_symbol");
149 /* allocate and prepare required data storage */
150 m_pSectGenInfo = new struct xran_section_gen_info[8];
151 ASSERT_NE(m_pSectGenInfo, nullptr);
152 m_params.sections = m_pSectGenInfo;
154 /* allocating an mbuf for packet generatrion */
155 m_pTestBuffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
156 ASSERT_FALSE(m_pTestBuffer == NULL);
160 void TearDown() override
163 if(m_pTestBuffer != NULL)
164 rte_pktmbuf_free(m_pTestBuffer);
166 delete[] m_pSectGenInfo;
172 void performance_cp(void *pHandle,struct xran_cp_gen_params *params, struct xran_section_gen_info *sect_geninfo, struct xran_device_ctx *pxran_lib_ctx,
173 uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id,
174 uint16_t beam_id, uint8_t cc_id, uint8_t prach_port_id, uint8_t seq_id)
176 struct rte_mbuf *mbuf;
178 mbuf = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
180 generate_cpmsg_prach(pxran_lib_ctx, params, sect_geninfo, mbuf, pxran_lib_ctx,
181 frame_id, subframe_id, slot_id,
182 beam_id, cc_id, prach_port_id, 0, seq_id);
186 rte_pktmbuf_free(mbuf);
189 TEST_P(PrachPerf, PrachPerfPacketGen)//TestCaseName TestName
192 void *pHandle = NULL;
194 /* Preparing input data for prach config */
195 ret = xran_init_prach(&m_xranConf, &m_xran_dev_ctx);
196 ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
199 ret = generate_cpmsg_prach(&m_xran_dev_ctx, &m_params, m_pSectGenInfo, m_pTestBuffer, &m_xran_dev_ctx,
200 m_frameId, m_subframeId, m_slotId,
201 m_beamId, m_ccId, m_antId, 0, 0);
202 ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
205 performance("C", module_name,
206 &performance_cp, pHandle, &m_params, m_pSectGenInfo, &m_xran_dev_ctx,
207 m_frameId, m_subframeId, m_slotId,
208 m_beamId, m_ccId, m_antId, 0);
212 INSTANTIATE_TEST_CASE_P(UnitTest, PrachPerf,
213 testing::ValuesIn(get_sequence(PrachPerf::get_number_of_cases("prach_performance"))));