+static int xran_prepare_sectionext_3(struct rte_mbuf *mbuf,
+ struct xran_sectionext3_info *params, int last_flag)
+{
+ int total_len;
+ int adj;
+
+
+ if(params->layerId == XRAN_LAYERID_0
+ || params->layerId == XRAN_LAYERID_TXD) { /* first data layer */
+
+ struct xran_cp_radioapp_section_ext3_first *ext3_f;
+ uint64_t *tmp;
+
+ total_len = sizeof(struct xran_cp_radioapp_section_ext3_first);
+ ext3_f = (struct xran_cp_radioapp_section_ext3_first *)rte_pktmbuf_append(mbuf, total_len);
+ if(ext3_f == NULL) {
+ print_err("Fail to allocate the space for section extension 3");
+ return (XRAN_STATUS_RESOURCE);
+ }
+
+ ext3_f->layerId = params->layerId;
+ ext3_f->ef = last_flag;
+ ext3_f->extType = XRAN_CP_SECTIONEXTCMD_3;
+ ext3_f->crsSymNum = params->crsSymNum;
+ ext3_f->crsShift = params->crsShift;
+ ext3_f->crsReMask = params->crsReMask;
+ ext3_f->txScheme = params->txScheme;
+ ext3_f->numLayers = params->numLayers;
+ ext3_f->codebookIndex = params->codebookIdx;
+
+ if(params->numAntPort == 2) {
+ ext3_f->beamIdAP3 = params->beamIdAP1;
+ ext3_f->beamIdAP2 = 0;
+ ext3_f->beamIdAP1 = 0;
+ ext3_f->extLen = 3;
+ adj = 4;
+ total_len -= adj;
+ }
+ else {
+ ext3_f->beamIdAP3 = params->beamIdAP1;
+ ext3_f->beamIdAP2 = params->beamIdAP2;
+ ext3_f->beamIdAP1 = params->beamIdAP3;
+ ext3_f->extLen = 4;
+ adj = 0;
+ }
+ ext3_f->reserved0 = 0;
+ ext3_f->reserved1 = 0;
+ ext3_f->reserved2 = 0;
+
+ /* convert byte order */
+ tmp = (uint64_t *)ext3_f;
+ *tmp = rte_cpu_to_be_64(*tmp); tmp++;
+ *tmp = rte_cpu_to_be_64(*tmp);
+
+ if(adj)
+ rte_pktmbuf_trim(mbuf, adj);
+ }
+ else { /* non-first data layer */
+ struct xran_cp_radioapp_section_ext3_non_first *ext3_nf;
+
+ total_len = sizeof(struct xran_cp_radioapp_section_ext3_non_first);
+ ext3_nf = (struct xran_cp_radioapp_section_ext3_non_first *)rte_pktmbuf_append(mbuf, total_len);
+ if(ext3_nf == NULL) {
+ print_err("Fail to allocate the space for section extension 3");
+ return (XRAN_STATUS_RESOURCE);
+ }
+
+ ext3_nf->layerId = params->layerId;
+ ext3_nf->ef = last_flag;
+ ext3_nf->extType = XRAN_CP_SECTIONEXTCMD_3;
+ ext3_nf->numLayers = params->numLayers;
+ ext3_nf->codebookIndex = params->codebookIdx;
+
+ ext3_nf->extLen = sizeof(struct xran_cp_radioapp_section_ext3_non_first)/XRAN_SECTIONEXT_ALIGN;
+
+ *(uint32_t *)ext3_nf = rte_cpu_to_be_32(*(uint32_t *)ext3_nf);
+ }
+
+ return (total_len);
+}
+