diff --git a/lib/include/srslte/mac/pdu.h b/lib/include/srslte/mac/pdu.h index b301e5f4a..ea235bafc 100644 --- a/lib/include/srslte/mac/pdu.h +++ b/lib/include/srslte/mac/pdu.h @@ -35,7 +35,8 @@ namespace srslte { /* 3GPP 36.321 Table 6.2.1-1 */ enum class dl_sch_lcid { - CCCH = 0b00000, + CCCH = 0b00000, + RESERVED = 0b10001, //... SCELL_ACTIVATION_4_OCTET = 0b11000, SCELL_ACTIVATION = 0b11011, @@ -47,7 +48,53 @@ enum class dl_sch_lcid { const char* to_string(dl_sch_lcid v); uint32_t ce_size(dl_sch_lcid v); uint32_t ce_subheader_size(dl_sch_lcid v); -uint32_t ce_tot_size(dl_sch_lcid v); +uint32_t ce_total_size(dl_sch_lcid v); +bool is_mac_ce(dl_sch_lcid v) +{ + return v > dl_sch_lcid::RESERVED; +} + +/* 3GPP 36.321 Table 6.2.1-2 */ +enum class ul_sch_lcid { + CCCH = 0b00000, + RESERVED = 0b10001, + //... + PHR_REPORT_EXT = 0b11001, + PHR_REPORT = 0b11010, + CRNTI = 0b11011, + TRUNC_BSR = 0b11100, + SHORT_BSR = 0b11101, + LONG_BSR = 0b11110, + PADDING = 0b11111 +}; +const char* to_string(ul_sch_lcid v); +bool is_mac_ce(ul_sch_lcid v) +{ + return v >= ul_sch_lcid::RESERVED; +} + +/* 3GPP 36.321 Table 6.2.1-4 */ +enum class mch_lcid { + MCCH = 0b00000, + //... + MTCH_MAX_LCID = 0b11100, + MCH_SCHED_INFO = 0b11110, + PADDING = 0b11111 +}; +const char* to_string(mch_lcid v); + +/* Common LCID type */ +struct lcid_t { + enum class sch_type { dl_sch, ul_sch, mch } type; + union { + uint32_t lcid; + dl_sch_lcid dl_sch; + ul_sch_lcid ul_sch; + mch_lcid mch; + }; + const char* to_string() const; + bool is_sch() const { return type == sch_type::dl_sch or type == sch_type::ul_sch; } +}; template class pdu diff --git a/lib/src/mac/pdu.cc b/lib/src/mac/pdu.cc index 35c9708a7..386418c4e 100644 --- a/lib/src/mac/pdu.cc +++ b/lib/src/mac/pdu.cc @@ -85,11 +85,67 @@ uint32_t ce_subheader_size(dl_sch_lcid v) return 1; } -uint32_t ce_tot_size(dl_sch_lcid v) +uint32_t ce_total_size(dl_sch_lcid v) { return ce_subheader_size(v) + ce_size(v); } +/************************* + * UL-SCH LCID + *************************/ + +const char* to_string(ul_sch_lcid v) +{ + switch (v) { + case ul_sch_lcid::CCCH: + return "CCCH"; + case ul_sch_lcid::PHR_REPORT_EXT: + return "Extended Power Headroom Report"; + case ul_sch_lcid::PHR_REPORT: + return "Power Headroom Report"; + case ul_sch_lcid::CRNTI: + return "C-RNTI"; + case ul_sch_lcid::TRUNC_BSR: + return "Truncated BSR"; + case ul_sch_lcid::SHORT_BSR: + return "Short BSR"; + case ul_sch_lcid::LONG_BSR: + return "Long BSR"; + case ul_sch_lcid::PADDING: + return "Padding"; + default: + return "Unrecognized LCID"; + } +} + +const char* to_string(mch_lcid v) +{ + switch (v) { + case mch_lcid::MCCH: + return "MCCH"; + case mch_lcid::MCH_SCHED_INFO: + return "MCH Scheduling Information"; + case mch_lcid::PADDING: + return "Padding"; + default: + return "Unrecognized MCH LCID"; + } +} + +const char* lcid_t::to_string() const +{ + switch (type) { + case sch_type::dl_sch: + return srslte::to_string(dl_sch); + case sch_type::ul_sch: + return srslte::to_string(ul_sch); + case sch_type::mch: + return srslte::to_string(mch); + default: + return "unrecognized lcid type\n"; + } +} + /************************* * SCH PDU *************************/ diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index 9349a8294..f0bf9f1ec 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -413,7 +413,7 @@ uint32_t sched_ue::allocate_mac_ces(sched_interface::dl_sched_data_t* data, uint int rem_tbs = total_tbs; while (not pending_ces.empty()) { - int toalloc = srslte::ce_tot_size(pending_ces.front()); + int toalloc = srslte::ce_total_size(pending_ces.front()); if (rem_tbs < toalloc) { break; } @@ -895,7 +895,7 @@ std::pair sched_ue::get_requested_dl_bytes(uint32_t ue_cc_id // Add pending CEs if (ue_cc_idx == 0) { for (const auto& ce : pending_ces) { - sum_ce_data += srslte::ce_tot_size(ce); + sum_ce_data += srslte::ce_total_size(ce); } } // Add pending data in remaining RLC buffers @@ -910,11 +910,11 @@ std::pair sched_ue::get_requested_dl_bytes(uint32_t ue_cc_id /* Set Minimum boundary */ min_data = srb0_data; if (pending_ces.front() == ce_cmd::CON_RES_ID) { - min_data += srslte::ce_tot_size(pending_ces.front()); + min_data += srslte::ce_total_size(pending_ces.front()); } if (min_data == 0) { if (sum_ce_data > 0) { - min_data = srslte::ce_tot_size(pending_ces.front()); + min_data = srslte::ce_total_size(pending_ces.front()); } else if (rb_data > 0) { min_data = min_alloc_bytes; } @@ -940,7 +940,7 @@ uint32_t sched_ue::get_pending_dl_new_data() } } for (auto& ce : pending_ces) { - pending_data += srslte::ce_tot_size(ce); + pending_data += srslte::ce_total_size(ce); } return pending_data; } diff --git a/srsenb/test/mac/scheduler_ca_test.cc b/srsenb/test/mac/scheduler_ca_test.cc index 0a21d4d3c..c85efb7a1 100644 --- a/srsenb/test/mac/scheduler_ca_test.cc +++ b/srsenb/test/mac/scheduler_ca_test.cc @@ -186,7 +186,7 @@ int test_scell_activation(test_scell_activation_params params) if (tester.tti_info.dl_sched_result[params.pcell_idx].data[0].nof_pdu_elems[0] > 0) { // it is a new DL tx TESTASSERT(tester.tti_info.dl_sched_result[params.pcell_idx].data[0].pdu[0][0].lcid == - srslte::sch_subh::cetype::SCELL_ACTIVATION); + (uint32_t)srslte::dl_sch_lcid::SCELL_ACTIVATION); break; } } diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index d71b9922b..b8b9d5e0d 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -886,7 +886,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) if (pending_dl_new_data == 0) { uint32_t lcid = 0; // Use SRB0 to schedule Msg4 dl_rlc_buffer_state(ue_ev.rnti, lcid, 50, 0); - dl_mac_buffer_state(ue_ev.rnti, srslte::sch_subh::cetype::CON_RES_ID); + dl_mac_buffer_state(ue_ev.rnti, (uint32_t)srslte::dl_sch_lcid::CON_RES_ID); } else { // Let SRB0 Msg4 get fully transmitted }