|
|
|
@ -185,51 +185,34 @@ int srslte_ra_ul_dci_to_grant_prb_allocation(srslte_ra_ul_dci_t *dci, srslte_ra_
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte_mod_t last_mod[8];
|
|
|
|
|
uint32_t last_ul_tbs_idx[8];
|
|
|
|
|
uint32_t last_dl_tbs[8];
|
|
|
|
|
uint32_t last_dl_tbs2[8];
|
|
|
|
|
|
|
|
|
|
static int ul_dci_to_grant_mcs(srslte_ra_ul_dci_t *dci, srslte_ra_ul_grant_t *grant, uint32_t harq_pid) {
|
|
|
|
|
int tbs = -1;
|
|
|
|
|
static void ul_dci_to_grant_mcs(srslte_ra_ul_dci_t *dci, srslte_ra_ul_grant_t *grant) {
|
|
|
|
|
// 8.6.2 First paragraph
|
|
|
|
|
if (dci->mcs_idx <= 28) {
|
|
|
|
|
/* Table 8.6.1-1 on 36.213 */
|
|
|
|
|
if (dci->mcs_idx < 11) {
|
|
|
|
|
grant->mcs.mod = SRSLTE_MOD_QPSK;
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(dci->mcs_idx, grant->L_prb);
|
|
|
|
|
last_ul_tbs_idx[harq_pid%8] = dci->mcs_idx;
|
|
|
|
|
grant->mcs.tbs = srslte_ra_tbs_from_idx(dci->mcs_idx, grant->L_prb);
|
|
|
|
|
} else if (dci->mcs_idx < 21) {
|
|
|
|
|
grant->mcs.mod = SRSLTE_MOD_16QAM;
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(dci->mcs_idx-1, grant->L_prb);
|
|
|
|
|
last_ul_tbs_idx[harq_pid%8] = dci->mcs_idx-1;
|
|
|
|
|
grant->mcs.tbs = srslte_ra_tbs_from_idx(dci->mcs_idx-1, grant->L_prb);
|
|
|
|
|
} else if (dci->mcs_idx < 29) {
|
|
|
|
|
grant->mcs.mod = SRSLTE_MOD_64QAM;
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(dci->mcs_idx-2, grant->L_prb);
|
|
|
|
|
last_ul_tbs_idx[harq_pid%8] = dci->mcs_idx-2;
|
|
|
|
|
grant->mcs.tbs = srslte_ra_tbs_from_idx(dci->mcs_idx-2, grant->L_prb);
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "Invalid MCS index %d\n", dci->mcs_idx);
|
|
|
|
|
}
|
|
|
|
|
last_mod[harq_pid%8] = grant->mcs.mod;
|
|
|
|
|
} else if (dci->mcs_idx == 29 && dci->cqi_request && grant->L_prb <= 4) {
|
|
|
|
|
// 8.6.1 and 8.6.2 36.213 second paragraph
|
|
|
|
|
grant->mcs.mod = SRSLTE_MOD_QPSK;
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(last_ul_tbs_idx[harq_pid%8], grant->L_prb);
|
|
|
|
|
grant->mcs.tbs = 0;
|
|
|
|
|
dci->rv_idx = 1;
|
|
|
|
|
} else if (dci->mcs_idx >= 29) {
|
|
|
|
|
// Else use last TBS/Modulation and use mcs to obtain rv_idx
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(last_ul_tbs_idx[harq_pid%8], grant->L_prb);
|
|
|
|
|
grant->mcs.mod = last_mod[harq_pid%8];
|
|
|
|
|
grant->mcs.tbs = -1;
|
|
|
|
|
grant->mcs.mod = SRSLTE_MOD_LAST;
|
|
|
|
|
dci->rv_idx = dci->mcs_idx - 28;
|
|
|
|
|
DEBUG("TTI=%d, harq_pid=%d, mcs_idx=%d, tbs=%d, mod=%d, rv=%d\n",
|
|
|
|
|
harq_pid, harq_pid%8, dci->mcs_idx, tbs/8, grant->mcs.mod, dci->rv_idx);
|
|
|
|
|
}
|
|
|
|
|
if (tbs < 0) {
|
|
|
|
|
fprintf(stderr, "Error computing TBS\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
} else {
|
|
|
|
|
grant->mcs.tbs = (uint32_t) tbs;
|
|
|
|
|
return SRSLTE_SUCCESS;
|
|
|
|
|
DEBUG("mcs_idx=%d, tbs=%d, mod=%d, rv=%d\n",
|
|
|
|
|
dci->mcs_idx, grant->mcs.tbs/8, grant->mcs.mod, dci->rv_idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -241,25 +224,21 @@ void srslte_ra_ul_grant_to_nbits(srslte_ra_ul_grant_t *grant, srslte_cp_t cp, ui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Compute PRB allocation for Uplink as defined in 8.1 and 8.4 of 36.213 */
|
|
|
|
|
int srslte_ra_ul_dci_to_grant(srslte_ra_ul_dci_t *dci, uint32_t nof_prb, uint32_t n_rb_ho, srslte_ra_ul_grant_t *grant,
|
|
|
|
|
uint32_t harq_pid)
|
|
|
|
|
int srslte_ra_ul_dci_to_grant(srslte_ra_ul_dci_t *dci, uint32_t nof_prb, uint32_t n_rb_ho, srslte_ra_ul_grant_t *grant)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Compute PRB allocation
|
|
|
|
|
if (!srslte_ra_ul_dci_to_grant_prb_allocation(dci, grant, n_rb_ho, nof_prb)) {
|
|
|
|
|
|
|
|
|
|
// Compute MCS
|
|
|
|
|
if (!ul_dci_to_grant_mcs(dci, grant, harq_pid)) {
|
|
|
|
|
ul_dci_to_grant_mcs(dci, grant);
|
|
|
|
|
|
|
|
|
|
// Fill rest of grant structure
|
|
|
|
|
grant->mcs.idx = dci->mcs_idx;
|
|
|
|
|
grant->M_sc = grant->L_prb*SRSLTE_NRE;
|
|
|
|
|
grant->M_sc_init = grant->M_sc; // FIXME: What should M_sc_init be?
|
|
|
|
|
grant->Qm = srslte_mod_bits_x_symbol(grant->mcs.mod);
|
|
|
|
|
|
|
|
|
|
// Fill rest of grant structure
|
|
|
|
|
grant->mcs.idx = dci->mcs_idx;
|
|
|
|
|
grant->M_sc = grant->L_prb*SRSLTE_NRE;
|
|
|
|
|
grant->M_sc_init = grant->M_sc; // FIXME: What should M_sc_init be?
|
|
|
|
|
grant->Qm = srslte_mod_bits_x_symbol(grant->mcs.mod);
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "Error computing MCS\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
printf("Error computing UL PRB allocation\n");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
@ -442,8 +421,7 @@ int srslte_ra_dl_dci_to_grant_prb_allocation(srslte_ra_dl_dci_t *dci, srslte_ra_
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_dl_fill_ra_mcs(srslte_ra_mcs_t *mcs, uint32_t nprb) {
|
|
|
|
|
uint32_t i_tbs = 0;
|
|
|
|
|
int tbs = -1;
|
|
|
|
|
int i_tbs = 0;
|
|
|
|
|
if (mcs->idx < 10) {
|
|
|
|
|
mcs->mod = SRSLTE_MOD_QPSK;
|
|
|
|
|
i_tbs = mcs->idx;
|
|
|
|
@ -455,23 +433,19 @@ int srslte_dl_fill_ra_mcs(srslte_ra_mcs_t *mcs, uint32_t nprb) {
|
|
|
|
|
i_tbs = mcs->idx-2;
|
|
|
|
|
} else if (mcs->idx == 29) {
|
|
|
|
|
mcs->mod = SRSLTE_MOD_QPSK;
|
|
|
|
|
tbs = 0;
|
|
|
|
|
i_tbs = 0;
|
|
|
|
|
i_tbs = -1;
|
|
|
|
|
} else if (mcs->idx == 30) {
|
|
|
|
|
mcs->mod = SRSLTE_MOD_16QAM;
|
|
|
|
|
tbs = 0;
|
|
|
|
|
i_tbs = 0;
|
|
|
|
|
i_tbs = -1;
|
|
|
|
|
} else if (mcs->idx == 31) {
|
|
|
|
|
mcs->mod = SRSLTE_MOD_64QAM;
|
|
|
|
|
tbs = 0;
|
|
|
|
|
i_tbs = 0;
|
|
|
|
|
i_tbs = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tbs == -1) {
|
|
|
|
|
int tbs = -1;
|
|
|
|
|
if (i_tbs >= 0) {
|
|
|
|
|
tbs = srslte_ra_tbs_from_idx(i_tbs, nprb);
|
|
|
|
|
if (tbs >= 0) {
|
|
|
|
|
mcs->tbs = tbs;
|
|
|
|
|
}
|
|
|
|
|
mcs->tbs = tbs;
|
|
|
|
|
}
|
|
|
|
|
return tbs;
|
|
|
|
|
}
|
|
|
|
@ -555,26 +529,14 @@ static int dl_dci_to_grant_mcs(srslte_ra_dl_dci_t *dci, srslte_ra_dl_grant_t *gr
|
|
|
|
|
grant->nof_tb = 0;
|
|
|
|
|
if (dci->tb_en[0]) {
|
|
|
|
|
grant->mcs[0].idx = dci->mcs_idx;
|
|
|
|
|
tbs = srslte_dl_fill_ra_mcs(&grant->mcs[0], n_prb);
|
|
|
|
|
if (tbs) {
|
|
|
|
|
last_dl_tbs[dci->harq_process%8] = tbs;
|
|
|
|
|
} else {
|
|
|
|
|
// For mcs>=29, set last TBS received for this PID
|
|
|
|
|
grant->mcs[0].tbs = last_dl_tbs[dci->harq_process%8];
|
|
|
|
|
}
|
|
|
|
|
grant->mcs[0].tbs = srslte_dl_fill_ra_mcs(&grant->mcs[0], n_prb);
|
|
|
|
|
grant->nof_tb++;
|
|
|
|
|
} else {
|
|
|
|
|
grant->mcs[0].tbs = 0;
|
|
|
|
|
}
|
|
|
|
|
if (dci->tb_en[1]) {
|
|
|
|
|
grant->mcs[1].idx = dci->mcs_idx_1;
|
|
|
|
|
tbs = srslte_dl_fill_ra_mcs(&grant->mcs[1], n_prb);
|
|
|
|
|
if (tbs) {
|
|
|
|
|
last_dl_tbs2[dci->harq_process%8] = tbs;
|
|
|
|
|
} else {
|
|
|
|
|
// For mcs>=29, set last TBS received for this PID
|
|
|
|
|
grant->mcs[1].tbs = last_dl_tbs2[dci->harq_process%8];
|
|
|
|
|
}
|
|
|
|
|
grant->mcs[1].tbs = srslte_dl_fill_ra_mcs(&grant->mcs[1], n_prb);
|
|
|
|
|
} else {
|
|
|
|
|
grant->mcs[1].tbs = 0;
|
|
|
|
|
}
|
|
|
|
|