Changed PDCP LTE to use unique_lock.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent 3da0391fff
commit 8c10eabf23

@ -112,31 +112,31 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, bool blocking)
(do_integrity) ? "true" : "false", (do_integrity) ? "true" : "false",
(do_encryption) ? "true" : "false"); (do_encryption) ? "true" : "false");
mutex.lock(); {
std::unique_lock<std::mutex> lock(mutex);
if (is_srb()) { if (is_srb()) {
pdcp_pack_control_pdu(tx_count, sdu.get()); pdcp_pack_control_pdu(tx_count, sdu.get());
if (do_integrity) { if (do_integrity) {
integrity_generate(sdu->msg, sdu->N_bytes - 4, tx_count, &sdu->msg[sdu->N_bytes - 4]); integrity_generate(sdu->msg, sdu->N_bytes - 4, tx_count, &sdu->msg[sdu->N_bytes - 4]);
}
} }
}
if (is_drb()) { if (is_drb()) {
if (12 == cfg.sn_len) { if (12 == cfg.sn_len) {
pdcp_pack_data_pdu_long_sn(tx_count, sdu.get()); pdcp_pack_data_pdu_long_sn(tx_count, sdu.get());
} else { } else {
pdcp_pack_data_pdu_short_sn(tx_count, sdu.get()); pdcp_pack_data_pdu_short_sn(tx_count, sdu.get());
}
} }
}
if (do_encryption) { if (do_encryption) {
cipher_encrypt( cipher_encrypt(
&sdu->msg[cfg.hdr_len_bytes], sdu->N_bytes - cfg.hdr_len_bytes, tx_count, &sdu->msg[cfg.hdr_len_bytes]); &sdu->msg[cfg.hdr_len_bytes], sdu->N_bytes - cfg.hdr_len_bytes, tx_count, &sdu->msg[cfg.hdr_len_bytes]);
log->info_hex(sdu->msg, sdu->N_bytes, "TX %s SDU (encrypted)", rrc->get_rb_name(lcid).c_str()); log->info_hex(sdu->msg, sdu->N_bytes, "TX %s SDU (encrypted)", rrc->get_rb_name(lcid).c_str());
}
tx_count++;
} }
tx_count++;
mutex.unlock();
rlc->write_sdu(lcid, std::move(sdu), blocking); rlc->write_sdu(lcid, std::move(sdu), blocking);
} }
@ -157,8 +157,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
return; return;
} }
mutex.lock(); std::unique_lock<std::mutex> lock(mutex);
if (is_drb()) { if (is_drb()) {
// Handle DRB messages // Handle DRB messages
if (rlc->rb_is_um(lcid)) { if (rlc->rb_is_um(lcid)) {
@ -192,7 +191,6 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
} }
exit: exit:
rx_count++; rx_count++;
mutex.unlock();
} }
/**************************************************************************** /****************************************************************************

@ -260,7 +260,7 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
* RX Test: PDCP Entity with SN LEN = 12 and 18. Tested 4097 packets received without losses. * RX Test: PDCP Entity with SN LEN = 12 and 18. Tested 4097 packets received without losses.
* PDCP entity configured with EIA2 and EEA2 * PDCP entity configured with EIA2 and EEA2
*/ */
int test_rx_in_sequence(uint32_t n_packets, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log) int test_rx_in_sequence(uint64_t n_packets, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log)
{ {
srslte::pdcp_entity_nr pdcp_tx; srslte::pdcp_entity_nr pdcp_tx;
srslte::pdcp_entity_nr pdcp_rx; srslte::pdcp_entity_nr pdcp_rx;
@ -296,7 +296,7 @@ int test_rx_in_sequence(uint32_t n_packets, uint8_t pdcp_sn_len, srslte::byte_bu
// Generate test message and // Generate test message and
// decript and check matching SDUs // decript and check matching SDUs
for (uint32_t i = 0; i < n_packets; ++i) { for (uint64_t i = 0; i < n_packets; ++i) {
srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t pdu = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t pdu = allocate_unique_buffer(*pool);
memcpy(sdu->msg, sdu_exp->msg, SDU1_LEN); memcpy(sdu->msg, sdu_exp->msg, SDU1_LEN);
@ -326,6 +326,7 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
TESTASSERT(test_tx_all(pool, &log) == 0); TESTASSERT(test_tx_all(pool, &log) == 0);
TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, &log) == 0); TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, &log) == 0);
// TESTASSERT(test_rx_in_sequence(4294967297, srslte::PDCP_SN_LEN_12, pool, &log) == 0);
TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, &log) == 0); TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, &log) == 0);
return 0; return 0;
} }

Loading…
Cancel
Save