SRSENB: Add PHY UE DB return codes

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent e8395c7474
commit c5bb522f11

@ -74,7 +74,7 @@ private:
/**
* Cell information for the UE database
*/
typedef struct {
struct cell_info_t {
cell_state_t state = cell_state_none; ///< Configuration state
uint32_t enb_cc_idx = 0; ///< Corresponding eNb cell/carrier index
uint8_t last_ri = 0; ///< Last reported rank indicator
@ -123,8 +123,9 @@ private:
* Internal RNTI addition, it is not thread safe protected
*
* @param rnti identifier of the UE
* @return SRSLTE_SUCCESS if the RNTI is not duplicated and is added successfully, SRSLTE_ERROR code if it exists
*/
inline void _add_rnti(uint16_t rnti);
inline int _add_rnti(uint16_t rnti);
/**
* Internal pending ACK clear for a given RNTI and TTI, it is not thread safe protected
@ -221,7 +222,8 @@ private:
*
* @param rnti provides UE identifier
* @param enb_cc_idx eNb cell index
* @return The PHY configuration of the indicated UE for the indicated eNb carrier/call index.
* @param[out] phy_cfg The PHY configuration of the indicated UE for the indicated eNb carrier/call index.
* @return SRSLTE_SUCCESS if provided context is correct, SRSLTE_ERROR code otherwise
*/
inline srsran::phy_cfg_t _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const;
@ -255,16 +257,18 @@ public:
* Removes a whole UE entry from the UE database
*
* @param rnti identifier of the UE
* @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise
*/
void rem_rnti(uint16_t rnti);
int rem_rnti(uint16_t rnti);
/**
* Stack callback for indicating the completion of the configuration process and apply the stashed configuration in
* the primary cell.
*
* @param rnti identifier of the user
* @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise
*/
void complete_config(uint16_t rnti);
int complete_config(uint16_t rnti);
/**
* Activates or deactivates configured secondary cells for a given RNTI and SCell index (UE SCell index), index 0 is
@ -272,30 +276,25 @@ public:
* @param rnti identifier of the UE
* @param scell_idx
* @param activate
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
void activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate);
int activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate);
/**
* Asserts a given eNb cell is PCell of the given RNTI
* @param rnti identifier of the UE
* @param enb_cc_idx eNb cell/carrier index
* @return It returns true if it is the primmary cell, othwerwise it returns false
* @return It returns true if it is the primary cell, otherwise it returns false
*/
bool is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const;
/**
* Asserts a given eNb cell is part of the given RNTI
* @param rnti identifier of the UE
* @param enb_cc_idx eNb cell/carrier index
* @return It returns true if the cell is part of the UE, othwerwise it returns false
*/
bool ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const;
/**
* Get the current down-link physical layer configuration for an RNTI and an eNb cell/carrier
*
* @param rnti identifier of the UE
* @param cc_idx the eNb cell/carrier identifier
* @param[out] dl_cfg Current DL PHY configuration
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
srsran_dl_cfg_t get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const;
@ -304,6 +303,8 @@ public:
*
* @param rnti identifier of the UE
* @param cc_idx the eNb cell/carrier identifier
* @param[out] dci_cfg Current DL-DCI configuration
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
srsran_dci_cfg_t get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const;
@ -312,6 +313,8 @@ public:
*
* @param rnti identifier of the UE
* @param cc_idx the eNb cell/carrier identifier
* @param[out] ul_cfg Current UL PHY configuration
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
srsran_ul_cfg_t get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const;
@ -320,6 +323,8 @@ public:
*
* @param rnti identifier of the UE
* @param cc_idx the eNb cell/carrier identifier
* @param[out] dci_cfg Current UL-DCI configuration
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
srsran_dci_cfg_t get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const;
@ -362,6 +367,7 @@ public:
* @param rnti is the UE identifier
* @param uci_cfg is the UCI configuration
* @param uci_value is the UCI received value
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
void send_uci_data(uint32_t tti,
uint16_t rnti,
@ -377,6 +383,7 @@ public:
* @param enb_cc_idx the cell/carrier origin of the transmission
* @param pid HARQ process identifier
* @param tb the Resource Allocation for the PUSCH transport block
* @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise
*/
void set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb);
@ -388,7 +395,8 @@ public:
* @param rnti the UE temporal ID
* @param cc_idx the cell/carrier origin of the transmission
* @param pid HARQ process identifier
* @return the Resource Allocation for the PUSCH transport block
* @param[out] ra_tb the Resource Allocation for the PUSCH transport block
* @return SRSLTE_SUCCESS if the provided context is valid
*/
srsran_ra_tb_t get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const;
@ -398,7 +406,7 @@ public:
* @param rnti
* @param enb_cc_idx
*/
void set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list);
int set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list);
};
} // namespace srsenb

@ -262,7 +262,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
uint16_t rnti = ul_grant.dci.rnti;
// Invalid RNTI
if (rnti == 0) {
if (rnti == SRSLTE_INVALID_RNTI) {
return;
}
@ -272,7 +272,10 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
}
// Get UE configuration
ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx);
if (phy->ue_db.get_ul_config(rnti, cc_idx, ul_cfg) < SRSLTE_SUCCESS) {
Error("Error retrieving UL configuration for RNTI %x and CC %d", rnti, cc_idx);
return;
}
// Fill UCI configuration
bool uci_required =
@ -288,8 +291,11 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
// Handle Format0 adaptive retx
// Use last TBS for this TB in case of mcs>28
if (ul_grant.dci.tb.mcs_idx > 28) {
int rv_idx = grant.tb.rv;
grant.tb = phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid);
int rv_idx = grant.tb.rv;
if (phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) {
Error("Error retrieving last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid);
return;
}
grant.tb.rv = rv_idx;
Info("Adaptive retx: rnti=0x%x, pid=%d, rv_idx=%d, mcs=%d, old_tbs=%d",
rnti,
@ -298,7 +304,10 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
ul_grant.dci.tb.mcs_idx,
grant.tb.tbs / 8);
}
phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb);
if (phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) {
Error("Error setting last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid);
}
// Run PUSCH decoder
ul_cfg.pusch.softbuffers.rx = ul_grant.softbuffer_rx;
@ -380,7 +389,14 @@ int cc_worker::decode_pucch()
srsran_ul_cfg_t ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx);
// Check if user needs to receive PUCCH
if (phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg)) {
int ret = phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg);
if (ret < SRSLTE_SUCCESS) {
Error("Error retrieving UCI configuration for RNTI %x, CC %d", rnti, cc_idx);
continue;
}
// If ret is more than success, UCI is present
if (ret > SRSLTE_SUCCESS) {
// Decode PUCCH
if (srsran_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) {
ERROR("Error getting PUCCH");
@ -388,7 +404,10 @@ int cc_worker::decode_pucch()
}
// Send UCI data to MAC
phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data);
if (phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data) < SRSLTE_SUCCESS) {
Error("Error sending UCI data for RNTI %x, CC %d", rnti, cc_idx);
continue;
}
if (pucch_res.detected and pucch_res.ta_valid) {
phy->stack->ta_info(tti_rx, rnti, pucch_res.ta_us);
@ -531,6 +550,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u
if (srsran_ra_dl_dci_to_grant(
&enb_dl.cell, &dl_sf, dl_cfg.tm, dl_cfg.pdsch.use_tbs_index_alt, &grants[i].dci, &dl_cfg.pdsch.grant)) {
Error("Computing DL grant");
continue;
}
// Set soft buffer

@ -184,7 +184,9 @@ void sf_worker::work_imp()
ul_sf.tti = tti_rx;
// Set UL grant availability prior to any UL processing
phy->ue_db.set_ul_grant_available(tti_rx, ul_grants);
if (phy->ue_db.set_ul_grant_available(tti_rx, ul_grants)) {
Error("Error setting UL grants. Some grant's RNTI does not exist.");
}
// Process UL
for (uint32_t cc = 0; cc < cc_workers.size(); cc++) {

@ -248,7 +248,9 @@ void phy::set_config(uint16_t rnti, const phy_rrc_cfg_list_t& phy_cfg_list)
void phy::complete_config(uint16_t rnti)
{
// Forwards call to the UE Database
workers_common.ue_db.complete_config(rnti);
if (workers_common.ue_db.complete_config(rnti) < SRSLTE_SUCCESS) {
Error("Error completing configuration for RNTI %x. It does not exist.", rnti);
}
}
void phy::configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch)

@ -23,13 +23,13 @@ void phy_ue_db::init(stack_interface_phy_lte* stack_ptr,
cell_cfg_list = &cell_cfg_list_;
}
inline void phy_ue_db::_add_rnti(uint16_t rnti)
inline int phy_ue_db::_add_rnti(uint16_t rnti)
{
// Private function not mutexed
// Assert RNTI does NOT exist
if (ue_db.count(rnti)) {
return;
return SRSLTE_ERROR;
}
// Create new UE by accesing it
@ -51,6 +51,8 @@ inline void phy_ue_db::_add_rnti(uint16_t rnti)
for (uint32_t tti = 0; tti < TTIMOD_SZ; tti++) {
_clear_tti_pending_rnti(tti, rnti);
}
return SRSLTE_SUCCESS;
}
inline void phy_ue_db::_clear_tti_pending_rnti(uint32_t tti, uint16_t rnti)
@ -234,13 +236,13 @@ inline srsran::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb
// Make sure the C-RNTI exists and the cell/carrier is configured
if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) {
ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.", enb_cc_idx, rnti);
return default_cfg;
return SRSLTE_ERROR;
}
// Write the current configuration
uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx);
// Otherwise return current configuration
return ue_db.at(rnti).cell_info.at(ue_cc_idx).phy_cfg;
phy_cfg = ue_db.at(rnti).cell_info.at(ue_cc_idx).phy_cfg;
return SRSLTE_SUCCESS;
}
void phy_ue_db::clear_tti_pending_ack(uint32_t tti)
@ -329,13 +331,17 @@ void phy_ue_db::addmod_rnti(uint16_t rnti, const phy_interface_rrc_lte::phy_rrc_
}
}
void phy_ue_db::rem_rnti(uint16_t rnti)
int phy_ue_db::rem_rnti(uint16_t rnti)
{
std::lock_guard<std::mutex> lock(mutex);
if (ue_db.count(rnti) != 0) {
ue_db.erase(rnti);
if (ue_db.count(rnti) == 0) {
return SRSLTE_ERROR;
}
ue_db.erase(rnti);
return SRSLTE_SUCCESS;
}
uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti)
@ -350,7 +356,7 @@ uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti)
return nof_configured_scell;
}
void phy_ue_db::complete_config(uint16_t rnti)
int phy_ue_db::complete_config(uint16_t rnti)
{
std::lock_guard<std::mutex> lock(mutex);
@ -368,9 +374,11 @@ void phy_ue_db::complete_config(uint16_t rnti)
ue_db[rnti].cell_info[ue_cc_idx].stash_use_tbs_index_alt =
ue_db[rnti].cell_info[ue_cc_idx].phy_cfg.dl_cfg.pdsch.use_tbs_index_alt;
}
return SRSLTE_SUCCESS;
}
void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate)
int phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate)
{
std::lock_guard<std::mutex> lock(mutex);
@ -383,12 +391,11 @@ void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, boo
// If scell is default only complain
if (activate and cell_info.state == cell_state_none) {
ERROR("RNTI 0x%X SCell %d has received an activation MAC command but it was not configured", rnti, ue_cc_idx);
return;
return SRSLTE_ERROR;
}
// Set scell state
cell_info.state = (activate) ? cell_state_secondary_active : cell_state_secondary_inactive;
}
bool phy_ue_db::ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const
{
@ -411,10 +418,10 @@ srsran_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) con
if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) {
uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx);
if (ue_cc_idx == 0) {
ret.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt;
dl_cfg.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt;
}
}
return ret;
return SRSLTE_SUCCESS;
}
srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const
@ -427,22 +434,36 @@ srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx
if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) {
uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx);
if (ue_cc_idx == 0) {
ret.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled;
dci_cfg.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled;
}
}
return ret;
return SRSLTE_SUCCESS;
}
srsran_ul_cfg_t phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const
{
std::lock_guard<std::mutex> lock(mutex);
return _get_rnti_config(rnti, enb_cc_idx).ul_cfg;
srslte::phy_cfg_t phy_cfg = {};
if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
ul_cfg = phy_cfg.ul_cfg;
return SRSLTE_SUCCESS;
}
srsran_dci_cfg_t phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const
{
std::lock_guard<std::mutex> lock(mutex);
return _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci;
srslte::phy_cfg_t phy_cfg = {};
if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
dci_cfg = phy_cfg.dl_cfg.dci;
return SRSLTE_SUCCESS;
}
bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srsran_dci_dl_t& dci)
@ -509,17 +530,17 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti,
// There is a PUSCH grant available for the provided RNTI in at least one serving cell and this call is for PUCCH
if (pusch_grant_available and not is_pusch_available) {
return 0;
return SRSLTE_SUCCESS;
}
// There is a PUSCH grant and enb_cc_idx with lowest ue_cc_idx with a grant
if (pusch_grant_available and uci_enb_cc_id != enb_cc_idx) {
return 0;
return SRSLTE_SUCCESS;
}
// No PUSCH grant for this TTI and cell and no enb_cc_idx is not the PCell
if (not pusch_grant_available and _get_ue_cc_idx(rnti, enb_cc_idx) != 0) {
return 0;
return SRSLTE_SUCCESS;
}
common_ue& ue = ue_db.at(rnti);
@ -570,7 +591,7 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti,
uci_required |= (srsran_uci_cfg_total_ack(&uci_cfg) > 0);
// Return whether UCI needs to be decoded
return uci_required ? 1 : 0;
return uci_required ? 1 : SRSLTE_SUCCESS;
}
void phy_ue_db::send_uci_data(uint32_t tti,
@ -671,6 +692,8 @@ void phy_ue_db::send_uci_data(uint32_t tti,
stack->ri_info(tti, rnti, cqi_cc_idx, uci_value.ri);
cqi_scell_info.last_ri = uci_value.ri;
}
return SRSLTE_SUCCESS;
}
void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb)
@ -684,6 +707,8 @@ void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid,
// Save resource allocation
ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid] = tb;
return SRSLTE_SUCCESS;
}
srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const
@ -695,11 +720,13 @@ srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uin
return {};
}
// Returns the latest stored UL transmission grant
return ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid];
// writes the latest stored UL transmission grant
ra_tb = ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid];
return SRSLTE_SUCCESS;
}
void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list)
int phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list)
{
std::lock_guard<std::mutex> lock(mutex);
@ -721,6 +748,10 @@ void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_l
// Rise Grant available flag
ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true;
}
// Rise Grant available flag
ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true;
}
}
return SRSLTE_SUCCESS;
}

Loading…
Cancel
Save