diff --git a/srsue/hdr/mac/dl_harq.h b/srsue/hdr/mac/dl_harq.h index 3b9c25e28..25677dd84 100644 --- a/srsue/hdr/mac/dl_harq.h +++ b/srsue/hdr/mac/dl_harq.h @@ -45,15 +45,15 @@ namespace srsue { - + +template class dl_harq_entity { public: - const static uint32_t NOF_HARQ_PROC = 8; - const static uint32_t HARQ_BCCH_PID = NOF_HARQ_PROC; + const static uint32_t HARQ_BCCH_PID = N; - dl_harq_entity() + dl_harq_entity() : proc(N+1) { pcap = NULL; } @@ -65,7 +65,7 @@ public: mac_cfg = mac_cfg_; si_window_start = 0; log_h = log_h_; - for (uint32_t i=0;iMAC interface for DL processes **************************/ - void new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t *action) + void new_grant_dl(Tgrant grant, Taction *action) { if (grant.rnti_type != SRSLTE_RNTI_SPS) { uint32_t harq_pid; @@ -82,7 +82,7 @@ public: if (grant.rnti_type == SRSLTE_RNTI_SI) { harq_pid = HARQ_BCCH_PID; } else { - harq_pid = grant.pid%NOF_HARQ_PROC; + harq_pid = grant.pid%N; } if (grant.rnti_type == SRSLTE_RNTI_TEMP && last_temporal_crnti != grant.rnti) { grant.ndi = true; @@ -96,7 +96,7 @@ public: proc[harq_pid].new_grant_dl(grant, action); } else { /* This is for SPS scheduling */ - uint32_t harq_pid = get_harq_sps_pid(grant.tti)%NOF_HARQ_PROC; + uint32_t harq_pid = get_harq_sps_pid(grant.tti)%N; if (grant.ndi) { grant.ndi = false; proc[harq_pid].new_grant_dl(grant, action); @@ -121,16 +121,16 @@ public: void tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid) { if (rnti_type == SRSLTE_RNTI_SI) { - proc[NOF_HARQ_PROC].tb_decoded(ack); + proc[N].tb_decoded(ack); } else { - proc[harq_pid%NOF_HARQ_PROC].tb_decoded(ack); + proc[harq_pid%N].tb_decoded(ack); } } void reset() { - for (uint32_t i=0;idefault_ack = ack; action->generate_ack = true; action->decode_enabled = false; @@ -224,7 +224,7 @@ private: action->rv = cur_grant.rv; action->rnti = cur_grant.rnti; action->softbuffer = &softbuffer; - memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(srslte_phy_grant_t)); + memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(Tphygrant)); n_retx++; } else { @@ -293,7 +293,7 @@ private: int get_current_tbs() { return cur_grant.n_bytes*8; } private: - bool calc_is_new_transmission(mac_interface_phy::mac_grant_t grant) + bool calc_is_new_transmission(Tgrant grant) { bool is_new_tb = true; if ((srslte_tti_interval(grant.tti, cur_grant.tti) <= 8 && (grant.n_bytes == cur_grant.n_bytes)) || @@ -328,7 +328,7 @@ private: uint32_t n_retx; - mac_interface_phy::mac_grant_t cur_grant; + Tgrant cur_grant; srslte_softbuffer_rx_t softbuffer; }; @@ -344,7 +344,8 @@ private: dl_sps dl_sps_assig; - dl_harq_process proc[NOF_HARQ_PROC+1]; + + std::vector proc; srslte::timers *timers_db; mac_interface_rrc::mac_cfg_t *mac_cfg; demux *demux_unit; diff --git a/srsue/hdr/mac/mac.h b/srsue/hdr/mac/mac.h index 82a7b1e76..660f7fbba 100644 --- a/srsue/hdr/mac/mac.h +++ b/srsue/hdr/mac/mac.h @@ -106,6 +106,7 @@ private: static const int MAC_MAIN_THREAD_PRIO = 5; static const int MAC_PDU_THREAD_PRIO = 6; + static const int MAC_NOF_HARQ_PROC = 8; // Interaction with PHY srslte::tti_sync_cv ttisync; @@ -130,9 +131,9 @@ private: mux mux_unit; demux demux_unit; - /* DL/UL HARQ */ - dl_harq_entity dl_harq; - ul_harq_entity ul_harq; + /* DL/UL HARQ */ + dl_harq_entity dl_harq; + ul_harq_entity ul_harq; /* MAC Uplink-related Procedures */ ra_proc ra_procedure; diff --git a/srsue/hdr/mac/ul_harq.h b/srsue/hdr/mac/ul_harq.h index 38046b099..21c4a9602 100644 --- a/srsue/hdr/mac/ul_harq.h +++ b/srsue/hdr/mac/ul_harq.h @@ -43,17 +43,18 @@ /* Uplink HARQ entity as defined in 5.4.2 of 36.321 */ namespace srsue { - + +template class ul_harq_entity { public: - const static uint32_t NOF_HARQ_PROC = 8; static uint32_t pidof(uint32_t tti) { - return (uint32_t) tti%NOF_HARQ_PROC; + return (uint32_t) tti%N; } - ul_harq_entity() { + ul_harq_entity() : proc(N) + { pcap = NULL; timers_db = NULL; mux_unit = NULL; @@ -61,7 +62,7 @@ public: mac_cfg = NULL; rntis = NULL; average_retx = 0; - nof_pkts = 0; + nof_pkts = 0; } bool init(srslte::log *log_h_, @@ -75,7 +76,7 @@ public: mac_cfg = mac_cfg_; rntis = rntis_; timers_db = timers_db_; - for (uint32_t i=0;iMAC interface for UL processes **************************/ - void new_grant_ul(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_ul_t *action) + void new_grant_ul(Tgrant grant, Taction *action) { if (grant.rnti_type == SRSLTE_RNTI_USER || grant.rnti_type == SRSLTE_RNTI_TEMP || @@ -125,13 +126,13 @@ public: } } - void new_grant_ul_ack(mac_interface_phy::mac_grant_t grant, bool ack, mac_interface_phy::tb_action_ul_t *action) + void new_grant_ul_ack(Tgrant grant, bool ack, Taction *action) { set_ack(grant.tti, ack); new_grant_ul(grant, action); } - void harq_recv(uint32_t tti, bool ack, mac_interface_phy::tb_action_ul_t *action) + void harq_recv(uint32_t tti, bool ack, Taction *action) { set_ack(tti, ack); run_tti(tti, NULL, action); @@ -162,7 +163,7 @@ private: is_initiated = false; is_grant_configured = false; tti_last_tx = 0; - bzero(&cur_grant, sizeof(mac_interface_phy::mac_grant_t)); + bzero(&cur_grant, sizeof(Tgrant)); } bool init(uint32_t pid_, ul_harq_entity *parent) @@ -191,12 +192,12 @@ private: current_irv = 0; tti_last_tx = 0; is_grant_configured = false; - bzero(&cur_grant, sizeof(mac_interface_phy::mac_grant_t)); + bzero(&cur_grant, sizeof(Tgrant)); } void reset_ndi() { ndi = false; } - void run_tti(uint32_t tti_tx, mac_interface_phy::mac_grant_t *grant, mac_interface_phy::tb_action_ul_t* action) + void run_tti(uint32_t tti_tx, Tgrant *grant, Taction* action) { uint32_t max_retx; if (is_msg3) { @@ -287,7 +288,7 @@ private: int get_current_tbs() { return cur_grant.n_bytes*8; } private: - mac_interface_phy::mac_grant_t cur_grant; + Tgrant cur_grant; uint32_t pid; uint32_t current_tx_nb; @@ -307,14 +308,14 @@ private: uint8_t *payload_buffer; uint8_t *pdu_ptr; - void generate_retx(uint32_t tti_tx, mac_interface_phy::tb_action_ul_t *action) + void generate_retx(uint32_t tti_tx, Taction *action) { generate_retx(tti_tx, NULL, action); } // Retransmission with or w/o grant (Section 5.4.2.2) - void generate_retx(uint32_t tti_tx, mac_interface_phy::mac_grant_t *grant, - mac_interface_phy::tb_action_ul_t *action) + void generate_retx(uint32_t tti_tx, Tgrant *grant, + Taction *action) { int irv_of_rv[4] = {0, 3, 1, 2}; if (grant) { @@ -322,7 +323,7 @@ private: if (grant->rv) { current_irv = irv_of_rv[grant->rv%4]; } - memcpy(&cur_grant, grant, sizeof(mac_interface_phy::mac_grant_t)); + memcpy(&cur_grant, grant, sizeof(Tgrant)); harq_feedback = false; Info("UL %d: Adaptive retx=%d, RV=%d, TBS=%d\n", pid, current_tx_nb, get_rv(), grant->n_bytes); @@ -345,13 +346,12 @@ private: } // New transmission (Section 5.4.2.2) - void generate_new_tx(uint32_t tti_tx, bool is_msg3_, mac_interface_phy::mac_grant_t *grant, - mac_interface_phy::tb_action_ul_t *action) + void generate_new_tx(uint32_t tti_tx, bool is_msg3_, Tgrant *grant, Taction *action) { if (grant) { // Compute average number of retransmissions per packet considering previous packet harq_entity->average_retx = SRSLTE_VEC_CMA((float) current_tx_nb, harq_entity->average_retx, harq_entity->nof_pkts++); - memcpy(&cur_grant, grant, sizeof(mac_interface_phy::mac_grant_t)); + memcpy(&cur_grant, grant, sizeof(Tgrant)); harq_feedback = false; is_grant_configured = true; current_tx_nb = 0; @@ -364,7 +364,7 @@ private: } // Transmission of pending frame (Section 5.4.2.2) - void generate_tx(uint32_t tti_tx, mac_interface_phy::tb_action_ul_t *action) + void generate_tx(uint32_t tti_tx, Taction *action) { action->current_tx_nb = current_tx_nb; current_tx_nb++; @@ -374,7 +374,7 @@ private: action->softbuffer = &softbuffer; action->tx_enabled = true; action->payload_ptr = pdu_ptr; - memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(srslte_phy_grant_t)); + memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(Tphygrant)); current_irv = (current_irv+1)%4; tti_last_tx = tti_tx; @@ -383,7 +383,7 @@ private: // Implements Section 5.4.2.1 // Called with UL grant - void run_tti(uint32_t tti, mac_interface_phy::mac_grant_t *grant, mac_interface_phy::tb_action_ul_t* action) + void run_tti(uint32_t tti, Tgrant *grant, Taction* action) { uint32_t tti_tx = (tti+4)%10240; proc[pidof(tti_tx)].run_tti(tti_tx, grant, action); @@ -405,7 +405,7 @@ private: srslte::timers *timers_db; mux *mux_unit; - ul_harq_process proc[NOF_HARQ_PROC]; + std::vector proc; srslte::log *log_h; srslte::mac_pcap *pcap;