From 52f75c3cf20f31db6c435623d49ed12e15e02afb Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 2 Jul 2019 18:53:41 +0100 Subject: [PATCH] Starting to add PDCP NR state variables. --- lib/include/srslte/common/interfaces_common.h | 28 +++++++++--------- lib/include/srslte/upper/pdcp_entity_nr.h | 29 +++++++------------ lib/src/upper/pdcp_entity_nr.cc | 10 +++++-- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index e7fff3ebc..7069f5727 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -92,14 +92,19 @@ public: // bool do_rohc; }; +enum class srslte_nr_sn_len_t { + SN_12 = 12, + SN_18 = 18 +}; + class srslte_pdcp_config_nr_t { public: - srslte_pdcp_config_nr_t(uint8_t bearer_id_ = 0, - bool is_control_ = false, - bool is_data_ = false, - uint8_t direction_ = SECURITY_DIRECTION_UPLINK, - uint8_t sn_len_ = 12) : + srslte_pdcp_config_nr_t(uint8_t bearer_id_ = 0, + bool is_control_ = false, + bool is_data_ = false, + uint8_t direction_ = SECURITY_DIRECTION_UPLINK, + srslte_nr_sn_len_t sn_len_ = srslte_nr_sn_len_t::SN_12) : bearer_id(bearer_id_), direction(direction_), is_control(is_control_), @@ -108,14 +113,11 @@ public: { } - 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; + uint32_t bearer_id; + uint8_t direction; + bool is_control; + bool is_data; + srslte_nr_sn_len_t sn_len; }; class mac_interface_timers diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index 367c7ee6c..655edc963 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -74,31 +74,22 @@ private: srslte_pdcp_config_nr_t cfg; - uint32_t rx_count = 0; - uint32_t tx_count = 0; + uint16_t sn_len_bytes = 0; - uint32_t rx_hfn = 0; - uint32_t next_pdcp_rx_sn = 0; - uint32_t reordering_window = 0; - uint32_t last_submitted_pdcp_rx_sn = 0; - uint32_t maximum_pdcp_sn = 0; - - void handle_um_drb_pdu(const srslte::unique_byte_buffer_t& pdu); - void handle_am_drb_pdu(const srslte::unique_byte_buffer_t& pdu); + // State variables: 3GPP TS 38.323 v15.2.0, section 7.1 + uint32_t tx_next = 0; + uint32_t rx_next = 0; + uint32_t rx_deliv = 0; + uint32_t rx_reord = 0; + + // Constants: 3GPP TS 38.323 v15.2.0, section 7.2 + uint32_t window_size = 0; }; /**************************************************************************** * Pack/Unpack helper functions - * Ref: 3GPP TS 36.323 v10.1.0 + * Ref: 3GPP TS 38.323 v15.2.0 ***************************************************************************/ -void pdcp_pack_control_pdu(uint32_t sn, byte_buffer_t *sdu); -void pdcp_unpack_control_pdu(byte_buffer_t *sdu, uint32_t *sn); - -void pdcp_pack_data_pdu_short_sn(uint32_t sn, byte_buffer_t *sdu); -void pdcp_unpack_data_pdu_short_sn(byte_buffer_t *sdu, uint32_t *sn); -void pdcp_pack_data_pdu_long_sn(uint32_t sn, byte_buffer_t *sdu); -void pdcp_unpack_data_pdu_long_sn(byte_buffer_t *sdu, uint32_t *sn); - } // namespace srslte #endif // SRSLTE_PDCP_ENTITY_NR_H diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 35de3e191..0bf59d7d6 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -46,6 +46,7 @@ void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, do_encryption = false; // TODO + sn_len_bytes = (int)cfg.sn_len % 8; } // Reestablishment procedure: 36.323 5.2 @@ -68,8 +69,8 @@ void pdcp_entity_nr::reset() void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu, bool blocking) { log->info_hex(sdu->msg, sdu->N_bytes, - "TX %s SDU, SN: %d, do_integrity = %s, do_encryption = %s", - rrc->get_rb_name(lcid).c_str(), tx_count, + "TX %s SDU, do_integrity = %s, do_encryption = %s", + rrc->get_rb_name(lcid).c_str(), (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); // TODO @@ -86,6 +87,11 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); + // Sanity check + if (pdu->N_bytes <= sn_len_bytes) { + return; + } + // TODO }