diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 66f9911c8a..fed265b0d6 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -40,6 +40,9 @@ #include "NR_RRCReconfiguration.h" #include "RRC/NR/MESSAGES/asn1_msg.h" +#define SRB1 1 +#define SRB2 2 + void rrc_add_nsa_user(gNB_RRC_INST *rrc, x2ap_ENDC_sgnb_addition_req_t *m, sctp_assoc_t assoc_id); void rrc_add_nsa_user_resp(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const f1ap_ue_context_setup_t *resp); void rrc_release_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e8c0edf441..9a2039ebef 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -270,12 +270,17 @@ unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP) return tmp; } -/** - * @brief Create srb-ToAddModList for RRCSetup and RRCReconfiguration messages -*/ -static NR_SRB_ToAddModList_t *createSRBlist(gNB_RRC_UE_t *ue, bool reestablish) +/** @brief Create srb-ToAddModList for RRCSetup and RRCReconfiguration messages + * @param reestablish bitmap to indicates whether PDCP should be re-established + * for the SRB1 and/or SRB2. For convenience the bitmap is 0-based, with index 1 + * corresponding to SRB1, index 2 to SRB2. 3GPP TS 38.331 RadioBearerConfig + * specifies that PDCP shall be re-established whenever the security key used + * for the radio bearer changes, with some expections for SRB1 (i.e. when resuming + * an RRC connection, or at the first reconfiguration after RRC connection + * reestablishment in NR, do not re-establish PDCP) */ +static NR_SRB_ToAddModList_t *createSRBlist(gNB_RRC_UE_t *ue, uint8_t reestablish) { - if (!ue->Srb[1].Active) { + if (!ue->Srb[SRB1].Active) { LOG_E(NR_RRC, "Call SRB list while SRB1 doesn't exist\n"); return NULL; } @@ -284,9 +289,11 @@ static NR_SRB_ToAddModList_t *createSRBlist(gNB_RRC_UE_t *ue, bool reestablish) if (ue->Srb[i].Active) { asn1cSequenceAdd(list->list, NR_SRB_ToAddMod_t, srb); srb->srb_Identity = i; - /* Set reestablishPDCP only for SRB2 */ - if (reestablish && i == 2) { + /* Based on the bitmap, set reestablishPDCP for SRB1 and SRB2 */ + if ((i == SRB1 || i == SRB2) && (reestablish & (1 << i))) { asn1cCallocOne(srb->reestablishPDCP, NR_SRB_ToAddMod__reestablishPDCP_true); + } else { + DevAssert(!(reestablish & (1 << i))); } } return list; @@ -558,7 +565,7 @@ void free_RRCReconfiguration_params(nr_rrc_reconfig_param_t params) /** @brief Prepare the instance of RRCReconfigurationParams to be pass to RRC encoding */ static nr_rrc_reconfig_param_t get_RRCReconfiguration_params(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, - bool srb_reestablish, + uint8_t srb_reest_bitmap, bool drb_reestablish) { uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); @@ -620,8 +627,9 @@ static nr_rrc_reconfig_param_t get_RRCReconfiguration_params(gNB_RRC_INST *rrc, UE->measConfig = measconfig; // Re-establish PDCP for SRB2 only - NR_SRB_ToAddModList_t *SRBs = createSRBlist(UE, srb_reestablish); + NR_SRB_ToAddModList_t *SRBs = createSRBlist(UE, srb_reest_bitmap); NR_DRB_ToAddModList_t *DRBs = createDRBlist(UE, drb_reestablish); + nr_rrc_reconfig_param_t params = {.cell_group_config = UE->masterCellGroup, .transaction_id = xid, .drb_config_list = DRBs, @@ -662,7 +670,7 @@ static byte_array_t rrc_gNB_encode_RRCReconfiguration(gNB_RRC_INST *rrc, gNB_RRC static void rrc_gNB_generate_dedicatedRRCReconfiguration(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) { /* do not re-establish PDCP for any bearer */ - nr_rrc_reconfig_param_t params = get_RRCReconfiguration_params(rrc, ue_p, false, false); + nr_rrc_reconfig_param_t params = get_RRCReconfiguration_params(rrc, ue_p, 0, false); ue_p->xids[params.transaction_id] = RRC_PDUSESSION_ESTABLISH; byte_array_t msg = rrc_gNB_encode_RRCReconfiguration(rrc, ue_p, params); if (msg.len <= 0) { @@ -1043,8 +1051,10 @@ static void rrc_gNB_process_RRCReestablishmentComplete(gNB_RRC_INST *rrc, gNB_RR /* PDCP Reestablishment of DRBs according to 5.3.5.6.5 of 3GPP TS 38.331 (over E1) */ cuup_notify_reestablishment(rrc, ue_p); - /* Create srb-ToAddModList */ - NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, true); + /* Create srb-ToAddModList, 3GPP TS 38.331 RadioBearerConfig: + * do not re-establish PDCP for SRB1, when resuming an RRC connection, + * or at the first reconfiguration after RRC connection reestablishment in NR */ + NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, 1 << SRB2); // Re-establish PDCP for SRB2 only /* Create drb-ToAddModList */ NR_DRB_ToAddModList_t *DRBs = createDRBlist(ue_p, true); @@ -2153,7 +2163,7 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, instance * used for the radio bearer changes, with some expections for SRB1 (i.e. when resuming * an RRC connection, or at the first reconfiguration after RRC connection reestablishment * in NR, do not re-establish PDCP */ - nr_rrc_reconfig_param_t params = get_RRCReconfiguration_params(rrc, UE, true, true); + nr_rrc_reconfig_param_t params = get_RRCReconfiguration_params(rrc, UE, (1 << SRB2), true); params.transaction_id = xid; byte_array_t msg = rrc_gNB_encode_RRCReconfiguration(rrc, UE, params);