srsLTE/srsenb/hdr/phy/phy_common.h

141 lines
4.8 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 "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 <semaphore.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:
2019-04-23 01:53:11 -07:00
phy_common(uint32_t nof_workers);
~phy_common();
void set_nof_workers(uint32_t nof_workers);
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();
void
worker_end(uint32_t tx_mutex_cnt, 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
phy_cell_cfg_list_t cell_list;
phy_args_t params = {};
uint32_t get_nof_carriers() { return (uint32_t)cell_list.size(); };
uint32_t get_nof_prb() { return (uint32_t)cell_list[0].cell.nof_prb; };
uint32_t get_nof_ports() { return (uint32_t)cell_list[0].cell.nof_ports; };
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;
// Common objects for schedulign 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] = {};
// Map of pending ACKs for each user
2017-06-01 03:25:57 -07:00
typedef struct {
bool is_pending[TTIMOD_SZ][SRSLTE_MAX_TB];
uint16_t n_pdcch[TTIMOD_SZ];
2017-06-01 03:25:57 -07:00
} pending_ack_t;
class common_ue
{
public:
pending_ack_t pending_ack = {};
uint8_t ri = 0;
srslte_ra_tb_t last_tb[SRSLTE_MAX_HARQ_PROC] = {};
};
std::map<uint16_t, common_ue> common_ue_db;
2019-10-17 07:44:45 -07:00
void ue_db_add_rnti(uint16_t rnti);
void ue_db_rem_rnti(uint16_t rnti);
2019-04-23 01:53:11 -07:00
void ue_db_clear(uint32_t tti);
void ue_db_set_ack_pending(uint32_t tti, uint16_t rnti, uint32_t tb_idx, uint32_t n_pdcch);
2019-10-17 07:44:45 -07:00
bool ue_db_is_ack_pending(uint32_t tti, uint16_t rnti, uint32_t tb_idx, uint32_t* last_n_pdcch = nullptr);
void ue_db_set_ri(uint16_t rnti, uint8_t ri);
uint8_t ue_db_get_ri(uint16_t rnti);
2019-04-23 01:53:11 -07:00
void ue_db_set_last_ul_tb(uint16_t rnti, uint32_t pid, srslte_ra_tb_t tb);
srslte_ra_tb_t ue_db_get_last_ul_tb(uint16_t rnti, uint32_t pid);
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:
std::vector<sem_t> tx_sem;
bool is_first_tx = false;
2017-06-01 03:25:57 -07:00
2019-10-17 07:44:45 -07:00
uint32_t nof_workers = 0;
uint32_t max_workers = 0;
2018-06-13 01:15:52 -07:00
std::mutex user_mutex = {};
2019-04-23 01:53:11 -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 = {};
2019-10-17 07:44:45 -07:00
bool sib13_configured = false;
bool mcch_configured = false;
uint8_t mch_table[40] = {};
uint8_t mcch_table[10] = {};
2019-10-17 07:44:45 -07:00
uint32_t mch_period_stop = 0;
uint8_t mch_sf_idx_lut[10] = {};
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);
2018-06-13 01:49:28 -07:00
void add_rnti(uint16_t rnti);
2017-06-01 03:25:57 -07:00
};
} // namespace srsenb
2018-03-31 10:04:04 -07:00
#endif // SRSENB_PHCH_COMMON_H