mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.9 KiB
C++
125 lines
3.9 KiB
C++
/**
|
|
*
|
|
* \section COPYRIGHT
|
|
*
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
|
*
|
|
* By using this file, you agree to the terms and conditions set
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
* the distribution.
|
|
*
|
|
*/
|
|
|
|
#ifndef SRSENB_MAC_NR_H
|
|
#define SRSENB_MAC_NR_H
|
|
|
|
#include "srsran/common/block_queue.h"
|
|
#include "srsran/common/mac_pcap.h"
|
|
|
|
#include "srsenb/hdr/common/rnti_pool.h"
|
|
#include "srsenb/hdr/stack/enb_stack_base.h"
|
|
#include "srsenb/hdr/stack/mac/nr/sched_nr.h"
|
|
#include "srsenb/hdr/stack/mac/nr/ue_nr.h"
|
|
#include "srsran/common/task_scheduler.h"
|
|
#include "srsran/interfaces/enb_metrics_interface.h"
|
|
#include "srsran/interfaces/enb_rlc_interfaces.h"
|
|
#include "srsran/interfaces/gnb_interfaces.h"
|
|
|
|
namespace srsenb {
|
|
|
|
struct mac_nr_args_t {
|
|
srsran::phy_cfg_nr_t phy_base_cfg = {};
|
|
int fixed_dl_mcs = -1;
|
|
int fixed_ul_mcs = -1;
|
|
srsenb::pcap_args_t pcap;
|
|
};
|
|
|
|
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_rlc_nr
|
|
{
|
|
public:
|
|
mac_nr(srsran::task_sched_handle task_sched_);
|
|
~mac_nr();
|
|
|
|
int init(const mac_nr_args_t& args_,
|
|
phy_interface_stack_nr* phy,
|
|
stack_interface_mac* stack_,
|
|
rlc_interface_mac* rlc_,
|
|
rrc_interface_mac_nr* rrc_);
|
|
void stop();
|
|
|
|
void get_metrics(srsenb::mac_metrics_t& metrics);
|
|
|
|
// MAC interface for RRC
|
|
int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) override;
|
|
uint16_t reserve_rnti() override;
|
|
int read_pdu_bcch_bch(uint8_t* payload);
|
|
|
|
// MAC interface for RLC
|
|
// TODO:
|
|
int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) override { return 0; }
|
|
|
|
// Interface for PHY
|
|
void process_pdus();
|
|
int slot_indication(const srsran_slot_cfg_t& slot_cfg) override;
|
|
int get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched) override;
|
|
int get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched) override;
|
|
int pucch_info(const srsran_slot_cfg_t& slot_cfg, const pucch_info_t& pucch_info) override;
|
|
int pusch_info(const srsran_slot_cfg_t& slot_cfg, const pusch_info_t& pusch_info) override;
|
|
void rach_detected(const rach_info_t& rach_info) override;
|
|
|
|
private:
|
|
uint16_t add_ue(uint32_t enb_cc_idx);
|
|
int remove_ue(uint16_t rnti);
|
|
|
|
// internal misc helpers
|
|
bool is_rnti_valid_unsafe(uint16_t rnti);
|
|
bool is_rnti_active_unsafe(uint16_t rnti);
|
|
|
|
// PDU processing
|
|
int handle_pdu(srsran::unique_byte_buffer_t pdu);
|
|
|
|
// Interaction with other components
|
|
phy_interface_stack_nr* phy = nullptr;
|
|
stack_interface_mac* stack = nullptr;
|
|
rlc_interface_mac* rlc = nullptr;
|
|
rrc_interface_mac_nr* rrc = nullptr;
|
|
|
|
// args
|
|
srsran::task_sched_handle task_sched;
|
|
srsran::task_multiqueue::queue_handle stack_task_queue;
|
|
|
|
std::unique_ptr<srsran::mac_pcap> pcap = nullptr;
|
|
mac_nr_args_t args = {};
|
|
srslog::basic_logger& logger;
|
|
|
|
std::atomic<bool> started = {false};
|
|
|
|
const static uint32_t NUMEROLOGY_IDX = 0; /// only 15kHz supported at this stage
|
|
srsran::slot_point pdsch_slot, pusch_slot;
|
|
srsenb::sched_nr sched;
|
|
srsenb::sched_interface::cell_cfg_t cfg = {};
|
|
|
|
// Map of active UEs
|
|
pthread_rwlock_t rwlock = {};
|
|
static const uint16_t FIRST_RNTI = 0x4601;
|
|
srsran::static_circular_map<uint16_t, std::unique_ptr<ue_nr>, SRSENB_MAX_UES> ue_db;
|
|
|
|
std::atomic<uint16_t> ue_counter;
|
|
|
|
// BCH buffers
|
|
struct sib_info_t {
|
|
uint32_t index;
|
|
uint32_t periodicity;
|
|
srsran::unique_byte_buffer_t payload;
|
|
};
|
|
std::vector<sib_info_t> bcch_dlsch_payload;
|
|
srsran::unique_byte_buffer_t bcch_bch_payload = nullptr;
|
|
|
|
// Number of rach preambles detected for a cc.
|
|
std::vector<uint32_t> detected_rachs;
|
|
};
|
|
|
|
} // namespace srsenb
|
|
|
|
#endif // SRSENB_MAC_NR_H
|