diff --git a/lib/include/srsran/mac/bsr_nr.h b/lib/include/srsran/mac/bsr_nr.h new file mode 100644 index 000000000..a9922c442 --- /dev/null +++ b/lib/include/srsran/mac/bsr_nr.h @@ -0,0 +1,93 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_BSR_NR_H +#define SRSRAN_BSR_NR_H + +#include + +/** + * @brief Buffer size format definition and levels according to 3GPP TS 38.321 version 15.3.0 + * + * Shared between UE and gNB MAC layers + */ + +namespace srsran { + +// TS 38.321 Sec 6.1.3.1 +typedef enum { SHORT_BSR, LONG_BSR, SHORT_TRUNC_BSR, LONG_TRUNC_BSR } bsr_format_nr_t; + +// TS 38.321, Table 6.1.3.1-1 Buffer size levels (in bytes) for 5-bit Buffer Size field, all values <= except marked +static const uint32_t buffer_size_levels_5bit_max_idx = 31; +static uint32_t buffer_size_levels_5bit[buffer_size_levels_5bit_max_idx + 1] = { + /* == */ 0, 10, 14, 20, 28, 38, 53, 74, 102, 142, 198, + 276, 384, 535, 745, 1038, 1446, 2014, 2806, 3909, 5446, 7587, + 10570, 14726, 20516, 28581, 39818, 55474, 77284, 107669, 150000, /* > */ 150000}; + +// TS 38.321, Table 6.1.3.1-2: Buffer size levels (in bytes) for 8-bit Buffer Size field, all values <= except marked +static const uint32_t buffer_size_levels_8bit_max_idx = 254; +static uint32_t buffer_size_levels_8bit[buffer_size_levels_8bit_max_idx + 1] = { + /* == */ 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, + 19, 20, 22, 23, 25, + 26, 28, 30, 32, 34, + 36, 38, 40, 43, 46, + 49, 52, 55, 59, 62, + 66, 71, 75, 80, 85, + 91, 97, 103, 110, 117, + 124, 132, 141, 150, 160, + 170, 181, 193, 205, 218, + 233, 248, 264, 281, 299, + 318, 339, 361, 384, 409, + 436, 464, 494, 526, 560, + 597, 635, 677, 720, 767, + 817, 870, 926, 987, 1051, + 1119, 1191, 1269, 1351, 1439, + 1532, 1631, 1737, 1850, 1970, + 2098, 2234, 2379, 2533, 2698, + 2873, 3059, 3258, 3469, 3694, + 3934, 4189, 4461, 4751, 5059, + 5387, 5737, 6109, 6506, 6928, + 7378, 7857, 8367, 8910, 9488, + 10104, 10760, 11458, 12202, 12994, + 13838, 14736, 15692, 16711, 17795, + 18951, 20181, 21491, 22885, 24371, + 25953, 27638, 29431, 31342, 33376, + 35543, 37850, 40307, 42923, 45709, + 48676, 51836, 55200, 58784, 62599, + 66663, 70990, 75598, 80505, 85730, + 91295, 97221, 103532, 110252, 117409, + 125030, 133146, 141789, 150992, 160793, + 171231, 182345, 194182, 206786, 220209, + 234503, 249725, 265935, 283197, 301579, + 321155, 342002, 364202, 387842, 413018, + 439827, 468377, 498780, 531156, 565634, + 602350, 641449, 683087, 727427, 774645, + 824928, 878475, 935498, 996222, 1060888, + 1129752, 1203085, 1281179, 1364342, 1452903, + 1547213, 1647644, 1754595, 1868488, 1989774, + 2118933, 2256475, 2402946, 2558924, 2725027, + 2901912, 3090279, 3290873, 3504487, 3731968, + 3974215, 4232186, 4506902, 4799451, 5110989, + 5442750, 5796046, 6172275, 6572925, 6999582, + 7453933, 7937777, 8453028, 9001725, 9586039, + 10208280, 10870913, 11576557, 12328006, 13128233, + 13980403, 14887889, 15854280, 16883401, 17979324, + 19146385, 20389201, 21712690, 23122088, 24622972, + 26221280, 27923336, 29735875, 31666069, 33721553, + 35910462, 38241455, 40723756, 43367187, 46182206, + 49179951, 52372284, 55771835, 59392055, 63247269, + 67352729, 71724679, 76380419, 81338368, /* > */ 81338368}; + +} // namespace srsran + +#endif // SRSRAN_BSR_NR_H diff --git a/srsue/hdr/stack/mac_nr/mux_nr.h b/srsue/hdr/stack/mac_nr/mux_nr.h index 18e5b3a6c..c4bf9e4d4 100644 --- a/srsue/hdr/stack/mac_nr/mux_nr.h +++ b/srsue/hdr/stack/mac_nr/mux_nr.h @@ -47,7 +47,7 @@ public: srsran::unique_byte_buffer_t get_pdu(uint32_t max_pdu_len); // Interface for BSR procedure - void generate_bsr_mac_ce(const bsr_interface_mux_nr::bsr_format_nr_t& format); + void generate_bsr_mac_ce(const srsran::bsr_format_nr_t& format); private: // internal helper methods diff --git a/srsue/hdr/stack/mac_nr/proc_bsr_nr.h b/srsue/hdr/stack/mac_nr/proc_bsr_nr.h index 162a661f6..da2e88c6f 100644 --- a/srsue/hdr/stack/mac_nr/proc_bsr_nr.h +++ b/srsue/hdr/stack/mac_nr/proc_bsr_nr.h @@ -18,6 +18,7 @@ #include "proc_sr_nr.h" #include "srsran/common/task_scheduler.h" +#include "srsran/mac/bsr_nr.h" #include "srsran/mac/mac_sch_pdu_nr.h" #include "srsran/srslog/srslog.h" #include "srsue/hdr/stack/mac_common/mac_common.h" @@ -32,9 +33,6 @@ class rlc_interface_mac; class bsr_interface_mux_nr { public: - // TS 38.321 Sec 6.1.3.1 - typedef enum { SHORT_BSR, LONG_BSR, SHORT_TRUNC_BSR, LONG_TRUNC_BSR } bsr_format_nr_t; - /// MUX calls BSR to receive the buffer state of a single LCG. virtual srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr() = 0; }; @@ -43,7 +41,7 @@ class mux_interface_bsr_nr { public: /// Inform MUX unit to that a BSR needs to be generated in the next UL transmission. - virtual void generate_bsr_mac_ce(const bsr_interface_mux_nr::bsr_format_nr_t& format) = 0; + virtual void generate_bsr_mac_ce(const srsran::bsr_format_nr_t& format) = 0; }; /** @@ -101,7 +99,7 @@ private: bool check_new_data(const mac_buffer_states_t& new_buffer_state); bool check_any_channel(); - uint8_t buff_size_bytes_to_field(uint32_t buffer_size, bsr_format_nr_t format); + uint8_t buff_size_bytes_to_field(uint32_t buffer_size, srsran::bsr_format_nr_t format); uint32_t find_max_priority_lcg_with_data(); diff --git a/srsue/src/stack/mac_nr/mux_nr.cc b/srsue/src/stack/mac_nr/mux_nr.cc index dfe3ca7d8..6aab037e5 100644 --- a/srsue/src/stack/mac_nr/mux_nr.cc +++ b/srsue/src/stack/mac_nr/mux_nr.cc @@ -170,13 +170,13 @@ bool mux_nr::msg3_is_empty() return msg3_buff->N_bytes == 0; } -void mux_nr::generate_bsr_mac_ce(const bsr_interface_mux_nr::bsr_format_nr_t& format) +void mux_nr::generate_bsr_mac_ce(const srsran::bsr_format_nr_t& format) { switch (format) { - case bsr_interface_mux_nr::SHORT_BSR: + case srsran::SHORT_BSR: add_bsr_ce = sbsr_ce; break; - case bsr_interface_mux_nr::LONG_BSR: + case srsran::LONG_BSR: add_bsr_ce = lbsr_ce; default: logger.error("MUX can only be instructred to generate short or long BSRs."); diff --git a/srsue/src/stack/mac_nr/proc_bsr_nr.cc b/srsue/src/stack/mac_nr/proc_bsr_nr.cc index e0bbf6ce7..7cca98ede 100644 --- a/srsue/src/stack/mac_nr/proc_bsr_nr.cc +++ b/srsue/src/stack/mac_nr/proc_bsr_nr.cc @@ -16,67 +16,7 @@ namespace srsue { -// TS 38.321, Table 6.1.3.1-1 Buffer size levels (in bytes) for 5-bit Buffer Size field, all values <= except marked -static const uint32_t buffer_size_levels_5bit_max_idx = 31; -static uint32_t buffer_size_levels_5bit[buffer_size_levels_5bit_max_idx + 1] = { - /* == */ 0, 10, 14, 20, 28, 38, 53, 74, 102, 142, 198, - 276, 384, 535, 745, 1038, 1446, 2014, 2806, 3909, 5446, 7587, - 10570, 14726, 20516, 28581, 39818, 55474, 77284, 107669, 150000, /* > */ 150000}; - -// TS 38.321, Table 6.1.3.1-2: Buffer size levels (in bytes) for 8-bit Buffer Size field, all values <= except marked -static const uint32_t buffer_size_levels_8bit_max_idx = 254; -static uint32_t buffer_size_levels_8bit[buffer_size_levels_8bit_max_idx + 1] = { - /* == */ 0, 10, 11, 12, 13, - 14, 15, 16, 17, 18, - 19, 20, 22, 23, 25, - 26, 28, 30, 32, 34, - 36, 38, 40, 43, 46, - 49, 52, 55, 59, 62, - 66, 71, 75, 80, 85, - 91, 97, 103, 110, 117, - 124, 132, 141, 150, 160, - 170, 181, 193, 205, 218, - 233, 248, 264, 281, 299, - 318, 339, 361, 384, 409, - 436, 464, 494, 526, 560, - 597, 635, 677, 720, 767, - 817, 870, 926, 987, 1051, - 1119, 1191, 1269, 1351, 1439, - 1532, 1631, 1737, 1850, 1970, - 2098, 2234, 2379, 2533, 2698, - 2873, 3059, 3258, 3469, 3694, - 3934, 4189, 4461, 4751, 5059, - 5387, 5737, 6109, 6506, 6928, - 7378, 7857, 8367, 8910, 9488, - 10104, 10760, 11458, 12202, 12994, - 13838, 14736, 15692, 16711, 17795, - 18951, 20181, 21491, 22885, 24371, - 25953, 27638, 29431, 31342, 33376, - 35543, 37850, 40307, 42923, 45709, - 48676, 51836, 55200, 58784, 62599, - 66663, 70990, 75598, 80505, 85730, - 91295, 97221, 103532, 110252, 117409, - 125030, 133146, 141789, 150992, 160793, - 171231, 182345, 194182, 206786, 220209, - 234503, 249725, 265935, 283197, 301579, - 321155, 342002, 364202, 387842, 413018, - 439827, 468377, 498780, 531156, 565634, - 602350, 641449, 683087, 727427, 774645, - 824928, 878475, 935498, 996222, 1060888, - 1129752, 1203085, 1281179, 1364342, 1452903, - 1547213, 1647644, 1754595, 1868488, 1989774, - 2118933, 2256475, 2402946, 2558924, 2725027, - 2901912, 3090279, 3290873, 3504487, 3731968, - 3974215, 4232186, 4506902, 4799451, 5110989, - 5442750, 5796046, 6172275, 6572925, 6999582, - 7453933, 7937777, 8453028, 9001725, 9586039, - 10208280, 10870913, 11576557, 12328006, 13128233, - 13980403, 14887889, 15854280, 16883401, 17979324, - 19146385, 20389201, 21712690, 23122088, 24622972, - 26221280, 27923336, 29735875, 31666069, 33721553, - 35910462, 38241455, 40723756, 43367187, 46182206, - 49179951, 52372284, 55771835, 59392055, 63247269, - 67352729, 71724679, 76380419, 81338368, /* > */ 81338368}; +using namespace srsran; int32_t proc_bsr_nr::init(proc_sr_nr* sr_, mux_interface_bsr_nr* mux_,