From f9b7b7827b7ca3b7be580752aad78c4127f36d92 Mon Sep 17 00:00:00 2001 From: ismagom Date: Sun, 7 Jun 2015 18:02:03 +0200 Subject: [PATCH] Added SRS subframe occasion for CS/UE references --- srsapps/ue/mac/src/demux.cc | 2 +- srsapps/ue/mac/test/mac_test.cc | 53 +++++++-- .../phy/include/srsapps/ue/phy/phy_params.h | 16 ++- srsapps/ue/phy/src/dl_buffer.cc | 9 ++ .../srslte/ch_estimation/refsignal_ul.h | 6 + srslte/lib/ch_estimation/src/refsignal_ul.c | 103 ++++++++++++++++++ 6 files changed, 176 insertions(+), 13 deletions(-) diff --git a/srsapps/ue/mac/src/demux.cc b/srsapps/ue/mac/src/demux.cc index 4a3bf5570..2674b2188 100644 --- a/srsapps/ue/mac/src/demux.cc +++ b/srsapps/ue/mac/src/demux.cc @@ -116,7 +116,7 @@ void demux::push_pdu(uint8_t *mac_pdu, uint32_t nof_bits) // Unpack DLSCH MAC PDU mac_msg.init(nof_bits/8); mac_msg.parse_packet(mac_pdu); - mac_msg.fprint(stdout); + //mac_msg.fprint(stdout); process_pdu(&mac_msg); Debug("Normal MAC PDU processed\n"); } diff --git a/srsapps/ue/mac/test/mac_test.cc b/srsapps/ue/mac/test/mac_test.cc index b2d207612..cb76013ed 100644 --- a/srsapps/ue/mac/test/mac_test.cc +++ b/srsapps/ue/mac/test/mac_test.cc @@ -189,30 +189,61 @@ void setup_mac_phy_sib2(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2, srslte::u sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.zero_correlation_zone_config); phy->set_param(srslte::ue::phy_params::PRACH_CONFIG_INDEX, sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_config_index); - + printf("Set PRACH ConfigCommon: SeqIdx=%d, HS=%d, FreqOffset=%d, ZC=%d, ConfigIndex=%d\n", sib2->rr_config_common_sib.prach_cnfg.root_sequence_index, sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.high_speed_flag?1:0, sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_freq_offset, sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.zero_correlation_zone_config, sib2->rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_config_index); + + // SRS ConfigCommon + if (sib2->rr_config_common_sib.srs_ul_cnfg.present) { + phy->set_param(srslte::ue::phy_params::SRS_CS_BWCFG, sib2->rr_config_common_sib.srs_ul_cnfg.bw_cnfg); + phy->set_param(srslte::ue::phy_params::SRS_CS_SFCFG, sib2->rr_config_common_sib.srs_ul_cnfg.subfr_cnfg); + phy->set_param(srslte::ue::phy_params::SRS_CS_ACKNACKSIMUL, sib2->rr_config_common_sib.srs_ul_cnfg.ack_nack_simul_tx); + phy->set_param(srslte::ue::phy_params::SRS_IS_CS_CONFIGURED, 1); + } + + printf("Set SRS ConfigCommon: BW-Configuration=%d, SF-Configuration=%d, ACKNACK=%d\n", + sib2->rr_config_common_sib.srs_ul_cnfg.bw_cnfg, + sib2->rr_config_common_sib.srs_ul_cnfg.subfr_cnfg, + sib2->rr_config_common_sib.srs_ul_cnfg.ack_nack_simul_tx); } void process_connsetup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *msg, srslte::ue::mac *mac, srslte::ue::phy *phy) { // FIXME: There's an error parsing the connectionSetup message. This value is hard-coded: - phy->set_param(srslte::ue::phy_params::PUCCH_N_PUCCH_SR, - msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx); - phy->set_param(srslte::ue::phy_params::SR_CONFIG_INDEX, - msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx); - phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_ACK, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ack_idx); - phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_CQI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_cqi_idx); - phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_RI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ri_idx); - - printf("Set PHY configuration: n_pucch=%d, configIndex=%d\n", + if (msg->rr_cnfg.phy_cnfg_ded_present) { + phy->set_param(srslte::ue::phy_params::PUCCH_N_PUCCH_SR, + msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx); + phy->set_param(srslte::ue::phy_params::SR_CONFIG_INDEX, + msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx); + phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_ACK, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ack_idx); + phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_CQI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_cqi_idx); + phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_RI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ri_idx); + + if (msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded_present && msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.setup_present) { + phy->set_param(srslte::ue::phy_params::SRS_UE_CS, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.cyclic_shift); + phy->set_param(srslte::ue::phy_params::SRS_UE_DURATION, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.duration); + phy->set_param(srslte::ue::phy_params::SRS_UE_NRRC, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.freq_domain_pos); + phy->set_param(srslte::ue::phy_params::SRS_UE_BW, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_bandwidth); + phy->set_param(srslte::ue::phy_params::SRS_UE_CONFIGINDEX, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_cnfg_idx); + phy->set_param(srslte::ue::phy_params::SRS_UE_HOP, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_hopping_bandwidth); + phy->set_param(srslte::ue::phy_params::SRS_UE_TXCOMB, msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.tx_comb); + phy->set_param(srslte::ue::phy_params::SRS_BETA, 10); + phy->set_param(srslte::ue::phy_params::SRS_IS_UE_CONFIGURED, 1); + } + } + printf("Set PHY configuration: SR-n_pucch=%d, SR-ConfigIndex=%d, SRS-ConfigIndex=%d, SRS-bw=%d, SRS-Nrcc=%d, SRS-hop=%d, SRS-Ncs=%d\n", msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx, - msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx); + msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx, + msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_cnfg_idx, + msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_bandwidth, + msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.freq_domain_pos, + msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.srs_hopping_bandwidth, + msg->rr_cnfg.phy_cnfg_ded.srs_ul_cnfg_ded.cyclic_shift); mac->set_param(srslte::ue::mac_params::HARQ_MAXTX, liblte_rrc_max_harq_tx_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.max_harq_tx]); 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 02aed5a4f..104800ce2 100644 --- a/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h +++ b/srsapps/ue/phy/include/srsapps/ue/phy/phy_params.h @@ -78,7 +78,21 @@ namespace ue { PUCCH_N_PUCCH_SR, SR_CONFIG_INDEX, - + + SRS_BETA, + SRS_UE_TXCOMB, + SRS_UE_NRRC, + SRS_UE_DURATION, + SRS_UE_CONFIGINDEX, + SRS_UE_BW, + SRS_UE_HOP, + SRS_UE_CS, + SRS_IS_UE_CONFIGURED, + SRS_CS_BWCFG, + SRS_CS_SFCFG, + SRS_CS_ACKNACKSIMUL, + SRS_IS_CS_CONFIGURED, + UCI_I_OFFSET_ACK, UCI_I_OFFSET_RI, UCI_I_OFFSET_CQI, diff --git a/srsapps/ue/phy/src/dl_buffer.cc b/srsapps/ue/phy/src/dl_buffer.cc index d937b2b23..d3379862f 100644 --- a/srsapps/ue/phy/src/dl_buffer.cc +++ b/srsapps/ue/phy/src/dl_buffer.cc @@ -116,6 +116,15 @@ bool dl_buffer::get_ul_grant(ul_sched_grant *grant) if (srslte_ue_dl_find_ul_dci(&ue_dl, &dci_msg, cfi, tti%10, grant->get_rnti()) != 1) { return false; } + /* + grant->set_shortened(false); + if (params_db->get_param(phy_params::SRS_IS_CS_CONFIGURED)) { + if (srslte_refsignal_srs_send_cs((uint32_t) params_db->get_param(phy_params::SRS_CS_SFCFG), tti%10) == 1) { + grant->set_shortened(true); + printf("UL grant tti=%d is shortened. SF-CFG=%d\n", tti, (int) params_db->get_param(phy_params::SRS_CS_SFCFG)); + } + } + */ return grant->create_from_dci(&dci_msg, cell, params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET)); } } diff --git a/srslte/include/srslte/ch_estimation/refsignal_ul.h b/srslte/include/srslte/ch_estimation/refsignal_ul.h index a362e0eb6..a7caffe5e 100644 --- a/srslte/include/srslte/ch_estimation/refsignal_ul.h +++ b/srslte/include/srslte/ch_estimation/refsignal_ul.h @@ -120,4 +120,10 @@ SRSLTE_API void srslte_refsignal_srs_gen(srslte_refsignal_ul_t *q, uint32_t sf_idx, cf_t *r_srs); +SRSLTE_API int srslte_refsignal_srs_send_cs(uint32_t subframe_config, + uint32_t sf_idx); + +SRSLTE_API int srslte_refsignal_srs_send_ue(uint32_t I_srs, + uint32_t tti); + #endif diff --git a/srslte/lib/ch_estimation/src/refsignal_ul.c b/srslte/lib/ch_estimation/src/refsignal_ul.c index e4fd7dc2a..d3438d69f 100644 --- a/srslte/lib/ch_estimation/src/refsignal_ul.c +++ b/srslte/lib/ch_estimation/src/refsignal_ul.c @@ -63,6 +63,11 @@ uint32_t pucch_dmrs_symbol_format1_cpext[2] = {2, 3}; uint32_t pucch_dmrs_symbol_format2_cpnorm[2] = {1, 5}; uint32_t pucch_dmrs_symbol_format2_cpext[1] = {3}; +/* Table 5.5.3.3-1: Frame structure type 1 sounding reference signal subframe configuration. */ +uint32_t T_sfc[15] = {1, 2, 2, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10}; +uint32_t Delta_sfc1[7] = {0, 0, 1, 0, 1, 2, 3}; +uint32_t Delta_sfc2[4] = {0, 1, 2, 3}; + /** Computes n_prs values used to compute alpha as defined in 5.5.2.1.1 of 36.211 */ static int generate_n_prs(srslte_refsignal_ul_t * q) { /* Calculate n_prs */ @@ -491,3 +496,101 @@ void srslte_refsignal_srs_gen(srslte_refsignal_ul_t *q, uint32_t ns, cf_t *r_srs { } + + +/* Returns 1 if tti is a valid subframe for SRS transmission according to I_srs (UE-specific + * configuration index), as defined in Section 8.1 of 36.213. + * Returns 0 if no SRS shall be transmitted or a negative number if error. + */ +int srslte_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti) { + if (I_srs < 1024 && tti < 10240) { + uint32_t T_srs = 0; + uint32_t Toffset = 0; + /* This is Table 8.2-1 */ + if (I_srs < 2) { + T_srs = 2; + Toffset = I_srs; + } else if (I_srs < 7) { + T_srs = 5; + Toffset = I_srs-2; + } else if (I_srs < 17) { + T_srs = 10; + Toffset = I_srs-7; + } else if (I_srs < 37) { + T_srs = 20; + Toffset = I_srs-17; + } else if (I_srs < 77) { + T_srs = 40; + Toffset = I_srs-37; + } else if (I_srs < 157) { + T_srs = 80; + Toffset = I_srs-77; + } else if (I_srs < 317) { + T_srs = 160; + Toffset = I_srs-157; + } else if (I_srs < 637) { + T_srs = 320; + Toffset = I_srs-317; + } else { + return 0; + } + if (((tti-Toffset)%T_srs) == 0) { + return 1; + } else { + return 0; + } + } else { + return SRSLTE_ERROR_INVALID_INPUTS; + } +} + +/* Returns 1 if sf_idx is a valid subframe for SRS transmission according to subframe_config (cell-specific), + * as defined in Section 5.5.3.3 of 36.211. Returns 0 if no SRS shall be transmitted or a negative + * number if error. + */ +int srslte_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx) { + if (subframe_config < 15 && sf_idx < 10) { + uint32_t tsfc = T_sfc[subframe_config]; + if (subframe_config < 7) { + if ((sf_idx%tsfc)==Delta_sfc1[subframe_config]) { + return 1; + } else { + return 0; + } + } else if (subframe_config == 8) { + if (((sf_idx%tsfc)==0) || ((sf_idx%tsfc)==1)){ + return 1; + } else { + return 0; + } + } else if (subframe_config == 9) { + if (((sf_idx%tsfc)==2) || ((sf_idx%tsfc)==3)){ + return 1; + } else { + return 0; + } + } else if (subframe_config < 13) { + if ((sf_idx%tsfc)==Delta_sfc2[subframe_config-9]) { + return 1; + } else { + return 0; + } + } else if (subframe_config == 13) { + if (((sf_idx%tsfc)==5) || ((sf_idx%tsfc)==7) || ((sf_idx%tsfc)==9)){ + return 0; + } else { + return 1; + } + } else if (subframe_config == 14) { + if (((sf_idx%tsfc)==7) || ((sf_idx%tsfc)==9)) { + return 0; + } else { + return 1; + } + } else { + return 0; + } + } else { + return SRSLTE_ERROR_INVALID_INPUTS; + } +}