From 647882d03e9f0ef1a8d439567accec743d42af50 Mon Sep 17 00:00:00 2001 From: Bedran Karakoc Date: Fri, 17 Dec 2021 01:42:00 +0100 Subject: [PATCH] nr,gnb,rrc: Add initial UE capability transfer --- srsgnb/hdr/stack/rrc/rrc_nr_ue.h | 6 +++++ srsgnb/src/stack/rrc/rrc_nr.cc | 3 +++ srsgnb/src/stack/rrc/rrc_nr_ue.cc | 45 ++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h index 502a52f88..450226888 100644 --- a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h +++ b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h @@ -69,6 +69,9 @@ public: void handle_rrc_reestablishment_request(const asn1::rrc_nr::rrc_reest_request_s& msg); void handle_rrc_reestablishment_complete(const asn1::rrc_nr::rrc_reest_complete_s& msg); + /* TS 38.331 - 5.6.1 UE capability transfer */ + void handle_ue_capability_information(const asn1::rrc_nr::ue_cap_info_s& msg); + /** TS 38.331 - 5.3.8 Connection Release */ void send_rrc_release(); @@ -87,6 +90,9 @@ public: /* TS 38.331 - 5.3.5 RRC reconfiguration */ void send_rrc_reconfiguration(); + /* TS 38.331 - 5.6.1 UE capability transfer */ + void send_ue_capability_enquiry(); + private: int send_dl_ccch(const asn1::rrc_nr::dl_ccch_msg_s& dl_ccch_msg); int send_dl_dcch(srsran::nr_srb srb, const asn1::rrc_nr::dl_dcch_msg_s& dl_dcch_msg); diff --git a/srsgnb/src/stack/rrc/rrc_nr.cc b/srsgnb/src/stack/rrc/rrc_nr.cc index 2b04b7857..8b20dd4c6 100644 --- a/srsgnb/src/stack/rrc/rrc_nr.cc +++ b/srsgnb/src/stack/rrc/rrc_nr.cc @@ -554,6 +554,9 @@ void rrc_nr::handle_ul_dcch(uint16_t rnti, uint32_t lcid, srsran::const_byte_spa case ul_dcch_msg_type_c::c1_c_::types_opts::rrc_reest_complete: u.handle_rrc_reestablishment_complete(ul_dcch_msg.msg.c1().rrc_reest_complete()); break; + case ul_dcch_msg_type_c::c1_c_::types_opts::ue_cap_info: + u.handle_ue_capability_information(ul_dcch_msg.msg.c1().ue_cap_info()); + break; default: log_rx_pdu_fail(rnti, srb_to_lcid(lte_srb::srb0), pdu, "Unsupported UL-CCCH message type", false); // TODO Remove user diff --git a/srsgnb/src/stack/rrc/rrc_nr_ue.cc b/srsgnb/src/stack/rrc/rrc_nr_ue.cc index a5e14e743..8a99120c5 100644 --- a/srsgnb/src/stack/rrc/rrc_nr_ue.cc +++ b/srsgnb/src/stack/rrc/rrc_nr_ue.cc @@ -1116,8 +1116,8 @@ void rrc_nr::ue::handle_security_mode_complete(const asn1::rrc_nr::security_mode // finally, also enable ciphering on SRB1 update_as_security(srb_to_lcid(srsran::nr_srb::srb1), false, true); + send_ue_capability_enquiry(); send_rrc_reconfiguration(); - // Note: Skip UE capabilities // Send RRCReconfiguration if necessary if (not nas_pdu_queue.empty()) { @@ -1189,6 +1189,49 @@ void rrc_nr::ue::send_rrc_reconfiguration() } } +void rrc_nr::ue::send_ue_capability_enquiry() +{ + dl_dcch_msg_s dl_dcch_msg; + dl_dcch_msg.msg.set_c1().set_ue_cap_enquiry().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); + ue_cap_enquiry_ies_s& ies = dl_dcch_msg.msg.c1().ue_cap_enquiry().crit_exts.set_ue_cap_enquiry(); + + // ue-CapabilityRAT-RequestList + ue_cap_rat_request_s cap_rat_request; + cap_rat_request.rat_type.value = rat_type_opts::nr; + cap_rat_request.cap_request_filt_present = true; + + // capabilityRequestFilter + ue_cap_request_filt_nr_s request_filter; + + // frequencyBandListFilter + request_filter.freq_band_list_filt_present = true; + freq_band_info_c freq_band_info; + freq_band_info_nr_s& freq_band_info_nr = freq_band_info.set_band_info_nr(); + + // Iterate through cell list and assign bandInformationNR items + for (auto& iter : parent->cfg.cell_list) { + freq_band_info_nr.band_nr = iter.band; + request_filter.freq_band_list_filt.push_back(freq_band_info); + } + + // Pack capabilityRequestFilter + cap_rat_request.cap_request_filt.resize(128); + asn1::bit_ref bref_pack(cap_rat_request.cap_request_filt.data(), cap_rat_request.cap_request_filt.size()); + if (request_filter.pack(bref_pack) != asn1::SRSASN_SUCCESS) { + logger.error("Failed to pack capabilityRequestFilter in UE Capability Enquiry"); + } + cap_rat_request.cap_request_filt.resize(bref_pack.distance_bytes()); + + ies.ue_cap_rat_request_list.push_back(cap_rat_request); + + send_dl_dcch(srsran::nr_srb::srb1, dl_dcch_msg); +} + +void rrc_nr::ue::handle_ue_capability_information(const asn1::rrc_nr::ue_cap_info_s& msg) +{ + logger.info("UECapabilityInformation transaction ID: %d", msg.rrc_transaction_id); +} + void rrc_nr::ue::handle_rrc_reconfiguration_complete(const asn1::rrc_nr::rrc_recfg_complete_s& msg) { update_mac(next_cell_group_cfg, true);