From 0c398130c9feb4dd7bb10c4bc169fb220c7da48f Mon Sep 17 00:00:00 2001 From: ismagom Date: Fri, 19 Jun 2015 02:05:51 +0200 Subject: [PATCH] Added Periodic CQI to PUSCH. Fixed PUSCH not shortened when SRS RB are contiguous to PUSCH RB --- srsapps/ue/mac/src/mac.cc | 5 ++ srsapps/ue/phy/include/srsapps/ue/phy/phy.h | 6 ++- .../phy/include/srsapps/ue/phy/phy_params.h | 6 +++ srsapps/ue/phy/src/phy.cc | 13 +++++ srsapps/ue/phy/src/ul_buffer.cc | 12 ++++- srslte/include/srslte/phch/cqi.h | 3 ++ srslte/lib/phch/src/cqi.c | 48 +++++++++++++++++++ srslte/lib/phch/src/pusch.c | 19 ++++---- 8 files changed, 101 insertions(+), 11 deletions(-) diff --git a/srsapps/ue/mac/src/mac.cc b/srsapps/ue/mac/src/mac.cc index c5bef4cca..918c5da2b 100644 --- a/srsapps/ue/mac/src/mac.cc +++ b/srsapps/ue/mac/src/mac.cc @@ -259,6 +259,11 @@ void mac::main_radio_loop() { ul_buffer->generate_sr(); } + if (phy_h->cqi_is_ready_to_send(tti+4)) { + ul_buffer->generate_cqi_report(); + } + + // The UL buffer is released when successfully transmitted. if (ul_buffer->is_released()) { ul_buffer->ready(); diff --git a/srsapps/ue/phy/include/srsapps/ue/phy/phy.h b/srsapps/ue/phy/include/srsapps/ue/phy/phy.h index b510f5072..63a7166fe 100644 --- a/srsapps/ue/phy/include/srsapps/ue/phy/phy.h +++ b/srsapps/ue/phy/include/srsapps/ue/phy/phy.h @@ -124,9 +124,11 @@ public: void start_trace(); void write_trace(std::string filename); - void main_radio_loop(); - bool sr_is_ready_to_send(uint32_t tti); + bool sr_is_ready_to_send(uint32_t tti); + bool cqi_is_ready_to_send(uint32_t tti); + void main_radio_loop(); + private: enum { IDLE, RXTX diff --git a/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h b/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h index 621f951cd..1096eedb3 100644 --- a/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h +++ b/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h @@ -93,6 +93,12 @@ namespace ue { SRS_CS_ACKNACKSIMUL, SRS_IS_CONFIGURED, + CQI_PERIODIC_PMI_IDX, + CQI_PERIODIC_SIMULT_ACK, + CQI_PERIODIC_FORMAT_SUBBAND, + CQI_PERIODIC_FORMAT_SUBBAND_K, + CQI_PERIODIC_CONFIGURED, + UCI_I_OFFSET_ACK, UCI_I_OFFSET_RI, UCI_I_OFFSET_CQI, diff --git a/srsapps/ue/phy/src/phy.cc b/srsapps/ue/phy/src/phy.cc index b38d45ffd..9cc9f6b19 100644 --- a/srsapps/ue/phy/src/phy.cc +++ b/srsapps/ue/phy/src/phy.cc @@ -195,6 +195,19 @@ int phy::sr_last_tx_tti() { } } +bool phy::cqi_is_ready_to_send(uint32_t tti) +{ + /* + if (params_db.get_param(phy_params::CQI_PERIODIC_CONFIGURED)) { + if (srslte_cqi_send(params_db.get_param(phy_params::CQI_PERIODIC_PMI_IDX), tti)) { + Warning("Sending PUCCH CQI\n"); + return true; + } + } + */ + return false; +} + bool phy::sr_is_ready_to_send(uint32_t tti_) { if (sr_enabled) { // Get I_sr parameter diff --git a/srsapps/ue/phy/src/ul_buffer.cc b/srsapps/ue/phy/src/ul_buffer.cc index ae8212f13..c98872f0f 100644 --- a/srsapps/ue/phy/src/ul_buffer.cc +++ b/srsapps/ue/phy/src/ul_buffer.cc @@ -98,7 +98,10 @@ void ul_buffer::set_current_tx_nb(uint32_t current_tx_nb_) bool ul_buffer::generate_cqi_report() { - return false; + uci_data.uci_cqi_len = 4; + uint8_t cqi[4] = {1, 1, 1, 1}; + uci_data.uci_cqi = cqi; + return true; } bool ul_buffer::generate_sr() { @@ -216,6 +219,13 @@ bool ul_buffer::generate_data(ul_sched_grant *grant, srslte_softbuffer_tx_t *sof int n = 0; // Transmit on PUSCH if UL grant available, otherwise in PUCCH if (grant) { + + if (params_db->get_param(phy_params::CQI_PERIODIC_CONFIGURED)) { + if (srslte_cqi_send(params_db->get_param(phy_params::CQI_PERIODIC_PMI_IDX), tti)) { + generate_cqi_report(); + } + } + srslte_pusch_hopping_cfg_t pusch_hopping_cfg; bzero(&pusch_hopping_cfg, sizeof(srslte_pusch_hopping_cfg_t)); diff --git a/srslte/include/srslte/phch/cqi.h b/srslte/include/srslte/phch/cqi.h index 6c2676f7f..6c4eb9ce4 100644 --- a/srslte/include/srslte/phch/cqi.h +++ b/srslte/include/srslte/phch/cqi.h @@ -94,4 +94,7 @@ SRSLTE_API int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg uint8_t *buff, uint32_t buff_len); +SRSLTE_API bool srslte_cqi_send(uint32_t I_cqi_pmi, + uint32_t tti); + #endif // CQI_ diff --git a/srslte/lib/phch/src/cqi.c b/srslte/lib/phch/src/cqi.c index 3a05fd78b..94d292afa 100644 --- a/srslte/lib/phch/src/cqi.c +++ b/srslte/lib/phch/src/cqi.c @@ -75,3 +75,51 @@ int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t * return 4+1; } +bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) { + + uint32_t N_p = 0; + uint32_t N_offset = 0; + + if (I_cqi_pmi <= 1) { + N_p = 2; + N_offset = I_cqi_pmi; + } else if (I_cqi_pmi <= 6) { + N_p = 5; + N_offset = I_cqi_pmi - 2; + } else if (I_cqi_pmi <= 16) { + N_p = 10; + N_offset = I_cqi_pmi - 7; + } else if (I_cqi_pmi <= 36) { + N_p = 20; + N_offset = I_cqi_pmi - 17; + } else if (I_cqi_pmi <= 76) { + N_p = 40; + N_offset = I_cqi_pmi - 37; + } else if (I_cqi_pmi <= 156) { + N_p = 80; + N_offset = I_cqi_pmi - 77; + } else if (I_cqi_pmi <= 316) { + N_p = 160; + N_offset = I_cqi_pmi - 157; + } else if (I_cqi_pmi == 317) { + return false; + } else if (I_cqi_pmi <= 349) { + N_p = 32; + N_offset = I_cqi_pmi - 318; + } else if (I_cqi_pmi <= 413) { + N_p = 64; + N_offset = I_cqi_pmi - 350; + } else if (I_cqi_pmi <= 541) { + N_p = 128; + N_offset = I_cqi_pmi - 414; + } else if (I_cqi_pmi <= 1023) { + return false; + } + + if ((tti-N_offset)%N_p == 0) { + return true; + } else { + return false; + } +} + diff --git a/srslte/lib/phch/src/pusch.c b/srslte/lib/phch/src/pusch.c index ad9259757..8c5a69dd0 100644 --- a/srslte/lib/phch/src/pusch.c +++ b/srslte/lib/phch/src/pusch.c @@ -335,10 +335,18 @@ int srslte_pusch_cfg(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_dci_msg_ if (srslte_refsignal_srs_send_cs(srs_cfg->subframe_config, tti%10) == 1 && srslte_refsignal_srs_send_ue(srs_cfg->I_srs, tti) == 1) { - printf("PUSCH shorteneed for SRS UE transmission\n"); q->shortened = true; + /* If RBs are contiguous, PUSCH is not shortened */ + uint32_t k0_srs = srslte_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + uint32_t nrb_srs = srslte_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + for (uint32_t ns=0;ns<2 && q->shortened;ns++) { + if (cfg->grant.n_prb_tilde[ns] != k0_srs + nrb_srs) { + q->shortened = false; + } + } } - // If not coincides with UE transmission. PUSCH shall be shortened if cell-specific SRS transmission RB coincides with PUSCH allocated RB + // If not coincides with UE transmission. PUSCH shall be shortened if cell-specific SRS transmission RB + //coincides with PUSCH allocated RB if (!q->shortened) { uint32_t k0_srs = srslte_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); uint32_t nrb_srs = srslte_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); @@ -348,15 +356,10 @@ int srslte_pusch_cfg(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_dci_msg_ cfg->grant.n_prb_tilde[ns] + cfg->grant.L_prb < k0_srs + nrb_srs)) { q->shortened = true; - printf("CS n_prb=%d, L=%d, k0=%d, nrb=%d\n", cfg->grant.n_prb_tilde[ns], cfg->grant.L_prb, k0_srs, nrb_srs); } } } - } - - if (q->shortened) { - printf("PUSCH is shortened TTI=%d\n", tti); - } + } } /* Compute final number of bits and RE */