|
|
@ -44,6 +44,7 @@ ue::ue(uint16_t rnti_,
|
|
|
|
pdus(128),
|
|
|
|
pdus(128),
|
|
|
|
nof_rx_harq_proc(nof_rx_harq_proc_),
|
|
|
|
nof_rx_harq_proc(nof_rx_harq_proc_),
|
|
|
|
nof_tx_harq_proc(nof_tx_harq_proc_),
|
|
|
|
nof_tx_harq_proc(nof_tx_harq_proc_),
|
|
|
|
|
|
|
|
rx_used_buffers(nof_cells_),
|
|
|
|
ta_fsm(this)
|
|
|
|
ta_fsm(this)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
|
|
|
|
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
|
|
|
@ -76,6 +77,12 @@ ue::~ue()
|
|
|
|
srslte_softbuffer_tx_free(&buffer);
|
|
|
|
srslte_softbuffer_tx_free(&buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& rx_buffers_cc : rx_used_buffers) {
|
|
|
|
|
|
|
|
for (auto& q : rx_buffers_cc) {
|
|
|
|
|
|
|
|
pdus.deallocate(q.second);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_buffers_cc.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ue::reset()
|
|
|
|
void ue::reset()
|
|
|
@ -161,13 +168,40 @@ ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, con
|
|
|
|
return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc);
|
|
|
|
return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t* ue::request_buffer(const uint32_t len)
|
|
|
|
uint8_t* ue::request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t* pdu = nullptr;
|
|
|
|
if (len > 0) {
|
|
|
|
if (len > 0) {
|
|
|
|
return pdus.request(len);
|
|
|
|
// Deallocate oldest buffer if we didn't deallocate it
|
|
|
|
|
|
|
|
if (!rx_used_buffers.at(ue_cc_idx).count(tti)) {
|
|
|
|
|
|
|
|
pdu = pdus.request(len);
|
|
|
|
|
|
|
|
if (pdu) {
|
|
|
|
|
|
|
|
rx_used_buffers.at(ue_cc_idx).emplace(tti, pdu);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
log_h->warning("Requesting buffer for zero bytes\n");
|
|
|
|
Error("UE buffers: Requesting buffer from pool\n");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Error("UE buffers: buffer for tti=%d already allocated\n", tti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Error("UE buffers: Requesting buffer for zero bytes\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return pdu;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ue::clear_old_buffers(uint32_t tti)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// remove old buffers
|
|
|
|
|
|
|
|
for (auto& rx_buffer_cc : rx_used_buffers) {
|
|
|
|
|
|
|
|
for (auto it = rx_buffer_cc.begin(); it != rx_buffer_cc.end();) {
|
|
|
|
|
|
|
|
if (srslte_tti_interval(tti, it->first) > 20) {
|
|
|
|
|
|
|
|
Warning("UE buffers: Removing old buffer tti=%d, rnti=%d, now is %d\n", it->first, rnti, tti);
|
|
|
|
|
|
|
|
pdus.deallocate(it->second);
|
|
|
|
|
|
|
|
it = rx_buffer_cc.erase(it);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
++it;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -293,21 +327,33 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
|
|
|
|
Debug("MAC PDU processed\n");
|
|
|
|
Debug("MAC PDU processed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ue::deallocate_pdu(const uint8_t* pdu_ptr)
|
|
|
|
void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pdu_ptr) {
|
|
|
|
if (rx_used_buffers.at(ue_cc_idx).count(tti)) {
|
|
|
|
pdus.deallocate(pdu_ptr);
|
|
|
|
pdus.deallocate(rx_used_buffers.at(ue_cc_idx).at(tti));
|
|
|
|
|
|
|
|
rx_used_buffers.at(ue_cc_idx).erase(tti);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Error("Error deallocating PDU: null ptr\n");
|
|
|
|
Warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n",
|
|
|
|
|
|
|
|
rnti,
|
|
|
|
|
|
|
|
tti % nof_rx_harq_proc,
|
|
|
|
|
|
|
|
ue_cc_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ue::push_pdu(const uint8_t* pdu_ptr, uint32_t len)
|
|
|
|
void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pdu_ptr && len > 0) {
|
|
|
|
if (rx_used_buffers.at(ue_cc_idx).count(tti)) {
|
|
|
|
pdus.push(pdu_ptr, len);
|
|
|
|
if (len > 0) {
|
|
|
|
|
|
|
|
pdus.push(rx_used_buffers.at(ue_cc_idx).at(tti), len);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Error("Error pushing PDU: null length\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_used_buffers.at(ue_cc_idx).erase(tti);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Error("Error pushing PDU: ptr=%p, len=%d\n", pdu_ptr, len);
|
|
|
|
Warning("UE buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n",
|
|
|
|
|
|
|
|
rnti,
|
|
|
|
|
|
|
|
tti % nof_rx_harq_proc,
|
|
|
|
|
|
|
|
ue_cc_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|