Commit a6136177 authored by rmagueta's avatar rmagueta

Fix preamble shift at gNB for RA works with all preambles

parent 22fa28e7
......@@ -678,19 +678,10 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
}
else {
preamble_shift -= NCS;
// FIXME: It is working, but we need to differentiate between odd and even preamble index
// Check why preamble_shift does not match with UE
// 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;
}
preamble_shift+=((N_ZC/NCS)*NCS);
}
} else { // This is the high-speed case
new_dft = 0;
......
......@@ -257,6 +257,8 @@ typedef struct {
uint8_t RA_attempt_number;
/// Random-access procedure flag
uint8_t RA_active;
/// Random-access preamble index
int ra_PreambleIndex;
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
uint8_t generate_nr_prach;
......
......@@ -64,6 +64,8 @@ void init_RA(module_id_t mod_id,
RA_config_t *ra = &mac->ra;
ra->RA_active = 1;
ra->ra_PreambleIndex = -1;
ra->RA_usedGroupA = 1;
ra->RA_RAPID_found = 0;
ra->preambleTransMax = 0;
ra->first_Msg3 = 1;
......@@ -251,7 +253,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
int messageSizeGroupA = 0;
int sizeOfRA_PreamblesGroupA = 0;
int messagePowerOffsetGroupB = 0;
int PLThreshold;
int PLThreshold = 0;
long deltaPreamble_Msg3 = 0;
uint8_t noGroupB = 0;
RA_config_t *ra = &mac->ra;
......@@ -354,37 +356,34 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
}
/* Msg3 has not been transmitted yet */
if (ra->first_Msg3) {
if(ra->ra_PreambleIndex < 0 || ra->ra_PreambleIndex > 63) {
if (noGroupB) {
// use Group A preamble
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
ra->RA_usedGroupA = 1;
} else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
// Group B is configured and RA preamble Group A is used
// - todo add condition on CCCH_sdu_size for initiation by CCCH
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
ra->RA_usedGroupA = 1;
} else {
// Group B preamble is configured and used
// the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
// the remaining belong to RA Preambles Group B
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
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
if (ra->RA_usedGroupA && noGroupB) {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
} else if (ra->RA_usedGroupA && !noGroupB){
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
} else {
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
}
}
prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex;
}
// RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted)
......
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