mirror of https://github.com/PentHertz/srsLTE.git
fix padding BSR generation and add test for it
This commit is contained in:
parent
fab75592ec
commit
7145cd2358
|
@ -369,8 +369,9 @@ bool bsr_proc::generate_padding_bsr(uint32_t nof_padding_bytes, bsr_t* bsr)
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
if (triggered_bsr_type != NONE && nof_padding_bytes >= 2) {
|
if (triggered_bsr_type == NONE && nof_padding_bytes >= 2) {
|
||||||
|
// generate padding BSR
|
||||||
|
triggered_bsr_type = PADDING;
|
||||||
generate_bsr(bsr, nof_padding_bytes);
|
generate_bsr(bsr, nof_padding_bytes);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
|
|
|
@ -644,6 +644,61 @@ int mac_ul_sch_pdu_with_short_bsr_test()
|
||||||
return SRSLTE_SUCCESS;
|
return SRSLTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PDU with only padding BSR (long BSR) and the rest padding
|
||||||
|
int mac_ul_sch_pdu_with_padding_bsr_test()
|
||||||
|
{
|
||||||
|
const uint8_t tv[] = {0x3e, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
srslte::log_filter mac_log("MAC");
|
||||||
|
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
|
||||||
|
mac_log.set_hex_limit(100000);
|
||||||
|
|
||||||
|
srslte::log_filter rlc_log("RLC");
|
||||||
|
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
|
||||||
|
rlc_log.set_hex_limit(100000);
|
||||||
|
|
||||||
|
// dummy layers
|
||||||
|
phy_dummy phy;
|
||||||
|
rlc_dummy rlc(&rlc_log);
|
||||||
|
rrc_dummy rrc;
|
||||||
|
|
||||||
|
// the actual MAC
|
||||||
|
mac mac;
|
||||||
|
mac.init(&phy, &rlc, &rrc, &mac_log);
|
||||||
|
const uint16_t crnti = 0x1001;
|
||||||
|
mac.set_ho_rnti(crnti, 0);
|
||||||
|
|
||||||
|
// create UL action and grant and push MAC PDU
|
||||||
|
{
|
||||||
|
mac_interface_phy_lte::tb_action_ul_t ul_action = {};
|
||||||
|
mac_interface_phy_lte::mac_grant_ul_t mac_grant = {};
|
||||||
|
|
||||||
|
mac_grant.rnti = crnti; // make sure MAC picks it up as valid UL grant
|
||||||
|
mac_grant.tb.ndi_present = true;
|
||||||
|
mac_grant.tb.ndi = true;
|
||||||
|
mac_grant.tb.tbs = 10; // give enough room for Padding BSR
|
||||||
|
int cc_idx = 0;
|
||||||
|
|
||||||
|
// Send grant to MAC and get action for this TB, then call tb_decoded to unlock MAC
|
||||||
|
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
|
||||||
|
|
||||||
|
// print generated PDU
|
||||||
|
mac_log.info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
|
||||||
|
#if HAVE_PCAP
|
||||||
|
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TESTASSERT(memcmp(ul_action.tb.payload, tv, sizeof(tv)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure MAC PDU thread picks up before stopping
|
||||||
|
sleep(1);
|
||||||
|
mac.run_tti(0);
|
||||||
|
mac.stop();
|
||||||
|
|
||||||
|
return SRSLTE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#if HAVE_PCAP
|
#if HAVE_PCAP
|
||||||
|
@ -681,5 +736,10 @@ int main(int argc, char** argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mac_ul_sch_pdu_with_padding_bsr_test()) {
|
||||||
|
printf("mac_ul_sch_pdu_with_padding_bsr_test() test failed.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue