Commit 9dce92ea authored by Xue Song's avatar Xue Song

implement rrcReestablishmentRequest

parent ec48bb89
...@@ -48,6 +48,7 @@ typedef enum { ...@@ -48,6 +48,7 @@ typedef enum {
MSC_MAC_ENB, MSC_MAC_ENB,
MSC_RLC_ENB, MSC_RLC_ENB,
MSC_PDCP_ENB, MSC_PDCP_ENB,
MSC_PDCP_GNB,
MSC_RRC_ENB, MSC_RRC_ENB,
MSC_RRC_GNB, MSC_RRC_GNB,
MSC_IP_ENB, MSC_IP_ENB,
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "NR_RRCReconfigurationComplete.h" #include "NR_RRCReconfigurationComplete.h"
#include "NR_RRCReconfigurationComplete-IEs.h" #include "NR_RRCReconfigurationComplete-IEs.h"
#include "NR_DLInformationTransfer.h" #include "NR_DLInformationTransfer.h"
#include "NR_RRCReestablishmentRequest.h"
#if defined(NR_Rel16) #if defined(NR_Rel16)
#include "NR_SCS-SpecificCarrier.h" #include "NR_SCS-SpecificCarrier.h"
#include "NR_TDD-UL-DL-ConfigCommon.h" #include "NR_TDD-UL-DL-ConfigCommon.h"
...@@ -1260,3 +1261,40 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8 ...@@ -1260,3 +1261,40 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8
return encoded; return encoded;
} }
uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer) {
asn_enc_rval_t enc_rval;
NR_UL_CCCH_Message_t ul_ccch_msg;
NR_RRCReestablishmentRequest_t *rrcReestablishmentRequest;
uint8_t buf[2];
memset((void *)&ul_ccch_msg,0,sizeof(NR_UL_CCCH_Message_t));
ul_ccch_msg.message.present = NR_UL_CCCH_MessageType_PR_c1;
ul_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_CCCH_MessageType__c1));
ul_ccch_msg.message.choice.c1->present = NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest;
ul_ccch_msg.message.choice.c1->choice.rrcReestablishmentRequest = CALLOC(1, sizeof(NR_RRCReestablishmentRequest_t));
rrcReestablishmentRequest = ul_ccch_msg.message.choice.c1->choice.rrcReestablishmentRequest;
// test
rrcReestablishmentRequest->rrcReestablishmentRequest.reestablishmentCause = NR_ReestablishmentCause_reconfigurationFailure;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.c_RNTI = 0x1234;
rrcReestablishmentRequest->rrcReestablishmentRequest.ue_Identity.physCellId = 0;
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) ) {
xer_fprint(stdout, &asn_DEF_NR_UL_CCCH_Message, (void *)&ul_ccch_msg);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_CCCH_Message,
NULL,
(void *)&ul_ccch_msg,
buffer,
100);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
LOG_D(NR_RRC,"[UE] RRCSetupRequest Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8);
}
...@@ -146,3 +146,5 @@ do_NR_DLInformationTransfer( ...@@ -146,3 +146,5 @@ do_NR_DLInformationTransfer(
uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, uint8_t do_NR_ULInformationTransfer(uint8_t **buffer,
uint32_t pdu_length, uint32_t pdu_length,
uint8_t *pdu_buffer); uint8_t *pdu_buffer);
uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer);
...@@ -439,6 +439,7 @@ typedef struct { ...@@ -439,6 +439,7 @@ typedef struct {
NR_SRB_INFO SI; NR_SRB_INFO SI;
NR_SRB_INFO Srb0; NR_SRB_INFO Srb0;
int initial_csi_index[MAX_NR_RRC_UE_CONTEXTS]; int initial_csi_index[MAX_NR_RRC_UE_CONTEXTS];
int physCellId;
} rrc_gNB_carrier_data_t; } rrc_gNB_carrier_data_t;
//--------------------------------------------------- //---------------------------------------------------
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "NR_UL-CCCH-Message.h" #include "NR_UL-CCCH-Message.h"
#include "NR_RRCSetupRequest-IEs.h" #include "NR_RRCSetupRequest-IEs.h"
#include "NR_RRCSetupComplete-IEs.h" #include "NR_RRCSetupComplete-IEs.h"
#include "NR_RRCReestablishmentRequest-IEs.h"
#include "rlc.h" #include "rlc.h"
#include "rrc_eNB_UE_context.h" #include "rrc_eNB_UE_context.h"
...@@ -566,6 +567,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( ...@@ -566,6 +567,8 @@ rrc_gNB_generate_defaultRRCReconfiguration(
ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config); ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config);
ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config); ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config);
dedicatedNAS_MessageList = CALLOC(1, sizeof(struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList));
if (ue_context_pP->ue_context.nas_pdu_flag == 1) { if (ue_context_pP->ue_context.nas_pdu_flag == 1) {
dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t)); dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t));
memset(dedicatedNAS_Message, 0, sizeof(OCTET_STRING_t)); memset(dedicatedNAS_Message, 0, sizeof(OCTET_STRING_t));
...@@ -1161,12 +1164,15 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1161,12 +1164,15 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
int buffer_length, int buffer_length,
const int CC_id) const int CC_id)
{ {
module_id_t Idx;
asn_dec_rval_t dec_rval; asn_dec_rval_t dec_rval;
NR_UL_CCCH_Message_t *ul_ccch_msg = NULL; NR_UL_CCCH_Message_t *ul_ccch_msg = NULL;
struct rrc_gNB_ue_context_s *ue_context_p = NULL; struct rrc_gNB_ue_context_s *ue_context_p = NULL;
gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id];
NR_RRCSetupRequest_IEs_t *rrcSetupRequest = NULL; NR_RRCSetupRequest_IEs_t *rrcSetupRequest = NULL;
NR_RRCReestablishmentRequest_IEs_t rrcReestablishmentRequest;
uint64_t random_value = 0; uint64_t random_value = 0;
int i;
dec_rval = uper_decode( NULL, dec_rval = uper_decode( NULL,
&asn_DEF_NR_UL_CCCH_Message, &asn_DEF_NR_UL_CCCH_Message,
...@@ -1317,7 +1323,222 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1317,7 +1323,222 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest:
LOG_I(NR_RRC, "receive rrcReestablishmentRequest message \n"); LOG_I(NR_RRC, "receive rrcReestablishmentRequest message \n");
/* TODO */ LOG_DUMPMSG(NR_RRC, DEBUG_RRC,(char *)(buffer), buffer_length,
"[MSG] RRC Reestablishment Request\n");
LOG_D(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT"MAC_gNB--- MAC_DATA_IND (rrcReestablishmentRequest on SRB0) --> RRC_gNB\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
rrcReestablishmentRequest = ul_ccch_msg->message.choice.c1->choice.rrcReestablishmentRequest->rrcReestablishmentRequest;
LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest cause %s\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
((rrcReestablishmentRequest.reestablishmentCause == NR_ReestablishmentCause_otherFailure) ? "Other Failure" :
(rrcReestablishmentRequest.reestablishmentCause == NR_ReestablishmentCause_handoverFailure) ? "Handover Failure" :
"reconfigurationFailure"));
{
uint16_t c_rnti = 0;
if (rrcReestablishmentRequest.ue_Identity.physCellId != RC.nrrrc[ctxt_pP->module_id]->carrier.physCellId) {
/* UE was moving from previous cell so quickly that RRCReestablishment for previous cell was recieved in this cell */
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
rrcReestablishmentRequest.ue_Identity.physCellId,
RC.nrrrc[ctxt_pP->module_id]->carrier.physCellId);
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
LOG_D(NR_RRC, "physCellId is %ld\n", rrcReestablishmentRequest.ue_Identity.physCellId);
for (i = 0; i < rrcReestablishmentRequest.ue_Identity.shortMAC_I.size; i++) {
LOG_D(NR_RRC, "rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[%d] = %x\n",
i, rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[i]);
}
if (rrcReestablishmentRequest.ue_Identity.c_RNTI < 0 ||
rrcReestablishmentRequest.ue_Identity.c_RNTI > 65535) {
/* c_RNTI range error should not happen */
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest c_RNTI range error, fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
LOG_D(NR_RRC, "c_rnti is %x\n", c_rnti);
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], c_rnti);
if (ue_context_p == NULL) {
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest without UE context, fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
int UE_id = find_nr_UE_id(ctxt_pP->module_id, c_rnti);
if(UE_id == -1) {
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest without UE_id(MAC) rnti %x, fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti);
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
//previous rnti
rnti_t previous_rnti = 0;
for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (reestablish_rnti_map[i][1] == c_rnti) {
previous_rnti = reestablish_rnti_map[i][0];
break;
}
}
if(previous_rnti != 0) {
UE_id = find_nr_UE_id(ctxt_pP->module_id, previous_rnti);
if(UE_id == -1) {
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCReestablishmentRequest without UE_id(MAC) previous rnti %x, fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),previous_rnti);
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
}
//c-plane not end
if((ue_context_p->ue_context.Status != NR_RRC_RECONFIGURED) && (ue_context_p->ue_context.reestablishment_cause == NR_ReestablishmentCause_spare1)) {
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest (UE %x c-plane is not end), fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti);
rrc_gNB_generate_RRCSetup(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id);
break;
}
if(ue_context_p->ue_context.ue_reestablishment_timer > 0) {
LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" RRRCReconfigurationComplete(Previous) don't receive, delete the Previous UE,\nprevious Status %d, new Status NR_RRC_RECONFIGURED\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p->ue_context.Status
);
ue_context_p->ue_context.Status = NR_RRC_RECONFIGURED;
protocol_ctxt_t ctxt_old_p;
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p,
ctxt_pP->instance,
GNB_FLAG_YES,
c_rnti,
ctxt_pP->frame,
ctxt_pP->subframe);
rrc_gNB_process_RRCReconfigurationComplete(&ctxt_old_p,
ue_context_p,
ue_context_p->ue_context.reestablishment_xid);
for (uint8_t pdusessionid = 0; pdusessionid < ue_context_p->ue_context.nb_of_pdusessions; pdusessionid++) {
if (ue_context_p->ue_context.pdusession[pdusessionid].status == PDU_SESSION_STATUS_DONE) {
ue_context_p->ue_context.pdusession[pdusessionid].status = PDU_SESSION_STATUS_ESTABLISHED;
} else {
ue_context_p->ue_context.pdusession[pdusessionid].status = PDU_SESSION_STATUS_FAILED;
}
}
}
LOG_D(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" UE context: %p\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p);
/* reset timers */
ue_context_p->ue_context.ul_failure_timer = 0;
ue_context_p->ue_context.ue_release_timer = 0;
ue_context_p->ue_context.ue_reestablishment_timer = 0;
// ue_context_p->ue_context.ue_release_timer_s1 = 0;
ue_context_p->ue_context.ue_release_timer_rrc = 0;
ue_context_p->ue_context.reestablishment_xid = -1;
// insert C-RNTI to map
for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (reestablish_rnti_map[i][0] == 0) {
reestablish_rnti_map[i][0] = ctxt_pP->rnti;
reestablish_rnti_map[i][1] = c_rnti;
LOG_D(NR_RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n",
i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]);
break;
}
}
ue_context_p->ue_context.reestablishment_cause = rrcReestablishmentRequest.reestablishmentCause;
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Accept reestablishment request from UE physCellId %ld cause %ld\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
rrcReestablishmentRequest.ue_Identity.physCellId,
ue_context_p->ue_context.reestablishment_cause);
ue_context_p->ue_context.primaryCC_id = CC_id;
//LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
Idx = DCCH;
// SRB1
ue_context_p->ue_context.Srb1.Active = 1;
ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx;
memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
// SRB2: set it to go through SRB1 with id 1 (DCCH)
ue_context_p->ue_context.Srb2.Active = 1;
ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
// rrc_gNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id);
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
Idx);
MSC_LOG_TX_MESSAGE(MSC_RRC_GNB,
MSC_PDCP_GNB,
NULL,
0,
MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti);
nr_rrc_pdcp_config_asn1_req(ctxt_pP,
ue_context_p->ue_context.SRB_configList,
NULL,
NULL,
0xff,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
// if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) {
nr_rrc_rlc_config_asn1_req(ctxt_pP,
ue_context_p->ue_context.SRB_configList,
NULL,
NULL,
NULL,
NULL);
// }
}
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest:
......
...@@ -2740,3 +2740,35 @@ nr_rrc_ue_process_ueCapabilityEnquiry( ...@@ -2740,3 +2740,35 @@ nr_rrc_ue_process_ueCapabilityEnquiry(
} }
} }
} }
//-----------------------------------------------------------------------------
void rrc_ue_generate_RRCReestablishmentRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index )
{
if(NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size ==0) {
NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size =
do_RRCReestablishmentRequest(
ctxt_pP->module_id,
(uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload);
LOG_I(NR_RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCReestablishmentRequest (bytes %d, gNB %d)\n",
ctxt_pP->module_id, ctxt_pP->frame, NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index);
for (int i=0; i<NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) {
LOG_T(NR_RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]);
}
LOG_T(NR_RRC,"\n");
#ifdef ITTI_SIM
MessageDef *message_p;
uint8_t *message_buffer;
message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM,
NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size);
memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload,
NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size);
message_p = itti_alloc_new_message (TASK_RRC_NRUE, UE_RRC_CCCH_DATA_IND);
GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer;
GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size;
itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p);
#endif
}
}
...@@ -84,7 +84,7 @@ int config_sync_var=-1; ...@@ -84,7 +84,7 @@ int config_sync_var=-1;
openair0_config_t openair0_cfg[MAX_CARDS]; openair0_config_t openair0_cfg[MAX_CARDS];
volatile int start_gNB = 0; //volatile int start_gNB = 0;
volatile int oai_exit = 0; volatile int oai_exit = 0;
//static int wait_for_sync = 0; //static int wait_for_sync = 0;
......
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