Commit 72c38798 authored by Cedric Roux's avatar Cedric Roux

Merge remote-tracking branch 'origin/bugfix-229' into develop_integration_w13

parents 26f06f35 adf920b6
...@@ -258,7 +258,7 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, ...@@ -258,7 +258,7 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue,
if (ulsch->harq_processes[harq_pid]->nb_rb > 4) { if (ulsch->harq_processes[harq_pid]->nb_rb > 4) {
msg("rar_tools.c: unlikely rb count for RAR grant : nb_rb > 3\n"); msg("rar_tools.c: unlikely rb count for RAR grant : nb_rb > 3\n");
return(-1); // return(-1);
} }
// ulsch->harq_processes[harq_pid]->Ndi = 1; // ulsch->harq_processes[harq_pid]->Ndi = 1;
......
...@@ -3242,7 +3242,8 @@ void process_rar(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, runmode_t mo ...@@ -3242,7 +3242,8 @@ void process_rar(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, runmode_t mo
ue->prach_resources[eNB_id]->ra_RNTI, ue->prach_resources[eNB_id]->ra_RNTI,
dlsch0->harq_processes[0]->b, dlsch0->harq_processes[0]->b,
&ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->crnti, &ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->crnti,
ue->prach_resources[eNB_id]->ra_PreambleIndex); ue->prach_resources[eNB_id]->ra_PreambleIndex,
dlsch0->harq_processes[0]->b); // alter the 'b' buffer so it contains only the selected RAR header and RAR payload
ue->pdcch_vars[(subframe_rx+1) & 0x1][eNB_id]->crnti = ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->crnti; ue->pdcch_vars[(subframe_rx+1) & 0x1][eNB_id]->crnti = ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->crnti;
......
...@@ -454,6 +454,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,u ...@@ -454,6 +454,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,u
@param t_crnti Pointer to PHY variable containing the T_CRNTI @param t_crnti Pointer to PHY variable containing the T_CRNTI
@param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of @param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of
random-access procedure random-access procedure
@param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload
@returns timing advance or 0xffff if preamble doesn't match @returns timing advance or 0xffff if preamble doesn't match
*/ */
uint16_t uint16_t
...@@ -464,7 +465,8 @@ ue_process_rar( ...@@ -464,7 +465,8 @@ ue_process_rar(
const rnti_t ra_rnti, const rnti_t ra_rnti,
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
); );
......
...@@ -136,15 +136,48 @@ ue_process_rar( ...@@ -136,15 +136,48 @@ ue_process_rar(
const rnti_t ra_rnti, const rnti_t ra_rnti,
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
) )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
uint16_t ret = 0; // return value
RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer;
// RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); // 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
uint8_t n_rarpy = 0; // number of RAR payloads
uint8_t n_rarh = 0; // number of MAC RAR subheaders
uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs
while (1) {
n_rarh++;
if (rarh->T == 1) {
n_rarpy++;
LOG_D(MAC, "RAPID %d\n", rarh->RAPID);
}
if (rarh->RAPID == preamble_index) {
LOG_D(PHY, "Found RAR with the intended RAPID %d\n", rarh->RAPID);
rar = (uint8_t *)(dlsch_buffer+n_rarh + (n_rarpy-1)*6);
break;
}
if (abs((int)rarh->RAPID - (int)preamble_index) < abs((int)best_rx_rapid - (int)preamble_index)) {
best_rx_rapid = rarh->RAPID;
rar = (uint8_t *)(dlsch_buffer+n_rarh + (n_rarpy-1)*6);
}
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);
break;
} else {
rarh++;
}
};
LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_rarh, n_rarpy);
if (CC_id>0) { if (CC_id>0) {
LOG_W(MAC,"Should not have received RAR on secondary CCs! \n"); LOG_W(MAC,"Should not have received RAR on secondary CCs! \n");
return(0xffff); return(0xffff);
...@@ -172,7 +205,7 @@ ue_process_rar( ...@@ -172,7 +205,7 @@ ue_process_rar(
if (opt_enabled) { if (opt_enabled) {
LOG_D(OPT,"[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n", LOG_D(OPT,"[UE %d][RAPROC] CC_id %d RAR Frame %d trace pdu for ra-RNTI %x\n",
module_idP, CC_id, frameP, ra_rnti); module_idP, CC_id, frameP, ra_rnti);
trace_pdu(1, (uint8_t*)rarh, 7, module_idP, 2, ra_rnti, trace_pdu(1, (uint8_t*)dlsch_buffer, n_rarh + n_rarpy*6, module_idP, 2, ra_rnti,
UE_mac_inst[module_idP].rxFrame, UE_mac_inst[module_idP].rxSubframe, 0, 0); UE_mac_inst[module_idP].rxFrame, UE_mac_inst[module_idP].rxSubframe, 0, 0);
} }
...@@ -180,9 +213,16 @@ ue_process_rar( ...@@ -180,9 +213,16 @@ ue_process_rar(
*t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti; *t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti;
UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti; UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti;
//return(rar->Timing_Advance_Command); //return(rar->Timing_Advance_Command);
return((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); ret = ((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4));
} else { } else {
UE_mac_inst[module_idP].crnti=0; UE_mac_inst[module_idP].crnti=0;
return(0xffff); ret = (0xffff);
} }
// move the selected RAR to the front of the RA_PDSCH buffer
memcpy(selected_rar_buffer+0, (uint8_t*)rarh, 1);
memcpy(selected_rar_buffer+1, (uint8_t*)rar , 6);
return ret;
} }
...@@ -170,7 +170,7 @@ typedef struct { ...@@ -170,7 +170,7 @@ typedef struct {
PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe); PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe);
/// Process Random-Access Response /// Process Random-Access Response
uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP, uint16_t ra_rnti, uint8_t *dlsch_buffer, uint16_t *t_crnti,uint8_t preamble_index); uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP, uint16_t ra_rnti, uint8_t *dlsch_buffer, uint16_t *t_crnti,uint8_t preamble_index, uint8_t* selected_rar_buffer);
/// Get SR payload (0,1) from UE MAC /// Get SR payload (0,1) from UE MAC
uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe); uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe);
......
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