Commit d906c3c9 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/remove-duplications-of-srb-list' into integration_2023_w22

parents 3ff39449 313d34a8
...@@ -428,15 +428,6 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); ...@@ -428,15 +428,6 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac);
void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs);
static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
nr_dci_format_t dci_format,
uint8_t dci_size,
uint16_t rnti,
int ss_type,
uint64_t *dci_pdu,
dci_pdu_rel15_t *dci_pdu_rel15,
int slot);
fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot, int fb_time); fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot, int fb_time);
fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot); fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot);
......
...@@ -149,6 +149,14 @@ const initial_pucch_resource_t initial_pucch_resource[16] = { ...@@ -149,6 +149,14 @@ const initial_pucch_resource_t initial_pucch_resource[16] = {
/* 14 */ { 1, 0, 14, 4, 4, { 0, 3, 6, 9 } }, /* 14 */ { 1, 0, 14, 4, 4, { 0, 3, 6, 9 } },
/* 15 */ { 1, 0, 14, 0, 4, { 0, 3, 6, 9 } }, /* 15 */ { 1, 0, 14, 0, 4, { 0, 3, 6, 9 } },
}; };
static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
nr_dci_format_t dci_format,
uint8_t dci_size,
uint16_t rnti,
int ss_type,
uint64_t *dci_pdu,
dci_pdu_rel15_t *dci_pdu_rel15,
int slot);
void nr_ue_init_mac(module_id_t module_idP) void nr_ue_init_mac(module_id_t module_idP)
{ {
......
...@@ -506,89 +506,56 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, ...@@ -506,89 +506,56 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer, uint8_t *const buffer,
const uint8_t transaction_id, const uint8_t transaction_id,
const uint8_t *masterCellGroup, const uint8_t *masterCellGroup,
int masterCellGroup_len, int masterCellGroup_len,
const gNB_RrcConfigurationReq *configuration) const gNB_RrcConfigurationReq *configuration,
NR_SRB_ToAddModList_t *SRBs)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
asn_enc_rval_t enc_rval; AssertFatal(ue_context_pP != NULL, "ue_context_p is null\n");
NR_DL_CCCH_Message_t dl_ccch_msg; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
NR_RRCSetup_t *rrcSetup;
NR_RRCSetup_IEs_t *ie; NR_DL_CCCH_Message_t dl_ccch_msg = {0};
NR_SRB_ToAddMod_t *SRB1_config = NULL; dl_ccch_msg.message.present = NR_DL_CCCH_MessageType_PR_c1;
NR_PDCP_Config_t *pdcp_Config = NULL; asn1cCalloc(dl_ccch_msg.message.choice.c1, dl_msg);
dl_msg->present = NR_DL_CCCH_MessageType__c1_PR_rrcSetup;
AssertFatal(ue_context_pP != NULL,"ue_context_p is null\n"); asn1cCalloc(dl_msg->choice.rrcSetup, rrcSetup);
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; rrcSetup->criticalExtensions.present = NR_RRCSetup__criticalExtensions_PR_rrcSetup;
NR_SRB_ToAddModList_t **SRB_configList = &ue_p->SRB_configList; rrcSetup->rrc_TransactionIdentifier = transaction_id;
rrcSetup->criticalExtensions.choice.rrcSetup = calloc(1, sizeof(NR_RRCSetup_IEs_t));
NR_RRCSetup_IEs_t *ie = rrcSetup->criticalExtensions.choice.rrcSetup;
memset((void *)&dl_ccch_msg, 0, sizeof(NR_DL_CCCH_Message_t)); /****************************** radioBearerConfig ******************************/
dl_ccch_msg.message.present = NR_DL_CCCH_MessageType_PR_c1; ie->radioBearerConfig.srb_ToAddModList = SRBs;
dl_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_DL_CCCH_MessageType__c1)); ie->radioBearerConfig.srb3_ToRelease = NULL;
dl_ccch_msg.message.choice.c1->present = NR_DL_CCCH_MessageType__c1_PR_rrcSetup; ie->radioBearerConfig.drb_ToAddModList = NULL;
dl_ccch_msg.message.choice.c1->choice.rrcSetup = calloc(1, sizeof(NR_RRCSetup_t)); ie->radioBearerConfig.drb_ToReleaseList = NULL;
ie->radioBearerConfig.securityConfig = NULL;
rrcSetup = dl_ccch_msg.message.choice.c1->choice.rrcSetup;
rrcSetup->criticalExtensions.present = NR_RRCSetup__criticalExtensions_PR_rrcSetup;
rrcSetup->rrc_TransactionIdentifier = transaction_id;
rrcSetup->criticalExtensions.choice.rrcSetup = calloc(1, sizeof(NR_RRCSetup_IEs_t));
ie = rrcSetup->criticalExtensions.choice.rrcSetup;
/****************************** radioBearerConfig ******************************/ /****************************** masterCellGroup ******************************/
DevAssert(masterCellGroup && masterCellGroup_len > 0);
/* Configure SRB1 */ ie->masterCellGroup.buf = malloc(masterCellGroup_len);
if (*SRB_configList) { AssertFatal(ie->masterCellGroup.buf != NULL, "could not allocate memory for masterCellGroup\n");
free(*SRB_configList); memcpy(ie->masterCellGroup.buf, masterCellGroup, masterCellGroup_len);
} ie->masterCellGroup.size = masterCellGroup_len;
*SRB_configList = calloc(1, sizeof(NR_SRB_ToAddModList_t)); // decode masterCellGroup OCTET_STRING received from DU and place in ue context
// SRB1 ue_p->masterCellGroup = decode_cellGroupConfig(masterCellGroup, masterCellGroup_len);
/* 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;
asn1cSeqAdd(&(*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 ******************************/
DevAssert(masterCellGroup && masterCellGroup_len > 0);
ie->masterCellGroup.buf = malloc(masterCellGroup_len);
AssertFatal(ie->masterCellGroup.buf != NULL, "could not allocate memory for masterCellGroup\n");
memcpy(ie->masterCellGroup.buf, masterCellGroup, masterCellGroup_len);
ie->masterCellGroup.size = masterCellGroup_len;
// decode masterCellGroup OCTET_STRING received from DU and place in ue context
ue_p->masterCellGroup = decode_cellGroupConfig(masterCellGroup, masterCellGroup_len);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, ue_p->masterCellGroup); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, ue_p->masterCellGroup);
xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg); 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, asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_CCCH_Message, NULL, (void *)&dl_ccch_msg, buffer, 1000);
NULL,
(void *)&dl_ccch_msg,
buffer,
1000);
AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
AssertFatal(enc_rval.encoded >0, "ASN1 message encoding failed (%s, %lu)!\n", LOG_D(NR_RRC, "RRCSetup Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded + 7) / 8);
enc_rval.failed_type->name, enc_rval.encoded); return ((enc_rval.encoded + 7) / 8);
LOG_D(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n",
enc_rval.encoded,(enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8);
} }
uint8_t do_NR_SecurityModeCommand( uint8_t do_NR_SecurityModeCommand(
...@@ -1134,67 +1101,26 @@ uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c ...@@ -1134,67 +1101,26 @@ uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int do_RRCReestablishment(const protocol_ctxt_t *const ctxt_pP, int do_RRCReestablishment(const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP, rrc_gNB_ue_context_t *const ue_context_pP,
int CC_id, int CC_id,
uint8_t *const buffer, uint8_t *const buffer,
size_t buffer_size, size_t buffer_size,
const uint8_t Transaction_id, const uint8_t Transaction_id,
NR_SRB_ToAddModList_t **SRB_configList, NR_SRB_ToAddModList_t *SRB_configList,
const uint8_t *masterCellGroup_from_DU, const uint8_t *masterCellGroup_from_DU,
NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfigCommon_t *scc,
rrc_gNB_carrier_data_t *carrier) rrc_gNB_carrier_data_t *carrier)
{ {
asn_enc_rval_t enc_rval; asn_enc_rval_t enc_rval;
struct NR_SRB_ToAddMod *SRB1_config = NULL;
struct NR_SRB_ToAddMod *SRB2_config = NULL;
NR_DL_DCCH_Message_t dl_dcch_msg = {0}; NR_DL_DCCH_Message_t dl_dcch_msg = {0};
NR_RRCReestablishment_t *rrcReestablishment = NULL; NR_RRCReestablishment_t *rrcReestablishment = NULL;
NR_SRB_ToAddModList_t **SRB_configList2 = NULL;
SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[Transaction_id];
if (*SRB_configList2) {
free(*SRB_configList2);
}
*SRB_configList2 = CALLOC(1, sizeof(NR_SRB_ToAddModList_t));
dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.present = NR_DL_DCCH_MessageType_PR_c1;
dl_dcch_msg.message.choice.c1 = calloc(1, sizeof(struct NR_DL_DCCH_MessageType__c1)); dl_dcch_msg.message.choice.c1 = calloc(1, sizeof(struct NR_DL_DCCH_MessageType__c1));
dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment; dl_dcch_msg.message.choice.c1->present = NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment;
dl_dcch_msg.message.choice.c1->choice.rrcReestablishment = CALLOC(1, sizeof(NR_RRCReestablishment_t)); dl_dcch_msg.message.choice.c1->choice.rrcReestablishment = CALLOC(1, sizeof(NR_RRCReestablishment_t));
rrcReestablishment = dl_dcch_msg.message.choice.c1->choice.rrcReestablishment; rrcReestablishment = dl_dcch_msg.message.choice.c1->choice.rrcReestablishment;
// get old configuration of SRB2
if (*SRB_configList != NULL) {
for (int i = 0; (i < (*SRB_configList)->list.count) && (i < 3); i++) {
LOG_D(NR_RRC, "(*SRB_configList)->list.array[%d]->srb_Identity=%ld\n", i, (*SRB_configList)->list.array[i]->srb_Identity);
if ((*SRB_configList)->list.array[i]->srb_Identity == 2) {
SRB2_config = (*SRB_configList)->list.array[i];
} else if ((*SRB_configList)->list.array[i]->srb_Identity == 1) {
SRB1_config = (*SRB_configList)->list.array[i];
}
}
}
if (SRB1_config == NULL) {
// default SRB1 configuration
LOG_W(NR_RRC, "SRB1 configuration does not exist in SRB configuration list, use default\n");
/// SRB1
SRB1_config = CALLOC(1, sizeof(*SRB1_config));
SRB1_config->srb_Identity = 1;
}
if (SRB2_config == NULL) {
LOG_W(NR_RRC, "SRB2 configuration does not exist in SRB configuration list\n");
} else {
asn1cSeqAdd(&(*SRB_configList2)->list, SRB2_config);
}
if (*SRB_configList) {
free(*SRB_configList);
}
*SRB_configList = CALLOC(1, sizeof(NR_SRB_ToAddModList_t));
asn1cSeqAdd(&(*SRB_configList)->list, SRB1_config);
/****************************** masterCellGroup ******************************/ /****************************** masterCellGroup ******************************/
rrcReestablishment->rrc_TransactionIdentifier = Transaction_id; rrcReestablishment->rrc_TransactionIdentifier = Transaction_id;
rrcReestablishment->criticalExtensions.present = NR_RRCReestablishment__criticalExtensions_PR_rrcReestablishment; rrcReestablishment->criticalExtensions.present = NR_RRCReestablishment__criticalExtensions_PR_rrcReestablishment;
......
...@@ -99,12 +99,13 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, ...@@ -99,12 +99,13 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
NR_DRB_ToAddModList_t *drb_configList, NR_DRB_ToAddModList_t *drb_configList,
long *priority); long *priority);
int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer, uint8_t *const buffer,
const uint8_t transaction_id, const uint8_t transaction_id,
const uint8_t *masterCellGroup, const uint8_t *masterCellGroup,
int masterCellGroup_len, int masterCellGroup_len,
const gNB_RrcConfigurationReq *configuration); const gNB_RrcConfigurationReq *configuration,
NR_SRB_ToAddModList_t *SRBs);
uint8_t do_NR_SecurityModeCommand( uint8_t do_NR_SecurityModeCommand(
const protocol_ctxt_t *const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
...@@ -172,15 +173,15 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, ...@@ -172,15 +173,15 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer,
uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c_rnti); uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c_rnti);
int do_RRCReestablishment(const protocol_ctxt_t *const ctxt_pP, int do_RRCReestablishment(const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *const ue_context_pP, rrc_gNB_ue_context_t *const ue_context_pP,
int CC_id, int CC_id,
uint8_t *const buffer, uint8_t *const buffer,
size_t buffer_size, size_t buffer_size,
const uint8_t Transaction_id, const uint8_t Transaction_id,
NR_SRB_ToAddModList_t **SRB_configList, NR_SRB_ToAddModList_t *SRB_configList,
const uint8_t *masterCellGroup_from_DU, const uint8_t *masterCellGroup_from_DU,
NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfigCommon_t *scc,
rrc_gNB_carrier_data_t *carrier); rrc_gNB_carrier_data_t *carrier);
int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier);
......
...@@ -101,12 +101,11 @@ void CU_update_UP_DL_tunnel(e1ap_bearer_setup_req_t *const req, instance_t insta ...@@ -101,12 +101,11 @@ void CU_update_UP_DL_tunnel(e1ap_bearer_setup_req_t *const req, instance_t insta
} }
static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
rrc_gNB_ue_context_t *ue_context_p, rrc_gNB_ue_context_t *ue_context_p,
e1ap_bearer_setup_req_t *const req, e1ap_bearer_setup_req_t *const req,
NR_DRB_ToAddModList_t *DRB_configList, NR_DRB_ToAddModList_t *DRB_configList,
NR_SRB_ToAddModList_t *SRB_configList, instance_t instance)
instance_t instance) { {
gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0}; gtpv1u_gnb_create_tunnel_req_t create_tunnel_req={0};
gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0}; gtpv1u_gnb_create_tunnel_resp_t create_tunnel_resp={0};
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
...@@ -151,10 +150,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, ...@@ -151,10 +150,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
/* Refresh SRBs/DRBs */ /* Refresh SRBs/DRBs */
LOG_D(NR_RRC, "Configuring PDCP DRBs/SRBs for UE %x\n", UE->rnti); LOG_D(NR_RRC, "Configuring PDCP DRBs for UE %x\n", UE->rnti);
nr_pdcp_add_srbs(ctxt_p->enb_flag, ctxt_p->rntiMaybeUEid, SRB_configList, (UE->integrity_algorithm << 4) | UE->ciphering_algorithm, kRRCenc, kRRCint);
nr_pdcp_add_drbs(ctxt_p->enb_flag, nr_pdcp_add_drbs(ctxt_p->enb_flag,
ctxt_p->rntiMaybeUEid, ctxt_p->rntiMaybeUEid,
0, 0,
...@@ -167,21 +163,6 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p, ...@@ -167,21 +163,6 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
return ret; return ret;
} }
static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_ToAddModList_t *SRB_configList, uint8_t xid)
{
NR_SRB_ToAddModList_t **SRB_configList2 = NULL;
SRB_configList2 = &ue->SRB_configList2[xid];
if (*SRB_configList2 == NULL) {
*SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
NR_SRB_ToAddMod_t *SRB2_config = CALLOC(1, sizeof(*SRB2_config));
SRB2_config->srb_Identity = 2;
asn1cSeqAdd(&(*SRB_configList2)->list, SRB2_config);
asn1cSeqAdd(&SRB_configList->list, SRB2_config);
}
return SRB_configList2;
}
static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance, uint8_t xid) static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance, uint8_t xid)
{ {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], req->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], req->rnti);
...@@ -205,10 +186,8 @@ static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const ...@@ -205,10 +186,8 @@ static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const
} }
gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id];
// Fixme: xid not random, but almost!
NR_SRB_ToAddModList_t **SRB_configList2 = generateSRB2_confList(UE, UE->SRB_configList, UE->pduSession[0].xid);
// GTP tunnel for UL // GTP tunnel for UL
int ret = drb_config_gtpu_create(&ctxt, ue_context_p, req, UE->DRB_configList, *SRB_configList2, rrc->e1_inst); int ret = drb_config_gtpu_create(&ctxt, ue_context_p, req, UE->DRB_configList, rrc->e1_inst);
if (ret < 0) AssertFatal(false, "Unable to configure DRB or to create GTP Tunnel\n"); if (ret < 0) AssertFatal(false, "Unable to configure DRB or to create GTP Tunnel\n");
// Used to store teids: if monolithic, will simply be NULL // Used to store teids: if monolithic, will simply be NULL
......
...@@ -54,14 +54,3 @@ void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan) ...@@ -54,14 +54,3 @@ void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan)
chan->Delay_class = 1; chan->Delay_class = 1;
return; return;
} }
//-----------------------------------------------------------------------------
void rrc_config_nr_buffer(NR_SRB_INFO* Srb_info,
uint8_t Lchan_type,
uint8_t Role)
{
Srb_info->Rx_buffer.payload_size = 0;
Srb_info->Tx_buffer.payload_size = 0;
}
//-----------------------------------------------------------------------------
...@@ -61,31 +61,16 @@ typedef struct RB_INFO_NR_s { ...@@ -61,31 +61,16 @@ typedef struct RB_INFO_NR_s {
} NR_RB_INFO; } NR_RB_INFO;
typedef struct NR_SRB_INFO_s { typedef struct NR_SRB_INFO_s {
uint16_t Srb_id; //=Lchan_id NR_RRC_BUFFER Rx_buffer;
NR_RRC_BUFFER Rx_buffer; NR_RRC_BUFFER Tx_buffer;
NR_RRC_BUFFER Tx_buffer;
NR_LCHAN_DESC Lchan_desc[2];
unsigned int Trans_id;
uint8_t Active;
} NR_SRB_INFO; } NR_SRB_INFO;
typedef struct RB_INFO_TABLE_ENTRY_NR_s {
NR_RB_INFO Rb_info;
uint8_t Active;
uint32_t Next_check_frame;
uint8_t status;
} NR_RB_INFO_TABLE_ENTRY;
typedef struct SRB_INFO_TABLE_ENTRY_NR_s { typedef struct SRB_INFO_TABLE_ENTRY_NR_s {
NR_SRB_INFO Srb_info; NR_SRB_INFO Srb_info;
uint8_t Active; uint8_t Active;
uint8_t status; uint8_t status;
uint32_t Next_check_frame;
} NR_SRB_INFO_TABLE_ENTRY; } NR_SRB_INFO_TABLE_ENTRY;
void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan); void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan);
void rrc_config_nr_buffer(NR_SRB_INFO* Srb_info,
uint8_t Lchan_type,
uint8_t Role);
#endif #endif
...@@ -236,9 +236,7 @@ typedef enum { ...@@ -236,9 +236,7 @@ typedef enum {
} rrc_action_t; } rrc_action_t;
typedef struct gNB_RRC_UE_s { typedef struct gNB_RRC_UE_s {
uint8_t primaryCC_id; uint8_t primaryCC_id;
NR_SRB_ToAddModList_t *SRB_configList;
NR_SRB_ToAddModList_t *SRB_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER];
NR_DRB_ToAddModList_t *DRB_configList; NR_DRB_ToAddModList_t *DRB_configList;
NR_DRB_ToAddModList_t *DRB_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; NR_DRB_ToAddModList_t *DRB_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER];
NR_DRB_ToReleaseList_t *DRB_Release_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER]; NR_DRB_ToReleaseList_t *DRB_Release_configList2[NR_RRC_TRANSACTION_IDENTIFIER_NUMBER];
......
...@@ -115,22 +115,23 @@ mui_t rrc_gNB_mui = 0; ...@@ -115,22 +115,23 @@ mui_t rrc_gNB_mui = 0;
///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------///
static void nr_rrc_addmod_srbs(int rnti, static void nr_rrc_addmod_srbs(int rnti,
const NR_SRB_ToAddModList_t *srb_list, const NR_SRB_INFO_TABLE_ENTRY *srb_list,
const int nb_srb,
const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list) const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list)
{ {
if (srb_list == NULL || bearer_list == NULL) if (srb_list == NULL || bearer_list == NULL)
return; return;
for (int i = 0; i < srb_list->list.count; i++) { for (int i = 0; i < nb_srb; i++) {
const NR_SRB_ToAddMod_t *srb = srb_list->list.array[i]; if (srb_list[i].Active)
for (int j = 0; j < bearer_list->list.count; j++) { for (int j = 0; j < bearer_list->list.count; j++) {
const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j]; const NR_RLC_BearerConfig_t *bearer = bearer_list->list.array[j];
if (bearer->servedRadioBearer != NULL if (bearer->servedRadioBearer != NULL
&& bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity && bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity
&& srb->srb_Identity == bearer->servedRadioBearer->choice.srb_Identity) { && i == bearer->servedRadioBearer->choice.srb_Identity) {
nr_rlc_add_srb(rnti, srb->srb_Identity, bearer); nr_rlc_add_srb(rnti, i, bearer);
}
} }
}
} }
} }
...@@ -303,22 +304,49 @@ unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP) ...@@ -303,22 +304,49 @@ unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP)
return tmp; return tmp;
} }
static NR_SRB_ToAddModList_t *createSRBlist(gNB_RRC_UE_t *ue, bool reestablish)
{
if (!ue->Srb[1].Active) {
LOG_E(NR_RRC, "Call SRB list while SRB1 doesn't exist\n");
return NULL;
}
NR_SRB_ToAddModList_t *list = CALLOC(sizeof(*list), 1);
for (int i = 0; i < maxSRBs; i++)
if (ue->Srb[i].Active) {
asn1cSequenceAdd(list->list, NR_SRB_ToAddMod_t, srb);
srb->srb_Identity = i;
if (reestablish && i == 2) {
asn1cCallocOne(srb->reestablishPDCP, NR_SRB_ToAddMod__reestablishPDCP_true);
}
}
return list;
}
static void freeSRBlist(NR_SRB_ToAddModList_t *l)
{
if (l) {
for (int i = 0; i < l->list.count; i++)
free(l->list.array[i]);
free(l);
} else
LOG_E(NR_RRC, "Call free SRB list on NULL pointer\n");
}
static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP) static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP)
{ {
NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL; NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL;
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, cgc); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
nr_rrc_mac_update_cellgroup(ue_p->rnti, cgc);
nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, cgc->rlc_BearerToAddModList); nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, ue_p->Srb, maxSRBs, cgc->rlc_BearerToAddModList);
nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.DRB_configList, cgc->rlc_BearerToAddModList); nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, ue_p->DRB_configList, cgc->rlc_BearerToAddModList);
} }
void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP, ue_id_t ue_id) void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP, ue_id_t ue_id)
{ {
nr_rrc_mac_update_cellgroup(ue_id, ue_context_pP->ue_context.masterCellGroup); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
nr_rrc_mac_update_cellgroup(ue_id, ue_p->masterCellGroup);
nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, ue_p->Srb, maxSRBs, ue_p->masterCellGroup->rlc_BearerToAddModList);
ue_context_pP->ue_context.SRB_configList,
ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -336,7 +364,9 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance, ...@@ -336,7 +364,9 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance,
unsigned char buf[1024]; unsigned char buf[1024];
uint8_t xid = rrc_gNB_get_next_transaction_identifier(instance); uint8_t xid = rrc_gNB_get_next_transaction_identifier(instance);
ue_p->xids[xid] = RRC_SETUP; ue_p->xids[xid] = RRC_SETUP;
int size = do_RRCSetup(ue_context_pP, buf, xid, masterCellGroup, masterCellGroup_len, &rrc->configuration); NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, false);
int size = do_RRCSetup(ue_context_pP, buf, xid, masterCellGroup, masterCellGroup_len, &rrc->configuration, SRBs);
AssertFatal(size > 0, "do_RRCSetup failed\n"); AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n"); AssertFatal(size <= 1024, "memory corruption\n");
...@@ -344,9 +374,9 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance, ...@@ -344,9 +374,9 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance,
(char *)buf, (char *)buf,
size, size,
"[MSG] RRC Setup\n"); "[MSG] RRC Setup\n");
nr_pdcp_add_srbs(true, rnti, SRBs, 0, NULL, NULL);
nr_pdcp_add_srbs(true, rnti, ue_context_pP->ue_context.SRB_configList, 0, NULL, NULL); freeSRBlist(SRBs);
f1ap_dl_rrc_message_t dl_rrc = { f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF, .old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = buf, .rrc_container = buf,
...@@ -371,7 +401,9 @@ static int rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t m ...@@ -371,7 +401,9 @@ static int rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t m
unsigned char buf[1024]; unsigned char buf[1024];
uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id); uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id);
ue_p->xids[xid] = RRC_SETUP_FOR_REESTABLISHMENT; ue_p->xids[xid] = RRC_SETUP_FOR_REESTABLISHMENT;
int size = do_RRCSetup(ue_context_pP, buf, xid, NULL, 0, &rrc_instance_p->configuration); NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, true);
int size = do_RRCSetup(ue_context_pP, buf, xid, NULL, 0, &rrc_instance_p->configuration, SRBs);
AssertFatal(size > 0, "do_RRCSetup failed\n"); AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n"); AssertFatal(size <= 1024, "memory corruption\n");
...@@ -383,6 +415,7 @@ static int rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t m ...@@ -383,6 +415,7 @@ static int rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t m
"[MSG] RRC Setup\n"); "[MSG] RRC Setup\n");
LOG_D(NR_RRC, "RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB for rnti %04x\n", rnti); LOG_D(NR_RRC, "RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB for rnti %04x\n", rnti);
freeSRBlist(SRBs);
// update SCC and MIB/SIB (two calls) // update SCC and MIB/SIB (two calls)
nr_mac_config_scc(RC.nrmac[rrc_instance_p->module_id], nr_mac_config_scc(RC.nrmac[rrc_instance_p->module_id],
...@@ -570,12 +603,9 @@ void fill_DRB_configList(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_contex ...@@ -570,12 +603,9 @@ void fill_DRB_configList(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_contex
if (!ue_p->DRB_configList) if (!ue_p->DRB_configList)
ue_p->DRB_configList = CALLOC(1, sizeof(*ue_p->DRB_configList)); ue_p->DRB_configList = CALLOC(1, sizeof(*ue_p->DRB_configList));
else
memset(ue_p->DRB_configList, 0, sizeof(*ue_p->DRB_configList));
if (!ue_p->DRB_configList2[xid]) if (!ue_p->DRB_configList2[xid])
ue_p->DRB_configList2[xid] = CALLOC(1, sizeof(**ue_p->DRB_configList2)); ue_p->DRB_configList2[xid] = CALLOC(1, sizeof(**ue_p->DRB_configList2));
else
memset(ue_p->DRB_configList2[xid], 0, sizeof(**ue_p->DRB_configList2));
for (i = 0; i < ue_p->nb_of_pdusessions; i++) { for (i = 0; i < ue_p->nb_of_pdusessions; i++) {
if (ue_p->pduSession[i].status >= PDU_SESSION_STATUS_DONE) { if (ue_p->pduSession[i].status >= PDU_SESSION_STATUS_DONE) {
continue; continue;
...@@ -672,15 +702,13 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c ...@@ -672,15 +702,13 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c
NR_CellGroupConfig_t *cellGroupConfig = ue_p->masterCellGroup; NR_CellGroupConfig_t *cellGroupConfig = ue_p->masterCellGroup;
AssertFatal(xid > -1, "Invalid xid %d. No PDU sessions setup to configure.\n", xid); AssertFatal(xid > -1, "Invalid xid %d. No PDU sessions setup to configure.\n", xid);
NR_SRB_ToAddModList_t *SRB_configList2 = NULL;
SRB_configList2 = ue_p->SRB_configList2[xid];
uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t buffer[RRC_BUF_SIZE] = {0};
NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, false);
int size = do_RRCReconfiguration(ctxt_pP, int size = do_RRCReconfiguration(ctxt_pP,
buffer, buffer,
RRC_BUF_SIZE, RRC_BUF_SIZE,
xid, xid,
SRB_configList2, SRBs,
DRB_configList, DRB_configList,
NULL, NULL,
NULL, NULL,
...@@ -693,7 +721,7 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c ...@@ -693,7 +721,7 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c
NULL, NULL,
cellGroupConfig); cellGroupConfig);
LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Reconfiguration\n"); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Reconfiguration\n");
freeSRBlist(SRBs);
/* Free all NAS PDUs */ /* Free all NAS PDUs */
for (int i = 0; i < ue_p->nb_of_pdusessions; i++) { for (int i = 0; i < ue_p->nb_of_pdusessions; i++) {
if (ue_p->pduSession[i].param.nas_pdu.buffer != NULL) { if (ue_p->pduSession[i].param.nas_pdu.buffer != NULL) {
...@@ -990,12 +1018,11 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co ...@@ -990,12 +1018,11 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co
uint8_t kRRCint[16] = {0}; uint8_t kRRCint[16] = {0};
uint8_t kUPenc[16] = {0}; uint8_t kUPenc[16] = {0};
uint8_t kUPint[16] = {0}; uint8_t kUPint[16] = {0};
NR_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid]; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; NR_DRB_ToAddModList_t *DRB_configList = ue_p->DRB_configList2[xid];
NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_p->DRB_Release_configList2[xid];
NR_DRB_Identity_t *drb_id_p = NULL; NR_DRB_Identity_t *drb_id_p = NULL;
// uint8_t nr_DRB2LCHAN[8]; // uint8_t nr_DRB2LCHAN[8];
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
/* Derive the keys from kgnb */ /* Derive the keys from kgnb */
if (DRB_configList != NULL) { if (DRB_configList != NULL) {
...@@ -1023,9 +1050,15 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co ...@@ -1023,9 +1050,15 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co
} }
} }
} }
NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, false);
nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, SRB_configList, (ue_p->integrity_algorithm << 4) | ue_p->ciphering_algorithm, kRRCenc, kRRCint); nr_pdcp_add_srbs(ctxt_pP->enb_flag,
ctxt_pP->rntiMaybeUEid,
SRBs,
(ue_p->integrity_algorithm << 4) | ue_p->ciphering_algorithm,
kRRCenc,
kRRCint);
freeSRBlist(SRBs);
nr_pdcp_add_drbs(ctxt_pP->enb_flag, nr_pdcp_add_drbs(ctxt_pP->enb_flag,
ctxt_pP->rntiMaybeUEid, ctxt_pP->rntiMaybeUEid,
reestablish_ue_id, reestablish_ue_id,
...@@ -1035,32 +1068,14 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co ...@@ -1035,32 +1068,14 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co
kUPint, kUPint,
get_softmodem_params()->sa ? ue_p->masterCellGroup->rlc_BearerToAddModList : NULL); get_softmodem_params()->sa ? ue_p->masterCellGroup->rlc_BearerToAddModList : NULL);
/* Refresh SRBs/DRBs */ /* Refresh DRBs */
if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) {
LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %04x\n",ue_context_pP->ue_context.rnti); LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %04x\n",ue_context_pP->ue_context.rnti);
const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list = const struct NR_CellGroupConfig__rlc_BearerToAddModList *bearer_list =
ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList; ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList;
nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, SRB_configList, bearer_list);
nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, DRB_configList, bearer_list); nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, DRB_configList, bearer_list);
} }
/* Set the SRB active in UE context */
if (SRB_configList != NULL) {
for (int i = 0; (i < SRB_configList->list.count) && (i < 3); i++) {
if (SRB_configList->list.array[i]->srb_Identity == 1) {
ue_p->Srb[1].Active = 1;
} else if (SRB_configList->list.array[i]->srb_Identity == 2) {
ue_p->Srb[2].Active = 1;
LOG_I(NR_RRC, "[gNB %d] Frame %d CC %d : SRB2 is now active\n", ctxt_pP->module_id, ctxt_pP->frame, ue_p->primaryCC_id);
} else {
LOG_W(NR_RRC, "[gNB %d] Frame %d CC %d: invalid SRB identity %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ue_p->primaryCC_id, SRB_configList->list.array[i]->srb_Identity);
}
}
free(SRB_configList);
ue_p->SRB_configList2[xid] = NULL;
}
/* Loop through DRBs and establish if necessary */ /* Loop through DRBs and establish if necessary */
if (DRB_configList != NULL) { if (DRB_configList != NULL) {
for (int i = 0; i < DRB_configList->list.count; i++) { for (int i = 0; i < DRB_configList->list.count; i++) {
...@@ -1143,7 +1158,6 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1143,7 +1158,6 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
{ {
// int UE_id = -1; // int UE_id = -1;
// NR_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL; // NR_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL;
NR_SRB_ToAddModList_t **SRB_configList;
// NR_SRB_ToAddMod_t *SRB1_config = NULL; // NR_SRB_ToAddMod_t *SRB1_config = NULL;
// rrc_gNB_carrier_data_t *carrier = NULL; // rrc_gNB_carrier_data_t *carrier = NULL;
module_id_t module_id = ctxt_pP->module_id; module_id_t module_id = ctxt_pP->module_id;
...@@ -1156,18 +1170,17 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1156,18 +1170,17 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
ue_p->spCellConfigReestablishment = ue_p->masterCellGroup->spCellConfig; ue_p->spCellConfigReestablishment = ue_p->masterCellGroup->spCellConfig;
ue_p->masterCellGroup->spCellConfig = NULL; ue_p->masterCellGroup->spCellConfig = NULL;
SRB_configList = &(ue_p->SRB_configList);
uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t buffer[RRC_BUF_SIZE] = {0};
uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id); uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id);
ue_p->xids[xid] = RRC_REESTABLISH; ue_p->xids[xid] = RRC_REESTABLISH;
NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, true);
int size = do_RRCReestablishment(ctxt_pP, int size = do_RRCReestablishment(ctxt_pP,
ue_context_pP, ue_context_pP,
CC_id, CC_id,
buffer, buffer,
RRC_BUF_SIZE, RRC_BUF_SIZE,
xid, xid,
SRB_configList, SRBs,
masterCellGroup_from_DU, masterCellGroup_from_DU,
scc, scc,
&rrc->carrier); &rrc->carrier);
...@@ -1178,28 +1191,16 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1178,28 +1191,16 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
uint8_t kRRCint[16] = {0}; uint8_t kRRCint[16] = {0};
uint8_t kUPenc[16] = {0}; uint8_t kUPenc[16] = {0};
/* Derive the keys from kgnb */ /* Derive the keys from kgnb */
if (SRB_configList != NULL) { if (ue_p->Srb[1].Active)
nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc); nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc);
}
nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc); nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc);
nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint); nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint);
/* Configure SRB1 for UE */ /* Configure SRB1 for UE */
if (*SRB_configList != NULL) { nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, SRBs, 0, NULL, NULL);
for (int cnt = 0; cnt < (*SRB_configList)->list.count; cnt++) { LOG_D(NR_RRC, "UE %04x --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", ue_p->rnti);
if ((*SRB_configList)->list.array[cnt]->srb_Identity == 1) { freeSRBlist(SRBs);
nr_pdcp_add_srbs(ctxt_pP->enb_flag,
ctxt_pP->rntiMaybeUEid,
*SRB_configList,
0,
NULL,
NULL);
}
LOG_D(NR_RRC, "UE %04x --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", ue_p->rnti);
}
} // if (*SRB_configList != NULL)
LOG_I(NR_RRC, "Set PDCP security RNTI %04lx nca %ld nia %d in RRCReestablishment\n", ctxt_pP->rntiMaybeUEid, ue_p->ciphering_algorithm, ue_p->integrity_algorithm); LOG_I(NR_RRC, "Set PDCP security RNTI %04lx nca %ld nia %d in RRCReestablishment\n", ctxt_pP->rntiMaybeUEid, ue_p->ciphering_algorithm, ue_p->integrity_algorithm);
uint8_t security_mode = uint8_t security_mode =
enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4); enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4);
...@@ -1218,78 +1219,6 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1218,78 +1219,6 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc); nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
} }
/*
* Handle RRC Reestablishment Complete Functions
*/
/// @brief Function used in RRCReestablishmentComplete procedure to reestablish the SRB2.
/// @param old_xid The old RRC transaction id.
/// @param new_xid The new RRC transaction id.
void RRCReestablishmentComplete_fill_SRB2_configList(const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *ue_context_pP,
const uint8_t old_xid,
const uint8_t new_xid)
{
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
NR_SRB_ToAddMod_t *SRB2_config = NULL;
NR_SRB_ToAddModList_t *SRB_configList = ue_p->SRB_configList;
NR_SRB_ToAddModList_t **SRB_configList2 = NULL;
SRB_configList2 = &ue_p->SRB_configList2[old_xid];
// get old configuration of SRB2
if (*SRB_configList2 != NULL) {
if ((*SRB_configList2)->list.count != 0) {
LOG_D(NR_RRC,
"RRC Reestablishment - SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p\n",
SRB_configList2,
(*SRB_configList2)->list.count,
(*SRB_configList2)->list.array[0]);
}
for (int i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) {
if ((*SRB_configList2)->list.array[i]->srb_Identity == 2) {
LOG_D(NR_RRC, "RRC Reestablishment - get SRB2_config from (ue_p->SRB_configList2[%d])\n", old_xid);
SRB2_config = (*SRB_configList2)->list.array[i];
SRB2_config->reestablishPDCP = CALLOC(1, sizeof(*SRB2_config->reestablishPDCP));
*SRB2_config->reestablishPDCP = NR_SRB_ToAddMod__reestablishPDCP_true;
break;
}
}
}
SRB_configList2 = &(ue_p->SRB_configList2[new_xid]);
if (*SRB_configList2) {
free(*SRB_configList2);
LOG_D(NR_RRC, "RRC Reestablishment - free(ue_p->SRB_configList2[%d])\n", new_xid);
}
*SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2));
if (SRB2_config != NULL) {
// Add SRB2 to SRB configuration list
asn1cSeqAdd(&SRB_configList->list, SRB2_config);
asn1cSeqAdd(&(*SRB_configList2)->list, SRB2_config);
LOG_D(NR_RRC, "RRC Reestablishment - Add SRB2_config (srb_Identity:%ld) to ue_p->SRB_configList\n", SRB2_config->srb_Identity);
LOG_D(NR_RRC,
"RRC Reestablishment - Add SRB2_config (srb_Identity:%ld) to ue_p->SRB_configList2[%d]\n",
SRB2_config->srb_Identity,
new_xid);
} else {
// SRB configuration list only contains SRB1.
LOG_W(NR_RRC, "RRC Reestablishment - SRB2 configuration does not exist in SRB configuration list\n");
}
ue_p->Srb[1].Active = 1;
if (get_softmodem_params()->sa) {
uint8_t send_security_mode_command = false;
nr_rrc_pdcp_config_security(ctxt_pP, ue_context_pP, send_security_mode_command);
LOG_D(NR_RRC, "RRC Reestablishment - set security successfully \n");
}
}
/// @brief Function used in RRCReestablishmentComplete procedure to reestablish the DRBs /// @brief Function used in RRCReestablishmentComplete procedure to reestablish the DRBs
/// that the UE previously had, it gets the information from the established_drbs /// that the UE previously had, it gets the information from the established_drbs
/// struct. /// struct.
...@@ -1413,7 +1342,13 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx ...@@ -1413,7 +1342,13 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
uint8_t new_xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); uint8_t new_xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id);
ue_p->xids[new_xid] = RRC_REESTABLISH_COMPLETE; ue_p->xids[new_xid] = RRC_REESTABLISH_COMPLETE;
ue_p->StatusRrc = NR_RRC_CONNECTED; ue_p->StatusRrc = NR_RRC_CONNECTED;
RRCReestablishmentComplete_fill_SRB2_configList(ctxt_pP, ue_context_pP, xid, new_xid);
ue_p->Srb[1].Active = 1;
if (get_softmodem_params()->sa) {
uint8_t send_security_mode_command = false;
nr_rrc_pdcp_config_security(ctxt_pP, ue_context_pP, send_security_mode_command);
LOG_D(NR_RRC, "RRC Reestablishment - set security successfully \n");
}
RRCReestablishmentComplete_fill_DRB_configList(ctxt_pP, ue_context_pP, new_xid); RRCReestablishmentComplete_fill_DRB_configList(ctxt_pP, ue_context_pP, new_xid);
RRCReestablishmentComplete_update_ngu_tunnel(ctxt_pP, ue_context_pP, reestablish_rnti); RRCReestablishmentComplete_update_ngu_tunnel(ctxt_pP, ue_context_pP, reestablish_rnti);
RRCReestablishmentComplete_nas_pdu_update(ue_context_pP, xid); RRCReestablishmentComplete_nas_pdu_update(ue_context_pP, xid);
...@@ -1448,11 +1383,12 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx ...@@ -1448,11 +1383,12 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
} }
uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t buffer[RRC_BUF_SIZE] = {0};
NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, true);
int size = do_RRCReconfiguration(ctxt_pP, int size = do_RRCReconfiguration(ctxt_pP,
buffer, buffer,
RRC_BUF_SIZE, RRC_BUF_SIZE,
new_xid, new_xid,
ue_p->SRB_configList2[new_xid], SRBs,
ue_p->DRB_configList2[new_xid], ue_p->DRB_configList2[new_xid],
NULL, NULL,
NULL, NULL,
...@@ -1464,6 +1400,7 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx ...@@ -1464,6 +1400,7 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
NULL, NULL,
NULL, NULL,
cellGroupConfig); cellGroupConfig);
freeSRBlist(SRBs);
LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Reconfiguration\n"); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Reconfiguration\n");
...@@ -1665,7 +1602,7 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint ...@@ -1665,7 +1602,7 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
UE = &ue_context_p->ue_context; UE = &ue_context_p->ue_context;
UE->establishment_cause = rrcSetupRequest->establishmentCause; UE->establishment_cause = rrcSetupRequest->establishmentCause;
UE->Srb[1].Active = 1;
rrc_gNB_generate_RRCSetup(module_id, rrc_gNB_generate_RRCSetup(module_id,
rnti, rnti,
rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti), rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti),
...@@ -2651,10 +2588,14 @@ void prepare_and_send_ue_context_modification_f1(rrc_gNB_ue_context_t *ue_contex ...@@ -2651,10 +2588,14 @@ void prepare_and_send_ue_context_modification_f1(rrc_gNB_ue_context_t *ue_contex
} }
/* Instruction towards the DU for SRB2 configuration */ /* Instruction towards the DU for SRB2 configuration */
int nb_srb = 1; int nb_srb = 0;
f1ap_srb_to_be_setup_t srbs[nb_srb]; f1ap_srb_to_be_setup_t srbs[1];
srbs[0].srb_id = 2; if (UE->Srb[2].Active == 0) {
srbs[0].lcid = 2; UE->Srb[2].Active = 1;
nb_srb = 1;
srbs[0].srb_id = 2;
srbs[0].lcid = 2;
}
f1ap_ue_context_modif_req_t ue_context_modif_req = { f1ap_ue_context_modif_req_t ue_context_modif_req = {
.gNB_CU_ue_id = 0xffffffff, /* filled by F1 for the moment */ .gNB_CU_ue_id = 0xffffffff, /* filled by F1 for the moment */
......
...@@ -128,8 +128,6 @@ nr_rrc_pdcp_config_security( ...@@ -128,8 +128,6 @@ nr_rrc_pdcp_config_security(
) )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList;
(void)SRB_configList;
uint8_t kRRCenc[16] = {0}; uint8_t kRRCenc[16] = {0};
uint8_t kRRCint[16] = {0}; uint8_t kRRCint[16] = {0};
uint8_t kUPenc[16] = {0}; uint8_t kUPenc[16] = {0};
...@@ -783,7 +781,7 @@ void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t ins ...@@ -783,7 +781,7 @@ void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t ins
for (int j=0; j < pdu->numDRB2Setup; j++) { for (int j=0; j < pdu->numDRB2Setup; j++) {
DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + j; DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + j;
drb->id = i + j + 1; drb->id = i + j + UE->nb_of_pdusessions;
drb->defaultDRB = E1AP_DefaultDRB_true; drb->defaultDRB = E1AP_DefaultDRB_true;
......
...@@ -1653,8 +1653,7 @@ nr_rrc_ue_establish_srb1( ...@@ -1653,8 +1653,7 @@ nr_rrc_ue_establish_srb1(
{ {
// add descriptor from RRC PDU // add descriptor from RRC PDU
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1; NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1;
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].status = RADIO_CONFIG_OK; // RADIO CFG
NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1;
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index); LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index);
return(0); return(0);
} }
...@@ -1671,8 +1670,7 @@ nr_rrc_ue_establish_srb2( ...@@ -1671,8 +1670,7 @@ nr_rrc_ue_establish_srb2(
{ {
// add descriptor from RRC PDU // add descriptor from RRC PDU
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1; NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1;
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].status = RADIO_CONFIG_OK; // RADIO CFG
NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2;
LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index); LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index);
return(0); return(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