Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downlink PAPR measurement to eNB. #659

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/include/srsran/interfaces/enb_command_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ namespace srsenb {
class enb_command_interface
{
public:
/**
* Trigger downlink singnal measurements.
*/
virtual void cmd_cell_measure() = 0;
/**
* Sets the relative gain of a cell from it's index (following rr.conf) order.
* @param cell_id Provides a cell identifier
Expand Down
1 change: 1 addition & 0 deletions srsenb/hdr/enb.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class enb : public enb_metrics_interface, enb_command_interface
bool get_metrics(enb_metrics_t* m) override;

// eNodeB command interface
void cmd_cell_measure() override;
void cmd_cell_gain(uint32_t cell_id, float gain) override;

private:
Expand Down
2 changes: 2 additions & 0 deletions srsenb/hdr/phy/enb_phy_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class enb_phy_base

virtual void get_metrics(std::vector<phy_metrics_t>& m) = 0;

virtual void cmd_cell_measure() = 0;

virtual void cmd_cell_gain(uint32_t cell_idx, float gain_db) = 0;
};

Expand Down
2 changes: 2 additions & 0 deletions srsenb/hdr/phy/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class phy final : public enb_phy_base, public phy_interface_stack_lte, public sr

void get_metrics(std::vector<phy_metrics_t>& metrics) override;

void cmd_cell_measure() override;

void cmd_cell_gain(uint32_t cell_id, float gain_db) override;

void radio_overflow() override{};
Expand Down
41 changes: 41 additions & 0 deletions srsenb/hdr/phy/phy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ class phy_common
return c;
};

void set_cell_measure_trigger()
{
// Trigger on LTE cell
for (auto it_lte = cell_list_lte.begin(); it_lte != cell_list_lte.end(); ++it_lte) {
it_lte->dl_measure = true;
}

// Trigger on NR cell
for (auto it_nr = cell_list_nr.begin(); it_nr != cell_list_nr.end(); ++it_nr) {
it_nr->dl_measure = true;
}
}

void set_cell_gain(uint32_t cell_id, float gain_db)
{
// Find LTE cell
Expand All @@ -195,6 +208,20 @@ class phy_common
srsran::console("cell ID %d not found\n", cell_id);
}

bool get_cell_measure_trigger(uint32_t cc_idx)
{
if (cc_idx < cell_list_lte.size()) {
return cell_list_lte.at(cc_idx).dl_measure;
}

cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
return cell_list_nr.at(cc_idx).dl_measure;
}

return false;
}

float get_cell_gain(uint32_t cc_idx)
{
if (cc_idx < cell_list_lte.size()) {
Expand All @@ -209,6 +236,20 @@ class phy_common
return 0.0f;
}

void clear_cell_measure_trigger(uint32_t cc_idx)
{
if (cc_idx < cell_list_lte.size()) {
cell_list_lte.at(cc_idx).dl_measure = false;
}

cc_idx -= cell_list_lte.size();
if (cc_idx < cell_list_nr.size()) {
cell_list_nr.at(cc_idx).dl_measure = false;
}

return;
}

// Common Physical Uplink DMRS configuration
srsran_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {};

Expand Down
2 changes: 2 additions & 0 deletions srsenb/hdr/phy/phy_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct phy_cell_cfg_t {
uint32_t root_seq_idx;
uint32_t num_ra_preambles;
float gain_db;
bool dl_measure;
};

struct phy_cell_cfg_nr_t {
Expand All @@ -51,6 +52,7 @@ struct phy_cell_cfg_nr_t {
uint32_t root_seq_idx;
uint32_t num_ra_preambles;
float gain_db;
bool dl_measure;
};

typedef std::vector<phy_cell_cfg_t> phy_cell_cfg_list_t;
Expand Down
5 changes: 5 additions & 0 deletions srsenb/hdr/phy/vnf_phy_nr.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class vnf_phy_nr : public srsenb::enb_phy_base, public srsenb::phy_interface_sta
int dl_config_request(const dl_config_request_t& request) override;
int tx_request(const tx_request_t& request) override;

void cmd_cell_measure() override
{
// Do nothing
}

void cmd_cell_gain(uint32_t cell_idx, float gain_db) override
{
// Do nothing
Expand Down
5 changes: 5 additions & 0 deletions srsenb/src/enb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ void enb::cmd_cell_gain(uint32_t cell_id, float gain)
phy->cmd_cell_gain(cell_id, gain);
}

void enb::cmd_cell_measure()
{
phy->cmd_cell_measure();
}

std::string enb::get_build_mode()
{
return std::string(srsran_get_build_mode());
Expand Down
5 changes: 5 additions & 0 deletions srsenb/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
{
struct pollfd pfd = {STDIN_FILENO, POLLIN, 0};
string input_line;

while (running) {
int ret = poll(&pfd, 1, 1000); // query stdin with a timeout of 1000ms
if (ret == 1) {
Expand All @@ -458,6 +459,9 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
cout << "Enter t to restart trace." << endl;
}
metrics->toggle_print(do_metrics);
} else if (cmd[0] == "m") {
// Trigger cell measurements
control->cmd_cell_measure();
} else if (cmd[0] == "q") {
raise(SIGTERM);
} else if (cmd[0] == "cell_gain") {
Expand All @@ -475,6 +479,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
} else {
cout << "Available commands: " << endl;
cout << " t: starts console trace" << endl;
cout << " m: downlink signal measurements" << endl;
cout << " q: quit srsenb" << endl;
cout << " cell_gain: set relative cell gain" << endl;
cout << endl;
Expand Down
19 changes: 19 additions & 0 deletions srsenb/src/phy/lte/cc_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* and at http://www.gnu.org/licenses/.
*
*/
#include <iomanip>

#include "srsran/common/threads.h"
#include "srsran/srsran.h"
Expand Down Expand Up @@ -262,6 +263,24 @@ void cc_worker::work_dl(const srsran_dl_sf_cfg_t& dl_sf_cfg,
srsran_vec_sc_prod_cfc(signal_buffer_tx[i], scale, signal_buffer_tx[i], sf_len);
}
}

// Measure if flag was triggered
bool cell_meas_flag = phy->get_cell_measure_trigger(cc_idx);
if (cell_meas_flag == true) {
uint32_t sf_len = SRSRAN_SF_LEN_PRB(enb_dl.cell.nof_prb);
for (uint32_t i = 0; i < enb_dl.cell.nof_ports; i++) {
// PAPR measure
std::vector<float> sigSq(sf_len);
srsran_vec_abs_square_cf(signal_buffer_tx[i], sigSq.data(), sf_len);
float sigPMax = sigSq[srsran_vec_max_abs_fi(sigSq.data(), sf_len)];
float sigPMean = srsran_vec_acc_ff(sigSq.data(), sf_len) / float(sf_len);
float PAPRdB = 10.0f * log10(sigPMax / sigPMean);
std::cout << "Cell #" << cc_idx << " port #" << i << " PAPR = " << std::setprecision(4) << PAPRdB << " dB "
<< std::endl;
}
// clear measurement flag on cell
phy->clear_cell_measure_trigger(cc_idx);
}
}

void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_grant,
Expand Down
5 changes: 5 additions & 0 deletions srsenb/src/phy/phy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ void phy::cmd_cell_gain(uint32_t cell_id, float gain_db)
workers_common.set_cell_gain(cell_id, gain_db);
}

void phy::cmd_cell_measure()
{
workers_common.set_cell_measure_trigger();
}

/***** RRC->PHY interface **********/

void phy::set_config(uint16_t rnti, const phy_rrc_cfg_list_t& phy_cfg_list)
Expand Down