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.

134 lines
3.6 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_DL_HARQ_H
#define SRSUE_DL_HARQ_H
#include "demux.h"
#include "dl_sps.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/common/timers.h"
#include "srsue/hdr/stack/mac_common/mac_common.h"
/* Downlink HARQ entity as defined in 5.3.2 of 36.321 */
namespace srsue {
class dl_harq_entity
{
public:
dl_harq_entity(uint8_t cc_idx_);
bool init(ue_rnti* rntis, demux* demux_unit);
void reset();
void start_pcap(srsran::mac_pcap* pcap_);
/***************** PHY->MAC interface for DL processes **************************/
void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action);
void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]);
void set_si_window_start(int si_window_start);
float get_average_retx();
void set_average_retx(uint32_t n_retx);
private:
class dl_harq_process
{
public:
dl_harq_process();
bool init(int pid, dl_harq_entity* parent);
void reset(void);
void reset_ndi();
void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action);
void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]);
bool is_sps();
private:
const static int RESET_DUPLICATE_TIMEOUT = 6;
class dl_tb_process
{
public:
dl_tb_process(void);
~dl_tb_process();
bool init(int pid, dl_harq_entity* parent, uint32_t tb_idx);
void reset();
void reset_ndi();
void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action);
void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool* ack_ptr);
private:
// Determine if it's a new transmission 5.3.2.2
bool calc_is_new_transmission(mac_interface_phy_lte::mac_grant_dl_t grant);
// Internal function to reset process, caller must hold the mutex
void reset_nolock();
std::mutex mutex;
Upgrade loggers in srsue (#2163) * Replaced UE logger in the ue class. * Replaced loggers in the main phy class and prach. * Replaced loggers in phy common and ta_control. * Replace loggers in cc and sf workers. * Replaced loggers in intra_measure, scell_recv, search, sfn_sync, sync. * Remove last uses of the old loggers in the main phy class. * Remove stray newline in logs. * Replaced loggers in ue gw. * - Started to replace loggers in the ue stack. - Replaced loggers in usim and pcsc. - Adapted nas and usim tests. * Replace loggers in nas. * Added missing log init calls in two previously modified tests. * Replaced logger in nas idle procs. * Replaced loggers in nas emm state. * Replaced loggers in tft packet filter and adapted tft test. * Replaced loggers in main RRC class. * Replaced loggers in RRC cell. * Replaced loggers in RRC meas. * Replaced loggers in rrc procedures. * Started logger replacement in MAC layer, more precisely in demux and dl_harq classes. Been unable to inject loggers in construction for dl_tb_process due to very weird static assertions in the std::vector code being the type not constructible which is not true, so instead use the main MAC logger directly. * Replaced loggers in mac mux class. * Replaced loggers in mac pro_bsr. * Replaced loggers in mac proc phr. * Replaced loggers in mac proc SR and RA. * Replace loggers in mac UL HARQ. * Replaced loggers in main ue stack class. * Fixed nas test crashing due to a null string. * Ported mac_test to use the new loggers. * Removed TTI reporting for the PHY log as the old logger did. * Replaced loggers in UE phy tests. * Configure loggers in nas_test. * Replaced loggers in rrc_meas_test. * Replaced loggers in rrc_reconfig_test. * Added missing newline in tft_test. * Fix compilation errors in TTCN3 tests. * Fix linker error detected in CI and warning. * Replaced loggers in TTCN3 tests. * Fix a text replace error in some log messages. * Remove trailing newlines from log entries. * Remove old logger from rrc. * Flush backend before printing the test status. * - Fix compilation error from previous rebase. - Remove trailing newlines from some missing log entries.
4 years ago
bool is_initiated;
dl_harq_entity* harq_entity;
srslog::basic_logger& logger;
bool is_first_tb;
bool is_new_transmission;
bool is_bcch;
uint32_t pid; /* HARQ Proccess ID */
uint32_t tid; /* Transport block ID */
uint8_t* payload_buffer_ptr;
bool ack;
uint32_t n_retx;
mac_interface_phy_lte::mac_grant_dl_t cur_grant;
srsran_softbuffer_rx_t softbuffer;
};
/* Transport blocks */
std::vector<dl_tb_process> subproc;
};
// Private members of dl_harq_entity
uint32_t get_harq_sps_pid(uint32_t tti);
dl_sps dl_sps_assig;
std::vector<dl_harq_process> proc;
dl_harq_process bcch_proc;
demux* demux_unit = nullptr;
srslog::basic_logger& logger;
srsran::mac_pcap* pcap = nullptr;
ue_rnti* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
int si_window_start = 0;
std::mutex retx_cnt_mutex = {};
float average_retx = 0.0;
uint64_t nof_pkts = 0;
uint8_t cc_idx = 0;
};
Upgrade loggers in srsue (#2163) * Replaced UE logger in the ue class. * Replaced loggers in the main phy class and prach. * Replaced loggers in phy common and ta_control. * Replace loggers in cc and sf workers. * Replaced loggers in intra_measure, scell_recv, search, sfn_sync, sync. * Remove last uses of the old loggers in the main phy class. * Remove stray newline in logs. * Replaced loggers in ue gw. * - Started to replace loggers in the ue stack. - Replaced loggers in usim and pcsc. - Adapted nas and usim tests. * Replace loggers in nas. * Added missing log init calls in two previously modified tests. * Replaced logger in nas idle procs. * Replaced loggers in nas emm state. * Replaced loggers in tft packet filter and adapted tft test. * Replaced loggers in main RRC class. * Replaced loggers in RRC cell. * Replaced loggers in RRC meas. * Replaced loggers in rrc procedures. * Started logger replacement in MAC layer, more precisely in demux and dl_harq classes. Been unable to inject loggers in construction for dl_tb_process due to very weird static assertions in the std::vector code being the type not constructible which is not true, so instead use the main MAC logger directly. * Replaced loggers in mac mux class. * Replaced loggers in mac pro_bsr. * Replaced loggers in mac proc phr. * Replaced loggers in mac proc SR and RA. * Replace loggers in mac UL HARQ. * Replaced loggers in main ue stack class. * Fixed nas test crashing due to a null string. * Ported mac_test to use the new loggers. * Removed TTI reporting for the PHY log as the old logger did. * Replaced loggers in UE phy tests. * Configure loggers in nas_test. * Replaced loggers in rrc_meas_test. * Replaced loggers in rrc_reconfig_test. * Added missing newline in tft_test. * Fix compilation errors in TTCN3 tests. * Fix linker error detected in CI and warning. * Replaced loggers in TTCN3 tests. * Fix a text replace error in some log messages. * Remove trailing newlines from log entries. * Remove old logger from rrc. * Flush backend before printing the test status. * - Fix compilation error from previous rebase. - Remove trailing newlines from some missing log entries.
4 years ago
typedef std::unique_ptr<dl_harq_entity> dl_harq_entity_ptr;
typedef std::array<dl_harq_entity_ptr, SRSRAN_MAX_CARRIERS> dl_harq_entity_vector;
} // namespace srsue
#endif // SRSUE_DL_HARQ_H