mirror of https://github.com/PentHertz/srsLTE.git
Working with 2 threads up to 3 Mbps DL, 4 UL. A few L&Us yet
This commit is contained in:
parent
f5370bd23d
commit
38f4321ed2
|
@ -71,6 +71,10 @@ public:
|
|||
level = LOG_LEVEL_DEBUG;
|
||||
}
|
||||
|
||||
uint32_t get_tti() {
|
||||
return tti;
|
||||
}
|
||||
|
||||
// Pure virtual methods for logging
|
||||
virtual void error(std::string message, ...) = 0;
|
||||
virtual void warning(std::string message, ...) = 0;
|
||||
|
|
|
@ -119,7 +119,7 @@ bool radio_uhd::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_tim
|
|||
bool radio_uhd::tx_end()
|
||||
{
|
||||
save_trace(2, &end_of_burst_time);
|
||||
cuhd_send_timed2(uhd, zeros, 10, end_of_burst_time.full_secs, end_of_burst_time.frac_secs, false, true);
|
||||
cuhd_send_timed2(uhd, zeros, 0, end_of_burst_time.full_secs, end_of_burst_time.frac_secs, false, true);
|
||||
is_start_of_burst = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,9 @@ private:
|
|||
void process_pdu(sch_pdu *pdu);
|
||||
bool process_ce(sch_subh *subheader);
|
||||
|
||||
// Mutex for exclusive access
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
uint64_t contention_resolution_id;
|
||||
bool pending_temp_rnti;
|
||||
bool has_pending_contention_resolution_id;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "srsapps/common/log.h"
|
||||
#include "srsapps/common/tti_sync.h"
|
||||
|
@ -117,13 +118,16 @@ public:
|
|||
pthread_t thread;
|
||||
};
|
||||
|
||||
static const int NOF_TTI_THREADS = 2;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// TTI processing threads
|
||||
static const int NOF_TTI_THREADS = 1;
|
||||
tti_thread tti_threads[NOF_TTI_THREADS];
|
||||
tti_sync_cv tti_threads_sync[NOF_TTI_THREADS];
|
||||
pthread_mutex_t tti_threads_sync_tx[NOF_TTI_THREADS];
|
||||
bool is_first_tx;
|
||||
|
||||
// Interaction with PHY
|
||||
tti_sync *ttisync;
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
uint32_t lchid_sorted[mac_io::NOF_UL_LCH];
|
||||
uint32_t nof_tx_pkts[mac_io::NOF_UL_LCH];
|
||||
|
||||
// Mutex for priority setting from outside MAC
|
||||
// Mutex for exclusive access
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
log *log_h;
|
||||
|
|
|
@ -100,6 +100,8 @@ private:
|
|||
void generate_tx(uint32_t tti_tx, uint8_t *pdu_payload, ul_buffer* ul);
|
||||
};
|
||||
|
||||
uint8_t mac_pdu_buffer[NOF_HARQ_PROC][64*1024];
|
||||
|
||||
timers *timers_db;
|
||||
mux *mux_unit;
|
||||
ul_harq_process proc[NOF_HARQ_PROC];
|
||||
|
|
|
@ -38,6 +38,9 @@ demux::demux() : mac_msg(20),pending_mac_msg(20)
|
|||
pending_temp_rnti = false;
|
||||
has_pending_contention_resolution_id = false;
|
||||
sdu_handler_ = NULL;
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
|
||||
}
|
||||
|
||||
void demux::init(phy* phy_h_, log* log_h_, mac_io* mac_io_h_, timers* timers_db_)
|
||||
|
@ -113,12 +116,17 @@ void demux::push_pdu_temp_crnti(uint8_t *mac_pdu, uint32_t nof_bits)
|
|||
/* Demultiplexing of logical channels and dissassemble of MAC CE */
|
||||
void demux::push_pdu(uint8_t *mac_pdu, uint32_t nof_bits)
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
// Unpack DLSCH MAC PDU
|
||||
mac_msg.init(nof_bits/8);
|
||||
mac_msg.parse_packet(mac_pdu);
|
||||
//mac_msg.fprint(stdout);
|
||||
process_pdu(&mac_msg);
|
||||
Debug("Normal MAC PDU processed\n");
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
}
|
||||
|
||||
void demux::discard_pending_pdu()
|
||||
|
|
|
@ -52,6 +52,7 @@ bool mac::init(phy *phy_h_, tti_sync* ttisync_, log* log_h_)
|
|||
is_synchronized = false;
|
||||
last_temporal_crnti = 0;
|
||||
phy_rnti = 0;
|
||||
is_first_tx = true;
|
||||
|
||||
bsr_procedure.init(log_h, &timers_db, ¶ms_db, &mac_io_lch);
|
||||
mux_unit.init(log_h, &mac_io_lch, &bsr_procedure);
|
||||
|
@ -62,13 +63,14 @@ bool mac::init(phy *phy_h_, tti_sync* ttisync_, log* log_h_)
|
|||
reset();
|
||||
|
||||
for (int i=0;i<NOF_TTI_THREADS;i++) {
|
||||
pthread_mutex_init(&tti_threads_sync_tx[i], NULL);
|
||||
tti_threads_sync[i].set_increment(NOF_TTI_THREADS);
|
||||
if (!tti_threads[i].init(this, &tti_threads_sync[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (threads_new_rt_prio(&mac_thread, mac_thread_fnc, this, 0)) {
|
||||
if (threads_new_rt_prio(&mac_thread, mac_thread_fnc, this, 1)) {
|
||||
started = true;
|
||||
}
|
||||
|
||||
|
@ -81,6 +83,7 @@ void mac::stop()
|
|||
pthread_join(mac_thread, NULL);
|
||||
for (int i=0;i<NOF_TTI_THREADS;i++) {
|
||||
tti_threads[i].stop();
|
||||
pthread_mutex_destroy(&tti_threads_sync_tx[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,8 +282,9 @@ void mac::main_radio_loop() {
|
|||
timers_db.step_all();
|
||||
|
||||
// Trigger execution of corresponding TTI processor thread
|
||||
//tti_threads_sync[tti%NOF_TTI_THREADS].increase();
|
||||
tti_threads[0].run_tti(tti);
|
||||
//printf("triggering tti=%d\n", tti);
|
||||
tti_threads_sync[tti%NOF_TTI_THREADS].increase();
|
||||
//tti_threads[0].run_tti(tti);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -626,7 +630,7 @@ bool mac::tti_thread::init(mac* parent_, tti_sync_cv *sync_)
|
|||
log_h = parent->log_h;
|
||||
sync = sync_;
|
||||
|
||||
//started = threads_new_rt(&thread, tti_thread_runner, this);
|
||||
started = threads_new_rt(&thread, tti_thread_runner, this);
|
||||
return started;
|
||||
}
|
||||
|
||||
|
@ -642,12 +646,13 @@ void mac::tti_thread::run()
|
|||
uint32_t tti = sync->wait();
|
||||
|
||||
if (parent->is_synchronized) {
|
||||
run_tti(tti);
|
||||
run_tti((tti+1)%10240);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mac::tti_thread::run_tti(uint32_t tti) {
|
||||
//printf("running tti=%d\n", tti);
|
||||
// Receive PCH, if requested
|
||||
parent->receive_pch(tti);
|
||||
|
||||
|
@ -676,13 +681,20 @@ void mac::tti_thread::run_tti(uint32_t tti) {
|
|||
ul_buffer->generate_sr();
|
||||
}
|
||||
|
||||
// The UL buffer is released when successfully transmitted.
|
||||
if (ul_buffer->is_released()) {
|
||||
ul_buffer->ready();
|
||||
parent->is_first_of_burst = false;
|
||||
} else if (ul_buffer->uci_ready() || ul_buffer->srs_is_ready_to_send()) {
|
||||
// If the packet was not generated by a call from MAC, means it's PUCCH or SRS. Generate now the signal
|
||||
// If the packet was not generated by an UL grant, means it's PUCCH or SRS. Generate now the signal
|
||||
if (!ul_buffer->is_released() && (ul_buffer->uci_ready() || ul_buffer->srs_is_ready_to_send())) {
|
||||
ul_buffer->generate_data();
|
||||
}
|
||||
|
||||
// Wait for previous TTI to be transmitted
|
||||
if (!parent->is_first_tx) {
|
||||
pthread_mutex_lock(&parent->tti_threads_sync_tx[tti%parent->NOF_TTI_THREADS]);
|
||||
}
|
||||
parent->is_first_tx = false;
|
||||
|
||||
// Send now to the radio
|
||||
if (ul_buffer->is_released()) {
|
||||
ul_buffer->send();
|
||||
ul_buffer->ready();
|
||||
parent->is_first_of_burst = false;
|
||||
} else {
|
||||
|
@ -692,6 +704,9 @@ void mac::tti_thread::run_tti(uint32_t tti) {
|
|||
}
|
||||
}
|
||||
|
||||
// Allow next TTI to be transmitted
|
||||
pthread_mutex_unlock(&parent->tti_threads_sync_tx[(tti+1)%parent->NOF_TTI_THREADS]);
|
||||
|
||||
// Check if there is pending CCCH SDU in Multiplexing Unit
|
||||
if (parent->mux_unit.is_pending_ccch_sdu()) {
|
||||
// Start RA procedure
|
||||
|
|
|
@ -37,8 +37,8 @@ namespace ue {
|
|||
|
||||
mux::mux() : pdu_msg(20)
|
||||
{
|
||||
msg3_buff.init(1, MSG3_BUFF_SZ);
|
||||
pdu_buff.init(1, PDU_BUFF_SZ);
|
||||
msg3_buff.init(mac::NOF_TTI_THREADS, MSG3_BUFF_SZ);
|
||||
pdu_buff.init(mac::NOF_TTI_THREADS, PDU_BUFF_SZ);
|
||||
bzero(nof_tx_pkts, sizeof(uint32_t) * mac_io::NOF_UL_LCH);
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
msg3_has_been_transmitted = false;
|
||||
|
@ -124,6 +124,7 @@ void mux::set_priority(uint32_t lch_id, uint32_t set_priority, int set_PBR, uint
|
|||
|
||||
void mux::pdu_release()
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
pdu_buff.release();
|
||||
}
|
||||
|
||||
|
@ -152,6 +153,9 @@ bool mux::pdu_move_to_msg3(uint32_t pdu_sz)
|
|||
// Multiplexing and logical channel priorization as defined in Section 5.4.3
|
||||
uint8_t* mux::pdu_pop(uint32_t pdu_sz)
|
||||
{
|
||||
// Acquire mutex. Will be released after a call to pdu_release
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
if (pdu_buff.isempty()) {
|
||||
if (assemble_pdu(pdu_sz)) {
|
||||
return (uint8_t*) pdu_buff.pop();
|
||||
|
@ -191,9 +195,6 @@ bool mux::assemble_pdu(uint32_t pdu_sz_nbits) {
|
|||
// Make sure pdu_sz is byte-aligned
|
||||
pdu_sz_nbits = 8*(pdu_sz_nbits/8);
|
||||
|
||||
// Acquire mutex. Cannot change priorities, PBR or BSD after assemble finishes
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
// Update Bj
|
||||
for (int i=0;i<mac_io::NOF_UL_LCH;i++) {
|
||||
// Add PRB unless it's infinity
|
||||
|
@ -263,7 +264,6 @@ bool mux::assemble_pdu(uint32_t pdu_sz_nbits) {
|
|||
for (int i=0;i<mac_io::NOF_UL_LCH;i++) {
|
||||
while (allocate_sdu(lchid_sorted[i], &pdu_msg));
|
||||
}
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
/* Release all SDUs */
|
||||
for (int i=0;i<mac_io::NOF_UL_LCH;i++) {
|
||||
|
|
|
@ -120,10 +120,12 @@ void ul_harq_entity::run_tti(uint32_t tti, ul_sched_grant *grant, phy *phy_h)
|
|||
// Request a MAC PDU from the Multiplexing & Assemble Unit
|
||||
uint8_t* mac_pdu = mux_unit->pdu_pop(grant->get_tbs());
|
||||
if (mac_pdu) {
|
||||
proc[pid].generate_new_tx(tti_tx, mac_pdu, false, grant, phy_h->get_ul_buffer(tti_tx));
|
||||
// FIXME: This is inefficient. too many memcopies
|
||||
memcpy(mac_pdu_buffer[pid], mac_pdu, grant->get_tbs()*sizeof(uint8_t));
|
||||
mux_unit->pdu_release();
|
||||
proc[pid].generate_new_tx(tti_tx, mac_pdu_buffer[pid], false, grant, phy_h->get_ul_buffer(tti_tx));
|
||||
} else {
|
||||
Warning("Uplink grant with MAC PDU available in Multiplex Unit\n");
|
||||
Warning("Uplink grant but no MAC PDU in Multiplex Unit buffer\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -134,7 +134,7 @@ private:
|
|||
IDLE, RXTX
|
||||
} phy_state;
|
||||
|
||||
static const int NOF_ULDL_QUEUES = 6;
|
||||
static const int NOF_ULDL_QUEUES = 10;
|
||||
|
||||
tti_sync *ttisync;
|
||||
radio *radio_handler;
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace ue {
|
|||
bool generate_data(ul_sched_grant *pusch_grant, srslte_softbuffer_tx_t *softbuffer, uint8_t *payload);
|
||||
void set_tx_params(float cfo, float time_adv_sec, srslte_timestamp_t tx_time);
|
||||
void send_end_of_burst();
|
||||
void send();
|
||||
static const uint32_t tx_advance_sf = 1; // Number of subframes to advance transmission
|
||||
static const bool normalize_amp = true;
|
||||
private:
|
||||
|
|
|
@ -106,7 +106,7 @@ bool phy::init_(srslte::radio* radio_handler_, srslte::ue::tti_sync* ttisync_, l
|
|||
params_db.set_param(phy_params::CELLSEARCH_TIMEOUT_PSS_CORRELATION_THRESHOLD, 160);
|
||||
params_db.set_param(phy_params::CELLSEARCH_TIMEOUT_MIB_NFRAMES, 100);
|
||||
|
||||
if (threads_new_rt_prio(&phy_thread, phy_thread_fnc, this, 1)) {
|
||||
if (threads_new_rt_prio(&phy_thread, phy_thread_fnc, this, 2)) {
|
||||
started = true;
|
||||
}
|
||||
return started;
|
||||
|
|
|
@ -285,8 +285,6 @@ bool ul_buffer::generate_data(ul_sched_grant *grant, srslte_softbuffer_tx_t *sof
|
|||
srslte_vec_sc_prod_cfc(signal_buffer, 0.9/max, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
||||
}
|
||||
|
||||
radio_h->tx(signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb), tx_time);
|
||||
|
||||
release();
|
||||
|
||||
if (n < 0) {
|
||||
|
@ -310,6 +308,11 @@ void ul_buffer::set_tx_params(float cfo_, float time_adv_sec, srslte_timestamp_t
|
|||
srslte_timestamp_add(&tx_time, 0, 4e-3 - time_adv_sec); // UL buffer is configured for tti+4
|
||||
}
|
||||
|
||||
void ul_buffer::send() {
|
||||
radio_h->tx(signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb), tx_time);
|
||||
Info("TX TTI=%d\n", tti);
|
||||
}
|
||||
|
||||
void ul_buffer::send_end_of_burst()
|
||||
{
|
||||
Info("TTI %d sending end of burst\n", tti);
|
||||
|
|
|
@ -162,9 +162,7 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
|
|||
{
|
||||
cuhd_handler *handler = new cuhd_handler();
|
||||
std::string _args = std::string(args);
|
||||
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=30720000, num_recv_frames=512");
|
||||
|
||||
// handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=50000000" + ", num_recv_frames=512");
|
||||
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=30720000, num_recv_frames=64, num_send_frames=64");
|
||||
handler->usrp->set_clock_source("internal");
|
||||
|
||||
#ifdef HIDE_MESSAGES
|
||||
|
|
Loading…
Reference in New Issue