Commit ca86e1f0 authored by alexandr's avatar alexandr

PHY/MAC bug fixed for HO

parent 09e2b149
......@@ -81,7 +81,7 @@ set ( USE_MME "R10" )
set ( USER_MODE True )
set ( XER_PRINT False )
set ( XFORMS False )
set(XFORMS True )
set(XFORMS False )
set(RRC_ASN1_VERSION "Rel10")
set(ENABLE_VCD_FIFO False )
include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)
......@@ -662,6 +662,8 @@ typedef struct {
SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX];
SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX];
#endif
// UE prach state for handover
uint8_t prach_ho;
} PHY_VARS_UE;
/// Top-level PHY Data Structure for RN
......
......@@ -3147,11 +3147,11 @@ void prach_procedures(PHY_VARS_eNB *phy_vars_eNB,uint8_t sched_subframe,uint8_t
//phy_vars_eNb->eNB_UE_stats[(uint32_t)UE_id].mode = PRACH;
phy_vars_eNB->eNB_UE_stats[(uint32_t)UE_id].sector = 0;
LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n",
phy_vars_eNB->Mod_id,
phy_vars_eNB->CC_id,
phy_vars_eNB->Mod_id,
phy_vars_eNB->CC_id,
frame,
subframe,
UE_id,
UE_id,
preamble_max,
preamble_energy_max/10,
preamble_energy_max%10,
......
......@@ -856,13 +856,16 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstra
#endif
stop_meas(&phy_vars_ue->ulsch_encoding_stats);
if(phy_vars_ue->prach_ho){
phy_vars_ue->UE_mode[eNB_id] = PUSCH;
phy_vars_ue->prach_ho = 0;
}
#ifdef OPENAIR2
// signal MAC that Msg3 was sent
mac_xface->Msg3_transmitted(Mod_id,
CC_id,
frame_tx,
eNB_id);
eNB_id,phy_vars_ue->UE_mode[eNB_id]);
#endif
} else {
input_buffer_length = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->TBS/8;
......@@ -3026,7 +3029,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstrac
frame_rx-((subframe_prev==0) ? 1 : 0),
phy_vars_ue->dlsch_ue_ra[eNB_id]->harq_processes[0]->b,
&phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->crnti,
phy_vars_ue->prach_resources[eNB_id]->ra_PreambleIndex);
phy_vars_ue->prach_resources[eNB_id]->ra_PreambleIndex,phy_vars_ue->prach_ho);
if (timing_advance!=0xffff) {
......@@ -3861,17 +3864,20 @@ void phy_procedures_UE_lte(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstr
LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",phy_vars_ue->Mod_id,
frame_rx,subframe_tx);
phy_vars_ue->UE_mode[eNB_id] = PRACH;
phy_vars_ue->prach_ho = 0;
// mac_xface->macphy_exit("Connection lost");
} else if (ret == PHY_RESYNCH) {
LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n",
phy_vars_ue->Mod_id,
frame_rx,subframe_tx);
phy_vars_ue->UE_mode[eNB_id] = RESYNCH;
phy_vars_ue->prach_ho = 0;
// mac_xface->macphy_exit("Connection lost");
} else if (ret == PHY_HO_PRACH) {
LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n",
phy_vars_ue->Mod_id,frame_rx,subframe_tx);
phy_vars_ue->UE_mode[eNB_id] = PRACH;
phy_vars_ue->prach_ho = 1;
}
}
......
......@@ -438,7 +438,7 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t
RA_template[i].timing_offset=timing_offset;
// Put in random rnti (to be replaced with proper procedure!!)
RA_template[i].rnti = taus();
RA_template[i].RA_rnti = 1+subframeP+(10*f_id);
RA_template[i].RA_rnti = 1+subframeP+(10*f_id);
RA_template[i].preamble_index = preamble_index;
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n",
module_idP,CC_id,frameP,i,RA_template[i].rnti,
......
......@@ -74,7 +74,7 @@ void rx_sdu(
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP,
rnti_t rntiP,
uint8_t *sduP,
const uint16_t sdu_lenP,
const int harq_pidP,
......@@ -129,6 +129,8 @@ void rx_sdu(
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d (ce %d/%d): Received CRNTI %2.2x%2.2x\n",
enb_mod_idP, CC_idP, rx_ces[i], i,num_ce, payload_ptr[0], payload_ptr[1]);
UE_id = find_UE_id(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
/* TODO: maybe check that the CRNTI is in handover mode? */
if (UE_id != -1) rntiP = (((uint16_t)payload_ptr[0])<<8) + payload_ptr[1];
LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : CRNTI %x (UE_id %d) in Msg3\n",enb_mod_idP, CC_idP, rx_ces[i], (((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id);
payload_ptr+=2;
......
......@@ -425,7 +425,8 @@ ue_process_rar(
const frame_t frameP,
uint8_t * const dlsch_buffer,
rnti_t * const t_crnti,
const uint8_t preamble_index
const uint8_t preamble_index,
uint8_t prach_state
);
......@@ -635,7 +636,7 @@ void update_phr (module_id_t module_idP,int CC_id);
\param[in] Mod_id Instance index of UE
\param[in] eNB_id Index of eNB
*/
void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP,uint8_t eNB_id,UE_MODE_t UE_mode);
/*! \brief Function to indicate the transmission of msg1/rach
......
......@@ -283,7 +283,7 @@ void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
}
void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id)
void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id,UE_MODE_t UE_mode)
{
if (CC_id>0) {
......@@ -295,8 +295,13 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
// start contention resolution timer
LOG_D(MAC,"[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",module_idP,frameP);
UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0;
UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
if(UE_mode==PUSCH){
// Call rrc to update the HO status
mac_ue_rrc_ue_update_ho_status(module_idP);
}
else{
UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
}
if (opt_enabled) { // msg3
trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size,
module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0);
......@@ -320,7 +325,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
mac_rlc_status_resp_t rlc_status;
uint8_t dcch_header_len=0;
uint16_t sdu_lengths[8];
uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
static uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
if (CC_id>0) {
LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n");
......@@ -339,6 +344,9 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
if (UE_mac_inst[module_idP].RA_active == 0) {
LOG_D(MAC,"RA not active\n");
printf("DCCH LEN %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]);
if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] == 9)
printf("yo\n");
// check if RRC is ready to initiate the RA procedure
Size = mac_rrc_data_req(module_idP,
CC_id,
......@@ -399,11 +407,12 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element
rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
DCCH,
6);
9);
if (rlc_status.bytes_in_buffer == 0) abort();
if (UE_mac_inst[module_idP].crnti_before_ho)
LOG_D(MAC,
"[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n",
"[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send through PRACH (mac header len %d)\n",
module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len);
else
LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n",
......@@ -412,14 +421,23 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti,
eNB_indexP, frameP,ENB_FLAG_NO, MBMS_FLAG_NO,
DCCH,
(char *)&ulsch_buff[0]);
(char *)&ulsch_buff[4]);
/*
ulsch_buff[0] = 0x01;
ulsch_buff[1] = 0x02;
ulsch_buff[2] = 0x03;
ulsch_buff[3] = 0x04;
ulsch_buff[4] = 0x05;
ulsch_buff[5] = 0x06;
*/
LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]);
update_bsr(module_idP, frameP, eNB_indexP,DCCH,UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]);
//header_len +=2;
UE_mac_inst[module_idP].RA_active = 1;
UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len;
UE_mac_inst[module_idP].RA_Msg3_size = sdu_lengths[0]+dcch_header_len;
UE_mac_inst[module_idP].RA_prachMaskIndex = 0;
UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff;
UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
......@@ -441,6 +459,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
// Fill in preamble and PRACH resource
get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL);
lcid = DCCH;
generate_ulsch_header((uint8_t*)ulsch_buff, // mac header
1, // num sdus
0, // short pading
......@@ -453,6 +472,13 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
NULL, // long_bsr
0); //post_padding
printf("length %d\n", sdu_lengths[0]);
{
int i;
for (i = 0; i < 13; i++)
printf("%2.2x ", (unsigned int)ulsch_buff[i]);
printf("\n");
}
return(&UE_mac_inst[module_idP].RA_prach_resources);
}
} else { // RACH is active
......
......@@ -145,7 +145,8 @@ ue_process_rar(
const frame_t frameP,
uint8_t* const dlsch_buffer,
rnti_t* const t_crnti,
const uint8_t preamble_index
const uint8_t preamble_index,
uint8_t prach_state
)
//------------------------------------------------------------------------------
{
......@@ -181,7 +182,10 @@ ue_process_rar(
if (preamble_index == rarh->RAPID) {
*t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti;
UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti;
if(prach_state==0){
UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti;
LOG_D(MAC,"Update the c-rnti (not HO case)\n");
}
//return(rar->Timing_Advance_Command);
return((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4));
} else {
......
......@@ -1019,8 +1019,12 @@ unsigned char generate_ulsch_header(uint8_t *mac_header,
mac_header_ptr->E = 0;
mac_header_ptr->LCID = CRNTI;
last_size=1;
*((uint16_t *)ce_ptr)=(*crnti);
ce_ptr+=sizeof(uint16_t);
//*((uint16_t *)ce_ptr)=(*crnti);
//ce_ptr+=sizeof(uint16_t);
*ce_ptr = ((*crnti) >> 8) & 255;
ce_ptr++;
*ce_ptr = (*crnti) & 255;
ce_ptr++;
// printf("offset %d\n",ce_ptr-mac_header_control_elements);
}
......@@ -1188,6 +1192,7 @@ unsigned char generate_ulsch_header(uint8_t *mac_header,
LOG_T(MAC,"\n");
#endif
printf("header %d bytes\n", (unsigned char*)mac_header_ptr - mac_header);
return((unsigned char*)mac_header_ptr - mac_header);
}
......
......@@ -164,7 +164,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);
/// Process Random-Access Response
uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,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,uint8_t *dlsch_buffer,uint16_t *t_crnti,uint8_t preamble_index,uint8_t prach_state);
/// 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);
......@@ -218,7 +218,7 @@ typedef struct {
void (*Msg1_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
/// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer
void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id);
void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id,UE_MODE_t UE_mode);
/// Function to pass inter-cell measurement parameters to PHY (cell Ids)
void (*phy_config_meas_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,uint32_t *adj_cell_id);
......
......@@ -288,3 +288,7 @@ openair_rrc_eNB_init(
{
return openair_rrc_lite_eNB_init(module_idP);
}
void mac_ue_rrc_ue_update_ho_status(const module_id_t module_idP){
return (rrc_lite_ue_update_ho_status(module_idP));
}
......@@ -138,4 +138,6 @@ void mac_in_sync_ind(
const frame_t frameP,
const uint16_t eNB_indexP);
void mac_ue_rrc_ue_update_ho_status(const module_id_t module_idP);
#endif
......@@ -746,3 +746,11 @@ int mac_ue_ccch_success_ind(module_id_t Mod_idP, uint8_t eNB_index)
#endif
return 0;
}
void rrc_lite_ue_update_ho_status(module_id_t Mod_idP){
// Handover is done
LOG_D(RRC,"Reset HO timer in RRC\n");
UE_rrc_inst[Mod_idP].Info[0].T304_active = 0; // Stop the timer (MAC procedure was successful)
UE_rrc_inst[Mod_idP].HandoverInfoUe.measFlag = 0; // Stop the measurements
UE_rrc_inst[Mod_idP].Info[0].State = RRC_CONNECTED;
}
......@@ -359,6 +359,8 @@ ue_measurement_report_triggering(
const uint8_t eNB_index
);
void rrc_lite_ue_update_ho_status(module_id_t Mod_idP);
int
mac_eNB_get_rrc_lite_status(
const module_id_t Mod_idP,
......
......@@ -1958,7 +1958,7 @@ rrc_ue_decode_dcch(
"[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n",
ctxt_pP->module_id,
ctxt_pP->frame);
UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required
//UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required
}
}
......@@ -3669,7 +3669,6 @@ void ue_measurement_report_triggering( const protocol_ctxt_t* const ctxt_pP, con
case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3:
LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",
ctxt_pP->module_id, ctxt_pP->frame);
if ((check_trigger_meas_event(
ctxt_pP->module_id,
ctxt_pP->frame,
......@@ -3688,7 +3687,7 @@ void ue_measurement_report_triggering( const protocol_ctxt_t* const ctxt_pP, con
rrc_ue_generate_MeasurementReport(
ctxt_pP,
eNB_index);
UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1;
//UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1;
LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n",
ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[0].State);
} else {
......
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