diff --git a/srsenb/hdr/phy/phch_worker.h b/srsenb/hdr/phy/phch_worker.h index 383c9d583..c02b4607b 100644 --- a/srsenb/hdr/phy/phch_worker.h +++ b/srsenb/hdr/phy/phch_worker.h @@ -54,15 +54,15 @@ public: /* These are used by the GUI plotting tools */ int read_ce_abs(float *ce_abs); + int read_ce_arg(float *ce_abs); int read_pusch_d(cf_t *pusch_d); + int read_pucch_d(cf_t *pusch_d); void start_plot(); void set_conf_dedicated_ack(uint16_t rnti, bool rrc_completed); void set_config_dedicated(uint16_t rnti, - srslte_uci_cfg_t *uci_cfg, - srslte_pucch_sched_t *pucch_sched, srslte_refsignal_srs_cfg_t *srs_cfg, LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT* dedicated); diff --git a/srsenb/hdr/upper/rrc.h b/srsenb/hdr/upper/rrc.h index bbed4c2da..dc2c0f742 100644 --- a/srsenb/hdr/upper/rrc.h +++ b/srsenb/hdr/upper/rrc.h @@ -187,6 +187,7 @@ public: void handle_rrc_con_req(LIBLTE_RRC_CONNECTION_REQUEST_STRUCT *msg); void handle_rrc_con_reest_req(LIBLTE_RRC_CONNECTION_REESTABLISHMENT_REQUEST_STRUCT *msg); void handle_rrc_con_setup_complete(LIBLTE_RRC_CONNECTION_SETUP_COMPLETE_STRUCT *msg, srslte::byte_buffer_t *pdu); + void handle_rrc_reconf_complete(LIBLTE_RRC_CONNECTION_RECONFIGURATION_COMPLETE_STRUCT *msg, srslte::byte_buffer_t *pdu); void handle_security_mode_complete(LIBLTE_RRC_SECURITY_MODE_COMPLETE_STRUCT *msg); void handle_security_mode_failure(LIBLTE_RRC_SECURITY_MODE_FAILURE_STRUCT *msg); void handle_ue_cap_info(LIBLTE_RRC_UE_CAPABILITY_INFORMATION_STRUCT *msg); diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 092acc8a5..f10297760 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -854,9 +854,11 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg) if (rrc_cfg->antenna_info.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_3) { rrc_cfg->antenna_info.ue_tx_antenna_selection_setup = LIBLTE_RRC_UE_TX_ANTENNA_SELECTION_OPEN_LOOP; - rrc_cfg->antenna_info.ue_tx_antenna_selection_setup_present = true; + rrc_cfg->antenna_info.ue_tx_antenna_selection_setup_present = false; rrc_cfg->antenna_info.codebook_subset_restriction_choice = LIBLTE_RRC_CODEBOOK_SUBSET_RESTRICTION_N2_TM3; + rrc_cfg->antenna_info.codebook_subset_restriction = 0b11; + rrc_cfg->antenna_info.codebook_subset_restriction_present = true; } else if (rrc_cfg->antenna_info.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { rrc_cfg->antenna_info.ue_tx_antenna_selection_setup = LIBLTE_RRC_UE_TX_ANTENNA_SELECTION_CLOSED_LOOP; rrc_cfg->antenna_info.ue_tx_antenna_selection_setup_present = true; diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index 8b61aa4ce..ea24b8908 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -648,7 +648,7 @@ int sched::dl_sched_data(dl_sched_data_t data[MAX_DATA_LIST]) user->get_locations(current_cfi, sf_idx), aggr_level, user)) { - bool is_newtx = h->is_empty(0); + bool is_newtx = h->is_empty(0) && h->is_empty(1) ; int tbs = 0; switch(dci_format) { case SRSLTE_DCI_FORMAT1: @@ -663,7 +663,7 @@ int sched::dl_sched_data(dl_sched_data_t data[MAX_DATA_LIST]) default: Error("DCI format (%d) not implemented\n", dci_format); } - if (tbs >= 0) { + if (tbs > 0) { log_h->info("SCHED: DL %s rnti=0x%x, pid=%d, mask=0x%x, dci=%d,%d, n_rtx=%d, tbs=%d, buffer=%d, tb_en={%s,%s}\n", !is_newtx?"retx":"tx", rnti, h->get_id(), h->get_rbgmask(), data[nof_data_elems].dci_location.L, data[nof_data_elems].dci_location.ncce, h->nof_retx(0) + h->nof_retx(1), diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 311439d71..5ced3631a 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -471,7 +471,7 @@ int sched_ue::generate_format2a(dl_harq_proc *h, srslte_ra_dl_grant_t grant; srslte_ra_dl_dci_to_grant_prb_allocation(dci, &grant, cell.nof_prb); uint32_t nof_re = srslte_ra_dl_grant_nof_re(&grant, cell, sf_idx, nof_ctrl_symbols); - uint32_t req_bytes = get_pending_dl_new_data(tti); + bool no_retx = true; if (dl_ri == 0) { if (h->is_empty(1)) { @@ -483,7 +483,6 @@ int sched_ue::generate_format2a(dl_harq_proc *h, } } else { /* Two layers, retransmit what TBs that have not been Acknowledged */ - bool no_retx = true; for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { if (!h->is_empty(tb)) { tb_en[tb] = true; @@ -498,35 +497,33 @@ int sched_ue::generate_format2a(dl_harq_proc *h, } for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + uint32_t req_bytes = get_pending_dl_new_data(tti); int mcs = 0; int tbs = 0; - if (tb_en[tb]) { - if (h->is_empty(tb)) { - if (fixed_mcs_dl < 0) { - tbs = alloc_tbs_dl(nof_prb, nof_re, req_bytes, &mcs); - } else { - tbs = srslte_ra_tbs_from_idx((uint32_t) srslte_ra_tbs_idx_from_mcs((uint32_t) fixed_mcs_dl), nof_prb) / 8; - mcs = fixed_mcs_dl; - } - - h->new_tx(tb, tti, mcs, tbs, data->dci_location.ncce); - - int rem_tbs = tbs; - int x = 0; - do { - x = alloc_pdu(rem_tbs, &data->pdu[tb][data->nof_pdu_elems[tb]]); - rem_tbs -= x; - if (x) { - data->nof_pdu_elems[tb]++; - } - } while (rem_tbs > 0 && x > 0); - - Debug("SCHED: Alloc format2/2a new mcs=%d, tbs=%d, nof_prb=%d, req_bytes=%d\n", mcs, tbs, nof_prb, req_bytes); + if (!h->is_empty(tb)) { + h->new_retx(tb, tti, &mcs, &tbs); + Debug("SCHED: Alloc format2/2a previous mcs=%d, tbs=%d\n", mcs, tbs); + } else if (tb_en[tb] && req_bytes && no_retx) { + if (fixed_mcs_dl < 0) { + tbs = alloc_tbs_dl(nof_prb, nof_re, req_bytes, &mcs); } else { - h->new_retx(tb, tti, &mcs, &tbs); - Debug("SCHED: Alloc format2/2a previous mcs=%d, tbs=%d\n", mcs, tbs); + tbs = srslte_ra_tbs_from_idx((uint32_t) srslte_ra_tbs_idx_from_mcs((uint32_t) fixed_mcs_dl), nof_prb) / 8; + mcs = fixed_mcs_dl; } + h->new_tx(tb, tti, mcs, tbs, data->dci_location.ncce); + + int rem_tbs = tbs; + int x = 0; + do { + x = alloc_pdu(rem_tbs, &data->pdu[tb][data->nof_pdu_elems[tb]]); + rem_tbs -= x; + if (x) { + data->nof_pdu_elems[tb]++; + } + } while (rem_tbs > 0 && x > 0); + + Debug("SCHED: Alloc format2/2a new mcs=%d, tbs=%d, nof_prb=%d, req_bytes=%d\n", mcs, tbs, nof_prb, req_bytes); } /* Fill DCI TB dedicated fields */ @@ -546,12 +543,6 @@ int sched_ue::generate_format2a(dl_harq_proc *h, data->tbs[tb] = 0; dci->tb_en[tb] = false; } - - if ( req_bytes > (uint32_t) tbs) { - req_bytes -= tbs; - } else { - req_bytes = 0; - } } /* Fill common fields */ diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index 060fb3d34..f71f023c4 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -228,45 +228,81 @@ void phch_worker::set_conf_dedicated_ack(uint16_t rnti, bool ack){ } void phch_worker::set_config_dedicated(uint16_t rnti, - srslte_uci_cfg_t *uci_cfg, - srslte_pucch_sched_t *pucch_sched, srslte_refsignal_srs_cfg_t *srs_cfg, LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT* dedicated) { - uint32_t I_sr = dedicated->sched_request_cnfg.sr_cnfg_idx; - bool pucch_cqi = dedicated->cqi_report_cnfg.report_periodic_setup_present; - uint32_t pmi_idx = dedicated->cqi_report_cnfg.report_periodic.pmi_cnfg_idx; bool pucch_cqi_ack = dedicated->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi; bool pucch_ri = dedicated->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present; - uint32_t ri_idx = dedicated->cqi_report_cnfg.report_periodic.ri_cnfg_idx; pthread_mutex_lock(&mutex); if (ue_db.count(rnti)) { - pucch_sched->N_pucch_1 = phy->pucch_cfg.n1_pucch_an; - 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; + /* PUSCH UCI and scheduling configuration */ + srslte_uci_cfg_t uci_cfg = {0}; + if (dedicated->pusch_cnfg_ded_present && dedicated->sched_request_cnfg_present) { + uci_cfg.I_offset_ack = dedicated->pusch_cnfg_ded.beta_offset_ack_idx; + uci_cfg.I_offset_cqi = dedicated->pusch_cnfg_ded.beta_offset_cqi_idx; + uci_cfg.I_offset_ri = dedicated->pusch_cnfg_ded.beta_offset_ri_idx; + + srslte_pucch_sched_t pucch_sched = {false}; + pucch_sched.N_pucch_1 = phy->pucch_cfg.n1_pucch_an; + pucch_sched.n_pucch_2 = dedicated->cqi_report_cnfg.report_periodic.pucch_resource_idx; + pucch_sched.n_pucch_sr = dedicated->sched_request_cnfg.sr_pucch_resource_idx; + srslte_enb_ul_cfg_ue(&enb_ul, rnti, &uci_cfg, &pucch_sched, srs_cfg); + + ue_db[rnti].I_sr = dedicated->sched_request_cnfg.sr_cnfg_idx; + ue_db[rnti].I_sr_en = true; + } - if (pucch_cqi) { - ue_db[rnti].pmi_idx = pmi_idx; - ue_db[rnti].cqi_en = true; + /* CQI Reporting */ + if (dedicated->cqi_report_cnfg.report_periodic_setup_present) { + ue_db[rnti].pmi_idx = dedicated->cqi_report_cnfg.report_periodic.pmi_cnfg_idx; + ue_db[rnti].cqi_en = true; ue_db[rnti].pucch_cqi_ack = pucch_cqi_ack; } else { ue_db[rnti].pmi_idx = 0; - ue_db[rnti].cqi_en = false; + ue_db[rnti].cqi_en = false; } + /* RI reporting */ if (pucch_ri) { - ue_db[rnti].ri_idx = ri_idx; - ue_db[rnti].ri_en = true; + ue_db[rnti].ri_idx = dedicated->cqi_report_cnfg.report_periodic.ri_cnfg_idx; + ue_db[rnti].ri_en = true; } else { ue_db[rnti].ri_idx = 0; - ue_db[rnti].ri_en = false; + ue_db[rnti].ri_en = false; } - /* Copy all dedicated RRC configuration to UE */ - memcpy(&ue_db[rnti].dedicated, dedicated, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT)); + if (dedicated->antenna_info_present) { + /* If default antenna info then follow 3GPP 36.331 clause 9.2.4 Default physical channel configuration */ + if (dedicated->antenna_info_default_value) { + if (enb_dl.cell.nof_ports == 1) { + ue_db[rnti].dedicated.antenna_info_explicit_value.tx_mode = LIBLTE_RRC_TRANSMISSION_MODE_1; + } else { + ue_db[rnti].dedicated.antenna_info_explicit_value.tx_mode = LIBLTE_RRC_TRANSMISSION_MODE_2; + } + ue_db[rnti].dedicated.antenna_info_explicit_value.codebook_subset_restriction_present = false; + ue_db[rnti].dedicated.antenna_info_explicit_value.ue_tx_antenna_selection_setup_present = false; + ue_db[rnti].ri_idx = 0; + ue_db[rnti].ri_en = false; + } else { + /* Physical channel reconfiguration according to 3GPP 36.331 clause 5.3.10.6 */ + memcpy(&ue_db[rnti].dedicated.antenna_info_explicit_value, + &dedicated->antenna_info_explicit_value, + sizeof(LIBLTE_RRC_ANTENNA_INFO_DEDICATED_STRUCT)); + if (dedicated->antenna_info_explicit_value.tx_mode != LIBLTE_RRC_TRANSMISSION_MODE_3 && + dedicated->antenna_info_explicit_value.tx_mode != LIBLTE_RRC_TRANSMISSION_MODE_4 && + ue_db[rnti].ri_en) { + ue_db[rnti].ri_idx = 0; + ue_db[rnti].ri_en = false; + } + } + } + + /* Set PDSCH power allocation */ + if (dedicated->pdsch_cnfg_ded_present) { + ue_db[rnti].dedicated.pdsch_cnfg_ded_present = true; + ue_db[rnti].dedicated.pdsch_cnfg_ded = dedicated->pdsch_cnfg_ded; + } } else { Error("Setting config dedicated: rnti=0x%x does not exist\n"); } @@ -856,13 +892,11 @@ int phch_worker::encode_pdsch(srslte_enb_dl_pdsch_t *grants, uint32_t nof_grants char tbstr[SRSLTE_MAX_TB][128]; for (int tb = 0; tb < SRSLTE_MAX_TB; tb++) { if (phy_grant.tb_en[tb]) { - snprintf(tbstr[tb], 128, ", TB%d: tbs=%d, mcs=%d, rv=%d%s%s", + snprintf(tbstr[tb], 128, ", TB%d: tbs=%d, mcs=%d, rv=%d", tb, phy_grant.mcs[tb].tbs / 8, phy_grant.mcs[tb].idx, - (tb == 0) ? grants[i].grant.rv_idx : grants[i].grant.rv_idx_1, - grants[i].softbuffers[tb]==NULL?", \e[31msoftbuffer=NULL\e[0m":"", - grants[i].data[tb]==NULL?", \e[31mdata=NULL\e[0m":""); + (tb == 0) ? grants[i].grant.rv_idx : grants[i].grant.rv_idx_1); } else { tbstr[tb][0] = '\0'; } @@ -984,6 +1018,20 @@ int phch_worker::read_ce_abs(float *ce_abs) { return sz; } +int phch_worker::read_ce_arg(float *ce_arg) { + uint32_t i=0; + int sz = srslte_symbol_sz(phy->cell.nof_prb); + bzero(ce_arg, sizeof(float)*sz); + int g = (sz - 12*phy->cell.nof_prb)/2; + for (i = 0; i < 12*phy->cell.nof_prb; i++) { + ce_arg[g+i] = cargf(enb_ul.ce[i]) * 180.0f / (float) M_PI; + if (isinf(ce_arg[g+i])) { + ce_arg[g+i] = -80; + } + } + return sz; +} + int phch_worker::read_pusch_d(cf_t* pdsch_d) { int nof_re = 400;//enb_ul.pusch_cfg.nbits.nof_re @@ -991,6 +1039,13 @@ int phch_worker::read_pusch_d(cf_t* pdsch_d) return nof_re; } +int phch_worker::read_pucch_d(cf_t* pdsch_d) +{ + int nof_re = SRSLTE_PUCCH_MAX_BITS/2;//enb_ul.pusch_cfg.nbits.nof_re + memcpy(pdsch_d, enb_ul.pucch.z_tmp, nof_re*sizeof(cf_t)); + return nof_re; +} + } @@ -1003,12 +1058,15 @@ int phch_worker::read_pusch_d(cf_t* pdsch_d) #ifdef ENABLE_GUI -plot_real_t pce; +plot_real_t pce, pce_arg; plot_scatter_t pconst; +plot_scatter_t pconst2; #define SCATTER_PUSCH_BUFFER_LEN (20*6*SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)) #define SCATTER_PUSCH_PLOT_LEN 4000 float tmp_plot[SCATTER_PUSCH_BUFFER_LEN]; +float tmp_plot_arg[SCATTER_PUSCH_BUFFER_LEN]; cf_t tmp_plot2[SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +cf_t tmp_pucch_plot[SRSLTE_PUCCH_MAX_BITS/2]; void *plot_thread_run(void *arg) { srsenb::phch_worker *worker = (srsenb::phch_worker*) arg; @@ -1018,24 +1076,42 @@ void *plot_thread_run(void *arg) { plot_real_setTitle(&pce, (char*) "Channel Response - Magnitude"); plot_real_setLabels(&pce, (char*) "Index", (char*) "dB"); plot_real_setYAxisScale(&pce, -40, 40); + + plot_real_init(&pce_arg); + plot_real_setTitle(&pce_arg, (char*) "Channel Response - Argument"); + plot_real_setLabels(&pce_arg, (char*) "Angle", (char*) "deg"); + plot_real_setYAxisScale(&pce_arg, -180, 180); plot_scatter_init(&pconst); plot_scatter_setTitle(&pconst, (char*) "PUSCH - Equalized Symbols"); plot_scatter_setXAxisScale(&pconst, -4, 4); plot_scatter_setYAxisScale(&pconst, -4, 4); + + plot_scatter_init(&pconst2); + plot_scatter_setTitle(&pconst2, (char*) "PUCCH - Equalized Symbols"); + plot_scatter_setXAxisScale(&pconst2, -4, 4); + plot_scatter_setYAxisScale(&pconst2, -4, 4); plot_real_addToWindowGrid(&pce, (char*)"srsenb", 0, 0); + plot_real_addToWindowGrid(&pce_arg, (char*)"srsenb", 1, 0); plot_scatter_addToWindowGrid(&pconst, (char*)"srsenb", 0, 1); + plot_scatter_addToWindowGrid(&pconst2, (char*)"srsenb", 1, 1); - int n; + int n, n_arg, n_pucch; int readed_pusch_re=0; while(1) { sem_wait(&plot_sem); n = worker->read_pusch_d(tmp_plot2); + n_pucch = worker->read_pucch_d(tmp_pucch_plot); plot_scatter_setNewData(&pconst, tmp_plot2, n); + plot_scatter_setNewData(&pconst2, tmp_pucch_plot, n_pucch); + n = worker->read_ce_abs(tmp_plot); - plot_real_setNewData(&pce, tmp_plot, n); + plot_real_setNewData(&pce, tmp_plot, n); + + n_arg = worker->read_ce_arg(tmp_plot_arg); + plot_real_setNewData(&pce_arg, tmp_plot_arg, n_arg); } return NULL; diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 6a1077de5..533abb765 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -219,23 +219,8 @@ void phy::set_conf_dedicated_ack(uint16_t rnti, bool ack) void phy::set_config_dedicated(uint16_t rnti, LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT* dedicated) { - // Parse RRC config - srslte_uci_cfg_t uci_cfg; - srslte_pucch_sched_t pucch_sched; - - /* PUSCH UCI configuration */ - bzero(&uci_cfg, sizeof(srslte_uci_cfg_t)); - uci_cfg.I_offset_ack = dedicated->pusch_cnfg_ded.beta_offset_ack_idx; - uci_cfg.I_offset_cqi = dedicated->pusch_cnfg_ded.beta_offset_cqi_idx; - uci_cfg.I_offset_ri = dedicated->pusch_cnfg_ded.beta_offset_ri_idx; - - /* PUCCH Scheduling configuration */ - bzero(&pucch_sched, sizeof(srslte_pucch_sched_t)); - pucch_sched.n_pucch_2 = dedicated->cqi_report_cnfg.report_periodic.pucch_resource_idx; - pucch_sched.n_pucch_sr = dedicated->sched_request_cnfg.sr_pucch_resource_idx; - for (uint32_t i=0;is1ap->write_pdu(rnti, pdu); break; case LIBLTE_RRC_UL_DCCH_MSG_TYPE_RRC_CON_RECONFIG_COMPLETE: + handle_rrc_reconf_complete(&ul_dcch_msg.msg.rrc_con_reconfig_complete, pdu); parent->rrc_log->console("User 0x%x connected\n", rnti); state = RRC_STATE_REGISTERED; break; @@ -878,6 +879,16 @@ void rrc::ue::handle_rrc_con_setup_complete(LIBLTE_RRC_CONNECTION_SETUP_COMPLETE state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; } +void rrc::ue::handle_rrc_reconf_complete(LIBLTE_RRC_CONNECTION_RECONFIGURATION_COMPLETE_STRUCT *msg, srslte::byte_buffer_t *pdu) +{ + parent->rrc_log->info("RRCReconfigurationComplete transaction ID: %d\n", msg->rrc_transaction_id); + + + // Acknowledge Dedicated Configuration + parent->phy->set_conf_dedicated_ack(rnti, true); + parent->mac->phy_config_enabled(rnti, true); +} + void rrc::ue::handle_security_mode_complete(LIBLTE_RRC_SECURITY_MODE_COMPLETE_STRUCT *msg) { parent->rrc_log->info("SecurityModeComplete transaction ID: %d\n", msg->rrc_transaction_id); @@ -1123,12 +1134,8 @@ void rrc::ue::send_connection_setup(bool is_setup) phy_cfg->sched_request_cnfg.setup_present = true; phy_cfg->sched_request_cnfg.dsr_trans_max = parent->cfg.sr_cfg.dsr_max; - if (parent->cfg.antenna_info.tx_mode > LIBLTE_RRC_TRANSMISSION_MODE_1) { - memcpy(&phy_cfg->antenna_info_explicit_value, &parent->cfg.antenna_info, - sizeof(LIBLTE_RRC_ANTENNA_INFO_DEDICATED_STRUCT)); - phy_cfg->antenna_info_present = true; - phy_cfg->antenna_info_default_value = false; - } + phy_cfg->antenna_info_default_value = true; + phy_cfg->antenna_info_present = false; if (is_setup) { if (sr_allocate(parent->cfg.sr_cfg.period, &phy_cfg->sched_request_cnfg.sr_cnfg_idx, &phy_cfg->sched_request_cnfg.sr_pucch_resource_idx)) { @@ -1146,30 +1153,24 @@ void rrc::ue::send_connection_setup(bool is_setup) phy_cfg->ul_pwr_ctrl_ded.accumulation_en = true; phy_cfg->ul_pwr_ctrl_ded.p0_ue_pucch = 0, phy_cfg->ul_pwr_ctrl_ded.p_srs_offset = 3; - - phy_cfg->pdsch_cnfg_ded_present = true; + + // PDSCH + phy_cfg->pdsch_cnfg_ded_present = true; phy_cfg->pdsch_cnfg_ded = parent->cfg.pdsch_cfg; - + + // PUCCH + phy_cfg->pucch_cnfg_ded_present = true; + phy_cfg->pucch_cnfg_ded.ack_nack_repetition_n1_pucch_an = 0; + phy_cfg->cqi_report_cnfg_present = true; if(parent->cfg.cqi_cfg.mode == RRC_CFG_CQI_MODE_APERIODIC) { phy_cfg->cqi_report_cnfg.report_mode_aperiodic_present = true; - if (phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { - phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM31; - } else { - phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM30; - } + phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM31; } else { phy_cfg->cqi_report_cnfg.report_periodic_present = true; phy_cfg->cqi_report_cnfg.report_periodic_setup_present = true; phy_cfg->cqi_report_cnfg.report_periodic.format_ind_periodic = LIBLTE_RRC_CQI_FORMAT_INDICATOR_PERIODIC_WIDEBAND_CQI; - phy_cfg->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi = parent->cfg.cqi_cfg.simultaneousAckCQI; - if (phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_3 || - phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { - phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = true; - phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx = 483; - } else { - phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = false; - } + phy_cfg->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi = false; if (is_setup) { if (cqi_allocate(parent->cfg.cqi_cfg.period, &phy_cfg->cqi_report_cnfg.report_periodic.pmi_cnfg_idx, @@ -1308,19 +1309,31 @@ void rrc::ue::send_connection_reconf_upd(srslte::byte_buffer_t *pdu) phy_cfg->cqi_report_cnfg_present = true; if (cqi_allocated) { - phy_cfg->cqi_report_cnfg.report_periodic_present = true; - phy_cfg->cqi_report_cnfg.report_periodic_setup_present = true; - phy_cfg->cqi_report_cnfg.report_periodic.format_ind_periodic = LIBLTE_RRC_CQI_FORMAT_INDICATOR_PERIODIC_WIDEBAND_CQI; - phy_cfg->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi = false; - phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = false; - phy_cfg->cqi_report_cnfg.report_periodic.pucch_resource_idx = cqi_pucch; - phy_cfg->cqi_report_cnfg.report_periodic.pmi_cnfg_idx = cqi_idx; + cqi_get(&phy_cfg->cqi_report_cnfg.report_periodic.pmi_cnfg_idx, + &phy_cfg->cqi_report_cnfg.report_periodic.pucch_resource_idx); + phy_cfg->cqi_report_cnfg.report_periodic_present = true; + phy_cfg->cqi_report_cnfg.report_periodic_setup_present = true; + phy_cfg->cqi_report_cnfg.report_periodic.format_ind_periodic = + LIBLTE_RRC_CQI_FORMAT_INDICATOR_PERIODIC_WIDEBAND_CQI; + phy_cfg->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi = parent->cfg.cqi_cfg.simultaneousAckCQI; + if (parent->cfg.antenna_info.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_3 || + parent->cfg.antenna_info.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = true; + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx = 483; /* TODO: HARDCODED! Add to UL scheduler */ + } else { + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = false; + } } else { - phy_cfg->cqi_report_cnfg.report_mode_aperiodic_present = true; - phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM30; - phy_cfg->cqi_report_cnfg.nom_pdsch_rs_epre_offset = 0; + phy_cfg->cqi_report_cnfg.report_mode_aperiodic_present = true; + if (phy_cfg->antenna_info_present && + parent->cfg.antenna_info.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { + phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM31; + } else { + phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM30; + } } - + parent->phy->set_config_dedicated(rnti, phy_cfg); + sr_get(&phy_cfg->sched_request_cnfg.sr_cnfg_idx, &phy_cfg->sched_request_cnfg.sr_pucch_resource_idx); pdu->reset(); @@ -1349,6 +1362,50 @@ void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) conn_reconf->mob_ctrl_info_present = false; conn_reconf->sec_cnfg_ho_present = false; + LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *phy_cfg = &conn_reconf->rr_cnfg_ded.phy_cnfg_ded; + bzero(phy_cfg, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT)); + conn_reconf->rr_cnfg_ded.phy_cnfg_ded_present = true; + + if (parent->cfg.antenna_info.tx_mode > LIBLTE_RRC_TRANSMISSION_MODE_1) { + memcpy(&phy_cfg->antenna_info_explicit_value, &parent->cfg.antenna_info, + sizeof(LIBLTE_RRC_ANTENNA_INFO_DEDICATED_STRUCT)); + phy_cfg->antenna_info_present = true; + phy_cfg->antenna_info_default_value = false; + } + + // Configure PHY layer + phy_cfg->cqi_report_cnfg_present = true; + if(parent->cfg.cqi_cfg.mode == RRC_CFG_CQI_MODE_APERIODIC) { + phy_cfg->cqi_report_cnfg.report_mode_aperiodic_present = true; + if (phy_cfg->antenna_info_present && + phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { + phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM31; + } else { + phy_cfg->cqi_report_cnfg.report_mode_aperiodic = LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM30; + } + } else { + cqi_get(&phy_cfg->cqi_report_cnfg.report_periodic.pmi_cnfg_idx, + &phy_cfg->cqi_report_cnfg.report_periodic.pucch_resource_idx); + phy_cfg->cqi_report_cnfg.report_periodic_present = true; + phy_cfg->cqi_report_cnfg.report_periodic_setup_present = true; + phy_cfg->cqi_report_cnfg.report_periodic.format_ind_periodic = LIBLTE_RRC_CQI_FORMAT_INDICATOR_PERIODIC_WIDEBAND_CQI; + phy_cfg->cqi_report_cnfg.report_periodic.simult_ack_nack_and_cqi = parent->cfg.cqi_cfg.simultaneousAckCQI; + if (phy_cfg->antenna_info_present && + (phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_3 || + phy_cfg->antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4)) { + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = true; + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx = 483; + } else { + phy_cfg->cqi_report_cnfg.report_periodic.ri_cnfg_idx_present = false; + } + } + phy_cfg->cqi_report_cnfg.nom_pdsch_rs_epre_offset = 0; + + parent->phy->set_config_dedicated(rnti, phy_cfg); + parent->phy->set_conf_dedicated_ack(rnti, false); + parent->mac->set_dl_ant_info(rnti, &phy_cfg->antenna_info_explicit_value); + parent->mac->phy_config_enabled(rnti, false); + // Add SRB2 to the message conn_reconf->rr_cnfg_ded.srb_to_add_mod_list_size = 1; conn_reconf->rr_cnfg_ded.srb_to_add_mod_list[0].srb_id = 2;