unify RLC interface for writing SDUs w/ and w/o blocking

master
Andre Puschmann 7 years ago
parent 3950629a75
commit 89df8f1582

@ -86,8 +86,7 @@ public:
uint32_t get_bearer();
// PDCP interface
void write_sdu(byte_buffer_t *sdu);
void write_sdu_nb(byte_buffer_t *sdu);
void write_sdu(byte_buffer_t *sdu, bool blocking = true);
// MAC interface
uint32_t get_buffer_state();

@ -166,8 +166,7 @@ public:
virtual void reset_metrics() = 0;
// PDCP interface
virtual void write_sdu(byte_buffer_t *sdu) = 0;
virtual void write_sdu_nb(byte_buffer_t *sdu) = 0;
virtual void write_sdu(byte_buffer_t *sdu, bool blocking) = 0;
// MAC interface
virtual uint32_t get_buffer_state() = 0;

@ -59,8 +59,7 @@ public:
void reset_metrics();
// PDCP interface
void write_sdu(byte_buffer_t *sdu);
void write_sdu_nb(byte_buffer_t *sdu);
void write_sdu(byte_buffer_t *sdu, bool blocking);
// MAC interface
uint32_t get_buffer_state();

@ -65,8 +65,7 @@ public:
uint32_t get_bearer();
// PDCP interface
void write_sdu(byte_buffer_t *sdu);
void write_sdu_nb(byte_buffer_t *sdu);
void write_sdu(byte_buffer_t *sdu, bool blocking = true);
// MAC interface
uint32_t get_buffer_state();

@ -202,11 +202,7 @@ void rlc::write_sdu(uint32_t lcid, byte_buffer_t *sdu, bool blocking)
{
pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) {
if (blocking) {
rlc_array.at(lcid)->write_sdu(sdu);
} else {
rlc_array.at(lcid)->write_sdu_nb(sdu);
}
rlc_array.at(lcid)->write_sdu(sdu, blocking);
} else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu);
@ -218,7 +214,7 @@ void rlc::write_sdu_mch(uint32_t lcid, byte_buffer_t *sdu)
{
pthread_rwlock_rdlock(&rwlock);
if (valid_lcid_mrb(lcid)) {
rlc_array_mrb.at(lcid)->write_sdu_nb(sdu);
rlc_array_mrb.at(lcid)->write_sdu(sdu, false); // write in non-blocking mode by default
} else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu);

@ -199,33 +199,26 @@ uint32_t rlc_am::get_bearer()
* PDCP interface
***************************************************************************/
void rlc_am::write_sdu(byte_buffer_t *sdu)
void rlc_am::write_sdu(byte_buffer_t *sdu, bool blocking)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
if (blocking) {
// block on write to queue
tx_sdu_queue.write(sdu);
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
} else {
log->warning("NULL SDU pointer in write_sdu()\n");
}
}
void rlc_am::write_sdu_nb(byte_buffer_t *sdu)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
// non-blocking write
if (tx_sdu_queue.try_write(sdu)) {
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
} else {
log->debug_hex(sdu->msg, sdu->N_bytes, "[Dropped SDU] %s Tx SDU (%d B, tx_sdu_queue_len=%d)", rrc->get_rb_name(lcid).c_str(), sdu->N_bytes, tx_sdu_queue.size());
pool->deallocate(sdu);
}
}
} else {
log->warning("NULL SDU pointer in write_sdu()\n");
}

@ -96,28 +96,18 @@ uint32_t rlc_tm::get_bearer()
}
// PDCP interface
void rlc_tm::write_sdu(byte_buffer_t *sdu)
void rlc_tm::write_sdu(byte_buffer_t *sdu, bool blocking)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
if (blocking) {
ul_queue.write(sdu);
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
} else {
log->warning("NULL SDU pointer in write_sdu()\n");
}
}
void rlc_tm::write_sdu_nb(byte_buffer_t *sdu)
{
if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu);
return;
}
if (sdu) {
if (ul_queue.try_write(sdu)) {
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
@ -126,6 +116,7 @@ void rlc_tm::write_sdu_nb(byte_buffer_t *sdu)
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
pool->deallocate(sdu);
}
}
} else {
log->warning("NULL SDU pointer in write_sdu()\n");
}

@ -142,14 +142,14 @@ uint32_t rlc_um::get_bearer()
/****************************************************************************
* PDCP interface
***************************************************************************/
void rlc_um::write_sdu(byte_buffer_t *sdu)
void rlc_um::write_sdu(byte_buffer_t *sdu, bool blocking)
{
if (blocking) {
tx.write_sdu(sdu);
} else {
tx.try_write_sdu(sdu);
}
void rlc_um::write_sdu_nb(byte_buffer_t *sdu)
{
tx.try_write_sdu(sdu);
}
/****************************************************************************

Loading…
Cancel
Save