srsLTE/srsenb/hdr/phy/phy_common.h

175 lines
5.1 KiB
C
Raw Normal View History

2019-04-23 01:53:11 -07:00
/*
* Copyright 2013-2019 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
#include "phy_interfaces.h"
#include "srsenb/hdr/phy/phy_ue_db.h"
#include "srslte/common/gen_mch_tables.h"
#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"
#include "srslte/common/threads.h"
#include "srslte/interfaces/common_interfaces.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/phy/channel/channel.h"
2017-06-01 03:25:57 -07:00
#include "srslte/radio/radio.h"
#include <map>
#include <srslte/common/tti_sempahore.h>
#include <string.h>
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;
bool
init(const phy_cell_cfg_list_t& cell_list_, srslte::radio_interface_phy* radio_handler, stack_interface_phy_lte* mac);
void reset();
2017-06-01 03:25:57 -07:00
void stop();
/**
* 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
*/
void worker_end(void* tx_sem_id, cf_t* buffer[SRSLTE_MAX_PORTS], 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-23 06:12:26 -08:00
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].cell.nof_ports;
}
return ret;
};
float get_ul_freq_hz(uint32_t cc_idx)
2020-01-23 06:12:26 -08:00
{
float ret = 0.0f;
2020-01-23 06:12:26 -08:00
if (cc_idx < cell_list.size()) {
ret = cell_list[cc_idx].ul_freq_hz;
2020-01-23 06:12:26 -08:00
}
return ret;
};
float get_dl_freq_hz(uint32_t cc_idx)
2020-01-23 06:12:26 -08:00
{
float ret = 0.0f;
2020-01-23 06:12:26 -08:00
if (cc_idx < cell_list.size()) {
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
// Physical Uplink Config common
2019-10-17 07:44:45 -07:00
srslte_ul_cfg_t ul_cfg_com = {};
2019-04-23 01:53:11 -07:00
// Physical Downlink Config common
2019-10-17 07:44:45 -07:00
srslte_dl_cfg_t dl_cfg_com = {};
2017-06-01 03:25:57 -07:00
srslte::radio_interface_phy* radio = nullptr;
stack_interface_phy_lte* stack = nullptr;
srslte::channel_ptr dl_channel = nullptr;
2020-03-03 08:20:44 -08:00
// Common objects for scheduling grants
stack_interface_phy_lte::ul_sched_list_t ul_grants[TTIMOD_SZ] = {};
stack_interface_phy_lte::dl_sched_list_t dl_grants[TTIMOD_SZ] = {};
2020-02-10 03:59:23 -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
*/
phy_ue_db ue_db;
2019-04-23 01:53:11 -07:00
void configure_mbsfn(phy_interface_stack_lte::phy_cfg_mbsfn_t* cfg);
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);
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
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;
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