Skip to content

Commit d81788e

Browse files
andrepuschmannherlesupreethfrankist
committed
rrc_bearer_cfg: replace fixed E-RAB to DRB mapping
also make sure we don't assign LCIDs beyond the possible number. possible fix for #658 Co-authored-by: herlesupreeth <[email protected]> Co-authored-by: Francisco <[email protected]>
1 parent ace8ff2 commit d81788e

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

lib/include/srsran/common/common_lte.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ enum class lte_srb { srb0, srb1, srb2, count };
5959
const uint32_t MAX_LTE_SRB_ID = 2;
6060
enum class lte_drb { drb1 = 1, drb2, drb3, drb4, drb5, drb6, drb7, drb8, drb9, drb10, drb11, invalid };
6161
const uint32_t MAX_LTE_DRB_ID = 11;
62-
const uint32_t MAX_NOF_BEARERS = 14;
62+
const uint32_t MAX_LTE_LCID = 10; // logicalChannelIdentity 3..10 in TS 36.331 v15.3
63+
const uint32_t INVALID_LCID = 99; // random invalid LCID
6364

6465
constexpr bool is_lte_rb(uint32_t lcid)
6566
{
66-
return lcid < MAX_NOF_BEARERS;
67+
return lcid <= MAX_LTE_LCID;
6768
}
6869

6970
constexpr bool is_lte_srb(uint32_t lcid)

lib/src/upper/pdcp.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void pdcp::del_bearer(uint32_t lcid)
172172
}
173173
if (valid_lcid(lcid)) {
174174
pdcp_array.erase(lcid);
175-
logger.warning("Deleted PDCP bearer %s", rrc->get_rb_name(lcid));
175+
logger.info("Deleted PDCP bearer %s", rrc->get_rb_name(lcid));
176176
} else {
177177
logger.warning("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid));
178178
}

srsenb/hdr/stack/rrc/rrc_bearer_cfg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class bearer_cfg_handler
7878
uint32_t teid_in = 0;
7979
uint32_t addr = 0;
8080
};
81-
uint8_t id = 0;
81+
uint8_t id = 0;
82+
uint8_t lcid = 0;
8283
asn1::s1ap::erab_level_qos_params_s qos_params;
8384
asn1::bounded_bitstring<1, 160, true, true> address;
8485
uint32_t teid_out = 0;

srsenb/hdr/stack/upper/gtpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class gtpu_tunnel_manager
6464

6565
struct tunnel {
6666
uint16_t rnti = SRSRAN_INVALID_RNTI;
67-
uint32_t lcid = srsran::MAX_NOF_BEARERS;
67+
uint32_t lcid = srsran::INVALID_LCID;
6868
uint32_t teid_in = 0;
6969
uint32_t teid_out = 0;
7070
uint32_t spgw_addr = 0;

srsenb/src/stack/rrc/rrc_bearer_cfg.cc

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,26 @@ int bearer_cfg_handler::add_erab(uint8_t
233233
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::unknown_erab_id;
234234
return SRSRAN_ERROR;
235235
}
236-
uint8_t lcid = erab_id - 2; // Map e.g. E-RAB 5 to LCID 3 (==DRB1)
237-
uint8_t drbid = erab_id - 4;
236+
237+
uint8_t lcid = 3; // first E-RAB with DRB1 gets LCID3
238+
for (const auto& drb : current_drbs) {
239+
if (drb.lc_ch_id == lcid) {
240+
lcid++;
241+
}
242+
}
243+
if (lcid > srsran::MAX_LTE_LCID) {
244+
logger->error("Can't allocate LCID for ERAB id=%d", erab_id);
245+
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::radio_res_not_available;
246+
return SRSRAN_ERROR;
247+
}
248+
249+
// We currently have this static mapping between LCID->DRB ID
250+
uint8_t drbid = lcid - 2;
251+
if (drbid > srsran::MAX_LTE_DRB_ID) {
252+
logger->error("Can't allocate DRB ID for ERAB id=%d", erab_id);
253+
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::radio_res_not_available;
254+
return SRSRAN_ERROR;
255+
}
238256

239257
auto qci_it = cfg->qci_cfg.find(qos.qci);
240258
if (qci_it == cfg->qci_cfg.end() or not qci_it->second.configured) {
@@ -250,6 +268,7 @@ int bearer_cfg_handler::add_erab(uint8_t
250268
const rrc_cfg_qci_t& qci_cfg = qci_it->second;
251269

252270
erabs[erab_id].id = erab_id;
271+
erabs[erab_id].lcid = lcid;
253272
erabs[erab_id].qos_params = qos;
254273
erabs[erab_id].address = addr;
255274
erabs[erab_id].teid_out = teid_out;
@@ -385,7 +404,7 @@ srsran::expected<uint32_t> bearer_cfg_handler::add_gtpu_bearer(uint32_t
385404
erab_t::gtpu_tunnel bearer;
386405
bearer.teid_out = teid_out;
387406
bearer.addr = addr;
388-
srsran::expected<uint32_t> teidin = gtpu->add_bearer(rnti, erab.id - 2, addr, teid_out, props);
407+
srsran::expected<uint32_t> teidin = gtpu->add_bearer(rnti, erab.lcid, addr, teid_out, props);
389408
if (teidin.is_error()) {
390409
logger->error("Adding erab_id=%d to GTPU", erab_id);
391410
return srsran::default_error_t();
@@ -397,7 +416,12 @@ srsran::expected<uint32_t> bearer_cfg_handler::add_gtpu_bearer(uint32_t
397416

398417
void bearer_cfg_handler::rem_gtpu_bearer(uint32_t erab_id)
399418
{
400-
gtpu->rem_bearer(rnti, erab_id - 2);
419+
auto it = erabs.find(erab_id);
420+
if (it == erabs.end()) {
421+
logger->error("Removing erab_id=%d from GTPU", erab_id);
422+
return;
423+
}
424+
gtpu->rem_bearer(rnti, it->second.lcid);
401425
}
402426

403427
void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_s* msg)

srsenb/src/stack/rrc/rrc_mobility.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ rrc::ue::rrc_mobility::s1_source_ho_st::start_enb_status_transfer(const asn1::s1
582582

583583
for (const auto& erab_pair : rrc_ue->bearer_list.get_erabs()) {
584584
s1ap_interface_rrc::bearer_status_info b = {};
585-
uint8_t lcid = erab_pair.second.id - 2u;
585+
uint8_t lcid = erab_pair.second.lcid;
586586
b.erab_id = erab_pair.second.id;
587587
srsran::pdcp_lte_state_t pdcp_state = {};
588588
if (not rrc_enb->pdcp->get_bearer_state(rrc_ue->rnti, lcid, &pdcp_state)) {

srsenb/src/stack/rrc/rrc_ue.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
*/
2121

2222
#include "srsenb/hdr/stack/rrc/rrc_ue.h"
23+
#include "srsenb/hdr/common/common_enb.h"
2324
#include "srsenb/hdr/stack/rrc/mac_controller.h"
2425
#include "srsenb/hdr/stack/rrc/rrc_mobility.h"
2526
#include "srsenb/hdr/stack/rrc/ue_rr_cfg.h"
26-
#include "srsran/adt/pool/mem_pool.h"
2727
#include "srsran/asn1/rrc_utils.h"
2828
#include "srsran/common/enb_events.h"
2929
#include "srsran/common/int_helpers.h"
@@ -1339,7 +1339,7 @@ void rrc::ue::apply_pdcp_srb_updates(const rr_cfg_ded_s& pending_rr_cfg)
13391339
void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg)
13401340
{
13411341
for (uint8_t drb_id : pending_rr_cfg.drb_to_release_list) {
1342-
parent->pdcp->del_bearer(rnti, drb_id + 2);
1342+
parent->pdcp->del_bearer(rnti, drb_to_lcid((lte_drb)drb_id));
13431343
}
13441344
for (const drb_to_add_mod_s& drb : pending_rr_cfg.drb_to_add_mod_list) {
13451345
// Configure DRB1 in PDCP
@@ -1361,7 +1361,7 @@ void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg)
13611361
// If reconf due to reestablishment, recover PDCP state
13621362
if (state == RRC_STATE_REESTABLISHMENT_COMPLETE) {
13631363
for (const auto& erab_pair : bearer_list.get_erabs()) {
1364-
uint16_t lcid = erab_pair.second.id - 2;
1364+
uint16_t lcid = erab_pair.second.lcid;
13651365
bool is_am = parent->cfg.qci_cfg[erab_pair.second.qos_params.qci].rlc_cfg.type().value ==
13661366
asn1::rrc::rlc_cfg_c::types_opts::am;
13671367
if (is_am) {
@@ -1389,7 +1389,7 @@ void rrc::ue::apply_rlc_rb_updates(const rr_cfg_ded_s& pending_rr_cfg)
13891389
}
13901390
if (pending_rr_cfg.drb_to_release_list.size() > 0) {
13911391
for (uint8_t drb_id : pending_rr_cfg.drb_to_release_list) {
1392-
parent->rlc->del_bearer(rnti, drb_id + 2);
1392+
parent->rlc->del_bearer(rnti, drb_to_lcid((lte_drb)drb_id));
13931393
}
13941394
}
13951395
for (const drb_to_add_mod_s& drb : pending_rr_cfg.drb_to_add_mod_list) {

0 commit comments

Comments
 (0)