mirror of https://github.com/PentHertz/srsLTE.git
Added mutex to RLC and PDCP eNodeB
This commit is contained in:
parent
d7f6820d12
commit
cde432fbb6
|
@ -41,6 +41,7 @@ class pdcp : public pdcp_interface_rlc,
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void init(rlc_interface_pdcp *rlc_, rrc_interface_pdcp *rrc_, gtpu_interface_pdcp *gtpu_, srslte::log *pdcp_log_);
|
void init(rlc_interface_pdcp *rlc_, rrc_interface_pdcp *rrc_, gtpu_interface_pdcp *gtpu_, srslte::log *pdcp_log_);
|
||||||
|
~pdcp();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
// pdcp_interface_rlc
|
// pdcp_interface_rlc
|
||||||
|
@ -105,6 +106,9 @@ private:
|
||||||
srslte::pdcp *pdcp;
|
srslte::pdcp *pdcp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mutex to protect access to users std::map
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
std::map<uint32_t,user_interface> users;
|
std::map<uint32_t,user_interface> users;
|
||||||
|
|
||||||
rlc_interface_pdcp *rlc;
|
rlc_interface_pdcp *rlc;
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
|
|
||||||
void init(pdcp_interface_rlc *pdcp_, rrc_interface_rlc *rrc_, mac_interface_rlc *mac_,
|
void init(pdcp_interface_rlc *pdcp_, rrc_interface_rlc *rrc_, mac_interface_rlc *mac_,
|
||||||
srslte::mac_interface_timers *mac_timers_, srslte::log *log_h);
|
srslte::mac_interface_timers *mac_timers_, srslte::log *log_h);
|
||||||
|
~rlc();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
// rlc_interface_rrc
|
// rlc_interface_rrc
|
||||||
|
@ -93,8 +94,10 @@ private:
|
||||||
srsenb::rlc *parent;
|
srsenb::rlc *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mutex to protect access to users std::map
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
std::map<uint32_t,user_interface> users;
|
std::map<uint32_t,user_interface> users;
|
||||||
std::vector<mch_service_t> mch_services;
|
|
||||||
|
|
||||||
mac_interface_rlc *mac;
|
mac_interface_rlc *mac;
|
||||||
pdcp_interface_rlc *pdcp;
|
pdcp_interface_rlc *pdcp;
|
||||||
|
|
|
@ -37,6 +37,11 @@ void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interfa
|
||||||
log_h = pdcp_log_;
|
log_h = pdcp_log_;
|
||||||
|
|
||||||
pool = srslte::byte_buffer_pool::get_instance();
|
pool = srslte::byte_buffer_pool::get_instance();
|
||||||
|
pthread_mutex_init(&mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
pdcp::~pdcp() {
|
||||||
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::stop()
|
void pdcp::stop()
|
||||||
|
@ -44,11 +49,14 @@ void pdcp::stop()
|
||||||
for(std::map<uint32_t, user_interface>::iterator iter=users.begin(); iter!=users.end(); ++iter) {
|
for(std::map<uint32_t, user_interface>::iterator iter=users.begin(); iter!=users.end(); ++iter) {
|
||||||
rem_user((uint32_t) iter->first);
|
rem_user((uint32_t) iter->first);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
users.clear();
|
users.clear();
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::add_user(uint16_t rnti)
|
void pdcp::add_user(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti) == 0) {
|
if (users.count(rnti) == 0) {
|
||||||
srslte::pdcp *obj = new srslte::pdcp;
|
srslte::pdcp *obj = new srslte::pdcp;
|
||||||
obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf, log_h, RB_ID_SRB0, SECURITY_DIRECTION_DOWNLINK);
|
obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf, log_h, RB_ID_SRB0, SECURITY_DIRECTION_DOWNLINK);
|
||||||
|
@ -61,20 +69,24 @@ void pdcp::add_user(uint16_t rnti)
|
||||||
users[rnti].gtpu_itf.gtpu = gtpu;
|
users[rnti].gtpu_itf.gtpu = gtpu;
|
||||||
users[rnti].pdcp = obj;
|
users[rnti].pdcp = obj;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::rem_user(uint16_t rnti)
|
void pdcp::rem_user(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].pdcp->stop();
|
users[rnti].pdcp->stop();
|
||||||
delete users[rnti].pdcp;
|
delete users[rnti].pdcp;
|
||||||
users[rnti].pdcp = NULL;
|
users[rnti].pdcp = NULL;
|
||||||
users.erase(rnti);
|
users.erase(rnti);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t cfg)
|
void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t cfg)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
if(rnti != SRSLTE_MRNTI){
|
if(rnti != SRSLTE_MRNTI){
|
||||||
users[rnti].pdcp->add_bearer(lcid, cfg);
|
users[rnti].pdcp->add_bearer(lcid, cfg);
|
||||||
|
@ -82,37 +94,45 @@ void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_pdcp_config_t
|
||||||
users[rnti].pdcp->add_bearer_mrb(lcid, cfg);
|
users[rnti].pdcp->add_bearer_mrb(lcid, cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::reset(uint16_t rnti)
|
void pdcp::reset(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].pdcp->reset();
|
users[rnti].pdcp->reset();
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_,
|
void pdcp::config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_,
|
||||||
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
|
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
|
||||||
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_)
|
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].pdcp->config_security(lcid, k_rrc_enc_, k_rrc_int_, cipher_algo_, integ_algo_);
|
users[rnti].pdcp->config_security(lcid, k_rrc_enc_, k_rrc_int_, cipher_algo_, integ_algo_);
|
||||||
users[rnti].pdcp->enable_integrity(lcid);
|
users[rnti].pdcp->enable_integrity(lcid);
|
||||||
users[rnti].pdcp->enable_encryption(lcid);
|
users[rnti].pdcp->enable_encryption(lcid);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].pdcp->write_pdu(lcid, sdu);
|
users[rnti].pdcp->write_pdu(lcid, sdu);
|
||||||
} else {
|
} else {
|
||||||
pool->deallocate(sdu);
|
pool->deallocate(sdu);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
if(rnti != SRSLTE_MRNTI){
|
if(rnti != SRSLTE_MRNTI){
|
||||||
users[rnti].pdcp->write_sdu(lcid, sdu);
|
users[rnti].pdcp->write_sdu(lcid, sdu);
|
||||||
|
@ -122,6 +142,7 @@ void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
||||||
} else {
|
} else {
|
||||||
pool->deallocate(sdu);
|
pool->deallocate(sdu);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu)
|
void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu)
|
||||||
|
|
|
@ -40,6 +40,11 @@ void rlc::init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface
|
||||||
|
|
||||||
pool = srslte::byte_buffer_pool::get_instance();
|
pool = srslte::byte_buffer_pool::get_instance();
|
||||||
|
|
||||||
|
pthread_mutex_init(&mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
rlc::~rlc() {
|
||||||
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::stop()
|
void rlc::stop()
|
||||||
|
@ -47,11 +52,14 @@ void rlc::stop()
|
||||||
for(std::map<uint32_t, user_interface>::iterator iter=users.begin(); iter!=users.end(); ++iter) {
|
for(std::map<uint32_t, user_interface>::iterator iter=users.begin(); iter!=users.end(); ++iter) {
|
||||||
rem_user((uint32_t) iter->first);
|
rem_user((uint32_t) iter->first);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
users.clear();
|
users.clear();
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::add_user(uint16_t rnti)
|
void rlc::add_user(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti) == 0) {
|
if (users.count(rnti) == 0) {
|
||||||
srslte::rlc *obj = new srslte::rlc;
|
srslte::rlc *obj = new srslte::rlc;
|
||||||
obj->init(&users[rnti], &users[rnti], &users[rnti], log_h, mac_timers, RB_ID_SRB0);
|
obj->init(&users[rnti], &users[rnti], &users[rnti], log_h, mac_timers, RB_ID_SRB0);
|
||||||
|
@ -61,27 +69,33 @@ void rlc::add_user(uint16_t rnti)
|
||||||
users[rnti].rlc = obj;
|
users[rnti].rlc = obj;
|
||||||
users[rnti].parent = this;
|
users[rnti].parent = this;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::rem_user(uint16_t rnti)
|
void rlc::rem_user(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->stop();
|
users[rnti].rlc->stop();
|
||||||
delete users[rnti].rlc;
|
delete users[rnti].rlc;
|
||||||
users[rnti].rlc = NULL;
|
users[rnti].rlc = NULL;
|
||||||
users.erase(rnti);
|
users.erase(rnti);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::reset(uint16_t rnti)
|
void rlc::reset(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->reset();
|
users[rnti].rlc->reset();
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::clear_buffer(uint16_t rnti)
|
void rlc::clear_buffer(uint16_t rnti)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->empty_queue();
|
users[rnti].rlc->empty_queue();
|
||||||
for (int i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
for (int i=0;i<SRSLTE_N_RADIO_BEARERS;i++) {
|
||||||
|
@ -89,27 +103,34 @@ void rlc::clear_buffer(uint16_t rnti)
|
||||||
}
|
}
|
||||||
log_h->info("Cleared buffer rnti=0x%x\n", rnti);
|
log_h->info("Cleared buffer rnti=0x%x\n", rnti);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::add_bearer(uint16_t rnti, uint32_t lcid)
|
void rlc::add_bearer(uint16_t rnti, uint32_t lcid)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->add_bearer(lcid);
|
users[rnti].rlc->add_bearer(lcid);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg)
|
void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->add_bearer(lcid, cnfg);
|
users[rnti].rlc->add_bearer(lcid, cnfg);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::add_bearer_mrb(uint16_t rnti, uint32_t lcid)
|
void rlc::add_bearer_mrb(uint16_t rnti, uint32_t lcid)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->add_bearer_mrb_enb(lcid);
|
users[rnti].rlc->add_bearer_mrb_enb(lcid);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::read_pdu_pcch(uint8_t* payload, uint32_t buffer_size)
|
void rlc::read_pdu_pcch(uint8_t* payload, uint32_t buffer_size)
|
||||||
|
@ -119,13 +140,14 @@ void rlc::read_pdu_pcch(uint8_t* payload, uint32_t buffer_size)
|
||||||
|
|
||||||
int rlc::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
|
int rlc::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t tx_queue;
|
uint32_t tx_queue;
|
||||||
if(users.count(rnti)){
|
if (users.count(rnti)) {
|
||||||
if(rnti != SRSLTE_MRNTI){
|
if (rnti != SRSLTE_MRNTI) {
|
||||||
ret = users[rnti].rlc->read_pdu(lcid, payload, nof_bytes);
|
ret = users[rnti].rlc->read_pdu(lcid, payload, nof_bytes);
|
||||||
tx_queue = users[rnti].rlc->get_total_buffer_state(lcid);
|
tx_queue = users[rnti].rlc->get_total_buffer_state(lcid);
|
||||||
}else{
|
} else {
|
||||||
ret = users[rnti].rlc->read_pdu_mch(lcid, payload, nof_bytes);
|
ret = users[rnti].rlc->read_pdu_mch(lcid, payload, nof_bytes);
|
||||||
tx_queue = users[rnti].rlc->get_total_mch_buffer_state(lcid);
|
tx_queue = users[rnti].rlc->get_total_mch_buffer_state(lcid);
|
||||||
}
|
}
|
||||||
|
@ -135,15 +157,14 @@ int rlc::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_b
|
||||||
uint32_t retx_queue = 0;
|
uint32_t retx_queue = 0;
|
||||||
log_h->debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d\n", rnti, lcid, tx_queue);
|
log_h->debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d\n", rnti, lcid, tx_queue);
|
||||||
mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
|
mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
|
||||||
return ret;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
return SRSLTE_ERROR;
|
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
|
void rlc::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
users[rnti].rlc->write_pdu(lcid, payload, nof_bytes);
|
users[rnti].rlc->write_pdu(lcid, payload, nof_bytes);
|
||||||
|
|
||||||
|
@ -154,6 +175,7 @@ void rlc::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof
|
||||||
log_h->debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d\n", rnti, lcid, tx_queue);
|
log_h->debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d\n", rnti, lcid, tx_queue);
|
||||||
mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
|
mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rlc::read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t *payload)
|
void rlc::read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t *payload)
|
||||||
|
@ -165,6 +187,7 @@ void rlc::read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t *payload)
|
||||||
void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
uint32_t tx_queue;
|
uint32_t tx_queue;
|
||||||
if (users.count(rnti)) {
|
if (users.count(rnti)) {
|
||||||
if(rnti != SRSLTE_MRNTI){
|
if(rnti != SRSLTE_MRNTI){
|
||||||
|
@ -183,6 +206,7 @@ void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* sdu)
|
||||||
} else {
|
} else {
|
||||||
pool->deallocate(sdu);
|
pool->deallocate(sdu);
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rlc::rb_is_um(uint16_t rnti, uint32_t lcid) {
|
bool rlc::rb_is_um(uint16_t rnti, uint32_t lcid) {
|
||||||
|
|
Loading…
Reference in New Issue