Refactor new-RNTI functionality in separate function
This function will be used in the case of a handover for getting a new RNTI (checking that we do not reuse an already used RNTI).
This commit is contained in:
@@ -40,7 +40,6 @@
|
|||||||
#include "common/utils/LOG/vcd_signal_dumper.h"
|
#include "common/utils/LOG/vcd_signal_dumper.h"
|
||||||
#include "common/utils/nr/nr_common.h"
|
#include "common/utils/nr/nr_common.h"
|
||||||
#include "UTIL/OPT/opt.h"
|
#include "UTIL/OPT/opt.h"
|
||||||
#include "SIMULATION/TOOLS/sim.h" // for taus
|
|
||||||
|
|
||||||
/* rlc */
|
/* rlc */
|
||||||
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
|
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
|
||||||
@@ -677,16 +676,6 @@ static NR_RA_t *find_free_nr_RA(NR_RA_t *ra_base, int ra_count, uint16_t preambl
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const NR_RA_t *find_nr_RA_rnti(const NR_RA_t *ra_base, int ra_count, rnti_t rnti)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ra_count; ++i) {
|
|
||||||
const NR_RA_t *ra = &ra_base[i];
|
|
||||||
if (ra->ra_state != nrRA_gNB_IDLE && ra->rnti == rnti)
|
|
||||||
return ra;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nr_initiate_ra_proc(module_id_t module_idP,
|
void nr_initiate_ra_proc(module_id_t module_idP,
|
||||||
int CC_id,
|
int CC_id,
|
||||||
frame_t frameP,
|
frame_t frameP,
|
||||||
@@ -712,23 +701,13 @@ void nr_initiate_ra_proc(module_id_t module_idP,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA
|
if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA
|
||||||
int loop = 0;
|
bool rnti_found = nr_mac_get_new_rnti(&nr_mac->UE_info, cc->ra, sizeofArray(cc->ra), &ra->rnti);
|
||||||
bool exist_connected_ue, exist_in_pending_ra_ue;
|
if (!rnti_found) {
|
||||||
rnti_t trial = 0;
|
|
||||||
do {
|
|
||||||
// 3GPP TS 38.321 version 15.13.0 Section 7.1 Table 7.1-1: RNTI values
|
|
||||||
while (trial < 1 || trial > 0xffef)
|
|
||||||
trial = (taus() % 0xffef) + 1;
|
|
||||||
exist_connected_ue = find_nr_UE(&nr_mac->UE_info, trial) != NULL;
|
|
||||||
exist_in_pending_ra_ue = find_nr_RA_rnti(cc->ra, sizeofArray(cc->ra), ra->rnti) != NULL;
|
|
||||||
loop++;
|
|
||||||
} while (loop < 100 && (exist_connected_ue || exist_in_pending_ra_ue) );
|
|
||||||
if (loop == 100) {
|
|
||||||
LOG_E(NR_MAC, "initialisation random access: no more available RNTIs for new UE\n");
|
LOG_E(NR_MAC, "initialisation random access: no more available RNTIs for new UE\n");
|
||||||
|
nr_clear_ra_proc(ra);
|
||||||
NR_SCHED_UNLOCK(&nr_mac->sched_lock);
|
NR_SCHED_UNLOCK(&nr_mac->sched_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ra->rnti = trial;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ra->preamble_frame = frameP;
|
ra->preamble_frame = frameP;
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
#include "uper_encoder.h"
|
#include "uper_encoder.h"
|
||||||
#include "uper_decoder.h"
|
#include "uper_decoder.h"
|
||||||
|
|
||||||
|
#include "SIMULATION/TOOLS/sim.h" // for taus
|
||||||
|
|
||||||
#define ENABLE_MAC_PAYLOAD_DEBUG
|
#define ENABLE_MAC_PAYLOAD_DEBUG
|
||||||
#define DEBUG_gNB_SCHEDULER 1
|
#define DEBUG_gNB_SCHEDULER 1
|
||||||
|
|
||||||
@@ -3395,3 +3397,26 @@ bool nr_mac_remove_lcid(NR_UE_sched_ctrl_t *sched_ctrl, long lcid)
|
|||||||
seq_arr_erase(&sched_ctrl->lc_config, elm.it);
|
seq_arr_erase(&sched_ctrl->lc_config, elm.it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const NR_RA_t *find_nr_RA_rnti(const NR_RA_t *ra_base, int ra_count, rnti_t rnti)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ra_count; ++i) {
|
||||||
|
const NR_RA_t *ra = &ra_base[i];
|
||||||
|
if (ra->ra_state != nrRA_gNB_IDLE && ra->rnti == rnti)
|
||||||
|
return ra;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nr_mac_get_new_rnti(NR_UEs_t *UEs, const NR_RA_t *ra_base, int ra_count, rnti_t *rnti)
|
||||||
|
{
|
||||||
|
int loop = 0;
|
||||||
|
bool exist_connected_ue, exist_in_pending_ra_ue;
|
||||||
|
do {
|
||||||
|
*rnti = (taus() % 0xffef) + 1;
|
||||||
|
exist_connected_ue = find_nr_UE(UEs, *rnti) != NULL;
|
||||||
|
exist_in_pending_ra_ue = find_nr_RA_rnti(ra_base, ra_count, *rnti) != NULL;
|
||||||
|
loop++;
|
||||||
|
} while (loop < 100 && (exist_connected_ue || exist_in_pending_ra_ue));
|
||||||
|
return loop < 100; // nothing found: loop count 100
|
||||||
|
}
|
||||||
|
|||||||
@@ -477,4 +477,6 @@ void process_addmod_bearers_cellGroupConfig(NR_UE_sched_ctrl_t *sched_ctrl,
|
|||||||
bool nr_mac_add_lcid(NR_UE_sched_ctrl_t *sched_ctrl, const nr_lc_config_t *c);
|
bool nr_mac_add_lcid(NR_UE_sched_ctrl_t *sched_ctrl, const nr_lc_config_t *c);
|
||||||
bool nr_mac_remove_lcid(NR_UE_sched_ctrl_t *sched_ctrl, long lcid);
|
bool nr_mac_remove_lcid(NR_UE_sched_ctrl_t *sched_ctrl, long lcid);
|
||||||
|
|
||||||
|
bool nr_mac_get_new_rnti(NR_UEs_t *UEs, const NR_RA_t *ra_base, int ra_count, rnti_t *rnti);
|
||||||
|
|
||||||
#endif /*__LAYER2_NR_MAC_PROTO_H__*/
|
#endif /*__LAYER2_NR_MAC_PROTO_H__*/
|
||||||
|
|||||||
Reference in New Issue
Block a user