Added Scheduling Request Procedure

This commit is contained in:
ismagom 2015-05-18 09:44:58 +02:00
parent 0b3c611f38
commit ae5316ae92
12 changed files with 243 additions and 28 deletions

View File

@ -33,6 +33,7 @@
#include "srsapps/common/timers.h"
#include "srsapps/ue/mac/mac_params.h"
#include "srsapps/ue/mac/pdu.h"
#include "srsapps/ue/mac/sdu_handler.h"
#ifndef DEMUX_H
#define DEMUX_H
@ -48,6 +49,8 @@ public:
demux();
void init(phy* phy_h_, log* log_h_, mac_io* mac_io_h_, timers* timers_db_);
void add_sdu_handler(sdu_handler *handler);
void push_pdu(uint8_t *mac_pdu, uint32_t nof_bits);
void push_pdu_bcch(uint8_t *mac_pdu, uint32_t nof_bits);
void push_pdu_temp_crnti(uint8_t *mac_pdu, uint32_t nof_bits);
@ -73,6 +76,7 @@ private:
log *log_h;
mac_io *mac_io_h;
timers *timers_db;
sdu_handler *sdu_handler_;
};
}
}

View File

@ -44,6 +44,7 @@
#include "srsapps/ue/mac/proc_phr.h"
#include "srsapps/ue/mac/mux.h"
#include "srsapps/ue/mac/demux.h"
#include "srsapps/ue/mac/sdu_handler.h"
#ifndef UEMAC_H
#define UEMAC_H
@ -62,10 +63,14 @@ public:
int get_tti();
void main_radio_loop(); // called after thread creation
void add_sdu_handler(sdu_handler *handler);
bool send_sdu(uint32_t lcid, uint8_t *sdu_payload, uint32_t nbytes);
bool send_ccch_sdu(uint8_t *sdu_payload, uint32_t nbytes);
bool send_dtch0_sdu(uint8_t *sdu_payload, uint32_t nbytes); // SRB0
bool send_dcch0_sdu(uint8_t *sdu_payload, uint32_t nbytes); // DRB0
int recv_sdu(uint32_t lcid, uint8_t *sdu_payload, uint32_t nbytes);
int recv_bcch_sdu(uint8_t *sdu_payload, uint32_t buffer_len_nbytes);
int recv_ccch_sdu(uint8_t *sdu_payload, uint32_t buffer_len_nbytes);
int recv_dtch0_sdu(uint8_t *sdu_payload, uint32_t buffer_len_nbytes); // SRB0
@ -129,7 +134,7 @@ private:
/* Other procedures */
void process_dl_grants(uint32_t tti);
void process_ul_grants(uint32_t tti);
bool process_ul_grants(uint32_t tti);
void receive_pch(uint32_t tti);
/* Functions for MAC Timers */

View File

@ -80,6 +80,7 @@ namespace ue {
RA_INITRECEIVEDPOWER,
RA_CONTENTIONTIMER,
SR_PUCCH_CONFIGURED,
SR_PUCCH_RESINDEX,
SR_CONFIG_INDEX,
SR_TRANS_MAX,

View File

@ -48,7 +48,8 @@ public:
void reset();
void init(log *log_h, mac_io *mac_io_h);
bool is_pending_sdu();
bool is_pending_ccch_sdu();
bool is_pending_any_sdu();
uint8_t* pdu_pop(uint32_t pdu_sz);
bool pdu_move_to_msg3(uint32_t pdu_sz);

View File

@ -30,11 +30,13 @@
#include <stdint.h>
#include "srsapps/ue/mac/proc.h"
#include "srsapps/ue/phy/phy.h"
#include "srsapps/ue/mac/mac_params.h"
#ifndef PROCSR_H
#define PROCSR_H
/* Scheduling Request procedure */
/* Scheduling Request procedure as defined in 5.4.4 of 36.321 */
namespace srslte {
namespace ue {
@ -42,15 +44,20 @@ namespace ue {
class sr_proc : public proc
{
public:
void step(uint32_t tti) {
if (is_running()) {
fprintf(stderr, "SR procedure not implemented\n");
}
}
void reset() {
}
sr_proc();
void init(log *log_h, mac_params *params_db, phy *phy_h);
void step(uint32_t tti);
void reset();
void start();
bool need_random_access();
private:
uint32_t sr_counter;
uint32_t dsr_transmax;
bool is_pending_sr;
mac_params *params_db;
phy *phy_h;
log *log_h;
bool initiated;
};
}
}

View File

@ -0,0 +1,39 @@
/**
*
* \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

View File

@ -37,6 +37,7 @@ demux::demux() : mac_msg(20),pending_mac_msg(20)
contention_resolution_id = 0;
pending_temp_rnti = false;
has_pending_contention_resolution_id = false;
sdu_handler_ = NULL;
}
void demux::init(phy* phy_h_, log* log_h_, mac_io* mac_io_h_, timers* timers_db_)
@ -47,6 +48,10 @@ void demux::init(phy* phy_h_, log* log_h_, mac_io* mac_io_h_, timers* timers_db_
timers_db = timers_db_;
}
void demux::add_sdu_handler(sdu_handler* handler)
{
sdu_handler_ = handler;
}
bool demux::is_temp_crnti_pending()
{
@ -158,6 +163,15 @@ void demux::process_pdu(sch_pdu *pdu_msg)
}
}
}
/* notify handler if registred */
if (sdu_handler_) {
pdu_msg->reset();
while(pdu_msg->next()) {
if (pdu_msg->get()->is_sdu()) {
sdu_handler_->notify_new_sdu(pdu_msg->get()->get_sdu_lcid());
}
}
}
}

View File

@ -50,7 +50,7 @@ bool mac::init(phy *phy_h_, tti_sync* ttisync_, log* log_h_)
mux_unit.init(log_h, &mac_io_lch);
demux_unit.init(phy_h, log_h, &mac_io_lch, &timers_db);
ra_procedure.init(&params_db, phy_h, log_h, &timers_db, &mux_unit, &demux_unit);
sr_procedure.init(log_h, &params_db, phy_h);
reset();
pthread_attr_t attr;
@ -168,16 +168,23 @@ void mac::main_radio_loop() {
}
if (is_synchronized) {
/* Warning: Here order of invocation of procedures is important!! */
bool ul_resources_available;
tti = ttisync->wait();
log_h->step(tti);
// Step all procedures
ra_procedure.step(tti);
sr_procedure.step(tti);
//sr_procedure.step(tti);
bsr_procedure.step(tti);
phr_procedure.step(tti);
// Check SR if we need to start RA
/*
if (sr_procedure.need_random_access()) {
ra_procedure.start_mac_order();
}
*/
// Receive PCH, if requested
receive_pch(tti);
@ -186,11 +193,11 @@ void mac::main_radio_loop() {
// Process UL grants if RA procedure is done and we have pending data or in contention resolution
if (ra_procedure.is_contention_resolution() ||
ra_procedure.is_successful() && mux_unit.is_pending_sdu())
ra_procedure.is_successful() && mux_unit.is_pending_ccch_sdu())
{
process_ul_grants(tti);
ul_resources_available = process_ul_grants(tti);
}
// Send pending HARQ ACK, if any, and contention resolution is resolved
if (dl_harq.is_ack_pending_resolution()) {
ra_procedure.step(tti);
@ -203,17 +210,27 @@ void mac::main_radio_loop() {
timers_db.step_all();
// Check if there is pending CCCH SDU in Multiplexing Unit
if (mux_unit.is_pending_sdu()) {
if (mux_unit.is_pending_ccch_sdu()) {
// Start RA procedure
if (!ra_procedure.in_progress() && !ra_procedure.is_successful()) {
Info("Starting RA procedure by RLC order\n");
ra_procedure.start_rlc_order();
}
}
} /*else if (mux_unit.is_pending_any_sdu()) {
// Sart SR if no PUSCH resources available for TTI+4
if (!ul_resources_available) {
sr_procedure.start();
Info("Starting Scheduling Request procedure\n");
}
}*/
}
}
}
void mac::add_sdu_handler(sdu_handler *handler) {
demux_unit.add_sdu_handler(handler);
}
void mac::setup_timers()
{
if (params_db.get_param(mac_params::TIMER_TIMEALIGN) > 0) {
@ -376,7 +393,7 @@ void mac::process_dl_grants(uint32_t tti) {
}
/* UL Grant reception and processin as defined in Section 5.4.1 in 36.321 */
void mac::process_ul_grants(uint32_t tti) {
bool mac::process_ul_grants(uint32_t tti) {
// Get DL buffer for this TTI to look for DCI grants
dl_buffer *dl_buffer = phy_h->get_dl_buffer(tti);
@ -399,7 +416,7 @@ void mac::process_ul_grants(uint32_t tti) {
}
Info("Found UL Grant TBS=%d RNTI=%d is_from_rar=%d\n", ul_grant.get_tbs(), params_db.get_param(i), ul_grant.is_from_rar());
ul_harq.run_tti(tti, &ul_grant, phy_h);
return;
return true;
}
else if (i == mac_params::RNTI_SPS) {
if (ul_grant.get_ndi()) {
@ -412,7 +429,7 @@ void mac::process_ul_grants(uint32_t tti) {
ul_sps_assig.reset(tti, &ul_grant);
ul_grant.set_ndi(true);
ul_harq.run_tti(tti, &ul_grant, phy_h);
return;
return true;
}
}
}
@ -424,13 +441,24 @@ void mac::process_ul_grants(uint32_t tti) {
if (sps_grant != NULL) {
sps_grant->set_ndi(true);
ul_harq.run_tti(tti, sps_grant, phy_h);
return;
return true;
}
}
ul_harq.run_tti(tti, phy_h);
return false;
}
int mac::recv_sdu(uint32_t lcid, uint8_t* sdu_payload, uint32_t nbytes)
{
if (lcid <= mac_io::MAC_LCH_PCCH_DL) {
return mac_io_lch.get(lcid)->recv(sdu_payload, nbytes);
} else {
Error("Receiving SDU: Invalid lcid=%d\n", lcid);
return -1;
}
}
int mac::recv_bcch_sdu(uint8_t* sdu_payload, uint32_t buffer_len_nbytes)
{
return mac_io_lch.get(mac_io::MAC_LCH_BCCH_DL)->recv(sdu_payload, buffer_len_nbytes);
@ -452,6 +480,17 @@ int mac::recv_dcch0_sdu(uint8_t* sdu_payload, uint32_t buffer_len_nbytes)
}
bool mac::send_sdu(uint32_t lcid, uint8_t* sdu_payload, uint32_t nbytes)
{
lcid += mac_io::MAC_LCH_CCCH_UL;
if (lcid <= mac_io::MAC_LCH_DTCH2_UL) {
return mac_io_lch.get(lcid)->send(sdu_payload, nbytes);
} else {
Error("Receiving SDU: Invalid lcid=%d\n", lcid);
return -1;
}
}
bool mac::send_ccch_sdu(uint8_t* sdu_payload, uint32_t nbytes)
{
return mac_io_lch.get(mac_io::MAC_LCH_CCCH_UL)->send(sdu_payload, nbytes);

View File

@ -65,7 +65,17 @@ void mux::reset()
}
}
bool mux::is_pending_sdu()
bool mux::is_pending_any_sdu()
{
for (int i=0;i<mac_io::NOF_UL_LCH;i++) {
if (!mac_io_h->get(i)->isempty()) {
return true;
}
}
return false;
}
bool mux::is_pending_ccch_sdu()
{
return !mac_io_h->get(mac_io::MAC_LCH_CCCH_UL)->isempty();
}

View File

@ -0,0 +1,91 @@
/**
*
* \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/.
*
*/
#include "srsapps/ue/mac/proc_sr.h"
#include "srsapps/ue/mac/mac_params.h"
namespace srslte {
namespace ue {
sr_proc::sr_proc() {
initiated = false;
}
void sr_proc::init(log* log_h_, mac_params* params_db_, phy* phy_h_)
{
log_h = log_h_;
params_db = params_db_;
phy_h = phy_h_;
initiated = true;
}
void sr_proc::reset()
{
is_pending_sr = false;
}
void sr_proc::step(uint32_t tti)
{
if (initiated) {
if (is_pending_sr) {
if (sr_counter < dsr_transmax) {
sr_counter++;
phy_h->get_ul_buffer(tti+4)->generate_sr();
} else {
reset();
}
}
}
}
bool sr_proc::need_random_access() {
if (initiated) {
if (sr_counter == dsr_transmax && dsr_transmax > 0 ||
!params_db->get_param(mac_params::SR_PUCCH_CONFIGURED)) {
return true;
} else {
return false;
}
}
}
void sr_proc::start()
{
if (initiated) {
if (params_db->get_param(mac_params::SR_PUCCH_CONFIGURED)) {
if (!is_pending_sr) {
sr_counter = 0;
dsr_transmax = params_db->get_param(mac_params::SR_TRANS_MAX);
}
}
}
}
}
}

View File

@ -201,9 +201,12 @@ void process_connsetup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *msg, srslte::ue::mac
mac->set_param(srslte::ue::mac_params::HARQ_MAXTX,
liblte_rrc_max_harq_tx_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.max_harq_tx]);
mac->set_param(srslte::ue::mac_params::SR_PUCCH_RESINDEX, msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx);
mac->set_param(srslte::ue::mac_params::SR_CONFIG_INDEX, msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx);
mac->set_param(srslte::ue::mac_params::SR_TRANS_MAX, liblte_rrc_dsr_trans_max_num[msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.dsr_trans_max]);
mac->set_param(srslte::ue::mac_params::SR_PUCCH_RESINDEX,
msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx);
mac->set_param(srslte::ue::mac_params::SR_CONFIG_INDEX,
msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx);
mac->set_param(srslte::ue::mac_params::SR_TRANS_MAX,
liblte_rrc_dsr_trans_max_num[msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.dsr_trans_max]);
phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_ACK, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ack_idx);
phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_CQI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_cqi_idx);

View File

@ -96,6 +96,7 @@ bool ul_buffer::generate_cqi_report()
bool ul_buffer::generate_sr() {
uci_data.scheduling_request = true;
uci_pending = true;
return true;
}
bool ul_buffer::uci_ready() {