Commit d3913062 authored by Cedric Roux's avatar Cedric Roux

nr: bugfix: LDPC post-processing copies wrong number of bytes

There was a bug. Uplink MAC PDU were corrupted. It turns out
that at the end of the processing of an LDPC segment, the decoded
data is copied to the output buffer, but! with a wrong size, bigger
than it should. The bug I saw was with three segments: 0, 1, and 2.
Segment 1 was finished first, then 0, then 2. When copying segment
0, the beginning of segment 1 was overwritten with the end
of segment 1 (which contains non-data bytes but CRC bytes then 0s),
leading to a corrupted MAC PDU.

Let's copy only the decoded data bytes instead.
parent 8f03a80a
...@@ -294,6 +294,7 @@ void nr_processULSegment(void* arg) { ...@@ -294,6 +294,7 @@ void nr_processULSegment(void* arg) {
int Kr_bytes; int Kr_bytes;
int K_bytes_F; int K_bytes_F;
uint8_t crc_type; uint8_t crc_type;
int crc_len;
int i; int i;
int j; int j;
int r = rdata->segment_r; int r = rdata->segment_r;
...@@ -388,15 +389,19 @@ void nr_processULSegment(void* arg) { ...@@ -388,15 +389,19 @@ void nr_processULSegment(void* arg) {
memset(ulsch_harq->c[r],0,Kr_bytes); memset(ulsch_harq->c[r],0,Kr_bytes);
if (ulsch_harq->C == 1) { if (ulsch_harq->C == 1) {
if (A > 3824) if (A > 3824) {
crc_type = CRC24_A; crc_type = CRC24_A;
else crc_len = 3;
} else {
crc_type = CRC16; crc_type = CRC16;
crc_len = 2;
}
length_dec = ulsch_harq->B; length_dec = ulsch_harq->B;
} }
else { else {
crc_type = CRC24_B; crc_type = CRC24_B;
crc_len = 3;
length_dec = (ulsch_harq->B+24*ulsch_harq->C)/ulsch_harq->C; length_dec = (ulsch_harq->B+24*ulsch_harq->C)/ulsch_harq->C;
} }
...@@ -434,6 +439,8 @@ void nr_processULSegment(void* arg) { ...@@ -434,6 +439,8 @@ void nr_processULSegment(void* arg) {
ulsch_harq->p_nrLDPC_procBuf[r], ulsch_harq->p_nrLDPC_procBuf[r],
p_procTime); p_procTime);
rdata->data_size = (length_dec>>3) - crc_len;
if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) { if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) {
#ifdef PRINT_CRC_CHECK #ifdef PRINT_CRC_CHECK
LOG_I(PHY, "Segment %d CRC OK\n",r); LOG_I(PHY, "Segment %d CRC OK\n",r);
......
...@@ -854,6 +854,7 @@ typedef struct LDPCDecode_s { ...@@ -854,6 +854,7 @@ typedef struct LDPCDecode_s {
int offset; int offset;
int Tbslbrm; int Tbslbrm;
int decodeIterations; int decodeIterations;
int data_size;
} ldpcDecode_t; } ldpcDecode_t;
struct ldpcReqId { struct ldpcReqId {
......
...@@ -239,7 +239,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ...@@ -239,7 +239,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
if (decodeSuccess) { if (decodeSuccess) {
memcpy(ulsch_harq->b+rdata->offset, memcpy(ulsch_harq->b+rdata->offset,
ulsch_harq->c[r], ulsch_harq->c[r],
rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); rdata->data_size);
} else { } else {
if ( rdata->nbSegments != ulsch_harq->processedSegments ) { if ( rdata->nbSegments != ulsch_harq->processedSegments ) {
......
...@@ -81,7 +81,7 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ...@@ -81,7 +81,7 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
if (decodeSuccess) { if (decodeSuccess) {
memcpy(ulsch_harq->b+rdata->offset, memcpy(ulsch_harq->b+rdata->offset,
ulsch_harq->c[r], ulsch_harq->c[r],
rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); rdata->data_size);
} else { } else {
if ( rdata->nbSegments != ulsch_harq->processedSegments ) { if ( rdata->nbSegments != ulsch_harq->processedSegments ) {
int nb=abortTpool(gNB->threadPool, req->key); int nb=abortTpool(gNB->threadPool, req->key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment