mirror of https://github.com/pvnis/srsRAN_4G.git
ue,stack: refactor handling of radio bearears in UE stack
this is a rather large commit that is hard to split because it touches quite a few components. It's a preparation patch for adding NR split bearers in the next step. We realized that managing RLC and PDCP bearers for both NR and LTE in the same entity doesn't work. This is because we use the LCID as a key for all accesses. With NR dual connectivity however we can have the same LCID active at the same time for both LTE and NR carriers. The patch solves that by creating a dedicated NR instance for RLC/PDCP in the stack. But then the question arises for UL traffic on, e.g. LCID 4 what PDCP instance the GW should use for pushing SDUs. It doesnt' know that. And in fact it doesn't need to. It just needs to know EPS bearer IDs. So the next change was to remove the knowledge of what LCIDs are from the GW. Make is agnostic and only work on EPS bearer IDs. The handling and mapping between EPS bearer IDs and LCIDs for LTE or NR (mainly PDCP for pushing data) is done in the Stack because it has access to both. The NAS also has a EPS bearer map but only knows about default and dedicated bearers. It doesn't know on which logical channels they are transmitted.master
parent
a4b2a065ff
commit
483a216bd5
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* By using this file, you agree to the terms and conditions set
|
||||||
|
* forth in the LICENSE file which can be found at the top level of
|
||||||
|
* the distribution.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRSUE_BEARER_MANAGER_H
|
||||||
|
#define SRSUE_BEARER_MANAGER_H
|
||||||
|
|
||||||
|
#include "srsran/common/common.h"
|
||||||
|
#include "srsran/common/rwlock_guard.h"
|
||||||
|
#include "srsran/srslog/srslog.h"
|
||||||
|
#include <map>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace srsue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper class to manage the mapping between EPS bearer and radio bearer
|
||||||
|
*
|
||||||
|
* The class maps EPS bearers that are known to NAS and GW and radio bearer (RB) that
|
||||||
|
* are only known to RRC. Since the lifetime of a EPS bearer is usually longer
|
||||||
|
* than the lifetime of a RB, the GW needs to query the Stack to check whether a
|
||||||
|
* given EPS bearer is active, i.e. a DRB is established, or not.
|
||||||
|
*
|
||||||
|
* The class also maps between RATs since each LCID can exist on either EUTRA or NR RATs, or both.
|
||||||
|
*
|
||||||
|
* Since the access of this class is happening from two different threads (GW+RRC/Stack)
|
||||||
|
* it's public interface is protected.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class bearer_manager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bearer_manager();
|
||||||
|
~bearer_manager();
|
||||||
|
|
||||||
|
// RRC interface
|
||||||
|
/// Registers EPS bearer with PDCP RAT type and LCID
|
||||||
|
void add_eps_bearer(uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid);
|
||||||
|
|
||||||
|
/// EPS bearer is removed from map when the associated DRB is deleted (e.g. after connection release)
|
||||||
|
void remove_eps_bearer(uint8_t eps_bearer_id);
|
||||||
|
|
||||||
|
// GW interface
|
||||||
|
bool has_active_radio_bearer(uint32_t eps_bearer_id);
|
||||||
|
|
||||||
|
// Stack interface to retrieve active RB
|
||||||
|
struct radio_bearer_t {
|
||||||
|
srsran::srsran_rat_t rat;
|
||||||
|
uint32_t lcid;
|
||||||
|
};
|
||||||
|
radio_bearer_t& get_radio_bearer(uint32_t eps_bearer_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
pthread_rwlock_t rwlock = {}; /// RW lock to protect access from RRC/GW threads
|
||||||
|
srslog::basic_logger& logger;
|
||||||
|
std::map<uint32_t, radio_bearer_t> eps_rb_map;
|
||||||
|
radio_bearer_t invalid_rb = {srsran::srsran_rat_t::nulltype, 0};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace srsue
|
||||||
|
|
||||||
|
#endif // SRSUE_BEARER_MANAGER_H
|
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* By using this file, you agree to the terms and conditions set
|
||||||
|
* forth in the LICENSE file which can be found at the top level of
|
||||||
|
* the distribution.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "srsue/hdr/stack/bearer_manager.h"
|
||||||
|
|
||||||
|
namespace srsue {
|
||||||
|
|
||||||
|
bearer_manager::bearer_manager() : logger(srslog::fetch_basic_logger("STCK", false))
|
||||||
|
{
|
||||||
|
pthread_rwlock_init(&rwlock, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bearer_manager::~bearer_manager()
|
||||||
|
{
|
||||||
|
pthread_rwlock_destroy(&rwlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bearer_manager::add_eps_bearer(uint8_t eps_bearer_id, srsran::srsran_rat_t rat, uint32_t lcid)
|
||||||
|
{
|
||||||
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
||||||
|
auto it = eps_rb_map.find(eps_bearer_id);
|
||||||
|
if (it != eps_rb_map.end()) {
|
||||||
|
logger.error("EPS bearer ID %d already registered", eps_bearer_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eps_rb_map.emplace(eps_bearer_id, radio_bearer_t{rat, lcid});
|
||||||
|
logger.info("Registered EPS bearer ID %d for lcid=%d over %s-PDCP", eps_bearer_id, lcid, to_string(rat).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EPS bearer is removed from map when the associated DRB is deleted (e.g. after connection release)
|
||||||
|
void bearer_manager::remove_eps_bearer(uint8_t eps_bearer_id)
|
||||||
|
{
|
||||||
|
srsran::rwlock_write_guard rw_lock(rwlock);
|
||||||
|
auto it = eps_rb_map.find(eps_bearer_id);
|
||||||
|
if (it == eps_rb_map.end()) {
|
||||||
|
logger.error("Can't remove EPS bearer ID %d", eps_bearer_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eps_rb_map.erase(it);
|
||||||
|
logger.info("Removed mapping for EPS bearer ID %d", eps_bearer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GW interface
|
||||||
|
bool bearer_manager::has_active_radio_bearer(uint32_t eps_bearer_id)
|
||||||
|
{
|
||||||
|
srsran::rwlock_read_guard rw_lock(rwlock);
|
||||||
|
return eps_rb_map.find(eps_bearer_id) != eps_rb_map.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stack interface
|
||||||
|
bearer_manager::radio_bearer_t& bearer_manager::get_radio_bearer(uint32_t eps_bearer_id)
|
||||||
|
{
|
||||||
|
srsran::rwlock_read_guard rw_lock(rwlock);
|
||||||
|
if (eps_rb_map.find(eps_bearer_id) != eps_rb_map.end()) {
|
||||||
|
return eps_rb_map.at(eps_bearer_id);
|
||||||
|
}
|
||||||
|
return invalid_rb;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace srsue
|
Loading…
Reference in New Issue