Commit cfcaf414 authored by francescomani's avatar francescomani

transmission of RRCReestablishmentRequest message

parent 8e39d4bd
......@@ -32,7 +32,7 @@ void nr_mac_rrc_sync_ind(const module_id_t module_id,
const frame_t frame,
const bool in_sync) {}
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti) {}
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti, int gnb_id) {}
void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) {}
......@@ -48,6 +48,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const frame_t frame,
const int slot,
const rnti_t rnti,
const uint32_t cellid,
const channel_t channel,
const uint8_t* pduP,
const sdu_size_t pdu_len) { return 0; }
......
......@@ -76,7 +76,8 @@ typedef struct NRRrcMacRaInd_s {
} NRRrcMacRaInd;
typedef struct NRRrcMacMsg3Ind_s {
uint16_t rnti;
uint16_t rnti;
int gnb_id;
} NRRrcMacMsg3Ind;
typedef struct RrcMacInSyncInd_s {
......@@ -118,6 +119,7 @@ typedef struct NRRrcMacBcchDataInd_s {
bool is_bch;
uint8_t rsrq;
uint8_t rsrp;
uint32_t phycellid;
} NRRrcMacBcchDataInd;
typedef struct NRRrcMacSBcchDataInd_s {
......
......@@ -267,7 +267,7 @@ int8_t nr_ue_decode_BCCH_DL_SCH(NR_UE_MAC_INST_t *mac,
{
if(ack_nack) {
LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n");
nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, mac->physCellId, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
mac->get_sib1 = false;
mac->get_otherSI = false;
}
......@@ -4030,7 +4030,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
// - optimize: mu_pusch, j and table_6_1_2_1_1_2_time_dom_res_alloc_A are already defined in nr_ue_procedures
static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id)
{
frame_t frame = dl_info->frame;
frame_t frame = dl_info->frame;
int slot = dl_info->slot;
if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack == 0) {
......@@ -4230,7 +4230,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
if (!ra->cfra) {
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
rnti = ra->t_crnti;
nr_mac_rrc_msg3_ind(mac->ue_id, rnti);
nr_mac_rrc_msg3_ind(mac->ue_id, rnti, dl_info->gNB_index);
}
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
if (!pdu)
......
......@@ -120,7 +120,7 @@ void nr_rlc_release_entity(int rnti, logical_chan_id_t channel_id)
void mac_rlc_data_ind(const module_id_t module_idP,
const rnti_t rntiP,
const eNB_index_t eNB_index,
const frame_t rameP,
const frame_t frameP,
const eNB_flag_t enb_flagP,
const MBMS_flag_t MBMS_flagP,
const logical_chan_id_t channel_idP,
......@@ -631,9 +631,10 @@ void nr_rlc_reestablish_entity(int rnti, int lc_id)
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (ue == NULL)
if (ue == NULL) {
LOG_E(RLC, "RLC instance for the given UE was not found \n");
return;
}
nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, lc_id);
if (rb != NULL) {
......@@ -645,6 +646,34 @@ void nr_rlc_reestablish_entity(int rnti, int lc_id)
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
void nr_rlc_reestablish_default_srb(int rnti, int srb_id)
{
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (ue == NULL) {
LOG_E(RLC, "RLC instance for the given UE was not found \n");
return;
}
nr_rlc_entity_t *srb = ue->srb[srb_id - 1];
if (srb != NULL) {
srb->reestablishment(srb);
// default values as in 9.2.1 of 38.331
int sn_field_length = 12;
nr_rlc_entity_am_reconfigure(srb,
45, //t_poll_retransmit
35, //t_reassembly
0, //t_status_prohibit
-1, //poll_pdu
-1, //poll_byte
8, //max_retx_threshold
&sn_field_length);
} else {
LOG_E(RLC, "no RLC entity found corresponding to SRB%d for reestablishment\n", srb_id);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
void nr_rlc_reconfigure_entity(int rnti, int lc_id, NR_RLC_Config_t *rlc_Config)
{
nr_rlc_manager_lock(nr_rlc_ue_manager);
......
......@@ -45,6 +45,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare
void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
void nr_rlc_reestablish_entity(int rnti, int lc_id);
void nr_rlc_reestablish_default_srb(int rnti, int srb_id);
void nr_rlc_remove_ue(int rnti);
bool nr_rlc_update_rnti(int from_rnti, int to_rnti);
......
......@@ -1048,7 +1048,8 @@ static int handle_bcch_bch(NR_UE_MAC_INST_t *mac,
mac->frequency_range = FR2;
else
mac->frequency_range = FR1;
nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU
// fixed 3 bytes MIB PDU
nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, cell_id, NR_BCCH_BCH, (uint8_t *) pduP, 3);
return 0;
}
......
......@@ -979,7 +979,10 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8
return encoded;
}
uint8_t do_RRCReestablishmentRequest(uint8_t *buffer, uint16_t c_rnti)
uint8_t do_RRCReestablishmentRequest(uint8_t *buffer,
NR_ReestablishmentCause_t cause,
uint32_t cell_id,
uint16_t c_rnti)
{
asn_enc_rval_t enc_rval;
NR_UL_CCCH_Message_t ul_ccch_msg;
......@@ -994,16 +997,16 @@ uint8_t do_RRCReestablishmentRequest(uint8_t *buffer, uint16_t c_rnti)
rrcReestablishmentRequest = ul_ccch_msg.message.choice.c1->choice.rrcReestablishmentRequest;
// test
rrcReestablishmentRequest->rrcReestablishmentRequest.reestablishmentCause = NR_ReestablishmentCause_reconfigurationFailure;
rrcReestablishmentRequest->rrcReestablishmentRequest.reestablishmentCause = cause;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.c_RNTI = c_rnti;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.physCellId = 0;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.physCellId = cell_id;
// TODO properly setting shortMAC-I (see 5.3.7.4 of 331)
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf = buf;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[0] = 0x08;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[1] = 0x32;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.shortMAC_I.size = 2;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
xer_fprint(stdout, &asn_DEF_NR_UL_CCCH_Message, (void *)&ul_ccch_msg);
}
......
......@@ -131,7 +131,10 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer,
uint32_t pdu_length,
uint8_t *pdu_buffer);
uint8_t do_RRCReestablishmentRequest(uint8_t *buffer, uint16_t c_rnti);
uint8_t do_RRCReestablishmentRequest(uint8_t *buffer,
NR_ReestablishmentCause_t cause,
uint32_t cell_id,
uint16_t c_rnti);
int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer,
......
......@@ -55,6 +55,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const frame_t frame,
const int slot,
const rnti_t rnti,
const uint32_t cellid,
const channel_t channel,
const uint8_t* pduP,
const sdu_size_t pdu_len)
......@@ -85,6 +86,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
NR_RRC_MAC_BCCH_DATA_IND (message_p).slot = slot;
NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size;
NR_RRC_MAC_BCCH_DATA_IND (message_p).gnb_index = gNB_index;
NR_RRC_MAC_BCCH_DATA_IND (message_p).phycellid = cellid;
NR_RRC_MAC_BCCH_DATA_IND (message_p).is_bch = (channel == NR_BCCH_BCH);
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p);
}
......@@ -127,10 +129,11 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
return(0);
}
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti)
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id)
{
MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MSG3_IND);
NR_RRC_MAC_MSG3_IND (message_p).rnti = rnti;
NR_RRC_MAC_MSG3_IND (message_p).gnb_id = gnb_id;
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p);
}
......
......@@ -405,10 +405,12 @@ int check_si_status(NR_UE_RRC_SI_INFO *SI_info)
/*brief decode BCCH-BCH (MIB) message*/
static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc,
const uint8_t gNB_index,
const uint32_t phycellid,
uint8_t *const bufferP,
const uint8_t buffer_len)
{
NR_BCCH_BCH_Message_t *bcch_message = NULL;
rrc->phyCellID = phycellid;
asn_dec_rval_t dec_rval = uper_decode_complete(NULL,
&asn_DEF_NR_BCCH_BCH_Message,
......@@ -425,9 +427,17 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc,
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
if (is_nr_timer_active(timers->T311)) {
nr_timer_stop(&timers->T311);
nr_timer_start(&timers->T301);
rrc->ra_trigger = RRC_CONNECTION_REESTABLISHMENT;
// preparing MSG3 for re-establishment in advance
uint8_t buffer[1024];
int buf_size = do_RRCReestablishmentRequest(buffer,
rrc->reestablishment_cause,
rrc->phyCellID,
rrc->rnti); // old rnti
nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buffer, buf_size);
// apply the default MAC Cell Group configuration
// (done at MAC by calling nr_ue_mac_default_configs)
......@@ -565,18 +575,29 @@ static int nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si)
return 0;
}
static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti)
static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti, int gnb_id)
{
NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants;
switch (rrc->ra_trigger) {
case INITIAL_ACCESS_FROM_RRC_IDLE:
// After SIB1 is received, prepare RRCConnectionRequest
rrc->rnti = rnti;
// start timer T300
NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants;
nr_timer_start(&tac->T300);
break;
case RRC_CONNECTION_REESTABLISHMENT:
AssertFatal(1==0, "ra_trigger not implemented yet!\n");
rrc->rnti = rnti;
nr_timer_start(&tac->T301);
int srb_id = 1;
// re-establish PDCP for SRB1
nr_pdcp_reestablishment(rrc->ue_id, srb_id, true);
// re-establish RLC for SRB1
// apply the specified configuration defined in 9.2.1 for SRB1
nr_rlc_reestablish_default_srb(rrc->ue_id, srb_id);
// TODO configure lower layers to suspend integrity protection and ciphering for SRB1
// resume SRB1
rrcPerNB_t *rrcNB = rrc->perNB + gnb_id;
rrcNB->Srb[srb_id] = RB_ESTABLISHED;
break;
case DURING_HANDOVER:
AssertFatal(1==0, "ra_trigger not implemented yet!\n");
......@@ -1426,7 +1447,7 @@ void *rrc_nrue(void *notUsed)
break;
case NR_RRC_MAC_MSG3_IND:
nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti);
nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti, NR_RRC_MAC_MSG3_IND(msg_p).gnb_id);
break;
case NR_RRC_MAC_RA_IND:
......@@ -1443,7 +1464,7 @@ void *rrc_nrue(void *notUsed)
LOG_D(NR_RRC, "[UE %ld] Received %s: gNB %d\n", rrc->ue_id, ITTI_MSG_NAME(msg_p), NR_RRC_MAC_BCCH_DATA_IND(msg_p).gnb_index);
NRRrcMacBcchDataInd *bcch = &NR_RRC_MAC_BCCH_DATA_IND(msg_p);
if (bcch->is_bch)
nr_rrc_ue_decode_NR_BCCH_BCH_Message(rrc, bcch->gnb_index, bcch->sdu, bcch->sdu_size);
nr_rrc_ue_decode_NR_BCCH_BCH_Message(rrc, bcch->gnb_index, bcch->phycellid, bcch->sdu, bcch->sdu_size);
else
nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(rrc, bcch->gnb_index, bcch->sdu, bcch->sdu_size, bcch->rsrq, bcch->rsrp);
break;
......@@ -1607,8 +1628,11 @@ static void nr_rrc_ue_process_ueCapabilityEnquiry(NR_UE_RRC_INST_t *rrc, NR_UECa
}
void nr_rrc_initiate_rrcReestablishment(NR_UE_RRC_INST_t *rrc,
NR_ReestablishmentCause_t cause,
const int gnb_id)
{
rrc->reestablishment_cause = cause;
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
rrcPerNB_t *rrcNB = rrc->perNB + gnb_id;
......@@ -1637,7 +1661,6 @@ void nr_rrc_initiate_rrcReestablishment(NR_UE_RRC_INST_t *rrc,
}
// release the MCG SCell(s), if configured
// no SCell configured in our implementation
rrc->nrRrcState = RRC_STATE_REESTABLISHMENT;
// reset MAC
// release spCellConfig, if configured
......
......@@ -56,6 +56,7 @@
#include "NR_UE-NR-Capability.h"
#include "NR_SL-PreconfigurationNR-r16.h"
#include "NR_MasterInformationBlockSidelink.h"
#include "NR_ReestablishmentCause.h"
#include "RRC/NR/nr_rrc_common.h"
#include "as_message.h"
......@@ -85,7 +86,6 @@ typedef enum Rrc_State_NR_e {
RRC_STATE_INACTIVE_NR,
RRC_STATE_CONNECTED_NR,
RRC_STATE_DETACH_NR,
RRC_STATE_REESTABLISHMENT
} Rrc_State_NR_t;
typedef enum requested_SI_List_e {
......@@ -188,12 +188,15 @@ typedef struct NR_UE_RRC_INST_s {
instance_t ue_id;
rrcPerNB_t perNB[NB_CNX_UE];
char *uecap_file;
rnti_t rnti;
char *uecap_file;
rnti_t rnti;
uint32_t phyCellID;
OAI_NR_UECapability_t UECap;
NR_UE_Timers_Constants_t timers_and_constants;
RA_trigger_t ra_trigger;
NR_ReestablishmentCause_t reestablishment_cause;
plmn_t plmnID;
NR_BWP_Id_t dl_bwp_id;
......
......@@ -73,6 +73,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const frame_t frame,
const int slot,
const rnti_t rnti,
const uint32_t cellid,
const channel_t channel,
const uint8_t* pduP,
const sdu_size_t pdu_len);
......@@ -86,7 +87,7 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
NR_RRCRelease_t *RRCRelease);
void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success);
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti);
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id);
void set_rlf_sib1_timers_and_constants(NR_UE_Timers_Constants_t *tac, NR_SIB1_t *sib1);
/**\brief RRC UE task.
......
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