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(); uint32_t get_bearer();
// PDCP interface // PDCP interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking = true);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface // MAC interface
uint32_t get_buffer_state(); uint32_t get_buffer_state();

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

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

@ -65,8 +65,7 @@ public:
uint32_t get_bearer(); uint32_t get_bearer();
// PDCP interface // PDCP interface
void write_sdu(byte_buffer_t *sdu); void write_sdu(byte_buffer_t *sdu, bool blocking = true);
void write_sdu_nb(byte_buffer_t *sdu);
// MAC interface // MAC interface
uint32_t get_buffer_state(); 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); pthread_rwlock_rdlock(&rwlock);
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
if (blocking) { rlc_array.at(lcid)->write_sdu(sdu, blocking);
rlc_array.at(lcid)->write_sdu(sdu);
} else {
rlc_array.at(lcid)->write_sdu_nb(sdu);
}
} else { } else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid); rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu); 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); pthread_rwlock_rdlock(&rwlock);
if (valid_lcid_mrb(lcid)) { 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 { } else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid); rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid);
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);

@ -199,32 +199,25 @@ uint32_t rlc_am::get_bearer()
* PDCP interface * 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) { if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);
return; return;
} }
if (sdu) { if (sdu) {
tx_sdu_queue.write(sdu); if (blocking) {
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()); // block on write to queue
} else { tx_sdu_queue.write(sdu);
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) {
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()); 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 { } 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()); // non-blocking write
pool->deallocate(sdu); 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 { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); log->warning("NULL SDU pointer in write_sdu()\n");

@ -96,35 +96,26 @@ uint32_t rlc_tm::get_bearer()
} }
// PDCP interface // 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) { if (!tx_enabled) {
byte_buffer_pool::get_instance()->deallocate(sdu); byte_buffer_pool::get_instance()->deallocate(sdu);
return; return;
} }
if (sdu) { if (sdu) {
ul_queue.write(sdu); if (blocking) {
log->info_hex(sdu->msg, sdu->N_bytes, "%s Tx SDU, queue size=%d, bytes=%d", ul_queue.write(sdu);
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", 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()); rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
} else { } else {
log->debug_hex(sdu->msg, sdu->N_bytes, "[Dropped SDU] %s Tx SDU, queue size=%d, bytes=%d", 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());
} else {
log->debug_hex(sdu->msg, sdu->N_bytes, "[Dropped SDU] %s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes()); rrc->get_rb_name(lcid).c_str(), ul_queue.size(), ul_queue.size_bytes());
pool->deallocate(sdu); pool->deallocate(sdu);
}
} }
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); log->warning("NULL SDU pointer in write_sdu()\n");

@ -142,14 +142,14 @@ uint32_t rlc_um::get_bearer()
/**************************************************************************** /****************************************************************************
* PDCP interface * PDCP interface
***************************************************************************/ ***************************************************************************/
void rlc_um::write_sdu(byte_buffer_t *sdu) void rlc_um::write_sdu(byte_buffer_t *sdu, bool blocking)
{ {
tx.write_sdu(sdu); 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