mac_nr_test: add TC to reproduce #3325

extend the rlc_dummy to allow providing different RLC PDUs.
add TC for issue #3325 but leave the original TV because it is very large.
master
Andre Puschmann 3 years ago
parent 7cbd3d50b7
commit fed53c91d0

@ -101,8 +101,12 @@ public:
return 0;
}
if (read_len > 0 && read_len < (int32_t)nof_bytes) {
nof_bytes = read_len;
if (read_len.size() >= read_len_idx) {
int32_t tmp_read_len = read_len.at(read_len_idx);
if (read_len.at(read_len_idx) > 0 && tmp_read_len < (int32_t)nof_bytes) {
nof_bytes = tmp_read_len;
}
read_len_idx = (read_len_idx + 1) % read_len.size();
}
uint32_t len = SRSRAN_MIN(ul_queues[lcid], nof_bytes);
@ -127,7 +131,7 @@ public:
uint32_t get_received_pdus() { return received_pdus; }
void disable_read() { read_enable = false; }
void set_read_len(uint32_t len) { read_len = len; }
void set_read_len(const std::vector<int32_t>& read_len_) { read_len = read_len_; }
void set_read_min(uint32_t len) { read_min = len; }
void reset_queues()
{
@ -138,7 +142,8 @@ public:
private:
bool read_enable = true;
int32_t read_len = -1; // read all
std::vector<int32_t> read_len = {-1}; // read all
uint32_t read_len_idx = 0;
uint32_t read_min = 0; // minimum "grant size" for read_pdu() to return data
uint32_t received_bytes = 0;
uint32_t received_pdus = 0;
@ -425,6 +430,90 @@ int mac_nr_ul_logical_channel_prioritization_test2()
return SRSRAN_SUCCESS;
}
// Correct packing of MAC PDU with multiple subHeader with 16bit L field
int mac_nr_ul_logical_channel_prioritization_test3()
{
// PDU layout (4737 B in total)
// TV skipped because it is very big
// dummy layers
dummy_phy phy;
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
// the actual MAC
mac_nr mac(&stack.task_sched);
const uint16_t crnti = 0x1001;
mac_nr_args_t args = {};
mac.init(args, &phy, &rlc, &rrc);
mac.set_crnti(crnti);
stack.init(&mac, &phy);
// generate config (default DRB2 config for EN-DC)
std::vector<srsran::logical_channel_config_t> lcids;
srsran::logical_channel_config_t config = {};
config.lcid = 4;
config.lcg = 6;
config.PBR = 0;
config.BSD = 1000; // 1000ms
config.priority = 11;
lcids.push_back(config);
// setup LCIDs in MAC
for (auto& channel : lcids) {
mac.setup_lcid(channel);
}
// write muliple SDUs to DRB2
const uint32_t sdu_len = 1502;
for (uint32_t i = 0; i < 10; ++i) {
rlc.write_sdu(4, sdu_len);
}
std::vector<int32_t> read_len;
read_len.push_back(80);
read_len.push_back(1480);
read_len.push_back(1480);
read_len.push_back(1480);
read_len.push_back(203);
rlc.set_read_len(read_len);
// run TTI to setup Bj, BSR should be generated
stack.run_tti(0);
usleep(100);
// create UL action and grant and read MAC PDU
{
mac_interface_phy_nr::tb_action_ul_t ul_action = {};
mac_interface_phy_nr::mac_nr_grant_ul_t mac_grant = {};
mac_grant.rnti = crnti; // make sure MAC picks it up as valid UL grant
mac_grant.pid = 0;
mac_grant.tti = 0;
mac_grant.tbs = 4737;
int cc_idx = 0;
// Send grant to MAC and get action for this TB, 0x
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload->msg, mac_grant.tbs, "Generated PDU (%d B)", mac_grant.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti_nr(
ul_action.tb.payload->msg, mac_grant.tbs, mac_grant.rnti, UE_ID, mac_grant.pid, mac_grant.tti);
#endif
}
// make sure MAC PDU thread picks up before stopping
stack.run_tti(0);
mac.stop();
return SRSRAN_SUCCESS;
}
// Basic test for periodic BSR transmission
int mac_nr_ul_periodic_bsr_test()
{
@ -710,6 +799,7 @@ int main()
TESTASSERT(msg3_test() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test1() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test2() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test3() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_periodic_bsr_test() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_dl_retx_test() == SRSRAN_SUCCESS);

Loading…
Cancel
Save