Commit edccb986 authored by rmagueta's avatar rmagueta

First draft implementation of CBRA

parent 9d498e1a
...@@ -678,10 +678,19 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, ...@@ -678,10 +678,19 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
} }
else { else {
preamble_shift -= NCS;
// FIXME: It is working, but we need to differentiate between odd and even preamble index
if (preamble_shift < 0) // Check why preamble_shift does not match with UE
preamble_shift+=N_ZC; // TS 38.211 Section 6.3.3.1 Sequence generation
if(preamble_index%2==0) {
preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS));
preamble_shift *= NCS;
} else {
preamble_shift -= 2*NCS;
if (preamble_shift < 0)
preamble_shift+=N_ZC;
}
} }
} else { // This is the high-speed case } else { // This is the high-speed case
new_dft = 0; new_dft = 0;
......
...@@ -529,11 +529,13 @@ int nr_rrc_mac_config_req_ue( ...@@ -529,11 +529,13 @@ int nr_rrc_mac_config_req_ue(
mac->servCellIndex = *cell_group_config->spCellConfig->servCellIndex; mac->servCellIndex = *cell_group_config->spCellConfig->servCellIndex;
config_control_ue(mac); config_control_ue(mac);
if (cell_group_config->spCellConfig->reconfigurationWithSync) { if (cell_group_config->spCellConfig->reconfigurationWithSync) {
ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
config_common_ue(mac,module_id,cc_idP); }
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); config_common_ue(mac,module_id,cc_idP);
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
} }
// Setup the SSB to Rach Occasions mapping according to the config // Setup the SSB to Rach Occasions mapping according to the config
......
...@@ -79,8 +79,8 @@ void init_RA(module_id_t mod_id, ...@@ -79,8 +79,8 @@ void init_RA(module_id_t mod_id,
if (rach_ConfigDedicated) { if (rach_ConfigDedicated) {
if (rach_ConfigDedicated->cfra){ if (rach_ConfigDedicated->cfra){
LOG_I(MAC, "Initialization of 4-step contention-free random access procedure\n"); LOG_I(MAC, "Initialization of 2-step contention-free random access procedure\n");
prach_resources->RA_TYPE = RA_4STEP; prach_resources->RA_TYPE = RA_2STEP;
ra->cfra = 1; ra->cfra = 1;
} else if (rach_ConfigDedicated->ext1){ } else if (rach_ConfigDedicated->ext1){
if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){ if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){
...@@ -93,6 +93,10 @@ void init_RA(module_id_t mod_id, ...@@ -93,6 +93,10 @@ void init_RA(module_id_t mod_id,
} else { } else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__); LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__);
} }
} else if (nr_rach_ConfigCommon){
LOG_I(MAC, "Initialization of 4-step contention-based random access procedure\n");
prach_resources->RA_TYPE = RA_4STEP;
ra->cfra = 0;
} else { } else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__); LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__);
} }
...@@ -366,6 +370,12 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t ...@@ -366,6 +370,12 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA)); prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->RA_usedGroupA = 0; ra->RA_usedGroupA = 0;
} }
// TODO: Remove to generate random ra_PreambleIndex
printf("prach_resources->ra_PreambleIndex = %i\n", prach_resources->ra_PreambleIndex);
prach_resources->ra_PreambleIndex = 21;
ra->RA_usedGroupA = 1;
} else { // Msg3 is being retransmitted } else { // Msg3 is being retransmitted
if (ra->RA_usedGroupA && noGroupB) { if (ra->RA_usedGroupA && noGroupB) {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb); prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
......
...@@ -454,11 +454,15 @@ void nr_initiate_ra_proc(module_id_t module_idP, ...@@ -454,11 +454,15 @@ void nr_initiate_ra_proc(module_id_t module_idP,
// if the preamble received correspond to one of the listed // if the preamble received correspond to one of the listed
// the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries
int pr_found=0; int pr_found=0;
for (int i = 0; i < ra->preambles.num_preambles; i++) { if(ra->preambles.num_preambles > 0) {
if (preamble_index == ra->preambles.preamble_list[i]) { for (int i = 0; i < ra->preambles.num_preambles; i++) {
pr_found=1; if (preamble_index == ra->preambles.preamble_list[i]) {
break; pr_found=1;
break;
}
} }
} else {
pr_found=1;
} }
if (!pr_found) { if (!pr_found) {
......
...@@ -226,7 +226,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ...@@ -226,7 +226,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000; secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1 = NULL; secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1 = NULL;
/* contention free ra */
// For 2-step contention-free random access procedure
#if 0
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = calloc(1,sizeof(struct NR_ReconfigurationWithSync__rach_ConfigDedicated)); secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = calloc(1,sizeof(struct NR_ReconfigurationWithSync__rach_ConfigDedicated));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->present= NR_ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->present= NR_ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink= calloc(1,sizeof(struct NR_RACH_ConfigDedicated)); secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink= calloc(1,sizeof(struct NR_RACH_ConfigDedicated));
...@@ -240,12 +242,13 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ...@@ -240,12 +242,13 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.present = NR_CFRA__resources_PR_ssb; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.present = NR_CFRA__resources_PR_ssb;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb = calloc(1,sizeof(struct NR_CFRA__resources__ssb)); secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb = calloc(1,sizeof(struct NR_CFRA__resources__ssb));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0;
struct NR_CFRA_SSB_Resource *ssbElem[8]; struct NR_CFRA_SSB_Resource *ssbElem[8];
ssbElem[0] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); ssbElem[0] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[0]->ssb = 0; ssbElem[0]->ssb = 0;
ssbElem[0]->ra_PreambleIndex = 63; ssbElem[0]->ra_PreambleIndex = 63;
ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[0]); ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[0]);
#if 0
ssbElem[1] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); ssbElem[1] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[1]->ssb = 1; ssbElem[1]->ssb = 1;
ssbElem[1]->ra_PreambleIndex = 62; ssbElem[1]->ra_PreambleIndex = 62;
...@@ -274,8 +277,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ...@@ -274,8 +277,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
ssbElem[7]->ssb = 7; ssbElem[7]->ssb = 7;
ssbElem[7]->ra_PreambleIndex = 63; ssbElem[7]->ra_PreambleIndex = 63;
ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[7]); ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[7]);
#endif
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL;
#endif
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup; secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment