o-du/phy
Intel O-RAN/X-RAN Generated Doxygen Documentation
prach_functional.cc
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright (c) 2019 Intel.
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 *******************************************************************************/
18 
19 
20 #include "common.hpp"
21 #include "xran_common.h"
22 #include "xran_fh_o_du.h"
23 #include "ethernet.h"
24 #include "xran_transport.h"
25 #include "xran_cp_api.h"
26 
27 #include <stdint.h>
28 
29 
30 const std::string module_name = "Prach_test";
31 
32 
33 class PrachCheck : public KernelTests
34 {
35 private:
36  struct xran_section_gen_info *m_pSectResult = NULL;
37 
38 protected:
44 
46  int m_maxSections = 8; /* not used */
48 
49  struct rte_mbuf *m_pTestBuffer;
50 
54 
55  uint8_t m_dir;
56  std::string m_dirStr;
57  uint8_t m_sectionType;
58 
59  uint8_t m_ccId, m_antId;
60  uint8_t m_seqId;
62  uint8_t m_symStart, m_symNum;
63  uint16_t *m_prbStart = NULL, *m_prbNum = NULL;
64 
66  uint16_t m_beamId;
67  uint16_t m_reMask = 0xfff;
68  uint16_t m_sectionId;
69  uint8_t m_filterIndex;
70  //uint16_t m_timeOffset;
71  uint8_t m_fftSize;
72 
73  //define reference values
74  uint8_t m_startSymId;
75  uint8_t m_x;
76  uint8_t m_filterIdx;
77  uint16_t m_startPrbc;
78  uint8_t m_numPrbc;
79  uint8_t m_numSymbol;
80  uint16_t m_timeOffset;
81  int32_t m_freqOffset;
88  uint8_t m_SlotNrNum;
90  uint16_t m_id;
91 
92  void SetUp() override
93  {
94  init_test("prach_functional");
95  memset(&m_xran_dev_ctx, 0, sizeof(struct xran_device_ctx));
96  //modify
97  m_xranConf = &m_xran_dev_ctx.fh_cfg;
98 
99  m_pPRACHConfig = &m_xranConf->prach_conf;
100  m_pRUConfig = &m_xranConf->ru_conf;
101  m_pPrachCPConfig = &m_xran_dev_ctx.PrachCPConfig;
102  //initialize input parameters
103  m_xranConf->frame_conf.nNumerology = get_input_parameter<uint8_t>("Numerology");
104  m_xranConf->frame_conf.nFrameDuplexType = get_input_parameter<uint8_t>("FrameDuplexType");
105  m_xranConf->log_level = get_input_parameter<uint32_t>("loglevel");
106  m_pPRACHConfig->nPrachConfIdx = get_input_parameter<uint8_t>("PrachConfIdx");
107  m_pPRACHConfig->nPrachFreqStart = get_input_parameter<uint16_t>("PrachFreqStart");
108  m_pPRACHConfig->nPrachFreqOffset = get_input_parameter<int32_t>("PrachFreqOffset");
109  m_pPRACHConfig->nPrachSubcSpacing = get_input_parameter<uint8_t>("PrachSubcSpacing");
110 
111  m_pRUConfig->iqWidth = get_input_parameter<uint8_t>("iqWidth");
112  m_pRUConfig->compMeth = get_input_parameter<uint8_t>("compMeth");
113  m_pRUConfig->fftSize = get_input_parameter<uint8_t>("fftSize");
114 
115  m_frameId = get_input_parameter<uint8_t>("frameId");
116  m_subframeId = get_input_parameter<uint8_t>("subframeId");
117  m_slotId = get_input_parameter<uint8_t>("slotId");
118  m_beamId = get_input_parameter<uint16_t>("beamId");
119  m_ccId = get_input_parameter<uint8_t>("ccId");
120  m_antId = get_input_parameter<uint8_t>("antId");
121 
122  //initialize reference output
123  m_startSymId = get_reference_parameter<uint8_t>("startSymId");
124  m_x = get_reference_parameter<uint8_t>("x_value");
125 
126  m_filterIdx = get_reference_parameter<uint8_t>("filterIdx");
127  m_startPrbc = get_reference_parameter<uint16_t>("startPrbc");
128  m_numPrbc = get_reference_parameter<uint8_t>("numPrbc");
129  m_timeOffset = get_reference_parameter<uint16_t>("timeOffset");
130  m_freqOffset = get_reference_parameter<uint32_t>("freqOffset");
131  m_nrofPrachInSlot = get_reference_parameter<uint8_t>("nrofPrachInSlot");
132  m_m_params_timeOffset = get_reference_parameter<uint16_t>("m_params_timeOffset");
133  m_id = get_reference_parameter<uint16_t>("id");
134  std::vector<uint8_t> y_vec = get_reference_parameter<std::vector<uint8_t>>("y_value");
135  for(int i=0; i < XRAN_PRACH_CANDIDATE_Y; i++) {
136  m_y[i] = y_vec[i];
137  }
138 
139  m_numSymbol = get_reference_parameter<uint8_t>("numSymbol");
140  m_occassionsInPrachSlot = get_reference_parameter<uint8_t>("occassionsInPrachSlot");
141 
142  std::vector<uint8_t> index_vec = get_reference_parameter<std::vector<uint8_t>>("isPRACHslot");
143  m_SlotNrNum = get_reference_parameter<uint8_t>("SlotNrNum");
144  for(int i = 0; i < XRAN_PRACH_CANDIDATE_SLOT; i++){
145  m_isPRACHslot[i]=0;
146  }
147  for(int i=0; i<m_SlotNrNum;i++){
148  m_isPRACHslot[index_vec[i]]=1;
149  }
150 
151 
152  m_prach_start_symbol = get_reference_parameter<int>("prach_start_symbol");
153  m_prach_last_symbol = get_reference_parameter<int>("prach_last_symbol");
154 
155  /* allocate and prepare required data storage */
156  m_pSectGenInfo = new struct xran_section_gen_info[8];
157  ASSERT_NE(m_pSectGenInfo, nullptr);
159 
160  /* allocating an mbuf for packet generatrion */
161  m_pTestBuffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
162  ASSERT_FALSE(m_pTestBuffer == NULL);
163 
164  }
165 
166  void TearDown() override
167  {
168  if(m_pTestBuffer != NULL)
169  rte_pktmbuf_free(m_pTestBuffer);
170  if(m_pSectGenInfo)
171  delete[] m_pSectGenInfo;
172  return;
173  }
174 };
175 
176 
177 TEST_P(PrachCheck, PacketGen)//TestCaseName TestName
178 {
179  int ret;
180  int32_t i;
181  void *pHandle = NULL;
182 
183  /* Preparing input data for prach config */
185  ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
186 
187  /* Verify the result */
191  EXPECT_EQ(m_pPrachCPConfig->numPrbc, m_numPrbc);
194  EXPECT_EQ(m_pPrachCPConfig->x, m_x);
196  EXPECT_EQ(m_pPrachCPConfig->y[0], m_y[0]);
197  EXPECT_EQ(m_pPrachCPConfig->y[1], m_y[1]);
200  for (i = 0; i < XRAN_PRACH_CANDIDATE_SLOT; i++){
201  EXPECT_EQ(m_pPrachCPConfig->isPRACHslot[i], m_isPRACHslot[i]);
202  }
203  for (i = 0; i < XRAN_MAX_SECTOR_NR; i++){
206  }
207 
208  ret = xran_open(pHandle, m_xranConf);
209  ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
210 
213  m_beamId, m_ccId, m_antId, 0);
214  ASSERT_TRUE(ret == XRAN_STATUS_SUCCESS);
215  /* Verify the result */
217  EXPECT_EQ(m_params.dir, XRAN_DIR_UL);
218  EXPECT_EQ(m_params.hdr.filterIdx, m_filterIdx);
219  EXPECT_EQ(m_params.hdr.frameId, m_frameId);
220  EXPECT_EQ(m_params.hdr.subframeId, m_subframeId);
221  EXPECT_EQ(m_params.hdr.slotId, m_slotId);
222  EXPECT_EQ(m_params.hdr.startSymId, m_startSymId);
223  EXPECT_EQ(m_params.hdr.iqWidth, (m_pRUConfig->iqWidth==16)?0:m_pRUConfig->iqWidth);
226  EXPECT_EQ(m_params.hdr.fftSize,m_pRUConfig->fftSize);
228  EXPECT_EQ(m_params.hdr.cpLength, 0);
229  EXPECT_EQ(m_params.numSections, 1);
230 
235 
236  EXPECT_EQ(m_params.sections[0].info.id, m_id);
237  EXPECT_EQ(m_params.sections[0].info.rb, XRAN_RBIND_EVERY);
239  EXPECT_EQ(m_params.sections[0].info.startPrbc, m_startPrbc);
240  EXPECT_EQ(m_params.sections[0].info.numPrbc, m_numPrbc);
242  EXPECT_EQ(m_params.sections[0].info.reMask, 0xfff);
243  EXPECT_EQ(m_params.sections[0].info.beamId, m_beamId);
246  EXPECT_EQ(m_params.sections[0].info.ef, 0);
247  EXPECT_EQ(m_params.sections[0].exDataSize, 0);
248 
249 }
250 
251 
253  testing::ValuesIn(get_sequence(PrachCheck::get_number_of_cases("prach_functional"))));
254 
int generate_cpmsg_prach(void *pHandle, struct xran_cp_gen_params *params, struct xran_section_gen_info *sect_geninfo, struct rte_mbuf *mbuf, struct xran_device_ctx *pxran_lib_ctx, uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id, uint16_t beam_id, uint8_t cc_id, uint8_t prach_port_id, uint8_t seq_id)
Definition: xran_common.c:595
uint8_t m_occassionsInPrachSlot
uint8_t m_sectionType
struct xran_prach_config * m_pPRACHConfig
int prach_last_symbol[XRAN_MAX_SECTOR_NR]
Definition: xran_common.h:263
#define XRAN_STATUS_SUCCESS
Definition: xran_fh_o_du.h:54
int32_t xran_open(void *pHandle, struct xran_fh_config *pConf)
Definition: xran_main.c:2756
int32_t nPrachFreqOffset
Definition: xran_fh_o_du.h:442
uint8_t m_SlotNrNum
static unsigned get_number_of_cases(const std::string &type)
Definition: common.hpp:190
uint8_t y[XRAN_PRACH_CANDIDATE_Y]
Definition: xran_common.h:137
struct xran_ru_config * m_pRUConfig
uint16_t m_startPrbc
uint8_t m_isPRACHslot[XRAN_PRACH_CANDIDATE_SLOT]
#define XRAN_MAX_SECTOR_NR
Definition: xran_fh_o_du.h:110
struct xran_section_info info
Definition: xran_cp_api.h:296
struct xran_recv_packet_info m_pktInfo
uint16_t nPrachFreqStart
Definition: xran_fh_o_du.h:441
TEST_P(PrachCheck, PacketGen)
int prach_start_symbol[XRAN_MAX_SECTOR_NR]
Definition: xran_common.h:262
uint8_t nFrameDuplexType
Definition: xran_fh_o_du.h:460
uint8_t m_subframeId
uint16_t m_beamId
const std::string module_name
uint8_t m_filterIdx
struct xran_fh_config fh_cfg
Definition: xran_common.h:209
uint8_t m_symStart
uint16_t * m_prbStart
uint8_t m_filterIndex
void SetUp() override
uint8_t occassionsInPrachSlot
Definition: xran_common.h:135
int xran_init_prach(struct xran_fh_config *pConf, struct xran_device_ctx *p_xran_dev_ctx)
Definition: xran_main.c:308
This file has all definitions for the Ethernet Data Interface Layer.
INSTANTIATE_TEST_CASE_P(UnitTest, PrachCheck, testing::ValuesIn(get_sequence(PrachCheck::get_number_of_cases("prach_functional"))))
int32_t m_freqOffset
uint32_t log_level
Definition: xran_fh_o_du.h:523
#define XRAN_PRACH_CANDIDATE_SLOT
Definition: xran_common.h:80
uint8_t m_y[XRAN_PRACH_CANDIDATE_Y]
uint8_t compMeth
Definition: xran_fh_o_du.h:487
uint16_t startPrbc
Definition: xran_cp_api.h:193
uint16_t * m_prbNum
struct xran_frame_config frame_conf
Definition: xran_fh_o_du.h:517
uint8_t m_compMethod
uint8_t m_numPrbc
uint8_t m_startSymId
void init_test(const std::string &type)
Defines section in the conf.json that is used to load parameters from.
Definition: common.hpp:358
struct xran_fh_config * m_xranConf
struct rte_mempool * _eth_mbuf_pool
Definition: ethernet.c:70
struct xran_cp_header_params hdr
Definition: xran_cp_api.h:320
struct xran_prach_config prach_conf
Definition: xran_fh_o_du.h:515
uint16_t m_m_params_timeOffset
#define XRAN_PRACH_CANDIDATE_Y
Definition: xran_common.h:79
uint8_t m_nrofPrachInSlot
uint16_t m_timeOffset
uint16_t m_sectionId
XRAN layer common functionality for both lls-CU and RU as well as C-plane and U-plane.
struct xran_ru_config ru_conf
Definition: xran_fh_o_du.h:518
struct xran_section_gen_info * m_pSectGenInfo
uint16_t m_reMask
uint8_t m_fftSize
void TearDown() override
uint8_t m_slotId
std::string m_dirStr
uint8_t m_iqWidth
uint8_t isPRACHslot[XRAN_PRACH_CANDIDATE_SLOT]
Definition: xran_common.h:138
This file provides public interface to xRAN Front Haul layer implementation as defined in the ORAN-WG...
int m_prach_start_symbol
struct xran_prach_cp_config PrachCPConfig
Definition: xran_common.h:210
struct xran_section_gen_info * sections
Definition: xran_cp_api.h:322
uint16_t numSections
Definition: xran_cp_api.h:318
struct rte_mbuf * m_pTestBuffer
struct xran_device_ctx m_xran_dev_ctx
struct xran_prach_cp_config * m_pPrachCPConfig
uint8_t m_frameId
uint8_t m_numSymbol
struct xran_cp_gen_params m_params
uint8_t m_symNum
std::vector< unsigned > get_sequence(const unsigned number)
For a given number return sequence of number from 0 to number - 1.
Definition: common.cpp:78
This file provides the definitions for Control Plane Messages APIs.
struct xran_cp_gen_params m_result
uint8_t nPrachSubcSpacing
Definition: xran_fh_o_du.h:433
This file provides the definitions for Transport layer (eCPRI) API.