@@ -122,7 +122,7 @@ bool proc_ra_nr::has_rar_rnti()
122122void proc_ra_nr::received_contention_resolution (bool is_successful)
123123{
124124 std::lock_guard<std::mutex> lock (mutex);
125- ra_contention_resolution (is_successful);
125+ ra_contention_resolution (is_successful, false );
126126}
127127
128128void proc_ra_nr::timer_expired (uint32_t timer_id)
@@ -196,8 +196,6 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
196196 return ;
197197 }
198198
199- // Stop rar timer
200- rar_timeout_timer.stop ();
201199 if (tb.ack && tb.payload != nullptr ) {
202200 srsran::mac_rar_pdu_nr pdu;
203201 if (!pdu.unpack (tb.payload ->msg , tb.payload ->N_bytes )) {
@@ -211,6 +209,9 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
211209
212210 for (auto & subpdu : pdu.get_subpdus ()) {
213211 if (subpdu.has_rapid () && subpdu.get_rapid () == preamble_index) {
212+ // Stop rar timer
213+ rar_timeout_timer.stop ();
214+
214215 logger.debug (" PROC RA NR: Setting UL grant and prepare Msg3" );
215216 mac.set_temp_crnti (subpdu.get_temp_crnti ());
216217
@@ -231,18 +232,20 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
231232 } else {
232233 preamble_backoff = 0 ;
233234 }
235+
236+ contention_resolution_timer.set (rach_cfg.ra_ContentionResolutionTimer ,
237+ [this ](uint32_t tid) { timer_expired (tid); });
238+ contention_resolution_timer.run ();
239+ logger.debug (" Waiting for Contention Resolution" );
240+ state = WAITING_FOR_CONTENTION_RESOLUTION;
234241 }
235242 }
236243 }
237- contention_resolution_timer.set (rach_cfg.ra_ContentionResolutionTimer , [this ](uint32_t tid) { timer_expired (tid); });
238- contention_resolution_timer.run ();
239- logger.debug (" Waiting for Contention Resolution" );
240- state = WAITING_FOR_CONTENTION_RESOLUTION;
241244}
242245
243246// TS 38.321 Section 5.1.5 2 ways to resolve contention resolution
244247// if the C-RNTI MAC CE was included in Msg3: (only this one is implemented)
245- void proc_ra_nr::ra_contention_resolution (bool received_con_res_matches_ue_id )
248+ void proc_ra_nr::ra_contention_resolution (bool is_successful, bool is_ul_grant )
246249{
247250 if (state != WAITING_FOR_CONTENTION_RESOLUTION) {
248251 logger.warning (
@@ -251,15 +254,20 @@ void proc_ra_nr::ra_contention_resolution(bool received_con_res_matches_ue_id)
251254 srsran::enum_to_text (state_str_nr, (uint32_t )ra_state_t ::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION));
252255 return ;
253256 }
254- if (started_by == initiators_t ::RRC || started_by == initiators_t ::MAC || received_con_res_matches_ue_id) {
255- if (received_con_res_matches_ue_id) {
256- logger.info (" Received CONRES ID matches transmitted UE ID" );
257+ if (started_by == initiators_t ::RRC || started_by == initiators_t ::MAC || is_successful) {
258+ if (is_successful) {
259+ if (is_ul_grant) {
260+ logger.info (" PDCCH to C-RNTI received with a new UL grant of transmission" );
261+ } else {
262+ logger.info (" Received CONRES ID matches transmitted UE ID" );
263+ }
264+ contention_resolution_timer.stop ();
265+ state = WAITING_FOR_COMPLETION;
266+ ra_completion ();
257267 } else {
258- logger.info (" PDCCH to C-RNTI received with a new UL grant of transmission" );
268+ logger.info (" Received CONRES ID DOES NOT match transmitted UE ID" );
269+ mac.set_temp_crnti (SRSRAN_INVALID_RNTI);
259270 }
260- contention_resolution_timer.stop ();
261- state = WAITING_FOR_COMPLETION;
262- ra_completion ();
263271 } else {
264272 logger.error (" Not started by the correct initiator MAC or RRC" );
265273 }
@@ -375,7 +383,7 @@ void proc_ra_nr::handle_rar_pdu(mac_interface_phy_nr::tb_action_dl_result_t& res
375383// Called from PHY thread, defer actions therefore.
376384void proc_ra_nr::pdcch_to_crnti ()
377385{
378- task_queue.push ([this ]() { ra_contention_resolution (false ); });
386+ task_queue.push ([this ]() { ra_contention_resolution (true , true ); });
379387}
380388
381389bool proc_ra_nr::is_contention_resolution ()
0 commit comments