From 0385a106569d4616f7b9bab398b65c3c60a8a19c Mon Sep 17 00:00:00 2001 From: ismagom Date: Sun, 9 Aug 2015 00:23:02 +0200 Subject: [PATCH] UL/DL iperf working with 1 thread --- .../include/srsapps/common/mac_interface.h | 2 +- srsapps/common/src/qbuff.cc | 3 ++- .../radio/include/srsapps/radio/radio_uhd.h | 2 +- srsapps/ue/mac/include/srsapps/ue/mac/pdu.h | 27 +++++++++---------- srsapps/ue/mac/src/demux.cc | 9 ++++--- srsapps/ue/mac/src/mac.cc | 1 - srsapps/ue/mac/src/mux.cc | 7 ++--- srsapps/ue/mac/src/pdu.cc | 10 +++++-- srsapps/ue/mac/src/proc_ra.cc | 4 +-- srsapps/ue/mac/test/mac_test.cc | 2 +- srsapps/ue/phy/src/phch_common.cc | 7 ++--- srsapps/ue/phy/src/phch_worker.cc | 8 +++--- srsapps/ue/phy/src/phy.cc | 7 ++--- 13 files changed, 51 insertions(+), 38 deletions(-) diff --git a/srsapps/common/include/srsapps/common/mac_interface.h b/srsapps/common/include/srsapps/common/mac_interface.h index f3cd367ef..66e262df3 100644 --- a/srsapps/common/include/srsapps/common/mac_interface.h +++ b/srsapps/common/include/srsapps/common/mac_interface.h @@ -139,7 +139,7 @@ public: /* MAC calls RLC to get RLC segment of nof_bytes length. Segmentation happens in this function. RLC PDU is stored in * payload. */ - virtual uint32_t read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) = 0; + virtual int read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) = 0; /* MAC calls RLC to push an RLC PDU. This function is called from an independent MAC thread. PDU gets placed into the * PDCP buffer and higher layer thread gets notified diff --git a/srsapps/common/src/qbuff.cc b/srsapps/common/src/qbuff.cc index 092cc0a2d..c09f4dbb2 100644 --- a/srsapps/common/src/qbuff.cc +++ b/srsapps/common/src/qbuff.cc @@ -158,8 +158,9 @@ bool qbuff::send(void* buffer, uint32_t msg_size) void *ptr = request(); if (ptr) { memcpy(ptr, buffer, msg_size); - push(msg_size); + return push(msg_size); } else { + printf("No ptr\n"); return false; } } else { diff --git a/srsapps/radio/include/srsapps/radio/radio_uhd.h b/srsapps/radio/include/srsapps/radio/radio_uhd.h index 9de56eb36..c8be0aabb 100644 --- a/srsapps/radio/include/srsapps/radio/radio_uhd.h +++ b/srsapps/radio/include/srsapps/radio/radio_uhd.h @@ -81,7 +81,7 @@ namespace srslte { void *uhd; static const double lo_offset = 8e6; // LO offset (in Hz) - static const double burst_settle_time = 0.35e-3; // Start of burst settle time (off->on RF transition time) + static const double burst_settle_time = 0.4e-3; // Start of burst settle time (off->on RF transition time) const static uint32_t burst_settle_max_samples = 30720000; // 30.72 MHz is maximum frequency srslte_timestamp_t end_of_burst_time; diff --git a/srsapps/ue/mac/include/srsapps/ue/mac/pdu.h b/srsapps/ue/mac/include/srsapps/ue/mac/pdu.h index 0fc629a3a..248823b64 100644 --- a/srsapps/ue/mac/include/srsapps/ue/mac/pdu.h +++ b/srsapps/ue/mac/include/srsapps/ue/mac/pdu.h @@ -72,9 +72,8 @@ public: rem_len = pdu_len; } - void init_rx(uint8_t *payload, uint32_t pdu_len_bytes, bool is_ulsch = false) { + void init_rx(uint32_t pdu_len_bytes, bool is_ulsch = false) { init_(NULL, pdu_len_bytes, is_ulsch); - parse_packet(payload); } void init_tx(uint8_t *payload, uint32_t pdu_len_bytes, bool is_ulsch = false) { @@ -130,18 +129,6 @@ public: total_sdu_len += sdu_sz; } -protected: - std::vector subheaders; - uint32_t pdu_len; - uint32_t rem_len; - int cur_idx; - int nof_subheaders; - uint32_t max_subheaders; - bool pdu_is_ul; - uint8_t* buffer_tx; - uint32_t total_sdu_len; - uint32_t sdu_offset_start; - // Section 6.1.2 void parse_packet(uint8_t *ptr) { uint8_t *init_ptr = ptr; @@ -154,6 +141,18 @@ protected: subheaders[i].read_payload(&ptr); } } + +protected: + std::vector subheaders; + uint32_t pdu_len; + uint32_t rem_len; + int cur_idx; + int nof_subheaders; + uint32_t max_subheaders; + bool pdu_is_ul; + uint8_t* buffer_tx; + uint32_t total_sdu_len; + uint32_t sdu_offset_start; private: diff --git a/srsapps/ue/mac/src/demux.cc b/srsapps/ue/mac/src/demux.cc index 073fd61c3..cae35dbdf 100644 --- a/srsapps/ue/mac/src/demux.cc +++ b/srsapps/ue/mac/src/demux.cc @@ -144,7 +144,8 @@ void demux::push_pdu_bcch(uint8_t *buff, uint32_t nof_bytes) void demux::push_pdu_temp_crnti(uint8_t *buff, uint32_t nof_bytes) { // Unpack DLSCH MAC PDU - pending_mac_msg.init_rx(buff, nof_bytes); + pending_mac_msg.init_rx(nof_bytes); + pending_mac_msg.parse_packet(buff); // Look for Contention Resolution UE ID is_uecrid_successful = false; @@ -197,9 +198,11 @@ void demux::process_pdus() void demux::process_pdu(uint8_t *mac_pdu, uint32_t nof_bytes) { // Unpack DLSCH MAC PDU - mac_msg.init_rx(mac_pdu, nof_bytes); - //mac_msg.fprint(stdout); + mac_msg.init_rx(nof_bytes); + mac_msg.parse_packet(mac_pdu); + process_sch_pdu(&mac_msg); + //srslte_vec_fprint_byte(stdout, mac_pdu, nof_bytes); Debug("MAC PDU processed\n"); } diff --git a/srsapps/ue/mac/src/mac.cc b/srsapps/ue/mac/src/mac.cc index eb8141779..4a7c01dde 100644 --- a/srsapps/ue/mac/src/mac.cc +++ b/srsapps/ue/mac/src/mac.cc @@ -185,7 +185,6 @@ void mac::run_thread() { Info("Pre-generating UL signals and C-RNTI scrambling sequences\n"); ((phy*) phy_h)->enable_pregen_signals(true); ((phy*) phy_h)->set_crnti(crnti); - phy_h->configure_ul_params(); Info("Done\n"); signals_pregenerated = true; } diff --git a/srsapps/ue/mac/src/mux.cc b/srsapps/ue/mac/src/mux.cc index 457d255ca..08b53060f 100644 --- a/srsapps/ue/mac/src/mux.cc +++ b/srsapps/ue/mac/src/mux.cc @@ -254,12 +254,13 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) { sdu_len = max_sdu_sz; } - if (sdu_len > pdu_msg->rem_size() - 2) { - sdu_len = pdu_msg->rem_size() - 2; + if (sdu_len > pdu_msg->rem_size() - 3) { + sdu_len = pdu_msg->rem_size() - 3; } if (sdu_len > MIN_RLC_SDU_LEN) { if (pdu_msg->new_subh()) { // there is space for a new subheader pdu_msg->next(); + int sdu_len2 = sdu_len; sdu_len = pdu_msg->get()->set_sdu(lcid, sdu_len, rlc, is_first?*is_first:false); if (sdu_len >= 0) { // new SDU could be added if (is_first) { @@ -272,7 +273,7 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t Info("Allocated SDU lcid=%d nbytes=%d, buffer_state=%d\n", lcid, sdu_len, buffer_state); return true; } else { - Info("Could not add SDU rem_size=%d, sdu_len=%d\n", pdu_msg->rem_size(), buffer_state); + Info("Could not add SDU rem_size=%d, sdu_len=%d\n", pdu_msg->rem_size(), sdu_len2); pdu_msg->del_subh(); } } diff --git a/srsapps/ue/mac/src/pdu.cc b/srsapps/ue/mac/src/pdu.cc index fbc9e8931..f260546a5 100644 --- a/srsapps/ue/mac/src/pdu.cc +++ b/srsapps/ue/mac/src/pdu.cc @@ -87,14 +87,16 @@ void sch_subh::fprint(FILE* stream) void sch_pdu::parse_packet(uint8_t *ptr) { + pdu::parse_packet(ptr); - + // Correct size for last SDU if (nof_subheaders > 0) { uint32_t read_len = 0; for (int i=0;i= 0) { subheaders[nof_subheaders-1].set_payload_size(pdu_len-read_len-1); } else { @@ -467,7 +469,11 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, rlc_interface_ma payload = ((sch_pdu*)parent)->get_current_sdu_ptr(); // Copy data and get final number of bytes written to the MAC PDU - uint32_t sdu_sz = rlc->read_pdu(lcid, payload, requested_bytes); + int sdu_sz = rlc->read_pdu(lcid, payload, requested_bytes); + + if (sdu_sz < 0) { + return -1; + } // Save final number of written bytes nof_bytes = sdu_sz; diff --git a/srsapps/ue/mac/src/proc_ra.cc b/srsapps/ue/mac/src/proc_ra.cc index ecc6de980..817640a85 100644 --- a/srsapps/ue/mac/src/proc_ra.cc +++ b/srsapps/ue/mac/src/proc_ra.cc @@ -261,8 +261,8 @@ void ra_proc::tb_decoded_ok() { rDebug("RAR decoded successfully TBS=%d\n", rar_grant_nbytes); - rar_pdu_msg.init_rx(rar_pdu_buffer, rar_grant_nbytes); - + rar_pdu_msg.init_rx(rar_grant_nbytes); + rar_pdu_msg.parse_packet(rar_pdu_buffer); // Set Backoff parameter if (rar_pdu_msg.has_backoff()) { backoff_param_ms = backoff_table[rar_pdu_msg.get_backoff()%16]; diff --git a/srsapps/ue/mac/test/mac_test.cc b/srsapps/ue/mac/test/mac_test.cc index 3df7b3b8a..29d3754bc 100644 --- a/srsapps/ue/mac/test/mac_test.cc +++ b/srsapps/ue/mac/test/mac_test.cc @@ -377,7 +377,7 @@ public: return 0; } - uint32_t read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) + int read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) { if (lcid == 0) { LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; diff --git a/srsapps/ue/phy/src/phch_common.cc b/srsapps/ue/phy/src/phch_common.cc index 8f8cf7be4..8b7d8a716 100644 --- a/srsapps/ue/phy/src/phch_common.cc +++ b/srsapps/ue/phy/src/phch_common.cc @@ -176,7 +176,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable, srslte_timestamp_t tx_time) { - pthread_mutex_lock(&tx_mutex); +/* pthread_mutex_lock(&tx_mutex); // Wait previous TTIs to be transmitted if (is_first_tx) { @@ -187,6 +187,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable, pthread_cond_wait(&tx_cvar, &tx_mutex); } } + */ if (tx_enable) { radio_h->tx(buffer, nof_samples, tx_time); is_first_of_burst = false; @@ -197,8 +198,8 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable, tx_tti_cnt = (tx_tti_cnt + 1) % 10240; - pthread_cond_signal(&tx_cvar); - pthread_mutex_unlock(&tx_mutex); + //pthread_cond_signal(&tx_cvar); + //pthread_mutex_unlock(&tx_mutex); } } diff --git a/srsapps/ue/phy/src/phch_worker.cc b/srsapps/ue/phy/src/phch_worker.cc index 0036a4aef..420a2b204 100644 --- a/srsapps/ue/phy/src/phch_worker.cc +++ b/srsapps/ue/phy/src/phch_worker.cc @@ -192,7 +192,8 @@ void phch_worker::work_imp() /* Transmit PUSCH, PUCCH or SRS */ bool tx_signal = false; if (ul_action.tx_enabled) { - encode_pusch(&ul_action.phy_grant.ul, ul_action.payload_ptr, ul_action.current_tx_nb, ul_action.softbuffer, ul_action.rv, ul_action.rnti); + encode_pusch(&ul_action.phy_grant.ul, ul_action.payload_ptr, ul_action.current_tx_nb, + ul_action.softbuffer, ul_action.rv, ul_action.rnti); tx_signal = true; if (ul_action.expect_ack) { phy->set_pending_ack(tti + 8, ue_ul.pusch_cfg.grant.n_prb_tilde[0], ul_action.phy_grant.ul.ncs_dmrs); @@ -529,7 +530,7 @@ void phch_worker::reset_ul_params() void phch_worker::set_ul_params() { - + /* PUSCH DMRS signal configuration */ bzero(&dmrs_cfg, sizeof(srslte_refsignal_dmrs_pusch_cfg_t)); dmrs_cfg.group_hopping_en = (bool) phy->params_db->get_param(phy_interface_params::DMRS_GROUP_HOPPING_EN); @@ -592,7 +593,8 @@ void phch_worker::set_ul_params() /* SR configuration */ I_sr = (uint32_t) phy->params_db->get_param(phy_interface_params::SR_CONFIG_INDEX); - if (pregen_enabled) { + if (pregen_enabled) { + printf("Pre-generating UL signals\n"); srslte_ue_ul_pregen_signals(&ue_ul); } diff --git a/srsapps/ue/phy/src/phy.cc b/srsapps/ue/phy/src/phy.cc index bef5ab3cd..dcd325a34 100644 --- a/srsapps/ue/phy/src/phy.cc +++ b/srsapps/ue/phy/src/phy.cc @@ -74,6 +74,7 @@ bool phy::init_(radio* radio_handler_, mac_interface_phy *mac, log *log_h_, bool for (int i=0;i