From e0a28cf4c037c68ad9cede6c7ba5fee146b9e2d6 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 20 Jun 2019 16:41:14 +0200 Subject: [PATCH] simplify PDCP init and also bypass it for SRB0 on eNB --- lib/include/srslte/interfaces/enb_interfaces.h | 2 ++ lib/include/srslte/upper/pdcp.h | 16 ++++++---------- lib/src/upper/pdcp.cc | 9 ++++----- srsenb/src/stack/rrc/rrc.cc | 9 +++------ srsenb/src/stack/upper/pdcp.cc | 2 +- srsenb/src/stack/upper/rlc.cc | 6 +++++- srsue/src/stack/ue_stack_lte.cc | 2 +- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 7fc1bb3d4..20787c8bd 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -193,6 +193,7 @@ public: virtual void add_bearer(uint16_t rnti, uint32_t lcid) = 0; virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg) = 0; virtual void add_bearer_mrb(uint16_t rnti, uint32_t lcid) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; }; // PDCP interface for GTPU @@ -237,6 +238,7 @@ public: virtual void read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t *payload) = 0; virtual void read_pdu_pcch(uint8_t *payload, uint32_t payload_size) = 0; virtual void max_retx_attempted(uint16_t rnti) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; }; // RRC interface for MAC diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index d47afa078..88571994e 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -37,12 +37,8 @@ class pdcp public: pdcp(); virtual ~pdcp(); - void init(srsue::rlc_interface_pdcp *rlc_, - srsue::rrc_interface_pdcp *rrc_, - srsue::gw_interface_pdcp *gw_, - log *pdcp_log_, - uint32_t lcid_, - uint8_t direction_); + void + init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, log* pdcp_log_); void stop(); // GW interface @@ -82,14 +78,14 @@ public: void write_pdu_pcch(unique_byte_buffer_t sdu); private: - srsue::rlc_interface_pdcp *rlc; - srsue::rrc_interface_pdcp *rrc; - srsue::gw_interface_pdcp *gw; + srsue::rlc_interface_pdcp* rlc = nullptr; + srsue::rrc_interface_pdcp* rrc = nullptr; + srsue::gw_interface_pdcp* gw = nullptr; typedef std::map pdcp_map_t; typedef std::pair pdcp_map_pair_t; - log *pdcp_log; + log* pdcp_log = nullptr; pdcp_map_t pdcp_array, pdcp_array_mrb; pthread_rwlock_t rwlock; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 60ec25266..0114a37cd 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -25,10 +25,6 @@ namespace srslte { pdcp::pdcp() { - rlc = NULL; - rrc = NULL; - gw = NULL; - pdcp_log = NULL; pthread_rwlock_init(&rwlock, NULL); } @@ -50,7 +46,10 @@ pdcp::~pdcp() pthread_rwlock_destroy(&rwlock); } -void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_) +void pdcp::init(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + log* pdcp_log_) { rlc = rlc_; rrc = rrc_; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index a3ec07843..766de890b 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -1978,11 +1978,10 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg) dl_ccch_msg->pack(bref); pdu->N_bytes = 1u + (uint32_t)bref.distance_bytes(pdu->msg); - char buf[32]; + char buf[32] = {}; sprintf(buf, "SRB0 - rnti=0x%x", rnti); parent->log_rrc_message(buf, Tx, pdu.get(), *dl_ccch_msg); - - parent->pdcp->write_sdu(rnti, RB_ID_SRB0, std::move(pdu)); + parent->rlc->write_sdu(rnti, RB_ID_SRB0, std::move(pdu)); } else { parent->rrc_log->error("Allocating pdu\n"); } @@ -1998,12 +1997,10 @@ void rrc::ue::send_dl_dcch(dl_dcch_msg_s* dl_dcch_msg, srslte::unique_byte_buffe dl_dcch_msg->pack(bref); pdu->N_bytes = 1u + (uint32_t)bref.distance_bytes(pdu->msg); - char buf[32]; + char buf[32] = {}; sprintf(buf, "SRB1 - rnti=0x%x", rnti); parent->log_rrc_message(buf, Tx, pdu.get(), *dl_dcch_msg); - parent->pdcp->write_sdu(rnti, RB_ID_SRB1, std::move(pdu)); - } else { parent->rrc_log->error("Allocating pdu\n"); } diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index 846231cda..9377f1284 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -52,7 +52,7 @@ void pdcp::add_user(uint16_t rnti) pthread_rwlock_rdlock(&rwlock); if (users.count(rnti) == 0) { srslte::pdcp *obj = new srslte::pdcp; - obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf, log_h, RB_ID_SRB0, SECURITY_DIRECTION_DOWNLINK); + obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf, log_h); users[rnti].rlc_itf.rnti = rnti; users[rnti].gtpu_itf.rnti = rnti; users[rnti].rrc_itf.rnti = rnti; diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index e78b11559..b3061ee4b 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -210,7 +210,11 @@ void rlc::user_interface::max_retx_attempted() void rlc::user_interface::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { - pdcp->write_pdu(rnti, lcid, std::move(sdu)); + if (lcid == RB_ID_SRB0) { + rrc->write_pdu(rnti, lcid, std::move(sdu)); + } else { + pdcp->write_pdu(rnti, lcid, std::move(sdu)); + } } void rlc::user_interface::write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index c1f05d46e..5dace1328 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -103,7 +103,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) mac.init(phy, &rlc, &rrc, &mac_log); rlc.init(&pdcp, &rrc, &rlc_log, &mac, 0 /* RB_ID_SRB0 */); - pdcp.init(&rlc, &rrc, gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK); + pdcp.init(&rlc, &rrc, gw, &pdcp_log); nas.init(usim.get(), &rrc, gw, &nas_log, args.nas); rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &mac, &rrc_log, args.rrc);