|
|
|
@ -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++) {
|
|
|
|
|
tti_threads_sync[i].set_increment(NOF_TTI_THREADS);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
@ -675,14 +680,21 @@ void mac::tti_thread::run_tti(uint32_t tti) {
|
|
|
|
|
if (parent->phy_h->sr_is_ready_to_send(tti+4)) {
|
|
|
|
|
ul_buffer->generate_sr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
// The UL buffer is released when successfully transmitted.
|
|
|
|
|
// Send now to the radio
|
|
|
|
|
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
|
|
|
|
|
ul_buffer->generate_data();
|
|
|
|
|
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
|
|
|
|
|