Commit a81b655c authored by Xue Song's avatar Xue Song

Add RRC Setup message

parent b77ecaf2
...@@ -299,6 +299,12 @@ typedef struct protocol_ctxt_s { ...@@ -299,6 +299,12 @@ typedef struct protocol_ctxt_s {
(CTXT_Pp)->module_id, \ (CTXT_Pp)->module_id, \
(CTXT_Pp)->rnti (CTXT_Pp)->rnti
#define PROTOCOL_NR_CTXT_ARGS(CTXT_Pp) \
(CTXT_Pp)->frame, \
((CTXT_Pp)->enb_flag == GNB_FLAG_YES) ? "gNB":" UE", \
(CTXT_Pp)->module_id, \
(CTXT_Pp)->rnti
#define CHECK_CTXT_ARGS(CTXT_Pp) #define CHECK_CTXT_ARGS(CTXT_Pp)
#define exit_fun(msg) exit_function(__FILE__,__FUNCTION__,__LINE__,msg) #define exit_fun(msg) exit_function(__FILE__,__FUNCTION__,__LINE__,msg)
......
...@@ -45,6 +45,15 @@ ...@@ -45,6 +45,15 @@
#include "NR_DL-CCCH-Message.h" #include "NR_DL-CCCH-Message.h"
#include "NR_RRCReject.h" #include "NR_RRCReject.h"
#include "NR_RejectWaitTime.h" #include "NR_RejectWaitTime.h"
#include "NR_RRCSetup.h"
#include "NR_RRCSetup-IEs.h"
#include "NR_SRB-ToAddModList.h"
#include "NR_CellGroupConfig.h"
#include "NR_RLC-BearerConfig.h"
#include "NR_RLC-Config.h"
#include "NR_LogicalChannelConfig.h"
#include "NR_PDCP-Config.h"
#include "NR_MAC-CellGroupConfig.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"
...@@ -619,3 +628,144 @@ uint8_t do_RRCReject(uint8_t Mod_id, ...@@ -619,3 +628,144 @@ uint8_t do_RRCReject(uint8_t Mod_id,
enc_rval.encoded,(enc_rval.encoded+7)/8); enc_rval.encoded,(enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8);
} }
//------------------------------------------------------------------------------
uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
rrc_eNB_ue_context_t *const ue_context_pP,
int CC_id,
uint8_t *const buffer,
const uint8_t transaction_id,
NR_SRB_ToAddModList_t *SRB_configList)
//------------------------------------------------------------------------------
{
asn_enc_rval_t enc_rval;;
NR_DL_CCCH_Message_t dl_ccch_msg;
NR_RRCSetup_t *rrcSetup;
NR_RRCSetup_IEs_t *ie;
NR_SRB_ToAddMod_t *SRB1_config = NULL;
NR_PDCP_Config_t *pdcp_Config = NULL;
NR_CellGroupConfig_t *cellGroupConfig = NULL;
NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL;
NR_RLC_Config_t *rlc_Config = NULL;
NR_LogicalChannelConfig_t *logicalChannelConfig = NULL;
NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = NULL;
char masterCellGroup_buf[1000];
int size = 0;
long *logicalChannelGroup = NULL;
memset((void *)&dl_ccch_msg, 0, sizeof(NR_DL_CCCH_Message_t));
dl_ccch_msg.message.present = NR_DL_CCCH_MessageType_PR_c1;
dl_ccch_msg.message.choice.c1->present = NR_DL_CCCH_MessageType__c1_PR_rrcSetup;
rrcSetup = dl_ccch_msg.message.choice.c1->choice.rrcSetup;
rrcSetup->criticalExtensions.present = NR_RRCSetup__criticalExtensions_PR_rrcSetup;
rrcSetup->rrc_TransactionIdentifier = transaction_id;
ie = rrcSetup->criticalExtensions.choice.rrcSetup;
/****************************** radioBearerConfig ******************************/
/* Configure SRB1 */
if (SRB_configList) {
free(SRB_configList);
}
SRB_configList = calloc(1, sizeof(NR_SRB_ToAddModList_t));
// SRB1
/* TODO */
SRB1_config = calloc(1, sizeof(NR_SRB_ToAddMod_t));
SRB1_config->srb_Identity = 1;
// pdcp_Config->t_Reordering
SRB1_config->pdcp_Config = pdcp_Config;
ie->radioBearerConfig.srb_ToAddModList = SRB_configList;
ASN_SEQUENCE_ADD(&SRB_configList->list, SRB1_config);
ie->radioBearerConfig.srb3_ToRelease = NULL;
ie->radioBearerConfig.drb_ToAddModList = NULL;
ie->radioBearerConfig.drb_ToReleaseList = NULL;
ie->radioBearerConfig.securityConfig = NULL;
/****************************** masterCellGroup ******************************/
/* TODO */
cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t));
cellGroupConfig->cellGroupId = 0;
/* Rlc Bearer Config */
/* TS38.331 9.2.1 Default SRB configurations */
cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList));
rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t));
rlc_BearerConfig->logicalChannelIdentity = 1;
rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 1;
rlc_BearerConfig->reestablishRLC = NULL;
rlc_Config->present = NR_RLC_Config_PR_am;
rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am));
*(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12;
rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35;
rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0;
*(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12;
rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45;
rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity;
rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity;
rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8;
rlc_BearerConfig->rlc_Config = rlc_Config;
logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t));
logicalChannelConfig->ul_SpecificParameters->priority = 1;
logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
logicalChannelGroup = CALLOC(1, sizeof(long));
*logicalChannelGroup = 0;
logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup;
rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig;
ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig);
/* mac CellGroup Config */
mac_CellGroupConfig = calloc(1, sizeof(NR_MAC_CellGroupConfig_t));
mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config));
mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10;
mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80;
mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config));
mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup;
mac_CellGroupConfig->phr_Config->choice.setup = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config->choice.setup));
mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf10;
mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10;
mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1;
cellGroupConfig->mac_CellGroupConfig = mac_CellGroupConfig;
// cellGroupConfig.physicalCellGroupConfig;
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
(void *)cellGroupConfig,
masterCellGroup_buf,
100);
if(enc_rval.encoded == -1) {
LOG_E(RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
return -1;
}
if (OCTET_STRING_fromBuf(&ie->masterCellGroup, masterCellGroup_buf, (enc_rval.encoded+7)/8) == -1) {
LOG_E(RRC, "fatal: OCTET_STRING_fromBuf failed\n");
return -1;
}
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_CCCH_Message,
NULL,
(void *)&dl_ccch_msg,
buffer,
100);
if(enc_rval.encoded == -1) {
LOG_E(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
return -1;
}
LOG_D(RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n",
enc_rval.encoded,(enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8);
}
...@@ -85,3 +85,10 @@ void do_SpCellConfig(gNB_RRC_INST *rrc, ...@@ -85,3 +85,10 @@ void do_SpCellConfig(gNB_RRC_INST *rrc,
uint8_t do_RRCReject(uint8_t Mod_id, uint8_t do_RRCReject(uint8_t Mod_id,
uint8_t *const buffer); uint8_t *const buffer);
uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
rrc_eNB_ue_context_t *const ue_context_pP,
int CC_id,
uint8_t *const buffer,
const uint8_t transaction_id,
NR_SRB_ToAddModList_t *SRB_configList);
...@@ -90,10 +90,10 @@ typedef struct nr_uid_linear_allocator_s { ...@@ -90,10 +90,10 @@ typedef struct nr_uid_linear_allocator_s {
#define PROTOCOL_NR_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_NR_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_NR_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) #define PROTOCOL_NR_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_NR_CTXT_ARGS(CTXT_Pp)
#define PROTOCOL_NR_RRC_CTXT_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_NR_RRC_CTXT_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_NR_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) #define PROTOCOL_NR_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_NR_CTXT_ARGS(CTXT_Pp)
#define NR_UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! #define NR_UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "rlc.h" #include "rlc.h"
#include "rrc_eNB_UE_context.h" #include "rrc_eNB_UE_context.h"
#include "rrc_gNB_UE_context.h"
#include "platform_types.h" #include "platform_types.h"
#include "msc.h" #include "msc.h"
#include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/vcd_signal_dumper.h"
...@@ -300,35 +301,16 @@ void rrc_gNB_process_AdditionRequestInformation(const module_id_t gnb_mod_idP, x ...@@ -300,35 +301,16 @@ void rrc_gNB_process_AdditionRequestInformation(const module_id_t gnb_mod_idP, x
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// return the ue context if there is already an UE with the same S-TMSI, NULL otherwise uint8_t
static struct rrc_gNB_ue_context_s * rrc_gNB_get_next_transaction_identifier(
rrc_gNB_ue_context_5g_stmsi_exist( module_id_t gnb_mod_idP
const protocol_ctxt_t *const ctxt_pP,
NR_NG_5G_S_TMSI_t *s_TMSI
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
struct rrc_gNB_ue_context_s *ue_context_p = NULL; static uint8_t nr_rrc_transaction_identifier[NUMBER_OF_gNB_MAX];
uint64_t s_TMSI_value = 0; // 48-bit nr_rrc_transaction_identifier[gnb_mod_idP] = (nr_rrc_transaction_identifier[gnb_mod_idP] + 1) % NR_RRC_TRANSACTION_IDENTIFIER_NUMBER;
// uint16_t amf_set_id = 0; // 10-bit LOG_T(NR_RRC, "generated xid is %d\n", nr_rrc_transaction_identifier[gnb_mod_idP]);
// uint8_t amf_pointer = 0; // 6-bit return nr_rrc_transaction_identifier[gnb_mod_idP];
// uint32_t tmsi = 0; // 32-bit
/* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */
s_TMSI_value = *(s_TMSI->buf);
// amf_set_id = s_TMSI_value >> 38;
// amf_pointer = (s_TMSI_value >> 32) & 0x3F;
// tmsi = (uint32_t)s_TMSI_value;
RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) {
LOG_I(RRC,"checking for UE 5G S-TMSI %x: rnti %x \n",
s_TMSI_value, ue_context_p->ue_context.rnti);
if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI == s_TMSI_value) {
return ue_context_p;
}
}
return NULL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -341,6 +323,78 @@ rrc_gNB_generate_RRCSetup( ...@@ -341,6 +323,78 @@ rrc_gNB_generate_RRCSetup(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(RRC, "rrc_gNB_generate_RRCSetup \n"); LOG_I(RRC, "rrc_gNB_generate_RRCSetup \n");
NR_SRB_ToAddModList_t *SRB_configList;
// T(T_GNB_RRC_SETUP,
// T_INT(ctxt_pP->module_id),
// T_INT(ctxt_pP->frame),
// T_INT(ctxt_pP->subframe),
// T_INT(ctxt_pP->rnti));
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
SRB_configList = &ue_p->SRB_configList;
do_RRCSetup(ctxt_pP,
ue_context_pP,
CC_id,
(uint8_t *) ue_p->Srb0.Tx_buffer.Payload,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
SRB_configList);
LOG_DUMPMSG(NR_RRC, DEBUG_RRC,
(char *)(ue_p->Srb0.Tx_buffer.Payload),
ue_p->Srb0.Tx_buffer.payload_size,
"[MSG] RRC Setup\n");
LOG_D(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
// rrc_mac_config_req_eNB( ctxt_pP->module_id,
// ue_context_pP->ue_context.primaryCC_id,
// 0,0,0,0,0, 0,
// ue_context_pP->ue_context.rnti,
// NULL,
// NULL,
// NULL,
// ue_context_pP->ue_context.physicalConfigDedicated,
// NULL,
// NULL,
// ue_context_pP->ue_context.mac_MainConfig,
// 1,
// SRB1_logicalChannelConfig,
// ue_context_pP->ue_context.measGapConfig,
// NULL,
// NULL,
// NULL,
// 0, NULL, NULL, NULL,
// 0, NULL, NULL,
// NULL,
// 0,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL);
MSC_LOG_TX_MESSAGE(
MSC_RRC_GNB,
MSC_RRC_UE,
ue_p->Srb0.Tx_buffer.Header, // LG WARNING
ue_p->Srb0.Tx_buffer.payload_size,
MSC_AS_TIME_FMT" RRCSetup UE %x size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_pP->ue_context.rnti,
ue_p->Srb0.Tx_buffer.payload_size);
LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_p->Srb0.Tx_buffer.payload_size);
// activate release timer, if RRCSetupComplete not received after 100 frames, remove UE
ue_context_pP->ue_context.ue_release_timer = 1;
// remove UE after 10 frames after RRCConnectionRelease is triggered
ue_context_pP->ue_context.ue_release_timer_thres = 1000;
/* init timers */
// ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0;
} }
void void
...@@ -351,15 +405,15 @@ rrc_gNB_generate_RRCReject( ...@@ -351,15 +405,15 @@ rrc_gNB_generate_RRCReject(
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(RRC, "rrc_gNB_generate_RRCReject \n"); LOG_I(NR_RRC, "rrc_gNB_generate_RRCReject \n");
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
ue_p->Srb0.Tx_buffer.payload_size = do_RRCReject(ctxt_pP->module_id, ue_p->Srb0.Tx_buffer.payload_size = do_RRCReject(ctxt_pP->module_id,
(uint8_t *)ue_p->Srb0.Tx_buffer.Payload); (uint8_t *)ue_p->Srb0.Tx_buffer.Payload);
LOG_DUMPMSG(RRC, DEBUG_RRC, LOG_DUMPMSG(NR_RRC, DEBUG_RRC,
(char *)(ue_p->Srb0.Tx_buffer.Payload), (char *)(ue_p->Srb0.Tx_buffer.Payload),
ue_p->Srb0.Tx_buffer.payload_size, ue_p->Srb0.Tx_buffer.payload_size,
"[MSG] RRCReject \n"); "[MSG] RRCReject \n");
MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_LOG_TX_MESSAGE(MSC_RRC_GNB,
MSC_RRC_UE, MSC_RRC_UE,
ue_p->Srb0.Tx_buffer.Header, ue_p->Srb0.Tx_buffer.Header,
ue_p->Srb0.Tx_buffer.payload_size, ue_p->Srb0.Tx_buffer.payload_size,
...@@ -367,19 +421,18 @@ rrc_gNB_generate_RRCReject( ...@@ -367,19 +421,18 @@ rrc_gNB_generate_RRCReject(
MSC_AS_TIME_ARGS(ctxt_pP), MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti, ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti,
ue_p->Srb0.Tx_buffer.payload_size); ue_p->Srb0.Tx_buffer.payload_size);
LOG_I(RRC, LOG_I(NR_RRC,
PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n", PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_p->Srb0.Tx_buffer.payload_size); ue_p->Srb0.Tx_buffer.payload_size);
} }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
const uint8_t *buffer, const uint8_t *buffer,
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;
...@@ -397,8 +450,8 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -397,8 +450,8 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
if (dec_rval.consumed == 0) { if (dec_rval.consumed == 0) {
/* TODO */ /* TODO */
// LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n", LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n",
// PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return -1; return -1;
} }
...@@ -406,9 +459,9 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -406,9 +459,9 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
switch (ul_ccch_msg->message.choice.c1->present) { switch (ul_ccch_msg->message.choice.c1->present) {
case NR_UL_CCCH_MessageType__c1_PR_NOTHING: case NR_UL_CCCH_MessageType__c1_PR_NOTHING:
/* TODO */ /* TODO */
// LOG_I(RRC, LOG_I(NR_RRC,
// PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n", PROTOCOL_NR_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n",
// PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP));
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest:
...@@ -416,7 +469,7 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -416,7 +469,7 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_p); rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_p);
MSC_LOG_RX_DISCARDED_MESSAGE( MSC_LOG_RX_DISCARDED_MESSAGE(
MSC_RRC_ENB, MSC_RRC_GNB,
MSC_RRC_UE, MSC_RRC_UE,
buffer, buffer,
dec_rval.consumed, dec_rval.consumed,
...@@ -427,8 +480,9 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -427,8 +480,9 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
} else { } else {
rrcSetupRequest = &ul_ccch_msg->message.choice.c1->choice.rrcSetupRequest->rrcSetupRequest; rrcSetupRequest = &ul_ccch_msg->message.choice.c1->choice.rrcSetupRequest->rrcSetupRequest;
if (NR_InitialUE_Identity_PR_randomValue == rrcSetupRequest->ue_Identity.present) { if (NR_InitialUE_Identity_PR_randomValue == rrcSetupRequest->ue_Identity.present) {
/* randomValue BIT STRING (SIZE (39)) */
if (rrcSetupRequest->ue_Identity.choice.randomValue.size != 5) { // 39-bit random value if (rrcSetupRequest->ue_Identity.choice.randomValue.size != 5) { // 39-bit random value
LOG_E(RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %lu", LOG_E(NR_RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %lu",
(long unsigned int)rrcSetupRequest->ue_Identity.choice.randomValue.size); (long unsigned int)rrcSetupRequest->ue_Identity.choice.randomValue.size);
return -1; return -1;
} }
...@@ -441,7 +495,7 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -441,7 +495,7 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
* the current one must be removed from MAC/PHY (zombie UE) * the current one must be removed from MAC/PHY (zombie UE)
*/ */
if ((ue_context_p = rrc_gNB_ue_context_random_exist(RC.nrrrc[ctxt_pP->module_id], random_value))) { if ((ue_context_p = rrc_gNB_ue_context_random_exist(RC.nrrrc[ctxt_pP->module_id], random_value))) {
LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", LOG_W(NR_RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti); ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti);
ue_context_p->ue_context.ul_failure_timer = 20000; ue_context_p->ue_context.ul_failure_timer = 20000;
} }
...@@ -456,15 +510,19 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -456,15 +510,19 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
} else if (NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1 == rrcSetupRequest->ue_Identity.present) { } else if (NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1 == rrcSetupRequest->ue_Identity.present) {
/* TODO */ /* TODO */
/* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */ /* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */
NR_NG_5G_S_TMSI_t s_TMSI = rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1; /* ng-5G-S-TMSI-Part1 BIT STRING (SIZE (39)) */
if (s_TMSI.size != 6) { if (rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.size != 5) {
LOG_E(RRC, "Identity 5G_s_TMSI size, expected 6, provided %lu \n", LOG_E(NR_RRC, "wrong InitialUE-Identity 5G_s_TMSI size, expected 5, provided %lu \n",
(long unsigned int)s_TMSI.size); (long unsigned int)rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.size);
return -1; return -1;
} }
if ((ue_context_p = rrc_gNB_ue_context_5g_stmsi_exist(ctxt_pP, &s_TMSI))) { memcpy(((uint8_t *) & random_value) + 3,
LOG_I(RRC, " 5G-S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p, ue_context_p->ue_context.rnti, ctxt_pP->rnti); rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf,
rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.size);
if ((ue_context_p = rrc_gNB_ue_context_5g_s_tmsi_exist(RC.nrrrc[ctxt_pP->module_id], random_value))) {
LOG_I(NR_RRC, " 5G-S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p, ue_context_p->ue_context.rnti, ctxt_pP->rnti);
rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti); rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
...@@ -482,23 +540,25 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -482,23 +540,25 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
ue_context_p->ue_context.ue_release_timer_s1 = 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.ue_release_timer_rrc = 0;
} else { } else {
LOG_I(RRC," 5G-S-TMSI doesn't exist, setting Initialue_identity_5g_s_TMSI to %p => %x\n",ue_context_p, *(s_TMSI.buf)); LOG_I(NR_RRC, " 5G-S-TMSI doesn't exist, setting Initialue_identity_5g_s_TMSI to %p => %x\n",
ue_context_p,
*(rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf));
ue_context_p = rrc_gNB_get_next_free_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], *(s_TMSI.buf)); ue_context_p = rrc_gNB_get_next_free_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], random_value);
if (ue_context_p == NULL) { if (ue_context_p == NULL) {
LOG_E(RRC, "%s:%d:%s: rrc_gNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(RRC, "%s:%d:%s: rrc_gNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__);
} }
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
ue_context_p->ue_context.Initialue_identity_5g_s_TMSI = *(s_TMSI.buf); ue_context_p->ue_context.Initialue_identity_5g_s_TMSI = *(rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf);
} }
} }
} else { } else {
/* TODO */ /* TODO */
// LOG_E(RRC, LOG_E(NR_RRC,
// PROTOCOL_RRC_CTXT_UE_FMT" RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n",
// PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
rrc_gNB_generate_RRCReject(ctxt_pP, rrc_gNB_generate_RRCReject(ctxt_pP,
rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti),
CC_id); CC_id);
...@@ -516,18 +576,23 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -516,18 +576,23 @@ int nr_rrc_eNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcResumeRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcResumeRequest:
LOG_I(NR_RRC, "receive rrcResumeRequest message \n");
/* TODO */
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest:
LOG_I(NR_RRC, "receive rrcReestablishmentRequest message \n");
/* TODO */
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest:
LOG_I(NR_RRC, "receive rrcSystemInfoRequest message \n");
/* TODO */
break; break;
default: default:
/* TODO */ LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Unknown message\n",
// LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
// PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
break; break;
} }
} }
...@@ -556,35 +621,35 @@ void *rrc_gnb_task(void *args_p) { ...@@ -556,35 +621,35 @@ void *rrc_gnb_task(void *args_p) {
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p)) {
case TERMINATE_MESSAGE: case TERMINATE_MESSAGE:
LOG_W(RRC, " *** Exiting NR_RRC thread\n"); LOG_W(NR_RRC, " *** Exiting NR_RRC thread\n");
itti_exit_task(); itti_exit_task();
break; break;
case MESSAGE_TEST: case MESSAGE_TEST:
LOG_I(RRC, "[gNB %d] Received %s\n", instance, msg_name_p); LOG_I(NR_RRC, "[gNB %d] Received %s\n", instance, msg_name_p);
break; break;
/* Messages from MAC */ /* Messages from MAC */
case NR_RRC_MAC_CCCH_DATA_IND: case NR_RRC_MAC_CCCH_DATA_IND:
// PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, // PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
// NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index, // NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index,
// ENB_FLAG_YES, // GNB_FLAG_YES,
// NR_RRC_MAC_CCCH_DATA_IND(msg_p).rnti, // NR_RRC_MAC_CCCH_DATA_IND(msg_p).rnti,
// msg_p->ittiMsgHeader.lte_time.frame, // msg_p->ittiMsgHeader.lte_time.frame,
// msg_p->ittiMsgHeader.lte_time.slot); // msg_p->ittiMsgHeader.lte_time.slot);
LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", LOG_I(NR_RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n",
instance, instance,
NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id, NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id,
&ctxt, &ctxt,
NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) { if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= CCCH_SDU_SIZE) {
LOG_I(RRC, "CCCH message has size %d > %d\n", LOG_I(NR_RRC, "CCCH message has size %d > %d\n",
NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE); NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,CCCH_SDU_SIZE);
break; break;
} }
nr_rrc_eNB_decode_ccch(&ctxt, nr_rrc_gNB_decode_ccch(&ctxt,
(uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu,
NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,
NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id);
......
...@@ -237,6 +237,27 @@ rrc_gNB_ue_context_random_exist( ...@@ -237,6 +237,27 @@ rrc_gNB_ue_context_random_exist(
return NULL; return NULL;
} }
//-----------------------------------------------------------------------------
// return the ue context if there is already an UE with the same S-TMSI, NULL otherwise
struct rrc_gNB_ue_context_s *
rrc_gNB_ue_context_5g_s_tmsi_exist(
gNB_RRC_INST *rrc_instance_pP,
const uint64_t s_TMSI
)
//-----------------------------------------------------------------------------
{
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head) {
LOG_I(NR_RRC,"checking for UE 5G S-TMSI %x: rnti %x \n",
s_TMSI, ue_context_p->ue_context.rnti);
if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI == s_TMSI) {
return ue_context_p;
}
}
return NULL;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection // return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection
struct rrc_gNB_ue_context_s * struct rrc_gNB_ue_context_s *
...@@ -254,9 +275,9 @@ rrc_gNB_get_next_free_ue_context( ...@@ -254,9 +275,9 @@ rrc_gNB_get_next_free_ue_context(
ue_context_p = rrc_gNB_allocate_new_UE_context(rrc_instance_pP); ue_context_p = rrc_gNB_allocate_new_UE_context(rrc_instance_pP);
if (ue_context_p == NULL) { if (ue_context_p == NULL) {
LOG_E(RRC, LOG_E(NR_RRC,
PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, no memory\n", PROTOCOL_NR_RRC_CTXT_UE_FMT" Cannot create new UE context, no memory\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return NULL; return NULL;
} }
...@@ -264,15 +285,15 @@ rrc_gNB_get_next_free_ue_context( ...@@ -264,15 +285,15 @@ rrc_gNB_get_next_free_ue_context(
ue_context_p->ue_context.rnti = ctxt_pP->rnti; // yes duplicate, 1 may be removed ue_context_p->ue_context.rnti = ctxt_pP->rnti; // yes duplicate, 1 may be removed
ue_context_p->ue_context.random_ue_identity = ue_identityP; ue_context_p->ue_context.random_ue_identity = ue_identityP;
RB_INSERT(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_p); RB_INSERT(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_p);
LOG_D(RRC, LOG_D(NR_RRC,
PROTOCOL_RRC_CTXT_UE_FMT" Created new UE context uid %u\n", PROTOCOL_NR_RRC_CTXT_UE_FMT" Created new UE context uid %u\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p->local_uid); ue_context_p->local_uid);
return ue_context_p; return ue_context_p;
} else { } else {
LOG_E(RRC, LOG_E(NR_RRC,
PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n", PROTOCOL_NR_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return NULL; return NULL;
} }
......
...@@ -90,6 +90,12 @@ rrc_gNB_ue_context_random_exist( ...@@ -90,6 +90,12 @@ rrc_gNB_ue_context_random_exist(
const uint64_t ue_identityP const uint64_t ue_identityP
); );
struct rrc_gNB_ue_context_s *
rrc_gNB_ue_context_5g_s_tmsi_exist(
gNB_RRC_INST *rrc_instance_pP,
const uint64_t s_TMSI
);
struct rrc_gNB_ue_context_s * struct rrc_gNB_ue_context_s *
rrc_gNB_get_next_free_ue_context( rrc_gNB_get_next_free_ue_context(
const protocol_ctxt_t *const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
......
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