Connection Request received

master
ismagom 10 years ago
parent 4652fe6bfe
commit 1b2c474f25

@ -100,7 +100,7 @@ public:
virtual void new_grant_dl(mac_grant_t grant, tb_action_dl_t *action) = 0; virtual void new_grant_dl(mac_grant_t grant, tb_action_dl_t *action) = 0;
/* Indicate successfull decoding of PDSCH TB. */ /* Indicate successfull decoding of PDSCH TB. */
virtual void tb_decoded_ok(uint32_t harq_pid) = 0; virtual void tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid) = 0;
/* Indicate successfull decoding of BCH TB through PBCH */ /* Indicate successfull decoding of BCH TB through PBCH */
virtual void bch_decoded_ok(uint8_t *payload, uint32_t len) = 0; virtual void bch_decoded_ok(uint8_t *payload, uint32_t len) = 0;

@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <vector>
#ifndef TIMERS_H #ifndef TIMERS_H
@ -82,16 +83,12 @@ public:
bool running; bool running;
}; };
timers(uint32_t nof_timers_) { timers(uint32_t nof_timers_) : timer_list(nof_timers_) {
nof_timers = nof_timers_; nof_timers = nof_timers_;
timer_list = new timer[nof_timers];
for (uint32_t i=0;i<nof_timers;i++) { for (uint32_t i=0;i<nof_timers;i++) {
timer_list[i].id = i; timer_list[i].id = i;
} }
} }
~timers() {
delete timer_list;
}
void step_all() { void step_all() {
for (int i=0;i<nof_timers;i++) { for (int i=0;i<nof_timers;i++) {
@ -123,7 +120,7 @@ public:
} }
private: private:
uint32_t nof_timers; uint32_t nof_timers;
timer *timer_list; std::vector<timer> timer_list;
}; };
} }

@ -52,12 +52,12 @@ public:
const static uint32_t HARQ_BCCH_PID = NOF_HARQ_PROC; const static uint32_t HARQ_BCCH_PID = NOF_HARQ_PROC;
dl_harq_entity(); dl_harq_entity();
bool init(log *log_h_, timers *timers_, demux *demux_unit); bool init(log *log_h_, mac_params *params_db, timers *timers_, demux *demux_unit);
/***************** PHY->MAC interface for DL processes **************************/ /***************** PHY->MAC 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(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t *action);
void tb_decoded_ok(uint32_t harq_pid); void tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid);
void reset(); void reset();
@ -74,7 +74,7 @@ private:
bool is_sps(); bool is_sps();
bool is_new_transmission(mac_interface_phy::mac_grant_t grant); bool is_new_transmission(mac_interface_phy::mac_grant_t grant);
void new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t *action); void new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t *action);
void tb_decoded_ok(); void tb_decoded(bool ack);
private: private:
@ -98,6 +98,7 @@ private:
dl_harq_process proc[NOF_HARQ_PROC+1]; dl_harq_process proc[NOF_HARQ_PROC+1];
timers *timers_db; timers *timers_db;
mac_params *params_db;
demux *demux_unit; demux *demux_unit;
log *log_h; log *log_h;
mac_pcap *pcap; mac_pcap *pcap;

@ -62,7 +62,7 @@ public:
void new_grant_ul_ack(mac_grant_t grant, uint8_t *payload_ptr, bool ack, tb_action_ul_t *action); void new_grant_ul_ack(mac_grant_t grant, uint8_t *payload_ptr, bool ack, tb_action_ul_t *action);
void harq_recv(uint32_t tti, bool ack, tb_action_ul_t *action); void harq_recv(uint32_t tti, bool ack, tb_action_ul_t *action);
void new_grant_dl(mac_grant_t grant, tb_action_dl_t *action); void new_grant_dl(mac_grant_t grant, tb_action_dl_t *action);
void tb_decoded_ok(uint32_t harq_pid); void tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid);
void bch_decoded_ok(uint8_t *payload, uint32_t len); void bch_decoded_ok(uint8_t *payload, uint32_t len);
void tti_clock(uint32_t tti); void tti_clock(uint32_t tti);
@ -120,8 +120,6 @@ private:
dl_harq_entity dl_harq; dl_harq_entity dl_harq;
ul_harq_entity ul_harq; ul_harq_entity ul_harq;
int si_window_start, si_window_length;
/* MAC Uplink-related Procedures */ /* MAC Uplink-related Procedures */
ra_proc ra_procedure; ra_proc ra_procedure;
sr_proc sr_procedure; sr_proc sr_procedure;
@ -135,6 +133,9 @@ private:
// pointer to MAC PCAP object // pointer to MAC PCAP object
mac_pcap* pcap; mac_pcap* pcap;
bool si_search_in_progress;
int si_window_length;
int si_window_start;
}; };

@ -58,7 +58,6 @@ public:
bool msg3_get(uint8_t *payload, uint32_t pdu_sz); bool msg3_get(uint8_t *payload, uint32_t pdu_sz);
void msg3_flush(); void msg3_flush();
void msg3_transmitted();
bool msg3_is_transmitted(); bool msg3_is_transmitted();
void append_crnti_ce_next_tx(uint16_t crnti); void append_crnti_ce_next_tx(uint16_t crnti);

@ -78,7 +78,7 @@ private:
log *log_h; log *log_h;
rlc_interface_mac *rlc; rlc_interface_mac *rlc;
bool initiated; bool initiated;
const static int MAX_LCID = 20; const static int MAX_LCID = 6;
int lcg[MAX_LCID]; int lcg[MAX_LCID];
uint32_t last_pending_data[MAX_LCID]; uint32_t last_pending_data[MAX_LCID];
int priorities[MAX_LCID]; int priorities[MAX_LCID];

@ -1,39 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SDUHANDLER_H
#define SDUHANDLER_H
class sdu_handler
{
public:
virtual void notify_new_sdu(uint32_t lcid) = 0;
};
#endif

@ -103,11 +103,11 @@ uint8_t* demux::request_buffer(uint32_t len)
} }
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
uint8_t idx; uint8_t idx;
while(find_unused_queue(&idx)) { while(!find_unused_queue(&idx)) {
pthread_cond_wait(&cvar, &mutex); pthread_cond_wait(&cvar, &mutex);
} }
if (idx > 0) { if (idx > 0) {
Debug("Using queue %d for MAC PDU\n"); Debug("Using queue %d for MAC PDU\n", idx);
} }
used_q[idx] = true; used_q[idx] = true;
uint8_t *buff = (uint8_t*) pdu_q[idx].request(); uint8_t *buff = (uint8_t*) pdu_q[idx].request();

@ -44,10 +44,11 @@ dl_harq_entity::dl_harq_entity()
{ {
pcap = NULL; pcap = NULL;
} }
bool dl_harq_entity::init(log* log_h_, timers* timers_, demux *demux_unit_) bool dl_harq_entity::init(log* log_h_, mac_params *params_db_, timers* timers_, demux *demux_unit_)
{ {
timers_db = timers_; timers_db = timers_;
demux_unit = demux_unit_; demux_unit = demux_unit_;
params_db = params_db_;
log_h = log_h_; log_h = log_h_;
for (uint32_t i=0;i<NOF_HARQ_PROC+1;i++) { for (uint32_t i=0;i<NOF_HARQ_PROC+1;i++) {
if (!proc[i].init(i, this)) { if (!proc[i].init(i, this)) {
@ -81,11 +82,6 @@ uint32_t dl_harq_entity::get_harq_sps_pid(uint32_t tti) {
void dl_harq_entity::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t* action) void dl_harq_entity::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t* action)
{ {
// If PDCCH for C-RNTI and RA procedure in Contention Resolution, notify it
if (grant.rnti_type == SRSLTE_RNTI_USER) {
Warning("Not implemented ra_procedure_crnti\n");
//ra_procedure.pdcch_to_crnti(false);
}
if (grant.rnti_type != SRSLTE_RNTI_SPS) { if (grant.rnti_type != SRSLTE_RNTI_SPS) {
uint32_t harq_pid; uint32_t harq_pid;
// Set BCCH PID for SI RNTI // Set BCCH PID for SI RNTI
@ -127,9 +123,13 @@ void dl_harq_entity::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_inte
} }
} }
void dl_harq_entity::tb_decoded_ok(uint32_t harq_pid) void dl_harq_entity::tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid)
{ {
proc[harq_pid%NOF_HARQ_PROC].tb_decoded_ok(); if (rnti_type == SRSLTE_RNTI_SI) {
proc[NOF_HARQ_PROC].tb_decoded(ack);
} else {
proc[harq_pid%NOF_HARQ_PROC].tb_decoded(ack);
}
} }
bool dl_harq_entity::generate_ack_callback(void *arg) bool dl_harq_entity::generate_ack_callback(void *arg)
@ -192,13 +192,10 @@ bool dl_harq_entity::dl_harq_process::is_new_transmission(mac_interface_phy::mac
(pid == HARQ_BCCH_PID && grant.rv == 0)) // Broadcast PID and 1st TX (RV=0) (pid == HARQ_BCCH_PID && grant.rv == 0)) // Broadcast PID and 1st TX (RV=0)
{ {
is_new_transmission = true; is_new_transmission = true;
Debug("Set HARQ Info for new transmission\n"); Debug("Set HARQ for new transmission\n");
} else { } else {
if (!is_new_tb) {
Info("old_tbs=%d, new_tbs=%d, old_tti=%d new_tti=%d\n", cur_grant.n_bytes, grant.n_bytes, cur_grant.tti, grant.tti);
}
is_new_transmission = false; is_new_transmission = false;
Debug("Set HARQ Info for retransmission\n"); Debug("Set HARQ for retransmission\n");
} }
Info("DL PID %d: %s RV=%d, NDI=%d, LastNDI=%d\n", pid, is_new_transmission?"new TX":"reTX", grant.rv, Info("DL PID %d: %s RV=%d, NDI=%d, LastNDI=%d\n", pid, is_new_transmission?"new TX":"reTX", grant.rv,
@ -209,6 +206,17 @@ bool dl_harq_entity::dl_harq_process::is_new_transmission(mac_interface_phy::mac
void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t* action) void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::tb_action_dl_t* action)
{ {
if (pid == HARQ_BCCH_PID) {
// Compute RV
uint32_t k;
if (grant.tti%10 == 5) { // This is SIB1, k is different
k = (grant.tti/20)%4;
} else {
uint32_t nw = harq_entity->params_db->get_param(mac_interface_params::BCCH_SI_WINDOW_LEN);
k = (grant.tti%nw)%4;
}
grant.rv = ((uint32_t) ceilf((float)1.5*k))%4;
}
if (is_new_transmission(grant)) { if (is_new_transmission(grant)) {
ack = false; ack = false;
@ -235,9 +243,8 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_
Error("Can't get a buffer for TBS=%d\n", cur_grant.n_bytes); Error("Can't get a buffer for TBS=%d\n", cur_grant.n_bytes);
return; return;
} }
memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(mac_interface_phy::mac_grant_t));
Info("DL PID %d: TBS=%d, RV=%d, crc=%s\n", pid, cur_grant.n_bytes, cur_grant.rv, ack?"OK":"NOK"); memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(srslte_phy_grant_t));
} else { } else {
Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n", pid); Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n", pid);
@ -247,17 +254,6 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_
// Do not generate ACK // Do not generate ACK
Debug("Not generating ACK\n"); Debug("Not generating ACK\n");
action->generate_ack = false; action->generate_ack = false;
if (pid == HARQ_BCCH_PID) {
// Compute RV
uint32_t k;
if (grant.tti%10 == 5) { // This is SIB1, k is different
k = (grant.tti/20)%4;
} else {
k = (grant.tti/10)%4;
}
action->rv = ((uint32_t) ceilf((float)1.5*k))%4;
}
} else { } else {
if (cur_grant.rnti_type == SRSLTE_RNTI_TEMP) { if (cur_grant.rnti_type == SRSLTE_RNTI_TEMP) {
// Postpone ACK after contention resolution is resolved // Postpone ACK after contention resolution is resolved
@ -270,9 +266,10 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_
} }
} }
void dl_harq_entity::dl_harq_process::tb_decoded_ok() void dl_harq_entity::dl_harq_process::tb_decoded(bool ack_)
{ {
ack = true; ack = ack_;
if (ack == true) {
if (pid == HARQ_BCCH_PID) { if (pid == HARQ_BCCH_PID) {
if (harq_entity->pcap) { if (harq_entity->pcap) {
harq_entity->pcap->write_dl_sirnti(payload_buffer_ptr, cur_grant.n_bytes, ack, cur_grant.tti); harq_entity->pcap->write_dl_sirnti(payload_buffer_ptr, cur_grant.n_bytes, ack, cur_grant.tti);
@ -295,6 +292,8 @@ void dl_harq_entity::dl_harq_process::tb_decoded_ok()
} }
} }
} }
}
Info("DL PID %d: TBS=%d, RV=%d, ACK=%s\n", pid, cur_grant.n_bytes, cur_grant.rv, ack?"OK":"KO");
} }

@ -41,8 +41,9 @@ mac::mac() : ttisync(10240), timers_db((uint32_t) NOF_MAC_TIMERS)
{ {
started = false; started = false;
pcap = NULL; pcap = NULL;
si_window_start = -1; si_search_in_progress = false;
si_window_length = -1; si_window_length = -1;
si_window_start = -1;
} }
bool mac::init(phy_interface *phy, rlc_interface_mac *rlc, log *log_h_) bool mac::init(phy_interface *phy, rlc_interface_mac *rlc, log *log_h_)
@ -62,10 +63,11 @@ bool mac::init(phy_interface *phy, rlc_interface_mac *rlc, log *log_h_)
ra_procedure.init (phy_h, log_h, &params_db, &timers_db, &mux_unit, &demux_unit); ra_procedure.init (phy_h, log_h, &params_db, &timers_db, &mux_unit, &demux_unit);
sr_procedure.init (phy_h, log_h, &params_db); sr_procedure.init (phy_h, log_h, &params_db);
ul_harq.init ( log_h, &params_db, &timers_db, &mux_unit); ul_harq.init ( log_h, &params_db, &timers_db, &mux_unit);
dl_harq.init ( log_h, &timers_db, &demux_unit); dl_harq.init ( log_h, &params_db, &timers_db, &demux_unit);
reset(); reset();
started = true;
start(MAC_THREAD_PRIO); start(MAC_THREAD_PRIO);
return started; return started;
@ -126,7 +128,7 @@ void mac::run_thread() {
while(!phy_h->get_current_tti()) { while(!phy_h->get_current_tti()) {
usleep(50000); usleep(50000);
} }
Debug("Setting ttysync to %d\n", phy_h->get_current_tti());
ttisync.set_producer_cntr(phy_h->get_current_tti()); ttisync.set_producer_cntr(phy_h->get_current_tti());
while(started) { while(started) {
@ -136,6 +138,8 @@ void mac::run_thread() {
log_h->step(tti); log_h->step(tti);
search_si_rnti();
// Step all procedures // Step all procedures
bsr_procedure.step(tti); bsr_procedure.step(tti);
@ -157,37 +161,48 @@ void mac::run_thread() {
//ra_procedure.start_mac_order(); //ra_procedure.start_mac_order();
} }
// Check if there is pending CCCH SDU in Mux unit
if (mux_unit.is_pending_ccch_sdu()) {
if (!ra_procedure.in_progress() && !ra_procedure.is_successful()) {
ra_procedure.start_rlc_order();
}
}
ra_procedure.step(tti); ra_procedure.step(tti);
//phr_procedure.step(tti); //phr_procedure.step(tti);
timers_db.step_all(); timers_db.step_all();
search_si_rnti();
demux_unit.process_pdus(); demux_unit.process_pdus();
} }
} }
void mac::search_si_rnti() void mac::search_si_rnti()
{ {
// Reset PDCCH search
if (si_window_length >= 0 && si_window_start >= 0) {
if (tti >= si_window_start + si_window_length) {
phy_h->pdcch_dl_search_reset();
}
}
// Setup PDCCH search // Setup PDCCH search
int _si_window_start = params_db.get_param(mac_interface_params::BCCH_SI_WINDOW_ST); int _si_window_start = params_db.get_param(mac_interface_params::BCCH_SI_WINDOW_ST);
int _si_window_length = params_db.get_param(mac_interface_params::BCCH_SI_WINDOW_LEN); int _si_window_length = params_db.get_param(mac_interface_params::BCCH_SI_WINDOW_LEN);
if (_si_window_length > 0 && _si_window_start >= 0) { if ((tti >= si_window_start + si_window_length) && si_search_in_progress) {
si_search_in_progress = false;
phy_h->pdcch_dl_search_reset();
Debug("SI search window expired (%d >= %d+%d)\n", tti, si_window_start, si_window_length);
params_db.set_param(mac_interface_params::BCCH_SI_WINDOW_ST, -1);
params_db.set_param(mac_interface_params::BCCH_SI_WINDOW_LEN, -1);
}
if (_si_window_length > 0 && _si_window_start >= 0 && !si_search_in_progress) {
si_window_length = _si_window_length; si_window_length = _si_window_length;
si_window_start = _si_window_start; si_window_start = _si_window_start;
Debug("Searching for DL grant for SI-RNTI window_st=%d, window_len=%d\n", si_window_start, si_window_length); Debug("Searching for DL grant for SI-RNTI window_st=%d, window_len=%d\n", si_window_start, si_window_length);
phy_h->pdcch_dl_search(SRSLTE_RNTI_SI, 0xffff, si_window_start, si_window_length); phy_h->pdcch_dl_search(SRSLTE_RNTI_SI, 0xffff, si_window_start, si_window_start+si_window_length);
params_db.set_param(mac_interface_params::BCCH_SI_WINDOW_ST, -1); si_search_in_progress = true;
params_db.set_param(mac_interface_params::BCCH_SI_WINDOW_LEN, -1); }
if ((_si_window_length < 0 || _si_window_start < 0) && si_search_in_progress) {
phy_h->pdcch_dl_search_reset();
si_search_in_progress = false;
Debug("SI search interrupted by higher layers\n");
} }
} }
@ -216,6 +231,12 @@ void mac::new_grant_dl(mac_interface_phy::mac_grant_t grant, mac_interface_phy::
if (grant.rnti_type == SRSLTE_RNTI_RAR) { if (grant.rnti_type == SRSLTE_RNTI_RAR) {
ra_procedure.new_grant_dl(grant, action); ra_procedure.new_grant_dl(grant, action);
} else { } else {
// If PDCCH for C-RNTI and RA procedure in Contention Resolution, notify it
if (grant.rnti_type == SRSLTE_RNTI_USER) {
if (ra_procedure.is_contention_resolution()) {
ra_procedure.pdcch_to_crnti(false);
}
}
dl_harq.new_grant_dl(grant, action); dl_harq.new_grant_dl(grant, action);
} }
} }
@ -228,6 +249,11 @@ uint32_t mac::get_current_tti()
void mac::new_grant_ul(mac_interface_phy::mac_grant_t grant, uint8_t* payload_ptr, void mac::new_grant_ul(mac_interface_phy::mac_grant_t grant, uint8_t* payload_ptr,
mac_interface_phy::tb_action_ul_t* action) mac_interface_phy::tb_action_ul_t* action)
{ {
if (grant.rnti_type == SRSLTE_RNTI_USER) {
if (ra_procedure.is_contention_resolution()) {
ra_procedure.pdcch_to_crnti(true);
}
}
ul_harq.new_grant_ul(grant, payload_ptr, action); ul_harq.new_grant_ul(grant, payload_ptr, action);
} }
@ -237,12 +263,14 @@ void mac::new_grant_ul_ack(mac_interface_phy::mac_grant_t grant, uint8_t* payloa
ul_harq.new_grant_ul_ack(grant, payload_ptr, ack, action); ul_harq.new_grant_ul_ack(grant, payload_ptr, ack, action);
} }
void mac::tb_decoded_ok(uint32_t harq_pid) void mac::tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid)
{ {
if (ra_procedure.in_progress()) { if (rnti_type == SRSLTE_RNTI_RAR) {
if (ack) {
ra_procedure.tb_decoded_ok(); ra_procedure.tb_decoded_ok();
}
} else { } else {
dl_harq.tb_decoded_ok(harq_pid); dl_harq.tb_decoded(ack, rnti_type, harq_pid);
} }
} }

@ -154,7 +154,7 @@ bool mux::pdu_get(uint8_t *payload, uint32_t pdu_sz)
bool is_first = true; bool is_first = true;
if (!allocate_sdu(0, &pdu_msg, &is_first)) { if (!allocate_sdu(0, &pdu_msg, &is_first)) {
if (pending_crnti_ce) { if (pending_crnti_ce) {
if (pdu_msg.new_subh()) {http://moodycamel.com/blog/2014/detailed-design-of-a-lock-free-queue if (pdu_msg.new_subh()) {
pdu_msg.next(); pdu_msg.next();
if (!pdu_msg.get()->set_c_rnti(pending_crnti_ce)) { if (!pdu_msg.get()->set_c_rnti(pending_crnti_ce)) {
Warning("Pending C-RNTI CE could not be inserted in MAC PDU\n"); Warning("Pending C-RNTI CE could not be inserted in MAC PDU\n");
@ -164,6 +164,7 @@ bool mux::pdu_get(uint8_t *payload, uint32_t pdu_sz)
} }
pending_crnti_ce = 0; pending_crnti_ce = 0;
#ifdef kk
uint32_t bsr_payload_sz = bsr_procedure->need_to_send_bsr_on_ul_grant(pdu_msg.rem_size()); uint32_t bsr_payload_sz = bsr_procedure->need_to_send_bsr_on_ul_grant(pdu_msg.rem_size());
bsr_proc::bsr_t bsr; bsr_proc::bsr_t bsr;
@ -189,7 +190,7 @@ bool mux::pdu_get(uint8_t *payload, uint32_t pdu_sz)
// data from any Logical Channel, except data from UL-CCCH; // data from any Logical Channel, except data from UL-CCCH;
// first only those with positive Bj // first only those with positive Bj
uint32_t sdu_sz = 0; uint32_t sdu_sz = 0;
for (int i=0;i<NOF_UL_LCH;i++) { for (int i=0;i<1;i++) {
uint32_t lcid = lchid_sorted[i]; uint32_t lcid = lchid_sorted[i];
if (lcid != 0) { if (lcid != 0) {
bool res = true; bool res = true;
@ -203,7 +204,7 @@ bool mux::pdu_get(uint8_t *payload, uint32_t pdu_sz)
} }
// If resources remain, allocate regardless of their Bj value // If resources remain, allocate regardless of their Bj value
for (int i=0;i<NOF_UL_LCH;i++) { for (int i=1;i<NOF_UL_LCH;i++) {
while (allocate_sdu(lchid_sorted[i], &pdu_msg)); while (allocate_sdu(lchid_sorted[i], &pdu_msg));
} }
@ -220,7 +221,8 @@ bool mux::pdu_get(uint8_t *payload, uint32_t pdu_sz)
if (bsr_subh) { if (bsr_subh) {
bsr_subh->set_bsr(bsr.buff_size, bsr_format_convert(bsr.format), bsr_payload_sz?false:true); bsr_subh->set_bsr(bsr.buff_size, bsr_format_convert(bsr.format), bsr_payload_sz?false:true);
} }
#endif
pdu_msg.fprint(stdout);
Debug("Assembled MAC PDU msg size %d/%d bytes\n", pdu_msg.size(), pdu_sz); Debug("Assembled MAC PDU msg size %d/%d bytes\n", pdu_msg.size(), pdu_sz);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
@ -254,11 +256,13 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
uint32_t sdu_len = rlc->get_buffer_state(lcid); uint32_t sdu_len = rlc->get_buffer_state(lcid);
if (sdu_len > 0) { // there is pending SDU to allocate if (sdu_len > 0) { // there is pending SDU to allocate
Debug("%d bytes pending on RLC buffer. Maximum rate=%d, available space=%d\n",
sdu_len, max_sdu_sz, pdu_msg->rem_size() - 2);
if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) { if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) {
sdu_len = max_sdu_sz; sdu_len = max_sdu_sz;
} }
if (sdu_len > pdu_msg->rem_size() - pdu_msg->size_plus_header_sdu(sdu_len)) { if (sdu_len > pdu_msg->rem_size() - 2) {
sdu_len = pdu_msg->rem_size() - pdu_msg->size_plus_header_sdu(sdu_len); sdu_len = pdu_msg->rem_size() - 2;
} }
if (pdu_msg->new_subh()) { // there is space for a new subheader if (pdu_msg->new_subh()) { // there is space for a new subheader
pdu_msg->next(); pdu_msg->next();
@ -286,11 +290,6 @@ void mux::msg3_flush()
msg3_has_been_transmitted = false; msg3_has_been_transmitted = false;
} }
void mux::msg3_transmitted()
{
msg3_has_been_transmitted = true;
}
bool mux::msg3_is_transmitted() bool mux::msg3_is_transmitted()
{ {
return msg3_has_been_transmitted; return msg3_has_been_transmitted;
@ -321,6 +320,8 @@ bool mux::msg3_get(uint8_t *payload, uint32_t pdu_sz)
if (msg3) { if (msg3) {
memcpy(payload, msg3, sizeof(uint8_t)*pdu_sz); memcpy(payload, msg3, sizeof(uint8_t)*pdu_sz);
msg3_buff.release(); msg3_buff.release();
msg3_has_been_transmitted = true;
srslte_vec_fprint_byte(stdout, payload, pdu_sz);
return true; return true;
} else { } else {
Error("Generating Msg3\n"); Error("Generating Msg3\n");

@ -112,11 +112,11 @@ bool sch_pdu::write_packet(uint8_t* ptr, rlc_interface_mac *rlc)
// Find last SDU or CE // Find last SDU or CE
int last_sh; int last_sh;
int last_sdu = nof_subheaders-1; int last_sdu = nof_subheaders-1;
while(!subheaders[last_sdu].is_sdu() && last_sdu >= 0) { while(!subheaders[last_sdu].is_sdu() && last_sdu > 0) {
last_sdu--; last_sdu--;
} }
int last_ce = nof_subheaders-1; int last_ce = nof_subheaders-1;
while(subheaders[last_ce].is_sdu() && last_ce >= 0) { while(subheaders[last_ce].is_sdu() && last_ce > 0) {
last_ce--; last_ce--;
} }
last_sh = subheaders[last_sdu].is_sdu()?last_sdu:last_ce; last_sh = subheaders[last_sdu].is_sdu()?last_sdu:last_ce;
@ -236,7 +236,6 @@ void sch_subh::init()
lcid = 0; lcid = 0;
nof_bytes = 0; nof_bytes = 0;
payload = NULL; payload = NULL;
bzero(payload, sizeof(uint8_t) * MAX_CE_PAYLOAD_LEN);
} }
sch_subh::cetype sch_subh::ce_type() sch_subh::cetype sch_subh::ce_type()
@ -450,20 +449,24 @@ void sch_subh::write_subheader(uint8_t** ptr, bool is_last)
{ {
if (is_sdu()) { if (is_sdu()) {
// MAC SDU: R/R/E/LCID/F/L subheader // MAC SDU: R/R/E/LCID/F/L subheader
*(*ptr + 0) = (uint8_t) is_last<<5 | (lcid & 0x1f); *(*ptr) = (uint8_t) !is_last<<5 | (lcid & 0x1f);
*ptr += 1;
// 2nd and 3rd octet // 2nd and 3rd octet
if (!is_last) { if (!is_last) {
if (nof_bytes >= 128) { if (nof_bytes >= 128) {
*(*ptr + 1) = (uint8_t) 1<<7 | ((nof_bytes & 0x7f00) >> 8); *(*ptr) = (uint8_t) 1<<7 | ((nof_bytes & 0x7f00) >> 8);
*(*ptr + 2) = (uint8_t) (nof_bytes & 0xff); *ptr += 1;
*(*ptr) = (uint8_t) (nof_bytes & 0xff);
*ptr += 1;
} else { } else {
*(*ptr + 1) = (uint8_t) (nof_bytes & 0x7f); *(*ptr) = (uint8_t) (nof_bytes & 0x7f);
*ptr += 1;
} }
} }
} else { } else {
// MAC CE: R/R/E/LCID MAC Subheader // MAC CE: R/R/E/LCID MAC Subheader
*(*ptr + 0) = (uint8_t) is_last<<5 | (lcid & 0x1f); *(*ptr) = (uint8_t) is_last<<5 | (lcid & 0x1f);
*ptr += 1;
} }
} }
@ -482,14 +485,17 @@ void sch_subh::write_payload(uint8_t** ptr, rlc_interface_mac *rlc)
bool sch_subh::read_subheader(uint8_t** ptr) bool sch_subh::read_subheader(uint8_t** ptr)
{ {
// Skip R // Skip R
bool e_bit = (bool) *(*ptr + 0) & 0x20; bool e_bit = (bool) *(*ptr) & 0x20;
lcid = (uint8_t) *(*ptr + 0) & 0x1f; lcid = (uint8_t) *(*ptr) & 0x1f;
*ptr += 1;
if (is_sdu()) { if (is_sdu()) {
if (e_bit) { if (e_bit) {
F_bit = (bool) *(*ptr + 1) & 0x80; F_bit = (bool) *(*ptr) & 0x80;
nof_bytes = (uint32_t)*(*ptr + 1) & 0x7f; nof_bytes = (uint32_t)*(*ptr) & 0x7f;
*ptr += 1;
if (F_bit) { if (F_bit) {
nof_bytes = nof_bytes<<8 | (uint32_t) *(*ptr + 2) & 0xff; nof_bytes = nof_bytes<<8 | (uint32_t) *(*ptr) & 0xff;
*ptr += 1;
} }
} else { } else {
nof_bytes = 0; nof_bytes = 0;
@ -640,6 +646,7 @@ void rar_subh::set_temp_crnti(uint16_t temp_rnti_)
void rar_subh::write_subheader(uint8_t** ptr, bool is_last) void rar_subh::write_subheader(uint8_t** ptr, bool is_last)
{ {
*(*ptr + 0) = (uint8_t) (is_last<<7 | 1<<6 | preamble & 0x3f); *(*ptr + 0) = (uint8_t) (is_last<<7 | 1<<6 | preamble & 0x3f);
*ptr += 1;
} }
// Section 6.2.3 // Section 6.2.3
void rar_subh::write_payload(uint8_t** ptr, rlc_interface_mac *rlc) void rar_subh::write_payload(uint8_t** ptr, rlc_interface_mac *rlc)
@ -651,11 +658,13 @@ void rar_subh::write_payload(uint8_t** ptr, rlc_interface_mac *rlc)
*(*ptr + 3) = (uint8_t) srslte_bit_unpack(&x, 8); *(*ptr + 3) = (uint8_t) srslte_bit_unpack(&x, 8);
*(*ptr + 4) = (uint8_t) ((temp_rnti&0xff00) >> 8); *(*ptr + 4) = (uint8_t) ((temp_rnti&0xff00) >> 8);
*(*ptr + 5) = (uint8_t) (temp_rnti&0x00ff); *(*ptr + 5) = (uint8_t) (temp_rnti&0x00ff);
*ptr += 6;
} }
void rar_subh::read_payload(uint8_t** ptr) void rar_subh::read_payload(uint8_t** ptr)
{ {
ta = *(*ptr + 0)&0x7f << 4 | (*(*ptr + 1)&0xf0)>>4; ta = ((uint32_t) *(*ptr + 0)&0x7f)<<4 | (*(*ptr + 1)&0xf0)>>4;
printf("ta=%d, 0x%x\n", ta, ta);
grant[0] = *(*ptr + 1)&0x8; grant[0] = *(*ptr + 1)&0x8;
grant[1] = *(*ptr + 1)&0x4; grant[1] = *(*ptr + 1)&0x4;
grant[2] = *(*ptr + 1)&0x2; grant[2] = *(*ptr + 1)&0x2;
@ -663,18 +672,20 @@ void rar_subh::read_payload(uint8_t** ptr)
uint8_t *x = &grant[4]; uint8_t *x = &grant[4];
srslte_bit_pack(*(*ptr+2), &x, 8); srslte_bit_pack(*(*ptr+2), &x, 8);
srslte_bit_pack(*(*ptr+3), &x, 8); srslte_bit_pack(*(*ptr+3), &x, 8);
temp_rnti = *(*ptr + 4)<<8 | *(*ptr + 5); temp_rnti = ((uint16_t) *(*ptr + 4))<<8 | *(*ptr + 5);
*ptr += 6;
} }
bool rar_subh::read_subheader(uint8_t** ptr) bool rar_subh::read_subheader(uint8_t** ptr)
{ {
bool e_bit = *(*ptr + 0) & 0x80; bool e_bit = *(*ptr) & 0x80;
bool type = *(*ptr + 0) & 0x40; bool type = *(*ptr) & 0x40;
if (type) { if (type) {
preamble = *(*ptr + 0) & 0x3f; preamble = *(*ptr) & 0x3f;
} else { } else {
((rar_pdu*)parent)->set_backoff(*(*ptr + 0) & 0xf); ((rar_pdu*)parent)->set_backoff(*(*ptr) & 0xf);
} }
*ptr += 1;
return e_bit; return e_bit;
} }

@ -292,7 +292,7 @@ bool bsr_proc::generate_bsr_on_ul_grant(uint32_t nof_padding_bytes, bsr_t *bsr)
} }
generate_bsr(bsr, nof_padding_bytes); generate_bsr(bsr, nof_padding_bytes);
ret = true; ret = true;
Info("Sending BSR type %s, format %s, nof_padding_bytes=%d\n", Info("Including BSR type %s, format %s, nof_padding_bytes=%d\n",
bsr_type_tostring(triggered_bsr_type), bsr_format_tostring(bsr->format), nof_padding_bytes); bsr_type_tostring(triggered_bsr_type), bsr_format_tostring(bsr->format), nof_padding_bytes);
if (timer_periodic && bsr->format != TRUNC_BSR) { if (timer_periodic && bsr->format != TRUNC_BSR) {

@ -262,7 +262,7 @@ void ra_proc::tb_decoded_ok() {
rar_pdu_msg.init(rar_grant_nbytes); rar_pdu_msg.init(rar_grant_nbytes);
rar_pdu_msg.parse_packet(rar_pdu_buffer); rar_pdu_msg.parse_packet(rar_pdu_buffer);
srslte_vec_fprint_byte(stdout, rar_pdu_buffer, rar_grant_nbytes);
// Set Backoff parameter // Set Backoff parameter
if (rar_pdu_msg.has_backoff()) { if (rar_pdu_msg.has_backoff()) {
backoff_param_ms = backoff_table[rar_pdu_msg.get_backoff()%16]; backoff_param_ms = backoff_table[rar_pdu_msg.get_backoff()%16];
@ -273,7 +273,7 @@ void ra_proc::tb_decoded_ok() {
while(rar_pdu_msg.next()) { while(rar_pdu_msg.next()) {
if (rar_pdu_msg.get()->get_rapid() == sel_preamble) { if (rar_pdu_msg.get()->get_rapid() == sel_preamble) {
rInfo("Received RAPID=%d\n", sel_preamble); rInfo("Received RAPID=%d\n", sel_preamble);
rar_pdu_msg.fprint(stdout);
process_timeadv_cmd(rar_pdu_msg.get()->get_ta_cmd()); process_timeadv_cmd(rar_pdu_msg.get()->get_ta_cmd());
// FIXME: Indicate received target power // FIXME: Indicate received target power
@ -282,6 +282,8 @@ void ra_proc::tb_decoded_ok() {
uint8_t grant[rar_subh::RAR_GRANT_LEN]; uint8_t grant[rar_subh::RAR_GRANT_LEN];
rar_pdu_msg.get()->get_sched_grant(grant); rar_pdu_msg.get()->get_sched_grant(grant);
phy_h->pdcch_dl_search_reset();
phy_h->set_rar_grant(rar_grant_tti, grant); phy_h->set_rar_grant(rar_grant_tti, grant);
if (preambleIndex > 0) { if (preambleIndex > 0) {
@ -290,6 +292,7 @@ void ra_proc::tb_decoded_ok() {
} else { } else {
// Preamble selected by UE MAC // Preamble selected by UE MAC
params_db->set_param(mac_interface_params::RNTI_TEMP, rar_pdu_msg.get()->get_temp_crnti()); params_db->set_param(mac_interface_params::RNTI_TEMP, rar_pdu_msg.get()->get_temp_crnti());
if (first_rar_received) { if (first_rar_received) {
first_rar_received = false; first_rar_received = false;
@ -341,6 +344,7 @@ void ra_proc::step_response_error() {
} else { } else {
rInfo("Transmitting inmediatly (%d/%d)\n", preambleTransmissionCounter, preambleTransMax); rInfo("Transmitting inmediatly (%d/%d)\n", preambleTransmissionCounter, preambleTransMax);
state = RESOURCE_SELECTION; state = RESOURCE_SELECTION;
exit(-1);
} }
} }
} }

@ -386,8 +386,9 @@ public:
// Send ConnectionRequest Packet // Send ConnectionRequest Packet
printf("Send ConnectionRequest %d/%d bytes\n", nbytes, nof_bytes); printf("Send ConnectionRequest %d/%d bytes\n", nbytes, nof_bytes);
srslte_bit_pack_vector(bit_msg.msg, payload, nbytes*8); srslte_bit_unpack_vector(bit_msg.msg, payload, nbytes*8);
bzero(&payload[nbytes], (nof_bytes-nbytes)*sizeof(uint8_t)); bzero(&payload[nbytes], (nof_bytes-nbytes)*sizeof(uint8_t));
srslte_vec_fprint_byte(stdout, payload, nof_bytes);
} else if (lcid == 1) { } else if (lcid == 1) {
if (nsegm_dcch < 2) { if (nsegm_dcch < 2) {
printf("Sending Connection Setup Complete %d length %d\n", nsegm_dcch, lengths[nsegm_dcch]); printf("Sending Connection Setup Complete %d length %d\n", nsegm_dcch, lengths[nsegm_dcch]);
@ -426,10 +427,11 @@ public:
void write_pdu_bcch_bch(uint8_t *payload, uint32_t nof_bytes) void write_pdu_bcch_bch(uint8_t *payload, uint32_t nof_bytes)
{ {
LIBLTE_RRC_MIB_STRUCT mib; LIBLTE_RRC_MIB_STRUCT mib;
srslte_vec_fprint_byte(stdout, payload, nof_bytes);
srslte_bit_pack_vector(payload, bit_msg.msg, nof_bytes*8); srslte_bit_pack_vector(payload, bit_msg.msg, nof_bytes*8);
bit_msg.N_bits = nof_bytes*8; bit_msg.N_bits = nof_bytes*8;
liblte_rrc_unpack_bcch_bch_msg(&bit_msg, &mib); liblte_rrc_unpack_bcch_bch_msg(&bit_msg, &mib);
printf("MIB received %d bytes, BW=%s\n", nof_bytes, liblte_rrc_dl_bandwidth_text[mib.dl_bw]); printf("MIB received %d bytes, BW=%s MHz\n", nof_bytes, liblte_rrc_dl_bandwidth_text[mib.dl_bw]);
mib_decoded = true; mib_decoded = true;
} }
@ -440,17 +442,19 @@ public:
bit_msg.N_bits = nof_bytes*8; bit_msg.N_bits = nof_bytes*8;
liblte_rrc_unpack_bcch_dlsch_msg(&bit_msg, &dlsch_msg); liblte_rrc_unpack_bcch_dlsch_msg(&bit_msg, &dlsch_msg);
if (dlsch_msg.N_sibs > 0) { if (dlsch_msg.N_sibs > 0) {
if (dlsch_msg.sibs[0].sib_type == LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_1) { if (dlsch_msg.sibs[0].sib_type == LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_1 && !sib1_decoded) {
si_window_len = liblte_rrc_si_window_length_num[dlsch_msg.sibs[0].sib.sib1.si_window_length]; si_window_len = liblte_rrc_si_window_length_num[dlsch_msg.sibs[0].sib.sib1.si_window_length];
sib2_period = liblte_rrc_si_periodicity_num[dlsch_msg.sibs[0].sib.sib1.sched_info[0].si_periodicity]; sib2_period = liblte_rrc_si_periodicity_num[dlsch_msg.sibs[0].sib.sib1.sched_info[0].si_periodicity];
printf("SIB1 received %d bytes, CellID=%d, si_window=%d, sib2_period=%d\n", printf("SIB1 received %d bytes, CellID=%d, si_window=%d, sib2_period=%d\n",
nof_bytes, dlsch_msg.sibs[0].sib.sib1.cell_id&0xfff, si_window_len, sib2_period); nof_bytes, dlsch_msg.sibs[0].sib.sib1.cell_id&0xfff, si_window_len, sib2_period);
sib1_decoded = true; sib1_decoded = true;
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, -1);
} else if (dlsch_msg.sibs[0].sib_type == LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2) { } else if (dlsch_msg.sibs[0].sib_type == LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2) {
printf("SIB2 received %d bytes\n", nof_bytes); printf("SIB2 received %d bytes\n", nof_bytes);
setup_mac_phy_sib2(&dlsch_msg.sibs[0].sib.sib2, &mac, &phy); setup_mac_phy_sib2(&dlsch_msg.sibs[0].sib.sib2, &mac, &phy);
sib2_decoded = true; sib2_decoded = true;
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, -1);
} }
} }
} }
@ -501,7 +505,7 @@ int main(int argc, char *argv[])
phy.init(&radio_uhd, &mac, &phy_log); phy.init(&radio_uhd, &mac, &phy_log);
} else { } else {
radio_uhd.init_agc(); radio_uhd.init_agc();
radio_uhd.set_tx_rx_gain_offset(0); radio_uhd.set_tx_rx_gain_offset(10);
phy.init_agc(&radio_uhd, &mac, &phy_log); phy.init_agc(&radio_uhd, &mac, &phy_log);
} }
// Init MAC // Init MAC
@ -511,20 +515,23 @@ int main(int argc, char *argv[])
radio_uhd.set_rx_freq(prog_args.uhd_rx_freq); radio_uhd.set_rx_freq(prog_args.uhd_rx_freq);
radio_uhd.set_tx_freq(prog_args.uhd_tx_freq); radio_uhd.set_tx_freq(prog_args.uhd_tx_freq);
while(1) { while(1) {
uint32_t tti; uint32_t tti;
if (my_rlc.mib_decoded) { if (my_rlc.mib_decoded) {
if (!my_rlc.sib1_decoded) { if (!my_rlc.sib1_decoded) {
usleep(10000);
tti = mac.get_current_tti(); tti = mac.get_current_tti();
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, sib_start_tti(tti, 2, 5)); mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, sib_start_tti(tti, 2, 5));
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_LEN, 1); mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_LEN, 1);
} else { } else if (!my_rlc.sib2_decoded) {
usleep(10000);
tti = mac.get_current_tti(); tti = mac.get_current_tti();
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, sib_start_tti(tti, my_rlc.sib2_period, 0)); mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_ST, sib_start_tti(tti, my_rlc.sib2_period, 0));
mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_LEN, my_rlc.si_window_len); mac.set_param(srslte::ue::mac_interface_params::BCCH_SI_WINDOW_LEN, my_rlc.si_window_len);
} }
} }
usleep(10000); usleep(50000);
} }
} }

@ -134,7 +134,9 @@ void phch_common::set_dl_rnti(srslte_rnti_type_t type, uint16_t rnti_value, int
dl_rnti_type = type; dl_rnti_type = type;
dl_rnti_start = tti_start; dl_rnti_start = tti_start;
dl_rnti_end = tti_end; dl_rnti_end = tti_end;
if (rnti_value) {
Debug("Set DL rnti: start=%d, end=%d, value=0x%x\n", tti_start, tti_end, rnti_value); Debug("Set DL rnti: start=%d, end=%d, value=0x%x\n", tti_start, tti_end, rnti_value);
}
} }
void phch_common::reset_pending_ack(uint32_t tti) { void phch_common::reset_pending_ack(uint32_t tti) {

@ -123,6 +123,7 @@ void phch_recv::free_cell()
bool phch_recv::cell_search(int force_N_id_2) bool phch_recv::cell_search(int force_N_id_2)
{ {
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
uint8_t bch_payload_bits[SRSLTE_BCH_PAYLOAD_LEN/8];
srslte_ue_cellsearch_result_t found_cells[3]; srslte_ue_cellsearch_result_t found_cells[3];
srslte_ue_cellsearch_t cs; srslte_ue_cellsearch_t cs;
@ -201,7 +202,9 @@ bool phch_recv::cell_search(int force_N_id_2)
if (ret == 1) { if (ret == 1) {
srslte_pbch_mib_unpack(bch_payload, &cell, NULL); srslte_pbch_mib_unpack(bch_payload, &cell, NULL);
srslte_cell_fprint(stdout, &cell, 0); srslte_cell_fprint(stdout, &cell, 0);
mac->bch_decoded_ok(bch_payload, SRSLTE_BCH_PAYLOAD_LEN); //FIXME: this is temporal
srslte_bit_unpack_vector(bch_payload, bch_payload_bits, SRSLTE_BCH_PAYLOAD_LEN);
mac->bch_decoded_ok(bch_payload_bits, SRSLTE_BCH_PAYLOAD_LEN/8);
return true; return true;
} else { } else {
Warning("Error decoding MIB: Error decoding PBCH\n"); Warning("Error decoding MIB: Error decoding PBCH\n");

@ -131,6 +131,7 @@ void phch_worker::work_imp()
reset_uci(); reset_uci();
bool ul_grant_available = false; bool ul_grant_available = false;
bool dl_ack = false;
mac_interface_phy::mac_grant_t dl_mac_grant; mac_interface_phy::mac_grant_t dl_mac_grant;
mac_interface_phy::tb_action_dl_t dl_action; mac_interface_phy::tb_action_dl_t dl_action;
@ -153,10 +154,9 @@ void phch_worker::work_imp()
phy->mac->new_grant_dl(dl_mac_grant, &dl_action); phy->mac->new_grant_dl(dl_mac_grant, &dl_action);
/* Decode PDSCH if instructed to do so */ /* Decode PDSCH if instructed to do so */
bool dl_ack = dl_action.default_ack; dl_ack = dl_action.default_ack;
if (dl_action.decode_enabled) { if (dl_action.decode_enabled) {
dl_ack = decode_pdsch(&dl_action.phy_grant.dl, dl_action.payload_ptr, dl_action.softbuffer, dl_action.rv, dl_action.rnti); dl_ack = decode_pdsch(&dl_action.phy_grant.dl, dl_action.payload_ptr, dl_action.softbuffer, dl_action.rv, dl_action.rnti);
phy->mac->tb_decoded_ok(dl_mac_grant.pid);
} }
if (dl_action.generate_ack_callback) { if (dl_action.generate_ack_callback) {
dl_action.generate_ack = dl_action.generate_ack_callback(dl_action.generate_ack_callback_arg); dl_action.generate_ack = dl_action.generate_ack_callback(dl_action.generate_ack_callback_arg);
@ -213,6 +213,9 @@ void phch_worker::work_imp()
phy->worker_end(tti, tx_signal, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb), tx_time); phy->worker_end(tti, tx_signal, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb), tx_time);
if (dl_action.decode_enabled) {
phy->mac->tb_decoded(dl_ack, dl_mac_grant.rnti_type, dl_mac_grant.pid);
}
} }
@ -280,6 +283,7 @@ bool phch_worker::decode_pdcch_dl(srslte::ue::mac_interface_phy::mac_grant_t* gr
grant->tti = tti; grant->tti = tti;
grant->rv = dci_unpacked.rv_idx; grant->rv = dci_unpacked.rv_idx;
grant->rnti = dl_rnti; grant->rnti = dl_rnti;
grant->rnti_type = type;
last_dl_pdcch_ncce = srslte_ue_dl_get_ncce(&ue_dl); last_dl_pdcch_ncce = srslte_ue_dl_get_ncce(&ue_dl);
@ -359,6 +363,7 @@ bool phch_worker::decode_pdcch_ul(mac_interface_phy::mac_grant_t* grant)
Error("Converting RAR message to UL grant\n"); Error("Converting RAR message to UL grant\n");
return false; return false;
} }
grant->rnti_type = SRSLTE_RNTI_TEMP;
grant->is_from_rar = true; grant->is_from_rar = true;
Info("RAR grant found for TTI=%d\n", tti); Info("RAR grant found for TTI=%d\n", tti);
rar_cqi_request = rar_grant.cqi_request; rar_cqi_request = rar_grant.cqi_request;
@ -378,6 +383,7 @@ bool phch_worker::decode_pdcch_ul(mac_interface_phy::mac_grant_t* grant)
Error("Converting DCI message to UL grant\n"); Error("Converting DCI message to UL grant\n");
return false; return false;
} }
grant->rnti_type = type;
grant->is_from_rar = false; grant->is_from_rar = false;
ret = true; ret = true;
Info("PDCCH: UL DCI Format0 cce_index=%d, n_data_bits=%d\n", ue_dl.last_n_cce, dci_msg.nof_bits); Info("PDCCH: UL DCI Format0 cce_index=%d, n_data_bits=%d\n", ue_dl.last_n_cce, dci_msg.nof_bits);

@ -279,8 +279,9 @@ public:
} }
} }
void tb_decoded_ok(uint32_t harq_pid) { void tb_decoded(bool ack, srslte_rnti_type_t rnti_type, uint32_t harq_pid) {
if (last_grant.rnti == 2) { if (ack) {
if (rnti_type == SRSLTE_RNTI_RAR) {
my_phy.pdcch_dl_search_reset(); my_phy.pdcch_dl_search_reset();
srslte_bit_pack_vector(payload, payload_bits, last_grant.n_bytes*8); srslte_bit_pack_vector(payload, payload_bits, last_grant.n_bytes*8);
rar_unpack(payload_bits, &rar_msg); rar_unpack(payload_bits, &rar_msg);
@ -304,6 +305,7 @@ public:
my_phy.pdcch_dl_search_reset(); my_phy.pdcch_dl_search_reset();
} }
} }
}
void bch_decoded_ok(uint8_t *payload, uint32_t len) { void bch_decoded_ok(uint8_t *payload, uint32_t len) {
printf("BCH decoded\n"); printf("BCH decoded\n");
@ -336,7 +338,7 @@ int main(int argc, char *argv[])
my_phy.init(&radio_uhd, &my_mac, &log); my_phy.init(&radio_uhd, &my_mac, &log);
} else { } else {
radio_uhd.init_agc(); radio_uhd.init_agc();
radio_uhd.set_tx_rx_gain_offset(0); radio_uhd.set_tx_rx_gain_offset(10);
my_phy.init_agc(&radio_uhd, &my_mac, &log); my_phy.init_agc(&radio_uhd, &my_mac, &log);
} }

@ -123,9 +123,11 @@ public:
} }
} }
void tb_decoded_ok(uint32_t harq_pid) { void tb_decoded(bool ack, srslte_rnti_type_t rnti, uint32_t harq_pid) {
if (ack) {
total_oks++; total_oks++;
} }
}
void bch_decoded_ok(uint8_t *payload, uint32_t len) { void bch_decoded_ok(uint8_t *payload, uint32_t len) {
printf("BCH decoded\n"); printf("BCH decoded\n");

Loading…
Cancel
Save