From 457f35699d590bbd8c6541b12fcde8c9cfc2e923 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 8 Jul 2019 16:04:45 +0100 Subject: [PATCH] Reverted back to a single config structure between PDCP NR and PDCP LTE. --- lib/include/srslte/common/interfaces_common.h | 38 +++++---------- .../srslte/interfaces/enb_interfaces.h | 16 +++---- lib/include/srslte/interfaces/ue_interfaces.h | 21 ++++----- lib/include/srslte/upper/pdcp.h | 4 +- lib/include/srslte/upper/pdcp_entity_lte.h | 5 +- lib/include/srslte/upper/pdcp_entity_nr.h | 4 +- lib/src/upper/pdcp.cc | 4 +- lib/src/upper/pdcp_entity_lte.cc | 2 +- lib/src/upper/pdcp_entity_nr.cc | 14 +++--- lib/test/upper/pdcp_nr_test.cc | 2 +- srsenb/hdr/stack/upper/pdcp.h | 2 +- srsenb/src/stack/rrc/rrc.cc | 47 ++++++++++--------- srsenb/src/stack/upper/pdcp.cc | 2 +- srsue/src/stack/rrc/rrc.cc | 18 +++---- 14 files changed, 82 insertions(+), 97 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index c751afb89..ddec2b299 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -67,45 +67,25 @@ public: uint32_t lcid; }; -class srslte_pdcp_config_lte_t -{ -public: - srslte_pdcp_config_lte_t(uint8_t bearer_id_ = 0, - bool is_control_ = false, - bool is_data_ = false, - uint8_t direction_ = SECURITY_DIRECTION_UPLINK) : - bearer_id(bearer_id_), - direction(direction_), - is_control(is_control_), - is_data(is_data_), - sn_len(12) - { - } - - uint32_t bearer_id; - uint8_t direction; - bool is_control; - bool is_data; - uint8_t sn_len; - - // TODO: Support the following configurations - // bool do_rohc; -}; - const uint8_t PDCP_SN_LEN_5 = 5; const uint8_t PDCP_SN_LEN_12 = 12; const uint8_t PDCP_SN_LEN_18 = 18; -class srslte_pdcp_config_nr_t +class srslte_pdcp_config_t { public: - srslte_pdcp_config_nr_t(uint8_t bearer_id_, bool is_control_, bool is_data_, uint8_t direction_, uint8_t sn_len_) : + srslte_pdcp_config_t(uint8_t bearer_id_, + bool is_control_, + bool is_data_ , + uint8_t direction_ , + uint8_t sn_len_) : bearer_id(bearer_id_), direction(direction_), is_control(is_control_), is_data(is_data_), sn_len(sn_len_) { + hdr_len_bytes = ceil((float)sn_len / 8); } uint32_t bearer_id; @@ -113,6 +93,10 @@ public: bool is_control; bool is_data; uint8_t sn_len; + uint8_t hdr_len_bytes; + + // TODO: Support the following configurations + // bool do_rohc; }; class mac_interface_timers diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 4bfd1b295..9d8c27aca 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -207,20 +207,20 @@ public: class pdcp_interface_rrc { public: - virtual void reset(uint16_t rnti) = 0; - virtual void add_user(uint16_t rnti) = 0; - virtual void rem_user(uint16_t rnti) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_lte_t cnfg) = 0; + virtual void reset(uint16_t rnti) = 0; + virtual void add_user(uint16_t rnti) = 0; + virtual void rem_user(uint16_t rnti) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t cnfg) = 0; virtual void config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; - virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; - virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; + virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; + virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; }; // PDCP interface for RLC diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 27d65d680..0e9ff0dea 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -228,26 +228,25 @@ public: class pdcp_interface_rrc { public: - virtual void reestablish() = 0; - virtual void reestablish(uint32_t lcid) = 0; - virtual void reset() = 0; - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = true) = 0; - virtual void add_bearer(uint32_t lcid, - srslte::srslte_pdcp_config_lte_t cnfg = srslte::srslte_pdcp_config_lte_t()) = 0; - virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; + virtual void reestablish() = 0; + virtual void reestablish(uint32_t lcid) = 0; + virtual void reset() = 0; + virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = true) = 0; + virtual void add_bearer(uint32_t lcid, srslte::srslte_pdcp_config_t cnfg) = 0; + virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; virtual void config_security(uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; virtual void config_security_all(uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; - virtual void enable_integrity(uint32_t lcid) = 0; - virtual void enable_encryption(uint32_t lcid) = 0; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; + virtual void enable_integrity(uint32_t lcid) = 0; + virtual void enable_encryption(uint32_t lcid) = 0; }; // PDCP interface for RLC diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index 4cd5b87d0..03d3bef4c 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -46,8 +46,8 @@ public: void reset(); void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking = true); void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu); - void add_bearer(uint32_t lcid, srslte_pdcp_config_lte_t cnfg = srslte_pdcp_config_lte_t()); - void add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_lte_t cnfg = srslte_pdcp_config_lte_t()); + void add_bearer(uint32_t lcid, srslte_pdcp_config_t cnfg); + void add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cnfg); void del_bearer(uint32_t lcid); void change_lcid(uint32_t old_lcid, uint32_t new_lcid); void config_security(uint32_t lcid, diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srslte/upper/pdcp_entity_lte.h index a4d0a2349..d1ebc68c5 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srslte/upper/pdcp_entity_lte.h @@ -54,7 +54,7 @@ public: srsue::gw_interface_pdcp* gw_, srslte::log* log_, uint32_t lcid_, - srslte_pdcp_config_lte_t cfg_); + srslte_pdcp_config_t cfg_); void reset(); void reestablish(); @@ -72,8 +72,7 @@ private: srsue::rrc_interface_pdcp* rrc = nullptr; srsue::gw_interface_pdcp* gw = nullptr; - srslte_pdcp_config_lte_t cfg = {}; - uint8_t sn_len_bytes = 0; + srslte_pdcp_config_t cfg = {0, SECURITY_DIRECTION_UPLINK, false, false, 0}; uint32_t rx_count = 0; uint32_t tx_count = 0; diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index 92c9ba8e1..1518a4cda 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -46,7 +46,7 @@ public: srsue::gw_interface_pdcp* gw_, srslte::log* log_, uint32_t lcid_, - srslte_pdcp_config_nr_t cfg_); + srslte_pdcp_config_t cfg_); void reset(); void reestablish(); @@ -64,7 +64,7 @@ private: srsue::rrc_interface_pdcp* rrc = nullptr; srsue::gw_interface_pdcp* gw = nullptr; - srslte_pdcp_config_nr_t cfg = {0, false, false, 0, PDCP_SN_LEN_12}; + srslte_pdcp_config_t cfg = {0, false, false, 0, PDCP_SN_LEN_12}; uint16_t sn_len_bytes = 0; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 81b3d6da9..ee4b9021f 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -120,7 +120,7 @@ void pdcp::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu) pthread_rwlock_unlock(&rwlock); } -void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_lte_t cfg) +void pdcp::add_bearer(uint32_t lcid, srslte_pdcp_config_t cfg) { pthread_rwlock_wrlock(&rwlock); if (not valid_lcid(lcid)) { @@ -141,7 +141,7 @@ unlock_and_exit: pthread_rwlock_unlock(&rwlock); } -void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_lte_t cfg) +void pdcp::add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cfg) { pthread_rwlock_wrlock(&rwlock); if (not valid_mch_lcid(lcid)) { diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index a930b6831..f87f689ac 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -33,7 +33,7 @@ void pdcp_entity_lte::init(srsue::rlc_interface_pdcp* rlc_, srsue::gw_interface_pdcp* gw_, srslte::log* log_, uint32_t lcid_, - srslte_pdcp_config_lte_t cfg_) + srslte_pdcp_config_t cfg_) { rlc = rlc_; rrc = rrc_; diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 002b35ac0..d152c701d 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -29,12 +29,12 @@ pdcp_entity_nr::pdcp_entity_nr() {} pdcp_entity_nr::~pdcp_entity_nr() {} -void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, - srsue::rrc_interface_pdcp* rrc_, - srsue::gw_interface_pdcp* gw_, - srslte::log* log_, - uint32_t lcid_, - srslte_pdcp_config_nr_t cfg_) +void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + srslte::log* log_, + uint32_t lcid_, + srslte_pdcp_config_t cfg_) { rlc = rlc_; rrc = rrc_; @@ -190,7 +190,7 @@ void pdcp_entity_nr::write_data_header(const srslte::unique_byte_buffer_t& sdu, } break; case PDCP_SN_LEN_18: - sdu->msg[0] = 0x80; // Data PDU and SN 18, D flag present + sdu->msg[0] = 0x80; // Data PDU and SN 18 implies DRB, D flag must be present *sdu->msg = count & 0x3F; break; default: diff --git a/lib/test/upper/pdcp_nr_test.cc b/lib/test/upper/pdcp_nr_test.cc index 4ba544f69..d21ed390b 100644 --- a/lib/test/upper/pdcp_nr_test.cc +++ b/lib/test/upper/pdcp_nr_test.cc @@ -99,7 +99,7 @@ private: bool test_tx_basic(srslte::byte_buffer_pool* pool, srslte::log* log) { srslte::pdcp_entity_nr pdcp; - srslte::srslte_pdcp_config_nr_t cfg = {1, false, true, SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12}; + srslte::srslte_pdcp_config_t cfg = {1, false, true, SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12}; rlc_dummy rlc(log); rrc_dummy rrc(log); diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index e9a8b5d51..f7059d50a 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -48,7 +48,7 @@ public: void add_user(uint16_t rnti); void rem_user(uint16_t rnti); void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_lte_t cnfg); + void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t cnfg); void config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index a54aa8154..1f238c553 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -193,11 +193,14 @@ void rrc::add_user(uint16_t rnti) } if (rnti == SRSLTE_MRNTI) { - srslte::srslte_pdcp_config_lte_t cfg; - cfg.is_control = false; - cfg.is_data = true; - cfg.sn_len = 12; - cfg.direction = SECURITY_DIRECTION_DOWNLINK; + srslte::srslte_pdcp_config_t cfg = { + .bearer_id = 1, + .is_control = false, + .is_data = true, + .sn_len = srslte::PDCP_SN_LEN_12, + .direction = SECURITY_DIRECTION_DOWNLINK, + }; + uint32_t teid_in = 1; for (uint32_t i = 0; i < mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9.size(); @@ -1529,12 +1532,11 @@ void rrc::ue::send_connection_setup(bool is_setup) parent->rlc->add_bearer(rnti, 1, srslte::rlc_config_t::srb_config(1)); // Configure SRB1 in PDCP - srslte::srslte_pdcp_config_lte_t pdcp_cnfg; - pdcp_cnfg.bearer_id = 1; - pdcp_cnfg.is_control = true; - pdcp_cnfg.is_data = false; - pdcp_cnfg.sn_len = 5; - pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; + srslte::srslte_pdcp_config_t pdcp_cnfg{.bearer_id = 1, + .is_control = true, + .is_data = false, + .sn_len = srslte::PDCP_SN_LEN_5, + .direction = SECURITY_DIRECTION_DOWNLINK}; parent->pdcp->add_bearer(rnti, 1, pdcp_cnfg); // Configure PHY layer @@ -1739,12 +1741,11 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) parent->rlc->add_bearer(rnti, 2, srslte::rlc_config_t::srb_config(2)); // Configure SRB2 in PDCP - srslte::srslte_pdcp_config_lte_t pdcp_cnfg; - pdcp_cnfg.bearer_id = 2; - pdcp_cnfg.direction = SECURITY_DIRECTION_DOWNLINK; - pdcp_cnfg.is_control = true; - pdcp_cnfg.is_data = false; - pdcp_cnfg.sn_len = 5; + srslte::srslte_pdcp_config_t pdcp_cnfg = {.bearer_id = 2, + .direction = SECURITY_DIRECTION_DOWNLINK, + .is_control = true, + .is_data = false, + .sn_len = srslte::PDCP_SN_LEN_5}; parent->pdcp->add_bearer(rnti, 2, pdcp_cnfg); parent->pdcp->config_security(rnti, 2, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo); parent->pdcp->enable_integrity(rnti, 2); @@ -1821,12 +1822,12 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE parent->rlc->add_bearer(rnti, lcid, srslte::make_rlc_config_t(drb_item.rlc_cfg)); // Configure DRB in PDCP - srslte::srslte_pdcp_config_lte_t pdcp_config; - pdcp_config.bearer_id = drb_item.drb_id - 1; // TODO: Review all ID mapping LCID DRB ERAB EPSBID Mapping - pdcp_config.is_control = false; - pdcp_config.is_data = true; - pdcp_config.sn_len = 12; - pdcp_config.direction = SECURITY_DIRECTION_DOWNLINK; + srslte::srslte_pdcp_config_t pdcp_config = { + .bearer_id = (uint8_t)(drb_item.drb_id - 1), // TODO: Review all ID mapping LCID DRB ERAB EPSBID Mapping + .is_control = false, + .is_data = true, + .sn_len = srslte::PDCP_SN_LEN_12, + .direction = SECURITY_DIRECTION_DOWNLINK}; parent->pdcp->add_bearer(rnti, lcid, pdcp_config); // DRB has already been configured in GTPU through bearer setup diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index c4db8a69c..c75a81b48 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -82,7 +82,7 @@ void pdcp::rem_user(uint16_t rnti) pthread_rwlock_unlock(&rwlock); } -void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_lte_t cfg) +void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t cfg) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index b1b683d65..5274598c9 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -3145,11 +3145,11 @@ void rrc::handle_con_reest(rrc_conn_reest_s* setup) void rrc::add_srb(srb_to_add_mod_s* srb_cnfg) { // Setup PDCP - srslte_pdcp_config_lte_t pdcp_cfg; - pdcp_cfg.is_control = true; - pdcp_cfg.is_data = false; - pdcp_cfg.sn_len = 5; - pdcp_cfg.bearer_id = srb_cnfg->srb_id; + srslte_pdcp_config_t pdcp_cfg = {.bearer_id = srb_cnfg->srb_id, + .is_control = true, + .is_data = false, + .direction = SECURITY_DIRECTION_DOWNLINK, + .sn_len = PDCP_SN_LEN_5}; pdcp->add_bearer(srb_cnfg->srb_id, pdcp_cfg); if (RB_ID_SRB2 == srb_cnfg->srb_id) { pdcp->config_security(srb_cnfg->srb_id, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo); @@ -3222,9 +3222,11 @@ void rrc::add_drb(drb_to_add_mod_s* drb_cnfg) } // Setup PDCP - srslte_pdcp_config_lte_t pdcp_cfg = {}; - pdcp_cfg.is_data = true; - pdcp_cfg.bearer_id = drb_cnfg->drb_id; + srslte_pdcp_config_t pdcp_cfg = {.bearer_id = drb_cnfg->drb_id, + .is_control = true, + .is_data = false, + .direction = SECURITY_DIRECTION_DOWNLINK, + .sn_len = PDCP_SN_LEN_12}; if (drb_cnfg->pdcp_cfg.rlc_um_present) { if (drb_cnfg->pdcp_cfg.rlc_um.pdcp_sn_size == pdcp_cfg_s::rlc_um_s_::pdcp_sn_size_e_::len7bits) { pdcp_cfg.sn_len = 7;