Commit 27566f49 authored by Robert Schmidt's avatar Robert Schmidt

Create CellGroup, SRB0, and SRB1, before sending Initial UL RRC message

During the Initial UL RRC Message, the CellGroup is created. Since the
CellGroup specifies the SRB1, the SRB1 should also be created (because
the DL RRC Messages is sent via SRB1). However, before this commit, the
CellGroup is created while having the RLC lock, so we cannot create
SRB1, as it results in a deadlock.

Therefore, we now first create CellGroup, SRB0, and SRB1, before giving
the UE message to the RLC.
parent c4c41d3b
......@@ -2908,30 +2908,16 @@ 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,
int rnti,
int uid,
const uint8_t *sdu,
sdu_size_t sdu_len) {
const gNB_MAC_INST *mac = RC.nrmac[module_id];
LOG_W(MAC,
"[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))
rrc_gNB_create_ue_context(rnti, RC.nrrrc[module_id], rnti);
void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void* rawUE)
{
LOG_W(MAC, "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", sdu_len, rnti);
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(uid, &cellGroupConfig, scc, sccd, &RC.nrrrc[module_id]->configuration);
NR_UE_info_t* UE = (NR_UE_info_t*) rawUE;
uint8_t du2cu_rrc_container[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
&cellGroupConfig,
UE->CellGroup,
du2cu_rrc_container,
sizeof(du2cu_rrc_container));
AssertFatal(enc_rval.encoded > 0,
......@@ -2947,5 +2933,48 @@ void send_initial_ul_rrc_message(module_id_t module_id,
.du2cu_rrc_container = (uint8_t *) du2cu_rrc_container,
.du2cu_rrc_container_length = (enc_rval.encoded + 7) / 8
};
mac->mac_rrc.initial_ul_rrc_message_transfer(module_id, &ul_rrc_msg);
mac->mac_rrc.initial_ul_rrc_message_transfer(0, &ul_rrc_msg);
}
void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t* UE)
{
/* create this UE's initial CellGroup */
/* Note: relying on the RRC is a hack, as we are in the DU; there should be
* no RRC, remove in the future */
module_id_t mod_id = 0;
gNB_RRC_INST *rrc = RC.nrrrc[mod_id];
const NR_ServingCellConfigCommon_t *scc = rrc->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = rrc->configuration.scd;
NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(*cellGroupConfig));
AssertFatal(cellGroupConfig != NULL, "out of memory\n");
fill_initial_cellGroupConfig(UE->uid, cellGroupConfig, scc, sccd, &rrc->configuration);
uint8_t du2cu_rrc_container[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
cellGroupConfig,
du2cu_rrc_container,
sizeof(du2cu_rrc_container));
AssertFatal(enc_rval.encoded > 0,
"Could not encode cellGroupConfig for UE %04x, failed element %s\n",
UE->rnti,
enc_rval.failed_type->name);
UE->CellGroup = cellGroupConfig;
nr_mac_update_cellgroup(mac, UE->rnti, cellGroupConfig);
/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */
if (NODE_IS_DU(rrc->node_type)) {
rrc_gNB_ue_context_t *ue = rrc_gNB_create_ue_context(UE->rnti, rrc, UE->rnti);
ue->ue_context.masterCellGroup = cellGroupConfig;
}
/* activate SRB0 */
nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message);
/* the cellGroup sent to CU specifies there is SRB1, so create it */
DevAssert(cellGroupConfig->rlc_BearerToAddModList->list.count == 1);
const NR_RLC_BearerConfig_t *bearer = cellGroupConfig->rlc_BearerToAddModList->list.array[0];
DevAssert(bearer->servedRadioBearer->choice.srb_Identity == 1);
nr_rlc_add_srb(UE->rnti, DCCH, bearer);
}
......@@ -372,8 +372,9 @@ int nr_process_mac_pdu(instance_t module_idP,
mac_len = 6;
}
nr_rlc_activate_srb0(UE->rnti, module_idP, CC_id, UE->uid, send_initial_ul_rrc_message);
LOG_W(MAC, "[RAPROC] Received SDU for CCCH length %d for UE %04x\n", mac_len, UE->rnti);
prepare_initial_ul_rrc_message(RC.nrmac[module_idP], UE);
mac_rlc_data_ind(module_idP,
UE->rnti,
module_idP,
......
......@@ -486,12 +486,8 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl);
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 prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t* UE);
void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void* rawUE);
void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid);
......
......@@ -951,34 +951,31 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP
}
struct srb0_data {
int module_id;
int CC_id;
struct gNB_MAC_INST_s *mac;
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 *rawUE;
void (*send_initial_ul_rrc_message)(struct gNB_MAC_INST_s *mac,
int rnti,
const uint8_t *sdu,
sdu_size_t sdu_len,
void *rawUE);
};
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);
s0->send_initial_ul_rrc_message(s0->mac, s0->rnti, (unsigned char *)buf,
size, s0->rawUE);
}
void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid,
void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE,
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))
struct gNB_MAC_INST_s *mac,
int rnti,
const uint8_t *sdu,
sdu_size_t sdu_len,
void *rawUE))
{
nr_rlc_entity_t *nr_rlc_tm;
nr_rlc_ue_t *ue;
......@@ -987,10 +984,9 @@ void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid,
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->mac = mac;
srb0_data->rnti = rnti;
srb0_data->uid = uid;
srb0_data->rawUE = rawUE;
srb0_data->send_initial_ul_rrc_message = send_initial_ul_rrc_message;
nr_rlc_manager_lock(nr_rlc_ue_manager);
......
......@@ -61,11 +61,11 @@ void nr_rlc_activate_avg_time_to_tx(
void nr_rlc_srb_recv_sdu(const int rnti, const logical_chan_id_t channel_id, unsigned char *buf, int size);
void nr_rlc_activate_srb0(int rnti, int module_id, int cc_id, int uid,
struct gNB_MAC_INST_s;
void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE,
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));
struct gNB_MAC_INST_s *mac,
int rnti,
const uint8_t *sdu,
sdu_size_t sdu_len,
void *rawUE));
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