- if(p_xran_dev_ctx->enablePrach
- && (p_xran_dev_ctx->fh_init.io_cfg.id == O_RU)) { /* Only RU needs to send PRACH I/Q */
- uint32_t isPRACHslot = xran_isPRACHSlot(subframe_id, slot_id);
- if((frame_id % pPrachCPConfig->x == pPrachCPConfig->y[0])
- && (isPRACHslot == 1)
- && (sym_id >= p_xran_dev_ctx->prach_start_symbol[cc_id])
- && (sym_id <= p_xran_dev_ctx->prach_last_symbol[cc_id])) { //is prach slot
- for(ant_id = 0; ant_id < num_eAxc; ant_id++) {
- int prach_port_id = ant_id + num_eAxc;
- pos = (char*) p_xran_dev_ctx->sFHPrachRxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[0].pData;
- pos += (sym_id - p_xran_dev_ctx->prach_start_symbol[cc_id]) * pPrachCPConfig->numPrbc * N_SC_PER_PRB * 4;
- mb = NULL;//(void*) p_xran_dev_ctx->sFHPrachRxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[0].pCtrl;
- send_symbol_ex(direction,
- xran_alloc_sectionid(pHandle, direction, cc_id, prach_port_id, slot_id),
- (struct rte_mbuf *)mb,
- (struct rb_map *)pos,
- p_xran_dev_ctx->fh_cfg.ru_conf.byteOrder,
- frame_id, subframe_id, slot_id, sym_id,
- pPrachCPConfig->startPrbc, pPrachCPConfig->numPrbc,
- cc_id, prach_port_id,
- xran_get_upul_seqid(pHandle, cc_id, prach_port_id));
- }
- } /* if((frame_id % pPrachCPConfig->x == pPrachCPConfig->y[0]) .... */
- } /* if(p_xran_dev_ctx->enablePrach ..... */
-
- } /* RU mode or C-Plane is not used */
+ return retval;
+}
+
+
+int32_t xran_process_tx_sym_cp_on(uint8_t ctx_id, uint32_t tti, int32_t cc_id, int32_t ant_id, uint32_t frame_id, uint32_t subframe_id,
+ uint32_t slot_id, uint32_t sym_id)
+{
+ int32_t retval = 0;
+ uint64_t t1 = MLogTick();
+
+ struct rte_mbuf *eth_oran_hdr = NULL;
+ char *ext_buff = NULL;
+ uint16_t ext_buff_len = 0;
+ struct rte_mbuf *tmp = NULL;
+ rte_iova_t ext_buff_iova = 0;
+ void *pHandle = NULL;
+ char *pos = NULL;
+ char *p_sec_iq = NULL;
+ void *mb = NULL;
+ int prb_num = 0;
+ uint16_t iq_sample_size_bits = 16; // TODO: make dynamic per
+ uint32_t next = 0;
+ int32_t num_sections = 0;
+
+ struct xran_section_info *sectinfo = NULL;
+ struct xran_device_ctx *p_xran_dev_ctx = xran_dev_get_ctx();
+
+ struct xran_prach_cp_config *pPrachCPConfig = &(p_xran_dev_ctx->PrachCPConfig);
+ struct xran_srs_config *p_srs_cfg = &(p_xran_dev_ctx->srs_cfg);
+ enum xran_pkt_dir direction;
+
+ struct rte_mbuf_ext_shared_info * p_share_data = &share_data[tti % XRAN_N_FE_BUF_LEN];
+
+ if(p_xran_dev_ctx->fh_init.io_cfg.id == O_DU) {
+ direction = XRAN_DIR_DL; /* O-DU */
+ prb_num = p_xran_dev_ctx->fh_cfg.nDLRBs;
+ } else {
+ direction = XRAN_DIR_UL; /* RU */
+ prb_num = p_xran_dev_ctx->fh_cfg.nULRBs;
+ }
+
+ next = 0;
+ num_sections = xran_cp_getsize_section_info(pHandle, direction, cc_id, ant_id, ctx_id);
+ /* iterate C-Plane configuration to generate corresponding U-Plane */
+ while(next < num_sections) {
+ sectinfo = xran_cp_iterate_section_info(pHandle, direction, cc_id, ant_id, ctx_id, &next);
+
+ if(sectinfo == NULL)
+ break;
+
+ if(sectinfo->type != XRAN_CP_SECTIONTYPE_1) { /* only supports type 1 */
+ print_err("Invalid section type in section DB - %d", sectinfo->type);
+ continue;
+ }
+
+ /* skip, if not scheduled */
+ if(sym_id < sectinfo->startSymId || sym_id >= sectinfo->startSymId + sectinfo->numSymbol)
+ continue;
+
+ if(sectinfo->compMeth)
+ iq_sample_size_bits = sectinfo->iqWidth;
+
+ print_dbg(">>> sym %2d [%d] type%d, id %d, startPrbc=%d, numPrbc=%d, numSymbol=%d\n", sym_id, next,
+ sectinfo->type, sectinfo->id, sectinfo->startPrbc,
+ sectinfo->numPrbc, sectinfo->numSymbol);
+
+ p_xran_dev_ctx->tx_mbufs[0].len = 0;
+ uint16_t len = p_xran_dev_ctx->tx_mbufs[0].len;
+ int16_t len2 = 0;
+ uint16_t i = 0;
+
+ //Added for Klocworks
+ if (len >= MBUF_TABLE_SIZE)
+ len = MBUF_TABLE_SIZE - 1;
+
+ pos = (char*) p_xran_dev_ctx->sFrontHaulTxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[sym_id].pData;
+ mb = p_xran_dev_ctx->sFrontHaulTxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[sym_id].pCtrl;
+
+#if 1
+ p_sec_iq = ((char*)pos + sectinfo->sec_desc[sym_id].iq_buffer_offset);
+
+ /* calculete offset for external buffer */
+ ext_buff_len = sectinfo->sec_desc[sym_id].iq_buffer_len;
+ ext_buff = p_sec_iq - (RTE_PKTMBUF_HEADROOM +
+ sizeof (struct xran_ecpri_hdr) +
+ sizeof (struct radio_app_common_hdr) +
+ sizeof(struct data_section_hdr));
+
+ ext_buff_len += RTE_PKTMBUF_HEADROOM +
+ sizeof (struct xran_ecpri_hdr) +
+ sizeof (struct radio_app_common_hdr) +
+ sizeof(struct data_section_hdr) + 18;
+
+ if(sectinfo->compMeth != XRAN_COMPMETHOD_NONE){
+ ext_buff -= sizeof (struct data_section_compression_hdr);
+ ext_buff_len += sizeof (struct data_section_compression_hdr);
+ }
+
+ eth_oran_hdr = rte_pktmbuf_alloc(_eth_mbuf_pool_small);
+
+ if (unlikely (( eth_oran_hdr) == NULL)) {
+ rte_panic("Failed rte_pktmbuf_alloc\n");
+ }
+
+ p_share_data->free_cb = extbuf_free_callback;
+ p_share_data->fcb_opaque = NULL;
+ rte_mbuf_ext_refcnt_set(p_share_data, 1);
+
+ ext_buff_iova = rte_mempool_virt2iova(mb);
+ if (unlikely (( ext_buff_iova) == 0)) {
+ rte_panic("Failed rte_mem_virt2iova \n");
+ }
+
+ if (unlikely (( (rte_iova_t)ext_buff_iova) == RTE_BAD_IOVA)) {
+ rte_panic("Failed rte_mem_virt2iova RTE_BAD_IOVA \n");
+ }
+
+ rte_pktmbuf_attach_extbuf(eth_oran_hdr,
+ ext_buff,
+ ext_buff_iova + RTE_PTR_DIFF(ext_buff , mb),
+ ext_buff_len,
+ p_share_data);
+
+ rte_pktmbuf_reset_headroom(eth_oran_hdr);
+
+ tmp = (struct rte_mbuf *)rte_pktmbuf_prepend(eth_oran_hdr, sizeof(struct ether_hdr));
+ if (unlikely (( tmp) == NULL)) {
+ rte_panic("Failed rte_pktmbuf_prepend \n");
+ }
+ mb = eth_oran_hdr;
+#else
+ rte_pktmbuf_refcnt_update(mb, 1); /* make sure eth won't free our mbuf */
+#endif
+ /* first all PRBs */
+ prepare_symbol_ex(direction, sectinfo->id,
+ mb,
+ (struct rb_map *)p_sec_iq,
+ sectinfo->compMeth,
+ sectinfo->iqWidth,
+ p_xran_dev_ctx->fh_cfg.ru_conf.byteOrder,
+ frame_id, subframe_id, slot_id, sym_id,
+ sectinfo->startPrbc, sectinfo->numPrbc,
+ cc_id, ant_id,
+ xran_get_updl_seqid(pHandle, cc_id, ant_id),
+ 0);
+
+ /* if we don't need to do any fragmentation */
+ if (likely (p_xran_dev_ctx->fh_init.mtu >=
+ sectinfo->numPrbc * (3*iq_sample_size_bits + 1))) {
+ /* no fragmentation */
+ p_xran_dev_ctx->tx_mbufs[0].m_table[len] = mb;
+ len2 = 1;
+ } else {
+ /* fragmentation */
+ uint8_t * seq_num = xran_get_updl_seqid_addr(pHandle, cc_id, ant_id);
+ if(seq_num)
+ (*seq_num)--;
+ else
+ rte_panic("pointer to seq number is NULL [CC %d Ant %d]\n", cc_id, ant_id);
+
+ len2 = xran_app_fragment_packet(mb,
+ &p_xran_dev_ctx->tx_mbufs[0].m_table[len],
+ (uint16_t)(MBUF_TABLE_SIZE - len),
+ p_xran_dev_ctx->fh_init.mtu,
+ p_xran_dev_ctx->direct_pool,
+ p_xran_dev_ctx->indirect_pool,
+ sectinfo,
+ seq_num);
+
+ /* Free input packet */
+ rte_pktmbuf_free(mb);
+
+ /* If we fail to fragment the packet */
+ if (unlikely (len2 < 0)){
+ print_err("len2= %d\n", len2);
+ return 0;
+ }
+ }
+
+ if(len2 > 1){
+ for (i = len; i < len + len2; i ++) {
+ struct rte_mbuf *m;
+ m = p_xran_dev_ctx->tx_mbufs[0].m_table[i];
+ struct ether_hdr *eth_hdr = (struct ether_hdr *)
+ rte_pktmbuf_prepend(m, (uint16_t)sizeof(struct ether_hdr));
+ if (eth_hdr == NULL) {
+ rte_panic("No headroom in mbuf.\n");