diff --git a/srsue/hdr/stack/mac_nr/ul_harq_nr.h b/srsue/hdr/stack/mac_nr/ul_harq_nr.h index 4bb5ac21a..605daa194 100644 --- a/srsue/hdr/stack/mac_nr/ul_harq_nr.h +++ b/srsue/hdr/stack/mac_nr/ul_harq_nr.h @@ -88,6 +88,8 @@ private: std::unique_ptr harq_buffer = nullptr; + void save_grant(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant); + void generate_tx(mac_interface_phy_nr::tb_action_ul_t* action); void generate_new_tx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant, mac_interface_phy_nr::tb_action_ul_t* action); @@ -104,6 +106,8 @@ private: srsran::ul_harq_cfg_t harq_cfg = {}; ul_harq_metrics_t metrics = {}; std::mutex metrics_mutex; + + const static uint8_t NDI_NOT_SET = 100; }; typedef std::unique_ptr ul_harq_entity_nr_ptr; diff --git a/srsue/src/stack/mac_nr/ul_harq_nr.cc b/srsue/src/stack/mac_nr/ul_harq_nr.cc index 1f4ae8c49..a27eb5f5d 100644 --- a/srsue/src/stack/mac_nr/ul_harq_nr.cc +++ b/srsue/src/stack/mac_nr/ul_harq_nr.cc @@ -144,11 +144,12 @@ void ul_harq_entity_nr::ul_harq_process_nr::reset() nof_retx = 0; harq_buffer = nullptr; current_grant = {}; + reset_ndi(); } void ul_harq_entity_nr::ul_harq_process_nr::reset_ndi() { - current_grant.ndi = false; + current_grant.ndi = NDI_NOT_SET; } uint8_t ul_harq_entity_nr::ul_harq_process_nr::get_ndi() @@ -226,11 +227,21 @@ int ul_harq_entity_nr::ul_harq_process_nr::get_current_tbs() return current_grant.tbs; } +void ul_harq_entity_nr::ul_harq_process_nr::save_grant(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant) +{ + current_grant = grant; + // When determining if NDI has been toggled compared to the value in the previous transmission the MAC entity shall + // ignore NDI received in all uplink grants on PDCCH for its Temporary C-RNTI. + if (grant.is_rar_grant || grant.rnti == harq_entity->mac->get_temp_crnti()) { + reset_ndi(); + } +} + // New transmission (Section 5.4.2.2) void ul_harq_entity_nr::ul_harq_process_nr::generate_new_tx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant, mac_interface_phy_nr::tb_action_ul_t* action) { - current_grant = grant; + save_grant(grant); nof_retx = 0; logger.info("UL %d: New TX%s, rv=%d, tbs=%d", @@ -252,7 +263,7 @@ void ul_harq_entity_nr::ul_harq_process_nr::generate_retx(const mac_interface_ph logger.info("UL %d: Retx=%d, rv=%d, tbs=%d", pid, nof_retx, grant.rv, grant.tbs); // overwrite original grant - current_grant = grant; + save_grant(grant); generate_tx(action);