diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 46b6397cdf..b1624126bb 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -516,7 +516,7 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - if(rlc_toadd_list) { + if (rlc_toadd_list) { for (int i = 0; i < rlc_toadd_list->list.count; i++) { NR_RLC_BearerConfig_t *rlc_bearer = rlc_toadd_list->list.array[i]; int id = rlc_bearer->logicalChannelIdentity - 1; @@ -525,7 +525,7 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, } if (rlc_torelease_list) { for (int i = 0; i < rlc_torelease_list->list.count; i++) { - if(rlc_torelease_list->list.array[i]) { + if (rlc_torelease_list->list.array[i]) { int id = *rlc_torelease_list->list.array[i] - 1; mac->active_RLC_bearer[id] = false; } @@ -533,7 +533,6 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, } } - void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommonSIB_t *scc, NR_CellGroupConfig_t *cell_group_config) diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 3f540f5b13..40488d458a 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -51,7 +51,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { //LOG_I(MAC, "[MAIN] init UE MAC functions \n"); //init mac here - nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t), NB_NR_UE_MAC_INST); + nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(NB_NR_UE_MAC_INST, sizeof(NR_UE_MAC_INST_t)); for (int j = 0; j < NB_NR_UE_MAC_INST; j++) nr_ue_init_mac(j); @@ -80,6 +80,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { nr_rlc_add_drb(nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list; rlc_toadd_list.list.count = 1; + rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t)); rlc_toadd_list.list.array[0] = rlc_rbconfig; nr_rrc_mac_config_req_ue_logicalChannelBearer(0, &rlc_toadd_list, NULL); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 334462bb1b..6a8a4c213d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1211,10 +1211,13 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t */ { bsr_regular_triggered = true; - LOG_D(NR_MAC, "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d slot %d\n", - module_idP, lcid, + LOG_D(NR_MAC, + "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d slot %d\n", + module_idP, + lcid, mac->scheduling_info.LCGID[lcid - 1], - frameP, slotP); + frameP, + slotP); break; } } @@ -2687,13 +2690,13 @@ Update the following in mac_ce_p: bsr_t */ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, - int CC_id, - frame_t frameP, - sub_frame_t subframe, - uint8_t gNB_index, - uint8_t *ulsch_buffer, - uint16_t buflen, - NR_UE_MAC_CE_INFO *mac_ce_p) + int CC_id, + frame_t frameP, + sub_frame_t subframe, + uint8_t gNB_index, + uint8_t *ulsch_buffer, + uint16_t buflen, + NR_UE_MAC_CE_INFO *mac_ce_p) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); @@ -2896,7 +2899,9 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, continue; buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size); - LOG_D(NR_MAC, "[UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header len %d bytes, buflen_remain %d bytes)\n", + LOG_D(NR_MAC, + "[UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header len %d " + "bytes, buflen_remain %d bytes)\n", module_idP, frameP, subframe, @@ -2907,7 +2912,6 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, buflen_remain); while (buflen_remain > 0) { - // Pointer used to build the MAC sub-PDU headers in the ULSCH buffer for each SDU NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) pdu; @@ -2925,21 +2929,23 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, 0, 0); - AssertFatal(buflen_remain >= sdu_length, "LCID = 0x%02x RLC has segmented %d bytes but MAC has max %d remaining bytes\n", + AssertFatal(buflen_remain >= sdu_length, + "LCID = 0x%02x RLC has segmented %d bytes but MAC has max %d remaining bytes\n", lcid, sdu_length, buflen_remain); if (sdu_length > 0) { - - LOG_D(NR_MAC, "[UE %d] [%d.%d] UL-DXCH -> ULSCH, Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID 0x%02x (buflen (TBS) %d bytes)\n", - module_idP, - frameP, - subframe, - num_sdus + 1, - sdu_length, - lcid, - buflen); + LOG_D(NR_MAC, + "[UE %d] [%d.%d] UL-DXCH -> ULSCH, Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID 0x%02x " + "(buflen (TBS) %d bytes)\n", + module_idP, + frameP, + subframe, + num_sdus + 1, + sdu_length, + lcid, + buflen); header->R = 0; header->F = 1; @@ -2969,9 +2975,13 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, //Update Buffer remain and BSR bytes after transmission mac->scheduling_info.LCID_buffer_remain[lcid - 1] -= sdu_length; - mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid- 1]] -= sdu_length; - LOG_D(NR_MAC, "[UE %d] Update BSR [%d.%d] BSR_bytes for LCG%d=%d\n", - module_idP, frameP, subframe, mac->scheduling_info.LCGID[lcid - 1], + mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid - 1]] -= sdu_length; + LOG_D(NR_MAC, + "[UE %d] Update BSR [%d.%d] BSR_bytes for LCG%d=%d\n", + module_idP, + frameP, + subframe, + mac->scheduling_info.LCGID[lcid - 1], mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid - 1]]); if (mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid - 1]] < 0) mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid - 1]] = 0; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.c index 9e0abbc83d..c7c91a38a0 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.c @@ -32,8 +32,7 @@ void e1_add_drb(int is_gnb, unsigned char *ciphering_key, unsigned char *integrity_key) { - add_drb(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); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 385ef15a16..6e04300f91 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -770,14 +770,19 @@ void add_srb(int is_gnb, int srb_id = s->srb_Identity; int t_Reordering = -1; // infinity as per default SRB configuration in 9.2.1 of 38.331 - if (s->pdcp_Config != NULL && - s->pdcp_Config->t_Reordering != NULL) + if (s->pdcp_Config != NULL && s->pdcp_Config->t_Reordering != NULL) t_Reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering); nr_pdcp_manager_lock(nr_pdcp_ue_manager); ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rntiMaybeUEid); if (ue->srb[srb_id-1] != NULL) { - LOG_E(PDCP, "%s:%d:%s: warning SRB %d already exist for UE ID/RNTI %ld, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rntiMaybeUEid); + LOG_E(PDCP, + "%s:%d:%s: warning SRB %d already exist for UE ID/RNTI %ld, do nothing\n", + __FILE__, + __LINE__, + __FUNCTION__, + srb_id, + rntiMaybeUEid); } else { pdcp_srb = new_nr_pdcp_entity(NR_PDCP_SRB, is_gnb, srb_id, 0, false, false, // sdap parameters @@ -794,7 +799,8 @@ void add_srb(int is_gnb, nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } -void add_drb(int is_gnb, ue_id_t rntiMaybeUEid, +void add_drb(int is_gnb, + ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, @@ -912,7 +918,13 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag, { if (drb2add_list != NULL) { for (int i = 0; i < drb2add_list->list.count; i++) { - add_drb(enb_flag, rntiMaybeUEid, drb2add_list->list.array[i], 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"); @@ -1045,9 +1057,7 @@ bool nr_pdcp_data_req_srb(ue_id_t ue_id, return 1; } -void nr_pdcp_reconfigure_srb(ue_id_t ue_id, - int srb_id, - long t_Reordering) +void nr_pdcp_reconfigure_srb(ue_id_t ue_id, int srb_id, long t_Reordering) { nr_pdcp_manager_lock(nr_pdcp_ue_manager); nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id); @@ -1057,9 +1067,7 @@ void nr_pdcp_reconfigure_srb(ue_id_t ue_id, nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } -void nr_pdcp_reconfigure_drb(ue_id_t ue_id, - int drb_id, - long t_Reordering) +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 diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h index 944f42fe8b..fac0d8869c 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h @@ -53,7 +53,8 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag, uint8_t *const kUPenc, uint8_t *const kUPint); -void add_drb(int is_gnb, ue_id_t rntiMaybeUEid, +void add_drb(int is_gnb, + ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, @@ -65,12 +66,8 @@ void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid); bool nr_pdcp_remove_UE(ue_id_t ue_id); 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 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, diff --git a/openair2/LAYER2/nr_rlc/asn1_utils.c b/openair2/LAYER2/nr_rlc/asn1_utils.c index 6b6a179e20..999cb79a52 100644 --- a/openair2/LAYER2/nr_rlc/asn1_utils.c +++ b/openair2/LAYER2/nr_rlc/asn1_utils.c @@ -67,7 +67,7 @@ int decode_poll_pdu(int v) { static const int tab[24] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 6144, - 8192, 12288, 16384, 20480, 24576, 28672, 32768, 40960, 49152, 57344, 65536, - 1 /* -1 means infinity */ + 8192, 12288, 16384, 20480, 24576, 28672, 32768, 40960, 49152, 57344, 65536, -1 /* -1 means infinity */ }; if (v < 0 || v > 23) { diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c index 7894deb194..0e07e14fc9 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c @@ -244,9 +244,7 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm( return (nr_rlc_entity_t *)ret; } -void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, - int t_reassembly, - int *sn_field_length) +void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, int t_reassembly, int *sn_field_length) { nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity; entity->t_reassembly = t_reassembly; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h index e572786bbb..dc0bf4907c 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h @@ -176,9 +176,7 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm( char *buf, int size), void *deliver_sdu_data); -void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, - int t_reassembly, - int *sn_field_length); +void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, int t_reassembly, int *sn_field_length); void nr_rlc_entity_am_reconfigure(nr_rlc_entity_t *_entity, int t_poll_retransmit, diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index d5bff30ff1..ff9d2f0213 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -71,38 +71,22 @@ static nr_rlc_entity_t *get_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_i } } -void nr_release_rlc_entity(int rnti, - logical_chan_id_t channel_id) +void nr_release_rlc_entity(int rnti, logical_chan_id_t channel_id) { nr_rlc_manager_lock(nr_rlc_ue_manager); nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); if (channel_id == 0) { if (ue->srb0 != NULL) { free(ue->srb0->deliver_sdu_data); - ue->srb0->delete(ue->srb0); - } + ue->srb0->delete (ue->srb0); + } else + LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", channel_id); + } else { + nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, channel_id); + if (rb) + rb->delete(rb); else - LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", - channel_id); - } - else { - nr_rlc_rb_t *rb = &ue->lcid2rb[channel_id - 1]; - if (rb->type == NR_RLC_SRB) { - if (ue->srb[rb->choice.srb_id - 1] != NULL) - ue->srb[rb->choice.srb_id - 1]->delete(ue->srb[rb->choice.srb_id - 1]); - else - LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", - channel_id); - } - else { - AssertFatal(rb->type == NR_RLC_DRB, - "Invalid RB type\n"); - if (ue->drb[rb->choice.drb_id - 1] != NULL) - ue->drb[rb->choice.drb_id - 1]->delete(ue->drb[rb->choice.drb_id - 1]); - else - LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", - channel_id); - } + LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", channel_id); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -623,7 +607,7 @@ void nr_rlc_reestablish_entity(int rnti, int lc_id) nr_rlc_manager_lock(nr_rlc_ue_manager); nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); - if(ue == NULL) + if (ue == NULL) LOG_E(RLC, "RLC instance for the given UE was not found \n"); nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, lc_id); @@ -632,16 +616,12 @@ void nr_rlc_reestablish_entity(int rnti, int lc_id) LOG_D(RLC, "RB found! (channel ID %d) \n", lc_id); rb->reestablishment(rb); } else { - LOG_E(RLC, "no RLC entity found (channel ID %d) for reestablishment\n", - lc_id); + LOG_E(RLC, "no RLC entity found (channel ID %d) for reestablishment\n", lc_id); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } -void nr_rlc_reconfigure_entity(int rnti, - int lc_id, - struct NR_RLC_Config *rlc_Config, - struct NR_LogicalChannelConfig *lc_Config) +void nr_rlc_reconfigure_entity(int rnti, int lc_id, struct NR_RLC_Config *rlc_Config, struct NR_LogicalChannelConfig *lc_Config) { nr_rlc_manager_lock(nr_rlc_ue_manager); nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); @@ -651,16 +631,14 @@ void nr_rlc_reconfigure_entity(int rnti, nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, lc_id); if (lc_Config) { - if(lc_Config->ul_SpecificParameters && - lc_Config->ul_SpecificParameters->logicalChannelGroup) - AssertFatal(*lc_Config->ul_SpecificParameters->logicalChannelGroup == 0, - "LCG %ld not supported\n", + if (lc_Config->ul_SpecificParameters && lc_Config->ul_SpecificParameters->logicalChannelGroup) + AssertFatal(*lc_Config->ul_SpecificParameters->logicalChannelGroup < 2, + "LCG %ld not supported as per limitation when creating RBs\n", *lc_Config->ul_SpecificParameters->logicalChannelGroup); } if (rlc_Config) { if (rb->stats.mode == NR_RLC_AM) { - AssertFatal(rlc_Config->present == NR_RLC_Config_PR_am, - "Invalid RLC Config type\n"); + AssertFatal(rlc_Config->present == NR_RLC_Config_PR_am, "Invalid RLC Config type\n"); struct NR_RLC_Config__am *am = rlc_Config->choice.am; int t_reassembly = decode_t_reassembly(am->dl_AM_RLC.t_Reassembly); int t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit); @@ -668,20 +646,18 @@ void nr_rlc_reconfigure_entity(int rnti, int poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU); int poll_byte = decode_poll_byte(am->ul_AM_RLC.pollByte); int max_retx_threshold = decode_max_retx_threshold(am->ul_AM_RLC.maxRetxThreshold); + int _sn_field_length; int *sn_field_length = NULL; if (am->dl_AM_RLC.sn_FieldLength) { - AssertFatal(am->ul_AM_RLC.sn_FieldLength != NULL, - "Cannot handle different sn_FieldLength for DL and UL\n"); + AssertFatal(am->ul_AM_RLC.sn_FieldLength != NULL, "Cannot handle different sn_FieldLength for DL and UL\n"); if (am->ul_AM_RLC.sn_FieldLength) { AssertFatal(*am->dl_AM_RLC.sn_FieldLength == *am->ul_AM_RLC.sn_FieldLength, "Cannot handle different sn_FieldLength for DL and UL\n"); - sn_field_length = calloc(1, sizeof(*sn_field_length)); - *sn_field_length = decode_sn_field_length_am(*am->dl_AM_RLC.sn_FieldLength); + _sn_field_length = decode_sn_field_length_am(*am->dl_AM_RLC.sn_FieldLength); + sn_field_length = &_sn_field_length; } - } - else - AssertFatal(am->ul_AM_RLC.sn_FieldLength == NULL, - "Cannot handle different sn_FieldLength for DL and UL\n"); + } else + AssertFatal(am->ul_AM_RLC.sn_FieldLength == NULL, "Cannot handle different sn_FieldLength for DL and UL\n"); nr_rlc_entity_am_reconfigure(rb, t_poll_retransmit, t_reassembly, @@ -690,29 +666,23 @@ void nr_rlc_reconfigure_entity(int rnti, poll_byte, max_retx_threshold, sn_field_length); - } - else { // UM - AssertFatal(rlc_Config->present == NR_RLC_Config_PR_um_Bi_Directional, - "Invalid RLC Config type\n"); + } else { // UM + AssertFatal(rlc_Config->present == NR_RLC_Config_PR_um_Bi_Directional, "Invalid RLC Config type\n"); struct NR_RLC_Config__um_Bi_Directional *um = rlc_Config->choice.um_Bi_Directional; int t_reassembly = decode_t_reassembly(um->dl_UM_RLC.t_Reassembly); + int _sn_field_length; int *sn_field_length = NULL; if (um->dl_UM_RLC.sn_FieldLength) { - AssertFatal(um->ul_UM_RLC.sn_FieldLength != NULL, - "Cannot handle different sn_FieldLength for DL and UL\n"); + AssertFatal(um->ul_UM_RLC.sn_FieldLength != NULL, "Cannot handle different sn_FieldLength for DL and UL\n"); if (um->ul_UM_RLC.sn_FieldLength) { AssertFatal(*um->dl_UM_RLC.sn_FieldLength == *um->ul_UM_RLC.sn_FieldLength, "Cannot handle different sn_FieldLength for DL and UL\n"); - sn_field_length = calloc(1, sizeof(*sn_field_length)); - *sn_field_length = decode_sn_field_length_um(*um->dl_UM_RLC.sn_FieldLength); + _sn_field_length = decode_sn_field_length_um(*um->dl_UM_RLC.sn_FieldLength); + sn_field_length = &_sn_field_length; } - } - else - AssertFatal(um->ul_UM_RLC.sn_FieldLength == NULL, - "Cannot handle different sn_FieldLength for DL and UL\n"); - nr_rlc_entity_um_reconfigure(rb, - t_reassembly, - sn_field_length); + } else + AssertFatal(um->ul_UM_RLC.sn_FieldLength == NULL, "Cannot handle different sn_FieldLength for DL and UL\n"); + nr_rlc_entity_um_reconfigure(rb, t_reassembly, sn_field_length); } } nr_rlc_manager_unlock(nr_rlc_ue_manager); @@ -736,9 +706,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare AssertFatal(srb_id > 0 && srb_id < 4, "Invalid srb id %d\n", srb_id); - if (l && - l->ul_SpecificParameters && - l->ul_SpecificParameters->logicalChannelGroup) + if (l && l->ul_SpecificParameters && l->ul_SpecificParameters->logicalChannelGroup) logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup; else logical_channel_group = 0; // default value as in 9.2.1 of 38.331 @@ -749,14 +717,13 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare exit(1); } - if (r && - r-> present == NR_RLC_Config_PR_am) { + if (r && r->present == NR_RLC_Config_PR_am) { struct NR_RLC_Config__am *am; am = r->choice.am; t_reassembly = decode_t_reassembly(am->dl_AM_RLC.t_Reassembly); t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit); t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit); - poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU); + poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU); poll_byte = decode_poll_byte(am->ul_AM_RLC.pollByte); max_retx_threshold = decode_max_retx_threshold(am->ul_AM_RLC.maxRetxThreshold); if (*am->dl_AM_RLC.sn_FieldLength != *am->ul_AM_RLC.sn_FieldLength) { @@ -764,8 +731,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare exit(1); } sn_field_length = decode_sn_field_length_am(*am->dl_AM_RLC.sn_FieldLength); - } - else { + } else { // default values as in 9.2.1 of 38.331 t_reassembly = 35; t_status_prohibit = 0; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index f7154f2fa2..c40e5c923a 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -51,13 +51,9 @@ bool nr_rlc_update_rnti(int from_rnti, int to_rnti); /* test function for CI to trigger reestablishments */ void nr_rlc_test_trigger_reestablishment(int rnti); -void nr_release_rlc_entity(int rnti, - logical_chan_id_t channel_id); +void nr_release_rlc_entity(int rnti, logical_chan_id_t channel_id); -void nr_rlc_reconfigure_entity(int rnti, - int lc_id, - struct NR_RLC_Config *rlc_Config, - struct NR_LogicalChannelConfig *lc_Config); +void nr_rlc_reconfigure_entity(int rnti, int lc_id, struct NR_RLC_Config *rlc_Config, struct NR_LogicalChannelConfig *lc_Config); int nr_rlc_get_available_tx_space( const rnti_t rntiP, diff --git a/openair2/RRC/NR/nr_rrc_common.h b/openair2/RRC/NR/nr_rrc_common.h index fcf756174c..1505e71924 100644 --- a/openair2/RRC/NR/nr_rrc_common.h +++ b/openair2/RRC/NR/nr_rrc_common.h @@ -46,17 +46,17 @@ typedef enum UE_STATE_NR_e { } NR_UE_STATE_t; typedef struct { - unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ - unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ - uint8_t Delay_class; /*!< \brief Delay class offered by MAC layer scheduling*/ - uint8_t Target_bler; /*!< \brief Target Average Transport Block Error rate*/ - uint8_t Lchan_t; /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/ + unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ + unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ + uint8_t Delay_class; /*!< \brief Delay class offered by MAC layer scheduling*/ + uint8_t Target_bler; /*!< \brief Target Average Transport Block Error rate*/ + uint8_t Lchan_t; /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/ } __attribute__ ((__packed__)) NR_LCHAN_DESC; typedef struct RB_INFO_NR_s { - uint16_t Rb_id; //=Lchan_id + uint16_t Rb_id; //=Lchan_id NR_LCHAN_DESC Lchan_desc[2]; //MAC_MEAS_REQ_ENTRY *Meas_entry; //may not needed for NB-IoT } NR_RB_INFO; diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 24961e509c..1cfb8068d3 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -133,11 +133,12 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, switch(Srb_id) { case CCCH: - LOG_D(NR_RRC, "nr_mac_rrc_data_req_ue: Payload size = %i\n", + 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++) { + 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]); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 5408a092c5..0116017433 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -114,8 +114,7 @@ nr_rrc_ue_generate_rrcReestablishmentComplete( mui_t nr_rrc_mui=0; // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded) -int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, - NR_CellGroupConfig_t *cell_group_config) +int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, NR_CellGroupConfig_t *cell_group_config) { if(NR_UE_rrc_inst[module_id].scell_group_config == NULL) NR_UE_rrc_inst[module_id].scell_group_config = cell_group_config; @@ -148,11 +147,14 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR NR_CellGroupConfig_t *cellGroupConfig = NULL; int size = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->size; uint8_t *buffer = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf; - asn_dec_rval_t dec_rval = uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, //might be added prefix later - (void **)&cellGroupConfig, - (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf, - size, 0, 0); + asn_dec_rval_t dec_rval = + uper_decode(NULL, + &asn_DEF_NR_CellGroupConfig, // might be added prefix later + (void **)&cellGroupConfig, + (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf, + size, + 0, + 0); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { LOG_E(NR_RRC, "NR_CellGroupConfig decode error\n"); for (int i = 0; i < size; i++) @@ -163,10 +165,10 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR return -1; } - if(get_softmodem_params()->sa || get_softmodem_params()->nsa) + if (get_softmodem_params()->sa || get_softmodem_params()->nsa) nr_rrc_manage_rlc_bearers(cellGroupConfig, &NR_UE_rrc_inst[module_id], 0, module_id, NR_UE_rrc_inst[module_id].rnti); - if(get_softmodem_params()->sa || get_softmodem_params()->nsa) { + if (get_softmodem_params()->sa || get_softmodem_params()->nsa) { if (LOG_DEBUGFLAG(DEBUG_ASN1)) { xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) cellGroupConfig); } @@ -186,8 +188,7 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR if (get_softmodem_params()->nsa) { nr_rrc_mac_config_req_scg(0, 0, cellGroupConfig); } - } - else + } else nr_rrc_ue_decode_secondary_cellgroup_config(module_id, cellGroupConfig); } if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig != NULL){ @@ -215,15 +216,12 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR return 0; } - - int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config){ return 0; } - -void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message,int msg_len) +void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len) { module_id_t module_id=0; // TODO switch (nsa_message_type) { @@ -284,7 +282,6 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, AssertFatal(1==0,"Unknown message %d\n",nsa_message_type); break; } - } NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* reconfig_file, char* rbconfig_file) @@ -338,9 +335,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* reconfig_fi strerror(errno)); msg_len=fread(buffer,1,1024,fd); fclose(fd); - process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, buffer,msg_len); - } - else if (get_softmodem_params()->nsa) { + process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, buffer,msg_len); + } else if (get_softmodem_params()->nsa) { LOG_D(NR_RRC, "In NSA mode \n"); } @@ -759,7 +755,7 @@ void nr_rrc_manage_rlc_bearers(const NR_CellGroupConfig_t *cellGroupConfig, module_id_t module_id, int rnti) { - if(cellGroupConfig->rlc_BearerToReleaseList != NULL) { + if (cellGroupConfig->rlc_BearerToReleaseList != NULL) { for (int i = 0; i < cellGroupConfig->rlc_BearerToReleaseList->list.count; i++) { NR_LogicalChannelIdentity_t *lcid = cellGroupConfig->rlc_BearerToReleaseList->list.array[i]; AssertFatal(lcid, "LogicalChannelIdentity shouldn't be null here\n"); @@ -767,20 +763,15 @@ void nr_rrc_manage_rlc_bearers(const NR_CellGroupConfig_t *cellGroupConfig, } } - if(cellGroupConfig->rlc_BearerToAddModList != NULL) { - //TODO (perform the RLC bearer addition/modification as specified in 5.3.5.5.4) + if (cellGroupConfig->rlc_BearerToAddModList != NULL) { for (int i = 0; i < cellGroupConfig->rlc_BearerToAddModList->list.count; i++) { NR_RLC_BearerConfig_t *rlc_bearer = cellGroupConfig->rlc_BearerToAddModList->list.array[i]; NR_LogicalChannelIdentity_t lcid = rlc_bearer->logicalChannelIdentity; if (rrc->active_RLC_entity[gNB_index][lcid]) { if (rlc_bearer->reestablishRLC) nr_rlc_reestablish_entity(rnti, lcid); - nr_rlc_reconfigure_entity(rnti, - lcid, - rlc_bearer->rlc_Config, - rlc_bearer->mac_LogicalChannelConfig); - } - else { + nr_rlc_reconfigure_entity(rnti, lcid, rlc_bearer->rlc_Config, rlc_bearer->mac_LogicalChannelConfig); + } else { rrc->active_RLC_entity[gNB_index][lcid] = true; AssertFatal(rlc_bearer->servedRadioBearer, "servedRadioBearer mandatory in case of setup\n"); AssertFatal(rlc_bearer->servedRadioBearer->present != NR_RLC_BearerConfig__servedRadioBearer_PR_NOTHING, @@ -788,8 +779,7 @@ void nr_rrc_manage_rlc_bearers(const NR_CellGroupConfig_t *cellGroupConfig, if (rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity) { NR_SRB_Identity_t srb_id = rlc_bearer->servedRadioBearer->choice.srb_Identity; nr_rlc_add_srb(rnti, srb_id, rlc_bearer); - } - else { // DRB + } else { // DRB NR_DRB_Identity_t drb_id = rlc_bearer->servedRadioBearer->choice.drb_Identity; nr_rlc_add_drb(rnti, drb_id, rlc_bearer); } @@ -955,11 +945,16 @@ static void rrc_ue_generate_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p size = do_RRCSetupComplete(ctxt_pP->module_id, buffer, sizeof(buffer), Transaction_id, sel_plmn_id, nas_msg_length, nas_msg); - LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", - ctxt_pP->module_id,ctxt_pP->frame, size, gNB_index); + LOG_I(NR_RRC, + "[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", + ctxt_pP->module_id, + ctxt_pP->frame, + size, + gNB_index); int srb_id = 1; // RRC setup complete on SRB1 LOG_D(NR_RRC, - "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCSetupComplete to gNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", + "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCSetupComplete to gNB %d MUI %d) --->][PDCP][MOD %02d][RB " + "%02d]\n", ctxt_pP->frame, ctxt_pP->module_id, size, @@ -968,35 +963,41 @@ static void rrc_ue_generate_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p ctxt_pP->module_id + NB_eNB_INST, srb_id); - 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 ) +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) { NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; NR_DL_CCCH_Message_t *dl_ccch_msg=NULL; asn_dec_rval_t dec_rval; int rval=0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_IN); - LOG_D(RRC,"[NR UE%d] Decoding DL-CCCH message (%d bytes), State %d\n", + 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, 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); + 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); -// } + // 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,ctxt_pP->frame,dec_rval.consumed); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); - return -1; + 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, + ctxt_pP->frame, + dec_rval.consumed); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); + return -1; } if (dl_ccch_msg->message.present == NR_DL_CCCH_MessageType_PR_c1) { @@ -1279,7 +1280,13 @@ void nr_rrc_ue_process_securityModeCommand(const protocol_ctxt_t *const ctxt_pP, // for the UE to declare AS security to be activated ue_rrc->as_security_activated = true; int srb_id = 1; // SecurityModeComplete in SRB1 - nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, srb_id, nr_rrc_mui++, (enc_rval.encoded + 7) / 8, buffer, deliver_pdu_srb_rlc, NULL); + nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, + srb_id, + nr_rrc_mui++, + (enc_rval.encoded + 7) / 8, + buffer, + deliver_pdu_srb_rlc, + NULL); } else LOG_W(NR_RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", securityModeCommand->criticalExtensions.present); @@ -1289,76 +1296,37 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB { 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) { + 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 +#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]); + rv[i] = i; +#else + rv[i] = taus() & 0xff; +#endif + LOG_T(NR_RRC, "%x.", rv[i]); } - LOG_T(NR_RRC,"\n"); + 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); + (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, "%x.", Srb0->srb_buffers.Tx_buffer.Payload[i]); - LOG_T(NR_RRC,"\n"); + LOG_T(NR_RRC, "\n"); } } -int32_t nr_rrc_ue_establish_drb(module_id_t ue_mod_idP, - frame_t frameP, - uint8_t gNB_index, - NR_DRB_ToAddMod_t *DRB_config) -{ - // add descriptor from RRC PDU - int oip_ifup = 0, ip_addr_offset3 = 0, ip_addr_offset4 = 0; - /* avoid gcc warnings */ - (void)oip_ifup; - (void)ip_addr_offset3; - (void)ip_addr_offset4; - LOG_I(NR_RRC,"[UE %d] Frame %d: processing RRCReconfiguration: reconfiguring DRB %ld\n", - ue_mod_idP, frameP, DRB_config->drb_Identity); - - if(!get_softmodem_params()->sa) { - ip_addr_offset3 = 0; - ip_addr_offset4 = 1; - LOG_I(OIP, "[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, - ip_addr_offset3+ue_mod_idP+1, ip_addr_offset4+ue_mod_idP+1); - oip_ifup = nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id - UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet - ip_addr_offset4+ue_mod_idP+1, // fourth_octet - "oip"); // interface suffix (when using kernel module) - - if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB - LOG_I(OIP, "[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", - ue_mod_idP, - ip_addr_offset3+ue_mod_idP, - (long int)((gNB_index * NR_maxDRB) + DRB_config->drb_Identity)); - rb_conf_ipv4(0,//add - ue_mod_idP,//cx align with the UE index - ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index - (gNB_index * NR_maxDRB) + DRB_config->drb_Identity,//rb - 0,//dscp - ipv4_address(ip_addr_offset3+ue_mod_idP+1, ip_addr_offset4+ue_mod_idP+1),//saddr - ipv4_address(ip_addr_offset3+ue_mod_idP+1, gNB_index+1));//daddr - LOG_D(NR_RRC,"[UE %d] State = Attached (gNB %d)\n",ue_mod_idP,gNB_index); - } - } - return(0); -} - //----------------------------------------------------------------------------- void nr_rrc_ue_process_measConfig( @@ -1483,103 +1451,94 @@ int32_t nr_rrc_ue_establish_drb(module_id_t ue_mod_idP, } } + void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP, + const uint8_t gNB_index, + NR_RadioBearerConfig_t *const radioBearerConfig) + { + if (LOG_DEBUGFLAG(DEBUG_ASN1)) + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *)radioBearerConfig); -void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP, - const uint8_t gNB_index, - NR_RadioBearerConfig_t *const radioBearerConfig) -{ - if (LOG_DEBUGFLAG(DEBUG_ASN1)) - xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)radioBearerConfig); + NR_UE_RRC_INST_t *ue_rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; + AssertFatal(radioBearerConfig->srb3_ToRelease == NULL, "Release of SRB3 not yet implemented\n"); - NR_UE_RRC_INST_t *ue_rrc = &NR_UE_rrc_inst[ctxt_pP->module_id]; - AssertFatal(radioBearerConfig->srb3_ToRelease == NULL, "Release of SRB3 not yet implemented\n"); + uint8_t kRRCenc[16] = {0}; + uint8_t kRRCint[16] = {0}; + if (ue_rrc->as_security_activated) { + if (radioBearerConfig->securityConfig != NULL) { + // When the field is not included, continue to use the currently configured keyToUse + if (radioBearerConfig->securityConfig->keyToUse) { + AssertFatal(*radioBearerConfig->securityConfig->keyToUse == NR_SecurityConfig__keyToUse_master, + "Secondary key usage seems not to be implemented\n"); + ue_rrc->keyToUse = *radioBearerConfig->securityConfig->keyToUse; + } + // When the field is not included, continue to use the currently configured security algorithm + if (radioBearerConfig->securityConfig->securityAlgorithmConfig) { + ue_rrc->cipheringAlgorithm = radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; + ue_rrc->integrityProtAlgorithm = *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; + } + } + nr_derive_key(RRC_ENC_ALG, + NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, + kRRCenc); + nr_derive_key(RRC_INT_ALG, + NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, + NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, + kRRCint); + } - uint8_t kRRCenc[16] = {0}; - uint8_t kRRCint[16] = {0}; - if (ue_rrc->as_security_activated) { - if (radioBearerConfig->securityConfig != NULL) { - // When the field is not included, continue to use the currently configured keyToUse - if (radioBearerConfig->securityConfig->keyToUse) { - AssertFatal(*radioBearerConfig->securityConfig->keyToUse == NR_SecurityConfig__keyToUse_master, - "Secondary key usage seems not to be implemented\n"); - ue_rrc->keyToUse = *radioBearerConfig->securityConfig->keyToUse; - } - // When the field is not included, continue to use the currently configured security algorithm - if (radioBearerConfig->securityConfig->securityAlgorithmConfig) { - ue_rrc->cipheringAlgorithm = radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; - ue_rrc->integrityProtAlgorithm = *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; - } - } - nr_derive_key(RRC_ENC_ALG, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, - kRRCenc); - nr_derive_key(RRC_INT_ALG, - NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, - NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, - kRRCint); - } + if (radioBearerConfig->srb_ToAddModList != NULL) { + for (int cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) { + struct NR_SRB_ToAddMod *srb = radioBearerConfig->srb_ToAddModList->list.array[cnt]; + NR_UE_RRC_SRB_INFO_t *Srb_info = &ue_rrc->Srb[gNB_index][srb->srb_Identity]; + if (Srb_info->status == RB_NOT_PRESENT) + add_srb(ctxt_pP->enb_flag, + ctxt_pP->rntiMaybeUEid, + radioBearerConfig->srb_ToAddModList->list.array[cnt], + ue_rrc->cipheringAlgorithm, + ue_rrc->integrityProtAlgorithm, + kRRCenc, + kRRCint); + else { + AssertFatal(srb->discardOnPDCP == NULL, "discardOnPDCP not yet implemented\n"); + AssertFatal(srb->reestablishPDCP == NULL, "reestablishPDCP not yet implemented\n"); + if (srb->pdcp_Config && srb->pdcp_Config->t_Reordering) + nr_pdcp_reconfigure_srb(ctxt_pP->rntiMaybeUEid, srb->srb_Identity, *srb->pdcp_Config->t_Reordering); + } + Srb_info->status = RB_ESTABLISHED; + } + } - if (radioBearerConfig->srb_ToAddModList != NULL) { - for (int cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) { - struct NR_SRB_ToAddMod *srb = radioBearerConfig->srb_ToAddModList->list.array[cnt]; - NR_UE_RRC_SRB_INFO_t *Srb_info = &ue_rrc->Srb[gNB_index][srb->srb_Identity]; - if (Srb_info->status == RB_NOT_PRESENT) - add_srb(ctxt_pP->enb_flag, - ctxt_pP->rntiMaybeUEid, - radioBearerConfig->srb_ToAddModList->list.array[cnt], - ue_rrc->cipheringAlgorithm, - ue_rrc->integrityProtAlgorithm, - kRRCenc, - kRRCint); - else { - AssertFatal(srb->discardOnPDCP, "discardOnPDCP not yet implemented\n"); - AssertFatal(srb->reestablishPDCP, "reestablishPDCP not yet implemented\n"); - if(srb->pdcp_Config && srb->pdcp_Config->t_Reordering) - nr_pdcp_reconfigure_srb(ctxt_pP->rntiMaybeUEid, - srb->srb_Identity, - *srb->pdcp_Config->t_Reordering); - } - Srb_info->status = RB_ESTABLISHED; - } - } + AssertFatal(radioBearerConfig->drb_ToReleaseList == NULL, "RB entity release not implemented yet\n"); + // Establish DRBs if present + if (radioBearerConfig->drb_ToAddModList != NULL) { + for (int cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) { + 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 == NULL, "reestablishPDCP not yet implemented\n"); + AssertFatal(drb->recoverPDCP == NULL, "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 == NULL, "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); + } + } + } // drb_ToAddModList // - if (radioBearerConfig->drb_ToReleaseList != NULL) { - // TODO not implemented yet - } - - // Establish DRBs if present - if (radioBearerConfig->drb_ToAddModList != NULL) { - for (int cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) { - 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); - } - } - } // drb_ToAddModList // - - 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); -} + 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); + } //----------------------------------------------------------------------------- static void rrc_ue_process_rrcReconfiguration(const protocol_ctxt_t *const ctxt_pP, @@ -1634,155 +1593,146 @@ void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP, } } - -void nr_rrc_ue_generate_RRCReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, - const uint8_t gNB_index, - const int srb_id, - const uint8_t Transaction_id) -{ - uint8_t buffer[32], size; - size = do_NR_RRCReconfigurationComplete(ctxt_pP, buffer, sizeof(buffer), Transaction_id); - LOG_I(NR_RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCReconfigurationComplete (bytes %d, gNB_index %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, gNB_index); - AssertFatal(srb_id == 1 || srb_id == 3, "Invalid SRB ID %d\n", srb_id); - LOG_D(RLC, - "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCReconfigurationComplete to gNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n", - ctxt_pP->frame, - UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), - size, - gNB_index, - nr_rrc_mui, - UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), - srb_id); + void nr_rrc_ue_generate_RRCReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, + const uint8_t gNB_index, + const int srb_id, + const uint8_t Transaction_id) + { + uint8_t buffer[32], size; + size = do_NR_RRCReconfigurationComplete(ctxt_pP, buffer, sizeof(buffer), Transaction_id); + LOG_I(NR_RRC, + PROTOCOL_RRC_CTXT_UE_FMT + " Logical Channel UL-DCCH (SRB1), Generating RRCReconfigurationComplete (bytes %d, gNB_index %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + gNB_index); + AssertFatal(srb_id == 1 || srb_id == 3, "Invalid SRB ID %d\n", srb_id); + LOG_D(RLC, + "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCReconfigurationComplete to gNB %d MUI %d) " + "--->][PDCP][INST %02d][RB %02d]\n", + ctxt_pP->frame, + UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), + size, + gNB_index, + nr_rrc_mui, + UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), + srb_id); nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, srb_id, nr_rrc_mui++, size, buffer, deliver_pdu_srb_rlc, NULL); } -int nr_rrc_ue_decode_dcch(const protocol_ctxt_t *const ctxt_pP, - const srb_id_t Srb_id, - const uint8_t *const Buffer, - size_t Buffer_size, - const uint8_t gNB_indexP) + int nr_rrc_ue_decode_dcch(const protocol_ctxt_t *const ctxt_pP, + const srb_id_t Srb_id, + const uint8_t *const Buffer, + size_t Buffer_size, + const uint8_t gNB_indexP) -{ - asn_dec_rval_t dec_rval; - NR_DL_DCCH_Message_t *dl_dcch_msg = NULL; - MessageDef *msg_p; + { + asn_dec_rval_t dec_rval; + NR_DL_DCCH_Message_t *dl_dcch_msg = NULL; + MessageDef *msg_p; - if (Srb_id != 1 && Srb_id != 2) { - LOG_E(NR_RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%ld), should not have ...\n", - ctxt_pP->module_id, ctxt_pP->frame, Srb_id); - } + if (Srb_id != 1 && Srb_id != 2) { + LOG_E(NR_RRC, + "[UE %d] Frame %d: Received message on DL-DCCH (SRB%ld), should not have ...\n", + ctxt_pP->module_id, + ctxt_pP->frame, + Srb_id); + } - LOG_D(NR_RRC, "Decoding DL-DCCH Message\n"); - dec_rval = uper_decode(NULL, - &asn_DEF_NR_DL_DCCH_Message, - (void **)&dl_dcch_msg, - Buffer, - Buffer_size, - 0, - 0); + LOG_D(NR_RRC, "Decoding DL-DCCH Message\n"); + dec_rval = uper_decode(NULL, &asn_DEF_NR_DL_DCCH_Message, (void **)&dl_dcch_msg, Buffer, Buffer_size, 0, 0); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(NR_RRC, "Failed to decode DL-DCCH (%zu bytes)\n", dec_rval.consumed); - ASN_STRUCT_FREE(asn_DEF_NR_DL_DCCH_Message, dl_dcch_msg); - return -1; - } + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + LOG_E(NR_RRC, "Failed to decode DL-DCCH (%zu bytes)\n", dec_rval.consumed); + ASN_STRUCT_FREE(asn_DEF_NR_DL_DCCH_Message, dl_dcch_msg); + return -1; + } - if (LOG_DEBUGFLAG(DEBUG_ASN1)) { - xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message,(void *)dl_dcch_msg); - } + if (LOG_DEBUGFLAG(DEBUG_ASN1)) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)dl_dcch_msg); + } - if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { - switch (dl_dcch_msg->message.choice.c1->present) { - case NR_DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(NR_RRC, "Received PR_NOTHING on DL-DCCH-Message\n"); - break; + if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { + switch (dl_dcch_msg->message.choice.c1->present) { + case NR_DL_DCCH_MessageType__c1_PR_NOTHING: + LOG_I(NR_RRC, "Received PR_NOTHING on DL-DCCH-Message\n"); + break; - case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: - { - rrc_ue_process_rrcReconfiguration(ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration, - gNB_indexP); - nr_rrc_ue_generate_RRCReconfigurationComplete(ctxt_pP, - gNB_indexP, - Srb_id, - dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier); - break; - } + case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: { + rrc_ue_process_rrcReconfiguration(ctxt_pP, dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration, gNB_indexP); + nr_rrc_ue_generate_RRCReconfigurationComplete( + ctxt_pP, + gNB_indexP, + Srb_id, + dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration->rrc_TransactionIdentifier); + break; + } - case NR_DL_DCCH_MessageType__c1_PR_rrcResume: - case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: - LOG_I(NR_RRC, "[UE %d] Received RRC Release (gNB %d)\n", - ctxt_pP->module_id, gNB_indexP); + case NR_DL_DCCH_MessageType__c1_PR_rrcResume: + case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: + LOG_I(NR_RRC, "[UE %d] Received RRC Release (gNB %d)\n", ctxt_pP->module_id, gNB_indexP); - msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_CONN_RELEASE_IND); + msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_CONN_RELEASE_IND); - if((dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.present == - NR_RRCRelease__criticalExtensions_PR_rrcRelease) && - (dl_dcch_msg->message.choice.c1->present == NR_DL_DCCH_MessageType__c1_PR_rrcRelease)) { - dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationTimer = - NR_RRCRelease_IEs__deprioritisationReq__deprioritisationTimer_min5; - dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationType = - NR_RRCRelease_IEs__deprioritisationReq__deprioritisationType_frequency; - } + if ((dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.present + == NR_RRCRelease__criticalExtensions_PR_rrcRelease) + && (dl_dcch_msg->message.choice.c1->present == NR_DL_DCCH_MessageType__c1_PR_rrcRelease)) { + dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq + ->deprioritisationTimer = NR_RRCRelease_IEs__deprioritisationReq__deprioritisationTimer_min5; + dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq + ->deprioritisationType = NR_RRCRelease_IEs__deprioritisationReq__deprioritisationType_frequency; + } - itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); - break; - case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(NR_RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", ctxt_pP->module_id,gNB_indexP); - nr_rrc_ue_process_ueCapabilityEnquiry(ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, - gNB_indexP); - break; - case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: - LOG_I(NR_RRC, - "[UE%d] Frame %d : Logical Channel DL-DCCH (SRB1), Received RRCReestablishment\n", - ctxt_pP->module_id, - ctxt_pP->frame); - nr_rrc_ue_generate_rrcReestablishmentComplete(ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.rrcReestablishment, - gNB_indexP); - break; - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: - { - NR_DLInformationTransfer_t *dlInformationTransfer = dl_dcch_msg->message.choice.c1->choice.dlInformationTransfer; + itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); + break; + case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: + LOG_I(NR_RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", ctxt_pP->module_id, gNB_indexP); + nr_rrc_ue_process_ueCapabilityEnquiry(ctxt_pP, dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, gNB_indexP); + break; + case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: + LOG_I(NR_RRC, + "[UE%d] Frame %d : Logical Channel DL-DCCH (SRB1), Received RRCReestablishment\n", + ctxt_pP->module_id, + ctxt_pP->frame); + nr_rrc_ue_generate_rrcReestablishmentComplete(ctxt_pP, + dl_dcch_msg->message.choice.c1->choice.rrcReestablishment, + gNB_indexP); + break; + case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: { + NR_DLInformationTransfer_t *dlInformationTransfer = dl_dcch_msg->message.choice.c1->choice.dlInformationTransfer; - if (dlInformationTransfer->criticalExtensions.present == - NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer) { - /* This message hold a dedicated info NAS payload, forward it to NAS */ - NR_DedicatedNAS_Message_t *dedicatedNAS_Message = - dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message; + if (dlInformationTransfer->criticalExtensions.present + == NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer) { + /* This message hold a dedicated info NAS payload, forward it to NAS */ + NR_DedicatedNAS_Message_t *dedicatedNAS_Message = + dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message; - MessageDef *msg_p; - msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND); - NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ? - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = dedicatedNAS_Message->size; - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = dedicatedNAS_Message->buf; - itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); - } - } - break; - case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: - case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: - case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16: - case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16: - case NR_DL_DCCH_MessageType__c1_PR_spare3: - case NR_DL_DCCH_MessageType__c1_PR_spare2: - case NR_DL_DCCH_MessageType__c1_PR_spare1: - case NR_DL_DCCH_MessageType__c1_PR_counterCheck: - break; - case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(NR_RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", - ctxt_pP->module_id, gNB_indexP); - nr_rrc_ue_process_securityModeCommand(ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.securityModeCommand, - gNB_indexP); - break; - } - } - return 0; -} + MessageDef *msg_p; + msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND); + NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ? + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = dedicatedNAS_Message->size; + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = dedicatedNAS_Message->buf; + itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); + } + } break; + case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: + case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: + case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: + case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16: + case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16: + case NR_DL_DCCH_MessageType__c1_PR_spare3: + case NR_DL_DCCH_MessageType__c1_PR_spare2: + case NR_DL_DCCH_MessageType__c1_PR_spare1: + case NR_DL_DCCH_MessageType__c1_PR_counterCheck: + break; + case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: + LOG_I(NR_RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", ctxt_pP->module_id, gNB_indexP); + nr_rrc_ue_process_securityModeCommand(ctxt_pP, dl_dcch_msg->message.choice.c1->choice.securityModeCommand, gNB_indexP); + break; + } + } + return 0; + } void nr_rrc_handle_ra_indication(unsigned int mod_id, bool ra_succeeded) { @@ -1877,15 +1827,12 @@ void *rrc_nrue_task(void *args_p) 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; + 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); + nr_rrc_ue_decode_ccch(&ctxt, srb0, NR_RRC_MAC_CCCH_DATA_IND(msg_p).gnb_index); break; /* PDCP messages */ @@ -2058,7 +2005,7 @@ void nr_rrc_ue_process_ueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, NR_UECapabilityEnquiry_IEs_t *ueCapabilityEnquiry_ie = UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry; if (get_softmodem_params()->nsa == 1) { - OCTET_STRING_t * requestedFreqBandsNR = ueCapabilityEnquiry_ie->ue_CapabilityEnquiryExt; + OCTET_STRING_t *requestedFreqBandsNR = ueCapabilityEnquiry_ie->ue_CapabilityEnquiryExt; nsa_sendmsg_to_lte_ue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, UE_CAPABILITY_INFO); } // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[ue_mod_idP].UECapability; @@ -2069,8 +2016,10 @@ void nr_rrc_ue_process_ueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, NR_UECapabilityInformation_t *ueCapabilityInformation = ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation; ueCapabilityInformation->criticalExtensions.present = NR_UECapabilityInformation__criticalExtensions_PR_ueCapabilityInformation; - ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation_IEs)); - ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList = CALLOC(1, sizeof(struct NR_UE_CapabilityRAT_ContainerList)); + ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation = + CALLOC(1, sizeof(struct NR_UECapabilityInformation_IEs)); + ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList = + CALLOC(1, sizeof(struct NR_UE_CapabilityRAT_ContainerList)); ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.count = 0; for (int i = 0; i < ueCapabilityEnquiry_ie->ue_CapabilityRAT_RequestList.list.count; i++) { @@ -2085,8 +2034,14 @@ void nr_rrc_ue_process_ueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); } LOG_I(NR_RRC, "UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - int srb_id = 1; //UECapabilityInformation on SRB1 - nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, srb_id, nr_rrc_mui++, (enc_rval.encoded + 7) / 8, buffer, deliver_pdu_srb_rlc, NULL); + int srb_id = 1; // UECapabilityInformation on SRB1 + nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, + srb_id, + nr_rrc_mui++, + (enc_rval.encoded + 7) / 8, + buffer, + deliver_pdu_srb_rlc, + NULL); } } } diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 6b4dc947fb..56d4dffd97 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -178,11 +178,7 @@ typedef enum { IN_SYNC = 1 } nr_sync_msg_t; -typedef enum { - RB_NOT_PRESENT = 0, - RB_ESTABLISHED, - RB_SUSPENDED -} NR_RB_status_t; +typedef enum { RB_NOT_PRESENT = 0, RB_ESTABLISHED, RB_SUSPENDED } NR_RB_status_t; typedef struct NR_UE_RRC_SRB_INFO_s { NR_RB_status_t status; @@ -207,8 +203,8 @@ typedef struct NR_UE_RRC_INST_s { 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]; + 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; uint8_t *UECapability; @@ -220,7 +216,7 @@ typedef struct NR_UE_RRC_INST_s { plmn_t plmnID; - NR_UE_RRC_SI_INFO SInfo[NB_CNX_UE]; + NR_UE_RRC_SI_INFO SInfo[NB_CNX_UE]; NR_MIB_t *mib;