Commit ffa5911d authored by cig's avatar cig

RA fixes

parent 903a1ec6
This diff is collapsed.
...@@ -70,12 +70,6 @@ ...@@ -70,12 +70,6 @@
// F: lenght of L is 0:8 or 1:16 bits wide // F: lenght of L is 0:8 or 1:16 bits wide
// R: Reserved bit, set to zero. // R: Reserved bit, set to zero.
typedef enum {
RA_IDLE = 0,
WAIT_RAR = 1,
WAIT_CONTENTION_RESOLUTION = 2
} RA_state_t;
typedef struct { typedef struct {
uint8_t LCID:6; // octet 1 [5:0] uint8_t LCID:6; // octet 1 [5:0]
uint8_t F:1; // octet 1 [6] uint8_t F:1; // octet 1 [6]
......
...@@ -74,6 +74,12 @@ typedef enum { ...@@ -74,6 +74,12 @@ typedef enum {
SFN_C_IMPOSSIBLE SFN_C_IMPOSSIBLE
} SFN_C_TYPE; } SFN_C_TYPE;
typedef enum {
RA_IDLE = 0,
WAIT_RAR = 1,
WAIT_CONTENTION_RESOLUTION = 2
} RA_state_t;
/*!\brief Top level UE MAC structure */ /*!\brief Top level UE MAC structure */
typedef struct { typedef struct {
......
...@@ -215,5 +215,7 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id, ...@@ -215,5 +215,7 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id,
const uint8_t preamble_index, const uint8_t preamble_index,
uint8_t * selected_rar_buffer); uint8_t * selected_rar_buffer);
void nr_process_rar(nr_downlink_indication_t *dl_info);
#endif #endif
/** @}*/ /** @}*/
...@@ -54,72 +54,64 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id, ...@@ -54,72 +54,64 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id,
uint8_t * const dlsch_buffer, uint8_t * const dlsch_buffer,
rnti_t * const t_crnti, rnti_t * const t_crnti,
const uint8_t preamble_index, const uint8_t preamble_index,
uint8_t * selected_rar_buffer/*output argument for storing the selected RAR header and RAR payload*/){ uint8_t * selected_rar_buffer){
NR_UE_MAC_INST_t *nrUE_mac_inst = get_mac_inst(mod_id); NR_UE_MAC_INST_t *nrUE_mac_inst = get_mac_inst(mod_id);
uint16_t ret = 0; // return value
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer; NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer;
uint16_t ret = 0;
// TODO TBR
// NR_RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); // NR_RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1);
uint8_t *rar = (uint8_t *) (dlsch_buffer + 1); uint8_t *rar = (uint8_t *) (dlsch_buffer + 1);
// get the last RAR payload for working with CMW500 // get the last RAR payload for working with CMW500
uint8_t n_rarpy = 0; // number of RAR payloads uint8_t n_rarpy = 0; // number of RAR payloads
uint8_t n_rarh = 0; // number of MAC RAR subheaders uint8_t n_rarh = 0; // number of MAC RAR subheaders
uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs
AssertFatal(CC_id == 0, "RAR reception on secondary CCs is not supported yet\n");
while (1) { while (1) {
n_rarh++; n_rarh++;
if (rarh->T == 1) { if (rarh->T == 1) {
n_rarpy++; n_rarpy++;
LOG_D(MAC, "RAPID %d\n", rarh->RAPID); LOG_D(MAC, "RAPID %d\n", rarh->RAPID);
} }
if (rarh->RAPID == preamble_index) { if (rarh->RAPID == preamble_index) {
LOG_D(PHY, "Found RAR with the intended RAPID %d\n", LOG_D(PHY, "Found RAR with the intended RAPID %d\n",
rarh->RAPID); rarh->RAPID);
rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6); rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6);
nrUE_mac_inst->RA_RAPID_found = 1; nrUE_mac_inst->RA_RAPID_found = 1;
break; break;
} }
if (abs((int) rarh->RAPID - (int) preamble_index) < if (abs((int) rarh->RAPID - (int) preamble_index) <
abs((int) best_rx_rapid - (int) preamble_index)) { abs((int) best_rx_rapid - (int) preamble_index)) {
best_rx_rapid = rarh->RAPID; best_rx_rapid = rarh->RAPID;
rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6); rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6);
} }
if (rarh->E == 0) { if (rarh->E == 0) {
LOG_I(PHY, "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", best_rx_rapid); LOG_I(PHY, "No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n", best_rx_rapid);
break; break;
} else { } else {
rarh++; rarh++;
} }
}; };
LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n",
n_rarh, n_rarpy); n_rarh, n_rarpy);
if (CC_id > 0) {
LOG_W(MAC, "Should not have received RAR on secondary CCs! \n");
return (0xffff);
}
LOG_I(MAC, LOG_I(MAC,
"[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2],
rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
#ifdef DEBUG_RAR #ifdef DEBUG_RAR
LOG_D(MAC, "[UE %d][RAPROC] rarh->E %d\n", mod_id, rarh->E); LOG_D(MAC, "[UE %d][RAPROC] rarh->E %d\n", mod_id, rarh->E);
LOG_D(MAC, "[UE %d][RAPROC] rarh->T %d\n", mod_id, rarh->T); LOG_D(MAC, "[UE %d][RAPROC] rarh->T %d\n", mod_id, rarh->T);
LOG_D(MAC, "[UE %d][RAPROC] rarh->RAPID %d\n", mod_id, LOG_D(MAC, "[UE %d][RAPROC] rarh->RAPID %d\n", mod_id,
rarh->RAPID); rarh->RAPID);
// LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",mod_id,rar->R); // LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",mod_id,rar->R);
LOG_D(MAC, "[UE %d][RAPROC] rar->Timing_Advance_Command %d\n", LOG_D(MAC, "[UE %d][RAPROC] rar->Timing_Advance_Command %d\n",
mod_id, (((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4)); mod_id, (((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4));
// LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",mod_id,rar->hopping_flag); // LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",mod_id,rar->hopping_flag);
// LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",mod_id,rar->rb_alloc); // LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",mod_id,rar->rb_alloc);
// LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",mod_id,rar->mcs); // LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",mod_id,rar->mcs);
...@@ -127,26 +119,26 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id, ...@@ -127,26 +119,26 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id,
// LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",mod_id,rar->UL_delay); // LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",mod_id,rar->UL_delay);
// LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",mod_id,rar->cqi_req); // LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",mod_id,rar->cqi_req);
LOG_D(MAC, "[UE %d][RAPROC] rar->t_crnti %x\n", mod_id, LOG_D(MAC, "[UE %d][RAPROC] rar->t_crnti %x\n", mod_id,
(uint16_t) rar[5] + (rar[4] << 8)); (uint16_t) rar[5] + (rar[4] << 8));
#endif #endif
if (opt_enabled) { if (opt_enabled) {
LOG_D(OPT, LOG_D(OPT,
"[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n", "[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n",
mod_id, CC_id, frameP, ra_rnti); mod_id, CC_id, frameP, ra_rnti);
/*trace_pdu(DIRECTION_DOWNLINK, (uint8_t *) dlsch_buffer, n_rarh + n_rarpy * 6, /*trace_pdu(DIRECTION_DOWNLINK, (uint8_t *) dlsch_buffer, n_rarh + n_rarpy * 6,
mod_id, WS_RA_RNTI, ra_rnti, nrUE_mac_inst->rxFrame, mod_id, WS_RA_RNTI, ra_rnti, nrUE_mac_inst->rxFrame,
nrUE_mac_inst->rxSubframe, 0, 0);*/ // TODO TBR fix rxframe and subframe nrUE_mac_inst->rxSubframe, 0, 0);*/ // TODO TBR fix rxframe and subframe
} }
if (preamble_index == rarh->RAPID) { // TBR double check this if (preamble_index == rarh->RAPID) { // TBR double check this
*t_crnti = (uint16_t) rar[5] + (rar[4] << 8); //rar->t_crnti; *t_crnti = (uint16_t) rar[5] + (rar[4] << 8); //rar->t_crnti;
nrUE_mac_inst->crnti = *t_crnti; //rar->t_crnti; nrUE_mac_inst->crnti = *t_crnti; //rar->t_crnti;
//return(rar->Timing_Advance_Command); //return(rar->Timing_Advance_Command);
ret = ((((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4)); ret = ((((uint16_t) (rar[0] & 0x7f)) << 4) + (rar[1] >> 4));
} else { } else {
nrUE_mac_inst->crnti = 0; nrUE_mac_inst->crnti = 0;
ret = (0xffff); ret = (0xffff);
} }
// move the selected RAR to the front of the RA_PDSCH buffer // move the selected RAR to the front of the RA_PDSCH buffer
...@@ -154,4 +146,4 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id, ...@@ -154,4 +146,4 @@ uint16_t nr_ue_process_rar(const module_id_t mod_id,
memcpy(selected_rar_buffer + 1, (uint8_t *) rar, 6); memcpy(selected_rar_buffer + 1, (uint8_t *) rar, 6);
return ret; return ret;
} }
\ No newline at end of file
...@@ -380,7 +380,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, ...@@ -380,7 +380,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
} }
// Phytest scheduling // Phytest scheduling
if (phy_test && slot_txP==1){ // TBR check phy_test if (phy_test && slot_txP==1){
nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP,NULL); nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP,NULL);
// This schedules Random-Access for NR starting in subframeP // This schedules Random-Access for NR starting in subframeP
nr_schedule_RA(module_idP, frame_txP, slot_txP); nr_schedule_RA(module_idP, frame_txP, slot_txP);
......
...@@ -75,6 +75,14 @@ ...@@ -75,6 +75,14 @@
/*!\brief Maximum number of random access process */ /*!\brief Maximum number of random access process */
#define NR_NB_RA_PROC_MAX 4 #define NR_NB_RA_PROC_MAX 4
typedef enum {
RA_IDLE = 0,
Msg2 = 1,
WAIT_Msg3 = 2,
Msg4 = 3,
WAIT_Msg4_ACK = 4
} RA_state_t;
/*! \brief gNB template for the Random access information */ /*! \brief gNB template for the Random access information */
typedef struct { typedef struct {
/// Flag to indicate this process is active /// Flag to indicate this process is active
......
...@@ -64,11 +64,7 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) { ...@@ -64,11 +64,7 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) {
NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf), NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti);
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) // TBR
,0
#endif
);
} }
} }
......
...@@ -93,12 +93,15 @@ int8_t handle_dlsch (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_n ...@@ -93,12 +93,15 @@ int8_t handle_dlsch (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_n
*/ */
} }
int8_t handle_rar (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, uint8_t *pduP, uint32_t pdu_len, frame_t frame, int slot, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){ int8_t handle_rar (nr_downlink_indication_t *dl_info,
uint8_t *pduP,
if (IS_SOFTMODEM_NOS1 || IS_SOFTMODEM_RFSIM) uint32_t pdu_len,
//nr_process_rar(ue,proc, gNB_index, mode); TBR NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){ // TBR not used params
LOG_D(MAC, "handling RAR at MAC layer \n");
nr_process_rar (dl_info);
return 0; return 0;
} }
int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
...@@ -260,10 +263,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ ...@@ -260,10 +263,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
break; break;
case FAPI_NR_RX_PDU_TYPE_RAR: case FAPI_NR_RX_PDU_TYPE_RAR:
/*ret_mask |= (handle_rar(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind, ret_mask |= (handle_rar(dl_info,
(dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu,
(dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length,
dl_info->frame, dl_info->slot,ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_RAR;*/ //TODO TBR ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_RAR;
break; break;
default: default:
......
...@@ -199,7 +199,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc) { ...@@ -199,7 +199,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc) {
rrc->carrier.pdsch_AntennaPorts, rrc->carrier.pdsch_AntennaPorts,
(NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon, (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon,
0, 0,
0, 0, // TBR hardcoded rnti
(NR_CellGroupConfig_t *)NULL (NR_CellGroupConfig_t *)NULL
); );
......
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