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.
135 lines
4.7 KiB
C
135 lines
4.7 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* 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.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
5 years ago
|
#ifndef SRSENB_MAC_NR_H
|
||
|
#define SRSENB_MAC_NR_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/common/block_queue.h"
|
||
|
#include "srsran/common/mac_pcap.h"
|
||
5 years ago
|
|
||
3 years ago
|
#include "srsenb/hdr/common/rnti_pool.h"
|
||
5 years ago
|
#include "srsenb/hdr/stack/enb_stack_base.h"
|
||
3 years ago
|
#include "srsenb/hdr/stack/mac/nr/sched_nr.h"
|
||
3 years ago
|
#include "srsenb/hdr/stack/mac/nr/ue_nr.h"
|
||
3 years ago
|
#include "srsran/common/task_scheduler.h"
|
||
4 years ago
|
#include "srsran/interfaces/enb_metrics_interface.h"
|
||
3 years ago
|
#include "srsran/interfaces/enb_rlc_interfaces.h"
|
||
3 years ago
|
#include "srsran/interfaces/gnb_mac_interfaces.h"
|
||
5 years ago
|
|
||
|
namespace srsenb {
|
||
|
|
||
|
struct mac_nr_args_t {
|
||
3 years ago
|
srsran::phy_cfg_nr_t phy_base_cfg = {};
|
||
3 years ago
|
int fixed_dl_mcs = -1;
|
||
|
int fixed_ul_mcs = -1;
|
||
|
srsenb::pcap_args_t pcap;
|
||
5 years ago
|
};
|
||
|
|
||
4 years ago
|
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_rlc_nr
|
||
5 years ago
|
{
|
||
|
public:
|
||
3 years ago
|
mac_nr(srsran::task_sched_handle task_sched_, const srsenb::sched_nr_interface::sched_cfg_t& sched_cfg = {});
|
||
5 years ago
|
~mac_nr();
|
||
|
|
||
|
int init(const mac_nr_args_t& args_,
|
||
|
phy_interface_stack_nr* phy,
|
||
4 years ago
|
stack_interface_mac* stack_,
|
||
3 years ago
|
rlc_interface_mac* rlc_,
|
||
5 years ago
|
rrc_interface_mac_nr* rrc_);
|
||
|
void stop();
|
||
|
|
||
4 years ago
|
void get_metrics(srsenb::mac_metrics_t& metrics);
|
||
5 years ago
|
|
||
|
// MAC interface for RRC
|
||
3 years ago
|
int cell_cfg(const sched_interface::cell_cfg_t& cell,
|
||
|
srsran::const_span<sched_nr_interface::cell_cfg_t> nr_cells) override;
|
||
|
uint16_t reserve_rnti(uint32_t enb_cc_idx) override;
|
||
|
int read_pdu_bcch_bch(uint8_t* payload);
|
||
|
int ue_cfg(uint16_t rnti, const sched_nr_interface::ue_cfg_t& ue_cfg) override;
|
||
5 years ago
|
|
||
|
// MAC interface for RLC
|
||
|
// TODO:
|
||
3 years ago
|
int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) override { return 0; }
|
||
5 years ago
|
|
||
|
// Interface for PHY
|
||
4 years ago
|
void process_pdus();
|
||
3 years ago
|
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;
|
||
3 years ago
|
int pucch_info(const srsran_slot_cfg_t& slot_cfg, const pucch_info_t& pucch_info) override;
|
||
3 years ago
|
int pusch_info(const srsran_slot_cfg_t& slot_cfg, pusch_info_t& pusch_info) override;
|
||
3 years ago
|
void rach_detected(const rach_info_t& rach_info) override;
|
||
5 years ago
|
|
||
|
private:
|
||
3 years ago
|
uint16_t add_ue_(uint32_t enb_cc_idx);
|
||
|
uint16_t alloc_ue(uint32_t enb_cc_idx);
|
||
3 years ago
|
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);
|
||
|
|
||
3 years ago
|
// handle UCI data from either PUCCH or PUSCH
|
||
|
bool handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg, const srsran_uci_value_nr_t& value);
|
||
|
|
||
4 years ago
|
// PDU processing
|
||
4 years ago
|
int handle_pdu(srsran::unique_byte_buffer_t pdu);
|
||
4 years ago
|
|
||
3 years ago
|
// Encoding
|
||
|
srsran::byte_buffer_t* assemble_rar(srsran::const_span<sched_nr_interface::sched_rar_grant_t> grants);
|
||
3 years ago
|
srsran::unique_byte_buffer_t rar_pdu_buffer = nullptr;
|
||
3 years ago
|
|
||
4 years ago
|
// Interaction with other components
|
||
3 years ago
|
phy_interface_stack_nr* phy = nullptr;
|
||
|
stack_interface_mac* stack = nullptr;
|
||
|
rlc_interface_mac* rlc = nullptr;
|
||
|
rrc_interface_mac_nr* rrc = nullptr;
|
||
5 years ago
|
|
||
3 years ago
|
// args
|
||
3 years ago
|
srsran::task_sched_handle task_sched;
|
||
3 years ago
|
srsran::task_multiqueue::queue_handle stack_task_queue;
|
||
3 years ago
|
|
||
4 years ago
|
std::unique_ptr<srsran::mac_pcap> pcap = nullptr;
|
||
4 years ago
|
mac_nr_args_t args = {};
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
5 years ago
|
|
||
3 years ago
|
std::atomic<bool> started = {false};
|
||
5 years ago
|
|
||
3 years ago
|
const static uint32_t NUMEROLOGY_IDX = 0; /// only 15kHz supported at this stage
|
||
3 years ago
|
srsran::slot_point pdsch_slot, pusch_slot;
|
||
|
srsenb::sched_nr sched;
|
||
3 years ago
|
srsran::const_span<sched_nr_interface::cell_cfg_t> cell_config;
|
||
5 years ago
|
|
||
3 years ago
|
// Map of active UEs
|
||
3 years ago
|
pthread_rwlock_t rwlock = {};
|
||
|
static const uint16_t FIRST_RNTI = 0x4601;
|
||
3 years ago
|
srsran::static_circular_map<uint16_t, std::unique_ptr<ue_nr>, SRSENB_MAX_UES> ue_db;
|
||
|
|
||
3 years ago
|
std::atomic<uint16_t> ue_counter{0};
|
||
3 years ago
|
|
||
5 years ago
|
// BCH buffers
|
||
|
struct sib_info_t {
|
||
|
uint32_t index;
|
||
|
uint32_t periodicity;
|
||
4 years ago
|
srsran::unique_byte_buffer_t payload;
|
||
5 years ago
|
};
|
||
|
std::vector<sib_info_t> bcch_dlsch_payload;
|
||
4 years ago
|
srsran::unique_byte_buffer_t bcch_bch_payload = nullptr;
|
||
5 years ago
|
|
||
3 years ago
|
// Number of rach preambles detected for a CC
|
||
3 years ago
|
std::vector<uint32_t> detected_rachs;
|
||
5 years ago
|
};
|
||
|
|
||
|
} // namespace srsenb
|
||
|
|
||
4 years ago
|
#endif // SRSENB_MAC_NR_H
|