Commit 231c2f3c authored by Cedric Roux's avatar Cedric Roux

gnb: remove srb0 shared global variable - use RLC module instead

parent 8773e423
......@@ -41,6 +41,9 @@
#include "UTIL/OPT/opt.h"
#include "SIMULATION/TOOLS/sim.h" // for taus
/* rlc */
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include <executables/softmodem-common.h>
extern RAN_CONTEXT_t RC;
extern const uint8_t nr_slots_per_frame[5];
......@@ -1418,9 +1421,19 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
int current_harq_pid = sched_ctrl->retrans_dl_harq.head;
if (ra->msg3_dcch_dtch == false && current_harq_pid < 0) {
mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, NULL);
if (mac_sdu_length <= 0)
return; // need to wait until RRCSetup is encoded
/* need to wait until RRCSetup is ready */
mac_rlc_status_resp_t srb0_status = mac_rlc_status_ind(module_idP,
ra->rnti,
module_idP,
frameP,
slotP,
ENB_FLAG_YES,
MBMS_FLAG_NO,
0 /* lcid 0 */,
0,
0);
if (srb0_status.bytes_in_buffer == 0) return;
mac_sdu_length = srb0_status.bytes_in_buffer;
}
long BWPStart = 0;
......@@ -1559,7 +1572,17 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length);
uint8_t buffer[CCCH_SDU_SIZE];
uint8_t mac_subheader_len = sizeof(NR_MAC_SUBHEADER_SHORT);
uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, buffer);
mac_sdu_length = mac_rlc_data_req(module_idP,
ra->rnti,
module_idP,
frameP,
ENB_FLAG_YES,
MBMS_FLAG_NO,
CCCH,
CCCH_SDU_SIZE,
(char *)buffer,
0,
0);
if (mac_sdu_length < 256) {
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->R = 0;
((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->F = 0;
......
......@@ -44,6 +44,8 @@
#include "OCG.h"
#include "OCG_extern.h"
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */
#include "RRC/LTE/rrc_extern.h"
#include "RRC/NR/nr_rrc_extern.h"
......@@ -2700,28 +2702,30 @@ void reset_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl) {
void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti)
{
NR_UEs_t *UE_info = &nr_mac->UE_info;
pthread_mutex_lock(&UE_info->mutex);
UE_iterator(UE_info->list, UE) {
if (UE->rnti==rnti)
break;
}
if (!UE) {
LOG_W(NR_MAC,"Call to del rnti %04x, but not existing\n", rnti);
pthread_mutex_unlock(&UE_info->mutex);
return;
}
NR_UE_info_t * newUEs[MAX_MOBILES_PER_GNB+1]={0};
int newListIdx=0;
for (int i=0; i<MAX_MOBILES_PER_GNB; i++)
if(UE_info->list[i] && UE_info->list[i]->rnti != rnti)
newUEs[newListIdx++]=UE_info->list[i];
memcpy(UE_info->list, newUEs, sizeof(UE_info->list));
pthread_mutex_unlock(&UE_info->mutex);
delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator);
nr_rlc_remove_ue(rnti);
NR_UEs_t *UE_info = &nr_mac->UE_info;
pthread_mutex_lock(&UE_info->mutex);
UE_iterator(UE_info->list, UE) {
if (UE->rnti==rnti)
break;
}
if (!UE) {
LOG_W(NR_MAC,"Call to del rnti %04x, but not existing\n", rnti);
pthread_mutex_unlock(&UE_info->mutex);
return;
}
NR_UE_info_t * newUEs[MAX_MOBILES_PER_GNB+1]={0};
int newListIdx=0;
for (int i=0; i<MAX_MOBILES_PER_GNB; i++)
if(UE_info->list[i] && UE_info->list[i]->rnti != rnti)
newUEs[newListIdx++]=UE_info->list[i];
memcpy(UE_info->list, newUEs, sizeof(UE_info->list));
pthread_mutex_unlock(&UE_info->mutex);
delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator);
}
void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti) {
......@@ -3097,15 +3101,14 @@ void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCom
void send_initial_ul_rrc_message(module_id_t module_id,
int CC_id,
const NR_UE_info_t *UE,
rb_id_t srb_id,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len) {
const gNB_MAC_INST *mac = RC.nrmac[module_id];
const rnti_t rnti = UE->rnti;
LOG_W(MAC,
"[RAPROC] Received SDU for CCCH on SRB %ld length %d for UE %04x\n",
srb_id, sdu_len, rnti);
"[RAPROC] Received SDU for CCCH length %d for UE %04x\n",
sdu_len, rnti);
/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */
if (NODE_IS_DU(RC.nrrrc[module_id]->node_type)) {
......@@ -3113,14 +3116,13 @@ void send_initial_ul_rrc_message(module_id_t module_id,
ue_context_p->ue_id_rnti = rnti;
ue_context_p->ue_context.rnti = rnti;
ue_context_p->ue_context.random_ue_identity = rnti;
ue_context_p->ue_context.Srb0.Active = 1;
RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_id]->rrc_ue_head, ue_context_p);
}
const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd;
NR_CellGroupConfig_t cellGroupConfig = {0};
fill_initial_cellGroupConfig(UE->uid, &cellGroupConfig, scc, sccd, &RC.nrrrc[module_id]->configuration);
fill_initial_cellGroupConfig(uid, &cellGroupConfig, scc, sccd, &RC.nrrrc[module_id]->configuration);
uint8_t du2cu_rrc_container[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
......
......@@ -35,6 +35,7 @@
#include "utils.h"
#include <openair2/UTIL/OPT/opt.h>
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
//#define SRS_IND_DEBUG
......@@ -363,12 +364,19 @@ int nr_process_mac_pdu(instance_t module_idP,
mac_len = 6;
}
send_initial_ul_rrc_message(module_idP,
CC_id,
UE,
CCCH,
pduP + mac_subheader_len,
mac_len);
nr_rlc_activate_srb0(UE->rnti, module_idP, CC_id, UE->uid, send_initial_ul_rrc_message);
mac_rlc_data_ind(module_idP,
UE->rnti,
module_idP,
frameP,
ENB_FLAG_YES,
MBMS_FLAG_NO,
0,
(char *) (pduP + mac_subheader_len),
mac_len,
1,
NULL);
break;
case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28):
......
......@@ -510,8 +510,8 @@ void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sche
void send_initial_ul_rrc_message(module_id_t module_id,
int CC_id,
const NR_UE_info_t *UE,
rb_id_t srb_id,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len);
......
......@@ -23,6 +23,7 @@
#include "mac_proto.h"
#include "openair2/RRC/NR/rrc_gNB_UE_context.h"
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "NR_RRCSetup.h"
#include "NR_DL-CCCH-Message.h"
......@@ -111,13 +112,10 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *
gNB_RRC_INST *rrc = RC.nrrrc[module_id];
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(rrc, dl_rrc->rnti);
gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
ue_context_p->ue_context.masterCellGroup = cellGroup;
ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
ue_p->masterCellGroup = cellGroup;
/* TODO: this should pass through RLC and NOT the RRC with a shared buffer */
AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n");
memcpy(ue_p->Srb0.Tx_buffer.Payload, dl_rrc->rrc_container, dl_rrc->rrc_container_length);
ue_p->Srb0.Tx_buffer.payload_size = dl_rrc->rrc_container_length;
nr_rlc_srb0_recv_sdu(dl_rrc->rnti, dl_rrc->rrc_container, dl_rrc->rrc_container_length);
protocol_ctxt_t ctxt = { .module_id = module_id, .rnti = dl_rrc->rnti };
nr_rrc_rlc_config_asn1_req(&ctxt,
......
......@@ -164,9 +164,10 @@ void mac_rlc_data_ind (
LOG_I(RLC, "RLC instance for the given UE was not found \n");
switch (channel_idP) {
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 0: rb = ue->srb0; break;
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 4 ... 32: rb = ue->drb[channel_idP - 4]; break;
default: rb = NULL; break;
default: rb = NULL; break;
}
if (rb != NULL) {
......@@ -205,7 +206,8 @@ tbs_size_t mac_rlc_data_req(
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rntiP);
switch (channel_idP) {
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 0: rb = ue->srb0; break;
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 4 ... 32: rb = ue->drb[channel_idP - 4]; break;
default:
rb = NULL;
......@@ -253,9 +255,10 @@ mac_rlc_status_resp_t mac_rlc_status_ind(
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rntiP);
switch (channel_idP) {
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 0: rb = ue->srb0; break;
case 1 ... 3: rb = ue->srb[channel_idP - 1]; break;
case 4 ... NGAP_MAX_DRBS_PER_UE: rb = ue->drb[channel_idP - 4]; break;
default: rb = NULL; break;
default: rb = NULL; break;
}
if (rb != NULL) {
......@@ -271,7 +274,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind(
+ buf_stat.retx_size
+ buf_stat.tx_size;
} else {
if (!(frameP%128)) //to suppress this warning message
if (!(frameP%128) || channel_idP == 0) //to suppress this warning message
LOG_W(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rntiP %x\n", __FUNCTION__, channel_idP, rntiP);
ret.bytes_in_buffer = 0;
}
......@@ -1017,6 +1020,66 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt
return RLC_OP_STATUS_OK;
}
struct srb0_data {
int module_id;
int CC_id;
int rnti;
int uid;
void (*send_initial_ul_rrc_message)(module_id_t module_id,
int CC_id,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len);
};
void deliver_sdu_srb0(void *deliver_sdu_data, struct nr_rlc_entity_t *entity,
char *buf, int size)
{
struct srb0_data *s0 = (struct srb0_data *)deliver_sdu_data;
s0->send_initial_ul_rrc_message(s0->module_id, s0->CC_id, s0->rnti, s0->uid,
(unsigned char *)buf, size);
}
void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid,
void (*send_initial_ul_rrc_message)(
module_id_t module_id,
int CC_id,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len))
{
nr_rlc_entity_t *nr_rlc_tm;
nr_rlc_ue_t *ue;
struct srb0_data *srb0_data;
srb0_data = calloc(1, sizeof(struct srb0_data));
AssertFatal(srb0_data != NULL, "out of memory\n");
srb0_data->module_id = module_id;
srb0_data->CC_id = cc_id;
srb0_data->rnti = rnti;
srb0_data->uid = uid;
srb0_data->send_initial_ul_rrc_message = send_initial_ul_rrc_message;
nr_rlc_manager_lock(nr_rlc_ue_manager);
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (ue->srb0 != NULL) {
LOG_W(RLC, "SRB0 already exists for UE with RNTI 0x%x, do nothing\n", rnti);
free(srb0_data);
nr_rlc_manager_unlock(nr_rlc_ue_manager);
return;
}
nr_rlc_tm = new_nr_rlc_entity_tm(10000,
deliver_sdu_srb0, srb0_data);
nr_rlc_ue_add_srb_rlc_entity(ue, 0, nr_rlc_tm);
LOG_I(RLC, "activated srb0 for UE with RNTI 0x%x\n", rnti);
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
rlc_op_status_t rrc_rlc_config_req (
const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP,
......@@ -1081,13 +1144,17 @@ void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t r
/* nothing to do */
}
rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x)
void nr_rlc_remove_ue(int rnti)
{
LOG_D(RLC, "%s:%d:%s: remove UE %d\n", __FILE__, __LINE__, __FUNCTION__, x->rnti);
LOG_W(RLC, "remove UE %x\n", rnti);
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_manager_remove_ue(nr_rlc_ue_manager, x->rnti);
nr_rlc_manager_remove_ue(nr_rlc_ue_manager, rnti);
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x)
{
nr_rlc_remove_ue(x->rnti);
return RLC_OP_STATUS_OK;
}
......@@ -1173,3 +1240,25 @@ const bool nr_rlc_get_statistics(
return ret;
}
void nr_rlc_srb0_recv_sdu(int rnti, unsigned char *buf, int size)
{
nr_rlc_ue_t *ue;
nr_rlc_entity_t *rb;
T(T_ENB_RLC_DL, T_INT(0), T_INT(rnti), T_INT(0), T_INT(size));
nr_rlc_manager_lock(nr_rlc_ue_manager);
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
rb = ue->srb0;
if (rb != NULL) {
rb->set_time(rb, nr_rlc_current_time);
rb->recv_sdu(rb, (char *)buf, size, -1);
} else {
LOG_E(RLC, "SDU sent to unknown RB rnti %d srb0\n", rnti);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
......@@ -48,6 +48,8 @@ void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config
void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig);
void nr_rlc_remove_ue(int rnti);
int nr_rlc_get_available_tx_space(
const rnti_t rntiP,
const logical_chan_id_t channel_idP);
......@@ -56,3 +58,14 @@ void nr_rlc_activate_avg_time_to_tx(
const rnti_t rnti,
const logical_chan_id_t channel_id,
const bool is_on);
void nr_rlc_srb0_recv_sdu(int rnti, unsigned char *buf, int size);
void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid,
void (*send_initial_ul_rrc_message)(
module_id_t module_id,
int CC_id,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len));
......@@ -117,7 +117,7 @@ void nr_rlc_manager_remove_ue(nr_rlc_ue_manager_t *_m, int rnti)
break;
if (i == m->ue_count) {
LOG_W(RLC, "%s:%d:%s: warning: ue %d not found\n",
LOG_W(RLC, "%s:%d:%s: warning: ue %x not found\n",
__FILE__, __LINE__, __FUNCTION__,
rnti);
return;
......@@ -125,11 +125,17 @@ void nr_rlc_manager_remove_ue(nr_rlc_ue_manager_t *_m, int rnti)
ue = m->ue_list[i];
for (j = 0; j < 2; j++)
if (ue->srb0 != NULL) {
/* deliver_sdu_data for srb0 is allocated, needs a free() */
free(ue->srb0->deliver_sdu_data);
ue->srb0->delete(ue->srb0);
}
for (j = 0; j < 3; j++)
if (ue->srb[j] != NULL)
ue->srb[j]->delete(ue->srb[j]);
for (j = 0; j < 5; j++)
for (j = 0; j < MAX_DRBS_PER_UE; j++)
if (ue->drb[j] != NULL)
ue->drb[j]->delete(ue->drb[j]);
......@@ -154,11 +160,23 @@ void nr_rlc_manager_remove_ue(nr_rlc_ue_manager_t *_m, int rnti)
/* must be called with lock acquired */
void nr_rlc_ue_add_srb_rlc_entity(nr_rlc_ue_t *ue, int srb_id, nr_rlc_entity_t *entity)
{
if (srb_id < 1 || srb_id > 2) {
if (srb_id < 0 || srb_id > 3) {
LOG_E(RLC, "%s:%d:%s: fatal, bad srb id\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
/* special case: srb0 */
if (srb_id == 0) {
if (ue->srb0 != NULL) {
LOG_E(RLC, "fatal, srb0 already present\n");
exit(1);
}
ue->srb0 = entity;
return;
}
srb_id--;
if (ue->srb[srb_id] != NULL) {
......@@ -173,7 +191,7 @@ void nr_rlc_ue_add_srb_rlc_entity(nr_rlc_ue_t *ue, int srb_id, nr_rlc_entity_t *
/* must be called with lock acquired */
void nr_rlc_ue_add_drb_rlc_entity(nr_rlc_ue_t *ue, int drb_id, nr_rlc_entity_t *entity)
{
if (drb_id < 1 || drb_id > 5) {
if (drb_id < 1 || drb_id > MAX_DRBS_PER_UE) {
LOG_E(RLC, "%s:%d:%s: fatal, bad drb id\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
......
......@@ -28,6 +28,7 @@ typedef void nr_rlc_ue_manager_t;
typedef struct nr_rlc_ue_t {
int rnti;
nr_rlc_entity_t *srb0;
nr_rlc_entity_t *srb[3];
nr_rlc_entity_t *drb[MAX_DRBS_PER_UE];
} nr_rlc_ue_t;
......
......@@ -161,29 +161,7 @@ uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
// CCCH
if ((Srb_id & RAB_OFFSET) == CCCH) {
LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id);
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_idP], rnti);
LOG_D(NR_RRC,"[gNB %d] Frame %d CCCH request (Srb_id %ld)\n", Mod_idP, frameP, Srb_id);
if (ue_context_p == NULL) {
if(buffer_pP != NULL)
LOG_E(NR_RRC,"[gNB %d] Frame %d CCCH request but no ue_context\n", Mod_idP, frameP);
return 0;
}
uint16_t payload_size = ue_context_p->ue_context.Srb0.Tx_buffer.payload_size;
if (buffer_pP == NULL)
return payload_size;
// check if data is there for MAC
if (payload_size > 0) {
char *payload_pP = ue_context_p->ue_context.Srb0.Tx_buffer.Payload;
LOG_D(NR_RRC,"[gNB %d] CCCH has %d bytes (dest: %p, src %p)\n", Mod_idP, payload_size, buffer_pP, payload_pP);
// Fill buffer
memcpy((void *)buffer_pP, (void*)payload_pP, payload_size);
ue_context_p->ue_context.Srb0.Tx_buffer.payload_size = 0;
}
return payload_size;
AssertFatal(0, "CCCH is managed by rlc of srb 0, not anymore by mac_rrc_nr_data_req\n");
}
return 0;
......
......@@ -286,7 +286,6 @@ typedef struct gNB_RRC_UE_s {
uint8_t DRB_active[NGAP_MAX_DRBS_PER_UE];
NR_SRB_INFO SI;
NR_SRB_INFO Srb0;
NR_SRB_INFO_TABLE_ENTRY Srb1;
NR_SRB_INFO_TABLE_ENTRY Srb2;
NR_MeasConfig_t *measConfig;
......@@ -452,7 +451,6 @@ typedef struct {
NR_PDCCH_ConfigSIB1_t *pdcch_ConfigSIB1;
NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS];
NR_SRB_INFO SI;
NR_SRB_INFO Srb0;
int p_gNB;
} rrc_gNB_carrier_data_t;
......
......@@ -138,8 +138,6 @@ void openair_nr_rrc_on(const protocol_ctxt_t *const ctxt_pP) {
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" gNB:OPENAIR NR RRC IN....\n",PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP));
rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier.SI, BCCH, 1);
RC.nrrrc[ctxt_pP->module_id]->carrier.SI.Active = 1;
rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier.Srb0, CCCH, 1);
RC.nrrrc[ctxt_pP->module_id]->carrier.Srb0.Active = 1;
}
///---------------------------------------------------------------------------------------------------------------///
......@@ -229,7 +227,6 @@ char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigu
AssertFatal(configuration!=NULL,"configuration input is null\n");
rrc->module_id = gnb_mod_idP;
rrc->Nb_ue = 0;
rrc->carrier.Srb0.Active = 0;
rrc_gNB_mac_rrc_init(rrc);
uid_linear_allocator_init(&rrc->uid_allocator);
RB_INIT(&rrc->rrc_ue_head);
......@@ -355,19 +352,21 @@ rrc_gNB_generate_RRCSetup(
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
unsigned char buf[1024];
const NR_ServingCellConfig_t *sccd = rrc->configuration.scd;
ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP,
(uint8_t *) ue_p->Srb0.Tx_buffer.Payload,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
masterCellGroup,
masterCellGroup_len,
scc,
sccd,
&rrc->configuration);
int size = do_RRCSetup(ue_context_pP,
buf,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
masterCellGroup,
masterCellGroup_len,
scc,
sccd,
&rrc->configuration);
AssertFatal(size <= 1024, "memory corruption\n");
LOG_DUMPMSG(NR_RRC, DEBUG_RRC,
(char *)(ue_p->Srb0.Tx_buffer.Payload),
ue_p->Srb0.Tx_buffer.payload_size,
(char *)buf,
size,
"[MSG] RRC Setup\n");
// activate release timer, if RRCSetupComplete not received after 100 frames, remove UE
......@@ -380,8 +379,8 @@ rrc_gNB_generate_RRCSetup(
f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload,
.rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH
};
......@@ -405,22 +404,22 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(
ue_context_pP = rrc_gNB_get_next_free_ue_context(ctxt_pP, rrc_instance_p, 0);
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
int16_t ret = do_RRCSetup(ue_context_pP,
(uint8_t *) ue_p->Srb0.Tx_buffer.Payload,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
NULL,
0,
scc,
sccd,
&rrc_instance_p->configuration);
AssertFatal(ret>0,"Error generating RRCSetup for RRCReestablishmentRequest\n");
unsigned char buf[1024];
int size = do_RRCSetup(ue_context_pP,
buf,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
NULL,
0,
scc,
sccd,
&rrc_instance_p->configuration);
AssertFatal(size <= 1024, "memory corruption\n");
ue_p->Srb0.Tx_buffer.payload_size = ret;
AssertFatal(size>0,"Error generating RRCSetup for RRCReestablishmentRequest\n");
LOG_DUMPMSG(NR_RRC, DEBUG_RRC,
(char *)(ue_p->Srb0.Tx_buffer.Payload),
ue_p->Srb0.Tx_buffer.payload_size,
(char *)buf,
size,
"[MSG] RRC Setup\n");
LOG_D(NR_RRC,
......@@ -442,13 +441,22 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(
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);
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;
f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH
};
rrc_instance_p->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc);
}
void
......@@ -458,50 +466,44 @@ rrc_gNB_generate_RRCReject(
//-----------------------------------------------------------------------------
{
LOG_I(NR_RRC, "rrc_gNB_generate_RRCReject \n");
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
MessageDef *message_p;
ue_p->Srb0.Tx_buffer.payload_size = do_RRCReject(ctxt_pP->module_id,
(uint8_t *)ue_p->Srb0.Tx_buffer.Payload);
unsigned char buf[1024];
int size = do_RRCReject(ctxt_pP->module_id, buf);
AssertFatal(size <= 1024, "memory corruption\n");
LOG_DUMPMSG(NR_RRC, DEBUG_RRC,
(char *)(ue_p->Srb0.Tx_buffer.Payload),
ue_p->Srb0.Tx_buffer.payload_size,
(char *)buf,
size,
"[MSG] RRCReject \n");
LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_p->Srb0.Tx_buffer.payload_size);
size);
switch (RC.nrrrc[ctxt_pP->module_id]->node_type) {
case ngran_gNB_CU:
// create an ITTI message
message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE);
F1AP_DL_RRC_MESSAGE (message_p).rrc_container = (uint8_t *)ue_p->Srb0.Tx_buffer.Payload;
F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size;
F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0;
F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown
F1AP_DL_RRC_MESSAGE (message_p).rnti = ue_p->rnti;
F1AP_DL_RRC_MESSAGE (message_p).srb_id = CCCH;
F1AP_DL_RRC_MESSAGE (message_p).execute_duplication = 1;
F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0;
itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p);
LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n");
case ngran_gNB:
case ngran_gNB_CU: {
f1ap_dl_rrc_message_t dl_rrc = {
.gNB_CU_ue_id = 0,
.gNB_DU_ue_id = 0,
.old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH,
.execute_duplication = 1,
.RAT_frequency_priority_information.en_dc = 0
};
rrc->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc);
break;
}
case ngran_gNB_DU:
// nothing to do for DU
AssertFatal(1==0,"nothing to do for DU\n");
break;
case ngran_gNB:
{
// NOTE: there was ITTI_SIM which has been removed. This case is maybe
// not necessary anymore
// rrc_mac_config_req_gNB
}
break;
default :
LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type);
}
......@@ -1472,15 +1474,17 @@ rrc_gNB_generate_RRCReestablishment(
gNB_RRC_UE_t *ue_context = NULL;
module_id_t module_id = ctxt_pP->module_id;
// uint16_t rnti = ctxt_pP->rnti;
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
SRB_configList = &(ue_context_pP->ue_context.SRB_configList);
//carrier = &(RC.nrrrc[ctxt_pP->module_id]->carrier);
ue_context = &(ue_context_pP->ue_context);
ue_context->Srb0.Tx_buffer.payload_size = do_RRCReestablishment(ctxt_pP,
unsigned char buf[1024];
int size = do_RRCReestablishment(ctxt_pP,
ue_context_pP,
CC_id,
(uint8_t *) ue_context->Srb0.Tx_buffer.Payload,
sizeof(ue_context->Srb0.Tx_buffer.Payload),
buf,
sizeof(buf),
//(uint8_t) carrier->p_gNB, // at this point we do not have the UE capability information, so it can only be TM1 or TM2
rrc_gNB_get_next_transaction_identifier(module_id),
SRB_configList
......@@ -1503,7 +1507,7 @@ rrc_gNB_generate_RRCReestablishment(
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context->Srb0.Tx_buffer.payload_size);
size);
#if(0)
/* TODO : It may be needed if gNB goes into full stack working. */
UE = find_nr_UE(module_id, rnti);
......@@ -1518,6 +1522,16 @@ rrc_gNB_generate_RRCReestablishment(
rnti);
}
#endif
/* correct? specs say RRCReestablishment goes through srb1... */
f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_context->rnti,
.srb_id = CCCH
};
rrc->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc);
}
//-----------------------------------------------------------------------------
......@@ -1916,12 +1930,6 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
}
ue_context_p = rrc_gNB_get_next_free_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], random_value);
ue_context_p->ue_context.Srb0.Srb_id = 0;
ue_context_p->ue_context.Srb0.Active = 1;
memcpy(ue_context_p->ue_context.Srb0.Rx_buffer.Payload,
buffer,
buffer_length);
ue_context_p->ue_context.Srb0.Rx_buffer.payload_size = buffer_length;
} else if (NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1 == rrcSetupRequest->ue_Identity.present) {
/* TODO */
/* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */
......
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