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.

132 lines
4.2 KiB
C

/**
* Copyright 2013-2021 Software Radio Systems Limited
5 years ago
*
* This file is part of srsRAN.
5 years ago
*
* srsRAN is free software: you can redistribute it and/or modify
* 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.
*
* srsRAN is distributed in the hope that it will be useful,
* 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.
5 years ago
*
* 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/.
5 years ago
*
*/
#ifndef SRSENB_MAC_NR_H
#define SRSENB_MAC_NR_H
5 years ago
#include "srsran/common/block_queue.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/mac/mac_sch_pdu_nr.h"
5 years ago
#include "srsenb/hdr/stack/enb_stack_base.h"
#include "srsran/common/task_scheduler.h"
#include "srsran/interfaces/enb_metrics_interface.h"
#include "srsran/interfaces/gnb_interfaces.h"
5 years ago
namespace srsenb {
struct mac_nr_args_t {
srsenb::pcap_args_t pcap;
// params for the dummy user
srsenb::sched_interface::sched_args_t sched;
uint16_t rnti;
uint32_t drb_lcid;
5 years ago
// Add args
std::string log_level;
uint32_t log_hex_limit;
uint32_t tb_size = 64;
};
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_rlc_nr
5 years ago
{
public:
mac_nr(srsran::task_sched_handle task_sched_);
5 years ago
~mac_nr();
int init(const mac_nr_args_t& args_,
phy_interface_stack_nr* phy,
stack_interface_mac* stack_,
5 years ago
rlc_interface_mac_nr* rlc_,
rrc_interface_mac_nr* rrc_);
void stop();
void get_metrics(srsenb::mac_metrics_t& metrics);
5 years ago
// MAC interface for RRC
int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) override;
5 years ago
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; }
5 years ago
// Interface for PHY
int sf_indication(const uint32_t tti);
int rx_data_indication(stack_interface_phy_nr::rx_data_ind_t& grant);
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;
5 years ago
private:
void get_dl_config(const uint32_t tti,
phy_interface_stack_nr::dl_config_request_t& config_request,
phy_interface_stack_nr::tx_request_t& tx_request);
// PDU processing
int handle_pdu(srsran::unique_byte_buffer_t pdu);
// Interaction with other components
phy_interface_stack_nr* phy_h = nullptr;
stack_interface_mac* stack_h = nullptr;
rlc_interface_mac_nr* rlc_h = nullptr;
rrc_interface_mac_nr* rrc_h = nullptr;
5 years ago
// args
srsran::task_sched_handle task_sched;
std::unique_ptr<srsran::mac_pcap> pcap = nullptr;
mac_nr_args_t args = {};
srslog::basic_logger& logger;
5 years ago
bool started = false;
srsenb::sched_interface::cell_cfg_t cfg = {};
// BCH buffers
struct sib_info_t {
uint32_t index;
uint32_t periodicity;
srsran::unique_byte_buffer_t payload;
5 years ago
};
std::vector<sib_info_t> bcch_dlsch_payload;
srsran::unique_byte_buffer_t bcch_bch_payload = nullptr;
5 years ago
// UE-specific buffer
srsran::mac_sch_pdu_nr ue_tx_pdu;
std::vector<srsran::unique_byte_buffer_t> ue_tx_buffer;
srsran::block_queue<srsran::unique_byte_buffer_t>
ue_rx_pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc)
5 years ago
srsran::unique_byte_buffer_t ue_rlc_buffer;
srsran::mac_sch_pdu_nr ue_rx_pdu;
5 years ago
};
} // namespace srsenb
#endif // SRSENB_MAC_NR_H