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.

109 lines
3.1 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 SRSUE_UL_HARQ_NR_H
#define SRSUE_UL_HARQ_NR_H
#include "mux_nr.h"
#include "proc_ra_nr.h"
#include "srsran/common/interfaces_common.h"
#include "srsran/common/timers.h"
#include "srsran/interfaces/ue_nr_interfaces.h"
using namespace srsran;
namespace srsue {
class ul_harq_entity_nr
{
public:
ul_harq_entity_nr(const uint8_t cc_idx_, mac_interface_harq_nr* mac_, proc_ra_nr* ra_proc__, mux_nr* mux_);
int init();
void reset();
void reset_ndi();
void set_config(srsran::ul_harq_cfg_t& harq_cfg);
/***************** PHY->MAC interface for UL processes **************************/
void new_grant_ul(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant, mac_interface_phy_nr::tb_action_ul_t* action);
int get_current_tbs(uint32_t pid);
float get_average_retx();
private:
class ul_harq_process_nr
{
public:
ul_harq_process_nr();
~ul_harq_process_nr();
bool init(uint32_t pid_, ul_harq_entity_nr* entity_);
void reset();
void reset_ndi();
uint8_t get_ndi();
bool has_grant();
uint32_t get_nof_retx();
int get_current_tbs();
/**
* Implements Section 5.4.2.1
*
* @param grant The unmodified grant as received from PHY
* @param ndi_toggled The NDI toggled state determined by the entity
* @param action The resulting UL action structure to be filled.
*/
void new_grant_ul(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant,
const bool& ndi_toggled,
mac_interface_phy_nr::tb_action_ul_t* action);
private:
mac_interface_phy_nr::mac_nr_grant_ul_t current_grant = {};
bool grant_configured = false;
uint32_t pid = 0;
uint32_t nof_retx = 0;
bool is_initiated = false;
srslog::basic_logger& logger;
ul_harq_entity_nr* harq_entity = nullptr;
srsran_softbuffer_tx_t softbuffer;
std::unique_ptr<byte_buffer_t> harq_buffer = nullptr;
void generate_tx(mac_interface_phy_nr::tb_action_ul_t* action);
void generate_new_tx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant,
mac_interface_phy_nr::tb_action_ul_t* action);
void generate_retx(const mac_interface_phy_nr::mac_nr_grant_ul_t& grant,
mac_interface_phy_nr::tb_action_ul_t* action);
};
std::array<ul_harq_process_nr, SRSRAN_MAX_HARQ_PROC_UL_NR> harq_procs;
mac_interface_harq_nr* mac = nullptr;
mux_nr* mux = nullptr;
srslog::basic_logger& logger;
srsran::ul_harq_cfg_t harq_cfg = {};
float average_retx = 0.0;
uint64_t nof_pkts = 0;
};
typedef std::unique_ptr<ul_harq_entity_nr> ul_harq_entity_nr_ptr;
typedef std::array<ul_harq_entity_nr_ptr, SRSRAN_MAX_CARRIERS> ul_harq_entity_nr_vector;
} // namespace srsue
#endif // SRSUE_UL_HARQ_NR_H