From 66ac734c514db163c41bab9db81b6f732fd4d68f Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 31 Aug 2016 19:07:20 +0200 Subject: [PATCH] added support for 2 tb in format2 --- srslte/include/srslte/phch/ra.h | 6 ++- srslte/lib/phch/dci.c | 11 ++++- srslte/lib/phch/ra.c | 79 +++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/srslte/include/srslte/phch/ra.h b/srslte/include/srslte/phch/ra.h index 0b51331f3..b32f759b2 100644 --- a/srslte/include/srslte/phch/ra.h +++ b/srslte/include/srslte/phch/ra.h @@ -102,8 +102,10 @@ typedef struct SRSLTE_API { typedef struct SRSLTE_API { bool prb_idx[2][SRSLTE_MAX_PRB]; uint32_t nof_prb; - uint32_t Qm; + uint32_t Qm; + uint32_t Qm2; srslte_ra_mcs_t mcs; + srslte_ra_mcs_t mcs2; } srslte_ra_dl_grant_t; /** Unpacked DCI message for DL grant */ @@ -130,6 +132,8 @@ typedef struct SRSLTE_API { bool pconf; bool power_offset; + uint32_t nof_tb; + bool dci_is_1a; bool dci_is_1c; } srslte_ra_dl_dci_t; diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index e6587c629..3203fc48d 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -627,6 +627,7 @@ int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t // TPC not implemented + data->nof_tb = 1; return SRSLTE_SUCCESS; } @@ -812,6 +813,8 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 y++; // MSB of TPC is reserved data->type2_alloc.n_prb1a = *y++; // LSB indicates N_prb_1a for TBS } + + data->nof_tb = 1; return SRSLTE_SUCCESS; } @@ -856,7 +859,8 @@ int dci_format1B_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_ data->pinfo = srslte_bit_pack(&y, tpmi_bits(nof_ports)); data->pconf = *y++ ? true : false; - + + data->nof_tb = 1; return SRSLTE_SUCCESS; } @@ -948,6 +952,8 @@ int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 data->rv_idx = -1; // Get RV later msg->nof_bits = (y - msg->data); + + data->nof_tb = 1; return SRSLTE_SUCCESS; } @@ -993,6 +999,7 @@ int dci_format1D_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_ data->pinfo = srslte_bit_pack(&y, tpmi_bits(nof_ports)); data->power_offset = *y++ ? true : false; + data->nof_tb = 1; return SRSLTE_SUCCESS; } @@ -1060,6 +1067,8 @@ int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 data->pinfo = srslte_bit_pack(&y, precoding_bits_f2a(nof_ports)); } + data->nof_tb = 2; + return SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/ra.c b/srslte/lib/phch/ra.c index 3ea7b9c30..dc12b7d4d 100644 --- a/srslte/lib/phch/ra.c +++ b/srslte/lib/phch/ra.c @@ -380,6 +380,40 @@ static int dl_dci_to_grant_prb_allocation(srslte_ra_dl_dci_t *dci, srslte_ra_dl_ return SRSLTE_SUCCESS; } +static int dl_fill_ra_mcs(srslte_ra_mcs_t *mcs, uint32_t nprb) { + uint32_t i_tbs = 0; + int tbs = -1; + if (mcs->idx < 10) { + mcs->mod = SRSLTE_MOD_QPSK; + i_tbs = mcs->idx; + } else if (mcs->idx < 17) { + mcs->mod = SRSLTE_MOD_16QAM; + i_tbs = mcs->idx-1; + } else if (mcs->idx < 29) { + mcs->mod = SRSLTE_MOD_64QAM; + i_tbs = mcs->idx-2; + } else if (mcs->idx == 29) { + mcs->mod = SRSLTE_MOD_QPSK; + tbs = 0; + i_tbs = 0; + } else if (mcs->idx == 30) { + mcs->mod = SRSLTE_MOD_16QAM; + tbs = 0; + i_tbs = 0; + } else if (mcs->idx == 31) { + mcs->mod = SRSLTE_MOD_64QAM; + tbs = 0; + i_tbs = 0; + } + if (tbs == -1) { + tbs = srslte_ra_tbs_from_idx(i_tbs, nprb); + if (tbs >= 0) { + mcs->tbs = tbs; + } + } + return tbs; +} + /* Modulation order and transport block size determination 7.1.7 in 36.213 */ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *grant, bool crc_is_crnti) { uint32_t n_prb=0; @@ -397,40 +431,23 @@ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *gr } } grant->mcs.mod = SRSLTE_MOD_QPSK; + grant->mcs.tbs = (uint32_t) tbs; } else { - tbs = -1; n_prb = grant->nof_prb; - if (dci->mcs_idx < 10) { - grant->mcs.mod = SRSLTE_MOD_QPSK; - i_tbs = dci->mcs_idx; - } else if (dci->mcs_idx < 17) { - grant->mcs.mod = SRSLTE_MOD_16QAM; - i_tbs = dci->mcs_idx-1; - } else if (dci->mcs_idx < 29) { - grant->mcs.mod = SRSLTE_MOD_64QAM; - i_tbs = dci->mcs_idx-2; - } else if (dci->mcs_idx == 29) { - grant->mcs.mod = SRSLTE_MOD_QPSK; - tbs = 0; - i_tbs = 0; - } else if (dci->mcs_idx == 30) { - grant->mcs.mod = SRSLTE_MOD_16QAM; - tbs = 0; - i_tbs = 0; - } else if (dci->mcs_idx == 31) { - grant->mcs.mod = SRSLTE_MOD_64QAM; - tbs = 0; - i_tbs = 0; - } - if (tbs == -1) { - tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb); + grant->mcs.idx = dci->mcs_idx; + tbs = dl_fill_ra_mcs(&grant->mcs, n_prb); + if (dci->nof_tb == 2) { + grant->mcs2.idx = dci->mcs_idx_1; + tbs = dl_fill_ra_mcs(&grant->mcs2, n_prb); } } - + grant->Qm = srslte_mod_bits_x_symbol(grant->mcs.mod); + if (dci->nof_tb == 2) { + grant->Qm2 = srslte_mod_bits_x_symbol(grant->mcs2.mod); + } if (tbs < 0) { return SRSLTE_ERROR; - } else { - grant->mcs.tbs = (uint32_t) tbs; + } else { return SRSLTE_SUCCESS; } } @@ -455,11 +472,7 @@ int srslte_ra_dl_dci_to_grant(srslte_ra_dl_dci_t *dci, // Compute PRB allocation if (!dl_dci_to_grant_prb_allocation(dci, grant, nof_prb)) { // Compute MCS - if (!dl_dci_to_grant_mcs(dci, grant, crc_is_crnti)) { - // Fill rest of grant structure - grant->mcs.idx = dci->mcs_idx; - grant->Qm = srslte_mod_bits_x_symbol(grant->mcs.mod); - + if (!dl_dci_to_grant_mcs(dci, grant, crc_is_crnti)) { // Apply Section 7.1.7.3. If RA-RNTI and Format1C rv_idx=0 if (msg_rnti >= SRSLTE_RARNTI_START && msg_rnti <= SRSLTE_RARNTI_END && dci->dci_is_1c)