diff --git a/lib/include/srslte/interfaces/ue_nr_interfaces.h b/lib/include/srslte/interfaces/ue_nr_interfaces.h index c5dbc6426..e38825eca 100644 --- a/lib/include/srslte/interfaces/ue_nr_interfaces.h +++ b/lib/include/srslte/interfaces/ue_nr_interfaces.h @@ -61,7 +61,7 @@ public: /// Indicate reception of UL grant (only TBS is provided). Buffer for resulting MAC PDU is provided by MAC and is /// passed as pointer to PHY during tx_reuqest - virtual void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) = 0; + virtual void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t phy_tx_pdu) = 0; /** * @brief Indicate the successful transmission of a PRACH. diff --git a/lib/src/common/basic_vnf.cc b/lib/src/common/basic_vnf.cc index de5793f92..6f0ebf8ad 100644 --- a/lib/src/common/basic_vnf.cc +++ b/lib/src/common/basic_vnf.cc @@ -217,7 +217,8 @@ int srslte_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg) ul_grant.tti = msg->tti; ul_grant.tbs = msg->pdus.length; ul_grant.rnti = msg->rnti; - m_ue_stack->new_grant_ul(cc_idx, ul_grant); + srslte::unique_byte_buffer_t tx_pdu = srslte::make_byte_buffer(); + m_ue_stack->new_grant_ul(cc_idx, ul_grant, std::move(tx_pdu)); return SRSLTE_SUCCESS; } diff --git a/srsue/hdr/stack/mac_nr/mac_nr.h b/srsue/hdr/stack/mac_nr/mac_nr.h index 10ba5910c..440d2c9f3 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr.h +++ b/srsue/hdr/stack/mac_nr/mac_nr.h @@ -52,7 +52,7 @@ public: int sf_indication(const uint32_t tti); void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant); - void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant); + void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t tx_pdu); void prach_sent(const uint32_t tti, const uint32_t s_id, const uint32_t t_id, @@ -95,7 +95,7 @@ public: private: void write_pcap(const uint32_t cc_idx, mac_nr_grant_dl_t& grant); // If PCAPs are enabled for this MAC void handle_pdu(srslte::unique_byte_buffer_t pdu); - void get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr::tx_request_t* tx_request); + void get_ul_data(const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t tx_pdu); // temporary helper void handle_rar_pdu(mac_nr_grant_dl_t& grant); diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index c3292f2fe..509c8e471 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -126,7 +126,7 @@ public: int sf_indication(const uint32_t tti) final { return SRSLTE_SUCCESS; } void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) final { mac_nr.tb_decoded(cc_idx, grant); } - void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) final { mac_nr.new_grant_ul(cc_idx, grant); } + void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t tx_pdu) final { mac_nr.new_grant_ul(cc_idx, grant, std::move(tx_pdu)); } void run_tti(const uint32_t tti) final { diff --git a/srsue/hdr/stack/ue_stack_nr.h b/srsue/hdr/stack/ue_stack_nr.h index 634256fb3..9a23b120f 100644 --- a/srsue/hdr/stack/ue_stack_nr.h +++ b/srsue/hdr/stack/ue_stack_nr.h @@ -82,7 +82,7 @@ public: return SRSLTE_SUCCESS; } void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) final { mac->tb_decoded(cc_idx, grant); } - void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) final { mac->new_grant_ul(cc_idx, grant); } + void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t phy_tx_pdu) final { mac->new_grant_ul(cc_idx, grant, std::move(phy_tx_pdu)); } void prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t f_id, uint32_t ul_carrier_id) { mac->prach_sent(tti, s_id, t_id, f_id, ul_carrier_id); diff --git a/srsue/src/phy/nr/cc_worker.cc b/srsue/src/phy/nr/cc_worker.cc index b4ee3cfaa..ffd957551 100644 --- a/srsue/src/phy/nr/cc_worker.cc +++ b/srsue/src/phy/nr/cc_worker.cc @@ -288,7 +288,7 @@ bool cc_worker::work_ul() mac_ul_grant.tti = ul_slot_cfg.idx; mac_ul_grant.tbs = pusch_cfg.grant.tb[0].tbs; srslte::unique_byte_buffer_t tx_pdu = srslte::make_byte_buffer(); - phy->stack->new_grant_ul(0, mac_ul_grant, tx_pdu.get()); + phy->stack->new_grant_ul(0, mac_ul_grant, std::move(tx_pdu)); // Provisional reset and assign Tx softbuffer srslte_softbuffer_tx_reset(&softbuffer_tx); pusch_cfg.grant.tb[0].softbuffer.tx = &softbuffer_tx; diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index 5c46c071e..d34980141 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -198,23 +198,15 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) stack_task_dispatch_queue.push([this]() { process_pdus(); }); } -void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) +void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t phy_tx_pdu) { - phy_interface_stack_nr::tx_request_t tx_request = {}; - - get_ul_data(grant, &tx_request); - - // send TX.request - phy->tx_request(tx_request); + get_ul_data(grant, std::move(phy_tx_pdu)); metrics[cc_idx].tx_pkts++; } -void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr::tx_request_t* tx_request) +void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srslte::unique_byte_buffer_t phy_tx_pdu) { - // Todo: delegate to mux class - tx_request->tb_len = grant.tbs; - // initialize MAC PDU tx_buffer->clear(); tx_pdu.init_tx(tx_buffer.get(), grant.tbs, true); @@ -256,11 +248,11 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr: logger.info(tx_buffer->msg, tx_buffer->N_bytes, "Generated MAC PDU (%d B)", tx_buffer->N_bytes); - tx_request->data = tx_buffer->msg; - tx_request->tb_len = tx_buffer->N_bytes; + memcpy(phy_tx_pdu.get()->msg, tx_buffer->msg, tx_buffer->N_bytes); + phy_tx_pdu.get()->N_bytes = tx_buffer->N_bytes; if (pcap) { - pcap->write_ul_crnti_nr(tx_request->data, tx_request->tb_len, grant.rnti, grant.pid, grant.tti); + pcap->write_ul_crnti_nr(tx_buffer->msg, tx_buffer->N_bytes, grant.rnti, grant.pid, grant.tti); } } diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 454052e7e..5a9fdb7bc 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -177,6 +177,7 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::mac_nr_grant_ for (auto& subpdu : pdu.get_subpdus()) { if (subpdu.has_rapid() && subpdu.get_rapid() == preamble_index) { + logger.info("PROC RA NR: Setting ul grant and prepare msg3"); phy->set_ul_grant(subpdu.get_ul_grant()); // reset all parameters that are used before rar rar_rnti = SRSLTE_INVALID_RNTI;