diff --git a/lib/include/srslte/interfaces/enb_s1ap_interfaces.h b/lib/include/srslte/interfaces/enb_s1ap_interfaces.h index 62105fad0..90d7cdca4 100644 --- a/lib/include/srslte/interfaces/enb_s1ap_interfaces.h +++ b/lib/include/srslte/interfaces/enb_s1ap_interfaces.h @@ -40,13 +40,16 @@ public: uint16_t dl_hfn, ul_hfn; }; - virtual void - initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu) = 0; virtual void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, + asn1::s1ap::rrc_establishment_cause_e cause, + srslte::unique_byte_buffer_t pdu) = 0; + virtual void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu, uint32_t m_tmsi, - uint8_t mmec) = 0; + uint8_t mmec) = 0; virtual void write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu) = 0; virtual bool user_exists(uint16_t rnti) = 0; @@ -87,6 +90,7 @@ public: * This message signals the completion of the HandoverPreparation from the TeNB point of view. */ virtual bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, + uint32_t enb_cc_idx, srslte::unique_byte_buffer_t ho_cmd, srslte::span admitted_bearers) = 0; diff --git a/lib/src/common/enb_events.cc b/lib/src/common/enb_events.cc index 358a29e4b..472848721 100644 --- a/lib/src/common/enb_events.cc +++ b/lib/src/common/enb_events.cc @@ -146,7 +146,6 @@ public: ctx.write("event"); ctx.write(get_time_stamp()); - //:TODO: not available ctx.write(enb_cc_idx); ctx.write("s1_context_create"); ctx.get().write(mme_id); @@ -161,7 +160,6 @@ public: ctx.write("event"); ctx.write(get_time_stamp()); - //:TODO: not available ctx.write(enb_cc_idx); ctx.write("s1_context_delete"); ctx.get().write(mme_id); diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index ae2393888..878e3469e 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -44,6 +44,9 @@ public: rrc_state_t get_state(); void get_metrics(rrc_ue_metrics_t& ue_metrics) const; + ///< Helper to access a cell cfg based on ue_cc_idx + enb_cell_common* get_ue_cc_cfg(uint32_t ue_cc_idx); + void send_connection_setup(); void send_connection_reest(uint8_t ncc); void send_connection_reject(); @@ -152,9 +155,6 @@ private: // controllers mac_controller mac_ctrl; - ///< Helper to access a cell cfg based on ue_cc_idx - enb_cell_common* get_ue_cc_cfg(uint32_t ue_cc_idx); - /// Helper to fill cell_ded_list with SCells provided in the eNB config void update_scells(); diff --git a/srsenb/hdr/stack/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h index a283b7e67..4f3e275dd 100644 --- a/srsenb/hdr/stack/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -43,6 +43,7 @@ struct ue_ctxt_t { uint16_t rnti = SRSLTE_INVALID_RNTI; uint32_t enb_ue_s1ap_id = invalid_enb_id; uint32_t mme_ue_s1ap_id = 0; + uint32_t enb_cc_idx = 0; struct timeval init_timestamp = {}; }; @@ -58,9 +59,12 @@ public: void get_metrics(s1ap_metrics_t& m); // RRC interface - void - initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu) override; void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, + asn1::s1ap::rrc_establishment_cause_e cause, + srslte::unique_byte_buffer_t pdu) override; + void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu, uint32_t m_tmsi, @@ -81,6 +85,7 @@ public: bool send_ho_failure(uint32_t mme_ue_s1ap_id); bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, + uint32_t enb_cc_idx, srslte::unique_byte_buffer_t ho_cmd, srslte::span admitted_bearers) override; void send_ho_notify(uint16_t rnti, uint64_t target_eci) override; diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index ff96cb1c6..8ebd098db 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -176,7 +176,6 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& // } // TODO: KeNB derivations - if (not ue_ptr->mobility_handler->start_s1_tenb_ho(msg, container)) { rem_user_thread(rnti); return SRSLTE_INVALID_RNTI; @@ -778,7 +777,11 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& } // send S1AP HandoverRequestAcknowledge - if (not rrc_enb->s1ap->send_ho_req_ack(*ho_req.ho_req_msg, rrc_ue->rnti, std::move(ho_cmd_pdu), admitted_erabs)) { + if (not rrc_enb->s1ap->send_ho_req_ack(*ho_req.ho_req_msg, + rrc_ue->rnti, + rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->enb_cc_idx, + std::move(ho_cmd_pdu), + admitted_erabs)) { trigger(srslte::failure_ev{}); return; } diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 039415225..af0963f0a 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -324,15 +324,17 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsl asn1::s1ap::rrc_establishment_cause_e s1ap_cause; s1ap_cause.value = (asn1::s1ap::rrc_establishment_cause_opts::options)establishment_cause.value; + + uint32_t enb_cc_idx = ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->enb_cc_idx; if (has_tmsi) { - parent->s1ap->initial_ue(rnti, s1ap_cause, std::move(pdu), m_tmsi, mmec); + parent->s1ap->initial_ue(rnti, enb_cc_idx, s1ap_cause, std::move(pdu), m_tmsi, mmec); } else { - parent->s1ap->initial_ue(rnti, s1ap_cause, std::move(pdu)); + parent->s1ap->initial_ue(rnti, enb_cc_idx, s1ap_cause, std::move(pdu)); } state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; // Log event. - event_logger::get().log_rrc_connected(ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->enb_cc_idx, + event_logger::get().log_rrc_connected(enb_cc_idx, asn1::octstring_to_string(last_ul_msg->msg, last_ul_msg->N_bytes), static_cast(conn_request_result_t::success), rnti); diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 473eb1899..83f418548 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -298,11 +298,15 @@ void s1ap::build_tai_cgi() /******************************************************************************* /* RRC interface ********************************************************************************/ -void s1ap::initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu) +void s1ap::initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, + asn1::s1ap::rrc_establishment_cause_e cause, + srslte::unique_byte_buffer_t pdu) { std::unique_ptr ue_ptr{new ue{this}}; - ue_ptr->ctxt.rnti = rnti; - ue* u = users.add_user(std::move(ue_ptr)); + ue_ptr->ctxt.rnti = rnti; + ue_ptr->ctxt.enb_cc_idx = enb_cc_idx; + ue* u = users.add_user(std::move(ue_ptr)); if (u == nullptr) { logger.error("Failed to add rnti=0x%x", rnti); return; @@ -311,14 +315,16 @@ void s1ap::initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause } void s1ap::initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu, uint32_t m_tmsi, uint8_t mmec) { std::unique_ptr ue_ptr{new ue{this}}; - ue_ptr->ctxt.rnti = rnti; - ue* u = users.add_user(std::move(ue_ptr)); + ue_ptr->ctxt.rnti = rnti; + ue_ptr->ctxt.enb_cc_idx = enb_cc_idx; + ue* u = users.add_user(std::move(ue_ptr)); if (u == nullptr) { logger.error("Failed to add rnti=0x%x", rnti); return; @@ -926,6 +932,7 @@ bool s1ap::send_ho_failure(uint32_t mme_ue_s1ap_id) bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, + uint32_t enb_cc_idx, srslte::unique_byte_buffer_t ho_cmd, srslte::span admitted_bearers) { @@ -933,8 +940,9 @@ bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_HO_RES_ALLOC); ho_request_ack_ies_container& container = tx_pdu.successful_outcome().value.ho_request_ack().protocol_ies; - ue* ue_ptr = users.find_ue_mmeid(msg.protocol_ies.mme_ue_s1ap_id.value.value); - ue_ptr->ctxt.rnti = rnti; + ue* ue_ptr = users.find_ue_mmeid(msg.protocol_ies.mme_ue_s1ap_id.value.value); + ue_ptr->ctxt.rnti = rnti; + ue_ptr->ctxt.enb_cc_idx = enb_cc_idx; container.mme_ue_s1ap_id.value = msg.protocol_ies.mme_ue_s1ap_id.value.value; container.enb_ue_s1ap_id.value = ue_ptr->ctxt.enb_ue_s1ap_id; @@ -1185,8 +1193,7 @@ bool s1ap::ue::send_uectxtreleasecomplete() container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; // Log event. - //:TODO: cc_idx not available - event_logger::get().log_s1_ctx_delete(0, ctxt.mme_ue_s1ap_id, ctxt.enb_ue_s1ap_id, ctxt.rnti); + event_logger::get().log_s1_ctx_delete(ctxt.enb_cc_idx, ctxt.mme_ue_s1ap_id, ctxt.enb_ue_s1ap_id, ctxt.rnti); return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "UEContextReleaseComplete"); } @@ -1220,8 +1227,7 @@ bool s1ap::ue::send_initial_ctxt_setup_response(const asn1::s1ap::init_context_s } // Log event. - //:TODO: cc_idx not available - event_logger::get().log_s1_ctx_create(0, ctxt.mme_ue_s1ap_id, ctxt.enb_ue_s1ap_id, ctxt.rnti); + event_logger::get().log_s1_ctx_create(ctxt.enb_cc_idx, ctxt.mme_ue_s1ap_id, ctxt.enb_ue_s1ap_id, ctxt.rnti); return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "InitialContextSetupResponse"); } diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index 12ba47f41..ed2700274 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -86,9 +86,13 @@ public: class s1ap_dummy : public s1ap_interface_rrc { public: - void initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu) override + void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, + asn1::s1ap::rrc_establishment_cause_e cause, + srslte::unique_byte_buffer_t pdu) override {} void initial_ue(uint16_t rnti, + uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, srslte::unique_byte_buffer_t pdu, uint32_t m_tmsi, @@ -115,6 +119,7 @@ public: } bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, + uint32_t enb_cc_idx, srslte::unique_byte_buffer_t ho_cmd, srslte::span admitted_bearers) override { diff --git a/srsenb/test/upper/test_helpers.h b/srsenb/test/upper/test_helpers.h index 176959b6b..cf64ed631 100644 --- a/srsenb/test/upper/test_helpers.h +++ b/srsenb/test/upper/test_helpers.h @@ -96,6 +96,7 @@ public: } bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, + uint32_t enb_cc_idx, srslte::unique_byte_buffer_t ho_cmd, srslte::span admitted_bearers) override {