From be9b84c03fd6d3e8e0804f60ad153be37642d309 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 2 Oct 2023 18:00:54 +0200 Subject: [PATCH 1/6] Refactor interface SRB0: no gNB MAC --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 8 ++++---- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 19 +++++++------------ openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h | 6 ++---- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index fc317593fb..1e5de41ab3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2908,10 +2908,10 @@ void UL_tti_req_ahead_initialization(gNB_MAC_INST * gNB, NR_ServingCellConfigCom } } -void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE) +void send_initial_ul_rrc_message(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data) { - - NR_UE_info_t *UE = (NR_UE_info_t *)rawUE; + gNB_MAC_INST *mac = RC.nrmac[0]; + NR_UE_info_t *UE = (NR_UE_info_t *)data; NR_SCHED_ENSURE_LOCKED(&mac->sched_lock); uint8_t du2cu[1024]; @@ -2945,7 +2945,7 @@ void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE) process_CellGroup(cellGroupConfig, UE); /* activate SRB0 */ - nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message); + nr_rlc_activate_srb0(UE->rnti, 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); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index b5c8ac4a97..cc649a28f3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -435,7 +435,7 @@ 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_info_t *UE); 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 send_initial_ul_rrc_message(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data); void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 2aec005e6d..19bfeb683d 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -963,31 +963,27 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP } struct srb0_data { - struct gNB_MAC_INST_s *mac; int rnti; - void *rawUE; - void (*send_initial_ul_rrc_message)(struct gNB_MAC_INST_s *mac, - int rnti, + void *data; + void (*send_initial_ul_rrc_message)(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, - void *rawUE); + void *data); }; 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->mac, s0->rnti, (unsigned char *)buf, - size, s0->rawUE); + s0->send_initial_ul_rrc_message(s0->rnti, (unsigned char *)buf, size, s0->data); } -void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, +void nr_rlc_activate_srb0(int rnti, void *data, 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 *data)) { nr_rlc_entity_t *nr_rlc_tm; nr_rlc_ue_t *ue; @@ -996,9 +992,8 @@ void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, srb0_data = calloc(1, sizeof(struct srb0_data)); AssertFatal(srb0_data != NULL, "out of memory\n"); - srb0_data->mac = mac; srb0_data->rnti = rnti; - srb0_data->rawUE = rawUE; + srb0_data->data = data; srb0_data->send_initial_ul_rrc_message = send_initial_ul_rrc_message; nr_rlc_manager_lock(nr_rlc_ue_manager); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index be12b236e8..d8a0d66f00 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -66,13 +66,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); -struct gNB_MAC_INST_s; -void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, +void nr_rlc_activate_srb0(int rnti, void *data, 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 *data)); bool nr_rlc_get_statistics(int rnti, int srb_flag, int rb_id, nr_rlc_statistics_t *out); From 91891299851b73aa8ae486fa289dd4bf94471634 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 22 Aug 2023 14:54:31 +0200 Subject: [PATCH 2/6] Use SRB0 at UE - Use SRB0 TM entity at UE for Msg.3/RRC Setup Request - Msg3 data request sent upon reception of Msg2, then we get data from rlc when needed --- openair1/SIMULATION/NR_PHY/dlsim.c | 10 -- openair1/SIMULATION/NR_PHY/prachsim.c | 10 -- openair1/SIMULATION/NR_PHY/ulsim.c | 10 -- openair2/COMMON/mac_messages_def.h | 3 +- openair2/COMMON/mac_messages_types.h | 5 + openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 - openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 + openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 36 +++++- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 101 +++++++++-------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 23 +++- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 +- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 8 +- openair2/RRC/NR/nr_rrc_common.h | 6 - openair2/RRC/NR_UE/L2_interface_ue.c | 57 +--------- openair2/RRC/NR_UE/rrc_UE.c | 113 ++++++++----------- openair2/RRC/NR_UE/rrc_defs.h | 1 - openair2/RRC/NR_UE/rrc_proto.h | 21 +--- 17 files changed, 176 insertions(+), 241 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 802fa780c7..6d80ac619c 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -108,16 +108,6 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB return; } -int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, - const int CC_id, - const uint8_t gNB_id, - const frame_t frameP, - const rb_id_t Srb_id, - uint8_t *buffer_pP) -{ - return 0; -} - int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) { return 0; } diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index b616f050fe..c90c414d51 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -108,16 +108,6 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB return; } -int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, - const int CC_id, - const uint8_t gNB_id, - const frame_t frameP, - const rb_id_t Srb_id, - uint8_t *buffer_pP) -{ - return 0; -} - int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) { return 0; } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5fd35cfd6c..77a1d6d821 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -104,16 +104,6 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB return; } -int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, - const int CC_id, - const uint8_t gNB_id, - const frame_t frameP, - const rb_id_t Srb_id, - uint8_t *buffer_pP) -{ - return 0; -} - int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) { return 0; } diff --git a/openair2/COMMON/mac_messages_def.h b/openair2/COMMON/mac_messages_def.h index 50e7a108c9..01dd1e3707 100644 --- a/openair2/COMMON/mac_messages_def.h +++ b/openair2/COMMON/mac_messages_def.h @@ -48,7 +48,8 @@ MESSAGE_DEF(RRC_MAC_MCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcMacMcchDat MESSAGE_DEF(RRC_MAC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcMacPcchDataReq, rrc_mac_pcch_data_req) -MESSAGE_DEF(NR_RRC_MAC_RA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacRaInd, nr_rrc_mac_ra_ind) +MESSAGE_DEF(NR_RRC_MAC_RA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacRaInd, nr_rrc_mac_ra_ind) +MESSAGE_DEF(NR_RRC_MAC_MSG3_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcMacMsg3Ind, nr_rrc_mac_msg3_ind) /* RRC configures DRX context (MAC timers) of a UE */ MESSAGE_DEF(RRC_MAC_DRX_CONFIG_REQ, MESSAGE_PRIORITY_MED, rrc_mac_drx_config_req_t, rrc_mac_drx_config_req) diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index db65e245d3..f20ff5b600 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -55,6 +55,7 @@ #define RRC_MAC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_pcch_data_req #define NR_RRC_MAC_RA_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_ra_ind +#define NR_RRC_MAC_MSG3_IND(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_mac_msg3_ind #define RRC_MAC_DRX_CONFIG_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_mac_drx_config_req @@ -73,6 +74,10 @@ typedef struct NRRrcMacRaInd_s { bool RA_succeeded; } NRRrcMacRaInd; +typedef struct NRRrcMacMsg3Ind_s { + uint16_t rnti; +} NRRrcMacMsg3Ind; + typedef struct RrcMacInSyncInd_s { uint32_t frame; uint8_t sub_frame; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 77a9484695..b7e0cbecb6 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -469,7 +469,6 @@ typedef struct { /* PDUs */ /// Outgoing CCCH pdu for PHY CCCH_PDU CCCH_pdu; - ULSCH_PDU ulsch_pdu; /* Random Access */ /// CRNTI diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 1817a67a0c..e830b34832 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -371,6 +371,8 @@ void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu); void nr_Msg1_transmitted(module_id_t mod_id); void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); +void nr_get_msg3_payload(module_id_t mod_id); +void send_msg3_rrc_request(module_id_t mod_id, int rnti); void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 40488d458a..a03f8d3e69 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -40,10 +40,38 @@ #include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h" #include "nr_rlc/nr_rlc_oai_api.h" #include "RRC/NR/MESSAGES/asn1_msg.h" +#include "RRC/NR_UE/rrc_proto.h" #include static NR_UE_MAC_INST_t *nr_ue_mac_inst; +// TODO: refactor +struct gNB_MAC_INST_s; +typedef struct gNB_MAC_INST_s gNB_MAC_INST; +static void send_srb0_rrc(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE) +{ + AssertFatal(sdu_len > 0 && sdu_len < CCCH_SDU_SIZE, "invalid CCCH SDU size %d\n", sdu_len); + + MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_CCCH_DATA_IND); + memset(NR_RRC_MAC_CCCH_DATA_IND(message_p).sdu, 0, sdu_len); + memcpy(NR_RRC_MAC_CCCH_DATA_IND(message_p).sdu, sdu, sdu_len); + NR_RRC_MAC_CCCH_DATA_IND(message_p).sdu_size = sdu_len; + NR_RRC_MAC_CCCH_DATA_IND(message_p).rnti = rnti; + NR_RRC_MAC_CCCH_DATA_IND(message_p).gnb_index = 0; + NR_RRC_MAC_CCCH_DATA_IND(message_p).frame = 0; + NR_RRC_MAC_CCCH_DATA_IND(message_p).slot = 0; + NR_RRC_MAC_CCCH_DATA_IND(message_p).du_to_cu_rrc_container = NULL; + NR_RRC_MAC_CCCH_DATA_IND(message_p).CC_id = 0; + NR_RRC_MAC_CCCH_DATA_IND(message_p).nr_cellid = 0; + itti_send_msg_to_task(TASK_RRC_NRUE, 0, message_p); +} + +void send_msg3_rrc_request(module_id_t mod_id, int rnti) +{ + nr_rlc_activate_srb0(rnti, NULL, NULL, send_srb0_rrc); + nr_mac_rrc_msg3_ind(mod_id, rnti); +} + NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { //LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); @@ -67,7 +95,10 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { if (rrc_inst && rrc_inst->scell_group_config) { nr_rrc_mac_config_req_scg(0, 0, rrc_inst->scell_group_config); - AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + int rc = rlc_module_init(0); + AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + /* convention: RNTI for SRB0 is 0, as it changes all the time */ + nr_rlc_activate_srb0(0, NULL, NULL, send_srb0_rrc); if (IS_SOFTMODEM_NOS1){ // get default noS1 configuration NR_RadioBearerConfig_t *rbconfig = NULL; @@ -91,7 +122,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { else { LOG_I(MAC,"Running without CellGroupConfig\n"); if(get_softmodem_params()->sa == 1) { - AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + int rc = rlc_module_init(0); + AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 9328d75b37..19c9919f6a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -605,7 +605,52 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot ra->RA_contention_resolution_timer_active = 1; ra->ra_state = WAIT_CONTENTION_RESOLUTION; +} +void nr_get_msg3_payload(module_id_t mod_id) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); + RA_config_t *ra = &mac->ra; + uint8_t *pdu = mac->CCCH_pdu.payload; + const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_FIXED); + NR_MAC_SUBHEADER_FIXED *header = (NR_MAC_SUBHEADER_FIXED *) pdu; + pdu += sh_size; + int lcid = 0; // SRB0 for messages sent in MSG3 + tbs_size_t len = mac_rlc_data_req(mod_id, + ra->t_crnti, + 0, + 0, + ENB_FLAG_NO, + MBMS_FLAG_NO, + lcid, + 16, /* size of mac_ce above */ + (char *)pdu, + 0, + 0); + AssertFatal(len > 0, "no data for Msg.3\n"); + // UE Contention Resolution Identity + // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the + // Random Access Procedure has been successful after reception of Msg4 + memcpy(ra->cont_res_id, pdu, sizeof(uint8_t) * 6); + pdu += len; + int Msg3_size = len + sh_size; + // Build header + header->R = 0; + header->LCID = UL_SCH_LCID_CCCH; + const uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // Note: unclear the reason behind the selection of such TBS_max + // Padding: fill remainder with 0 + if (TBS_max - Msg3_size > 0) { + AssertFatal(TBS_max > Msg3_size, "Allocated resources are not enough for Msg3!\n"); + LOG_D(NR_MAC, "Remaining %d bytes, filling with padding\n",TBS_max - Msg3_size); + ((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0; + ((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING; + pdu += sizeof(NR_MAC_SUBHEADER_FIXED); + memset(pdu, 0, TBS_max - Msg3_size - sizeof(NR_MAC_SUBHEADER_FIXED)); + } + // Dumping ULSCH payload + LOG_D(NR_MAC, "Dumping UL Msg3 MAC PDU with length %d: \n", TBS_max); + for(int k = 0; k < TBS_max; k++) + LOG_D(NR_MAC,"(%i): %i\n", k, pdu[k]); } /** @@ -660,47 +705,15 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, LOG_D(NR_MAC, "In %s: RA not active. Checking for data to transmit from upper layers...\n", __FUNCTION__); - const uint8_t lcid = UL_SCH_LCID_CCCH; - const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_FIXED); const uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // Note: unclear the reason behind the selection of such TBS_max - int8_t size_sdu = 0; + int size_sdu = 0; uint8_t mac_ce[16] = {0}; uint8_t *pdu = get_softmodem_params()->sa ? mac->CCCH_pdu.payload : mac_ce; uint8_t *payload = pdu; // Concerning the C-RNTI MAC CE, it has to be included if the UL transmission (Msg3) is not being made for the CCCH logical channel. // Therefore it has been assumed that this event only occurs only when RA is done and it is not SA mode. - if (get_softmodem_params()->sa) { - - NR_MAC_SUBHEADER_FIXED *header = (NR_MAC_SUBHEADER_FIXED *) pdu; - pdu += sh_size; - - // initialisation by RRC - nr_rrc_ue_generate_RRCSetupRequest(mod_id,gNB_id); - - // CCCH PDU - size_sdu = nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, pdu); - LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: Requested RRCConnectionRequest, got %d bytes for LCID 0x%02x \n", __FUNCTION__, mod_id, frame, nr_slot_tx, size_sdu, lcid); - - if (size_sdu > 0) { - - // UE Contention Resolution Identity - // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the - // Random Access Procedure has been successful after reception of Msg4 - memcpy(ra->cont_res_id, pdu, sizeof(uint8_t) * 6); - - pdu += size_sdu; - ra->Msg3_size = size_sdu + sh_size; - - // Build header - header->R = 0; - header->LCID = lcid; - - } else { - pdu -= sh_size; - } - - } else if (get_softmodem_params()->nsa) { + if (get_softmodem_params()->nsa) { uint8_t mac_sdus[34*1056]; uint16_t sdu_lengths[NB_RB_MAX] = {0}; @@ -722,7 +735,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); } - } else { + } else if (!get_softmodem_params()->sa) { size_sdu = nr_write_ce_ulsch_pdu(pdu, mac, 0, &(mac->crnti), NULL, NULL, NULL); pdu += size_sdu; @@ -732,12 +745,12 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, if (size_sdu > 0 && (ra->ra_state == GENERATE_PREAMBLE || get_softmodem_params()->nsa)) { - LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", __FUNCTION__, mod_id, frame, nr_slot_tx); + LOG_D(NR_MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx); // Padding: fill remainder with 0 if (TBS_max - ra->Msg3_size > 0) { AssertFatal(TBS_max > ra->Msg3_size, "In %s: allocated resources are not enough for Msg3!\n", __FUNCTION__); - LOG_D(NR_MAC, "In %s: remaining %d bytes, filling with padding\n", __FUNCTION__, TBS_max - ra->Msg3_size); + LOG_D(NR_MAC, "Remaining %d bytes, filling with padding\n",TBS_max - ra->Msg3_size); ((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING; pdu += sizeof(NR_MAC_SUBHEADER_FIXED); @@ -745,25 +758,17 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, } // Dumping ULSCH payload - LOG_D(NR_MAC, "In %s: dumping UL Msg3 MAC PDU with length %d: \n", __FUNCTION__, TBS_max); + LOG_D(NR_MAC, "Dumping UL Msg3 MAC PDU with length %d: \n", TBS_max); for(int k = 0; k < TBS_max; k++) { LOG_D(NR_MAC,"(%i): %i\n", k, payload[k]); } - // Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after - // receiving Msg2 (which contains the Msg3 resource reserve). - // Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s. - if (!get_softmodem_params()->nsa) { - mac->ulsch_pdu.Pdu_size = TBS_max; - memcpy(mac->ulsch_pdu.payload, payload, TBS_max); - } - } else { return 0; } } else if (ra->RA_window_cnt != -1) { // RACH is active - LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt); + LOG_D(MAC, "[%d.%d] RA is active: RA window count %d, RA backoff count %d\n", frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt); if (ra->RA_BI_found){ prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * ra->RA_backoff_indicator; @@ -806,7 +811,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, } } - if (ra->RA_contention_resolution_timer_active){ + if (ra->RA_contention_resolution_timer_active) { nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c5cef25784..e17f2f7582 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3523,7 +3523,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, break; } - if ( mac_len > 0 ) { + if (mac_len > 0) { LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len); for (int i = 0; i < mac_subheader_len; i++) { LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]); @@ -3531,7 +3531,18 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, for (int i = 0; i < mac_len; i++) { LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]); } - nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_len); + + mac_rlc_data_ind(module_idP, + mac->crnti, + module_idP, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + 0, + (char *)(pduP + mac_subheader_len), + mac_len, + 1, + NULL); } break; case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH: @@ -4037,7 +4048,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1); LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2); - LOG_I(NR_MAC, "In %s:[%d.%d]: [UE %d] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d t_crnti %x \n", + LOG_I(NR_MAC, "In %s:[%d.%d]: [UE %d] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d\n", __FUNCTION__, frame, slot, @@ -4047,8 +4058,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ta_command, rar_grant.mcs, rar_grant.freq_hopping, - tpc_command, - ra->t_crnti); + tpc_command); #endif // Schedule Msg3 @@ -4060,7 +4070,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) } ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); - if (ret != -1){ + if (ret != -1) { fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2); uint16_t rnti = mac->crnti; @@ -4076,6 +4086,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) if (!ra->cfra) { ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); rnti = ra->t_crnti; + send_msg3_rrc_request(mod_id, rnti); } pthread_mutex_lock(&ul_config->mutex_ul_config); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index e2548fc7b1..9bfd4f0f5c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1031,13 +1031,13 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id], ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator, TBS_bytes,ra->ra_state); - if (ra->ra_state == WAIT_RAR && !ra->cfra){ - memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes); - LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n"); + if (ra->ra_state == WAIT_RAR && !ra->cfra) { + nr_get_msg3_payload(mod_id); + memcpy(ulsch_input_buffer, mac->CCCH_pdu.payload, TBS_bytes); for (int k = 0; k < TBS_bytes; k++) { - LOG_D(NR_MAC,"(%i): 0x%x\n",k,mac->ulsch_pdu.payload[k]); + LOG_D(NR_MAC,"(%i): 0x%x\n", k, ulsch_input_buffer[k]); } - LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator); + LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n", ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator); mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator; mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0; mac_pdu_exist = 1; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 19bfeb683d..49df9469ab 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -151,8 +151,8 @@ void mac_rlc_data_ind(const module_id_t module_idP, rb->set_time(rb, nr_rlc_current_time); rb->recv_pdu(rb, buffer_pP, tb_sizeP); } else { - LOG_E(RLC, "%s:%d:%s: fatal: no RB found (channel ID %d)\n", - __FILE__, __LINE__, __FUNCTION__, channel_idP); + LOG_E(RLC, "Fatal: no RB found (channel ID %d RNTI %d)\n", + channel_idP, rntiP); // exit(1); } @@ -729,7 +729,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare int t_reassembly; int sn_field_length; - LOG_D(RLC,"Trying to add SRB %d\n",srb_id); + LOG_D(RLC, "Trying to add SRB %d\n", srb_id); AssertFatal(srb_id > 0 && srb_id < 4, "Invalid srb id %d\n", srb_id); @@ -792,7 +792,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare sn_field_length); nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am); - LOG_I(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); + LOG_I(RLC, "Added srb %d to UE with RNTI 0x%x\n", srb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } diff --git a/openair2/RRC/NR/nr_rrc_common.h b/openair2/RRC/NR/nr_rrc_common.h index 1505e71924..69dbb9ff0f 100644 --- a/openair2/RRC/NR/nr_rrc_common.h +++ b/openair2/RRC/NR/nr_rrc_common.h @@ -61,13 +61,7 @@ typedef struct RB_INFO_NR_s { //MAC_MEAS_REQ_ENTRY *Meas_entry; //may not needed for NB-IoT } NR_RB_INFO; -typedef struct NR_SRB_INFO_s { - NR_RRC_BUFFER Rx_buffer; - NR_RRC_BUFFER Tx_buffer; -} NR_SRB_INFO; - typedef struct SRB_INFO_TABLE_ENTRY_NR_s { - NR_SRB_INFO Srb_info; uint8_t Active; uint8_t status; } NR_SRB_INFO_TABLE_ENTRY; diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 1cfb8068d3..3a90e099e8 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -91,29 +91,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, break; case CCCH: - if (pdu_len>0) { - LOG_T(NR_RRC,"[UE %d] Received SDU for CCCH on SRB %u from gNB %d\n",module_id,channel & RAB_OFFSET,gNB_index); - - MessageDef *message_p; - int msg_sdu_size = CCCH_SDU_SIZE; - - if (pdu_len > msg_sdu_size) { - LOG_E(NR_RRC, "SDU larger than CCCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size); - sdu_size = msg_sdu_size; - } else { - sdu_size = pdu_len; - } - - message_p = itti_alloc_new_message (TASK_MAC_UE, 0, NR_RRC_MAC_CCCH_DATA_IND); - memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, pduP, sdu_size); - NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; //frameP - NR_RRC_MAC_CCCH_DATA_IND (message_p).slot = slot; - NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; - NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = gNB_index; - NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; //rntiP - itti_send_msg_to_task (TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE( module_id ), message_p); - } + AssertFatal(false, "use RLC instead\n"); break; default: @@ -123,36 +101,11 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, return(0); } -int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, - const int CC_id, - const uint8_t gNB_id, - const frame_t frameP, - const rb_id_t Srb_id, - uint8_t *buffer_pP) +void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti) { - switch(Srb_id) { - - case CCCH: - LOG_D(NR_RRC, - "nr_mac_rrc_data_req_ue: Payload size = %i\n", - NR_UE_rrc_inst[Mod_idP].Srb[gNB_id][0].srb_buffers.Tx_buffer.payload_size); - NR_UE_RRC_SRB_INFO_t *Srb0 = &NR_UE_rrc_inst[Mod_idP].Srb[gNB_id][0]; - memcpy(buffer_pP, (uint8_t *)Srb0->srb_buffers.Tx_buffer.Payload, Srb0->srb_buffers.Tx_buffer.payload_size); - for (int i = 0; i < Srb0->srb_buffers.Tx_buffer.payload_size; i++) { - LOG_D(NR_RRC,"(%i): %i\n", i, buffer_pP[i]); - } - - return Srb0->srb_buffers.Tx_buffer.payload_size; - - case DCCH: - AssertFatal(1==0, "SRB1 not implemented yet!\n"); - case DCCH1: - AssertFatal(1==0, "SRB2 not implemented yet!\n"); - default: - AssertFatal(1==0, "Invalid SRB id!\n"); - } - - return 0; + MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MSG3_IND); + NR_RRC_MAC_MSG3_IND (message_p).rnti = rnti; + itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p); } void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index a6a0d9dd07..28dfebafa8 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -616,12 +616,12 @@ int nr_decode_SI(const module_id_t module_id, const uint8_t gNB_index, NR_System return 0; } -int8_t nr_rrc_ue_generate_ra_msg(module_id_t module_id, uint8_t gNB_index) { - - switch(NR_UE_rrc_inst[module_id].ra_trigger){ +void nr_rrc_ue_generate_ra_msg(module_id_t module_id, int rnti) +{ + switch(NR_UE_rrc_inst[module_id].ra_trigger) { case INITIAL_ACCESS_FROM_RRC_IDLE: // After SIB1 is received, prepare RRCConnectionRequest - nr_rrc_ue_generate_RRCSetupRequest(module_id,gNB_index); + nr_rrc_ue_generate_RRCSetupRequest(module_id, rnti); break; case RRC_CONNECTION_REESTABLISHMENT: AssertFatal(1==0, "ra_trigger not implemented yet!\n"); @@ -648,8 +648,27 @@ int8_t nr_rrc_ue_generate_ra_msg(module_id_t module_id, uint8_t gNB_index) { AssertFatal(1==0, "Invalid ra_trigger value!\n"); break; } +} - return 0; +void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, int rnti) +{ + uint8_t rv[6]; + // Get RRCConnectionRequest, fill random for now + // Generate random byte stream for contention resolution + for (int i = 0; i < 6; i++) { +#ifdef SMBV + // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed + rv[i] = i; +#else + rv[i] = taus() & 0xff; +#endif + } + + uint8_t buf[1024]; + int len = do_RRCSetupRequest(module_id, buf, sizeof(buf), rv); + + /* convention: RNTI for SRB0 is zero, as it changes all the time */ + nr_rlc_srb_recv_sdu(rnti, 0, buf, len); } void nr_rrc_configure_default_SI(NR_UE_RRC_SI_INFO *SI_info, @@ -732,7 +751,6 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, // take ServingCellConfigCommon and configure L1/L2 rrc->servingCellConfigCommonSIB = sib1->servingCellConfigCommon; nr_rrc_mac_config_req_sib1(module_id, 0, sib1->si_SchedulingInfo, sib1->servingCellConfigCommon); - nr_rrc_ue_generate_ra_msg(module_id, gNB_index); break; case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: LOG_I(NR_RRC, "[UE %"PRIu8"] Decoding SI\n", module_id); @@ -966,7 +984,7 @@ static void rrc_ue_generate_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, srb_id, nr_rrc_mui++, size, buffer, deliver_pdu_srb_rlc, NULL); } -int8_t nr_rrc_ue_decode_ccch(const protocol_ctxt_t *const ctxt_pP, const NR_UE_RRC_SRB_INFO_t *Srb_info, const uint8_t gNB_index) +static int8_t nr_rrc_ue_decode_ccch(const protocol_ctxt_t *const ctxt_pP, const uint8_t *buf, int len, const uint8_t gNB_index) { NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; NR_DL_CCCH_Message_t *dl_ccch_msg=NULL; @@ -976,21 +994,15 @@ int8_t nr_rrc_ue_decode_ccch(const protocol_ctxt_t *const ctxt_pP, const NR_UE_R LOG_D(RRC, "[NR UE%d] Decoding DL-CCCH message (%d bytes), State %d\n", ctxt_pP->module_id, - Srb_info->srb_buffers.Rx_buffer.payload_size, + len, rrc->nrRrcState); - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_CCCH_Message, - (void **)&dl_ccch_msg, - (uint8_t *)Srb_info->srb_buffers.Rx_buffer.Payload, - Srb_info->srb_buffers.Rx_buffer.payload_size, - 0, - 0); - // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)dl_ccch_msg); - // } + dec_rval = uper_decode(NULL, &asn_DEF_NR_DL_CCCH_Message, (void **)&dl_ccch_msg, buf, len, 0, 0); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + if (LOG_DEBUGFLAG(DEBUG_ASN1)) + xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)dl_ccch_msg); + + if (dec_rval.code != RC_OK && dec_rval.consumed == 0) { LOG_E(RRC, "[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%zu bytes)\n", ctxt_pP->module_id, @@ -1292,41 +1304,6 @@ void nr_rrc_ue_process_securityModeCommand(const protocol_ctxt_t *const ctxt_pP, securityModeCommand->criticalExtensions.present); } -void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index) -{ - uint8_t rv[6]; - NR_UE_RRC_SRB_INFO_t *Srb0 = &NR_UE_rrc_inst[module_id].Srb[gNB_index][0]; - if (Srb0->srb_buffers.Tx_buffer.payload_size == 0) { - // Get RRCConnectionRequest, fill random for now - // Generate random byte stream for contention resolution - for (int i = 0; i < 6; i++) { -#ifdef SMBV - // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed - rv[i] = i; -#else - rv[i] = taus() & 0xff; -#endif - LOG_T(NR_RRC, "%x.", rv[i]); - } - - LOG_T(NR_RRC, "\n"); - Srb0->srb_buffers.Tx_buffer.payload_size = do_RRCSetupRequest(module_id, - (uint8_t *)Srb0->srb_buffers.Tx_buffer.Payload, - sizeof(Srb0->srb_buffers.Tx_buffer.Payload), - rv); - LOG_I(NR_RRC, - "[UE %d] : Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, gNB %d)\n", - module_id, - Srb0->srb_buffers.Tx_buffer.payload_size, - gNB_index); - - for (int i = 0; i < Srb0->srb_buffers.Tx_buffer.payload_size; i++) - LOG_T(NR_RRC, "%x.", Srb0->srb_buffers.Tx_buffer.Payload[i]); - - LOG_T(NR_RRC, "\n"); - } -} - //----------------------------------------------------------------------------- void nr_rrc_ue_process_measConfig( @@ -1799,8 +1776,17 @@ void *rrc_nrue_task(void *args_p) nr_rrc_SI_timers(SInfo); break; + case NR_RRC_MAC_MSG3_IND: + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_MSG3_IND (msg_p).rnti, 0, 0); + LOG_D(NR_RRC, "[UE %d] Received %s for RNTI %d\n", + ue_mod_id, + ITTI_MSG_NAME (msg_p), + NR_RRC_MAC_MSG3_IND (msg_p).rnti); + nr_rrc_ue_generate_ra_msg(ue_mod_id, NR_RRC_MAC_MSG3_IND (msg_p).rnti); + break; + case NR_RRC_MAC_RA_IND: - LOG_D(NR_RRC, "[UE %d] Received %s: frame %d\n RA %s", + LOG_D(NR_RRC, "[UE %d] Received %s: frame %d RA %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p), NR_RRC_MAC_RA_IND (msg_p).frame, @@ -1828,18 +1814,11 @@ void *rrc_nrue_task(void *args_p) break; case NR_RRC_MAC_CCCH_DATA_IND: - LOG_D(NR_RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n", - ue_mod_id, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, - ITTI_MSG_NAME (msg_p), - NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); - NR_UE_RRC_SRB_INFO_t *srb0 = &NR_UE_rrc_inst[ue_mod_id].Srb[NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index][0]; - memcpy(srb0->srb_buffers.Rx_buffer.Payload, NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); - srb0->srb_buffers.Rx_buffer.payload_size = NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0); - // PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); - nr_rrc_ue_decode_ccch(&ctxt, srb0, NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index); + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, 0, 0); + nr_rrc_ue_decode_ccch(&ctxt, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); break; /* PDCP messages */ diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 03b983d7ed..c2d2c1a0de 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -182,7 +182,6 @@ typedef enum { RB_NOT_PRESENT, RB_ESTABLISHED, RB_SUSPENDED } NR_RB_status_t; typedef struct NR_UE_RRC_SRB_INFO_s { NR_RB_status_t status; - NR_SRB_INFO srb_buffers; } NR_UE_RRC_SRB_INFO_t; typedef struct NR_UE_RRC_INST_s { diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index d04830192c..335b9ba84d 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -107,20 +107,7 @@ void nr_mac_rrc_sync_ind(const module_id_t module_id, const frame_t frame, const bool in_sync); void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success); - -/**\brief - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param frame_t frameP - \param rb_id_t SRB id - \param buffer_pP pointer to buffer*/ -int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, - const int CC_id, - const uint8_t gNB_id, - const frame_t frameP, - const rb_id_t Srb_id, - uint8_t *buffer_pP); +void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti); int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index); @@ -140,10 +127,8 @@ void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t m void start_oai_nrue_threads(void); -/**\brief RRC UE generate RRCSetupRequest message. - \param module_id module id - \param gNB_index gNB index */ -void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index); +/**\brief RRC UE generate RRCSetupRequest message. */ +void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, int rnti); void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len); From 9aee7bf74593eb31917829e58fcf481cfa71e26b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 2 Oct 2023 18:00:30 +0200 Subject: [PATCH 3/6] srb0 rnti --- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index a03f8d3e69..c34fae3cf3 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -45,10 +45,7 @@ static NR_UE_MAC_INST_t *nr_ue_mac_inst; -// TODO: refactor -struct gNB_MAC_INST_s; -typedef struct gNB_MAC_INST_s gNB_MAC_INST; -static void send_srb0_rrc(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *rawUE) +static void send_srb0_rrc(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data) { AssertFatal(sdu_len > 0 && sdu_len < CCCH_SDU_SIZE, "invalid CCCH SDU size %d\n", sdu_len); @@ -68,7 +65,7 @@ static void send_srb0_rrc(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu, sdu_s void send_msg3_rrc_request(module_id_t mod_id, int rnti) { - nr_rlc_activate_srb0(rnti, NULL, NULL, send_srb0_rrc); + nr_rlc_activate_srb0(rnti, NULL, send_srb0_rrc); nr_mac_rrc_msg3_ind(mod_id, rnti); } @@ -98,7 +95,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { int rc = rlc_module_init(0); AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); /* convention: RNTI for SRB0 is 0, as it changes all the time */ - nr_rlc_activate_srb0(0, NULL, NULL, send_srb0_rrc); + nr_rlc_activate_srb0(nr_ue_mac_inst->crnti, NULL, send_srb0_rrc); if (IS_SOFTMODEM_NOS1){ // get default noS1 configuration NR_RadioBearerConfig_t *rbconfig = NULL; From 7157e7fd9a07f96ffaf95bbf1848d6640fb8c4fa Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 Oct 2023 07:34:24 +0200 Subject: [PATCH 4/6] Remove unused fields of NR_RRC_MAC_CCCH_DATA_IND message --- openair2/COMMON/mac_messages_types.h | 6 ------ openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 6 ------ openair2/RRC/NR_UE/rrc_UE.c | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index f20ff5b600..668daad813 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -159,15 +159,9 @@ typedef struct RrcMacCcchDataInd_s { } RrcMacCcchDataInd; typedef struct NRRrcMacCcchDataInd_s { - uint32_t frame; - uint8_t slot; uint16_t rnti; uint32_t sdu_size; uint8_t sdu[CCCH_SDU_SIZE]; - OCTET_STRING_t *du_to_cu_rrc_container; - uint8_t gnb_index; - int CC_id; - uint64_t nr_cellid; } NRRrcMacCcchDataInd; typedef struct RrcMacMcchDataReq_s { diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index c34fae3cf3..3f565a1b17 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -54,12 +54,6 @@ static void send_srb0_rrc(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void memcpy(NR_RRC_MAC_CCCH_DATA_IND(message_p).sdu, sdu, sdu_len); NR_RRC_MAC_CCCH_DATA_IND(message_p).sdu_size = sdu_len; NR_RRC_MAC_CCCH_DATA_IND(message_p).rnti = rnti; - NR_RRC_MAC_CCCH_DATA_IND(message_p).gnb_index = 0; - NR_RRC_MAC_CCCH_DATA_IND(message_p).frame = 0; - NR_RRC_MAC_CCCH_DATA_IND(message_p).slot = 0; - NR_RRC_MAC_CCCH_DATA_IND(message_p).du_to_cu_rrc_container = NULL; - NR_RRC_MAC_CCCH_DATA_IND(message_p).CC_id = 0; - NR_RRC_MAC_CCCH_DATA_IND(message_p).nr_cellid = 0; itti_send_msg_to_task(TASK_RRC_NRUE, 0, message_p); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 28dfebafa8..709ffa50e4 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1818,7 +1818,7 @@ void *rrc_nrue_task(void *args_p) nr_rrc_ue_decode_ccch(&ctxt, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); + /* gNB_index = */ 0); break; /* PDCP messages */ From 91a30e9a2acb5c7537f14dcac0a31ec3463308d3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 Oct 2023 07:37:52 +0200 Subject: [PATCH 5/6] Correct return type of do_RRCSetupRequest() --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 3 ++- openair2/RRC/NR/MESSAGES/asn1_msg.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 2e3e00f12d..3093298005 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -772,7 +772,8 @@ int16_t do_RRCReconfiguration(const gNB_RRC_UE_t *UE, } -uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv) { +int do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv) +{ asn_enc_rval_t enc_rval; uint8_t buf[5],buf2=0; NR_UL_CCCH_Message_t ul_ccch_msg; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 5bd932ffd4..737f65cb85 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -117,7 +117,7 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS); -uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv); +int do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer, size_t buffer_size, uint8_t *rv); uint8_t do_NR_RRCReconfigurationComplete_for_nsa(uint8_t *buffer, size_t buffer_size, NR_RRC_TransactionIdentifier_t Transaction_id); From 79cd1891600426beb0c67c2cacd918999847facf Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 3 Oct 2023 18:58:16 +0200 Subject: [PATCH 6/6] fix sim compilation --- openair1/SIMULATION/NR_PHY/nr_dummy_functions.c | 2 ++ openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 6d3948974d..bf1a60faf8 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -32,6 +32,8 @@ void nr_mac_rrc_sync_ind(const module_id_t module_id, const frame_t frame, const bool in_sync) {} +void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti) {} + void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) {} void rrc_data_ind(const protocol_ctxt_t *const ctxt_pP, diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 3f565a1b17..b4ec1cb9eb 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -88,7 +88,6 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { nr_rrc_mac_config_req_scg(0, 0, rrc_inst->scell_group_config); int rc = rlc_module_init(0); AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - /* convention: RNTI for SRB0 is 0, as it changes all the time */ nr_rlc_activate_srb0(nr_ue_mac_inst->crnti, NULL, send_srb0_rrc); if (IS_SOFTMODEM_NOS1){ // get default noS1 configuration