Commit 53348bd4 authored by francescomani's avatar francescomani

improving DRB management at RRC UE

parent b0b57402
......@@ -73,13 +73,10 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = &rlc_rbconfig, .count = 1, .size = 1, }
};
// set up PDCP, RLC, MAC
nr_pdcp_layer_init();
nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL);
nr_rlc_add_drb(nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
nr_ue_mac_inst->logicalChannelBearer_exist[4] = true;
......
......@@ -271,10 +271,6 @@ void mac_top_init_gNB(ngran_node_t node_type)
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
NR_RLC_BearerConfig_t *rlc_rbconfig_list[1] = {rlc_rbconfig};
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = rlc_rbconfig_list, .count = 1, .size = 1, }
};
/* Note! previously, in nr_DRB_preconfiguration(), we passed ENB_FLAG_NO
* if ENB_NAS_USE_TUN was *not* set. It seems to me that we could not set
......@@ -284,7 +280,7 @@ void mac_top_init_gNB(ngran_node_t node_type)
* will output the packets at a local interface, which is in line with
* the noS1 mode. Hence, below, we simply hardcode ENB_FLAG_NO */
// setup PDCP, RLC
nr_pdcp_add_drbs(ENB_FLAG_NO, 0x1234, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_pdcp_add_drbs(ENB_FLAG_NO, 0x1234, rbconfig->drb_ToAddModList, 0, NULL, NULL);
nr_rlc_add_drb(0x1234, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
// free memory
......
......@@ -32,8 +32,8 @@ void e1_add_drb(int is_gnb,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
add_drb_am(is_gnb, ue_id, s, ciphering_algorithm, integrity_algorithm,
ciphering_key, integrity_key);
add_drb(is_gnb, ue_id, s, ciphering_algorithm, integrity_algorithm,
ciphering_key, integrity_key);
LOG_I(PDCP, "%s:%s:%d: added DRB for UE ID %ld\n", __FILE__, __FUNCTION__, __LINE__, ue_id);
}
......
......@@ -794,7 +794,12 @@ void add_srb(int is_gnb,
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void add_drb_am(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, unsigned char *ciphering_key, unsigned char *integrity_key)
void add_drb(int is_gnb, ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
nr_pdcp_entity_t *pdcp_drb;
nr_pdcp_ue_t *ue;
......@@ -888,32 +893,6 @@ void add_drb_am(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, in
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
static void add_drb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
NR_RLC_Config_t *rlc_Config,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
switch (rlc_Config->present) {
case NR_RLC_Config_PR_am:
add_drb_am(is_gnb, rntiMaybeUEid, s, ciphering_algorithm, integrity_algorithm, ciphering_key, integrity_key);
break;
case NR_RLC_Config_PR_um_Bi_Directional:
// add_drb_um(rntiMaybeUEid, s);
/* hack */
add_drb_am(is_gnb, rntiMaybeUEid, s, ciphering_algorithm, integrity_algorithm, ciphering_key, integrity_key);
break;
default:
LOG_E(PDCP, "%s:%d:%s: fatal: unhandled DRB type\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_I(PDCP, "%s:%s:%d: added DRB for UE ID/RNTI %ld\n", __FILE__, __FUNCTION__, __LINE__, rntiMaybeUEid);
}
void nr_pdcp_add_srbs(eNB_flag_t enb_flag, ue_id_t rntiMaybeUEid, NR_SRB_ToAddModList_t *const srb2add_list, const uint8_t security_modeP, uint8_t *const kRRCenc, uint8_t *const kRRCint)
{
if (srb2add_list != NULL) {
......@@ -929,12 +908,11 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list)
uint8_t *const kUPint)
{
if (drb2add_list != NULL) {
for (int i = 0; i < drb2add_list->list.count; i++) {
add_drb(enb_flag, rntiMaybeUEid, drb2add_list->list.array[i], rlc_bearer2add_list->list.array[i]->rlc_Config, security_modeP & 0x0f, (security_modeP >> 4) & 0x0f, kUPenc, kUPint);
add_drb(enb_flag, rntiMaybeUEid, drb2add_list->list.array[i], security_modeP & 0x0f, (security_modeP >> 4) & 0x0f, kUPenc, kUPint);
}
} else
LOG_W(PDCP, "nr_pdcp_add_drbs() with void list\n");
......@@ -1077,7 +1055,22 @@ void nr_pdcp_reconfigure_srb(ue_id_t ue_id,
int decoded_t_reordering = decode_t_reordering(t_Reordering);
srb->t_reordering = decoded_t_reordering;
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
}
void nr_pdcp_reconfigure_drb(ue_id_t ue_id,
int drb_id,
long t_Reordering)
{
// The enabling/disabling of ciphering or integrity protection
// can be changed only by releasing and adding the DRB
// (so not by reconfiguring).
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
nr_pdcp_entity_t *drb = ue->drb[drb_id - 1];
int decoded_t_reordering = decode_t_reordering(t_Reordering);
drb->t_reordering = decoded_t_reordering;
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_pdcp_reestablishment(ue_id_t ue_id)
{
......
......@@ -51,8 +51,14 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
uint8_t *const kUPint);
void add_drb(int is_gnb, ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key);
void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid);
......@@ -62,6 +68,9 @@ void nr_pdcp_reestablishment(ue_id_t ue_id);
void nr_pdcp_reconfigure_srb(ue_id_t ue_id,
int srb_id,
long t_Reordering);
void nr_pdcp_reconfigure_drb(ue_id_t ue_id,
int drb_id,
long t_Reordering);
void add_srb(int is_gnb,
ue_id_t rntiMaybeUEid,
......
......@@ -154,8 +154,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
DRB_configList,
(UE->integrity_algorithm << 4) | UE->ciphering_algorithm,
kUPenc,
kUPint,
get_softmodem_params()->sa ? UE->masterCellGroup->rlc_BearerToAddModList : NULL);
kUPint);
return ret;
}
......
......@@ -166,8 +166,7 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
uint8_t *const kUPint);
int rrc_gNB_generate_pcch_msg(uint32_t tmsi, uint8_t paging_drx, instance_t instance, uint8_t CC_id);
......
......@@ -969,8 +969,7 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co
DRB_configList,
(ue_p->integrity_algorithm << 4) | ue_p->ciphering_algorithm,
kUPenc,
kUPint,
get_softmodem_params()->sa ? ue_p->masterCellGroup->rlc_BearerToAddModList : NULL);
kUPint);
/* Loop through DRBs and establish if necessary */
if (DRB_configList != NULL) {
......
......@@ -385,8 +385,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
ue_context_p->ue_context.rb_config->drb_ToAddModList,
(ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm,
kUPenc,
kUPint,
ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList);
kUPint);
ctxt.rntiMaybeUEid = du_ue_id;
// assume only a single bearer
......
......@@ -97,13 +97,6 @@ nr_rrc_ue_process_ueCapabilityEnquiry(
uint8_t gNB_index
);
void
nr_rrc_ue_process_RadioBearerConfig(
const protocol_ctxt_t *const ctxt_pP,
const uint8_t gNB_index,
NR_RadioBearerConfig_t *const radioBearerConfig
);
uint8_t do_NR_RRCReconfigurationComplete(
const protocol_ctxt_t *const ctxt_pP,
uint8_t *buffer,
......@@ -309,6 +302,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* reconfig_fi
memset((void *)&rrc->SInfo[i], 0, sizeof(rrc->SInfo[i]));
for (int j = 0; j < NR_NUM_SRB; j++)
memset((void *)&rrc->Srb[i][j], 0, sizeof(rrc->Srb[i][j]));
for (int j = 0; j < MAX_DRBS_PER_UE; j++)
rrc->active_DRBs[i][j] = false;
// SRB0 activated by default
rrc->Srb[i][0].status = RB_ESTABLISHED;
}
......@@ -1539,77 +1534,39 @@ void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP,
}
}
if (radioBearerConfig->drb_ToReleaseList != NULL) {
// TODO not implemented yet
}
// Establish DRBs if present
if (radioBearerConfig->drb_ToAddModList != NULL) {
if ((NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB == NULL) &&
(radioBearerConfig->drb_ToAddModList->list.count >= 1)) {
NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB = malloc(sizeof(rb_id_t));
*NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB = radioBearerConfig->drb_ToAddModList->list.array[0]->drb_Identity;
}
for (int cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) {
int DRB_id = radioBearerConfig->drb_ToAddModList->list.array[cnt]->drb_Identity;
if (NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1]) {
memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1],
radioBearerConfig->drb_ToAddModList->list.array[cnt], sizeof(NR_DRB_ToAddMod_t));
} else {
//LOG_D(NR_RRC, "Adding DRB %ld %p\n", DRB_id-1, radioBearerConfig->drb_ToAddModList->list.array[cnt]);
NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1] = radioBearerConfig->drb_ToAddModList->list.array[cnt];
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list = NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList;
if (rlc_bearer2add_list != NULL) {
for(int j = 0; j < rlc_bearer2add_list->list.count; j++){
if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){
if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity){
if(DRB_id == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.drb_Identity){
LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB lcid %ld gNB %d) --->][MAC_UE][MOD %02d][]\n",
ctxt_pP->frame, ctxt_pP->module_id, rlc_bearer2add_list->list.array[j]->logicalChannelIdentity, 0, ctxt_pP->module_id);
nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,0,rlc_bearer2add_list->list.array[j]->logicalChannelIdentity,true); //todo handle mac_LogicalChannelConfig
}
}
}
}
}
struct NR_DRB_ToAddMod *drb = radioBearerConfig->drb_ToAddModList->list.array[cnt];
int DRB_id = drb->drb_Identity;
if (ue_rrc->active_DRBs[gNB_index][DRB_id]) {
AssertFatal(drb->reestablishPDCP, "reestablishPDCP not yet implemented\n");
AssertFatal(drb->recoverPDCP, "recoverPDCP not yet implemented\n");
if(drb->pdcp_Config && drb->pdcp_Config->t_Reordering)
nr_pdcp_reconfigure_drb(ctxt_pP->rntiMaybeUEid,
DRB_id,
*drb->pdcp_Config->t_Reordering);
if(drb->cnAssociation)
AssertFatal(drb->cnAssociation->choice.sdap_Config, "SDAP reconfiguration not yet implemented\n");
}
else {
ue_rrc->active_DRBs[gNB_index][DRB_id] = true;
add_drb(ctxt_pP->enb_flag,
ctxt_pP->rntiMaybeUEid,
radioBearerConfig->drb_ToAddModList->list.array[cnt],
ue_rrc->cipheringAlgorithm,
ue_rrc->integrityProtAlgorithm,
kRRCenc,
kRRCint);
}
}
uint8_t kUPenc[16] = {0};
uint8_t kUPint[16] = {0};
nr_derive_key(UP_ENC_ALG,
NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm,
NR_UE_rrc_inst[ctxt_pP->module_id].kgnb,
kUPenc);
nr_derive_key(UP_INT_ALG,
NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm,
NR_UE_rrc_inst[ctxt_pP->module_id].kgnb,
kUPint);
// Refresh DRBs
nr_pdcp_add_drbs(ctxt_pP->enb_flag,
ctxt_pP->rntiMaybeUEid,
radioBearerConfig->drb_ToAddModList,
ue_rrc->cipheringAlgorithm | (ue_rrc->integrityProtAlgorithm << 4),
kUPenc,
kUPint,
ue_rrc->cell_group_config->rlc_BearerToAddModList);
} // drb_ToAddModList //
if (radioBearerConfig->drb_ToReleaseList != NULL) {
for (int i = 0; i < radioBearerConfig->drb_ToReleaseList->list.count; i++) {
int DRB_id = *radioBearerConfig->drb_ToReleaseList->list.array[i];
free(NR_UE_rrc_inst[ctxt_pP->module_id].DRB_config[gNB_index][DRB_id-1]);
}
}
if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList != NULL) {
for (int i = 0; i < NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList->list.count; i++) {
NR_LogicalChannelIdentity_t lcid = *NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToReleaseList->list.array[i];
LOG_I(NR_RRC, "[FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (RB lcid %ld gNB %d release) --->][MAC_UE][MOD %02d][]\n",
ctxt_pP->frame, ctxt_pP->module_id, lcid, 0, ctxt_pP->module_id);
nr_rrc_mac_config_req_ue_logicalChannelBearer(ctxt_pP->module_id,0,0,lcid,false); //todo handle mac_LogicalChannelConfig
}
}
NR_UE_rrc_inst[ctxt_pP->module_id].nrRrcState = RRC_STATE_CONNECTED_NR;
LOG_I(NR_RRC,"[UE %d] State = NR_RRC_CONNECTED (gNB %d)\n", ctxt_pP->module_id, gNB_index);
}
......
......@@ -39,6 +39,7 @@
#include "platform_types.h"
#include "commonDef.h"
#include "common/platform_constants.h"
#include "NR_asn_constant.h"
#include "NR_MeasConfig.h"
......@@ -202,13 +203,11 @@ typedef struct NR_UE_RRC_INST_s {
NR_MeasGapConfig_t *measGapConfig[NB_CNX_UE];
NR_RSRP_Range_t s_measure;
NR_DRB_ToAddMod_t *DRB_config[NB_CNX_UE][8];
rb_id_t *defaultDRB; // remember the ID of the default DRB
char *uecap_file;
rnti_t rnti;
NR_UE_RRC_SRB_INFO_t Srb[NB_CNX_UE][NR_NUM_SRB];
bool active_DRBs [NB_CNX_UE][MAX_DRBS_PER_UE];
bool active_RLC_entity [NB_CNX_UE][NR_MAX_NUM_LCID];
OAI_NR_UECapability_t *UECap;
......
......@@ -73,9 +73,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR
\param meas_config measurement configuration*/
int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config);
/**\prief Process radio bearer config from NR RRC connection reconfiguration message
\param radio_bearer_config radio bearer configuration*/
int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_bearer_config);
void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP,
const uint8_t gNB_index,
NR_RadioBearerConfig_t *const radioBearerConfig);
/**\brief decode NR BCCH-BCH (MIB) message
\param module_idP module id
......
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