From 5e40bfe72cef0da6d289c7d948dd2bbc15eac039 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 20 Aug 2020 14:30:03 +0200 Subject: [PATCH] mac_pdu: unpack and print BSR index as well as BSR value in bytes before the BSR was extracted but the actual index (between 0 and 63) was not stored but directly converted into bytes. for log parsing and debugging it is easier to follow the index value. this patch therefore adds both values to the log message and extends the API accordingly. --- lib/include/srslte/mac/pdu.h | 2 +- lib/src/mac/pdu.cc | 20 ++++++++++---------- srsenb/src/stack/mac/ue.cc | 24 +++++++++++++----------- srsue/test/ttcn3/src/ttcn3_syssim.cc | 17 +++++++++-------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib/include/srslte/mac/pdu.h b/lib/include/srslte/mac/pdu.h index 2f8f1d882..7dc099b65 100644 --- a/lib/include/srslte/mac/pdu.h +++ b/lib/include/srslte/mac/pdu.h @@ -322,7 +322,7 @@ public: uint8_t get_ta_cmd(); uint8_t get_activation_deactivation_cmd(); float get_phr(); - int get_bsr(uint32_t buff_size[4]); + int get_bsr(uint32_t buff_size_idx[4], uint32_t buff_size_bytes[4]); bool get_next_mch_sched_info(uint8_t* lcid, uint16_t* mtch_stop); diff --git a/lib/src/mac/pdu.cc b/lib/src/mac/pdu.cc index 121413a59..aa2dff476 100644 --- a/lib/src/mac/pdu.cc +++ b/lib/src/mac/pdu.cc @@ -570,25 +570,25 @@ float sch_subh::get_phr() } } -int sch_subh::get_bsr(uint32_t buff_size[4]) +int sch_subh::get_bsr(uint32_t buff_size_idx[4], uint32_t buff_size_bytes[4]) { if (payload) { uint32_t nonzero_lcg = 0; if (ul_sch_ce_type() == ul_sch_lcid::LONG_BSR) { - buff_size[0] = (payload[0] & 0xFC) >> 2; - buff_size[1] = (payload[0] & 0x03) << 4 | (payload[1] & 0xF0) >> 4; - buff_size[2] = (payload[1] & 0x0F) << 4 | (payload[1] & 0xC0) >> 6; - buff_size[3] = (payload[2] & 0x3F); + buff_size_idx[0] = (payload[0] & 0xFC) >> 2; + buff_size_idx[1] = (payload[0] & 0x03) << 4 | (payload[1] & 0xF0) >> 4; + buff_size_idx[2] = (payload[1] & 0x0F) << 4 | (payload[1] & 0xC0) >> 6; + buff_size_idx[3] = (payload[2] & 0x3F); } else { nonzero_lcg = (payload[0] & 0xc0) >> 6; - buff_size[nonzero_lcg % 4] = payload[0] & 0x3f; + buff_size_idx[nonzero_lcg % 4] = payload[0] & 0x3f; } for (int i = 0; i < 4; i++) { - if (buff_size[i]) { - if (buff_size[i] < 63) { - buff_size[i] = btable[1 + buff_size[i]]; + if (buff_size_idx[i] > 0) { + if (buff_size_idx[i] < 63) { + buff_size_bytes[i] = btable[1 + buff_size_idx[i]]; } else { - buff_size[i] = btable[63]; + buff_size_bytes[i] = btable[63]; } } } diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 61884b041..b753e2e90 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -332,7 +332,8 @@ void ue::push_pdu(const uint32_t ue_cc_idx, const uint32_t tti, uint32_t len) bool ue::process_ce(srslte::sch_subh* subh) { - uint32_t buff_size[4] = {0, 0, 0, 0}; + uint32_t buff_size_idx[4] = {}; + uint32_t buff_size_bytes[4] = {}; float phr = 0; int32_t idx = 0; uint16_t old_rnti = 0; @@ -356,32 +357,33 @@ bool ue::process_ce(srslte::sch_subh* subh) break; case srslte::ul_sch_lcid::TRUNC_BSR: case srslte::ul_sch_lcid::SHORT_BSR: - idx = subh->get_bsr(buff_size); + idx = subh->get_bsr(buff_size_idx, buff_size_bytes); if (idx == -1) { Error("Invalid Index Passed to lc groups\n"); break; } // Indicate BSR to scheduler - sched->ul_bsr(rnti, idx, buff_size[idx]); - Info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d\n", + sched->ul_bsr(rnti, idx, buff_size_bytes[idx]); + Info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d (%d B)\n", subh->ul_sch_ce_type() == srslte::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc", rnti, idx, - buff_size[idx]); + buff_size_idx[idx], + buff_size_bytes[idx]); is_bsr = true; break; case srslte::ul_sch_lcid::LONG_BSR: - subh->get_bsr(buff_size); + subh->get_bsr(buff_size_idx, buff_size_bytes); for (idx = 0; idx < sched_interface::MAX_LC_GROUP; ++idx) { - sched->ul_bsr(rnti, idx, buff_size[idx]); + sched->ul_bsr(rnti, idx, buff_size_bytes[idx]); } is_bsr = true; Info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n", rnti, - buff_size[0], - buff_size[1], - buff_size[2], - buff_size[3]); + buff_size_idx[0], + buff_size_idx[1], + buff_size_idx[2], + buff_size_idx[3]); break; case srslte::ul_sch_lcid::PADDING: Debug("CE: Received padding for rnti=0x%x\n", rnti); diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 4a5c57c3a..e298cbed4 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -639,7 +639,8 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) { uint16_t rnti = dl_rnti; - uint32_t buff_size[4] = {0, 0, 0, 0}; + uint32_t buff_size_idx[4] = {}; + uint32_t buff_size_bytes[4] = {}; float phr = 0; int32_t idx = 0; uint16_t old_rnti = 0; @@ -655,7 +656,7 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) break; case srslte::ul_sch_lcid::TRUNC_BSR: case srslte::ul_sch_lcid::SHORT_BSR: - idx = subh->get_bsr(buff_size); + idx = subh->get_bsr(buff_size_idx, buff_size_bytes); if (idx == -1) { ss_mac_log->error("Invalid Index Passed to lc groups\n"); break; @@ -664,18 +665,18 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) subh->ul_sch_ce_type() == srslte::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc", rnti, idx, - buff_size[idx]); + buff_size_idx[idx]); is_bsr = true; break; case srslte::ul_sch_lcid::LONG_BSR: - subh->get_bsr(buff_size); + subh->get_bsr(buff_size_idx, buff_size_bytes); is_bsr = true; ss_mac_log->info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n", rnti, - buff_size[0], - buff_size[1], - buff_size[2], - buff_size[3]); + buff_size_idx[0], + buff_size_idx[1], + buff_size_idx[2], + buff_size_idx[3]); break; case srslte::ul_sch_lcid::PADDING: ss_mac_log->debug("CE: Received padding for rnti=0x%x\n", rnti);