mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
9.3 KiB
C
241 lines
9.3 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef SRSUE_RRC_NR_H
|
||
|
#define SRSUE_RRC_NR_H
|
||
|
|
||
3 years ago
|
#include "rrc_nr_config.h"
|
||
3 years ago
|
#include "srsran/adt/circular_map.h"
|
||
4 years ago
|
#include "srsran/asn1/rrc_nr.h"
|
||
|
#include "srsran/asn1/rrc_nr_utils.h"
|
||
|
#include "srsran/common/block_queue.h"
|
||
|
#include "srsran/common/buffer_pool.h"
|
||
4 years ago
|
#include "srsran/common/common_nr.h"
|
||
4 years ago
|
#include "srsran/common/stack_procedure.h"
|
||
|
#include "srsran/common/task_scheduler.h"
|
||
3 years ago
|
#include "srsran/interfaces/ue_interfaces.h"
|
||
4 years ago
|
#include "srsran/interfaces/ue_nr_interfaces.h"
|
||
4 years ago
|
#include "srsran/interfaces/ue_rrc_interfaces.h"
|
||
5 years ago
|
#include "srsue/hdr/stack/upper/gw.h"
|
||
|
|
||
|
namespace srsue {
|
||
|
|
||
4 years ago
|
class usim_interface_rrc_nr;
|
||
4 years ago
|
class pdcp_interface_rrc;
|
||
4 years ago
|
class rlc_interface_rrc;
|
||
4 years ago
|
|
||
5 years ago
|
struct rrc_nr_metrics_t {};
|
||
|
|
||
5 years ago
|
class rrc_nr final : public rrc_interface_phy_nr,
|
||
|
public rrc_interface_pdcp,
|
||
|
public rrc_interface_rlc,
|
||
4 years ago
|
public rrc_interface_mac,
|
||
4 years ago
|
public rrc_nr_interface_rrc,
|
||
4 years ago
|
public srsran::timer_callback
|
||
5 years ago
|
{
|
||
|
public:
|
||
4 years ago
|
rrc_nr(srsran::task_sched_handle task_sched_);
|
||
5 years ago
|
~rrc_nr();
|
||
|
|
||
4 years ago
|
int init(phy_interface_rrc_nr* phy_,
|
||
|
mac_interface_rrc_nr* mac_,
|
||
|
rlc_interface_rrc* rlc_,
|
||
|
pdcp_interface_rrc* pdcp_,
|
||
|
gw_interface_rrc* gw_,
|
||
|
rrc_eutra_interface_rrc_nr* rrc_eutra_,
|
||
|
usim_interface_rrc_nr* usim_,
|
||
|
srsran::timer_handler* timers_,
|
||
|
stack_interface_rrc* stack_,
|
||
|
const rrc_nr_args_t& args_);
|
||
5 years ago
|
|
||
|
void stop();
|
||
4 years ago
|
void init_core_less();
|
||
5 years ago
|
|
||
|
void get_metrics(rrc_nr_metrics_t& m);
|
||
|
|
||
|
// Timeout callback interface
|
||
|
void timer_expired(uint32_t timeout_id) final;
|
||
4 years ago
|
void srsran_rrc_log(const char* str);
|
||
5 years ago
|
|
||
|
enum direction_t { Rx = 0, Tx };
|
||
|
template <class T>
|
||
4 years ago
|
void log_rrc_message(const std::string& source,
|
||
|
direction_t dir,
|
||
4 years ago
|
const srsran::byte_buffer_t* pdu,
|
||
4 years ago
|
const T& msg,
|
||
|
const std::string& msg_type);
|
||
4 years ago
|
template <class T>
|
||
|
void log_rrc_message(const std::string& source,
|
||
|
direction_t dir,
|
||
|
asn1::dyn_octstring oct,
|
||
|
const T& msg,
|
||
|
const std::string& msg_type);
|
||
5 years ago
|
// PHY interface
|
||
|
void in_sync() final;
|
||
|
void out_of_sync() final;
|
||
|
|
||
|
// RLC interface
|
||
|
void max_retx_attempted() final;
|
||
3 years ago
|
void protocol_failure() final;
|
||
5 years ago
|
|
||
4 years ago
|
// MAC interface
|
||
4 years ago
|
void run_tti(uint32_t tti) final;
|
||
4 years ago
|
void ra_completed() final;
|
||
|
void ra_problem() final;
|
||
|
void release_pucch_srs() final;
|
||
|
|
||
5 years ago
|
// PDCP interface
|
||
4 years ago
|
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
|
||
|
void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) final;
|
||
|
void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final;
|
||
|
void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final;
|
||
|
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
|
||
4 years ago
|
void notify_pdcp_integrity_error(uint32_t lcid) final;
|
||
5 years ago
|
|
||
4 years ago
|
// RRC (LTE) interface
|
||
4 years ago
|
int get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps);
|
||
|
int get_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps);
|
||
4 years ago
|
void phy_meas_stop();
|
||
4 years ago
|
void phy_set_cells_to_meas(uint32_t carrier_freq_r15);
|
||
4 years ago
|
bool rrc_reconfiguration(bool endc_release_and_add_r15,
|
||
|
bool nr_secondary_cell_group_cfg_r15_present,
|
||
|
asn1::dyn_octstring nr_secondary_cell_group_cfg_r15,
|
||
|
bool sk_counter_r15_present,
|
||
|
uint32_t sk_counter_r15,
|
||
|
bool nr_radio_bearer_cfg1_r15_present,
|
||
|
asn1::dyn_octstring nr_radio_bearer_cfg1_r15);
|
||
3 years ago
|
void rrc_release();
|
||
4 years ago
|
bool configure_sk_counter(uint16_t sk_counter);
|
||
4 years ago
|
bool is_config_pending();
|
||
5 years ago
|
// STACK interface
|
||
4 years ago
|
void cell_search_completed(const rrc_interface_phy_lte::cell_search_ret_t& cs_ret, const phy_cell_t& found_cell);
|
||
5 years ago
|
|
||
3 years ago
|
void set_phy_config_complete(bool status) final;
|
||
|
|
||
5 years ago
|
private:
|
||
4 years ago
|
srsran::task_sched_handle task_sched;
|
||
5 years ago
|
struct cmd_msg_t {
|
||
|
enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command;
|
||
4 years ago
|
srsran::unique_byte_buffer_t pdu;
|
||
5 years ago
|
uint16_t lcid;
|
||
|
};
|
||
|
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
5 years ago
|
bool running = false;
|
||
4 years ago
|
srsran::block_queue<cmd_msg_t> cmd_q;
|
||
5 years ago
|
|
||
4 years ago
|
// PHY config
|
||
|
srsran::phy_cfg_nr_t phy_cfg = {};
|
||
|
|
||
4 years ago
|
phy_interface_rrc_nr* phy = nullptr;
|
||
|
mac_interface_rrc_nr* mac = nullptr;
|
||
4 years ago
|
rlc_interface_rrc* rlc = nullptr;
|
||
|
pdcp_interface_rrc* pdcp = nullptr;
|
||
|
gw_interface_rrc* gw = nullptr;
|
||
|
rrc_eutra_interface_rrc_nr* rrc_eutra = nullptr;
|
||
4 years ago
|
usim_interface_rrc_nr* usim = nullptr;
|
||
4 years ago
|
stack_interface_rrc* stack = nullptr;
|
||
5 years ago
|
|
||
4 years ago
|
const uint32_t sim_measurement_timer_duration_ms = 250;
|
||
4 years ago
|
uint32_t sim_measurement_carrier_freq_r15;
|
||
|
srsran::timer_handler::unique_timer sim_measurement_timer;
|
||
4 years ago
|
|
||
5 years ago
|
/// RRC states (3GPP 38.331 v15.5.1 Sec 4.2.1)
|
||
|
enum rrc_nr_state_t {
|
||
|
RRC_NR_STATE_IDLE = 0,
|
||
|
RRC_NR_STATE_CONNECTED,
|
||
|
RRC_NR_STATE_CONNECTED_INACTIVE,
|
||
|
RRC_NR_STATE_N_ITEMS,
|
||
|
};
|
||
|
const static char* rrc_nr_state_text[RRC_NR_STATE_N_ITEMS];
|
||
|
|
||
5 years ago
|
// rrc_nr_state_t state = RRC_NR_STATE_IDLE;
|
||
5 years ago
|
|
||
3 years ago
|
// Stores the state of the PHy configuration setting
|
||
|
enum {
|
||
|
PHY_CFG_STATE_NONE = 0,
|
||
|
PHY_CFG_STATE_APPLY_SP_CELL,
|
||
|
PHY_CFG_STATE_RA_COMPLETED,
|
||
|
} phy_cfg_state;
|
||
|
|
||
5 years ago
|
rrc_nr_args_t args = {};
|
||
|
|
||
4 years ago
|
const char* get_rb_name(uint32_t lcid) final;
|
||
4 years ago
|
|
||
4 years ago
|
bool add_lcid_drb(uint32_t lcid, uint32_t drb_id);
|
||
|
uint32_t get_lcid_for_drbid(uint32_t rdid);
|
||
4 years ago
|
|
||
4 years ago
|
std::map<uint32_t, srsran::nr_drb> lcid_drb; // Map of lcid to drb
|
||
4 years ago
|
|
||
|
std::map<uint32_t, uint32_t> drb_eps_bearer_id; // Map of drb id to eps_bearer_id
|
||
|
|
||
4 years ago
|
// temporary maps for building the pucch nr resources
|
||
3 years ago
|
srsran::static_circular_map<uint32_t, srsran_pucch_nr_resource_t, 128> pucch_res_list;
|
||
|
std::map<uint32_t, srsran_csi_rs_zp_resource_t> csi_rs_zp_res;
|
||
|
std::map<uint32_t, srsran_csi_rs_nzp_resource_t> csi_rs_nzp_res;
|
||
4 years ago
|
|
||
4 years ago
|
bool apply_cell_group_cfg(const asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg);
|
||
|
bool apply_radio_bearer_cfg(const asn1::rrc_nr::radio_bearer_cfg_s& radio_bearer_cfg);
|
||
|
bool apply_rlc_add_mod(const asn1::rrc_nr::rlc_bearer_cfg_s& rlc_bearer_cfg);
|
||
|
bool apply_mac_cell_group(const asn1::rrc_nr::mac_cell_group_cfg_s& mac_cell_group_cfg);
|
||
|
bool apply_sp_cell_cfg(const asn1::rrc_nr::sp_cell_cfg_s& sp_cell_cfg);
|
||
4 years ago
|
bool apply_phy_cell_group_cfg(const asn1::rrc_nr::phys_cell_group_cfg_s& phys_cell_group_cfg);
|
||
|
bool apply_dl_common_cfg(const asn1::rrc_nr::dl_cfg_common_s& dl_cfg_common);
|
||
|
bool apply_ul_common_cfg(const asn1::rrc_nr::ul_cfg_common_s& ul_cfg_common);
|
||
|
bool apply_sp_cell_init_dl_pdcch(const asn1::rrc_nr::pdcch_cfg_s& pdcch_cfg);
|
||
|
bool apply_sp_cell_init_dl_pdsch(const asn1::rrc_nr::pdsch_cfg_s& pdsch_cfg);
|
||
|
bool apply_sp_cell_ded_ul_pucch(const asn1::rrc_nr::pucch_cfg_s& pucch_cfg);
|
||
|
bool apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_cfg);
|
||
|
bool apply_csi_meas_cfg(const asn1::rrc_nr::csi_meas_cfg_s& csi_meas_cfg);
|
||
|
bool apply_res_csi_report_cfg(const asn1::rrc_nr::csi_report_cfg_s& csi_report_cfg);
|
||
4 years ago
|
bool apply_drb_add_mod(const asn1::rrc_nr::drb_to_add_mod_s& drb_cfg);
|
||
4 years ago
|
bool apply_drb_release(const uint8_t drb);
|
||
4 years ago
|
bool apply_security_cfg(const asn1::rrc_nr::security_cfg_s& security_cfg);
|
||
|
|
||
4 years ago
|
srsran::as_security_config_t sec_cfg;
|
||
4 years ago
|
|
||
4 years ago
|
typedef enum { mcg_srb1, en_dc_srb3, nr } reconf_initiator_t;
|
||
|
|
||
4 years ago
|
class connection_reconf_no_ho_proc
|
||
|
{
|
||
|
public:
|
||
|
explicit connection_reconf_no_ho_proc(rrc_nr* parent_);
|
||
4 years ago
|
srsran::proc_outcome_t init(const reconf_initiator_t initiator_,
|
||
4 years ago
|
const bool endc_release_and_add_r15,
|
||
|
const bool nr_secondary_cell_group_cfg_r15_present,
|
||
|
const asn1::dyn_octstring nr_secondary_cell_group_cfg_r15,
|
||
|
const bool sk_counter_r15_present,
|
||
|
const uint32_t sk_counter_r15,
|
||
|
const bool nr_radio_bearer_cfg1_r15_present,
|
||
|
const asn1::dyn_octstring nr_radio_bearer_cfg1_r15);
|
||
4 years ago
|
srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; }
|
||
4 years ago
|
static const char* name() { return "NR Connection Reconfiguration"; }
|
||
4 years ago
|
srsran::proc_outcome_t react(const bool& config_complete);
|
||
|
void then(const srsran::proc_state_t& result);
|
||
4 years ago
|
|
||
|
private:
|
||
|
// const
|
||
4 years ago
|
rrc_nr* rrc_ptr;
|
||
|
reconf_initiator_t initiator;
|
||
4 years ago
|
asn1::rrc_nr::rrc_recfg_s rrc_recfg;
|
||
|
asn1::rrc_nr::cell_group_cfg_s cell_group_cfg;
|
||
|
};
|
||
|
|
||
4 years ago
|
srsran::proc_t<connection_reconf_no_ho_proc> conn_recfg_proc;
|
||
4 years ago
|
|
||
4 years ago
|
srsran::proc_manager_list_t callback_list;
|
||
5 years ago
|
};
|
||
|
|
||
|
} // namespace srsue
|
||
|
|
||
4 years ago
|
#endif // SRSUE_RRC_NR_H
|