fix log tti, and print a warning when the ul_harq tti does not match existing ones

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 30ae2226c1
commit c661025cda

@ -117,6 +117,19 @@ inline tti_point min(tti_point tti1, tti_point tti2)
return tti1 < tti2 ? tti1 : tti2;
}
inline tti_point to_tx_dl(const srslte::tti_point& t)
{
return t + FDD_HARQ_DELAY_UL_MS;
}
inline tti_point to_tx_ul(const srslte::tti_point& t)
{
return t + (FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS);
}
inline tti_point to_tx_dl_ack(const srslte::tti_point& t)
{
return to_tx_ul(t);
}
} // namespace srslte
#endif // SRSLTE_TTI_POINT_H

@ -65,8 +65,8 @@ public:
int ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) override;
int crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) override;
int get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res) override;
int get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res) override;
int get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res) override;
int get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res) override;
int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res) override;
void set_sched_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) override
{

@ -103,7 +103,7 @@ public:
void new_tx(uint32_t tti, int mcs, int tbs, ul_alloc_t alloc, uint32_t max_retx_);
void new_retx(uint32_t tb_idx, uint32_t tti_, int* mcs, int* tbs, ul_alloc_t alloc);
void set_ack(uint32_t tb_idx, bool ack);
bool set_ack(uint32_t tb_idx, bool ack);
ul_alloc_t get_alloc() const;
bool has_pending_retx() const;

@ -112,7 +112,7 @@ public:
void set_dl_pmi(uint32_t tti, uint32_t enb_cc_idx, uint32_t ri);
void set_dl_cqi(uint32_t tti, uint32_t enb_cc_idx, uint32_t cqi);
int set_ack_info(uint32_t tti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack);
void set_ul_crc(uint32_t tti, uint32_t enb_cc_idx, bool crc_res);
void set_ul_crc(srslte::tti_point tti_rx, uint32_t enb_cc_idx, bool crc_res);
/*******************************************************
* Custom functions

@ -313,14 +313,14 @@ int mac::ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_
return SRSLTE_SUCCESS;
}
int mac::crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc)
int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc)
{
int ret = SRSLTE_ERROR;
log_h->step(tti);
log_h->step(tti_rx);
srslte::rwlock_read_guard lock(rwlock);
if (ue_db.count(rnti)) {
ue_db[rnti]->set_tti(tti);
ue_db[rnti]->set_tti(tti_rx);
ue_db[rnti]->metrics_rx(crc, nof_bytes);
std::array<int, SRSLTE_MAX_CARRIERS> enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti);
@ -332,15 +332,15 @@ int mac::crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof
// push the pdu through the queue if received correctly
if (crc) {
Info("Pushing PDU rnti=0x%x, tti=%d, nof_bytes=%d\n", rnti, tti, nof_bytes);
ue_db[rnti]->push_pdu(ue_cc_idx, tti, nof_bytes);
Info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes);
ue_db[rnti]->push_pdu(ue_cc_idx, tti_rx, nof_bytes);
stack_task_queue.push([this]() { process_pdus(); });
} else {
ue_db[rnti]->deallocate_pdu(ue_cc_idx, tti);
ue_db[rnti]->deallocate_pdu(ue_cc_idx, tti_rx);
}
// Scheduler uses eNB's CC mapping
ret = scheduler.ul_crc_info(tti, rnti, enb_cc_idx, crc);
ret = scheduler.ul_crc_info(tti_rx, rnti, enb_cc_idx, crc);
} else {
Error("User rnti=0x%x not found\n", rnti);
}
@ -511,18 +511,18 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
});
}
int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
{
if (!started) {
return 0;
}
log_h->step(tti);
log_h->step(TTI_SUB(tti_tx_dl, FDD_HARQ_DELAY_UL_MS));
for (uint32_t enb_cc_idx = 0; enb_cc_idx < cell_config.size(); enb_cc_idx++) {
// Run scheduler with current info
sched_interface::dl_sched_res_t sched_result = {};
if (scheduler.dl_sched(tti, enb_cc_idx, sched_result) < 0) {
if (scheduler.dl_sched(tti_tx_dl, enb_cc_idx, sched_result) < 0) {
Error("Running scheduler\n");
return SRSLTE_ERROR;
}
@ -562,7 +562,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
if (pcap) {
pcap->write_dl_crnti(
dl_sched_res->pdsch[n].data[tb], sched_result.data[i].tbs[tb], rnti, true, tti, enb_cc_idx);
dl_sched_res->pdsch[n].data[tb], sched_result.data[i].tbs[tb], rnti, true, tti_tx_dl, enb_cc_idx);
}
} else {
@ -588,15 +588,15 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
dl_sched_res->pdsch[n].softbuffer_tx[0] = &common_buffers[enb_cc_idx].rar_softbuffer_tx;
// Assemble PDU
dl_sched_res->pdsch[n].data[0] =
assemble_rar(sched_result.rar[i].msg3_grant, sched_result.rar[i].nof_grants, i, sched_result.rar[i].tbs, tti);
dl_sched_res->pdsch[n].data[0] = assemble_rar(
sched_result.rar[i].msg3_grant, sched_result.rar[i].nof_grants, i, sched_result.rar[i].tbs, tti_tx_dl);
if (pcap) {
pcap->write_dl_ranti(dl_sched_res->pdsch[n].data[0],
sched_result.rar[i].tbs,
dl_sched_res->pdsch[n].dci.rnti,
true,
tti,
tti_tx_dl,
enb_cc_idx);
}
@ -615,7 +615,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
dl_sched_res->pdsch[n].data[0] = rrc_h->read_pdu_bcch_dlsch(enb_cc_idx, sched_result.bc[i].index);
#ifdef WRITE_SIB_PCAP
if (pcap) {
pcap->write_dl_sirnti(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti, enb_cc_idx);
pcap->write_dl_sirnti(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti_tx_dl, enb_cc_idx);
}
#endif
} else {
@ -624,7 +624,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list)
rlc_h->read_pdu_pcch(common_buffers[enb_cc_idx].pcch_payload_buffer, pcch_payload_buffer_len);
if (pcap) {
pcap->write_dl_pch(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti, enb_cc_idx);
pcap->write_dl_pch(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti_tx_dl, enb_cc_idx);
}
}
@ -775,13 +775,13 @@ uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants,
}
}
int mac::get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res_list)
int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
{
if (!started) {
return SRSLTE_SUCCESS;
}
log_h->step(tti);
log_h->step(TTI_SUB(tti_tx_ul, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS));
// Execute TA FSM
for (auto& ue : ue_db) {
@ -796,7 +796,7 @@ int mac::get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res_list)
// Run scheduler with current info
sched_interface::ul_sched_res_t sched_result = {};
if (scheduler.ul_sched(tti, enb_cc_idx, sched_result) < 0) {
if (scheduler.ul_sched(tti_tx_ul, enb_cc_idx, sched_result) < 0) {
Error("Running scheduler\n");
return SRSLTE_ERROR;
}
@ -819,12 +819,12 @@ int mac::get_ul_sched(uint32_t tti, ul_sched_list_t& ul_sched_res_list)
phy_ul_sched_res->pusch[n].needs_pdcch = sched_result.pusch[i].needs_pdcch;
phy_ul_sched_res->pusch[n].dci = sched_result.pusch[i].dci;
phy_ul_sched_res->pusch[n].softbuffer_rx =
ue_db[rnti]->get_rx_softbuffer(sched_result.pusch[i].dci.ue_cc_idx, tti);
ue_db[rnti]->get_rx_softbuffer(sched_result.pusch[i].dci.ue_cc_idx, tti_tx_ul);
if (sched_result.pusch[n].current_tx_nb == 0) {
srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8);
}
phy_ul_sched_res->pusch[n].data =
ue_db[rnti]->request_buffer(sched_result.pusch[i].dci.ue_cc_idx, tti, sched_result.pusch[i].tbs);
ue_db[rnti]->request_buffer(sched_result.pusch[i].dci.ue_cc_idx, tti_tx_ul, sched_result.pusch[i].tbs);
phy_ul_sched_res->nof_grants++;
n++;
} else {

@ -277,9 +277,10 @@ int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_
return ret;
}
int sched::ul_crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, bool crc)
int sched::ul_crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, bool crc)
{
return ue_db_access(rnti, [tti, enb_cc_idx, crc](sched_ue& ue) { ue.set_ul_crc(tti, enb_cc_idx, crc); });
return ue_db_access(
rnti, [tti_rx, enb_cc_idx, crc](sched_ue& ue) { ue.set_ul_crc(srslte::tti_point{tti_rx}, enb_cc_idx, crc); });
}
int sched::dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_value)
@ -368,14 +369,14 @@ std::array<int, SRSLTE_MAX_CARRIERS> sched::get_enb_ue_cc_map(uint16_t rnti)
*******************************************************/
// Downlink Scheduler API
int sched::dl_sched(uint32_t tti, uint32_t cc_idx, sched_interface::dl_sched_res_t& sched_result)
int sched::dl_sched(uint32_t tti_tx_dl, uint32_t cc_idx, sched_interface::dl_sched_res_t& sched_result)
{
if (!configured) {
return 0;
}
std::lock_guard<std::mutex> lock(sched_mutex);
uint32_t tti_rx = sched_utils::tti_subtract(tti, FDD_HARQ_DELAY_UL_MS);
uint32_t tti_rx = sched_utils::tti_subtract(tti_tx_dl, FDD_HARQ_DELAY_UL_MS);
last_tti = sched_utils::max_tti(last_tti, tti_rx);
if (cc_idx < carrier_schedulers.size()) {

@ -255,10 +255,14 @@ void ul_harq_proc::new_retx(uint32_t tb_idx, uint32_t tti_, int* mcs, int* tbs,
new_retx_common(tb_idx, tti_point{tti_}, mcs, tbs);
}
void ul_harq_proc::set_ack(uint32_t tb_idx, bool ack_)
bool ul_harq_proc::set_ack(uint32_t tb_idx, bool ack_)
{
if (is_empty()) {
return false;
}
pending_ack = ack_ ? ACK : NACK;
set_ack_common(tb_idx, ack_);
return true;
}
bool ul_harq_proc::has_pending_ack() const

@ -287,11 +287,14 @@ void sched_ue::ul_recv_len(uint32_t lcid, uint32_t len)
Debug("SCHED: recv_len=%d, lcid=%d, bsr={%d,%d,%d,%d}\n", len, lcid, lch[0].bsr, lch[1].bsr, lch[2].bsr, lch[3].bsr);
}
void sched_ue::set_ul_crc(uint32_t tti, uint32_t enb_cc_idx, bool crc_res)
void sched_ue::set_ul_crc(srslte::tti_point tti_rx, uint32_t enb_cc_idx, bool crc_res)
{
auto p = get_cell_index(enb_cc_idx);
if (p.first) {
get_ul_harq(tti, p.second)->set_ack(0, crc_res);
srslte::tti_point tti_tx_ul = srslte::to_tx_ul(tti_rx);
if (not get_ul_harq(tti_tx_ul.to_uint(), p.second)->set_ack(0, crc_res)) {
log_h->warning("Received UL CRC for invalid tti_tx_ul=%d\n", (int)tti_tx_ul.to_uint());
}
} else {
log_h->warning("Received UL CRC for invalid cell index %d\n", enb_cc_idx);
}

Loading…
Cancel
Save