2019-04-23 01:53:11 -07:00
|
|
|
/*
|
2020-03-13 04:12:52 -07:00
|
|
|
* Copyright 2013-2020 Software Radio Systems Limited
|
2017-06-02 03:46:06 -07:00
|
|
|
*
|
|
|
|
* This file is part of srsLTE.
|
|
|
|
*
|
2019-04-23 01:53:11 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2017-06-02 03:46:06 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2019-04-23 01:53:11 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2017-06-02 03:46:06 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
2017-06-01 03:25:57 -07:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSENB_PHCH_COMMON_H
|
|
|
|
#define SRSENB_PHCH_COMMON_H
|
2017-06-01 03:25:57 -07:00
|
|
|
|
2020-01-22 09:03:50 -08:00
|
|
|
#include "phy_interfaces.h"
|
2020-02-18 09:09:28 -08:00
|
|
|
#include "srsenb/hdr/phy/phy_ue_db.h"
|
2018-05-15 08:01:51 -07:00
|
|
|
#include "srslte/common/gen_mch_tables.h"
|
2019-07-05 07:47:39 -07:00
|
|
|
#include "srslte/common/interfaces_common.h"
|
2017-06-01 03:25:57 -07:00
|
|
|
#include "srslte/common/log.h"
|
|
|
|
#include "srslte/common/thread_pool.h"
|
2019-07-05 07:47:39 -07:00
|
|
|
#include "srslte/common/threads.h"
|
|
|
|
#include "srslte/interfaces/enb_interfaces.h"
|
|
|
|
#include "srslte/interfaces/enb_metrics_interface.h"
|
2020-03-06 06:26:48 -08:00
|
|
|
#include "srslte/interfaces/radio_interfaces.h"
|
2019-12-16 07:04:22 -08:00
|
|
|
#include "srslte/phy/channel/channel.h"
|
2017-06-01 03:25:57 -07:00
|
|
|
#include "srslte/radio/radio.h"
|
2019-07-05 07:47:39 -07:00
|
|
|
#include <map>
|
2020-03-03 08:17:12 -08:00
|
|
|
#include <srslte/common/tti_sempahore.h>
|
2018-05-15 08:01:51 -07:00
|
|
|
#include <string.h>
|
2018-09-06 06:22:37 -07:00
|
|
|
|
2017-06-01 03:25:57 -07:00
|
|
|
namespace srsenb {
|
|
|
|
|
2019-04-23 01:53:11 -07:00
|
|
|
class phy_common
|
2017-06-01 03:25:57 -07:00
|
|
|
{
|
|
|
|
public:
|
2020-03-03 08:27:04 -08:00
|
|
|
phy_common() = default;
|
2018-09-06 06:22:37 -07:00
|
|
|
|
2020-01-22 09:03:50 -08:00
|
|
|
bool
|
|
|
|
init(const phy_cell_cfg_list_t& cell_list_, srslte::radio_interface_phy* radio_handler, stack_interface_phy_lte* mac);
|
2019-12-16 07:04:22 -08:00
|
|
|
void reset();
|
2017-06-01 03:25:57 -07:00
|
|
|
void stop();
|
2019-12-16 07:04:22 -08:00
|
|
|
|
2020-03-03 08:17:12 -08:00
|
|
|
/**
|
|
|
|
* TTI transmission semaphore, used for ensuring that PHY workers transmit following start order
|
|
|
|
*/
|
|
|
|
srslte::tti_semaphore<void*> semaphore;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs common end worker transmission tasks such as transmission and stack TTI execution
|
|
|
|
*
|
|
|
|
* @param tx_sem_id Semaphore identifier, the worker thread pointer is used
|
|
|
|
* @param buffer baseband IQ sample buffer
|
|
|
|
* @param nof_samples number of samples to transmit
|
|
|
|
* @param tx_time timestamp to transmit samples
|
|
|
|
*/
|
2020-03-06 06:26:48 -08:00
|
|
|
void worker_end(void* tx_sem_id, srslte::rf_buffer_t& buffer, uint32_t nof_samples, srslte_timestamp_t tx_time);
|
2017-06-01 03:25:57 -07:00
|
|
|
|
|
|
|
// Common objects
|
2020-01-23 06:12:26 -08:00
|
|
|
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;
|
2020-01-22 09:03:50 -08:00
|
|
|
|
2020-01-23 06:12:26 -08:00
|
|
|
if (cc_idx < cell_list.size()) {
|
|
|
|
ret = cell_list[cc_idx].cell.nof_ports;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
};
|
2020-03-13 00:41:18 -07:00
|
|
|
double get_ul_freq_hz(uint32_t cc_idx)
|
2020-01-23 06:12:26 -08:00
|
|
|
{
|
2020-03-13 00:41:18 -07:00
|
|
|
double ret = 0.0f;
|
2020-01-23 06:12:26 -08:00
|
|
|
|
|
|
|
if (cc_idx < cell_list.size()) {
|
2020-01-27 09:36:53 -08:00
|
|
|
ret = cell_list[cc_idx].ul_freq_hz;
|
2020-01-23 06:12:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
};
|
2020-03-13 00:41:18 -07:00
|
|
|
double get_dl_freq_hz(uint32_t cc_idx)
|
2020-01-23 06:12:26 -08:00
|
|
|
{
|
2020-03-13 00:41:18 -07:00
|
|
|
double ret = 0.0;
|
2020-01-23 06:12:26 -08:00
|
|
|
|
|
|
|
if (cc_idx < cell_list.size()) {
|
2020-01-27 09:36:53 -08:00
|
|
|
ret = cell_list[cc_idx].dl_freq_hz;
|
2020-01-23 06:12:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2020-03-02 08:51:00 -08:00
|
|
|
// Common Physical Uplink DMRS configuration
|
|
|
|
srslte_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {};
|
2017-06-01 03:25:57 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
srslte::radio_interface_phy* radio = nullptr;
|
|
|
|
stack_interface_phy_lte* stack = nullptr;
|
2019-10-23 09:09:39 -07:00
|
|
|
srslte::channel_ptr dl_channel = nullptr;
|
2019-06-06 07:52:37 -07:00
|
|
|
|
2020-03-03 08:20:44 -08:00
|
|
|
// Common objects for scheduling grants
|
2020-01-22 09:03:50 -08:00
|
|
|
stack_interface_phy_lte::ul_sched_list_t ul_grants[TTIMOD_SZ] = {};
|
|
|
|
stack_interface_phy_lte::dl_sched_list_t dl_grants[TTIMOD_SZ] = {};
|
2019-06-06 07:52:37 -07:00
|
|
|
|
2020-02-10 03:59:23 -08:00
|
|
|
/**
|
2020-02-18 09:09:28 -08:00
|
|
|
* UE Database object, direct public access, all PHY threads should be able to access this attribute directly
|
2020-02-10 03:59:23 -08:00
|
|
|
*/
|
2020-02-18 09:09:28 -08:00
|
|
|
phy_ue_db ue_db;
|
2019-04-23 01:53:11 -07:00
|
|
|
|
2019-06-06 07:52:37 -07:00
|
|
|
void configure_mbsfn(phy_interface_stack_lte::phy_cfg_mbsfn_t* cfg);
|
2018-05-15 08:01:51 -07:00
|
|
|
void build_mch_table();
|
|
|
|
void build_mcch_table();
|
2019-04-23 01:53:11 -07:00
|
|
|
bool is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti);
|
|
|
|
void set_mch_period_stop(uint32_t stop);
|
2018-01-12 07:22:48 -08:00
|
|
|
|
2017-06-01 03:25:57 -07:00
|
|
|
private:
|
2020-01-23 06:12:26 -08:00
|
|
|
phy_cell_cfg_list_t cell_list;
|
2017-06-01 03:25:57 -07:00
|
|
|
|
2020-02-18 09:09:28 -08:00
|
|
|
bool have_mtch_stop = false;
|
|
|
|
pthread_mutex_t mtch_mutex = {};
|
|
|
|
pthread_cond_t mtch_cvar = {};
|
|
|
|
phy_interface_stack_lte::phy_cfg_mbsfn_t mbsfn = {};
|
|
|
|
bool sib13_configured = false;
|
|
|
|
bool mcch_configured = false;
|
|
|
|
uint8_t mch_table[40] = {};
|
|
|
|
uint8_t mcch_table[10] = {};
|
|
|
|
uint32_t mch_period_stop = 0;
|
2019-12-16 07:04:22 -08:00
|
|
|
bool is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti);
|
|
|
|
bool is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti);
|
2017-06-01 03:25:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsenb
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSENB_PHCH_COMMON_H
|