o-du/phy
Intel O-RAN/X-RAN Generated Doxygen Documentation
u_plane_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_up_api.h"
23 #include "xran_fh_o_du.h"
24 #include "ethernet.h"
25 
26 #include <stdint.h>
27 
28 const std::string module_name = "u-plane";
29 
30 class U_planeCheck : public KernelTests
31 {
32 protected:
33  struct rte_mbuf *test_buffer;
34  char * iq_offset;
35  struct rte_mempool *test_eth_mbuf_pool;
36 
37  void SetUp() override
38  {
39  init_test("u_plane_functional");
40  test_buffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
41 
42  if(test_buffer == NULL) {
43  std::cout << __func__ << ":" << __LINE__ << " Failed to allocatte a packet buffer!" << std::endl;
44  return;
45  }
46  iq_offset = rte_pktmbuf_mtod(test_buffer, char * );
47  iq_offset = iq_offset + sizeof(struct ether_hdr) +
48  sizeof (struct xran_ecpri_hdr) +
49  sizeof (struct radio_app_common_hdr) +
50  sizeof(struct data_section_hdr);
51  }
52 
53  /* It's called after an execution of the each test case.*/
54  void TearDown() override
55  {
56  rte_pktmbuf_free(test_buffer);
57  }
58 };
59 
60 /* simple test of DL and UL functionality */
61 TEST_P(U_planeCheck, Test_DLUL)
62 {
63  enum xran_pkt_dir direction = XRAN_DIR_DL;
64  uint16_t section_id = 7;
65  enum xran_input_byte_order iq_buf_byte_order = XRAN_CPU_LE_BYTE_ORDER;
66  uint8_t frame_id = 99;
67  uint8_t subframe_id = 9;
68  uint8_t slot_id = 10;
69  uint8_t symbol_no = 7;
70  int prb_start = 0;
71  int prb_num = 66;
72  uint8_t CC_ID = 0;
73  uint8_t RU_Port_ID = 0;
74  uint8_t seq_id =0;
75  uint32_t do_copy = 0;
76  uint8_t compMeth = 0;
77  uint8_t iqWidth = 16;
78 
79  int32_t prep_bytes;
80  struct xran_ecpri_hdr *ecpri_hdr = NULL;
81  struct radio_app_common_hdr *app_hdr = NULL;
82  struct data_section_hdr *section_hdr = NULL;
83 
84  char *pChar = NULL;
85  uint16_t payl_size = 0;
86  struct data_section_hdr res_sect;
87 
88  prep_bytes = prepare_symbol_ex(direction,
89  section_id,
91  (struct rb_map *)iq_offset,
92  compMeth,
93  iqWidth,
94  iq_buf_byte_order,
95  frame_id,
96  subframe_id,
97  slot_id,
98  symbol_no,
99  prb_start,
100  prb_num,
101  CC_ID,
102  RU_Port_ID,
103  seq_id,
104  do_copy);
105 
106  ASSERT_EQ(prep_bytes, 3168);
107 
108  pChar = rte_pktmbuf_mtod(test_buffer, char*);
109 
110  ecpri_hdr = (struct xran_ecpri_hdr *)(pChar + sizeof(struct ether_hdr));
111  app_hdr = (struct radio_app_common_hdr *)(pChar + sizeof(struct ether_hdr)
112  + sizeof (struct xran_ecpri_hdr));
113  section_hdr = (struct data_section_hdr *)(pChar + sizeof(struct ether_hdr) +
114  sizeof (struct xran_ecpri_hdr) +
115  sizeof(struct radio_app_common_hdr));
116 
117  ASSERT_EQ (ecpri_hdr->cmnhdr.ecpri_mesg_type, ECPRI_IQ_DATA);
118  payl_size = rte_be_to_cpu_16(ecpri_hdr->cmnhdr.ecpri_payl_size);
119  ASSERT_EQ (payl_size, 3180);
120 
121  ASSERT_EQ(app_hdr->data_direction, direction);
122  ASSERT_EQ(app_hdr->frame_id, frame_id);
123 
124  res_sect.fields.all_bits = rte_be_to_cpu_32(section_hdr->fields.all_bits);
125  ASSERT_EQ(res_sect.fields.num_prbu, prb_num);
126  ASSERT_EQ(res_sect.fields.sect_id, section_id);
127 
128  {
129  /* UL direction */
130  void *iq_samp_buf;
131  struct ecpri_seq_id seq;
132  int num_bytes = 0;
133 
134  uint8_t CC_ID = 0;
135  uint8_t Ant_ID = 0;
136  uint8_t frame_id = 0;
137  uint8_t subframe_id = 0;
138  uint8_t slot_id = 0;
139  uint8_t symb_id = 0;
140 
141  uint8_t compMeth = 0;
142  uint8_t iqWidth = 0;
143 
144 
145  uint16_t num_prbu;
146  uint16_t start_prbu;
147  uint16_t sym_inc;
148  uint16_t rb;
149  uint16_t sect_id;
150 
151  int32_t prep_bytes;
152 
153  char *pChar = NULL;
154 
155 
157  &iq_samp_buf,
158  &CC_ID,
159  &Ant_ID,
160  &frame_id,
161  &subframe_id,
162  &slot_id,
163  &symb_id,
164  &seq,
165  &num_prbu,
166  &start_prbu,
167  &sym_inc,
168  &rb,
169  &sect_id,
170  0,
171  &compMeth,
172  &iqWidth);
173 
174  ASSERT_EQ(num_bytes, 3182);
175  ASSERT_EQ(prb_num, 66);
176  ASSERT_EQ(CC_ID, 0);
177  }
178 }
179 
181  testing::ValuesIn(get_sequence(U_planeCheck::get_number_of_cases("u_plane_functional"))));
182 
183 
uint8_t data_direction
Definition: xran_pkt.h:173
void TearDown() override
TEST_P(U_planeCheck, Test_DLUL)
xran_pkt_dir
Definition: xran_pkt.h:146
uint32_t rb
Definition: xran_pkt_cp.h:243
static unsigned get_number_of_cases(const std::string &type)
Definition: common.hpp:190
void SetUp() override
int32_t prepare_symbol_ex(enum xran_pkt_dir direction, uint16_t section_id, struct rte_mbuf *mb, struct rb_map *data, uint8_t compMeth, uint8_t iqWidth, const enum xran_input_byte_order iq_buf_byte_order, uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id, uint8_t symbol_no, int prb_start, int prb_num, uint8_t CC_ID, uint8_t RU_Port_ID, uint8_t seq_id, uint32_t do_copy)
Definition: xran_common.c:348
uint32_t num_prbu
Definition: xran_pkt_up.h:71
This file has all definitions for the Ethernet Data Interface Layer.
xran_input_byte_order
Definition: xran_fh_o_du.h:471
void init_test(const std::string &type)
Defines section in the conf.json that is used to load parameters from.
Definition: common.hpp:358
uint32_t all_bits
Definition: xran_pkt_up.h:69
struct rte_mempool * _eth_mbuf_pool
Definition: ethernet.c:70
const std::string module_name
struct rte_mbuf * test_buffer
struct xran_ecpri_cmn_hdr cmnhdr
Definition: xran_pkt.h:132
This file provides the definitions for User Plane Messages APIs.
XRAN layer common functionality for both lls-CU and RU as well as C-plane and U-plane.
This file provides public interface to xRAN Front Haul layer implementation as defined in the ORAN-WG...
struct rte_mempool * test_eth_mbuf_pool
uint32_t sect_id
Definition: xran_pkt_up.h:75
INSTANTIATE_TEST_CASE_P(UnitTest, U_planeCheck, testing::ValuesIn(get_sequence(U_planeCheck::get_number_of_cases("u_plane_functional"))))
uint8_t ecpri_mesg_type
Definition: xran_pkt.h:118
int32_t xran_extract_iq_samples(struct rte_mbuf *mbuf, void **iq_data_start, uint8_t *CC_ID, uint8_t *Ant_ID, uint8_t *frame_id, uint8_t *subframe_id, uint8_t *slot_id, uint8_t *symb_id, struct ecpri_seq_id *seq_id, uint16_t *num_prbu, uint16_t *start_prbu, uint16_t *sym_inc, uint16_t *rb, uint16_t *sect_id, int8_t expect_comp, uint8_t *compMeth, uint8_t *iqWidth)
Function extracts IQ samples from received mbuf packet.
Definition: xran_up_api.c:327
union data_section_hdr::@18 fields
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
uint16_t ecpri_payl_size
Definition: xran_pkt.h:119