8319306727d5dafe7f226ee070722f5408cd76f5
[o-du/phy.git] / fhi_lib / test / test_xran / c_plane_tests.cc
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_lib_wrap.hpp"
22 #include "xran_common.h"
23 #include "xran_fh_o_du.h"
24 #include "ethdi.h"
25 #include "ethernet.h"
26 #include "xran_transport.h"
27 #include "xran_cp_api.h"
28
29 #include <stdint.h>
30
31
32 const std::string module_name = "C-Plane";
33
34 const uint8_t m_bitmask[] = { 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
35
36 extern "C"
37 {
38
39 /* wrapper function for performace tests to reset mbuf */
40 int xran_ut_prepare_cp(struct rte_mbuf *mbuf, struct xran_cp_gen_params *params,
41                         uint8_t cc_id, uint8_t ant_id, uint8_t seq_id)
42 {
43     rte_pktmbuf_reset(mbuf);
44     return(xran_prepare_ctrl_pkt(mbuf, params, cc_id, ant_id, seq_id));
45 }
46
47
48 void cput_fh_rx_callback(void *pCallbackTag, xran_status_t status)
49 {
50     return;
51 }
52
53 void cput_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status)
54 {
55     rte_pause();
56 }
57
58 } /* extern "C" */
59
60
61
62 class C_plane: public KernelTests
63 {
64 private:
65     struct xran_section_gen_info *m_pSectGenInfo = NULL;
66     struct xran_section_gen_info *m_pSectResult = NULL;
67
68
69 protected:
70     int m_maxSections = 8;  /*  not used */
71     int m_numSections;
72
73     struct rte_mbuf *m_pTestBuffer;
74
75     struct xran_cp_gen_params m_params;
76     struct xran_recv_packet_info m_pktInfo;
77     struct xran_cp_gen_params m_result;
78
79     uint8_t     m_dir;
80     std::string m_dirStr;
81     uint8_t     m_sectionType;
82
83     uint8_t     m_ccId, m_antId;
84     uint8_t     m_seqId;
85     uint8_t     m_frameId, m_subframeId, m_slotId;
86     uint8_t     m_symStart, m_symNum;
87     uint16_t    *m_prbStart = NULL, *m_prbNum = NULL;
88
89     uint8_t     m_iqWidth, m_compMethod;
90     uint16_t    m_beamId;
91     uint16_t    m_reMask = 0xfff;
92     uint16_t    m_sectionId;
93     uint8_t     m_filterIndex;
94     uint16_t    m_timeOffset;
95     uint8_t     m_fftSize;
96     uint8_t     m_scs;
97     uint16_t    m_cpLength;
98     int         m_freqOffset;
99
100     uint16_t  m_ext1_dst_len = 0;
101     int8_t   *m_p_ext1_dst   = NULL;
102     int16_t  *m_p_bfw_iq_src = NULL;
103
104     struct xran_sectionext1_info m_ext1;
105     struct xran_sectionext2_info m_ext2;
106     struct xran_sectionext4_info m_ext4;
107     struct xran_sectionext5_info m_ext5;
108
109     int16_t m_bfwIQ[XRAN_MAX_BFW_N*2];
110
111
112     void SetUp() override
113     {
114         int i, j;
115
116         init_test("C_Plane");
117
118         m_numSections   = get_input_parameter<int>("num_sections");
119         ASSERT_FALSE(m_numSections == 0);
120
121         m_dirStr        = get_input_parameter<std::string>("direction");
122
123         if(!m_dirStr.compare("DL")) m_dir = XRAN_DIR_DL;
124         else if(!m_dirStr.compare("UL")) m_dir = XRAN_DIR_UL;
125         else FAIL() << "Invalid direction!";
126
127         m_sectionType   = get_input_parameter<uint8_t>("section_type");
128         m_ccId          = get_input_parameter<uint8_t>("cc_id");
129         m_antId         = get_input_parameter<uint8_t>("ant_id");
130         m_seqId         = get_input_parameter<uint16_t>("seq_id");
131
132         m_frameId       = get_input_parameter<uint8_t>("frame_id");
133         m_subframeId    = get_input_parameter<uint8_t>("subframe_id");
134         m_slotId        = get_input_parameter<uint8_t>("slot_id");
135         m_symStart      = get_input_parameter<uint8_t>("symbol_start");
136         m_compMethod    = get_input_parameter<uint8_t>("comp_method");
137         m_iqWidth       = get_input_parameter<uint8_t>("iq_width");
138
139         m_sectionId     = get_input_parameter<uint8_t>("section_id");
140         m_symNum        = get_input_parameter<uint8_t>("symbol_num");
141         m_beamId        = get_input_parameter<uint16_t>("beam_id");
142
143         /* reading configurations of start prb and the number of prbs  */
144         std::vector<int> prbstart = get_input_parameter<std::vector<int>>("prb_start");
145         std::vector<int> prbnum = get_input_parameter<std::vector<int>>("prb_num");
146         /* number of sections and  the pair of start/number of prb shall be matched */
147         ASSERT_TRUE((m_numSections == prbstart.size())
148                     && (m_numSections == prbnum.size())
149                     && (prbstart.size() == prbnum.size()));
150
151         m_prbStart  = new uint16_t [m_numSections];
152         m_prbNum    = new uint16_t [m_numSections];
153         for(i=0; i < m_numSections; i++) {
154             m_prbStart[i] = prbstart[i];
155             m_prbNum[i] = prbnum[i];
156             }
157
158         switch(m_sectionType) {
159             case XRAN_CP_SECTIONTYPE_1:
160                 m_filterIndex = XRAN_FILTERINDEX_STANDARD;
161                 break;
162
163             case XRAN_CP_SECTIONTYPE_3:
164                 m_filterIndex   = get_input_parameter<uint8_t>("filter_index");
165                 m_timeOffset    = get_input_parameter<uint16_t>("time_offset");
166                 m_fftSize       = get_input_parameter<uint8_t>("fft_size");
167                 m_scs           = get_input_parameter<uint8_t>("scs");
168                 m_cpLength      = get_input_parameter<uint16_t>("cp_length");
169                 m_freqOffset    = get_input_parameter<int>("freq_offset");
170                 break;
171
172             default:
173                 FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
174             }
175
176         /* allocate and prepare required data storage */
177         m_pSectGenInfo = new struct xran_section_gen_info [m_numSections];
178         ASSERT_NE(m_pSectGenInfo, nullptr);
179         m_params.sections = m_pSectGenInfo;
180
181         m_pSectResult = new struct xran_section_gen_info [m_numSections];
182         ASSERT_NE(m_pSectResult, nullptr);
183         m_result.sections = m_pSectResult;
184
185         m_ext1_dst_len   = 9600;
186         m_p_ext1_dst   = new int8_t [m_ext1_dst_len];
187         m_p_bfw_iq_src = new int16_t [9600/2];
188
189         /* allocating an mbuf for packet generatrion */
190         m_pTestBuffer = xran_ethdi_mbuf_alloc();
191
192         ASSERT_FALSE(m_pTestBuffer == NULL);
193     }
194
195     void TearDown() override
196     {
197         int i, j;
198
199         if(m_pTestBuffer != NULL)
200             rte_pktmbuf_free(m_pTestBuffer);
201
202         if(m_prbStart)
203             delete[] m_prbStart;
204         if(m_prbNum)
205             delete[] m_prbNum;
206
207         if(m_p_bfw_iq_src)
208             delete[] m_p_bfw_iq_src;
209
210         if(m_p_ext1_dst)
211             delete[] m_p_ext1_dst;
212
213         if(m_pSectGenInfo)
214             delete[] m_pSectGenInfo;
215
216         if(m_pSectResult) {
217             delete[] m_pSectResult;
218             }
219
220     }
221
222     int prepare_sections(bool extflag);
223     int prepare_extensions(int sect_num);
224     void verify_sections(void);
225
226 };
227
228
229
230 int C_plane::prepare_extensions(int sect_num)
231 {
232     int i, numext;
233     int N;
234
235
236     N = 8;
237
238     // extension 1
239     m_ext1.bfwNumber  = 4*N; // 4 ant, 8 UEs
240     m_ext1.bfwiqWidth = 16;
241     m_ext1.bfwCompMeth    = XRAN_BFWCOMPMETHOD_NONE;
242                             /* XRAN_BFWCOMPMETHOD_BLKFLOAT
243                              * XRAN_BFWCOMPMETHOD_BLKSCALE
244                              * XRAN_BFWCOMPMETHOD_ULAW
245                              * XRAN_BFWCOMPMETHOD_BEAMSPACE
246                              */
247     m_ext1.p_bfwIQ = m_bfwIQ;
248
249     switch (m_ext1.bfwCompMeth) {
250         case XRAN_BFWCOMPMETHOD_BLKFLOAT:
251             m_ext1.bfwCompParam.exponent = 0xa;
252             break;
253         case XRAN_BFWCOMPMETHOD_BLKSCALE:
254             m_ext1.bfwCompParam.blockScaler = 0xa5;
255             break;
256         case XRAN_BFWCOMPMETHOD_ULAW:
257             m_ext1.bfwCompParam.compBitWidthShift = 0x55;
258         case XRAN_BFWCOMPMETHOD_BEAMSPACE:
259             for(i=0; i<N; i++)
260                 m_ext1.bfwCompParam.activeBeamspaceCoeffMask[i] = 0xa0 + i;
261             break;
262         }
263
264     for(i=0; i<N*4; i++) {
265         m_ext1.p_bfwIQ[i*2]     = 0xcafe;
266         m_ext1.p_bfwIQ[i*2+1]   = 0xbeef;
267         }
268
269     // extension 2
270     m_ext2.bfAzPtWidth        = 7;
271     m_ext2.bfAzPt             = 0x55 & m_bitmask[m_ext2.bfAzPtWidth];
272     m_ext2.bfZePtWidth        = 7;
273     m_ext2.bfZePt             = 0xaa & m_bitmask[m_ext2.bfAzPtWidth];
274     m_ext2.bfAz3ddWidth       = 7;
275     m_ext2.bfAz3dd            = 0x5a & m_bitmask[m_ext2.bfAzPtWidth];
276     m_ext2.bfZe3ddWidth       = 7;
277     m_ext2.bfZe3dd            = 0xa5 & m_bitmask[m_ext2.bfAzPtWidth];
278     m_ext2.bfAzSI             = 0x2 & m_bitmask[3];
279     m_ext2.bfZeSI             = 0x5 & m_bitmask[3];
280
281     // extension 4
282     m_ext4.csf                = 1;
283     m_ext4.modCompScaler      = 0x5aa5;
284
285     // extension 5
286     m_ext5.num_sets = 2;
287     for(i=0; i<m_ext5.num_sets; i++) {
288         m_ext5.mc[i].csf              = i%2;
289         m_ext5.mc[i].mcScaleReMask    = 0xa5a + i;
290         m_ext5.mc[i].mcScaleOffset    = 0x5a5a + i;
291         }
292
293     numext = 0;
294
295     m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_1;
296     m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext1);
297     m_params.sections[sect_num].exData[numext].data = &m_ext1;
298     numext++;
299
300     m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_2;
301     m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext2);
302     m_params.sections[sect_num].exData[numext].data = &m_ext2;
303     numext++;
304
305     m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_4;
306     m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext4);
307     m_params.sections[sect_num].exData[numext].data = &m_ext4;
308     numext++;
309
310     m_params.sections[sect_num].exData[numext].type = XRAN_CP_SECTIONEXTCMD_5;
311     m_params.sections[sect_num].exData[numext].len  = sizeof(m_ext5);
312     m_params.sections[sect_num].exData[numext].data = &m_ext5;
313     numext++;
314
315     m_params.sections[sect_num].exDataSize = numext;
316
317     return (0);
318 }
319
320 int C_plane::prepare_sections(bool extflag)
321 {
322   int numsec;
323
324
325     /* Preparing input data for packet generation */
326     m_params.dir                  = m_dir;
327     m_params.sectionType          = m_sectionType;
328
329     m_params.hdr.filterIdx        = m_filterIndex;
330     m_params.hdr.frameId          = m_frameId;
331     m_params.hdr.subframeId       = m_subframeId;
332     m_params.hdr.slotId           = m_slotId;
333     m_params.hdr.startSymId       = m_symStart;
334     m_params.hdr.iqWidth          = XRAN_CONVERT_IQWIDTH(m_iqWidth);
335     m_params.hdr.compMeth         = m_compMethod;
336
337     switch(m_sectionType) {
338         case XRAN_CP_SECTIONTYPE_1:
339             break;
340
341         case XRAN_CP_SECTIONTYPE_3:
342             m_params.hdr.timeOffset   = m_timeOffset;
343             m_params.hdr.fftSize      = m_fftSize;
344             m_params.hdr.scs          = m_scs;
345             m_params.hdr.cpLength     = m_cpLength;
346             break;
347
348         default:
349             return (-1);
350         }
351
352     for(numsec=0; numsec < m_numSections; numsec++) {
353         m_params.sections[numsec].info.type         = m_params.sectionType;       // for database
354         m_params.sections[numsec].info.startSymId   = m_params.hdr.startSymId;    // for database
355         m_params.sections[numsec].info.iqWidth      = m_params.hdr.iqWidth;       // for database
356         m_params.sections[numsec].info.compMeth     = m_params.hdr.compMeth;      // for database
357         m_params.sections[numsec].info.id           = m_sectionId++;
358         m_params.sections[numsec].info.rb           = XRAN_RBIND_EVERY;
359         m_params.sections[numsec].info.symInc       = XRAN_SYMBOLNUMBER_NOTINC;
360         m_params.sections[numsec].info.startPrbc    = m_prbStart[numsec];
361         m_params.sections[numsec].info.numPrbc      = m_prbNum[numsec];
362         m_params.sections[numsec].info.numSymbol    = m_symNum;
363         m_params.sections[numsec].info.reMask       = m_reMask;
364         m_params.sections[numsec].info.beamId       = m_beamId;
365         switch(m_sectionType) {
366             case XRAN_CP_SECTIONTYPE_1:
367                 break;
368
369             case XRAN_CP_SECTIONTYPE_3:
370                 m_params.sections[numsec].info.freqOffset   = m_freqOffset;
371                 break;
372
373             default:
374                 return (-1);
375             }
376
377         /* section extension */
378         if(/*extflag == true*/0) {
379             m_params.sections[numsec].info.ef       = 1;
380             prepare_extensions(numsec);
381             }
382         else {
383             m_params.sections[numsec].info.ef       = 0;
384             m_params.sections[numsec].exDataSize    = 0;
385             }
386         }
387
388     m_params.numSections        = numsec;
389
390     return (0);
391 }
392
393
394 void C_plane::verify_sections(void)
395 {
396   int i,j;
397
398     /* Verify the result */
399     EXPECT_TRUE(m_result.dir            == m_params.dir);
400     EXPECT_TRUE(m_result.sectionType    == m_params.sectionType);
401
402     EXPECT_TRUE(m_result.hdr.filterIdx  == m_params.hdr.filterIdx);
403     EXPECT_TRUE(m_result.hdr.frameId    == m_params.hdr.frameId);
404     EXPECT_TRUE(m_result.hdr.subframeId == m_params.hdr.subframeId);
405     EXPECT_TRUE(m_result.hdr.slotId     == m_params.hdr.slotId);
406     EXPECT_TRUE(m_result.hdr.startSymId == m_params.hdr.startSymId);
407     EXPECT_TRUE(m_result.hdr.iqWidth    == m_params.hdr.iqWidth);
408     EXPECT_TRUE(m_result.hdr.compMeth   == m_params.hdr.compMeth);
409
410     switch(m_sectionType) {
411         case XRAN_CP_SECTIONTYPE_1:
412             break;
413
414         case XRAN_CP_SECTIONTYPE_3:
415             EXPECT_TRUE(m_result.hdr.fftSize    == m_params.hdr.fftSize);
416             EXPECT_TRUE(m_result.hdr.scs        == m_params.hdr.scs);
417             EXPECT_TRUE(m_result.hdr.cpLength   == m_params.hdr.cpLength);
418             break;
419
420         default:
421             FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
422         }
423
424     ASSERT_TRUE(m_result.numSections    == m_params.numSections);
425     for(i=0; i < m_result.numSections; i++) {
426         EXPECT_TRUE(m_result.sections[i].info.id        == m_params.sections[i].info.id);
427         EXPECT_TRUE(m_result.sections[i].info.rb        == XRAN_RBIND_EVERY);
428         EXPECT_TRUE(m_result.sections[i].info.symInc    == XRAN_SYMBOLNUMBER_NOTINC);
429         EXPECT_TRUE(m_result.sections[i].info.startPrbc == m_params.sections[i].info.startPrbc);
430         EXPECT_TRUE(m_result.sections[i].info.numPrbc   == m_params.sections[i].info.numPrbc);
431         EXPECT_TRUE(m_result.sections[i].info.numSymbol == m_params.sections[i].info.numSymbol);
432         EXPECT_TRUE(m_result.sections[i].info.reMask    == m_params.sections[i].info.reMask);
433         EXPECT_TRUE(m_result.sections[i].info.beamId    == m_params.sections[i].info.beamId);
434         EXPECT_TRUE(m_result.sections[i].info.ef        == m_params.sections[i].info.ef);
435
436         switch(m_sectionType) {
437             case XRAN_CP_SECTIONTYPE_1:
438                 break;
439
440             case XRAN_CP_SECTIONTYPE_3:
441                 EXPECT_TRUE(m_result.sections[i].info.freqOffset  == m_params.sections[i].info.freqOffset);
442                 break;
443
444             default:
445                 FAIL() << "Invalid Section Type - " << m_sectionType << "\n";
446             }
447
448         if(m_params.sections[i].info.ef) {
449      //       printf("[%d] %d ==  %d\n",i,  m_result.sections[i].exDataSize, m_params.sections[i].exDataSize);
450             EXPECT_TRUE(m_result.sections[i].exDataSize == m_params.sections[i].exDataSize);
451
452             for(j=0; j < m_params.sections[i].exDataSize; j++) {
453                 EXPECT_TRUE(m_result.sections[i].exData[j].type == m_params.sections[i].exData[j].type);
454
455                 switch(m_params.sections[i].exData[j].type) {
456                     case XRAN_CP_SECTIONEXTCMD_1:
457                         {
458                         struct xran_sectionext1_info *ext1_params, *ext1_result;
459                         int iq_size, parm_size, N;
460
461                         ext1_params = (struct xran_sectionext1_info *)m_params.sections[i].exData[j].data;
462                         ext1_result = (struct xran_sectionext1_info *)m_result.sections[i].exData[j].data;
463
464                         EXPECT_TRUE(ext1_result->bfwiqWidth == ext1_params->bfwiqWidth);
465                         EXPECT_TRUE(ext1_result->bfwCompMeth    == ext1_params->bfwCompMeth);
466
467                         N = ext1_params->bfwNumber;
468                         switch(ext1_params->bfwCompMeth) {
469                             case XRAN_BFWCOMPMETHOD_BLKFLOAT:
470                                 EXPECT_TRUE(ext1_result->bfwCompParam.exponent == ext1_params->bfwCompParam.exponent);
471                                 break;
472
473                             case XRAN_BFWCOMPMETHOD_BLKSCALE:
474                                 EXPECT_TRUE(ext1_result->bfwCompParam.blockScaler == ext1_params->bfwCompParam.blockScaler);
475                                 break;
476
477                             case XRAN_BFWCOMPMETHOD_ULAW:
478                                 EXPECT_TRUE(ext1_result->bfwCompParam.compBitWidthShift == ext1_params->bfwCompParam.compBitWidthShift);
479                                 break;
480
481                             case XRAN_BFWCOMPMETHOD_BEAMSPACE:
482                                 parm_size = N>>3; if(N%8) parm_size++; parm_size *= 8;
483                                 EXPECT_TRUE(std::memcmp(ext1_result->bfwCompParam.activeBeamspaceCoeffMask, ext1_params->bfwCompParam.activeBeamspaceCoeffMask, parm_size));
484                                 break;
485                             }
486
487                         /* Get the number of BF weights */
488                         iq_size = N*ext1_params->bfwiqWidth*2;  // total in bits
489                         parm_size = iq_size>>3;                 // total in bytes (/8)
490                         if(iq_size%8) parm_size++;              // round up
491                         EXPECT_TRUE(std::memcmp(ext1_result->p_bfwIQ, ext1_params->p_bfwIQ, parm_size));
492
493                         }
494                         break;
495
496                     case XRAN_CP_SECTIONEXTCMD_2:
497                         {
498                         struct xran_sectionext2_info *ext2_params, *ext2_result;
499
500                         ext2_params = (struct xran_sectionext2_info *)m_params.sections[i].exData[j].data;
501                         ext2_result = (struct xran_sectionext2_info *)m_result.sections[i].exData[j].data;
502
503                         if(ext2_params->bfAzPtWidth) {
504                             EXPECT_TRUE(ext2_result->bfAzPtWidth    == ext2_params->bfAzPtWidth);
505                             EXPECT_TRUE(ext2_result->bfAzPt         == ext2_params->bfAzPt);
506                             }
507
508                         if(ext2_params->bfZePtWidth) {
509                             EXPECT_TRUE(ext2_result->bfZePtWidth    == ext2_params->bfZePtWidth);
510                             EXPECT_TRUE(ext2_result->bfZePt         == ext2_params->bfZePt);
511                             }
512                         if(ext2_params->bfAz3ddWidth) {
513                             EXPECT_TRUE(ext2_result->bfAz3ddWidth   == ext2_params->bfAz3ddWidth);
514                             EXPECT_TRUE(ext2_result->bfAz3dd        == ext2_params->bfAz3dd);
515                             }
516                         if(ext2_params->bfZe3ddWidth) {
517                             EXPECT_TRUE(ext2_result->bfZe3ddWidth   == ext2_params->bfZe3ddWidth);
518                             EXPECT_TRUE(ext2_result->bfZe3dd        == ext2_params->bfZe3dd);
519                             }
520
521                         EXPECT_TRUE(ext2_result->bfAzSI == ext2_params->bfAzSI);
522                         EXPECT_TRUE(ext2_result->bfZeSI == ext2_params->bfZeSI);
523                         }
524                         break;
525
526                     case XRAN_CP_SECTIONEXTCMD_4:
527                         {
528                         struct xran_sectionext4_info *ext4_params, *ext4_result;
529
530                         ext4_params = (struct xran_sectionext4_info *)m_params.sections[i].exData[j].data;
531                         ext4_result = (struct xran_sectionext4_info *)m_result.sections[i].exData[j].data;
532
533                         EXPECT_TRUE(ext4_result->csf            == ext4_params->csf);
534                         EXPECT_TRUE(ext4_result->modCompScaler  == ext4_params->modCompScaler);
535                         }
536                         break;
537                     case XRAN_CP_SECTIONEXTCMD_5:
538                         {
539                         struct xran_sectionext5_info *ext5_params, *ext5_result;
540                         int idx;
541
542                         ext5_params = (struct xran_sectionext5_info *)m_params.sections[i].exData[j].data;
543                         ext5_result = (struct xran_sectionext5_info *)m_result.sections[i].exData[j].data;
544
545                         EXPECT_TRUE(ext5_result->num_sets == ext5_params->num_sets);
546                         for(idx=0; idx < ext5_params->num_sets; idx++) {
547                             EXPECT_TRUE(ext5_result->mc[idx].csf == ext5_params->mc[idx].csf);
548                             EXPECT_TRUE(ext5_result->mc[idx].mcScaleReMask == ext5_params->mc[idx].mcScaleReMask);
549                             EXPECT_TRUE(ext5_result->mc[idx].mcScaleOffset == ext5_params->mc[idx].mcScaleOffset);
550                             }
551                         }
552                         break;
553                     }
554                 }
555             }
556         }
557
558     return;
559 }
560
561
562 /***************************************************************************
563  * Functional Test cases
564  ***************************************************************************/
565
566 TEST_P(C_plane, Section_Ext1)
567 {
568     int i = 0, idRb;
569     int32_t len = 0;
570     int16_t *ptr = NULL;
571     int32_t nRbs = 36;
572     int32_t nAntElm = 32;
573     int8_t  iqWidth = 16;
574     int8_t  compMethod = XRAN_COMPMETHOD_NONE;
575     int8_t  *p_ext1_dst  = NULL;
576     int16_t *bfw_payload = NULL;
577     int32_t expected_len = (3+1)*nRbs + nAntElm*nRbs*4;
578
579     struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;
580     struct xran_sectionext1_info m_ext1;
581     struct xran_cp_radioapp_section_ext1 *p_ext1;
582
583     /* Configure section information */
584     if(prepare_sections(false) < 0) {
585         FAIL() << "Invalid Section configuration\n";
586     }
587     ptr = m_p_bfw_iq_src;
588
589     for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){
590         ptr[idRb] = i;
591         i++;
592     }
593
594     len = xran_cp_populate_section_ext_1(m_p_ext1_dst,
595                                          m_ext1_dst_len,
596                                          m_p_bfw_iq_src,
597                                          nRbs,
598                                          nAntElm,
599                                          iqWidth,
600                                          compMethod);
601
602     ASSERT_TRUE(len == expected_len);
603
604     p_ext1_dst = m_p_ext1_dst;
605     idRb = 0;
606     do {
607         p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;
608         bfw_payload = (int16_t*)(p_ext1+1);
609         p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;
610         idRb++;
611     }while(p_ext1->ef != XRAN_EF_F_LAST);
612
613     ASSERT_TRUE(idRb == nRbs);
614
615     /* Update section information */
616     memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));
617     m_ext1.bfwNumber      = nAntElm;
618     m_ext1.bfwiqWidth     = iqWidth;
619     m_ext1.bfwCompMeth    = compMethod;
620     m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;
621     m_ext1.bfwIQ_sz       = len;
622
623     loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;
624     loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);
625     loc_pSectGenInfo->exData[0].data = &m_ext1;
626
627     loc_pSectGenInfo->info.ef       = 1;
628     loc_pSectGenInfo->exDataSize    = 1;
629
630     m_params.numSections    = 1;
631
632     /* Generating C-Plane packet */
633     ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
634
635     /* Parsing generated packet */
636     EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
637
638     /* Verify the result */
639     //verify_sections();
640 }
641
642 TEST_P(C_plane, Section_Ext1_9bit)
643 {
644     int i = 0, idRb;
645     int32_t len = 0;
646     int16_t *ptr = NULL;
647     int32_t nRbs = 36;
648     int32_t nAntElm = 32;
649     int8_t  iqWidth = 9;
650     int8_t  compMethod = XRAN_COMPMETHOD_BLKFLOAT;
651     int8_t  *p_ext1_dst  = NULL;
652     int16_t *bfw_payload = NULL;
653     int32_t expected_len = ((nAntElm/16*4*iqWidth)+1)*nRbs + /* bfwCompParam + IQ = */
654                             sizeof(struct xran_cp_radioapp_section_ext1)*nRbs; /* ext1 Headers */
655
656     struct xran_section_gen_info* loc_pSectGenInfo = m_params.sections;
657     struct xran_sectionext1_info m_ext1;
658     struct xran_cp_radioapp_section_ext1 *p_ext1;
659
660     /* Configure section information */
661     if(prepare_sections(false) < 0) {
662         FAIL() << "Invalid Section configuration\n";
663     }
664     ptr = m_p_bfw_iq_src;
665
666     for (idRb =0; idRb < nRbs*nAntElm*2; idRb++){
667         ptr[idRb] = i;
668         i++;
669     }
670
671     len = xran_cp_populate_section_ext_1(m_p_ext1_dst,
672                                          m_ext1_dst_len,
673                                          m_p_bfw_iq_src,
674                                          nRbs,
675                                          nAntElm,
676                                          iqWidth,
677                                          compMethod);
678
679     ASSERT_TRUE(len == expected_len);
680
681     p_ext1_dst = m_p_ext1_dst;
682     idRb = 0;
683     do {
684         p_ext1 = (struct xran_cp_radioapp_section_ext1 *)p_ext1_dst;
685         bfw_payload = (int16_t*)(p_ext1+1);
686         p_ext1_dst += p_ext1->extLen*XRAN_SECTIONEXT_ALIGN;
687         idRb++;
688     }while(p_ext1->ef != XRAN_EF_F_LAST);
689
690     ASSERT_TRUE(idRb == nRbs);
691
692     /* Update section information */
693     memset(&m_ext1, 0, sizeof (struct xran_sectionext1_info));
694     m_ext1.bfwNumber      = nAntElm;
695     m_ext1.bfwiqWidth     = iqWidth;
696     m_ext1.bfwCompMeth    = compMethod;
697     m_ext1.p_bfwIQ        = (int16_t*)m_p_ext1_dst;
698     m_ext1.bfwIQ_sz       = len;
699
700     loc_pSectGenInfo->exData[0].type = XRAN_CP_SECTIONEXTCMD_1;
701     loc_pSectGenInfo->exData[0].len  = sizeof(m_ext1);
702     loc_pSectGenInfo->exData[0].data = &m_ext1;
703
704     loc_pSectGenInfo->info.ef       = 1;
705     loc_pSectGenInfo->exDataSize    = 1;
706
707     m_params.numSections    = 1;
708
709     /* Generating C-Plane packet */
710     ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
711
712     /* Parsing generated packet */
713     EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
714
715     /* Verify the result */
716     //verify_sections();
717 }
718
719
720
721 TEST_P(C_plane, PacketGen)
722 {
723   int i;
724
725
726     /* Configure section information */
727     if(prepare_sections(false) < 0) {
728         FAIL() << "Invalid Section configuration\n";
729         }
730
731     /* Generating C-Plane packet */
732     ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
733
734     /* Parsing generated packet */
735     EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
736
737     /* Verify the result */
738     verify_sections();
739 }
740
741
742 TEST_P(C_plane, PacketGen_Ext)
743 {
744   int i;
745
746
747     /* Configure section information */
748     if(prepare_sections(true) < 0) {
749         FAIL() << "Invalid Section configuration\n";
750         }
751
752     /* Generating C-Plane packet */
753     ASSERT_TRUE(xran_prepare_ctrl_pkt(m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId) == XRAN_STATUS_SUCCESS);
754
755     /* Parsing generated packet */
756     EXPECT_TRUE(xran_parse_cp_pkt(m_pTestBuffer, &m_result, &m_pktInfo) == XRAN_STATUS_SUCCESS);
757
758     /* Verify the result */
759     verify_sections();
760 }
761
762
763 /***************************************************************************
764  * Performance Test cases
765  ***************************************************************************/
766 TEST_P(C_plane, Perf)
767 {
768     /* Configure section information */
769     if(prepare_sections(false) < 0) {
770         FAIL() << "Invalid Section configuration\n";
771         }
772
773     /* using wrapper function to reset mbuf */
774     performance("C", module_name,
775             &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);
776 }
777
778 TEST_P(C_plane, Perf_Ext)
779 {
780     /* Configure section information */
781     if(prepare_sections(true) < 0) {
782         FAIL() << "Invalid Section configuration\n";
783         }
784
785     /* using wrapper function to reset mbuf */
786     performance("C", module_name,
787             &xran_ut_prepare_cp, m_pTestBuffer, &m_params, m_ccId, m_antId, m_seqId);
788 }
789
790
791 INSTANTIATE_TEST_CASE_P(UnitTest, C_plane,
792         testing::ValuesIn(get_sequence(C_plane::get_number_of_cases("C_Plane"))));
793