Added mutex to ul/dl harq reset

This commit is contained in:
Ismael Gomez 2018-03-05 14:33:51 +01:00
parent 73602a8558
commit 8591049e92
4 changed files with 35 additions and 6 deletions

View File

@ -76,10 +76,14 @@ void pdu_queue::deallocate(uint8_t* pdu)
*/ */
void pdu_queue::push(uint8_t *ptr, uint32_t len, uint32_t tstamp) void pdu_queue::push(uint8_t *ptr, uint32_t len, uint32_t tstamp)
{ {
if (ptr) {
pdu_t *pdu = (pdu_t*) ptr; pdu_t *pdu = (pdu_t*) ptr;
pdu->len = len; pdu->len = len;
pdu->tstamp = tstamp; pdu->tstamp = tstamp;
pdu_q.push(pdu); pdu_q.push(pdu);
} else {
log_h->warning("Error pushing pdu: ptr is empty\n");
}
} }
bool pdu_queue::process_pdus() bool pdu_queue::process_pdus()

View File

@ -196,6 +196,8 @@ private:
is_initiated = false; is_initiated = false;
ack = false; ack = false;
bzero(&cur_grant, sizeof(Tgrant)); bzero(&cur_grant, sizeof(Tgrant));
pthread_mutex_init(&mutex, NULL);
} }
~dl_tb_process() { ~dl_tb_process() {
@ -220,16 +222,23 @@ private:
} }
void reset(void) { void reset(void) {
pthread_mutex_lock(&mutex);
is_first_tb = true; is_first_tb = true;
ack = false; ack = false;
payload_buffer_ptr = NULL; if (payload_buffer_ptr) {
harq_entity->demux_unit->deallocate(payload_buffer_ptr);
}
bzero(&cur_grant, sizeof(Tgrant)); bzero(&cur_grant, sizeof(Tgrant));
if (is_initiated) { if (is_initiated) {
srslte_softbuffer_rx_reset(&softbuffer); srslte_softbuffer_rx_reset(&softbuffer);
} }
pthread_mutex_unlock(&mutex);
} }
void new_grant_dl(Tgrant grant, Taction *action) { void new_grant_dl(Tgrant grant, Taction *action) {
pthread_mutex_lock(&mutex);
// Compute RV for BCCH when not specified in PDCCH format // Compute RV for BCCH when not specified in PDCCH format
if (pid == HARQ_BCCH_PID && grant.rv[tid] == -1) { if (pid == HARQ_BCCH_PID && grant.rv[tid] == -1) {
uint32_t k; uint32_t k;
@ -271,6 +280,7 @@ private:
if (!action->payload_ptr[tid]) { if (!action->payload_ptr[tid]) {
action->decode_enabled[tid] = false; action->decode_enabled[tid] = false;
Error("Can't get a buffer for TBS=%d\n", cur_grant.n_bytes[tid]); Error("Can't get a buffer for TBS=%d\n", cur_grant.n_bytes[tid]);
pthread_mutex_unlock(&mutex);
return; return;
} }
action->decode_enabled[tid]= true; action->decode_enabled[tid]= true;
@ -299,6 +309,8 @@ private:
Debug("Generating ACK\n"); Debug("Generating ACK\n");
} }
} }
pthread_mutex_unlock(&mutex);
} }
void tb_decoded(bool ack_) { void tb_decoded(bool ack_) {
@ -364,6 +376,8 @@ private:
return is_new_transmission; return is_new_transmission;
} }
pthread_mutex_t mutex;
bool is_initiated; bool is_initiated;
dl_harq_entity *harq_entity; dl_harq_entity *harq_entity;
srslte::log *log_h; srslte::log *log_h;

View File

@ -159,6 +159,8 @@ private:
tti_last_tx = 0; tti_last_tx = 0;
payload_buffer = NULL; payload_buffer = NULL;
bzero(&cur_grant, sizeof(Tgrant)); bzero(&cur_grant, sizeof(Tgrant));
pthread_mutex_init(&mutex, NULL);
} }
~ul_harq_process() ~ul_harq_process()
@ -193,17 +195,21 @@ private:
void reset() void reset()
{ {
pthread_mutex_lock(&mutex);
current_tx_nb = 0; current_tx_nb = 0;
current_irv = 0; current_irv = 0;
tti_last_tx = 0; tti_last_tx = 0;
is_grant_configured = false; is_grant_configured = false;
bzero(&cur_grant, sizeof(Tgrant)); bzero(&cur_grant, sizeof(Tgrant));
pthread_mutex_unlock(&mutex);
} }
void reset_ndi() { cur_grant.ndi[0] = false; } void reset_ndi() { cur_grant.ndi[0] = false; }
void run_tti(uint32_t tti_tx, Tgrant *grant, bool *ack, Taction* action) void run_tti(uint32_t tti_tx, Tgrant *grant, bool *ack, Taction* action)
{ {
pthread_mutex_lock(&mutex);
if (ack) { if (ack) {
if (grant) { if (grant) {
if (grant->ndi[0] == get_ndi() && grant->phy_grant.ul.mcs.tbs != 0) { if (grant->ndi[0] == get_ndi() && grant->phy_grant.ul.mcs.tbs != 0) {
@ -276,6 +282,8 @@ private:
} }
harq_entity->pcap->write_ul_crnti(pdu_ptr, grant->n_bytes[0], grant->rnti, get_nof_retx(), tti_tx); harq_entity->pcap->write_ul_crnti(pdu_ptr, grant->n_bytes[0], grant->rnti, get_nof_retx(), tti_tx);
} }
pthread_mutex_unlock(&mutex);
} }
uint32_t get_rv() uint32_t get_rv()
@ -305,6 +313,7 @@ private:
bool is_initiated; bool is_initiated;
uint32_t tti_last_tx; uint32_t tti_last_tx;
pthread_mutex_t mutex;
const static int payload_buffer_len = 128*1024; const static int payload_buffer_len = 128*1024;
uint8_t *payload_buffer; uint8_t *payload_buffer;

View File

@ -768,6 +768,8 @@ void rrc::earfcn_end() {
// If searching for PLMN, indicate NAS we scanned all frequencies // If searching for PLMN, indicate NAS we scanned all frequencies
if (state == RRC_STATE_PLMN_SELECTION) { if (state == RRC_STATE_PLMN_SELECTION) {
nas->plmn_search_end(); nas->plmn_search_end();
} else if (state == RRC_STATE_CONNECTED) {
leave_connected();
} }
} }