srsLTE/srsue/hdr/stack/mac/dl_harq.h

141 lines
4.2 KiB
C
Raw Normal View History

2019-04-26 12:27:38 -07:00
/*
2020-03-13 04:12:52 -07:00
* Copyright 2013-2020 Software Radio Systems Limited
2017-05-30 06:38:04 -07:00
*
2019-04-26 12:27:38 -07:00
* This file is part of srsLTE.
2017-05-30 06:38:04 -07:00
*
2019-04-26 12:27:38 -07:00
* srsLTE is free software: you can redistribute it and/or modify
2017-05-30 06:38:04 -07:00
* 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.
*
2019-04-26 12:27:38 -07:00
* srsLTE is distributed in the hope that it will be useful,
2017-05-30 06:38:04 -07:00
* 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.
*
* 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/.
*
*/
2018-03-31 10:04:04 -07:00
#ifndef SRSUE_DL_HARQ_H
#define SRSUE_DL_HARQ_H
2017-05-30 06:38:04 -07:00
#include "demux.h"
#include "dl_sps.h"
#include "srslte/common/log.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/timers.h"
2017-05-30 06:38:04 -07:00
#include "srslte/interfaces/ue_interfaces.h"
2017-05-30 06:38:04 -07:00
/* Downlink HARQ entity as defined in 5.3.2 of 36.321 */
namespace srsue {
2017-06-23 04:19:18 -07:00
2017-05-30 06:38:04 -07:00
class dl_harq_entity
{
public:
2020-03-04 01:50:46 -08:00
dl_harq_entity(uint8_t cc_idx_);
2017-05-30 06:38:04 -07:00
bool init(srslte::log* log_h,
mac_interface_rrc::ue_rnti_t* rntis,
demux* demux_unit);
2019-04-23 01:53:11 -07:00
void reset();
void start_pcap(srslte::mac_pcap* pcap_);
2017-05-30 06:38:04 -07:00
/***************** 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[SRSLTE_MAX_CODEWORDS]);
2019-04-23 01:53:11 -07:00
void set_si_window_start(int si_window_start);
2019-04-23 01:53:11 -07:00
float get_average_retx();
2017-05-30 06:38:04 -07:00
2017-09-05 06:26:36 -07:00
private:
2019-04-23 01:53:11 -07:00
class dl_harq_process
{
2017-05-30 06:38:04 -07:00
public:
2019-04-23 01:53:11 -07:00
dl_harq_process();
bool init(int pid, dl_harq_entity* parent);
void reset(void);
void reset_ndi();
2017-09-05 06:26:36 -07:00
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[SRSLTE_MAX_CODEWORDS]);
2018-03-06 15:28:52 -08:00
2019-04-23 01:53:11 -07:00
bool is_sps();
private:
const static int RESET_DUPLICATE_TIMEOUT = 6;
2018-03-06 15:28:52 -08:00
class dl_tb_process
{
2017-09-05 06:26:36 -07:00
public:
2019-04-23 01:53:11 -07:00
dl_tb_process(void);
~dl_tb_process();
bool init(int pid, dl_harq_entity* parent, uint32_t tb_idx);
void reset(bool lock = true);
void reset_ndi();
2019-04-23 01:53:11 -07:00
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);
2017-09-05 06:26:36 -07:00
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);
2018-03-05 05:33:51 -08:00
pthread_mutex_t mutex;
bool is_initiated;
dl_harq_entity* harq_entity;
srslte::log* log_h;
bool is_first_tb;
2017-09-05 06:26:36 -07:00
bool is_new_transmission;
2019-04-23 01:53:11 -07:00
bool is_bcch;
uint32_t pid; /* HARQ Proccess ID */
uint32_t tid; /* Transport block ID */
uint8_t* payload_buffer_ptr;
bool ack;
2017-09-05 06:26:36 -07:00
uint32_t n_retx;
mac_interface_phy_lte::mac_grant_dl_t cur_grant;
srslte_softbuffer_rx_t softbuffer;
2017-09-05 06:26:36 -07:00
};
/* Transport blocks */
std::vector<dl_tb_process> subproc;
2017-05-30 06:38:04 -07:00
};
2019-04-23 01:53:11 -07:00
// Private members of dl_harq_entity
2017-05-30 06:38:04 -07:00
2019-04-23 01:53:11 -07:00
uint32_t get_harq_sps_pid(uint32_t tti);
dl_sps dl_sps_assig;
2017-06-23 04:19:18 -07:00
std::vector<dl_harq_process> proc;
dl_harq_process bcch_proc;
2020-03-04 01:50:46 -08:00
demux* demux_unit = nullptr;
srslte::log* log_h = nullptr;
srslte::mac_pcap* pcap = nullptr;
mac_interface_rrc::ue_rnti_t* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
int si_window_start = 0;
float average_retx = 0.0;
uint64_t nof_pkts = 0;
uint8_t cc_idx = 0;
2017-05-30 06:38:04 -07:00
};
typedef std::unique_ptr<dl_harq_entity> dl_harq_entity_ptr;
typedef std::vector<dl_harq_entity_ptr> dl_harq_entity_vector;
2017-05-30 06:38:04 -07:00
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_DL_HARQ_H