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_recv_info *m_pSectResult = NULL; /*Not used*/
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_xran_dev_ctx.dssPeriod = get_input_parameter<uint8_t>("dssperiod");
105 m_pPRACHConfig->nPrachConfIdx = get_input_parameter<uint8_t>("PrachConfIdx");
106 m_pPRACHConfig->nPrachFreqStart = get_input_parameter<uint16_t>("PrachFreqStart");
107 m_pPRACHConfig->nPrachFreqOffset = get_input_parameter<int32_t>("PrachFreqOffset");
108 m_pPRACHConfig->nPrachSubcSpacing = get_input_parameter<uint8_t>("PrachSubcSpacing");
111 m_frameId = get_input_parameter<uint8_t>("frameId");
112 m_subframeId = get_input_parameter<uint8_t>("subframeId");
113 m_slotId = get_input_parameter<uint8_t>("slotId");
114 m_beamId = get_input_parameter<uint16_t>("beamId");
115 m_ccId = get_input_parameter<uint8_t>("ccId");
116 m_antId = get_input_parameter<uint8_t>("antId");
118 //initialize reference output
119 m_startSymId = get_reference_parameter<uint8_t>("startSymId");
120 m_x = get_reference_parameter<uint8_t>("x_value");
121 m_filterIdx = get_reference_parameter<uint8_t>("filterIdx");
122 m_startPrbc = get_reference_parameter<uint16_t>("startPrbc");
123 m_numPrbc = get_reference_parameter<uint8_t>("numPrbc");
124 m_timeOffset = get_reference_parameter<uint16_t>("timeOffset");
125 m_freqOffset = get_reference_parameter<uint32_t>("freqOffset");
126 m_nrofPrachInSlot = get_reference_parameter<uint8_t>("nrofPrachInSlot");
128 //get the values from a vector
129 std::vector<uint8_t> y_vec = get_reference_parameter<std::vector<uint8_t>>("y_value");
130 for(int i=0; i < XRAN_PRACH_CANDIDATE_Y; i++) {
134 m_numSymbol = get_reference_parameter<uint8_t>("numSymbol");
135 m_occassionsInPrachSlot = get_reference_parameter<uint8_t>("occassionsInPrachSlot");
137 std::vector<uint8_t> index_vec = get_reference_parameter<std::vector<uint8_t>>("isPRACHslot");
138 m_SlotNrNum = get_reference_parameter<uint8_t>("SlotNrNum");
139 for(int i = 0; i < XRAN_PRACH_CANDIDATE_SLOT; i++){
142 for(int i=0; i<m_SlotNrNum;i++){
143 m_isPRACHslot[index_vec[i]]=1;
147 m_prach_start_symbol = get_reference_parameter<int>("prach_start_symbol");
148 m_prach_last_symbol = get_reference_parameter<int>("prach_last_symbol");
150 /* allocate and prepare required data storage */
151 m_pSectGenInfo = new struct xran_section_gen_info[8];
152 ASSERT_NE(m_pSectGenInfo, nullptr);
153 m_params.sections = m_pSectGenInfo;
154 m_params.sections[0].info = new xran_section_info;
156 /* allocating an mbuf for packet generatrion */
157 m_pTestBuffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
158 ASSERT_FALSE(m_pTestBuffer == NULL);
162 void TearDown() override
165 if(m_pTestBuffer != NULL)
166 rte_pktmbuf_free(m_pTestBuffer);
168 delete[] m_pSectGenInfo;
174 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,
175 uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id,
176 uint16_t beam_id, uint8_t cc_id, uint8_t prach_port_id, uint8_t seq_id)
178 struct rte_mbuf *mbuf;
180 mbuf = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
182 generate_cpmsg_prach(pxran_lib_ctx, params, sect_geninfo, mbuf, pxran_lib_ctx,
183 frame_id, subframe_id, slot_id, 0,
184 beam_id, cc_id, prach_port_id, 0, seq_id);
188 rte_pktmbuf_free(mbuf);
191 TEST_P(PrachPerf, PrachPerfPacketGen)//TestCaseName TestName
194 void *pHandle = NULL;
196 /* Preparing input data for prach config */
197 ret = xran_init_prach(&m_xranConf, &m_xran_dev_ctx, XRAN_RAN_5GNR);
198 ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
201 ret = generate_cpmsg_prach(&m_xran_dev_ctx, &m_params, m_pSectGenInfo, m_pTestBuffer, &m_xran_dev_ctx,
202 m_frameId, m_subframeId, m_slotId, 0,
203 m_beamId, m_ccId, m_antId, 0, 0);
204 ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
207 performance("C", module_name,
208 &performance_cp, pHandle, &m_params, m_pSectGenInfo, &m_xran_dev_ctx,
209 m_frameId, m_subframeId, m_slotId,
210 m_beamId, m_ccId, m_antId, 0);
212 if(m_params.sections[0].info)
213 delete[] m_params.sections[0].info;
217 INSTANTIATE_TEST_CASE_P(UnitTest, PrachPerf,
218 testing::ValuesIn(get_sequence(PrachPerf::get_number_of_cases("prach_performance"))));