1 /******************************************************************************
3 * Copyright (c) 2019 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 *******************************************************************************/
20 #include "xran_common.h"
21 #include "xran_up_api.h"
22 #include "xran_fh_o_du.h"
27 const std::string module_name = "u-plane";
29 class U_planeCheck : public KernelTests
32 struct rte_mbuf *test_buffer;
34 struct rte_mempool *test_eth_mbuf_pool;
38 init_test("u_plane_functional");
39 test_buffer = (struct rte_mbuf*)rte_pktmbuf_alloc(_eth_mbuf_pool);
41 if(test_buffer == NULL) {
42 std::cout << __func__ << ":" << __LINE__ << " Failed to allocatte a packet buffer!" << std::endl;
45 iq_offset = rte_pktmbuf_mtod(test_buffer, char * );
46 iq_offset = iq_offset + sizeof(struct rte_ether_hdr) +
47 sizeof (struct xran_ecpri_hdr) +
48 sizeof (struct radio_app_common_hdr) +
49 sizeof(struct data_section_hdr);
52 /* It's called after an execution of the each test case.*/
53 void TearDown() override
55 rte_pktmbuf_free(test_buffer);
59 /* simple test of DL and UL functionality */
60 TEST_P(U_planeCheck, Test_DLUL)
62 enum xran_pkt_dir direction = XRAN_DIR_DL;
63 uint16_t section_id = 7;
64 enum xran_input_byte_order iq_buf_byte_order = XRAN_CPU_LE_BYTE_ORDER;
65 uint8_t frame_id = 99;
66 uint8_t subframe_id = 9;
68 uint8_t symbol_no = 7;
72 uint8_t RU_Port_ID = 0;
79 struct xran_ecpri_hdr *ecpri_hdr = NULL;
80 struct radio_app_common_hdr *app_hdr = NULL;
81 struct data_section_hdr *section_hdr = NULL;
84 uint16_t payl_size = 0;
85 struct data_section_hdr res_sect;
87 prep_bytes = prepare_symbol_ex(direction,
90 (struct rb_map *)iq_offset,
105 ASSERT_EQ(prep_bytes, 3168);
107 pChar = rte_pktmbuf_mtod(test_buffer, char*);
109 ecpri_hdr = (struct xran_ecpri_hdr *)(pChar + sizeof(struct rte_ether_hdr));
110 app_hdr = (struct radio_app_common_hdr *)(pChar + sizeof(struct rte_ether_hdr)
111 + sizeof (struct xran_ecpri_hdr));
112 section_hdr = (struct data_section_hdr *)(pChar + sizeof(struct rte_ether_hdr) +
113 sizeof (struct xran_ecpri_hdr) +
114 sizeof(struct radio_app_common_hdr));
116 ASSERT_EQ (ecpri_hdr->cmnhdr.ecpri_mesg_type, ECPRI_IQ_DATA);
117 payl_size = rte_be_to_cpu_16(ecpri_hdr->cmnhdr.ecpri_payl_size);
118 ASSERT_EQ (payl_size, 3180);
120 ASSERT_EQ(app_hdr->data_direction, direction);
121 ASSERT_EQ(app_hdr->frame_id, frame_id);
123 res_sect.fields.all_bits = rte_be_to_cpu_32(section_hdr->fields.all_bits);
124 ASSERT_EQ(res_sect.fields.num_prbu, prb_num);
125 ASSERT_EQ(res_sect.fields.sect_id, section_id);
130 struct ecpri_seq_id seq;
135 uint8_t frame_id = 0;
136 uint8_t subframe_id = 0;
140 uint8_t compMeth = 0;
155 num_bytes = xran_extract_iq_samples(test_buffer,
173 ASSERT_EQ(num_bytes, 3182);
174 ASSERT_EQ(prb_num, 66);
179 INSTANTIATE_TEST_CASE_P(UnitTest, U_planeCheck,
180 testing::ValuesIn(get_sequence(U_planeCheck::get_number_of_cases("u_plane_functional"))));