Use static queue in pdu_queue

This commit is contained in:
Ismael Gomez 2021-03-10 21:25:11 +01:00 committed by Francisco Paisana
parent 611c5e9814
commit 7b33c48fe7
4 changed files with 13 additions and 12 deletions

View File

@ -50,6 +50,7 @@ public:
if (capacity_ > 0) { if (capacity_ > 0) {
nof_buffers = (uint32_t)capacity_; nof_buffers = (uint32_t)capacity_;
} }
used.reserve(nof_buffers);
pthread_mutex_init(&mutex, nullptr); pthread_mutex_init(&mutex, nullptr);
pthread_cond_init(&cv_not_empty, nullptr); pthread_cond_init(&cv_not_empty, nullptr);
for (uint32_t i = 0; i < nof_buffers; i++) { for (uint32_t i = 0; i < nof_buffers; i++) {

View File

@ -33,9 +33,7 @@ public:
virtual void process_pdu(uint8_t* buff, uint32_t len, channel_t channel) = 0; virtual void process_pdu(uint8_t* buff, uint32_t len, channel_t channel) = 0;
}; };
pdu_queue(srslog::basic_logger& logger, uint32_t pool_size = DEFAULT_POOL_SIZE) : pdu_queue(srslog::basic_logger& logger) : pool(DEFAULT_POOL_SIZE), callback(NULL), logger(logger) {}
pool(pool_size), callback(NULL), logger(logger), pdu_q(pool_size)
{}
void init(process_callback* callback); void init(process_callback* callback);
uint8_t* request(uint32_t len); uint8_t* request(uint32_t len);
@ -47,7 +45,7 @@ public:
void reset(); void reset();
private: private:
const static int DEFAULT_POOL_SIZE = 64; // Number of PDU buffers in total const static int DEFAULT_POOL_SIZE = 128; // Number of PDU buffers in total
const static int MAX_PDU_LEN = 150 * 1024 / 8; // ~ 150 Mbps const static int MAX_PDU_LEN = 150 * 1024 / 8; // ~ 150 Mbps
typedef struct { typedef struct {
@ -60,7 +58,7 @@ private:
} pdu_t; } pdu_t;
dyn_blocking_queue<pdu_t*> pdu_q; static_blocking_queue<pdu_t*, DEFAULT_POOL_SIZE> pdu_q;
buffer_pool<pdu_t> pool; buffer_pool<pdu_t> pool;
process_callback* callback; process_callback* callback;

View File

@ -58,7 +58,9 @@ void pdu_queue::push(const uint8_t* ptr, uint32_t len, channel_t channel)
pdu_t* pdu = (pdu_t*)ptr; pdu_t* pdu = (pdu_t*)ptr;
pdu->len = len; pdu->len = len;
pdu->channel = channel; pdu->channel = channel;
pdu_q.push_blocking(pdu); if (!pdu_q.try_push(pdu)) {
logger.warning("Error pushing pdu: queue is full");
}
} else { } else {
logger.warning("Error pushing pdu: ptr is empty"); logger.warning("Error pushing pdu: ptr is empty");
} }

View File

@ -107,11 +107,11 @@ ue::ue(uint16_t rnti_,
rrc(rrc_), rrc(rrc_),
rlc(rlc_), rlc(rlc_),
phy(phy_), phy(phy_),
logger(logger_), logger(logger),
mac_msg_dl(20, logger_), mac_msg_dl(20, logger),
mch_mac_msg_dl(10, logger_), mch_mac_msg_dl(10, logger),
mac_msg_ul(20, logger_), mac_msg_ul(20, logger),
pdus(logger_, 128), pdus(logger),
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_),
ta_fsm(this), ta_fsm(this),