print_err("Fail to allocate the space for section extension 1");
return (XRAN_STATUS_RESOURCE);
}
- bfp_com_req.data_in = (int16_t*)p_bfw_iq_src;
- bfp_com_req.len = bfwNumPerRb*4;
- bfp_com_req.compMethod = p_ext1->bfwCompMeth;
- bfp_com_req.iqWidth = p_ext1->bfwIqWidth;
+ bfp_com_req.data_in = (int16_t*)p_bfw_iq_src;
+ bfp_com_req.numRBs = 1;
+ bfp_com_req.numDataElements = bfwNumPerRb*2;
+ bfp_com_req.len = bfwNumPerRb*4;
+ bfp_com_req.compMethod = p_ext1->bfwCompMeth;
+ bfp_com_req.iqWidth = p_ext1->bfwIqWidth;
print_dbg("req 0x%08p iqWidth %d\n",bfp_com_req.data_in, bfp_com_req.iqWidth);
bfp_com_rsp.data_out = (int8_t*)p_bfw_content;
if(xranlib_compress_avx512_bfw(&bfp_com_req, &bfp_com_rsp) == 0){
comp_len = bfp_com_rsp.len;
- print_dbg("comp_len %d\n", comp_len);
+ print_dbg("comp_len %d parm_size %d\n", comp_len, parm_size);
} else {
print_err("compression failed\n");
return (XRAN_STATUS_FAIL);
rte_panic("ext1 should be aligned on 4-bytes boundary");
p_ext1->extLen = cur_ext_len / XRAN_SECTIONEXT_ALIGN;
- print_dbg("p_ext1->extLen %d\n", p_ext1->extLen);
+ print_dbg("[%d] %p iq %p p_ext1->extLen %d\n",idxRb, p_ext1, p_ext1+1, p_ext1->extLen);
/* update for next RB */
p_ext1_dst_cur += cur_ext_len;
return (freqOffset);
}
-static int xran_copy_sectionext_1(struct rte_mbuf *mbuf,
+static int xran_append_sectionext_1(struct rte_mbuf *mbuf,
struct xran_sectionext1_info *params, int last_flag)
{
- int32_t total_len;
- int8_t *p_dst = (int8_t *)rte_pktmbuf_append(mbuf, params->bfwIQ_sz);
- if(p_dst == NULL) {
- print_err("Fail to allocate the space for section extension 1 [%d]", params->bfwIQ_sz);
- return (XRAN_STATUS_RESOURCE);
- }
- if(params->p_bfwIQ){
- /* copy formated extType1 with all the headers */
- rte_memcpy(p_dst, params->p_bfwIQ, params->bfwIQ_sz);
+ int32_t total_len = 0;
+
+ if(params->bfwIQ_sz) {
+ int8_t *p_dst = (int8_t *)rte_pktmbuf_append(mbuf, params->bfwIQ_sz);
+
+ if(p_dst == NULL) {
+ print_err("Fail to allocate the space for section extension 1 [%d]", params->bfwIQ_sz);
+ return (XRAN_STATUS_RESOURCE);
+ }
+
+ /* extType1 with all the headers created by xran_cp_populate_section_ext_1() earlier */
total_len = params->bfwIQ_sz;
}
- else
- total_len = 0;
-
return (total_len);
}
return (total_len);
}
+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);
+}
+
static int xran_prepare_sectionext_4(struct rte_mbuf *mbuf,
struct xran_sectionext4_info *params, int last_flag)
{
switch(params->exData[i].type) {
case XRAN_CP_SECTIONEXTCMD_1:
- ext_size = xran_copy_sectionext_1(mbuf, params->exData[i].data, last_flag);
- //xran_prepare_sectionext_1(mbuf, params->exData[i].data, last_flag);
+ ext_size = xran_append_sectionext_1(mbuf, params->exData[i].data, last_flag);
break;
case XRAN_CP_SECTIONEXTCMD_2:
ext_size = xran_prepare_sectionext_2(mbuf, params->exData[i].data, last_flag);
break;
+ case XRAN_CP_SECTIONEXTCMD_3:
+ ext_size = xran_prepare_sectionext_3(mbuf, params->exData[i].data, last_flag);
+ break;
case XRAN_CP_SECTIONEXTCMD_4:
ext_size = xran_prepare_sectionext_4(mbuf, params->exData[i].data, last_flag);
break;
case XRAN_CP_SECTIONEXTCMD_5:
ext_size = xran_prepare_sectionext_5(mbuf, params->exData[i].data, last_flag);
break;
- case XRAN_CP_SECTIONEXTCMD_0:
- case XRAN_CP_SECTIONEXTCMD_3:
default:
print_err("Extension Type %d is not supported!", params->exData[i].type);
ret = XRAN_STATUS_INVALID_PARAM;
apphdr->filterIndex = params->hdr.filterIdx;
apphdr->frameId = params->hdr.frameId;
apphdr->subframeId = params->hdr.subframeId;
- apphdr->slotId = params->hdr.slotId;
+ apphdr->slotId = xran_slotid_convert(params->hdr.slotId, 0);
apphdr->startSymbolId = params->hdr.startSymId;
apphdr->numOfSections = params->numSections;
apphdr->sectionType = params->sectionType;
ext2 = (struct xran_cp_radioapp_section_ext2 *)ext;
data = (uint8_t *)ext;
- *(uint32_t *)ext2 = rte_cpu_to_be_32(*(uint32_t *)ext2);
+ *(uint32_t *)ext2 = rte_be_to_cpu_32(*(uint32_t *)ext2);
len = 0;
total_len = ext2->extLen * XRAN_SECTIONEXT_ALIGN; /* from word to byte */
+ (extinfo->bfAz3ddWidth ? extinfo->bfAz3ddWidth+1 : 0)
+ (extinfo->bfZe3ddWidth ? extinfo->bfZe3ddWidth+ 1: 0);
if(val_size) {
- val = rte_cpu_to_be_32(*(uint32_t *)data);
+ val = rte_be_to_cpu_32(*(uint32_t *)data);
val >>= (32 - val_size);
if(extinfo->bfZe3ddWidth) {
}
+int xran_parse_section_ext3(void *ext,
+ struct xran_sectionext3_info *extinfo)
+{
+ int len;
+ int total_len;
+
+ total_len = 0;
+ len = *((uint8_t *)ext + 1);
+
+ switch(len) {
+ case 1: /* non-first data layer */
+ {
+ struct xran_cp_radioapp_section_ext3_non_first *ext3_nf;
+
+ ext3_nf = (struct xran_cp_radioapp_section_ext3_non_first *)ext;
+ *(uint32_t *)ext3_nf = rte_be_to_cpu_32(*(uint32_t *)ext3_nf);
+
+ total_len = ext3_nf->extLen * XRAN_SECTIONEXT_ALIGN; /* from word to byte */
+
+ extinfo->codebookIdx= ext3_nf->codebookIndex;
+ extinfo->layerId = ext3_nf->layerId;
+ extinfo->numLayers = ext3_nf->numLayers;
+ }
+ break;
+
+ case 3: /* first data layer with two antenna */
+ case 4: /* first data layer with four antenna */
+ {
+ struct xran_cp_radioapp_section_ext3_first *ext3_f;
+ uint16_t *beamid;
+
+ ext3_f = (struct xran_cp_radioapp_section_ext3_first *)ext;
+ *(uint64_t *)ext3_f = rte_be_to_cpu_64(*(uint64_t *)ext3_f);
+
+ total_len = ext3_f->extLen * XRAN_SECTIONEXT_ALIGN; /* from word to byte */
+
+ extinfo->codebookIdx= ext3_f->codebookIndex;
+ extinfo->layerId = ext3_f->layerId;
+ extinfo->numLayers = ext3_f->numLayers;
+ extinfo->txScheme = ext3_f->txScheme;
+ extinfo->crsReMask = ext3_f->crsReMask;
+ extinfo->crsShift = ext3_f->crsShift;
+ extinfo->crsSymNum = ext3_f->crsSymNum;
+
+ /* beam IDs are stored from 10th octet */
+ beamid = (uint16_t *)((uint8_t *)ext + 10);
+
+ extinfo->beamIdAP1 = rte_be_to_cpu_16(*beamid++);
+ if(len == 4) {
+ extinfo->beamIdAP2 = rte_be_to_cpu_16(*beamid++);
+ extinfo->beamIdAP3 = rte_be_to_cpu_16(*beamid);
+ extinfo->numAntPort = 4;
+ }
+ else {
+ extinfo->numAntPort = 2;
+ }
+ }
+ break;
+
+ default:
+ print_err("Invalid length of extension 3 - %d", len);
+ }
+
+ return (total_len);
+}
+
int xran_parse_section_ext4(void *ext,
struct xran_sectionext4_info *extinfo)
{
ext4 = (struct xran_cp_radioapp_section_ext4 *)ext;
- *(uint32_t *)ext4 = rte_cpu_to_be_32(*(uint32_t *)ext4);
+ *(uint32_t *)ext4 = rte_be_to_cpu_32(*(uint32_t *)ext4);
len = 0;
total_len = ext4->extLen * XRAN_SECTIONEXT_ALIGN; /* from word to byte */
extinfo->modCompScaler = ext4->modCompScaler;
extinfo->csf = ext4->csf;
-// extinfo->pad0;
len += sizeof(struct xran_cp_radioapp_section_ext4);
if(len != total_len) {
uint8_t *data;
uint16_t i;
-
ext_hdr = (struct xran_cp_radioapp_section_ext_hdr *)ext;
- *(uint16_t *)ext_hdr = rte_cpu_to_be_16(*(uint16_t *)ext_hdr);
+ *(uint16_t *)ext_hdr = rte_be_to_cpu_16(*(uint16_t *)ext_hdr);
total_len = ext_hdr->extLen * XRAN_SECTIONEXT_ALIGN; /* from word to byte */
- // one set has 3.5 bytes, so enforcing double to do integer calculation
+ /* one set has 3.5 bytes, so enforcing double to do integer calculation */
parm_size = ((total_len-sizeof(struct xran_cp_radioapp_section_ext_hdr))*2) / 7;
if(parm_size > XRAN_MAX_MODCOMP_ADDPARMS) {
i = 0;
while(i < parm_size) {
// For odd number set, more data can be copied
- *((uint64_t *)&ext5) = rte_cpu_to_be_64(*((uint64_t *)data));
+ *((uint64_t *)&ext5) = rte_be_to_cpu_64(*((uint64_t *)data));
extinfo->mc[i].mcScaleOffset = ext5.mcScaleOffset1;
extinfo->mc[i].csf = ext5.csf1;
data += sizeof(struct xran_cp_radioapp_section_ext5);
}
- // check the values of last set
- // due to alignment, it cannot be identified by the length that 3 or 4, 11 or 12 and etc
- // don't check mcScaleOffset might not be zero (some part is out of zero-padding)
+ /* check the values of last set
+ * due to alignment, it cannot be identified by the length that 3 or 4, 11 or 12 and etc
+ * don't check mcScaleOffset might not be zero (some part is out of zero-padding) */
i--;
if(i < XRAN_MAX_MODCOMP_ADDPARMS) {
if(extinfo->mc[i].csf == 0 && extinfo->mc[i].mcScaleReMask == 0)
section->exData[numext].data = §ion->m_ext2[numext];
len = xran_parse_section_ext2(ptr, section->exData[numext].data);
break;
+ case XRAN_CP_SECTIONEXTCMD_3:
+ section->exData[numext].data = §ion->m_ext3[numext];
+ len = xran_parse_section_ext3(ptr, section->exData[numext].data);
+ break;
case XRAN_CP_SECTIONEXTCMD_4:
section->exData[numext].data = §ion->m_ext4[numext];
len = xran_parse_section_ext4(ptr, section->exData[numext].data);
len = xran_parse_section_ext5(ptr, section->exData[numext].data);
break;
- case XRAN_CP_SECTIONEXTCMD_0:
- case XRAN_CP_SECTIONEXTCMD_3:
default:
print_err("Extension %d is not supported!", ext_type);
len = 0;
return (XRAN_STATUS_INVALID_PACKET);
}
- *((uint32_t *)apphdr) = rte_cpu_to_be_32(*((uint32_t *)apphdr));
+ *((uint32_t *)apphdr) = rte_be_to_cpu_32(*((uint32_t *)apphdr));
if(apphdr->payloadVer != XRAN_PAYLOAD_VER) {
print_err("Invalid Payload version - %d", apphdr->payloadVer);