SRSENB: minor corrections

master
Xavier Arteaga 5 years ago committed by Xavier Arteaga
parent 9ee651d094
commit 922481659b

@ -56,12 +56,72 @@ public:
worker_end(uint32_t tx_mutex_cnt, cf_t* buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t tx_time); worker_end(uint32_t tx_mutex_cnt, cf_t* buffer[SRSLTE_MAX_PORTS], uint32_t nof_samples, srslte_timestamp_t tx_time);
// Common objects // Common objects
phy_cell_cfg_list_t cell_list; phy_args_t params = {};
phy_args_t params = {};
uint32_t get_nof_carriers() { return static_cast<uint32_t>(cell_list.size()); };
uint32_t get_nof_prb(uint32_t cc_idx)
{
uint32_t ret = 0;
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].cell.nof_prb;
}
return ret;
};
uint32_t get_nof_ports(uint32_t cc_idx)
{
uint32_t ret = 0;
uint32_t get_nof_carriers() { return (uint32_t)cell_list.size(); }; if (cc_idx < cell_list.size()) {
uint32_t get_nof_prb() { return (uint32_t)cell_list[0].cell.nof_prb; }; ret = cell_list[cc_idx].cell.nof_ports;
uint32_t get_nof_ports() { return (uint32_t)cell_list[0].cell.nof_ports; }; }
return ret;
};
uint32_t get_ul_earfcn(uint32_t cc_idx)
{
uint32_t ret = 0;
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].ul_earfcn;
// If there is no UL-EARFCN, deduce it from DL-EARFCN
if (ret == 0) {
ret = srslte_band_ul_earfcn(cell_list[cc_idx].dl_earfcn);
}
}
return ret;
};
uint32_t get_dl_earfcn(uint32_t cc_idx)
{
uint32_t ret = 0;
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].dl_earfcn;
}
return ret;
};
uint32_t get_rf_port(uint32_t cc_idx)
{
uint32_t ret = 0;
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].rf_port;
}
return ret;
};
srslte_cell_t get_cell(uint32_t cc_idx)
{
srslte_cell_t c = {};
if (cc_idx < cell_list.size()) {
c = cell_list[cc_idx].cell;
}
return c;
};
// Physical Uplink Config common // Physical Uplink Config common
srslte_ul_cfg_t ul_cfg_com = {}; srslte_ul_cfg_t ul_cfg_com = {};
@ -111,8 +171,9 @@ public:
void set_mch_period_stop(uint32_t stop); void set_mch_period_stop(uint32_t stop);
private: private:
std::vector<sem_t> tx_sem; phy_cell_cfg_list_t cell_list;
bool is_first_tx = false; std::vector<sem_t> tx_sem;
bool is_first_tx = false;
uint32_t nof_workers = 0; uint32_t nof_workers = 0;
uint32_t max_workers = 0; uint32_t max_workers = 0;

@ -86,28 +86,29 @@ FILE* f;
void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_) void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_)
{ {
srslte_cell_t cell = phy_->cell_list[cc_idx_].cell;
uint32_t nof_prb = phy_->get_nof_prb();
phy = phy_; phy = phy_;
log_h = log_h_; log_h = log_h_;
cc_idx = cc_idx_; cc_idx = cc_idx_;
srslte_cell_t cell = phy_->get_cell(cc_idx);
uint32_t nof_prb = phy_->get_nof_prb(cc_idx);
uint32_t sf_len = SRSLTE_SF_LEN_PRB(nof_prb);
// Init cell here // Init cell here
for (int p = 0; p < SRSLTE_MAX_PORTS; p++) { for (uint32_t izeof(cf_t) * (size_t)nsamplp = 0; p < SRSLTE_MAX_PORTS; p++) {
signal_buffer_rx[p] = srslte_vec_cf_malloc(2 * SRSLTE_SF_LEN_PRB(nof_prb)); signal_buffer_rx[p] = srslte_vec_cf_malloc(2 * sf_len);
if (!signal_buffer_rx[p]) { if (!signal_buffer_rx[p]) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory\n");
return; return;
} }
bzero(signal_buffer_rx[p], 2 * SRSLTE_SF_LEN_PRB(phy->get_nof_prb()) * sizeof(cf_t)); srslte_vec_cf_zero(signal_buffer_rx[p], 2 * sf_len);
signal_buffer_tx[p] = (cf_t*)srslte_vec_malloc(2 * SRSLTE_SF_LEN_PRB(nof_prb) * sizeof(cf_t)); signal_buffer_tx[p] = srslte_vec_cf_malloc(2 * sf_len);
if (!signal_buffer_tx[p]) { if (!signal_buffer_tx[p]) {
ERROR("Error allocating memory\n"); ERROR("Error allocating memory\n");
return; return;
} }
bzero(signal_buffer_tx[p], 2 * SRSLTE_SF_LEN_PRB(nof_prb) * sizeof(cf_t)); srslte_vec_cf_zero(signal_buffer_tx[p], 2 * sf_len);
} }
if (srslte_enb_dl_init(&enb_dl, signal_buffer_tx, phy->get_nof_prb())) { if (srslte_enb_dl_init(&enb_dl, signal_buffer_tx, nof_prb)) {
ERROR("Error initiating ENB DL\n"); ERROR("Error initiating ENB DL\n");
return; return;
} }
@ -115,7 +116,7 @@ void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_)
ERROR("Error initiating ENB DL\n"); ERROR("Error initiating ENB DL\n");
return; return;
} }
if (srslte_enb_ul_init(&enb_ul, signal_buffer_rx[0], phy->get_nof_prb())) { if (srslte_enb_ul_init(&enb_ul, signal_buffer_rx[0], nof_prb)) {
ERROR("Error initiating ENB UL\n"); ERROR("Error initiating ENB UL\n");
return; return;
} }
@ -771,19 +772,19 @@ void cc_worker::ue::metrics_ul(uint32_t mcs, float rssi, float sinr, float turbo
int cc_worker::read_ce_abs(float* ce_abs) int cc_worker::read_ce_abs(float* ce_abs)
{ {
int sz = srslte_symbol_sz(phy->get_nof_prb()); int sz = srslte_symbol_sz(phy->get_nof_prb(cc_idx));
bzero(ce_abs, sizeof(float) * sz); bzero(ce_abs, sizeof(float) * sz);
int g = (sz - SRSLTE_NRE * phy->get_nof_prb()) / 2; int g = (sz - SRSLTE_NRE * phy->get_nof_prb(cc_idx)) / 2;
srslte_vec_abs_dB_cf(enb_ul.chest_res.ce, -80.0f, &ce_abs[g], SRSLTE_NRE * phy->get_nof_prb()); srslte_vec_abs_dB_cf(enb_ul.chest_res.ce, -80.0f, &ce_abs[g], SRSLTE_NRE * phy->get_nof_prb(cc_idx));
return sz; return sz;
} }
int cc_worker::read_ce_arg(float* ce_arg) int cc_worker::read_ce_arg(float* ce_arg)
{ {
int sz = srslte_symbol_sz(phy->get_nof_prb()); int sz = srslte_symbol_sz(phy->get_nof_prb(cc_idx));
bzero(ce_arg, sizeof(float) * sz); bzero(ce_arg, sizeof(float) * sz);
int g = (sz - SRSLTE_NRE * phy->get_nof_prb()) / 2; int g = (sz - SRSLTE_NRE * phy->get_nof_prb(cc_idx)) / 2;
srslte_vec_arg_deg_cf(enb_ul.chest_res.ce, -80.0f, &ce_arg[g], SRSLTE_NRE * phy->get_nof_prb()); srslte_vec_arg_deg_cf(enb_ul.chest_res.ce, -80.0f, &ce_arg[g], SRSLTE_NRE * phy->get_nof_prb(cc_idx));
return sz; return sz;
} }

@ -89,14 +89,14 @@ void sf_worker::init(phy_common* phy_, srslte::log* log_h_)
cc_workers.push_back(std::unique_ptr<cc_worker>(q)); cc_workers.push_back(std::unique_ptr<cc_worker>(q));
} }
if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, phy->get_nof_prb())) { if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, phy->get_nof_prb(0))) {
ERROR("Error initiating soft buffer\n"); ERROR("Error initiating soft buffer\n");
exit(-1); exit(-1);
} }
srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer); srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer);
Info("Worker %d configured cell %d PRB\n", get_id(), phy->get_nof_prb()); Info("Worker %d configured cell %d PRB\n", get_id(), phy->get_nof_prb(0));
initiated = true; initiated = true;
running = true; running = true;
@ -190,8 +190,8 @@ void sf_worker::work_imp()
ul_sf.tti = tti_rx; ul_sf.tti = tti_rx;
// Process UL // Process UL
for (auto& q : phy->dl_grants[t_tx_dl]) { for (uint32_t cc = 0; cc < cc_workers.size(); cc++) {
q.cfi = mbsfn_cfg.non_mbsfn_region_length; cc_workers[cc]->work_ul(&ul_sf, &phy->ul_grants[t_rx][cc]);
} }
// Get DL scheduling for the TX TTI from MAC // Get DL scheduling for the TX TTI from MAC
@ -233,13 +233,13 @@ void sf_worker::work_imp()
// Get Transmission buffers // Get Transmission buffers
for (uint32_t cc = 0, i = 0; cc < phy->get_nof_carriers(); cc++) { for (uint32_t cc = 0, i = 0; cc < phy->get_nof_carriers(); cc++) {
for (uint32_t ant = 0; ant < phy->get_nof_ports(); ant++, i++) { for (uint32_t ant = 0; ant < phy->get_nof_ports(cc); ant++, i++) {
signal_buffer_tx[i] = cc_workers[cc]->get_buffer_tx(ant); signal_buffer_tx[i] = cc_workers[cc]->get_buffer_tx(ant);
} }
} }
Debug("Sending to radio\n"); Debug("Sending to radio\n");
phy->worker_end(tx_worker_cnt, signal_buffer_tx, SRSLTE_SF_LEN_PRB(phy->get_nof_prb()), tx_time); phy->worker_end(tx_worker_cnt, signal_buffer_tx, SRSLTE_SF_LEN_PRB(phy->get_nof_prb(0)), tx_time);
#ifdef DEBUG_WRITE_FILE #ifdef DEBUG_WRITE_FILE
fwrite(signal_buffer_tx, SRSLTE_SF_LEN_PRB(phy->cell.nof_prb) * sizeof(cf_t), 1, f); fwrite(signal_buffer_tx, SRSLTE_SF_LEN_PRB(phy->cell.nof_prb) * sizeof(cf_t), 1, f);

@ -89,49 +89,32 @@ void txrx::run_thread()
cf_t* buffer[SRSLTE_MAX_PORTS] = {}; cf_t* buffer[SRSLTE_MAX_PORTS] = {};
srslte_timestamp_t rx_time = {}; srslte_timestamp_t rx_time = {};
srslte_timestamp_t tx_time = {}; srslte_timestamp_t tx_time = {};
uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->get_nof_prb()); uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->get_nof_prb(0));
float samp_rate = srslte_sampling_freq_hz(worker_com->get_nof_prb()); float samp_rate = srslte_sampling_freq_hz(worker_com->get_nof_prb(0));
log_h->console("Setting Sampling frequency %.2f MHz\n", (float)samp_rate / 1000000); log_h->console("Setting Sampling frequency %.2f MHz\n", (float)samp_rate / 1000000);
// Configure radio // Configure radio
radio_h->set_rx_srate(0, samp_rate); radio_h->set_rx_srate(0, samp_rate);
radio_h->set_tx_srate(0, samp_rate); radio_h->set_tx_srate(0, samp_rate);
for (auto& cfg : worker_com->cell_list) { // Set Tx/Rx frequencies
// If there is no UL-EARDCN, deduce it from DL-EARFCN for (uint32_t cc_idx = 0; cc_idx < worker_com->get_nof_carriers(); cc_idx++) {
if (cfg.ul_earfcn == 0) { float tx_freq_hz = 1e6 * srslte_band_fd(worker_com->get_dl_earfcn(cc_idx));
cfg.ul_earfcn = srslte_band_ul_earfcn(cfg.dl_earfcn); float rx_freq_hz = 1e6 * srslte_band_fd(worker_com->get_ul_earfcn(cc_idx));
} uint32_t rf_port = worker_com->get_rf_port(cc_idx);
for (uint32_t i = 0; i < worker_com->get_nof_ports(cc_idx); i++) {
// Set Tx/Rx frequencies radio_h->set_tx_freq(0, rf_port + i, tx_freq_hz);
float tx_freq_hz = 1e6 * srslte_band_fd(cfg.dl_earfcn); radio_h->set_rx_freq(0, rf_port + i, rx_freq_hz);
float rx_freq_hz = 1e6 * srslte_band_fd(cfg.ul_earfcn);
for (uint32_t i = 0; i < worker_com->get_nof_ports(); i++) {
radio_h->set_tx_freq(0, cfg.rf_port + i, tx_freq_hz);
radio_h->set_rx_freq(0, cfg.rf_port + i, rx_freq_hz);
} }
} }
// Set channel emulator sampling rate
if (ul_channel) { if (ul_channel) {
ul_channel->set_srate(static_cast<uint32_t>(samp_rate)); ul_channel->set_srate(static_cast<uint32_t>(samp_rate));
for (auto& cfg : worker_com->cell_list) {
// If there is no UL-EARDCN, deduce it from DL-EARFCN
if (cfg.ul_earfcn == 0) {
cfg.ul_earfcn = srslte_band_ul_earfcn(cfg.dl_earfcn);
}
// Set Tx/Rx frequencies
float tx_freq_hz = 1e6 * srslte_band_fd(cfg.dl_earfcn);
float rx_freq_hz = 1e6 * srslte_band_fd(cfg.ul_earfcn);
for (uint32_t i = 0; i < worker_com->get_nof_ports(); i++) {
radio_h->set_tx_freq(0, cfg.rf_port + i, tx_freq_hz);
radio_h->set_rx_freq(0, cfg.rf_port + i, rx_freq_hz);
}
}
} }
log_h->info("Starting RX/TX thread nof_prb=%d, sf_len=%d\n", worker_com->get_nof_prb(), sf_len); log_h->info("Starting RX/TX thread nof_prb=%d, sf_len=%d\n", worker_com->get_nof_prb(0), sf_len);
// Set TTI so that first TX is at tti=0 // Set TTI so that first TX is at tti=0
tti = 10235; tti = 10235;
@ -141,9 +124,10 @@ void txrx::run_thread()
tti = (tti + 1) % 10240; tti = (tti + 1) % 10240;
worker = (sf_worker*)workers_pool->wait_worker(tti); worker = (sf_worker*)workers_pool->wait_worker(tti);
if (worker) { if (worker) {
// Multiple cell buffer mapping
for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) { for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) {
uint32_t rf_port = worker_com->cell_list[cc].rf_port; uint32_t rf_port = worker_com->get_rf_port(cc);
for (uint32_t p = 0; p < worker_com->get_nof_ports(); p++) { for (uint32_t p = 0; p < worker_com->get_nof_ports(cc); p++) {
buffer[rf_port + p] = worker->get_buffer_rx(cc, p); buffer[rf_port + p] = worker->get_buffer_rx(cc, p);
} }
} }
@ -173,7 +157,7 @@ void txrx::run_thread()
// Trigger prach worker execution // Trigger prach worker execution
for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) { for (uint32_t cc = 0; cc < worker_com->get_nof_carriers(); cc++) {
prach->new_tti(cc, tti, buffer[worker_com->cell_list[cc].rf_port * worker_com->get_nof_ports()]); prach->new_tti(cc, tti, buffer[worker_com->get_rf_port(cc) * worker_com->get_nof_ports(cc)]);
} }
} else { } else {
// wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here // wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here

Loading…
Cancel
Save