mirror of https://github.com/PentHertz/srsLTE.git
rewrite cell handling in TTCN3 PHY and SS
This commit is contained in:
parent
2a46413121
commit
3d7598a4cb
|
@ -65,7 +65,6 @@ public:
|
|||
void set_cell_map(const cell_list_t& cells_);
|
||||
|
||||
// phy_interface_rrc_lte
|
||||
void get_current_cell(srslte_cell_t* cell_, uint32_t* earfcn_ = NULL);
|
||||
uint32_t get_current_earfcn();
|
||||
uint32_t get_current_pci();
|
||||
void set_config_scell(asn1::rrc::scell_to_add_mod_r10_s* scell_config);
|
||||
|
@ -126,9 +125,13 @@ private:
|
|||
srslte::logger* logger = nullptr;
|
||||
srslte::log_filter log;
|
||||
|
||||
// The current cell
|
||||
// All available cells
|
||||
cell_list_t cells;
|
||||
uint32_t cell_idx = 0;
|
||||
|
||||
// The current PCell
|
||||
cell_t pcell = {};
|
||||
bool pcell_set = false;
|
||||
|
||||
phy_cfg_t phy_cfg = {};
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
virtual void prach_indication(uint32_t preamble_index, const uint32_t& cell_id) = 0;
|
||||
virtual void sr_req(uint32_t tti_tx) = 0;
|
||||
virtual void tx_pdu(const uint8_t* payload, const int len, const uint32_t tx_tti) = 0;
|
||||
virtual void select_cell(srslte_cell_t cell) = 0;
|
||||
};
|
||||
|
||||
class phy_interface_syssim
|
||||
|
|
|
@ -508,8 +508,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
dl_rnti = ue->get_dl_sched_rnti(tti);
|
||||
if (pcell_idx == -1) {
|
||||
log.debug("Skipping TTI. Pcell not yet selected.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// DL/UL processing if UE has selected cell
|
||||
dl_rnti = ue->get_dl_sched_rnti(tti);
|
||||
if (SRSLTE_RNTI_ISSI(dl_rnti)) {
|
||||
// deliver SIBs one after another
|
||||
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
|
||||
|
@ -702,17 +707,6 @@ public:
|
|||
// SYSSIM defines what cells the UE can connect to
|
||||
ue->set_cell_map(phy_cells);
|
||||
}
|
||||
|
||||
// reselect SS Pcell
|
||||
float max_power = -145;
|
||||
for (uint32_t i = 0; i < cells.size(); ++i) {
|
||||
float actual_power = cells[i]->initial_power - cells[i]->attenuation;
|
||||
if (actual_power > max_power) {
|
||||
max_power = actual_power;
|
||||
pcell_idx = i;
|
||||
log.info("Selecting PCI=%d with TxPower=%.2f as Pcell\n", cells[pcell_idx]->cell.id, max_power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool have_valid_pcell() { return (pcell_idx >= 0 && pcell_idx < static_cast<int>(cells.size())); }
|
||||
|
@ -871,6 +865,18 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
void select_cell(srslte_cell_t phy_cell)
|
||||
{
|
||||
// find matching cell in SS cell list
|
||||
for (uint32_t i = 0; i < cells.size(); ++i) {
|
||||
if (cells[i]->cell.id == phy_cell.id) {
|
||||
pcell_idx = i;
|
||||
log.info("New PCell: PCI=%d\n", cells[pcell_idx]->cell.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// SYS interface
|
||||
ttcn3_ut_interface ut;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace srsue {
|
||||
|
||||
#define MIN_IN_SYNC_POWER (-100)
|
||||
#define MIN_IN_SYNC_POWER (-120.0)
|
||||
#define DEFAULT_RSRQ (-3.0)
|
||||
|
||||
lte_ttcn3_phy::lte_ttcn3_phy(srslte::logger* logger_) : logger(logger_) {}
|
||||
|
@ -72,19 +72,6 @@ void lte_ttcn3_phy::set_cell_map(const cell_list_t& cells_)
|
|||
cells = cells_;
|
||||
}
|
||||
|
||||
// The interface for RRC
|
||||
void lte_ttcn3_phy::get_current_cell(srslte_cell_t* cell_, uint32_t* earfcn_)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
if (cell_) {
|
||||
memcpy(cell_, &pcell.info, sizeof(srslte_cell_t));
|
||||
}
|
||||
if (earfcn_) {
|
||||
*earfcn_ = pcell.earfcn;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t lte_ttcn3_phy::get_current_earfcn()
|
||||
{
|
||||
return pcell.earfcn;
|
||||
|
@ -130,43 +117,39 @@ int lte_ttcn3_phy::meas_stop(uint32_t earfcn, int pci)
|
|||
return 0;
|
||||
};
|
||||
|
||||
void lte_ttcn3_phy::select_pcell()
|
||||
{
|
||||
// select strongest cell as PCell
|
||||
float max_power = -145;
|
||||
int max_index = 0;
|
||||
for (uint32_t i = 0; i < cells.size(); ++i) {
|
||||
if (cells[i].power > max_power) {
|
||||
max_power = cells[i].power;
|
||||
max_index = i;
|
||||
}
|
||||
}
|
||||
pcell = cells[max_index];
|
||||
log.info("Setting PCell to EARFCN=%d CellId=%d with RS power=%.2f\n", pcell.earfcn, pcell.info.id, pcell.power);
|
||||
}
|
||||
|
||||
/* Cell search and selection procedures */
|
||||
phy_interface_rrc_lte::cell_search_ret_t lte_ttcn3_phy::cell_search(phy_cell_t* found_cell)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
select_pcell();
|
||||
|
||||
log.info("Running cell search in PHY\n");
|
||||
cell_search_ret_t ret = {};
|
||||
|
||||
// Consider cell found if Pcell power >= -100dBm
|
||||
if (pcell.power >= MIN_IN_SYNC_POWER) {
|
||||
cell_search_ret_t ret = {};
|
||||
ret.found = cell_search_ret_t::CELL_NOT_FOUND;
|
||||
|
||||
if (not cells.empty() && cell_idx < cells.size()) {
|
||||
log.info("Found Cell: EARFCN=%d CellId=%d\n", cells[cell_idx].earfcn, cells[cell_idx].info.id);
|
||||
if (found_cell) {
|
||||
found_cell->earfcn = pcell.earfcn;
|
||||
found_cell->pci = pcell.info.id;
|
||||
found_cell->earfcn = cells[cell_idx].earfcn;
|
||||
found_cell->pci = cells[cell_idx].info.id;
|
||||
}
|
||||
ret.found = cell_search_ret_t::CELL_FOUND;
|
||||
|
||||
// advance index
|
||||
cell_idx++;
|
||||
|
||||
if (cell_idx < cells.size()) {
|
||||
// more cells will be reported
|
||||
ret.last_freq = cell_search_ret_t::MORE_FREQS;
|
||||
} else {
|
||||
// all available cells have been reported, reset cell index
|
||||
ret.last_freq = cell_search_ret_t::NO_MORE_FREQS;
|
||||
cell_idx = 0;
|
||||
}
|
||||
ret.found = cell_search_ret_t::CELL_FOUND;
|
||||
ret.last_freq = cell_search_ret_t::NO_MORE_FREQS;
|
||||
} else {
|
||||
// no suitable cell found
|
||||
ret.found = cell_search_ret_t::CELL_NOT_FOUND;
|
||||
log.warning("No cells configured yet.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
@ -175,17 +158,31 @@ bool lte_ttcn3_phy::cell_select(phy_cell_t* rrc_cell)
|
|||
// try to find RRC cell in current cell map
|
||||
for (auto& cell : cells) {
|
||||
if (cell.info.id == rrc_cell->pci) {
|
||||
pcell = cell;
|
||||
return true;
|
||||
if (cell.power >= MIN_IN_SYNC_POWER) {
|
||||
pcell = cell;
|
||||
pcell_set = true;
|
||||
syssim->select_cell(pcell.info);
|
||||
log.info("Select PCell with %.2f on PCI=%d on EARFCN=%d.\n", cell.power, rrc_cell->pci, rrc_cell->earfcn);
|
||||
} else {
|
||||
pcell_set = false;
|
||||
log.error("Power of selected cell too low (%.2f < %.2f)\n", cell.power, MIN_IN_SYNC_POWER);
|
||||
}
|
||||
|
||||
return pcell_set;
|
||||
}
|
||||
}
|
||||
|
||||
log.error("Couldn't fine RRC cell with PCI=%d on EARFCN=%d in cell map.\n", rrc_cell->pci, rrc_cell->earfcn);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool lte_ttcn3_phy::cell_is_camping()
|
||||
{
|
||||
return (pcell.power >= MIN_IN_SYNC_POWER);
|
||||
if (pcell_set) {
|
||||
log.info("pcell.power=%2.f\n", pcell.power);
|
||||
return (pcell.power >= MIN_IN_SYNC_POWER);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void lte_ttcn3_phy::reset()
|
||||
|
@ -369,21 +366,33 @@ void lte_ttcn3_phy::run_tti()
|
|||
m.earfcn = cell.earfcn;
|
||||
m.rsrp = cell.power;
|
||||
m.rsrq = DEFAULT_RSRQ;
|
||||
|
||||
// Measurement for PCell needs to have EARFCN set to 0
|
||||
if (pcell_set && m.earfcn == pcell.earfcn) {
|
||||
m.earfcn = 0;
|
||||
}
|
||||
|
||||
log.debug("Create cell measurement for PCI=%d, EARFCN=%d with RSRP=%.2f\n", m.pci, m.earfcn, m.rsrp);
|
||||
phy_meas.push_back(m);
|
||||
}
|
||||
stack->new_cell_meas(phy_meas);
|
||||
|
||||
if (not phy_meas.empty()) {
|
||||
stack->new_cell_meas(phy_meas);
|
||||
}
|
||||
|
||||
// check if Pcell is in sync
|
||||
for (auto& cell : cells) {
|
||||
if (cell.info.id == pcell.info.id) {
|
||||
if (cell.power >= MIN_IN_SYNC_POWER) {
|
||||
log.debug("PCell id=%d power=%.2f -> sync\n", pcell.info.id, cell.power);
|
||||
stack->in_sync();
|
||||
} else {
|
||||
log.debug("PCell id=%d power=%.2f -> out of sync\n", pcell.info.id, cell.power);
|
||||
stack->out_of_sync();
|
||||
if (pcell_set) {
|
||||
for (auto& cell : cells) {
|
||||
if (cell.info.id == pcell.info.id) {
|
||||
if (cell.power >= MIN_IN_SYNC_POWER) {
|
||||
log.debug("PCell id=%d power=%.2f -> sync\n", pcell.info.id, cell.power);
|
||||
stack->in_sync();
|
||||
} else {
|
||||
log.debug("PCell id=%d power=%.2f -> out of sync\n", pcell.info.id, cell.power);
|
||||
stack->out_of_sync();
|
||||
}
|
||||
break; // make sure to call stack only once
|
||||
}
|
||||
break; // make sure to call stack only once
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue