srsLTE/srsenb/hdr/stack/mac/mac_nr.h

114 lines
3.1 KiB
C
Raw Normal View History

/**
2020-05-21 10:11:55 -07:00
*
* \section COPYRIGHT
2020-05-21 10:11:55 -07:00
*
2021-03-19 03:45:56 -07:00
* Copyright 2013-2021 Software Radio Systems Limited
2020-05-21 10:11:55 -07:00
*
* 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.
2020-05-21 10:11:55 -07:00
*
*/
2020-05-25 03:56:36 -07:00
#ifndef SRSENB_MAC_NR_H
#define SRSENB_MAC_NR_H
2020-05-21 10:11:55 -07:00
2021-03-19 03:45:56 -07:00
#include "srsran/common/block_queue.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/mac/mac_sch_pdu_nr.h"
2020-05-21 10:11:55 -07:00
#include "srsenb/hdr/stack/enb_stack_base.h"
2021-03-19 03:45:56 -07:00
#include "srsran/interfaces/enb_metrics_interface.h"
#include "srsran/interfaces/gnb_interfaces.h"
2020-05-21 10:11:55 -07:00
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;
2020-06-11 06:38:14 -07:00
uint32_t drb_lcid;
2020-05-21 10:11:55 -07:00
// Add args
std::string log_level;
uint32_t log_hex_limit;
uint32_t tb_size = 64;
};
2020-06-04 08:01:16 -07:00
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_rlc_nr
2020-05-21 10:11:55 -07:00
{
public:
2020-05-22 08:40:19 -07:00
mac_nr();
2020-05-21 10:11:55 -07:00
~mac_nr();
int init(const mac_nr_args_t& args_,
phy_interface_stack_nr* phy,
2020-06-11 06:38:14 -07:00
stack_interface_mac* stack_,
2020-05-21 10:11:55 -07:00
rlc_interface_mac_nr* rlc_,
rrc_interface_mac_nr* rrc_);
void stop();
void get_metrics(srsenb::mac_metrics_t& metrics);
2020-05-21 10:11:55 -07:00
// MAC interface for RRC
int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg);
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) { return 0; }
// Interface for PHY
int sf_indication(const uint32_t tti);
2020-06-11 06:38:14 -07:00
int rx_data_indication(stack_interface_phy_nr::rx_data_ind_t& grant);
void process_pdus();
2020-05-21 10:11:55 -07:00
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);
2020-06-11 06:38:14 -07:00
// PDU processing
2021-03-19 03:45:56 -07:00
int handle_pdu(srsran::unique_byte_buffer_t pdu);
2020-06-11 06:38:14 -07:00
// 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;
2020-05-21 10:11:55 -07:00
2021-03-19 03:45:56 -07:00
std::unique_ptr<srsran::mac_pcap> pcap = nullptr;
mac_nr_args_t args = {};
srslog::basic_logger& logger;
2020-05-21 10:11:55 -07:00
bool started = false;
srsenb::sched_interface::cell_cfg_t cfg = {};
// BCH buffers
struct sib_info_t {
uint32_t index;
uint32_t periodicity;
2021-03-19 03:45:56 -07:00
srsran::unique_byte_buffer_t payload;
2020-05-21 10:11:55 -07:00
};
std::vector<sib_info_t> bcch_dlsch_payload;
2021-03-19 03:45:56 -07:00
srsran::unique_byte_buffer_t bcch_bch_payload = nullptr;
2020-05-21 10:11:55 -07:00
// UE-specific buffer
2021-03-19 03:45:56 -07:00
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>
2020-06-11 06:38:14 -07:00
ue_rx_pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc)
2020-05-21 10:11:55 -07:00
2021-03-19 03:45:56 -07:00
srsran::unique_byte_buffer_t ue_rlc_buffer;
2020-06-11 06:38:14 -07:00
2021-03-19 03:45:56 -07:00
srsran::mac_sch_pdu_nr ue_rx_pdu;
2020-05-21 10:11:55 -07:00
};
} // namespace srsenb
2020-06-11 06:38:14 -07:00
#endif // SRSENB_MAC_NR_H