diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 743d838b8..837c05eb3 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -73,12 +73,12 @@ public: ul_sched_grant_t pusch[MAX_GRANTS]; ul_sched_ack_t phich[MAX_GRANTS]; uint32_t nof_grants; - uint32_t nof_phich; - } ul_sched_t; + uint32_t nof_phich; + } ul_sched_t; + + virtual int sr_detected(uint32_t tti, uint16_t rnti) = 0; + virtual int rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) = 0; - virtual int sr_detected(uint32_t tti, uint16_t rnti) = 0; - virtual int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) = 0; - virtual int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) = 0; virtual int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) = 0; virtual int cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value) = 0; diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 1f22ab25d..c452aa592 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -95,11 +95,11 @@ private: std::vector > log_vec; srslte::log* log_h = nullptr; - srslte::thread_pool workers_pool; - std::vector workers; - phy_common workers_common; - prach_worker prach; - txrx tx_rx; + srslte::thread_pool workers_pool; + std::vector workers; + phy_common workers_common; + prach_worker_pool prach; + txrx tx_rx; bool initialized = false; diff --git a/srsenb/hdr/phy/prach_worker.h b/srsenb/hdr/phy/prach_worker.h index c73e3d7a9..a2741cd84 100644 --- a/srsenb/hdr/phy/prach_worker.h +++ b/srsenb/hdr/phy/prach_worker.h @@ -33,25 +33,7 @@ namespace srsenb { class prach_worker : thread { public: - prach_worker() : - initiated(false), - prach_nof_det(0), - max_prach_offset_us(0), - buffer_pool(8), - running(false), - nof_sf(0), - sf_cnt(0), - thread("PRACH_WORKER") - { - log_h = nullptr; - stack = nullptr; - bzero(&prach, sizeof(srslte_prach_t)); - bzero(&prach_indices, sizeof(prach_indices)); - bzero(&prach_offsets, sizeof(prach_offsets)); - bzero(&prach_p2avg, sizeof(prach_p2avg)); - bzero(&cell, sizeof(cell)); - bzero(&prach_cfg, sizeof(prach_cfg)); - } + prach_worker(uint32_t cc_idx_) : buffer_pool(8), thread("PRACH_WORKER") { cc_idx = cc_idx_; } int init(const srslte_cell_t& cell_, const srslte_prach_cfg_t& prach_cfg_, @@ -63,14 +45,15 @@ public: void stop(); private: - uint32_t prach_nof_det; - uint32_t prach_indices[165]; - float prach_offsets[165]; - float prach_p2avg[165]; - - srslte_cell_t cell; - srslte_prach_cfg_t prach_cfg; - srslte_prach_t prach; + uint32_t cc_idx = 0; + uint32_t prach_nof_det = 0; + uint32_t prach_indices[165] = {}; + float prach_offsets[165] = {}; + float prach_p2avg[165] = {}; + + srslte_cell_t cell = {}; + srslte_prach_cfg_t prach_cfg = {}; + srslte_prach_t prach = {}; const static int sf_buffer_sz = 128*1024; class sf_buffer { @@ -95,7 +78,7 @@ private: srslte::log* log_h = nullptr; stack_interface_phy_lte* stack = nullptr; float max_prach_offset_us = 0.0f; - bool initiated = 0; + bool initiated = false; bool running = false; uint32_t nof_sf = 0; uint32_t sf_cnt = 0; @@ -105,5 +88,53 @@ private: }; + +class prach_worker_pool: +{ +private: + std::vector > prach_vec; + +public: + prach_worker_pool() = default; + ~prach_worker_pool() = default; + + void init(uint32_t cc_idx, + const srslte_cell_t& cell_, + const srslte_prach_cfg_t& prach_cfg_, + stack_interface_phy_lte* mac, + srslte::log* log_h, + int priority) + { + // Create PRACH worker if required + while (cc_idx >= prach_vec.size()) { + prach_vec.push_back(std::unique_ptr(new prach_worker(prach_vec.size()))); + } + + prach_vec[cc_idx]->init(cell_, prach_cfg_, mac, log_h, priority); + } + + void set_max_prach_offset_us(float delay_us) + { + for (auto& prach : prach_vec) { + prach->set_max_prach_offset_us(delay_us); + } + } + + void stop() + { + for (auto& prach : prach_vec) { + prach->stop(); + } + } + + int new_tti(uint32_t cc_idx, uint32_t tti, cf_t* buffer) + { + int ret = SRSLTE_ERROR; + if (cc_idx < prach_vec.size()) { + ret = prach_vec[cc_idx]->new_tti(tti, buffer); + } + return ret; + } +}; } #endif // SRSENB_PRACH_WORKER_H diff --git a/srsenb/hdr/phy/txrx.h b/srsenb/hdr/phy/txrx.h index ddd305449..cea0eb0f2 100644 --- a/srsenb/hdr/phy/txrx.h +++ b/srsenb/hdr/phy/txrx.h @@ -41,7 +41,7 @@ public: bool init(srslte::radio_interface_phy* radio_handler, srslte::thread_pool* _workers_pool, phy_common* worker_com, - prach_worker* prach, + prach_worker_pool* prach_, srslte::log* log_h, uint32_t prio); void stop(); @@ -52,7 +52,7 @@ private: srslte::radio_interface_phy* radio_h = nullptr; srslte::log* log_h = nullptr; srslte::thread_pool* workers_pool = nullptr; - prach_worker* prach = nullptr; + prach_worker_pool* prach = nullptr; phy_common* worker_com = nullptr; srslte::channel_ptr ul_channel = nullptr; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index e00833b50..90480ba6f 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -57,9 +57,9 @@ public: /* PHY-MAC interface */ int sr_detected(uint32_t tti, uint16_t rnti) final { return mac.sr_detected(tti, rnti); } - int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) final + int rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) final { - return mac.rach_detected(tti, preamble_idx, time_adv); + return mac.rach_detected(tti, primary_cc_idx, preamble_idx, time_adv); } int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) final { return mac.ri_info(tti, rnti, ri_value); } int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) final { return mac.pmi_info(tti, rnti, pmi_value); } diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index d4ca1ce45..7cfce8a1b 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -61,7 +61,7 @@ public: /******** Interface from PHY (PHY -> MAC) ****************/ int sr_detected(uint32_t tti, uint16_t rnti) final; - int rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) final; + int rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) final; int set_dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl_ant_info); diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 83fdd068b..17d76c6f3 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -58,16 +58,12 @@ phy::~phy() void phy::parse_config(const phy_cfg_t& cfg) { // PRACH configuration - ZERO_OBJECT(prach_cfg); prach_cfg.config_idx = cfg.prach_cnfg.prach_cfg_info.prach_cfg_idx; prach_cfg.hs_flag = cfg.prach_cnfg.prach_cfg_info.high_speed_flag; prach_cfg.root_seq_idx = cfg.prach_cnfg.root_seq_idx; prach_cfg.zero_corr_zone = cfg.prach_cnfg.prach_cfg_info.zero_correlation_zone_cfg; prach_cfg.freq_offset = cfg.prach_cnfg.prach_cfg_info.prach_freq_offset; - // Uplink Physical common configuration - ZERO_OBJECT(workers_common.ul_cfg_com); - // DMRS workers_common.ul_cfg_com.dmrs.cyclic_shift = cfg.pusch_cnfg.ul_ref_sigs_pusch.cyclic_shift; workers_common.ul_cfg_com.dmrs.delta_ss = cfg.pusch_cnfg.ul_ref_sigs_pusch.group_assign_pusch; @@ -80,7 +76,7 @@ void phy::parse_config(const phy_cfg_t& cfg) asn1::rrc::pusch_cfg_common_s::pusch_cfg_basic_s_::hop_mode_e_::intra_and_inter_sub_frame ? srslte_pusch_hopping_cfg_t::SRSLTE_PUSCH_HOP_MODE_INTRA_SF : srslte_pusch_hopping_cfg_t::SRSLTE_PUSCH_HOP_MODE_INTER_SF; - ; + workers_common.ul_cfg_com.hopping.n_sb = cfg.pusch_cnfg.pusch_cfg_basic.n_sb; workers_common.ul_cfg_com.hopping.hopping_offset = cfg.pusch_cnfg.pusch_cfg_basic.pusch_hop_offset; workers_common.ul_cfg_com.pusch.max_nof_iterations = workers_common.params.pusch_max_its; @@ -95,7 +91,6 @@ void phy::parse_config(const phy_cfg_t& cfg) workers_common.ul_cfg_com.pucch.threshold_format1 = 0.8; // PDSCH configuration - ZERO_OBJECT(workers_common.dl_cfg_com); workers_common.dl_cfg_com.tm = SRSLTE_TM1; workers_common.dl_cfg_com.pdsch.rs_power = cfg.pdsch_cnfg.ref_sig_pwr; workers_common.dl_cfg_com.pdsch.p_b = cfg.pdsch_cnfg.p_b; @@ -107,7 +102,7 @@ int phy::init(const phy_args_t& args, srslte::radio_interface_phy* radio_, stack_interface_phy_lte* stack_) { - mlockall(MCL_CURRENT | MCL_FUTURE); + mlockall((uint32_t)MCL_CURRENT | (uint32_t)MCL_FUTURE); // Create array of pointers to phy_logs for (int i = 0; i < args.nof_phy_threads; i++) { @@ -148,7 +143,10 @@ int phy::init(const phy_args_t& args, workers_pool.init_worker(i, &workers[i], WORKERS_THREAD_PRIO); } - prach.init(cfg.cell, prach_cfg, stack_, log_vec.at(0).get(), PRACH_WORKER_THREAD_PRIO); + // For each carrier, initialise PRACH worker + for (uint32_t cc = 0; cc < args.nof_carriers; cc++) { + prach.init(cc, cfg.cell, prach_cfg, stack_, log_vec.at(0).get(), PRACH_WORKER_THREAD_PRIO); + } prach.set_max_prach_offset_us(args.max_prach_offset_us); // Warning this must be initialized after all workers have been added to the pool diff --git a/srsenb/src/phy/prach_worker.cc b/srsenb/src/phy/prach_worker.cc index 53e6d7aa2..d43cabce2 100644 --- a/srsenb/src/phy/prach_worker.cc +++ b/srsenb/src/phy/prach_worker.cc @@ -127,11 +127,17 @@ int prach_worker::run_tti(sf_buffer *b) if (prach_nof_det) { for (uint32_t i=0;iinfo("PRACH: %d/%d, preamble=%d, offset=%.1f us, peak2avg=%.1f, max_offset=%.1f us\n", - i, prach_nof_det, prach_indices[i], prach_offsets[i]*1e6, prach_p2avg[i], max_prach_offset_us); - + log_h->info("PRACH: cc=%d, %d/%d, preamble=%d, offset=%.1f us, peak2avg=%.1f, max_offset=%.1f us\n", + cc_idx, + i, + prach_nof_det, + prach_indices[i], + prach_offsets[i] * 1e6, + prach_p2avg[i], + max_prach_offset_us); + if (prach_offsets[i]*1e6 < max_prach_offset_us) { - stack->rach_detected(b->tti, prach_indices[i], (uint32_t)(prach_offsets[i] * 1e6)); + stack->rach_detected(b->tti, cc_idx, prach_indices[i], (uint32_t)(prach_offsets[i] * 1e6)); } } } diff --git a/srsenb/src/phy/txrx.cc b/srsenb/src/phy/txrx.cc index a1c6cbaa8..b8982e928 100644 --- a/srsenb/src/phy/txrx.cc +++ b/srsenb/src/phy/txrx.cc @@ -46,7 +46,7 @@ txrx::txrx() : thread("TXRX") bool txrx::init(srslte::radio_interface_phy* radio_h_, srslte::thread_pool* workers_pool_, phy_common* worker_com_, - prach_worker* prach_, + prach_worker_pool* prach_, srslte::log* log_h_, uint32_t prio_) { @@ -131,11 +131,12 @@ void txrx::run_thread() tx_worker_cnt = (tx_worker_cnt+1)%nof_workers; // Trigger phy worker execution - workers_pool->start_worker(worker); + workers_pool->start_worker(worker); - // Trigger prach worker execution - prach->new_tti(tti, buffer[0]); - + // Trigger prach worker execution + for (uint32_t cc = 0; cc < worker_com->params.nof_carriers; cc++) { + prach->new_tti(cc, tti, buffer[cc * worker_com->cell.nof_ports]); + } } else { // wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here running = false; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index abf009882..024410b6a 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -460,7 +460,7 @@ int mac::sr_detected(uint32_t tti, uint16_t rnti) return ret; } -int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) +int mac::rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) { log_h->step(tti);