Integration with higher layers failing NAS integration

master
ismagom 9 years ago
parent 7e94f82ab6
commit aa47a524b4

@ -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 segment_idx) = 0;
virtual uint32_t 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

@ -52,9 +52,11 @@ public:
void process_pdus();
uint8_t* request_buffer(uint32_t len);
void release_pdu(uint8_t *buff, uint32_t nof_bytes);
void release_pdu_bcch(uint8_t *buff, uint32_t nof_bytes);
void release_pdu_temp_crnti(uint8_t *buff, uint32_t nof_bytes);
void push_pdu(uint8_t *buff, uint32_t nof_bytes);
void push_pdu_bcch(uint8_t *buff, uint32_t nof_bytes);
void push_pdu_temp_crnti(uint8_t *buff, uint32_t nof_bytes);
void release_buffer(uint8_t *ptr);
void set_uecrid_callback(bool (*callback)(void*, uint64_t), void *arg);
bool get_uecrid_successful();
@ -84,8 +86,6 @@ private:
} buff_header_t;
// Mutex for exclusive access
pthread_mutex_t mutex;
pthread_cond_t cvar;
qbuff pdu_q[NOF_PDU_Q];
bool used_q[NOF_PDU_Q];

@ -230,8 +230,8 @@ public:
// Writing functions
void write_subheader(uint8_t** ptr, bool is_last);
void write_payload(uint8_t **ptr);
bool set_sdu(uint32_t lcid, uint32_t requested_bytes, rlc_interface_mac *rlc);
bool set_sdu(uint32_t lcid, uint32_t requested_bytes, rlc_interface_mac *rlc, bool is_first);
int set_sdu(uint32_t lcid, uint32_t requested_bytes, rlc_interface_mac *rlc);
int set_sdu(uint32_t lcid, uint32_t requested_bytes, rlc_interface_mac *rlc, bool is_first);
bool set_c_rnti(uint16_t crnti);
bool set_bsr(uint32_t buff_size[4], sch_subh::cetype format, bool update_size);
bool set_con_res_id(uint64_t con_res_id);

@ -72,6 +72,8 @@ public:
private:
const static int QUEUE_STATUS_PERIOD_MS = 500;
bool reset_sr;
mac_params *params_db;
timers *timers_db;

@ -166,6 +166,7 @@ private:
} start_mode;
uint32_t rar_grant_nbytes;
uint32_t rar_grant_tti;
bool msg3_flushed;
};
}
}

@ -38,9 +38,6 @@ demux::demux() : mac_msg(20), pending_mac_msg(20)
pdu_q[i].init(8, MAX_PDU_LEN);
used_q[i] = false;
}
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL);
}
void demux::init(phy_interface* phy_h_, rlc_interface_mac *rlc_, log* log_h_, timers* timers_db_)
@ -94,36 +91,32 @@ uint8_t* demux::request_buffer(uint32_t len)
if (len >= MAX_PDU_LEN - sizeof(buff_header_t)) {
return NULL;
}
pthread_mutex_lock(&mutex);
uint8_t idx=0;
while(!find_unused_queue(&idx)) {
pthread_cond_wait(&cvar, &mutex);
}
if (idx > 0) {
printf("Using queue %d for MAC PDU\n", idx);
if(find_unused_queue(&idx)) {
if (idx > 0) {
printf("Using queue %d for MAC PDU\n", idx);
}
used_q[idx] = true;
uint8_t *buff = (uint8_t*) pdu_q[idx].request();
buff_header_t *head = (buff_header_t*) buff;
head->idx = idx;
return &buff[sizeof(buff_header_t)];
} else {
Error("All DL buffers are full. Packet will be lost\n");
return NULL;
}
used_q[idx] = true;
uint8_t *buff = (uint8_t*) pdu_q[idx].request();
buff_header_t *head = (buff_header_t*) buff;
head->idx = idx;
pthread_mutex_unlock(&mutex);
return &buff[sizeof(buff_header_t)];
}
void demux::push_buffer(uint8_t *buff, uint32_t nof_bytes) {
buff_header_t *head = (buff_header_t*) (buff-sizeof(buff_header_t));
if (head->idx < NOF_PDU_Q) {
pthread_mutex_lock(&mutex);
if (nof_bytes > 0) {
if (!pdu_q[head->idx].push(nof_bytes)) {
Warning("Full queue %d when pushing MAC PDU %d bytes\n", head->idx, nof_bytes);
}
}
used_q[head->idx] = false;
pthread_cond_signal(&cvar);
pthread_mutex_unlock(&mutex);
}
}
@ -132,7 +125,7 @@ void demux::push_buffer(uint8_t *buff, uint32_t nof_bytes) {
* Warning: this function sends the message to RLC now, since SI blocks do not
* require ACK feedback to be transmitted quickly.
*/
void demux::release_pdu_bcch(uint8_t *buff, uint32_t nof_bytes)
void demux::push_pdu_bcch(uint8_t *buff, uint32_t nof_bytes)
{
Debug("Pushed BCCH MAC PDU in transparent mode\n");
rlc->write_pdu_bcch_dlsch(buff, nof_bytes);
@ -148,7 +141,7 @@ void demux::release_pdu_bcch(uint8_t *buff, uint32_t nof_bytes)
* Warning: this function does some processing here assuming ACK deadline is not an
* issue here because Temp C-RNTI messages have small payloads
*/
void demux::release_pdu_temp_crnti(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);
@ -171,11 +164,22 @@ void demux::release_pdu_temp_crnti(uint8_t *buff, uint32_t nof_bytes)
* This function enqueues the packet and returns quicly because ACK
* deadline is important here.
*/
void demux::release_pdu(uint8_t *buff, uint32_t nof_bytes)
void demux::push_pdu(uint8_t *buff, uint32_t nof_bytes)
{
push_buffer(buff, nof_bytes);
}
void demux::release_buffer(uint8_t* ptr)
{
uint8_t *addr = ptr - sizeof(buff_header_t);
for (int i=0;i<NOF_PDU_Q;i++) {
if (pdu_q[i].request() == addr) {
used_q[i] = false;
break;
}
}
}
void demux::process_pdus()
{
uint32_t len;
@ -204,6 +208,7 @@ void demux::process_sch_pdu(sch_pdu *pdu_msg)
while(pdu_msg->next()) {
if (pdu_msg->get()->is_sdu()) {
// Route logical channel
Info("Delivering PDU for lcid=%d, %d bytes\n", pdu_msg->get()->get_sdu_lcid(), pdu_msg->get()->get_sdu_nbytes());
rlc->write_pdu(pdu_msg->get()->get_sdu_lcid(), pdu_msg->get()->get_sdu_ptr(), pdu_msg->get()->get_sdu_nbytes());
} else {
// Process MAC Control Element

@ -230,15 +230,12 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy::mac_grant_
bzero(action, sizeof(mac_interface_phy::tb_action_dl_t));
action->default_ack = ack;
action->generate_ack = true;
action->decode_enabled = false;
// If data has not yet been successfully decoded
if (ack == false) {
// Instruct the PHY To combine the received data and attempt to decode it
action->decode_enabled = true;
action->rv = cur_grant.rv;
action->rnti = cur_grant.rnti;
action->softbuffer = &softbuffer;
payload_buffer_ptr = harq_entity->demux_unit->request_buffer(cur_grant.n_bytes);
action->payload_ptr = payload_buffer_ptr;
if (!action->payload_ptr) {
@ -246,10 +243,13 @@ 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);
return;
}
action->decode_enabled = true;
action->rv = cur_grant.rv;
action->rnti = cur_grant.rnti;
action->softbuffer = &softbuffer;
memcpy(&action->phy_grant, &cur_grant.phy_grant, sizeof(srslte_phy_grant_t));
} else {
action->decode_enabled = false;
Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n", pid);
}
@ -279,7 +279,7 @@ void dl_harq_entity::dl_harq_process::tb_decoded(bool ack_)
}
if (ack) {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (BCCH)\n", cur_grant.n_bytes);
harq_entity->demux_unit->release_pdu_bcch(payload_buffer_ptr, cur_grant.n_bytes);
harq_entity->demux_unit->push_pdu_bcch(payload_buffer_ptr, cur_grant.n_bytes);
}
} else {
@ -289,13 +289,15 @@ void dl_harq_entity::dl_harq_process::tb_decoded(bool ack_)
if (ack) {
if (cur_grant.rnti_type == SRSLTE_RNTI_TEMP) {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI)\n", cur_grant.n_bytes);
harq_entity->demux_unit->release_pdu_temp_crnti(payload_buffer_ptr, cur_grant.n_bytes);
harq_entity->demux_unit->push_pdu_temp_crnti(payload_buffer_ptr, cur_grant.n_bytes);
} else {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit\n", cur_grant.n_bytes);
harq_entity->demux_unit->release_pdu(payload_buffer_ptr, cur_grant.n_bytes);
harq_entity->demux_unit->push_pdu(payload_buffer_ptr, cur_grant.n_bytes);
}
}
}
} else {
harq_entity->demux_unit->release_buffer(payload_buffer_ptr);
}
Info("DL PID %d: TBS=%d, RV=%d, ACK=%s\n", pid, cur_grant.n_bytes, cur_grant.rv, ack?"OK":"KO");
}

@ -250,9 +250,7 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
int sdu_len = rlc->get_buffer_state(lcid);
if (sdu_len > 0) { // there is pending SDU to allocate
Info("%d bytes pending on RLC buffer. Maximum rate=%d, available space=%d\n",
sdu_len, max_sdu_sz, pdu_msg->rem_size() - 2);
int buffer_state = sdu_len;
if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) {
sdu_len = max_sdu_sz;
}
@ -262,7 +260,8 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
if (sdu_len > MIN_RLC_SDU_LEN) {
if (pdu_msg->new_subh()) { // there is space for a new subheader
pdu_msg->next();
if (pdu_msg->get()->set_sdu(lcid, sdu_len, rlc, is_first?*is_first:false)) { // new SDU could be added
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) {
*is_first = false;
}
@ -270,10 +269,10 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
*sdu_sz = sdu_len;
}
Info("Allocated SDU lcid=%d nbytes=%d\n", lcid, sdu_len);
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(), sdu_len);
Info("Could not add SDU rem_size=%d, sdu_len=%d\n", pdu_msg->rem_size(), buffer_state);
pdu_msg->del_subh();
}
}
@ -284,6 +283,7 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
void mux::msg3_flush()
{
Info("Msg3 buffer flushed\n");
msg3_buff.flush();
msg3_has_been_transmitted = false;
}
@ -315,17 +315,21 @@ bool mux::pdu_move_to_msg3(uint32_t pdu_sz)
/* Returns a pointer to the Msg3 buffer */
uint8_t* mux::msg3_get(uint8_t *payload, uint32_t pdu_sz)
{
if (pdu_move_to_msg3(pdu_sz)) {
uint8_t *msg3 = (uint8_t*) msg3_buff.pop();
if (msg3) {
memcpy(payload, msg3, sizeof(uint8_t)*pdu_sz);
msg3_buff.release();
msg3_has_been_transmitted = true;
return payload;
} else {
Error("Generating Msg3\n");
if (msg3_buff.isempty()) {
Info("Moving PDU from Mux unit to Msg3 buffer\n");
if (!pdu_move_to_msg3(pdu_sz)) {
Error("Moving PDU from Mux unit to Msg3 buffer\n");
return NULL;
}
}
uint8_t *msg3 = (uint8_t*) msg3_buff.pop();
if (msg3) {
memcpy(payload, msg3, sizeof(uint8_t)*pdu_sz);
msg3_has_been_transmitted = true;
return payload;
} else {
Error("Generating Msg3\n");
}
return NULL;
}

@ -452,12 +452,12 @@ bool sch_subh::set_ta_cmd(uint8_t ta_cmd)
}
}
bool sch_subh::set_sdu(uint32_t lcid_, uint32_t nof_bytes_, rlc_interface_mac *rlc)
int sch_subh::set_sdu(uint32_t lcid_, uint32_t nof_bytes_, rlc_interface_mac *rlc)
{
return set_sdu(lcid_, nof_bytes_, rlc, false);
}
bool sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, rlc_interface_mac *rlc, bool is_first)
int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, rlc_interface_mac *rlc, bool is_first)
{
if (((sch_pdu*)parent)->has_space_sdu(requested_bytes, is_first)) {
lcid = lcid_;
@ -472,9 +472,9 @@ bool sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, rlc_interface_m
((sch_pdu*)parent)->add_sdu(nof_bytes);
((sch_pdu*)parent)->update_space_sdu(sdu_sz, is_first);
return true;
return (int) nof_bytes;
} else {
return false;
return -1;
}
}
// Section 6.2.1

@ -218,7 +218,7 @@ void bsr_proc::step(uint32_t tti)
update_pending_data();
if ((tti - last_print)%10240 > 40) {
if ((tti - last_print)%10240 > QUEUE_STATUS_PERIOD_MS) {
char str[128];
bzero(str, 128);
for (int i=0;i<MAX_LCID;i++) {

@ -172,6 +172,7 @@ void ra_proc::step_initialization() {
preambleTransmissionCounter = 1;
first_rar_received = true;
mux_unit->msg3_flush();
msg3_flushed = false;
backoff_param_ms = 0;
// Instruct phy to configure PRACH
@ -343,7 +344,6 @@ void ra_proc::step_response_error() {
} else {
rInfo("Transmitting inmediatly (%d/%d)\n", preambleTransmissionCounter, preambleTransMax);
state = RESOURCE_SELECTION;
exit(-1);
}
}
}
@ -424,7 +424,10 @@ void ra_proc::step_contention_resolution() {
void ra_proc::step_completition() {
params_db->set_param(mac_interface_params::RA_PREAMBLEINDEX, 0);
params_db->set_param(mac_interface_params::RA_MASKINDEX, 0);
mux_unit->msg3_flush();
if (!msg3_flushed) {
mux_unit->msg3_flush();
msg3_flushed = true;
}
msg3_transmitted = false;
}

@ -215,6 +215,7 @@ void ul_harq_entity::ul_harq_process::run_tti(uint32_t tti_tx, mac_interface_phy
// Uplink grant in a RAR
if (grant->is_from_rar) {
Info("Getting Msg3 buffer payload, grant size=%d bytes\n", grant->n_bytes);
pdu_ptr = harq_entity->mux_unit->msg3_get(payload_buffer, grant->n_bytes);
if (pdu_ptr) {
generate_new_tx(tti_tx, true, grant, action);

@ -55,6 +55,9 @@ void phch_common::init(phy_params *_params, log *_log, radio *_radio, mac_interf
mac = _mac;
is_first_tx = true;
sr_last_tx_tti = -1;
pthread_mutex_init(&tx_mutex, NULL);
pthread_cond_init(&tx_cvar, NULL);
}
bool phch_common::ul_rnti_active(uint32_t tti) {
@ -172,6 +175,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable,
cf_t *buffer, uint32_t nof_samples,
srslte_timestamp_t tx_time)
{
pthread_mutex_lock(&tx_mutex);
// Wait previous TTIs to be transmitted

@ -297,10 +297,12 @@ void phch_recv::run_thread()
worker->set_cfo(cfo);
/* Compute TX time: Any transmission happens in TTI+4 thus advance 4 ms the reception time */
srslte_timestamp_t rx_time, tx_time;
srslte_timestamp_t rx_time, tx_time, tx_time_prach;
srslte_ue_sync_get_last_timestamp(&ue_sync, &rx_time);
srslte_timestamp_copy(&tx_time, &rx_time);
srslte_timestamp_copy(&tx_time_prach, &rx_time);
srslte_timestamp_add(&tx_time, 0, 4e-3 - time_adv_sec);
srslte_timestamp_add(&tx_time_prach, 0, 4e-3);
worker->set_tx_time(tx_time);
worker->set_tti(tti);
@ -311,7 +313,7 @@ void phch_recv::run_thread()
Info("TX PRACH now. RX time: %d:%f, Now: %d:%f\n", rx_time.full_secs, rx_time.frac_secs,
cur_time.full_secs, cur_time.frac_secs);
// send prach if we have to
prach_buffer->send(radio_h, cfo, tx_time);
prach_buffer->send(radio_h, cfo, tx_time_prach);
radio_h->tx_end();
}
workers_pool->start_worker(worker);

@ -134,7 +134,6 @@ void phch_worker::work_imp()
mac_interface_phy::tb_action_ul_t ul_action;
bzero(&ul_action, sizeof(mac_interface_phy::tb_action_ul_t));
/* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */
if (extract_fft_and_pdcch_llr()) {
@ -153,8 +152,8 @@ void phch_worker::work_imp()
}
if (dl_action.generate_ack_callback && dl_action.decode_enabled) {
phy->mac->tb_decoded(dl_ack, dl_mac_grant.rnti_type, dl_mac_grant.pid);
dl_action.generate_ack = dl_action.generate_ack_callback(dl_action.generate_ack_callback_arg);
Info("Calling generate ACK callback returned=%d\n", dl_action.generate_ack);
dl_ack = dl_action.generate_ack_callback(dl_action.generate_ack_callback_arg);
Info("Calling generate ACK callback returned=%d\n", dl_ack);
}
if (dl_action.generate_ack) {
set_uci_ack(dl_ack);
@ -482,7 +481,7 @@ void phch_worker::encode_pusch(srslte_ra_ul_grant_t *grant, uint8_t *payload, ui
void phch_worker::encode_pucch()
{
if (uci_data.scheduling_request || uci_data.uci_cqi_len > 0 || uci_data.uci_ack_len > 0)
if (uci_data.scheduling_request || uci_data.uci_ack_len > 0)
{
if (srslte_ue_ul_pucch_encode(&ue_ul, uci_data, last_dl_pdcch_ncce, tti+4, signal_buffer)) {
Error("Encoding PUCCH\n");

@ -66,6 +66,11 @@ bool prach::init_cell(srslte_cell_t cell_)
cell = cell_;
preamble_idx = -1;
Info("ConfigIdx=%d, RootSeq=%d, ZC=%d\n",
params_db->get_param(phy_interface_params::PRACH_CONFIG_INDEX),
params_db->get_param(phy_interface_params::PRACH_ROOT_SEQ_IDX),
params_db->get_param(phy_interface_params::PRACH_ZC_CONFIG));
if (srslte_prach_init(&prach_obj, srslte_symbol_sz(cell.nof_prb),
srslte_prach_get_preamble_format(params_db->get_param(phy_interface_params::PRACH_CONFIG_INDEX)),
params_db->get_param(phy_interface_params::PRACH_ROOT_SEQ_IDX),

@ -189,7 +189,6 @@ void config_phy() {
my_phy.set_param(srslte::ue::phy_interface_params::PUCCH_N_PUCCH_1, 1);
my_phy.set_param(srslte::ue::phy_interface_params::PUCCH_N_RB_2, 2);
my_phy.configure_prach_params();
my_phy.configure_ul_params();
}

@ -278,7 +278,8 @@ int srslte_ue_ul_pucch_encode(srslte_ue_ul_t *q, srslte_uci_data_t uci_data,
pucch2_bits[0] = uci_data.uci_ack;
pucch2_bits[1] = uci_data.uci_ack_2;
} else {
fprintf(stderr, "Unsupported combination of UCI parameters\n");
fprintf(stderr, "Unsupported combination of UCI parameters: ack_len=%d, cqi_len=%d\n",
uci_data.uci_ack, uci_data.uci_cqi_len);
return SRSLTE_ERROR;
}

Loading…
Cancel
Save