Commit a37ff36d authored by matzakos's avatar matzakos

Added MAC level state variable for the UE and control mechanisms to ensure the...

Added MAC level state variable for the UE and control mechanisms to ensure the correct operation of the UE MAC state machine.
parent 4757a1b6
......@@ -1384,6 +1384,13 @@ typedef struct {
time_stats_t rx_p;
/// Panos: Mutex for nfapi UL_INFO
pthread_mutex_t UL_INFO_mutex;
/// Panos: UE_Mode variable should be used in the case of Phy_stub operation since we won't have access to PHY_VARS_UE
/// where the UE_mode originally is for the full stack operation mode. The transitions between the states of the UE_Mode
/// will be triggered within phy_stub_ue.c in this case
UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX];
/// Panos: Phy_stub mode: Boolean variable to distinguish whether a Msg3 or a regular ULSCH data pdu should be generated
/// after the reception of NFAPI_UL_CONFIG_ULSCH_PDU_TYPE.
uint8_t first_ULSCH_Tx;
} UE_MAC_INST;
/*! \brief ID of the neighboring cells used for HO*/
typedef struct {
......
......@@ -287,7 +287,11 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
uint8_t Size = 0;
UE_MODE_t UE_mode = get_ue_mode(module_idP,0,eNB_indexP);
// Panos: Modification for phy_stub_ue operation
//UE_MODE_t UE_mode = get_ue_mode(module_idP,0,eNB_indexP);
UE_MODE_t UE_mode = UE_mac_inst[module_idP].UE_mode[0];
uint8_t lcid = CCCH;
uint16_t Size16;
struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL;
......
......@@ -404,7 +404,10 @@ ue_send_sdu(
LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n", module_idP, frameP);
UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0;
ra_succeeded(module_idP,CC_id,eNB_index);
//Panos: Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH
UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH;
//ra_succeeded(module_idP,CC_id,eNB_index);
}
payload_ptr+=6;
......
......@@ -82,15 +82,21 @@ void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){
// ue_process_rar should be called but the problem is that this function currently uses PHY_VARS_UE
// elements.
// C-RNTI parameter not actually used. Provided only to comply with existing function definition.
// RNTI parameter not actually used. Provided only to comply with existing function definition.
// Not sure about parameters to fill the preamble index.
rnti_t c_rnti = UE_mac_inst[Mod_id].crnti;
ue_process_rar(Mod_id, CC_id, frame,
dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //RA-RNTI
Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
&c_rnti,
UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex,
Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data);
//rnti_t c_rnti = UE_mac_inst[Mod_id].crnti;
rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI;
if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) &&
(UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL)) {
ue_process_rar(Mod_id, CC_id, frame,
ra_rnti, //RA-RNTI
Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
&dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti
UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex,
Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data);
UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE)
}
}
else {
LOG_E(MAC,"[UE %d] CCid %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, CC_id,frame,subframe);
......@@ -572,8 +578,17 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint16_t rnti = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti;
uint8_t access_mode=SCHEDULED_ACCESS;
if(buflen>0){
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
if(UE_mac_inst[Mod_id].first_ULSCH_Tx){ // Msg3 case
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti);
Msg3_transmitted(Mod_id, 0, frame, 0);
UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
}
else {
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
}
}
}
......@@ -586,8 +601,18 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
uint8_t access_mode=SCHEDULED_ACCESS;
if(buflen>0){
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
if(UE_mac_inst[Mod_id].first_ULSCH_Tx){ // Msg3 case
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti);
Msg3_transmitted(Mod_id, 0, frame, 0);
UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
}
else {
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
}
}
if(ulsch_harq_information)
......@@ -604,8 +629,17 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
uint8_t access_mode=SCHEDULED_ACCESS;
if(buflen>0){
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
if(UE_mac_inst[Mod_id].first_ULSCH_Tx){ // Msg3 case
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti);
Msg3_transmitted(Mod_id, 0, frame, 0);
UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
}
else {
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
}
}
fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
......@@ -622,8 +656,17 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
uint8_t access_mode=SCHEDULED_ACCESS;
if(buflen>0){
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
if(UE_mac_inst[Mod_id].first_ULSCH_Tx){ // Msg3 case
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti);
Msg3_transmitted(Mod_id, 0, frame, 0);
UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
}
else {
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
}
}
if(ulsch_harq_information)
......@@ -728,12 +771,15 @@ int ul_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_
//*** Note we should find the right place to call free(UL_INFO).
UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
//Panos: Additional checks needed here to check if the UE is in PRACH mode.
uint8_t is_rach = req->ul_config_request_body.rach_prach_frequency_resources;
if(is_rach) {
if(is_rach && UE_mac_inst[Mod_id].UE_mode[0] == PRACH) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, sfn, 0, sf);
fill_rach_indication_UE_MAC(Mod_id, sfn ,sf, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
Msg1_transmitted(Mod_id, 0, sfn, 0);
}
// subframe works off TX SFN/SF which is 4 ahead, need to put it back to RX SFN/SF
// probably could just use proc->frame_rx
......
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