+ }
+#if 1
+ else
+ {
+ /* Generate a C-Plane message with multi sections,
+ * a C-Plane message for each section*/
+ if(prbMap)
+ {
+ if(0 == prbMap->nPrbElm)
+ {
+ print_dbg("prbMap->nPrbElm is %d\n",prbMap->nPrbElm);
+ return 0;
+ }
+
+ nsection = prbMap->nPrbElm;
+ i=0;
+ if(XRAN_DIR_DL == dir)
+ {
+ prbElmProcInfo->numSymsRemaining = 0;
+ prbElmProcInfo->nPrbElmProcessed = 0;
+ prbElmProcInfo->nPrbElmPerSym = prbMap->nPrbElm;
+ nsection = prbMap->nPrbElm;
+ } //dir = DL
+ else
+ {
+ nsection = prbMap->nPrbElm;
+ } //dir = UL
+ }
+ else
+ {
+ print_err("prbMap is NULL\n");
+ return (-1);
+ }
+
+ pPrbMapElem = &prbMap->prbMap[0];
+
+ if(xran_fs_get_slot_type(PortId, cc_id, tti, XRAN_SLOT_TYPE_FDD) != 1
+ && xran_fs_get_slot_type(PortId, cc_id, tti, XRAN_SLOT_TYPE_SP) == 1)
+ {
+ startSym = xran_check_symbolrange(
+ ((dir==XRAN_DIR_DL)?XRAN_SYMBOL_TYPE_DL:XRAN_SYMBOL_TYPE_UL),
+ PortId, cc_id, tti,
+ pPrbMapElem->nStartSymb,
+ pPrbMapElem->numSymb, &numSyms);
+
+ if(startSym < 0 || numSyms == 0)
+ {
+ /* if start symbol is not valid, then skip this section */
+ print_err("Skip section %d due to invalid symbol range - [%d:%d], [%d:%d]",
+ i,
+ pPrbMapElem->nStartSymb, pPrbMapElem->numSymb,
+ startSym, numSyms);
+ }
+ }
+ else
+ {
+ startSym = pPrbMapElem->nStartSymb;
+ numSyms = pPrbMapElem->numSymb;
+ }
+
+ vf_id = xran_map_ecpriRtcid_to_vf(p_x_ctx, dir, cc_id, ru_port_id);
+ params.dir = dir;
+ params.sectionType = XRAN_CP_SECTIONTYPE_1;
+ params.hdr.filterIdx = XRAN_FILTERINDEX_STANDARD;
+ params.hdr.frameId = frame_id;
+ params.hdr.subframeId = subframe_id;
+ params.hdr.slotId = slot_id;
+ params.hdr.startSymId = startSym;
+ params.hdr.iqWidth = pPrbMapElem->iqWidth;
+ params.hdr.compMeth = pPrbMapElem->compMethod;
+ params.sections = sect_geninfo;
+
+ for (i = 0, j = 0; j < nsection; j++)
+ {
+ sect_geninfo[i].exDataSize=0;
+ sect_geninfo[i].info = xran_cp_get_section_info_ptr(pHandle, dir, cc_id, ru_port_id, ctx_id);
+ sect_geninfo[i].info->prbElemBegin = ((j == 0 ) ? 1 : 0);
+ sect_geninfo[i].info->prbElemEnd = ((j + 1 == nsection) ? 1 : 0);
+ if(sect_geninfo[i].info == NULL)
+ {
+ rte_panic("xran_cp_get_section_info_ptr failed\n");
+ }
+ pPrbMapElem = &prbMap->prbMap[j];
+
+ sect_geninfo[i].info->type = XRAN_CP_SECTIONTYPE_1;
+ sect_geninfo[i].info->startSymId = pPrbMapElem->nStartSymb;
+ sect_geninfo[i].info->iqWidth = params.hdr.iqWidth;
+ sect_geninfo[i].info->compMeth = params.hdr.compMeth;
+ sect_geninfo[i].info->id = pPrbMapElem->nSectId;
+
+ if(sect_geninfo[i].info->id > XRAN_MAX_SECTIONS_PER_SLOT)
+ print_err("sectinfo->id %d\n", sect_geninfo[i].info->id);
+
+ sect_geninfo[i].info->rb = XRAN_RBIND_EVERY;
+ sect_geninfo[i].info->startPrbc = pPrbMapElem->UP_nRBStart;
+ sect_geninfo[i].info->numPrbc = pPrbMapElem->UP_nRBSize;
+ sect_geninfo[i].info->numSymbol = pPrbMapElem->numSymb;
+ sect_geninfo[i].info->reMask = 0xfff;
+ sect_geninfo[i].info->beamId = pPrbMapElem->nBeamIndex;
+
+ if(startSym == pPrbMapElem->nStartSymb)
+ sect_geninfo[i].info->symInc = XRAN_SYMBOLNUMBER_NOTINC;
+ else
+ {
+ if((startSym + numSyms) == pPrbMapElem->nStartSymb)
+ {
+ sect_geninfo[i].info->symInc = XRAN_SYMBOLNUMBER_INC;
+ startSym = pPrbMapElem->nStartSymb;
+ numSyms = pPrbMapElem->numSymb;
+ }
+ else
+ {
+ sect_geninfo[i].info->startSymId = startSym;
+ sect_geninfo[i].info->numSymbol = numSyms;
+ print_dbg("Last startSym is %d. Last numSyms is %d. But current pPrbMapElem->nStartSymb is %d.\n", startSym, numSyms, pPrbMapElem->nStartSymb);
+ }
+ }
+
+
+ for(loc_sym = 0; loc_sym < XRAN_NUM_OF_SYMBOL_PER_SLOT; loc_sym++)
+ {
+ struct xran_section_desc *p_sec_desc = &pPrbMapElem->sec_desc[loc_sym][0];
+ if(p_sec_desc)
+ {
+ p_sec_desc->section_id = sect_geninfo[i].info->id;
+
+ sect_geninfo[i].info->sec_desc[loc_sym].iq_buffer_offset = p_sec_desc->iq_buffer_offset;
+ sect_geninfo[i].info->sec_desc[loc_sym].iq_buffer_len = p_sec_desc->iq_buffer_len;
+ }
+ else
+ {
+ print_err("section desc is NULL\n");
+ }
+ }
+
+ next = 0;
+ sect_geninfo[i].exDataSize = 0;
+
+ /* Extension 4 for modulation compression */
+ if(pPrbMapElem->compMethod == XRAN_COMPMETHOD_MODULATION)
+ {
+ // print_dbg("[%s]:%d Modulation Compression need to verify for this code branch and may not be available\n");
+ print_err("[%s]:%d Modulation Compression need to verify for this code branch and may not be available\n",__FUNCTION__, __LINE__);
+ }
+ /* Extension 1 or 11 for Beam forming weights */
+ /* add section extention for BF Weights if update is needed */
+ if((category == XRAN_CATEGORY_B) && (pPrbMapElem->bf_weight_update))
+ {
+ // print_dbg("[%s]:%d Category B need to verify for this code branch and may not be available\n");
+ print_err("[%s]:%d Category B need to verify for this code branch and may not be available\n",__FUNCTION__, __LINE__);
+ } /* if((category == XRAN_CATEGORY_B) && (pPrbMapElem->bf_weight_update)) */
+ else
+ {
+ sect_geninfo[i].info->ef = 0;
+ sect_geninfo[i].exDataSize = 0;
+
+ if(p_x_ctx->dssEnable == 1) {
+ uint8_t dssSlot = 0;
+ dssSlot = tti % (p_x_ctx->dssPeriod);
+
+ ext9.technology = p_x_ctx->technology[dssSlot];
+ ext9.reserved = 0;
+
+ sect_geninfo[i].exData[next].type = XRAN_CP_SECTIONEXTCMD_9;
+ sect_geninfo[i].exData[next].len = sizeof(ext9);
+ sect_geninfo[i].exData[next].data = &ext9;
+
+ sect_geninfo[i].info->ef = 1;
+ sect_geninfo[i].exDataSize++;
+ next++;
+ }
+ }
+
+ // xran_cp_add_section_info(pHandle, dir, cc_id, ru_port_id, ctx_id, §_geninfo[i].info);
+
+ if(pPrbMapElem->IsNewSect == 1)
+ {
+ sect_geninfo[i].info->startPrbc = pPrbMapElem->nRBStart;
+ sect_geninfo[i].info->numPrbc = pPrbMapElem->nRBSize;
+ i++;
+ }
+ }
+
+ params.numSections = i;
+
+ mbuf = xran_ethdi_mbuf_alloc();
+ if(unlikely(mbuf == NULL))
+ {
+ print_err("Alloc fail!\n");
+ ret=-1;
+ goto _create_and_send_section_error;
+ }
+
+ seq_id = xran_get_cp_seqid(pHandle, ((XRAN_DIR_DL == dir)? XRAN_DIR_DL : XRAN_DIR_UL), cc_id, ru_port_id);
+ ret = xran_prepare_ctrl_pkt(mbuf, ¶ms, cc_id, ru_port_id, seq_id,start_sect_id);
+
+ if(ret < 0)
+ {
+ print_err("Fail to build control plane packet - [%d:%d:%d] dir=%d\n",
+ frame_id, subframe_id, slot_id, dir);
+ }
+ else
+ {
+
+ int32_t cp_sent = 0;
+ int32_t pkt_len = 0;
+ /* add in the ethernet header */
+ struct rte_ether_hdr *const h = (void *)rte_pktmbuf_prepend(mbuf, sizeof(*h));
+ pkt_len = rte_pktmbuf_pkt_len(mbuf);
+ pCnt->tx_counter++;
+ pCnt->tx_bytes_counter += pkt_len; //rte_pktmbuf_pkt_len(mbuf);
+ if(pkt_len > p_x_ctx->fh_init.mtu)
+ rte_panic("section %d: pkt_len = %d maxExtBufSize %d\n", i, pkt_len, pPrbMapElem->bf_weight.maxExtBufSize);
+
+ cp_sent = p_x_ctx->send_cpmbuf2ring(mbuf, ETHER_TYPE_ECPRI, vf_id);
+ if(cp_sent != 1)
+ {
+ rte_pktmbuf_free(mbuf);
+ }
+ }
+
+ struct xran_section_info *info;
+ for (j = 0; j < nsection; j++)
+ {
+ pPrbMapElem = &prbMap->prbMap[j];
+ info = xran_cp_find_section_info(pHandle, dir, cc_id, ru_port_id, ctx_id,j);
+ if(info == NULL)
+ {
+ rte_panic("xran_cp_get_section_info_ptr failed\n");
+ }
+ info->startPrbc = pPrbMapElem->UP_nRBStart;
+ info->numPrbc = pPrbMapElem->UP_nRBSize;
+ }
+ }
+#endif
+_create_and_send_section_error:
+ if(XRAN_DIR_DL == dir)
+ {
+ prbElmProcInfo->nPrbElmProcessed = nsection;
+ }