From 5e41ea9d5b67e0b5192635e8817e24a841f826ec Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 22 Aug 2017 10:02:41 +0200 Subject: [PATCH 01/16] Fixes #96. Reduce TX/RX offset for 20MHz. --- lib/src/radio/radio.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index bc74660b0..872fdda7e 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -333,7 +333,7 @@ void radio::set_tx_srate(float srate) } else if (srate_khz == 15.36e3) { nsamples = 131; } else if (srate_khz == 23.04e3) { - nsamples = 175; + nsamples = 150; } else { /* Interpolate from known values */ printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); @@ -353,7 +353,7 @@ void radio::set_tx_srate(float srate) } else if (srate_khz == 15.36e3) { nsamples = 86; } else if (srate_khz == 23.04e3) { - nsamples = 119; + nsamples = 110; } else { /* Interpolate from known values */ printf("\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); From 0f9f76ff00466f578fdd6e31f761bd24ea480847 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 22 Aug 2017 15:06:32 +0200 Subject: [PATCH 02/16] calibrated configuration values --- srsenb/enb.conf.example | 8 ++++---- srsenb/rr.conf.example | 2 +- srsenb/sib.conf.example | 28 ++++++++++++++-------------- srsue/ue.conf.example | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index cfba64a30..8cc063d41 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -57,8 +57,8 @@ drb_config = drb.conf ##################################################################### [rf] dl_earfcn = 3400 -tx_gain = 70 -rx_gain = 50 +tx_gain = 80 +rx_gain = 60 #device_name = auto #device_args = auto @@ -141,9 +141,9 @@ nof_ctrl_symbols = 2 #pdsch_max_its = 4 #nof_phy_threads = 2 #pregenerate_signals = false -#tx_amplitude = 0.8 +#tx_amplitude = 0.6 #link_failure_nof_err = 50 -#rrc_inactivity_timer = 30000 +#rrc_inactivity_timer = 10000 #max_prach_offset_us = 30 ##################################################################### diff --git a/srsenb/rr.conf.example b/srsenb/rr.conf.example index 33a625359..830dd3bc6 100644 --- a/srsenb/rr.conf.example +++ b/srsenb/rr.conf.example @@ -28,7 +28,7 @@ phy_cnfg = { beta_offset_ack_idx = 10; beta_offset_ri_idx = 5; - beta_offset_cqi_idx = 5; + beta_offset_cqi_idx = 10; }; // PUCCH-SR resources are scheduled on time-frequeny domain first, then multiplexed in the same resource. diff --git a/srsenb/sib.conf.example b/srsenb/sib.conf.example index 1ccfe5465..7002f4a7f 100644 --- a/srsenb/sib.conf.example +++ b/srsenb/sib.conf.example @@ -23,9 +23,9 @@ sib2 = rach_cnfg = { num_ra_preambles = 52; - preamble_init_rx_target_pwr = -108; + preamble_init_rx_target_pwr = -104; pwr_ramping_step = 6; // in dB - preamble_trans_max = 7; + preamble_trans_max = 10; ra_resp_win_size = 10; // in ms mac_con_res_timer = 64; // in ms max_harq_msg3_tx = 4; @@ -53,7 +53,7 @@ sib2 = pdsch_cnfg = { p_b = 0; - rs_power = -4; + rs_power = 20; }; pusch_cnfg = { @@ -71,25 +71,25 @@ sib2 = }; pucch_cnfg = { - delta_pucch_shift = 1; - n_rb_cqi = 1; + delta_pucch_shift = 2; + n_rb_cqi = 2; n_cs_an = 0; - n1_pucch_an = 2; + n1_pucch_an = 12; }; ul_pwr_ctrl = { - p0_nominal_pusch = -108; - alpha = 1.0; - p0_nominal_pucch = -88; + p0_nominal_pusch = -85; + alpha = 0.7; + p0_nominal_pucch = -107; delta_flist_pucch = { - format_1 = 2; + format_1 = 0; format_1b = 3; - format_2 = 0; - format_2a = 0; - format_2b = 0; + format_2 = 1; + format_2a = 2; + format_2b = 2; }; - delta_preamble_msg3 = 4; + delta_preamble_msg3 = 8; }; ul_cp_length = "Normal"; }; diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 90d974859..8c9ba7d3d 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -23,8 +23,8 @@ [rf] dl_freq = 2685000000 ul_freq = 2565000000 -tx_gain = 70 -rx_gain = 50 +tx_gain = 80 +rx_gain = 60 #nof_rx_ant = 1 #device_name = auto From 5fed7668065872c6077639302d06e586f1a28303 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 22 Aug 2017 15:06:51 +0200 Subject: [PATCH 03/16] fixed UE not reattaching after paging --- lib/include/srslte/upper/rlc.h | 1 + lib/include/srslte/upper/rlc_entity.h | 1 + lib/src/phy/phch/uci.c | 2 +- lib/src/upper/rlc.cc | 8 ++++++++ lib/src/upper/rlc_entity.cc | 6 ++++++ srsenb/src/mac/mac.cc | 2 +- srsenb/src/main.cc | 4 ++-- srsenb/src/phy/phch_worker.cc | 5 ++--- srsenb/src/upper/rlc.cc | 4 ++-- srsenb/src/upper/rrc.cc | 6 +++--- 10 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 11ce507d5..349a7952d 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -77,6 +77,7 @@ public: // RRC interface void reset(); + void empty_queue(); void add_bearer(uint32_t lcid); void add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg); diff --git a/lib/include/srslte/upper/rlc_entity.h b/lib/include/srslte/upper/rlc_entity.h index 3747f9410..651af72fb 100644 --- a/lib/include/srslte/upper/rlc_entity.h +++ b/lib/include/srslte/upper/rlc_entity.h @@ -56,6 +56,7 @@ public: void configure(srslte_rlc_config_t cnfg); void reset(); + void empty_queue(); bool active(); rlc_mode_t get_mode(); diff --git a/lib/src/phy/phch/uci.c b/lib/src/phy/phch/uci.c index 821e5be5f..5bf40cc17 100644 --- a/lib/src/phy/phch/uci.c +++ b/lib/src/phy/phch/uci.c @@ -380,7 +380,7 @@ int decode_cqi_long(srslte_uci_cqi_pusch_t *q, int16_t *q_bits, uint32_t Q, ret = srslte_crc_checksum(&q->crc, q->tmp_cqi, nof_bits + 8); if (ret == 0) { memcpy(data, q->tmp_cqi, nof_bits*sizeof(uint8_t)); - ret = 1; + ret = 1; } else { ret = 0; } diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 9a7b50448..0cc551a1f 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -102,6 +102,14 @@ void rlc::reset() rlc_array[0].init(RLC_MODE_TM, rlc_log, default_lcid, pdcp, rrc, mac_timers); // SRB0 } +void rlc::empty_queue() +{ + for(uint32_t i=0; iempty_queue(); +} + bool rlc_entity::active() { return (rlc != NULL); diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index d45330863..5711ccce0 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -259,7 +259,7 @@ void mac::rl_failure(uint16_t rnti) if (ue_db.count(rnti)) { uint32_t nof_fails = ue_db[rnti]->rl_failure(); if (nof_fails >= (uint32_t) args.link_failure_nof_err && args.link_failure_nof_err > 0) { - Info("Detected PUSCH failure for rnti=0x%x\n", rnti); + Info("Detected Uplink failure for rnti=0x%x\n", rnti); rrc_h->rl_failure(rnti); ue_db[rnti]->rl_failure_reset(); } diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 92669ba69..bc6aedc16 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -152,7 +152,7 @@ void parse_args(all_args_t *args, int argc, char* argv[]) { "Maximum number of turbo decoder iterations") ("expert.tx_amplitude", - bpo::value(&args->expert.phy.tx_amplitude)->default_value(0.8), + bpo::value(&args->expert.phy.tx_amplitude)->default_value(0.6), "Transmit amplitude factor") ("expert.nof_phy_threads", @@ -176,7 +176,7 @@ void parse_args(all_args_t *args, int argc, char* argv[]) { "Chooses the coefficients for the 3-tap channel estimator centered filter.") ("expert.rrc_inactivity_timer", - bpo::value(&args->expert.rrc_inactivity_timer)->default_value(30000), + bpo::value(&args->expert.rrc_inactivity_timer)->default_value(10000), "Inactivity timer in ms") diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index eca637635..187d8b49f 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -109,7 +109,7 @@ void phch_worker::init(phch_common* phy_, srslte::log *log_h_) return; } - srslte_pucch_set_threshold(&enb_ul.pucch, 0.8, 0.5); + srslte_pucch_set_threshold(&enb_ul.pucch, 0.5, 0.5); srslte_sch_set_max_noi(&enb_ul.pusch.ul_sch, phy->params.pusch_max_its); srslte_enb_dl_set_amp(&enb_dl, phy->params.tx_amplitude); @@ -355,7 +355,6 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch, } if (cqi_enabled) { uci_data.uci_cqi_len = srslte_cqi_size(&cqi_value); - Info("cqi enabled len=%d\n", uci_data.uci_cqi_len); } // mark this tti as having an ul grant to avoid pucch @@ -415,7 +414,7 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch, } */ 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\n", + "PUSCH: rnti=0x%x, prb=(%d,%d), tbs=%d, mcs=%d, rv=%d, snr=%.1f dB, n_iter=%d, crc=%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, diff --git a/srsenb/src/upper/rlc.cc b/srsenb/src/upper/rlc.cc index 758a3b5b3..6147597e3 100644 --- a/srsenb/src/upper/rlc.cc +++ b/srsenb/src/upper/rlc.cc @@ -83,11 +83,11 @@ void rlc::reset(uint16_t rnti) void rlc::clear_buffer(uint16_t rnti) { if (users.count(rnti)) { - log_h->info("Clearing buffer rnti=0x%x\n", rnti); - users[rnti].rlc->reset(); + users[rnti].rlc->empty_queue(); for (int i=0;irlc_buffer_state(rnti, i, 0, 0); } + log_h->info("Cleared buffer rnti=0x%x\n", rnti); } } diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index 331efdbd5..7c06ebab7 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -313,7 +313,7 @@ void rrc::release_complete(uint16_t rnti) rlc->clear_buffer(rnti); users[rnti].send_connection_release(); // There is no RRCReleaseComplete message from UE thus sleep to enable all retx in PHY +50% - usleep(1.5*8*1e3*cfg.mac_cnfg.ulsch_cnfg.max_harq_tx); + usleep(1500*8*cfg.mac_cnfg.ulsch_cnfg.max_harq_tx); } rem_user(rnti); } else { @@ -437,7 +437,7 @@ void rrc::add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID) // Described in Section 7 of 36.304 bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len) { - int sf_pattern[4][3] = {{9, 4, 0}, {-1, 9, 4}, {-1, -1, 5}, {-1, -1, 9}}; + int sf_pattern[4][4] = {{9, 4, -1, 0}, {-1, 9, -1, 4}, {-1, -1, -1, 5}, {-1, -1, -1, 9}}; if (pending_paging.empty()) { return false; @@ -466,7 +466,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len) if ((sfn % T) == (T/N) * (ueid % N)) { - int sf_idx = sf_pattern[i_s%4][(Ns-1)%3]; + int sf_idx = sf_pattern[i_s%4][(Ns-1)%4]; if (sf_idx < 0) { rrc_log->error("SF pattern is N/A for Ns=%d, i_s=%d, imsi_decimal=%d\n", Ns, i_s, ueid); } else if ((uint32_t) sf_idx == (tti%10)) { From 49e8a2c5941bbf08fd0ed524460361c20c668cf5 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 23 Aug 2017 12:33:33 +0200 Subject: [PATCH 04/16] fixed memory leak in mac/ue --- srsenb/hdr/mac/ue.h | 4 ++++ srsenb/src/mac/ue.cc | 2 ++ 2 files changed, 6 insertions(+) diff --git a/srsenb/hdr/mac/ue.h b/srsenb/hdr/mac/ue.h index bb3597a04..ef2df2f22 100644 --- a/srsenb/hdr/mac/ue.h +++ b/srsenb/hdr/mac/ue.h @@ -58,6 +58,10 @@ public: } virtual ~ue() { + for (int i=0;i Date: Wed, 23 Aug 2017 12:43:20 +0200 Subject: [PATCH 05/16] Fixes #89. Removed sampling rate warnings --- lib/src/phy/rf/rf_uhd_imp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index 319093994..3a047ceba 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -328,7 +328,7 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_rx_antennas) if (args[0]=='\0') { if (find_string(devices_str, "type=b200") && !strstr(args, "recv_frame_size")) { // If B200 is available, use it - args = "type=b200"; + args = "type=b200,master_clock_rate=30.72e6"; handler->devname = DEVNAME_B200; } else if (find_string(devices_str, "type=x300")) { // Else if X300 is available, set master clock rate now (can't be changed later) @@ -344,6 +344,8 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_rx_antennas) handler->dynamic_rate = false; handler->devname = DEVNAME_X300; } else if (strstr(args, "type=b200")) { + snprintf(args2, sizeof(args2), "%s,master_clock_rate=30.72e6", args); + args = args2; handler->devname = DEVNAME_B200; } } @@ -399,7 +401,11 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_rx_antennas) }; handler->nof_rx_channels = nof_rx_antennas; - handler->nof_tx_channels = 1; + handler->nof_tx_channels = 1; + + /* Set default rate to avoid decimation warnings */ + uhd_usrp_set_rx_rate(handler->usrp, 1.92e6, 0); + uhd_usrp_set_tx_rate(handler->usrp, 1.92e6, 0); /* Initialize rx and tx stremers */ uhd_rx_streamer_make(&handler->rx_stream); From 616e18c5707e55197dd5b39123d1ebc4a4740e4d Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 24 Aug 2017 15:16:13 +0200 Subject: [PATCH 06/16] fixed PUCCH correlation estimator --- lib/include/srslte/phy/phch/pucch.h | 6 ++--- lib/include/srslte/phy/utils/vector.h | 3 +++ lib/src/phy/enb/enb_ul.c | 2 +- lib/src/phy/phch/pucch.c | 35 ++++++++++++++++++--------- lib/src/phy/utils/vector.c | 9 +++++++ srsenb/src/mac/ue.cc | 4 +-- srsenb/src/phy/phch_worker.cc | 6 ++--- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/include/srslte/phy/phch/pucch.h b/lib/include/srslte/phy/phch/pucch.h index 56d512418..da0b5b81e 100644 --- a/lib/include/srslte/phy/phch/pucch.h +++ b/lib/include/srslte/phy/phch/pucch.h @@ -108,7 +108,6 @@ typedef struct SRSLTE_API { bool group_hopping_en; float threshold_format1; - float threshold_format1a; float last_corr; uint32_t last_n_prb; uint32_t last_n_pucch; @@ -125,9 +124,8 @@ SRSLTE_API bool srslte_pucch_set_cfg(srslte_pucch_t* q, srslte_pucch_cfg_t* cfg, bool group_hopping_en); -SRSLTE_API void srslte_pucch_set_threshold(srslte_pucch_t *q, - float format1, - float format1a); +SRSLTE_API void srslte_pucch_set_threshold(srslte_pucch_t *q, + float format1_threshold); SRSLTE_API int srslte_pucch_set_crnti(srslte_pucch_t *q, uint16_t c_rnti); diff --git a/lib/include/srslte/phy/utils/vector.h b/lib/include/srslte/phy/utils/vector.h index 74cd60172..d203ff390 100644 --- a/lib/include/srslte/phy/utils/vector.h +++ b/lib/include/srslte/phy/utils/vector.h @@ -152,6 +152,9 @@ SRSLTE_API void srslte_vec_conj_cc(cf_t *x, cf_t *y, uint32_t len); /* average vector power */ SRSLTE_API float srslte_vec_avg_power_cf(cf_t *x, uint32_t len); +/* Correlation between complex vectors x and y */ +SRSLTE_API float srslte_vec_corr_ccc(cf_t *x, cf_t *y, uint32_t len); + /* return the index of the maximum value in the vector */ SRSLTE_API uint32_t srslte_vec_max_fi(float *x, uint32_t len); SRSLTE_API uint32_t srslte_vec_max_abs_ci(cf_t *x, uint32_t len); diff --git a/lib/src/phy/enb/enb_ul.c b/lib/src/phy/enb/enb_ul.c index 9c294ac43..9d773d6d5 100644 --- a/lib/src/phy/enb/enb_ul.c +++ b/lib/src/phy/enb/enb_ul.c @@ -91,7 +91,7 @@ int srslte_enb_ul_init(srslte_enb_ul_t *q, srslte_cell_t cell, srslte_prach_set_detect_factor(&q->prach, 60); } - srslte_pucch_set_threshold(&q->pucch, 0.5, 0.5); + srslte_pucch_set_threshold(&q->pucch, 0.8); if (srslte_chest_ul_init(&q->chest, cell)) { fprintf(stderr, "Error initiating channel estimator\n"); diff --git a/lib/src/phy/phch/pucch.c b/lib/src/phy/phch/pucch.c index 6a889b89c..928a51019 100644 --- a/lib/src/phy/phch/pucch.c +++ b/lib/src/phy/phch/pucch.c @@ -214,15 +214,15 @@ uint32_t srslte_pucch_get_npucch(uint32_t n_cce, srslte_pucch_format_t format, b { uint32_t n_pucch = 0; if (has_scheduling_request) { - n_pucch = pucch_sched->n_pucch_sr; + n_pucch = pucch_sched->n_pucch_sr; } else if (format < SRSLTE_PUCCH_FORMAT_2) { if (pucch_sched->sps_enabled) { n_pucch = pucch_sched->n_pucch_1[pucch_sched->tpc_for_pucch%4]; } else { - n_pucch = n_cce + pucch_sched->N_pucch_1; + n_pucch = n_cce + pucch_sched->N_pucch_1; } } else { - n_pucch = pucch_sched->n_pucch_2; + n_pucch = pucch_sched->n_pucch_2; } return n_pucch; } @@ -411,9 +411,8 @@ static int pucch_get(srslte_pucch_t *q, srslte_pucch_format_t format, uint32_t n return pucch_cp(q, format, n_pucch, input, z, true); } -void srslte_pucch_set_threshold(srslte_pucch_t *q, float format1, float format1a) { - q->threshold_format1 = format1; - q->threshold_format1a = format1a; +void srslte_pucch_set_threshold(srslte_pucch_t *q, float format1_threshold) { + q->threshold_format1 = format1_threshold; } /** Initializes the PDCCH transmitter and receiver */ @@ -452,6 +451,8 @@ int srslte_pucch_init(srslte_pucch_t *q, srslte_cell_t cell) { q->z_tmp = srslte_vec_malloc(sizeof(cf_t)*SRSLTE_PUCCH_MAX_SYMBOLS); q->ce = srslte_vec_malloc(sizeof(cf_t)*SRSLTE_PUCCH_MAX_SYMBOLS); + q->threshold_format1 = 0.8; + ret = SRSLTE_SUCCESS; } return ret; @@ -612,6 +613,10 @@ static int uci_mod_bits(srslte_pucch_t *q, srslte_pucch_format_t format, uint8_t // Declare this here, since we can not include refsignal_ul.h void srslte_refsignal_r_uv_arg_1prb(float *arg, uint32_t u); + +float tmp_alpha; +uint32_t tmp_noc, tmp_nprime, tmp_woc; + static int pucch_encode_(srslte_pucch_t* q, srslte_pucch_format_t format, uint32_t n_pucch, uint32_t sf_idx, uint16_t rnti, uint8_t bits[SRSLTE_PUCCH_MAX_BITS], cf_t z[SRSLTE_PUCCH_MAX_SYMBOLS], bool signal_only) @@ -655,8 +660,14 @@ static int pucch_encode_(srslte_pucch_t* q, srslte_pucch_format_t format, if (n_prime_ns%2) { S_ns = M_PI/2; } - DEBUG("PUCCH d_0: %.1f+%.1fi, alpha: %.1f, n_oc: %d, n_prime_ns: %d, n_rb_2=%d\n", + DEBUG("PUCCH d_0: %.1f+%.1fi, alpha: %.1f, n_oc: %d, n_prime_ns: %d, n_rb_2=%d\n", __real__ q->d[0], __imag__ q->d[0], alpha, n_oc, n_prime_ns, q->pucch_cfg.n_rb_2); + + tmp_alpha = alpha; + tmp_noc = n_oc; + tmp_nprime = n_prime_ns; + tmp_woc = w_n_oc[N_sf_widx][n_oc%3][m]; + for (uint32_t n=0;nd[0]*cexpf(I*(w_n_oc[N_sf_widx][n_oc%3][m]+q->tmp_arg[n]+alpha*n+S_ns)); @@ -767,7 +778,7 @@ int srslte_pucch_decode(srslte_pucch_t* q, srslte_pucch_format_t format, case SRSLTE_PUCCH_FORMAT_1: bzero(bits, SRSLTE_PUCCH_MAX_BITS*sizeof(uint8_t)); pucch_encode(q, format, n_pucch, sf_idx, rnti, bits, q->z_tmp); - corr = crealf(srslte_vec_dot_prod_conj_ccc(q->z, q->z_tmp, nof_re))/nof_re; + corr = srslte_vec_corr_ccc(q->z, q->z_tmp, nof_re); if (corr >= q->threshold_format1) { ret = 1; } else { @@ -778,11 +789,11 @@ int srslte_pucch_decode(srslte_pucch_t* q, srslte_pucch_format_t format, break; case SRSLTE_PUCCH_FORMAT_1A: bzero(bits, SRSLTE_PUCCH_MAX_BITS*sizeof(uint8_t)); - ret = 0; + ret = 0; for (int b=0;b<2;b++) { - bits[0] = b; + bits[0] = b; pucch_encode(q, format, n_pucch, sf_idx, rnti, bits, q->z_tmp); - corr = crealf(srslte_vec_dot_prod_conj_ccc(q->z, q->z_tmp, nof_re))/nof_re; + corr = srslte_vec_corr_ccc(q->z, q->z_tmp, nof_re); if (corr > corr_max) { corr_max = corr; b_max = b; @@ -790,7 +801,7 @@ int srslte_pucch_decode(srslte_pucch_t* q, srslte_pucch_format_t format, if (corr_max > q->threshold_format1) { // check with format1 in case ack+sr because ack only is binary ret = 1; } - DEBUG("format1a b=%d, corr=%f, nof_re=%d, th=%f\n", b, corr, nof_re, q->threshold_format1a); + DEBUG("format1a b=%d, corr=%f, nof_re=%d\n", b, corr, nof_re); } q->last_corr = corr_max; bits[0] = b_max; diff --git a/lib/src/phy/utils/vector.c b/lib/src/phy/utils/vector.c index 30527510d..b76c87645 100644 --- a/lib/src/phy/utils/vector.c +++ b/lib/src/phy/utils/vector.c @@ -681,6 +681,15 @@ float srslte_vec_avg_power_cf(cf_t *x, uint32_t len) { return crealf(srslte_vec_dot_prod_conj_ccc(x,x,len)) / len; } +// Correlation assumes zero-mean x and y +float srslte_vec_corr_ccc(cf_t *x, cf_t *y, uint32_t len) { +// return crealf(srslte_vec_dot_prod_conj_ccc(x,y,len)) / len; + float s_x = crealf(srslte_vec_dot_prod_conj_ccc(x, x, len))/len; + float s_y = crealf(srslte_vec_dot_prod_conj_ccc(y, y, len))/len; + float cov = crealf(srslte_vec_dot_prod_conj_ccc(x, y, len))/len; + return cov/(sqrt(s_x*s_y)); +} + void srslte_vec_abs_cf(cf_t *x, float *abs, uint32_t len) { #ifndef HAVE_VOLK_MAG_FUNCTION int i; diff --git a/srsenb/src/mac/ue.cc b/srsenb/src/mac/ue.cc index cf82b5353..123f66e46 100644 --- a/srsenb/src/mac/ue.cc +++ b/srsenb/src/mac/ue.cc @@ -248,12 +248,12 @@ bool ue::process_ce(srslte::sch_subh *subh) { idx = subh->get_bsr(buff_size); if (idx > 0) { // Indicate BSR to scheduler - sched->ul_bsr(rnti, idx, buff_size[idx]); + sched->ul_bsr(rnti, idx, 2*buff_size[idx]); Info("CE: Received BSR rnti=0x%x, lcid=%d, value=%d\n", rnti, idx, buff_size[idx]); } else if (idx == 0) { // TODO: map lcid group to lcid for (int i=0;i<4;i++) { - sched->ul_bsr(rnti, i, buff_size[i]); + sched->ul_bsr(rnti, i, 2*buff_size[i]); } Info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n", rnti, buff_size[0], buff_size[1], buff_size[2], buff_size[3]); diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index 187d8b49f..095a4643c 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -109,7 +109,7 @@ void phch_worker::init(phch_common* phy_, srslte::log *log_h_) return; } - srslte_pucch_set_threshold(&enb_ul.pucch, 0.5, 0.5); + srslte_pucch_set_threshold(&enb_ul.pucch, 0.8); srslte_sch_set_max_noi(&enb_ul.pusch.ul_sch, phy->params.pusch_max_its); srslte_enb_dl_set_amp(&enb_dl, phy->params.tx_amplitude); @@ -178,8 +178,8 @@ void phch_worker::set_config_dedicated(uint16_t rnti, srslte_enb_ul_cfg_ue(&enb_ul, rnti, uci_cfg, pucch_sched, srs_cfg); ue_db[rnti].I_sr = I_sr; - ue_db[rnti].I_sr_en = true; - + ue_db[rnti].I_sr_en = true; + if (pucch_cqi) { ue_db[rnti].pmi_idx = pmi_idx; ue_db[rnti].cqi_en = true; From 955170bd52dbf15b1c8e6fb2c0041b7ffe5cb9b7 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 28 Aug 2017 10:06:12 +0200 Subject: [PATCH 07/16] Improved DL TCP performance by tweeking BSR reports and UL scheduler --- .../srslte/interfaces/sched_interface.h | 5 +- lib/src/common/pdu.cc | 10 +- srsenb/drb.conf.example | 6 +- srsenb/hdr/mac/scheduler.h | 2 +- srsenb/hdr/mac/scheduler_harq.h | 3 +- srsenb/hdr/mac/scheduler_ue.h | 11 +- srsenb/hdr/mac/ue.h | 8 +- srsenb/rr.conf.example | 2 +- srsenb/src/mac/mac.cc | 5 +- srsenb/src/mac/scheduler.cc | 20 ++- srsenb/src/mac/scheduler_harq.cc | 17 ++- srsenb/src/mac/scheduler_ue.cc | 18 ++- srsenb/src/mac/ue.cc | 133 +++++++++++------- srsenb/src/upper/rrc.cc | 4 + srsue/ue.conf.example | 2 +- 15 files changed, 165 insertions(+), 81 deletions(-) diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index 63ab92121..a717b4293 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -94,7 +94,8 @@ public: typedef struct { int priority; int bsd; - int pbr; + int pbr; + int group; enum {IDLE = 0, UL, DL, BOTH} direction; } ue_bearer_cfg_t; @@ -231,7 +232,7 @@ public: /* UL information */ virtual int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc) = 0; virtual int ul_sr_info(uint32_t tti, uint16_t rnti) = 0; - virtual int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr) = 0; + virtual int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true) = 0; virtual int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len) = 0; virtual int ul_phr(uint16_t rnti, int phr) = 0; virtual int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code) = 0; diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index c54636fcd..57bc07043 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -33,7 +33,7 @@ // Table 6.1.3.1-1 Buffer size levels for BSR static uint32_t btable[64] = { - 0, 5, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, 107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, 967, 1132, + 0, 1, 10, 12, 14, 17, 19, 22, 26, 31, 36, 42, 49, 57, 67, 78, 91, 107, 125, 146, 171, 200, 234, 274, 321, 376, 440, 515, 603, 706, 826, 967, 1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4667, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, 68201, 79846, 93479, 109439, 128125, 150000}; @@ -428,12 +428,16 @@ int sch_subh::get_bsr(uint32_t buff_size[4]) buff_size[2] = (payload[1]&0x0F) << 4 | (payload[1]&0xC0) >> 6; buff_size[3] = (payload[2]&0x3F); } else { - uint32_t nonzero_lcg = (payload[0]&0xc0) >> 6; + nonzero_lcg = (payload[0]&0xc0) >> 6; buff_size[nonzero_lcg%4] = payload[0]&0x3f; } for (int i=0;i<4;i++) { if (buff_size[i]) { - buff_size[i] = btable[buff_size[i]%64]; + if (buff_size[i]<63) { + buff_size[i] = btable[1+buff_size[i]]; + } else { + buff_size[i] = btable[63]; + } } } return nonzero_lcg; diff --git a/srsenb/drb.conf.example b/srsenb/drb.conf.example index 4a2eab0d6..0f8e83372 100644 --- a/srsenb/drb.conf.example +++ b/srsenb/drb.conf.example @@ -15,14 +15,14 @@ qci_config = ( }; dl_um = { sn_field_length = 10; - t_reordering = 80; + t_reordering = 45; }; }; logical_channel_config = { - priority = 11; + priority = 13; prioritized_bit_rate = -1; bucket_size_duration = 100; - log_chan_group = 3; + log_chan_group = 2; }; }, { diff --git a/srsenb/hdr/mac/scheduler.h b/srsenb/hdr/mac/scheduler.h index 74ca8cc95..66f8998c1 100644 --- a/srsenb/hdr/mac/scheduler.h +++ b/srsenb/hdr/mac/scheduler.h @@ -108,7 +108,7 @@ public: int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc); int ul_sr_info(uint32_t tti, uint16_t rnti); - int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr); + int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true); int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len); int ul_phr(uint16_t rnti, int phr); int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code); diff --git a/srsenb/hdr/mac/scheduler_harq.h b/srsenb/hdr/mac/scheduler_harq.h index 9a38306ae..2e09136f9 100644 --- a/srsenb/hdr/mac/scheduler_harq.h +++ b/srsenb/hdr/mac/scheduler_harq.h @@ -104,7 +104,8 @@ public: void set_alloc(ul_alloc_t alloc); void same_alloc(); bool is_adaptive_retx(); - + + void reset_pending_data(); bool has_pending_ack(); uint32_t get_pending_data(); diff --git a/srsenb/hdr/mac/scheduler_ue.h b/srsenb/hdr/mac/scheduler_ue.h index fa38b2396..1cb223e57 100644 --- a/srsenb/hdr/mac/scheduler_ue.h +++ b/srsenb/hdr/mac/scheduler_ue.h @@ -62,7 +62,7 @@ public: void rem_bearer(uint32_t lc_id); void dl_buffer_state(uint8_t lc_id, uint32_t tx_queue, uint32_t retx_queue); - void ul_buffer_state(uint8_t lc_id, uint32_t bsr); + void ul_buffer_state(uint8_t lc_id, uint32_t bsr, bool set_value = true); void ul_phr(int phr); void mac_buffer_state(uint32_t ce_code); void ul_recv_len(uint32_t lcid, uint32_t len); @@ -114,8 +114,10 @@ public: uint32_t get_max_retx(); bool get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2], uint32_t *L); - bool pucch_sr_collision(uint32_t current_tti, uint32_t n_cce); - + bool pucch_sr_collision(uint32_t current_tti, uint32_t n_cce); + + uint32_t get_pending_ul_old_data(); + private: typedef struct { @@ -126,8 +128,7 @@ private: } ue_bearer_t; bool is_sr_triggered(); - uint32_t get_pending_ul_old_data(); - int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu); + int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu); static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb); static int cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t *mcs); diff --git a/srsenb/hdr/mac/ue.h b/srsenb/hdr/mac/ue.h index ef2df2f22..b98b07f9d 100644 --- a/srsenb/hdr/mac/ue.h +++ b/srsenb/hdr/mac/ue.h @@ -85,7 +85,9 @@ public: uint32_t rl_failure(); void rl_failure_reset(); - + + void set_lcg(uint32_t lcid, uint32_t lcg); + void metrics_read(srsenb::mac_metrics_t* metrics); void metrics_rx(bool crc, uint32_t tbs); void metrics_tx(bool crc, uint32_t tbs); @@ -100,7 +102,9 @@ private: void allocate_ce(srslte::sch_pdu *pdu, uint32_t lcid); void metrics_phr(float phr); - uint32_t phr_counter; + uint32_t phr_counter; + + std::vector lc_groups[4]; mac_metrics_t metrics; diff --git a/srsenb/rr.conf.example b/srsenb/rr.conf.example index 830dd3bc6..af6dcf2c1 100644 --- a/srsenb/rr.conf.example +++ b/srsenb/rr.conf.example @@ -9,7 +9,7 @@ mac_cnfg = ulsch_cnfg = { max_harq_tx = 4; - periodic_bsr_timer = 5; // in ms + periodic_bsr_timer = 40; // in ms retx_bsr_timer = 320; // in ms }; diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index 5711ccce0..fb2c3110e 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include "srslte/common/log.h" #include "mac/mac.h" @@ -163,7 +164,9 @@ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) { - if (ue_db.count(rnti)) { + if (ue_db.count(rnti)) { + // configure BSR group in UE + ue_db[rnti]->set_lcg(lc_id, (uint32_t) cfg->group); return scheduler.bearer_ue_cfg(rnti, lc_id, cfg); } else { Error("User rnti=0x%x not found\n", rnti); diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index 5a9a8a6e5..12a7ea1cc 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -302,12 +302,12 @@ int sched::ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch return ret; } -int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr) +int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value) { pthread_mutex_lock(&mutex); int ret = 0; if (ue_db.count(rnti)) { - ue_db[rnti].ul_buffer_state(lcid, bsr); + ue_db[rnti].ul_buffer_state(lcid, bsr, set_value); } else { Error("User rnti=0x%x not found\n", rnti); ret = -1; @@ -792,13 +792,13 @@ int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched user->unset_sr(); } - log_h->info("SCHED: %s %s rnti=0x%x, pid=%d, dci=%d,%d, grant=%d,%d, n_rtx=%d, tbs=%d, bsr=%d (%d)\n", + log_h->info("SCHED: %s %s rnti=0x%x, pid=%d, dci=%d,%d, grant=%d,%d, n_rtx=%d, tbs=%d, bsr=%d (%d-%d)\n", is_rar?"RAR":"UL", is_newtx?"tx":"retx", rnti, h->get_id(), sched_result->pusch[nof_dci_elems].dci_location.L, sched_result->pusch[nof_dci_elems].dci_location.ncce, alloc.RB_start, alloc.L, h->nof_retx(), sched_result->pusch[nof_dci_elems].tbs, - user->get_pending_ul_new_data(current_tti),pending_data_before); + user->get_pending_ul_new_data(current_tti),pending_data_before, user->get_pending_ul_old_data()); nof_dci_elems++; } else { @@ -812,8 +812,16 @@ int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched } } } - } - + } + + // Update pending data counters after this TTI + for(std::map::iterator iter=ue_db.begin(); iter!=ue_db.end(); ++iter) { + sched_ue *user = (sched_ue *) &iter->second; + uint16_t rnti = (uint16_t) iter->first; + + user->get_ul_harq(current_tti)->reset_pending_data(); + } + sched_result->nof_dci_elems = nof_dci_elems; sched_result->nof_phich_elems = nof_phich_elems; diff --git a/srsenb/src/mac/scheduler_harq.cc b/srsenb/src/mac/scheduler_harq.cc index 4651b5533..009872153 100644 --- a/srsenb/src/mac/scheduler_harq.cc +++ b/srsenb/src/mac/scheduler_harq.cc @@ -98,7 +98,7 @@ bool harq_proc::get_ack() void harq_proc::set_ack(bool ack_) { ack = ack_; - ack_received = true; + ack_received = true; log_h->debug("ACK=%d received pid=%d, n_rtx=%d, max_retx=%d\n", ack_, id, n_rtx, max_retx); if (n_rtx >= max_retx) { Warning("SCHED: discarting TB pid=%d, tti=%d, maximum number of retx exceeded (%d)\n", id, tti, max_retx); @@ -229,13 +229,22 @@ bool ul_harq_proc::has_pending_ack() active = false; } if (!active) { - pending_data = 0; - need_ack = false; + need_ack = false; } return ret; } -uint32_t ul_harq_proc::get_pending_data() + + +void ul_harq_proc::reset_pending_data() +{ + if (!active) { + pending_data = 0; + } +} + + + uint32_t ul_harq_proc::get_pending_data() { return pending_data; } diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 178fe6446..5545efb51 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -163,12 +163,18 @@ void sched_ue::phy_config_enabled(uint32_t tti, bool enabled) phy_config_dedicated_enabled = enabled; } -void sched_ue::ul_buffer_state(uint8_t lc_id, uint32_t bsr) +void sched_ue::ul_buffer_state(uint8_t lc_id, uint32_t bsr, bool set_value) { if (lc_id < sched_interface::MAX_LC) { - lch[lc_id].bsr = bsr; + if (set_value) { + lch[lc_id].bsr = bsr; + } else { + lch[lc_id].bsr += bsr; + } Debug("SCHED: UL lcid=%d buffer_state=%d\n", lc_id, bsr); - } + } + Info("SCHED: bsr=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", bsr, lc_id, + lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr); } void sched_ue::ul_phr(int phr) @@ -297,6 +303,8 @@ void sched_ue::ul_recv_len(uint32_t lcid, uint32_t len) } } } + Info("SCHED: recv_len=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", len, lcid, + lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr); } void sched_ue::set_ul_crc(uint32_t tti, bool crc_res) @@ -554,6 +562,10 @@ uint32_t sched_ue::get_pending_ul_new_data(uint32_t tti) } else { pending_data = 0; } + if (pending_data) { + Info("SCHED: pending_data=%d, pending_ul_data=%d, bsr={%d,%d,%d,%d}\n", pending_data,pending_ul_data, + lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr); + } return pending_data; } diff --git a/srsenb/src/mac/ue.cc b/srsenb/src/mac/ue.cc index 123f66e46..b338a202d 100644 --- a/srsenb/src/mac/ue.cc +++ b/srsenb/src/mac/ue.cc @@ -58,6 +58,10 @@ void ue::config(uint16_t rnti_, uint32_t nof_prb, sched_interface *sched_, rrc_i for(int i=0;iwrite_ul_crnti(pdu, nof_bytes, rnti, true, last_tti); } + + uint32_t lcid_most_data = 0; + int most_data = -99; while(mac_msg_ul.next()) { assert(mac_msg_ul.get()); - if (mac_msg_ul.get()->is_sdu()) - { + if (mac_msg_ul.get()->is_sdu()) { // Route logical channel - log_h->debug_hex(mac_msg_ul.get()->get_sdu_ptr(), mac_msg_ul.get()->get_payload_size(), - "PDU: rnti=0x%x, lcid=%d, %d bytes\n", - rnti, mac_msg_ul.get()->get_sdu_lcid(), mac_msg_ul.get()->get_payload_size()); - - + log_h->debug_hex(mac_msg_ul.get()->get_sdu_ptr(), mac_msg_ul.get()->get_payload_size(), + "PDU: rnti=0x%x, lcid=%d, %d bytes\n", + rnti, mac_msg_ul.get()->get_sdu_lcid(), mac_msg_ul.get()->get_payload_size()); + + /* In some cases, an uplink transmission with only CQI has all zeros and gets routed to RRC * Compute the checksum if lcid=0 and avoid routing in that case */ - bool route_pdu = true; + bool route_pdu = true; if (mac_msg_ul.get()->get_sdu_lcid() == 0) { uint8_t *x = mac_msg_ul.get()->get_sdu_ptr(); - uint32_t sum = 0; - for (uint32_t i=0;iget_payload_size();i++) { + uint32_t sum = 0; + for (uint32_t i = 0; i < mac_msg_ul.get()->get_payload_size(); i++) { sum += x[i]; } if (sum == 0) { - route_pdu = false; + route_pdu = false; Warning("Received all zero PDU\n"); } } - + if (route_pdu) { - rlc->write_pdu(rnti, - mac_msg_ul.get()->get_sdu_lcid(), - mac_msg_ul.get()->get_sdu_ptr(), - mac_msg_ul.get()->get_payload_size()); + rlc->write_pdu(rnti, + mac_msg_ul.get()->get_sdu_lcid(), + mac_msg_ul.get()->get_sdu_ptr(), + mac_msg_ul.get()->get_payload_size()); } - + // Indicate scheduler to update BSR counters sched->ul_recv_len(rnti, mac_msg_ul.get()->get_sdu_lcid(), mac_msg_ul.get()->get_payload_size()); - + + if ((int) mac_msg_ul.get()->get_payload_size() > most_data) { + most_data = (int) mac_msg_ul.get()->get_payload_size(); + lcid_most_data = mac_msg_ul.get()->get_sdu_lcid(); + } + // Save contention resolution if lcid == 0 if (mac_msg_ul.get()->get_sdu_lcid() == 0 && route_pdu) { - uint32_t nbytes = srslte::sch_subh::MAC_CE_CONTRES_LEN; + uint32_t nbytes = srslte::sch_subh::MAC_CE_CONTRES_LEN; if (mac_msg_ul.get()->get_payload_size() >= nbytes) { - uint8_t *ue_cri_ptr = (uint8_t*) &conres_id; - uint8_t *pkt_ptr = mac_msg_ul.get()->get_sdu_ptr(); // Warning here: we want to include the - for (uint32_t i=0;iget_sdu_ptr(); // Warning here: we want to include the + for (uint32_t i = 0; i < nbytes; i++) { + ue_cri_ptr[nbytes - i - 1] = pkt_ptr[i]; } } else { Error("Received CCCH UL message of invalid size=%d bytes\n", mac_msg_ul.get()->get_payload_size()); } - } - } else { - // Process MAC Control Element - if (!process_ce(mac_msg_ul.get())) { - Warning("Received Subheader with invalid or unkonwn LCID\n"); } } - } + } + mac_msg_ul.reset(); + + /* Process CE after all SDUs because we need to update BSR after */ + bool bsr_received = false; + while(mac_msg_ul.next()) { + assert(mac_msg_ul.get()); + if (!mac_msg_ul.get()->is_sdu()) { + // Process MAC Control Element + bsr_received |= process_ce(mac_msg_ul.get()); + } + } + + // If BSR is not received means that new data has arrived and there is no space for BSR transmission + if (!bsr_received && lcid_most_data > 2) { + // Add BSR to the LCID for which most data was received + sched->ul_bsr(rnti, lcid_most_data, 256, false); // false adds BSR instead of setting + Info("BSR not received. Giving extra grant\n"); + } Debug("MAC PDU processed\n"); @@ -222,9 +255,10 @@ void ue::push_pdu(uint32_t tti, uint32_t len) bool ue::process_ce(srslte::sch_subh *subh) { uint32_t buff_size[4] = {0, 0, 0, 0}; - uint32_t idx = 0; - float phr = 0; - uint16_t old_rnti = 0; + float phr = 0; + int idx = 0; + uint16_t old_rnti = 0; + bool is_bsr = false; switch(subh->ce_type()) { case srslte::sch_subh::PHR_REPORT: phr = subh->get_phr(); @@ -243,23 +277,26 @@ bool ue::process_ce(srslte::sch_subh *subh) { } break; case srslte::sch_subh::TRUNC_BSR: - case srslte::sch_subh::SHORT_BSR: - case srslte::sch_subh::LONG_BSR: + case srslte::sch_subh::SHORT_BSR: idx = subh->get_bsr(buff_size); - if (idx > 0) { - // Indicate BSR to scheduler - sched->ul_bsr(rnti, idx, 2*buff_size[idx]); - Info("CE: Received BSR rnti=0x%x, lcid=%d, value=%d\n", rnti, idx, buff_size[idx]); - } else if (idx == 0) { - // TODO: map lcid group to lcid - for (int i=0;i<4;i++) { - sched->ul_bsr(rnti, i, 2*buff_size[i]); + for (uint32_t i=0;iul_bsr(rnti, lc_groups[idx][i], buff_size[idx]); + Info("CE: Received %s BSR rnti=0x%x, lcg=%d, lcid=%d, value=%d\n", + subh->ce_type()==srslte::sch_subh::SHORT_BSR?"Short":"Trunc", rnti, idx, lc_groups[idx][i], buff_size[idx]); + } + is_bsr = true; + break; + case srslte::sch_subh::LONG_BSR: + subh->get_bsr(buff_size); + for (int idx=0;idx<4;idx++) { + for (uint32_t i=0;iul_bsr(rnti, lc_groups[idx][i], buff_size[idx]); } - Info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n", rnti, - buff_size[0], buff_size[1], buff_size[2], buff_size[3]); - } else { - printf("Error!\n"); } + is_bsr = true; + Info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n", rnti, + buff_size[0], buff_size[1], buff_size[2], buff_size[3]); break; case srslte::sch_subh::PADDING: Debug("CE: Received padding for rnti=0x%x\n", rnti); @@ -268,7 +305,7 @@ bool ue::process_ce(srslte::sch_subh *subh) { Error("CE: Invalid lcid=0x%x\n", subh->ce_type()); break; } - return true; + return is_bsr; } diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index 7c06ebab7..de1c61b9e 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -24,6 +24,8 @@ * */ +#include +#include #include "srslte/asn1/liblte_mme.h" #include "upper/rrc.h" @@ -1311,7 +1313,9 @@ void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) // Add SRB2 and DRB1 to the scheduler srsenb::sched_interface::ue_bearer_cfg_t bearer_cfg; bearer_cfg.direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + bearer_cfg.group = 0; parent->mac->bearer_ue_cfg(rnti, 2, &bearer_cfg); + bearer_cfg.group = conn_reconf->rr_cnfg_ded.drb_to_add_mod_list[0].lc_cnfg.ul_specific_params.log_chan_group; parent->mac->bearer_ue_cfg(rnti, 3, &bearer_cfg); // Configure SRB2 in RLC and PDCP diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 8c9ba7d3d..532bb9849 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -26,7 +26,7 @@ ul_freq = 2565000000 tx_gain = 80 rx_gain = 60 -#nof_rx_ant = 1 +nof_rx_ant = 2 #device_name = auto #device_args = auto #time_adv_nsamples = auto From 0ca8c8aac698cbcb18fba5d2a011bdc27409b07d Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 28 Aug 2017 16:49:53 +0200 Subject: [PATCH 08/16] considering PUCCH2 in PUSCH scheduler --- srsenb/src/mac/scheduler_ue.cc | 30 +++++++++++++++++++++++------- srsenb/src/mac/ue.cc | 6 +++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 5545efb51..b217a8157 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -26,6 +26,7 @@ #include #include +#include #include "srslte/srslte.h" #include "srslte/common/pdu.h" @@ -171,9 +172,8 @@ void sched_ue::ul_buffer_state(uint8_t lc_id, uint32_t bsr, bool set_value) } else { lch[lc_id].bsr += bsr; } - Debug("SCHED: UL lcid=%d buffer_state=%d\n", lc_id, bsr); } - Info("SCHED: bsr=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", bsr, lc_id, + Debug("SCHED: bsr=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", bsr, lc_id, lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr); } @@ -245,7 +245,7 @@ bool sched_ue::get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2], uint32 // First check if it has pending ACKs for (int i=0;i 2) { // Add BSR to the LCID for which most data was received sched->ul_bsr(rnti, lcid_most_data, 256, false); // false adds BSR instead of setting - Info("BSR not received. Giving extra grant\n"); + Debug("BSR not received. Giving extra grant\n"); } Debug("MAC PDU processed\n"); @@ -282,9 +282,9 @@ bool ue::process_ce(srslte::sch_subh *subh) { for (uint32_t i=0;iul_bsr(rnti, lc_groups[idx][i], buff_size[idx]); - Info("CE: Received %s BSR rnti=0x%x, lcg=%d, lcid=%d, value=%d\n", - subh->ce_type()==srslte::sch_subh::SHORT_BSR?"Short":"Trunc", rnti, idx, lc_groups[idx][i], buff_size[idx]); } + Info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d\n", + subh->ce_type()==srslte::sch_subh::SHORT_BSR?"Short":"Trunc", rnti, idx, buff_size[idx]); is_bsr = true; break; case srslte::sch_subh::LONG_BSR: From 2832ece415db43e5b9ea8486ba6bd5a346e517cf Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 28 Aug 2017 18:41:23 +0200 Subject: [PATCH 09/16] Fixed SCTP stream id to 1. --- srsenb/src/upper/s1ap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srsenb/src/upper/s1ap.cc b/srsenb/src/upper/s1ap.cc index 032a6018f..9328060e6 100644 --- a/srsenb/src/upper/s1ap.cc +++ b/srsenb/src/upper/s1ap.cc @@ -173,7 +173,7 @@ void s1ap::build_tai_cgi() void s1ap::initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu) { ue_ctxt_map[rnti].eNB_UE_S1AP_ID = next_eNB_UE_S1AP_ID++; - ue_ctxt_map[rnti].stream_id = next_ue_stream_id++; + ue_ctxt_map[rnti].stream_id = 1; ue_ctxt_map[rnti].release_requested = false; enbid_to_rnti_map[ue_ctxt_map[rnti].eNB_UE_S1AP_ID] = rnti; send_initialuemessage(rnti, pdu, false); @@ -182,7 +182,7 @@ void s1ap::initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu) void s1ap::initial_ue(uint16_t rnti, srslte::byte_buffer_t *pdu, uint32_t m_tmsi, uint8_t mmec) { ue_ctxt_map[rnti].eNB_UE_S1AP_ID = next_eNB_UE_S1AP_ID++; - ue_ctxt_map[rnti].stream_id = next_ue_stream_id++; + ue_ctxt_map[rnti].stream_id = 1; ue_ctxt_map[rnti].release_requested = false; enbid_to_rnti_map[ue_ctxt_map[rnti].eNB_UE_S1AP_ID] = rnti; send_initialuemessage(rnti, pdu, true, m_tmsi, mmec); From c10f13139ef47aa6ead92a34b69d6d183ed6d6da Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 10:09:56 +0200 Subject: [PATCH 10/16] Added default value for filter coefficient in UL power control dedicated --- srsue/src/upper/rrc.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 8bb327b9d..80a6303b4 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -27,6 +27,7 @@ #include #include +#include #include "upper/rrc.h" #include "srslte/phy/utils/bit.h" @@ -1084,8 +1085,11 @@ void rrc::apply_phy_config_dedicated(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT current_cfg->ul_pwr_ctrl_ded.accumulation_en = true; current_cfg->ul_pwr_ctrl_ded.p0_ue_pucch = 0; current_cfg->ul_pwr_ctrl_ded.p_srs_offset = 7; - current_cfg->ul_pwr_ctrl_ded.filter_coeff = LIBLTE_RRC_FILTER_COEFFICIENT_FC4; - current_cfg->ul_pwr_ctrl_ded.filter_coeff_present = true; + } + if (phy_cnfg->ul_pwr_ctrl_ded.filter_coeff_present) { + current_cfg->ul_pwr_ctrl_ded.filter_coeff = current_cfg->ul_pwr_ctrl_ded.filter_coeff; + } else { + current_cfg->ul_pwr_ctrl_ded.filter_coeff = LIBLTE_RRC_FILTER_COEFFICIENT_FC4; } if(phy_cnfg->tpc_pdcch_cnfg_pucch_present) { memcpy(¤t_cfg->tpc_pdcch_cnfg_pucch, &phy_cnfg->tpc_pdcch_cnfg_pucch, sizeof(LIBLTE_RRC_TPC_PDCCH_CONFIG_STRUCT)); From 9997f8c20ae4a36838b5f87a5cd7d0daef95f876 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 11:22:39 +0200 Subject: [PATCH 11/16] (fix typo) Added default value for filter coefficient in UL power control dedicated --- srsue/src/upper/rrc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 80a6303b4..58015030d 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -1087,7 +1087,7 @@ void rrc::apply_phy_config_dedicated(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT current_cfg->ul_pwr_ctrl_ded.p_srs_offset = 7; } if (phy_cnfg->ul_pwr_ctrl_ded.filter_coeff_present) { - current_cfg->ul_pwr_ctrl_ded.filter_coeff = current_cfg->ul_pwr_ctrl_ded.filter_coeff; + current_cfg->ul_pwr_ctrl_ded.filter_coeff = phy_cnfg->ul_pwr_ctrl_ded.filter_coeff; } else { current_cfg->ul_pwr_ctrl_ded.filter_coeff = LIBLTE_RRC_FILTER_COEFFICIENT_FC4; } From 51fc9bffb1589282e4c1ffa158f911a08a6aca5d Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 12:01:30 +0200 Subject: [PATCH 12/16] added release function for mac timers --- lib/include/srslte/common/timers.h | 37 +++++++++++++++++++++++------- srsue/src/upper/rrc.cc | 11 +++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/common/timers.h b/lib/include/srslte/common/timers.h index 56e40e152..377df7b1d 100644 --- a/lib/include/srslte/common/timers.h +++ b/lib/include/srslte/common/timers.h @@ -97,11 +97,13 @@ public: bool running; }; - timers(uint32_t nof_timers_) : timer_list(nof_timers_) { + timers(uint32_t nof_timers_) : timer_list(nof_timers_),used_timers(nof_timers_) { nof_timers = nof_timers_; next_timer = 0; + nof_used_timers = 0; for (uint32_t i=0;i 0 && i < nof_timers) { + used_timers[i] = false; + nof_used_timers--; + } else { + fprintf(stderr, "Error releasing timer: nof_used_timers=%d, nof_timers=%d\n", nof_used_timers, nof_timers); + } + } uint32_t get_unique_id() { - if (next_timer == nof_timers){ - printf("No more unique timer ids (Only %d timers available)\n", nof_timers); - next_timer = 0; + if (nof_used_timers >= nof_timers) { + fprintf(stderr, "Error getting uinque timer id: no more timers available\n"); + return 0; + } else { + while(used_timers[next_timer]) { + next_timer++; + if (next_timer >= nof_timers) { + next_timer=0; + } + } + used_timers[next_timer] = true; + nof_used_timers++; + return next_timer; } - return next_timer++; } private: - uint32_t nof_timers; uint32_t next_timer; - std::vector timer_list; + uint32_t nof_used_timers; + uint32_t nof_timers; + std::vector timer_list; + std::vector used_timers; }; } // namespace srslte diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 58015030d..291024c05 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -79,7 +79,14 @@ void rrc::init(phy_interface_rrc *phy_, nas = nas_; usim = usim_; rrc_log = rrc_log_; + + // Use MAC timers mac_timers = mac_timers_; + t301 = mac_timers->get_unique_id(); + t310 = mac_timers->get_unique_id(); + t311 = mac_timers->get_unique_id(); + safe_reset_timer = mac_timers->get_unique_id(); + pthread_mutex_init(&mutex, NULL); @@ -1492,10 +1499,6 @@ void rrc::set_mac_default() void rrc::set_rrc_default() { N310 = 1; N311 = 1; - t301 = mac_timers->get_unique_id(); - t310 = mac_timers->get_unique_id(); - t311 = mac_timers->get_unique_id(); - safe_reset_timer = mac_timers->get_unique_id(); mac_timers->get(t310)->set(this, 1000); mac_timers->get(t311)->set(this, 1000); mac_timers->get(safe_reset_timer)->set(this, 10); From b7a91b597190426748db155c02cdee486976f621 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 12:20:47 +0200 Subject: [PATCH 13/16] fixed unititiazed pucch_sched in sched_ue::get_pucch_sched --- srsenb/src/mac/scheduler_ue.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index b217a8157..0d5dd87bb 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include "srslte/srslte.h" #include "srslte/common/pdu.h" @@ -236,7 +237,8 @@ bool sched_ue::get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2], uint32 if (!phy_config_dedicated_enabled) { return false; } - srslte_pucch_sched_t pucch_sched; + srslte_pucch_sched_t pucch_sched; + pucch_sched.sps_enabled = false; pucch_sched.n_pucch_sr = cfg.sr_N_pucch; pucch_sched.n_pucch_2 = cfg.n_pucch_cqi; pucch_sched.N_pucch_1 = cfg.pucch_cfg.n1_pucch_an; @@ -255,8 +257,7 @@ bool sched_ue::get_pucch_sched(uint32_t current_tti, uint32_t prb_idx[2], uint32 if (L) { *L = 1; } - Info("SCHED: Reserved Format1A PUCCH for rnti=0x%x, n_prb=%d,%d, n_pucch=%d, n_cce=%d, has_sr=%d\n", - rnti, prb_idx[0], prb_idx[1], n_pucch, dl_harq[i].get_n_cce(), has_sr); + Info("SCHED: Reserved Format1A PUCCH for rnti=0x%x, n_prb=%d,%d, n_pucch=%d\n", rnti, prb_idx[0], prb_idx[1], n_pucch); return true; } } From 8a25cac41bc71fc26c8d2d1516c4cf02765acc9e Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 15:07:47 +0200 Subject: [PATCH 14/16] increased timeout for RRCConnectionRelease transmission --- srsenb/src/upper/rrc.cc | 5 ++--- srsenb/src/upper/s1ap.cc | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index de1c61b9e..03ea65f2c 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -314,12 +314,11 @@ void rrc::release_complete(uint16_t rnti) if (!users[rnti].is_idle()) { rlc->clear_buffer(rnti); users[rnti].send_connection_release(); - // There is no RRCReleaseComplete message from UE thus sleep to enable all retx in PHY +50% - usleep(1500*8*cfg.mac_cnfg.ulsch_cnfg.max_harq_tx); + // There is no RRCReleaseComplete message from UE thus wait ~100 subframes for tx + usleep(100000); } rem_user(rnti); } else { - rrc_log->error("Received ReleaseComplete for unknown rnti=0x%x\n", rnti); } } diff --git a/srsenb/src/upper/s1ap.cc b/srsenb/src/upper/s1ap.cc index 9328060e6..eba9186e7 100644 --- a/srsenb/src/upper/s1ap.cc +++ b/srsenb/src/upper/s1ap.cc @@ -594,7 +594,7 @@ bool s1ap::handle_uectxtreleasecommand(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASECOMMA s1ap_log->warning("Not handling S1AP message extension\n"); } - uint16_t rnti; + uint16_t rnti = 0; if(msg->UE_S1AP_IDs.choice_type == LIBLTE_S1AP_UE_S1AP_IDS_CHOICE_UE_S1AP_ID_PAIR) { if(msg->UE_S1AP_IDs.choice.uE_S1AP_ID_pair.ext) { From fabeca49c741fc19812560bb9c0b926ef4186578 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 15:38:16 +0200 Subject: [PATCH 15/16] moved pdsch_coderate to phy_common --- lib/include/srslte/phy/common/phy_common.h | 3 +++ lib/include/srslte/phy/phch/pdsch.h | 5 +---- lib/src/phy/common/phy_common.c | 5 +++++ lib/src/phy/phch/pdsch.c | 7 +------ srsenb/src/mac/scheduler_ue.cc | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/include/srslte/phy/common/phy_common.h b/lib/include/srslte/phy/common/phy_common.h index efd498c86..65dc2319c 100644 --- a/lib/include/srslte/phy/common/phy_common.h +++ b/lib/include/srslte/phy/common/phy_common.h @@ -242,6 +242,9 @@ SRSLTE_API uint32_t srslte_N_ta_new_rar(uint32_t ta); SRSLTE_API uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta); +SRSLTE_API float srslte_coderate(uint32_t tbs, + uint32_t nof_re); + SRSLTE_API char *srslte_cp_string(srslte_cp_t cp); SRSLTE_API char *srslte_mod_string(srslte_mod_t mod); diff --git a/lib/include/srslte/phy/phch/pdsch.h b/lib/include/srslte/phy/phch/pdsch.h index ad01c4ef8..a73129444 100644 --- a/lib/include/srslte/phy/phch/pdsch.h +++ b/lib/include/srslte/phy/phch/pdsch.h @@ -93,10 +93,7 @@ SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t *q, SRSLTE_API void srslte_pdsch_free_rnti(srslte_pdsch_t *q, uint16_t rnti); -SRSLTE_API float srslte_pdsch_coderate(uint32_t tbs, - uint32_t nof_re); - -SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, +SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c index 8386ae18b..76dc0366f 100644 --- a/lib/src/phy/common/phy_common.c +++ b/lib/src/phy/common/phy_common.c @@ -178,6 +178,11 @@ uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta) { } } +float srslte_coderate(uint32_t tbs, uint32_t nof_re) +{ + return (float) (tbs + 24)/(nof_re); +} + /* Returns the new time advance as indicated by the random access response * as specified in Section 4.2.3 of 36.213 */ uint32_t srslte_N_ta_new_rar(uint32_t ta) { diff --git a/lib/src/phy/phch/pdsch.c b/lib/src/phy/phch/pdsch.c index 9b6128c64..a31e98c77 100644 --- a/lib/src/phy/phch/pdsch.c +++ b/lib/src/phy/phch/pdsch.c @@ -58,12 +58,7 @@ extern int indices[100000]; extern int indices_ptr; #endif -float srslte_pdsch_coderate(uint32_t tbs, uint32_t nof_re) -{ - return (float) (tbs + 24)/(nof_re); -} - -int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_grant_t *grant, uint32_t lstart_grant, uint32_t nsubframe, bool put) +int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_grant_t *grant, uint32_t lstart_grant, uint32_t nsubframe, bool put) { uint32_t s, n, l, lp, lstart, lend, nof_refs; bool is_pbch, is_sss; diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 0d5dd87bb..0518318f3 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -770,7 +770,7 @@ int sched_ue::cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32 sel_mcs--; uint32_t tbs_idx = srslte_ra_tbs_idx_from_mcs(sel_mcs); tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_prb); - coderate = srslte_pdsch_coderate(tbs, nof_re); + coderate = srslte_coderate(tbs, nof_re); } while(sel_mcs > 0 && coderate >= max_coderate); if (mcs) { *mcs = (uint32_t) sel_mcs; From 58aecf818d5eecdf874fec877ec84adfff26e0fe Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 29 Aug 2017 16:22:45 +0200 Subject: [PATCH 16/16] Allowing any PUSCH MCS --- srsenb/enb.conf.example | 2 +- srsenb/hdr/mac/scheduler_ue.h | 6 ++-- srsenb/sib.conf.example | 2 +- srsenb/src/mac/scheduler_ue.cc | 58 ++++++++++++++++++++++++---------- srsenb/src/main.cc | 2 +- srsenb/src/phy/phch_worker.cc | 8 ++++- 6 files changed, 55 insertions(+), 23 deletions(-) diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index 8cc063d41..7446df122 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -121,7 +121,7 @@ enable = false #pdsch_mcs = -1 #pdsch_max_mcs = -1 #pusch_mcs = -1 -pusch_max_mcs = 16 +#pusch_max_mcs = -1 nof_ctrl_symbols = 2 ##################################################################### diff --git a/srsenb/hdr/mac/scheduler_ue.h b/srsenb/hdr/mac/scheduler_ue.h index 1cb223e57..b95e5dda2 100644 --- a/srsenb/hdr/mac/scheduler_ue.h +++ b/srsenb/hdr/mac/scheduler_ue.h @@ -131,8 +131,10 @@ private: int alloc_pdu(int tbs, sched_interface::dl_sched_pdu_t* pdu); static uint32_t format1_count_prb(uint32_t bitmask, uint32_t cell_nof_prb); - static int cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t *mcs); - static int alloc_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, uint32_t max_mcs, int *mcs); + static int cqi_to_tbs(uint32_t cqi, uint32_t nof_prb, uint32_t nof_re, uint32_t max_mcs, uint32_t max_Qm, uint32_t *mcs); + int alloc_tbs_dl(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs); + int alloc_tbs_ul(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, int *mcs); + int alloc_tbs(uint32_t nof_prb, uint32_t nof_re, uint32_t req_bytes, bool is_ul, int *mcs); static bool bearer_is_ul(ue_bearer_t *lch); static bool bearer_is_dl(ue_bearer_t *lch); diff --git a/srsenb/sib.conf.example b/srsenb/sib.conf.example index 7002f4a7f..f23d18981 100644 --- a/srsenb/sib.conf.example +++ b/srsenb/sib.conf.example @@ -60,7 +60,7 @@ sib2 = n_sb = 1; hopping_mode = "inter-subframe"; pusch_hopping_offset = 2; - enable_64_qam = false; + enable_64_qam = false; // 64QAM PUSCH is not currently enabled ul_rs = { cyclic_shift = 0; diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 0518318f3..21aa61b19 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -395,7 +395,7 @@ int sched_ue::generate_format1(dl_harq_proc *h, uint32_t nof_ctrl_symbols = cfi+(cell.nof_prb<10?1:0); uint32_t nof_re = srslte_ra_dl_grant_nof_re(&grant, cell, sf_idx, nof_ctrl_symbols); if (fixed_mcs_dl < 0) { - tbs = alloc_tbs(dl_cqi, nof_prb, nof_re, req_bytes, max_mcs_dl, &mcs); + tbs = alloc_tbs_dl(nof_prb, nof_re, req_bytes, &mcs); } else { tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_dl), nof_prb); mcs = fixed_mcs_dl; @@ -466,7 +466,7 @@ int sched_ue::generate_format0(ul_harq_proc *h, uint32_t N_srs = 0; uint32_t nof_re = (2*(SRSLTE_CP_NSYMB(cell.cp)-1) - N_srs)*allocation.L*SRSLTE_NRE; if (fixed_mcs_ul < 0) { - tbs = alloc_tbs(ul_cqi, allocation.L, nof_re, req_bytes, max_mcs_ul, &mcs); + tbs = alloc_tbs_ul(allocation.L, nof_re, req_bytes, &mcs); } else { tbs = srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(fixed_mcs_ul), allocation.L); mcs = fixed_mcs_ul; @@ -610,7 +610,7 @@ uint32_t sched_ue::get_required_prb_dl(uint32_t req_bytes, uint32_t nof_ctrl_sym for (n=1;n 0 && coderate >= max_coderate); + Qm = SRSLTE_MIN(max_Qm, srslte_mod_bits_x_symbol(srslte_ra_mod_from_mcs(sel_mcs))); + eff_coderate = coderate/Qm; + } while((sel_mcs > 0 && coderate > max_coderate) || eff_coderate > 0.930); if (mcs) { *mcs = (uint32_t) sel_mcs; } return tbs; } -/* In this scheduler we tend to use all the available bandwidth and select the MCS +int sched_ue::alloc_tbs_dl(uint32_t nof_prb, + uint32_t nof_re, + uint32_t req_bytes, + int *mcs) +{ + return alloc_tbs(nof_prb, nof_re, req_bytes, false, mcs); +} + +int sched_ue::alloc_tbs_ul(uint32_t nof_prb, + uint32_t nof_re, + uint32_t req_bytes, + int *mcs) +{ + return alloc_tbs(nof_prb, nof_re, req_bytes, true, mcs); +} + + /* In this scheduler we tend to use all the available bandwidth and select the MCS * that approximates the minimum between the capacity and the requested rate */ -int sched_ue::alloc_tbs(uint32_t cqi, - uint32_t nof_prb, - uint32_t nof_re, - uint32_t req_bytes, - uint32_t max_mcs, - int *mcs) -{ - uint32_t sel_mcs = 0; - int tbs = cqi_to_tbs(cqi, nof_prb, nof_re, max_mcs, &sel_mcs)/8; +int sched_ue::alloc_tbs(uint32_t nof_prb, + uint32_t nof_re, + uint32_t req_bytes, + bool is_ul, + int *mcs) +{ + uint32_t sel_mcs = 0; + + uint32_t cqi = is_ul?ul_cqi:dl_cqi; + uint32_t max_mcs = is_ul?max_mcs_ul:max_mcs_dl; + uint32_t max_Qm = is_ul?4:6; // Allow 16-QAM in PUSCH Only + + int tbs = cqi_to_tbs(cqi, nof_prb, nof_re, max_mcs, max_Qm, &sel_mcs)/8; /* If less bytes are requested, lower the MCS */ if (tbs > (int) req_bytes && req_bytes > 0) { diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index bc6aedc16..1e337b3ba 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -130,7 +130,7 @@ void parse_args(all_args_t *args, int argc, char* argv[]) { bpo::value(&args->expert.mac.sched.pusch_mcs)->default_value(-1), "Optional fixed PUSCH MCS (ignores reported CQIs if specified)") ("scheduler.pusch_max_mcs", - bpo::value(&args->expert.mac.sched.pusch_max_mcs)->default_value(16), + bpo::value(&args->expert.mac.sched.pusch_max_mcs)->default_value(-1), "Optional PUSCH MCS limit") ("scheduler.nof_ctrl_symbols", bpo::value(&args->expert.mac.sched.nof_ctrl_symbols)->default_value(3), diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index 095a4643c..f10ebdfa8 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -49,6 +49,8 @@ using namespace std; #ifdef ENABLE_GUI #include "srsgui/srsgui.h" #include +#include + void init_plots(srsenb::phch_worker *worker); pthread_t plot_thread; sem_t plot_sem; @@ -363,7 +365,11 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch, srslte_ra_ul_grant_t phy_grant; int res = -1; if (!srslte_ra_ul_dci_to_grant(&grants[i].grant, enb_ul.cell.nof_prb, n_rb_ho, &phy_grant, tti%8)) { - res = srslte_enb_ul_get_pusch(&enb_ul, &phy_grant, grants[i].softbuffer, + if (phy_grant.mcs.mod == SRSLTE_MOD_64QAM) { + phy_grant.mcs.mod = SRSLTE_MOD_16QAM; + } + phy_grant.Qm = SRSLTE_MIN(phy_grant.Qm, 4); + res = srslte_enb_ul_get_pusch(&enb_ul, &phy_grant, grants[i].softbuffer, rnti, grants[i].rv_idx, grants[i].current_tx_nb, grants[i].data,