diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index 4604ed06f..b78527ddd 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -758,16 +758,10 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, uint32_t nb_q = cfg->nbits.nof_bits; uint32_t Qm = cfg->grant.Qm; - // Encode RI if CQI enabled - if (uci_data.uci_ri_len > 0 || uci_data.uci_cqi_len > 0) { - /* If no RI is reported set it to zero as specified in 3GPP 36.213 clause 7.2.1 */ - if (uci_data.uci_ri_len == 0) { - uci_data.uci_ri_len = 1; - uci_data.uci_ri = 0; - } + if (uci_data.uci_ri_len > 0) { float beta = beta_ri_offset[cfg->uci_cfg.I_offset_ri]; if (cfg->cb_segm.tbs == 0) { - beta /= beta_cqi_offset[cfg->uci_cfg.I_offset_cqi]; + beta /= beta_cqi_offset[cfg->uci_cfg.I_offset_cqi]; } uint8_t ri[2] = {uci_data.uci_ri, 0}; ret = srslte_uci_encode_ack_ri(cfg, ri, uci_data.uci_ri_len, uci_data.uci_cqi_len, beta, nb_q/Qm, q->ack_ri_bits, true); diff --git a/lib/src/phy/phch/uci.c b/lib/src/phy/phch/uci.c index 8a1a36544..6711c2fd3 100644 --- a/lib/src/phy/phch/uci.c +++ b/lib/src/phy/phch/uci.c @@ -581,7 +581,7 @@ static uint32_t encode_ri_ack(uint8_t data[2], uint32_t data_len, srslte_uci_bit while(i < Qm) { q_encoded_bits[i++] = UCI_BIT_PLACEHOLDER; } - } else { + } else if (data_len == 2) { q_encoded_bits[i++] = data[0] ? UCI_BIT_1 : UCI_BIT_0; q_encoded_bits[i++] = data[1] ? UCI_BIT_1 : UCI_BIT_0; while(igrant.Qm); + + for (uint32_t i=0;igrant.Qm, H_prime_total, cfg->nbits.nof_symb, cfg->cp, &ack_bits[cfg->grant.Qm*i]); + uci_ulsch_interleave_put(&q_encoded_bits[(i*cfg->grant.Qm)%nof_encoded_bits], cfg->grant.Qm, &ack_bits[cfg->grant.Qm*i]); + } + + return (int) Qprime; +} + +/* Encode UCI RI bits as described in 5.2.2.6 of 36.212 + * Currently only supporting 1-bit RI + */ +int srslte_uci_encode_ri(srslte_pusch_cfg_t *cfg, + uint8_t ri, + uint32_t O_cqi, float beta, uint32_t H_prime_total, + srslte_uci_bit_t *ri_bits) +{ + // FIXME: It supports RI of 1 bit only + uint8_t data[2] = {ri, 0}; + if (beta < 0) { + fprintf(stderr, "Error beta is reserved\n"); + return -1; + } + uint32_t Qprime = Q_prime_ri_ack(cfg, 1, O_cqi, beta); + srslte_uci_bit_type_t q_encoded_bits[18]; + + uint32_t nof_encoded_bits = encode_ri_ack(data, 1, q_encoded_bits, cfg->grant.Qm); + + for (uint32_t i=0;igrant.Qm, H_prime_total, cfg->nbits.nof_symb, cfg->cp, &ri_bits[cfg->grant.Qm*i]); + uci_ulsch_interleave_put(&q_encoded_bits[(i*cfg->grant.Qm)%nof_encoded_bits], cfg->grant.Qm, &ri_bits[cfg->grant.Qm*i]); + } + + return (int) Qprime; +} + /* Encode UCI ACK/RI bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit RI */ diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index aa1c128a0..24d2b3ca1 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -473,13 +473,11 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) // Configure PUSCH CQI channel srslte_cqi_value_t cqi_value = {0}; bool cqi_enabled = false; -#if 0 + if (ue_db[rnti].cqi_en && ue_db[rnti].ri_en && srslte_ri_send(ue_db[rnti].pmi_idx, ue_db[rnti].ri_idx, tti_rx) ) { uci_data.uci_ri_len = 1; /* Asumes only 1 bit for RI */ - ri_enabled = true; - } else -#endif - if (ue_db[rnti].cqi_en && srslte_cqi_send(ue_db[rnti].pmi_idx, tti_rx)) { + uci_data.ri_periodic_report = true; + } else if (ue_db[rnti].cqi_en && srslte_cqi_send(ue_db[rnti].pmi_idx, tti_rx)) { cqi_value.type = SRSLTE_CQI_TYPE_WIDEBAND; cqi_enabled = true; if (ue_db[rnti].dedicated.antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { @@ -588,19 +586,19 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) exit(-1); } */ - log_h->info_hex(grants[i].data, phy_grant.mcs.tbs/8, - "PUSCH: rnti=0x%x, prb=(%d,%d), tbs=%d, mcs=%d, rv=%d, snr=%.1f dB, n_iter=%d, crc=%s%s%s%s%s%s\n", - rnti, phy_grant.n_prb[0], phy_grant.n_prb[0]+phy_grant.L_prb, - phy_grant.mcs.tbs/8, phy_grant.mcs.idx, grants[i].grant.rv_idx, - snr_db, - srslte_pusch_last_noi(&enb_ul.pusch), - crc_res?"OK":"KO", - (acks_pending[0] || acks_pending[1])?", ack=":"", - (acks_pending[0])?(uci_data.uci_ack?"1":"0"):"", - (acks_pending[1])?(uci_data.uci_ack_2?"1":"0"):"", - uci_data.uci_cqi_len>0?cqi_str:"", - uci_data.uci_ri_len>0?(uci_data.uci_ri?", ri=0":", ri=1"):"", - timestr); + log_h->info_hex(grants[i].data, phy_grant.mcs.tbs / 8, + "PUSCH: rnti=0x%x, prb=(%d,%d), tbs=%d, mcs=%d, rv=%d, snr=%.1f dB, n_iter=%d, crc=%s%s%s%s%s%s\n", + rnti, phy_grant.n_prb[0], phy_grant.n_prb[0] + phy_grant.L_prb, + phy_grant.mcs.tbs / 8, phy_grant.mcs.idx, grants[i].grant.rv_idx, + snr_db, + srslte_pusch_last_noi(&enb_ul.pusch), + crc_res ? "OK" : "KO", + (acks_pending[0] || acks_pending[1]) ? ", ack=" : "", + (acks_pending[0]) ? (uci_data.uci_ack ? "1" : "0") : "", + (acks_pending[1]) ? (uci_data.uci_ack_2 ? "1" : "0") : "", + uci_data.uci_cqi_len > 0 ? cqi_str : "", + uci_data.uci_ri_len > 0 ? ((uci_data.uci_ri == 0) ? ", ri=0" : ", ri=1") : "", + timestr); // Notify MAC of RL status if (grants[i].grant.rv_idx == 0) { diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index 934be8aa7..f8f071005 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -1046,13 +1046,14 @@ void phch_worker::encode_pusch(srslte_ra_ul_grant_t *grant, uint8_t *payload, ui #endif uint8_t dummy[2] = {0,0}; - log_h->info("PUSCH: tti_tx=%d, alloc=(%d,%d), tbs=%d, mcs=%d, rv=%d, ack=%s, ri=%s, cfo=%.1f KHz%s\n", - (tti+HARQ_DELAY_MS)%10240, - grant->n_prb[0], grant->n_prb[0]+grant->L_prb, - grant->mcs.tbs/8, grant->mcs.idx, rv, - uci_data.uci_ack_len>0?(uci_data.uci_ack?"1":"0"):"no", - uci_data.uci_ri_len>0?(uci_data.uci_ri?"1":"0"):"no", - cfo*15, timestr); + log_h->info("PUSCH: tti_tx=%d, alloc=(%d,%d), tbs=%d, mcs=%d, rv=%d%s%s%s, cfo=%.1f KHz%s\n", + (tti + HARQ_DELAY_MS) % 10240, + grant->n_prb[0], grant->n_prb[0] + grant->L_prb, + grant->mcs.tbs / 8, grant->mcs.idx, rv, + uci_data.uci_ack_len > 0 ? (uci_data.uci_ack ? ", ack=1" : "0") : "", + uci_data.uci_ack_len > 1 ? (uci_data.uci_ack_2 ? "1" : "0") : "", + uci_data.uci_ri_len > 0 ? (uci_data.uci_ri ? ", ri=1" : ", ri=0") : "", + cfo * 15, timestr); // Store metrics ul_metrics.mcs = grant->mcs.idx;