UL/DL iperf working with 1 thread

This commit is contained in:
ismagom 2015-08-09 00:23:02 +02:00
parent 099b0eb1ea
commit 0385a10656
13 changed files with 51 additions and 38 deletions

View File

@ -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 nof_bytes) = 0;
virtual int 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

View File

@ -158,8 +158,9 @@ bool qbuff::send(void* buffer, uint32_t msg_size)
void *ptr = request();
if (ptr) {
memcpy(ptr, buffer, msg_size);
push(msg_size);
return push(msg_size);
} else {
printf("No ptr\n");
return false;
}
} else {

View File

@ -81,7 +81,7 @@ namespace srslte {
void *uhd;
static const double lo_offset = 8e6; // LO offset (in Hz)
static const double burst_settle_time = 0.35e-3; // Start of burst settle time (off->on RF transition time)
static const double burst_settle_time = 0.4e-3; // Start of burst settle time (off->on RF transition time)
const static uint32_t burst_settle_max_samples = 30720000; // 30.72 MHz is maximum frequency
srslte_timestamp_t end_of_burst_time;

View File

@ -72,9 +72,8 @@ public:
rem_len = pdu_len;
}
void init_rx(uint8_t *payload, uint32_t pdu_len_bytes, bool is_ulsch = false) {
void init_rx(uint32_t pdu_len_bytes, bool is_ulsch = false) {
init_(NULL, pdu_len_bytes, is_ulsch);
parse_packet(payload);
}
void init_tx(uint8_t *payload, uint32_t pdu_len_bytes, bool is_ulsch = false) {
@ -130,18 +129,6 @@ public:
total_sdu_len += sdu_sz;
}
protected:
std::vector<SubH> subheaders;
uint32_t pdu_len;
uint32_t rem_len;
int cur_idx;
int nof_subheaders;
uint32_t max_subheaders;
bool pdu_is_ul;
uint8_t* buffer_tx;
uint32_t total_sdu_len;
uint32_t sdu_offset_start;
// Section 6.1.2
void parse_packet(uint8_t *ptr) {
uint8_t *init_ptr = ptr;
@ -154,6 +141,18 @@ protected:
subheaders[i].read_payload(&ptr);
}
}
protected:
std::vector<SubH> subheaders;
uint32_t pdu_len;
uint32_t rem_len;
int cur_idx;
int nof_subheaders;
uint32_t max_subheaders;
bool pdu_is_ul;
uint8_t* buffer_tx;
uint32_t total_sdu_len;
uint32_t sdu_offset_start;
private:

View File

@ -144,7 +144,8 @@ void demux::push_pdu_bcch(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);
pending_mac_msg.init_rx(nof_bytes);
pending_mac_msg.parse_packet(buff);
// Look for Contention Resolution UE ID
is_uecrid_successful = false;
@ -197,9 +198,11 @@ void demux::process_pdus()
void demux::process_pdu(uint8_t *mac_pdu, uint32_t nof_bytes)
{
// Unpack DLSCH MAC PDU
mac_msg.init_rx(mac_pdu, nof_bytes);
//mac_msg.fprint(stdout);
mac_msg.init_rx(nof_bytes);
mac_msg.parse_packet(mac_pdu);
process_sch_pdu(&mac_msg);
//srslte_vec_fprint_byte(stdout, mac_pdu, nof_bytes);
Debug("MAC PDU processed\n");
}

View File

@ -185,7 +185,6 @@ void mac::run_thread() {
Info("Pre-generating UL signals and C-RNTI scrambling sequences\n");
((phy*) phy_h)->enable_pregen_signals(true);
((phy*) phy_h)->set_crnti(crnti);
phy_h->configure_ul_params();
Info("Done\n");
signals_pregenerated = true;
}

View File

@ -254,12 +254,13 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
if (sdu_len > max_sdu_sz && max_sdu_sz >= 0) {
sdu_len = max_sdu_sz;
}
if (sdu_len > pdu_msg->rem_size() - 2) {
sdu_len = pdu_msg->rem_size() - 2;
if (sdu_len > pdu_msg->rem_size() - 3) {
sdu_len = pdu_msg->rem_size() - 3;
}
if (sdu_len > MIN_RLC_SDU_LEN) {
if (pdu_msg->new_subh()) { // there is space for a new subheader
pdu_msg->next();
int sdu_len2 = sdu_len;
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) {
@ -272,7 +273,7 @@ bool mux::allocate_sdu(uint32_t lcid, sch_pdu *pdu_msg, int max_sdu_sz, uint32_t
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(), buffer_state);
Info("Could not add SDU rem_size=%d, sdu_len=%d\n", pdu_msg->rem_size(), sdu_len2);
pdu_msg->del_subh();
}
}

View File

@ -87,14 +87,16 @@ void sch_subh::fprint(FILE* stream)
void sch_pdu::parse_packet(uint8_t *ptr)
{
pdu::parse_packet(ptr);
// Correct size for last SDU
if (nof_subheaders > 0) {
uint32_t read_len = 0;
for (int i=0;i<nof_subheaders-1;i++) {
read_len += subheaders[i].size_plus_header();
}
if (pdu_len-read_len-1 >= 0) {
subheaders[nof_subheaders-1].set_payload_size(pdu_len-read_len-1);
} else {
@ -467,7 +469,11 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, rlc_interface_ma
payload = ((sch_pdu*)parent)->get_current_sdu_ptr();
// Copy data and get final number of bytes written to the MAC PDU
uint32_t sdu_sz = rlc->read_pdu(lcid, payload, requested_bytes);
int sdu_sz = rlc->read_pdu(lcid, payload, requested_bytes);
if (sdu_sz < 0) {
return -1;
}
// Save final number of written bytes
nof_bytes = sdu_sz;

View File

@ -261,8 +261,8 @@ void ra_proc::tb_decoded_ok() {
rDebug("RAR decoded successfully TBS=%d\n", rar_grant_nbytes);
rar_pdu_msg.init_rx(rar_pdu_buffer, rar_grant_nbytes);
rar_pdu_msg.init_rx(rar_grant_nbytes);
rar_pdu_msg.parse_packet(rar_pdu_buffer);
// Set Backoff parameter
if (rar_pdu_msg.has_backoff()) {
backoff_param_ms = backoff_table[rar_pdu_msg.get_backoff()%16];

View File

@ -377,7 +377,7 @@ public:
return 0;
}
uint32_t read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes)
int read_pdu(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes)
{
if (lcid == 0) {
LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;

View File

@ -176,7 +176,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable,
srslte_timestamp_t tx_time)
{
pthread_mutex_lock(&tx_mutex);
/* pthread_mutex_lock(&tx_mutex);
// Wait previous TTIs to be transmitted
if (is_first_tx) {
@ -187,6 +187,7 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable,
pthread_cond_wait(&tx_cvar, &tx_mutex);
}
}
*/
if (tx_enable) {
radio_h->tx(buffer, nof_samples, tx_time);
is_first_of_burst = false;
@ -197,8 +198,8 @@ void phch_common::worker_end(uint32_t tti, bool tx_enable,
tx_tti_cnt = (tx_tti_cnt + 1) % 10240;
pthread_cond_signal(&tx_cvar);
pthread_mutex_unlock(&tx_mutex);
//pthread_cond_signal(&tx_cvar);
//pthread_mutex_unlock(&tx_mutex);
}
}

View File

@ -192,7 +192,8 @@ void phch_worker::work_imp()
/* Transmit PUSCH, PUCCH or SRS */
bool tx_signal = false;
if (ul_action.tx_enabled) {
encode_pusch(&ul_action.phy_grant.ul, ul_action.payload_ptr, ul_action.current_tx_nb, ul_action.softbuffer, ul_action.rv, ul_action.rnti);
encode_pusch(&ul_action.phy_grant.ul, ul_action.payload_ptr, ul_action.current_tx_nb,
ul_action.softbuffer, ul_action.rv, ul_action.rnti);
tx_signal = true;
if (ul_action.expect_ack) {
phy->set_pending_ack(tti + 8, ue_ul.pusch_cfg.grant.n_prb_tilde[0], ul_action.phy_grant.ul.ncs_dmrs);
@ -529,7 +530,7 @@ void phch_worker::reset_ul_params()
void phch_worker::set_ul_params()
{
/* PUSCH DMRS signal configuration */
bzero(&dmrs_cfg, sizeof(srslte_refsignal_dmrs_pusch_cfg_t));
dmrs_cfg.group_hopping_en = (bool) phy->params_db->get_param(phy_interface_params::DMRS_GROUP_HOPPING_EN);
@ -592,7 +593,8 @@ void phch_worker::set_ul_params()
/* SR configuration */
I_sr = (uint32_t) phy->params_db->get_param(phy_interface_params::SR_CONFIG_INDEX);
if (pregen_enabled) {
if (pregen_enabled) {
printf("Pre-generating UL signals\n");
srslte_ue_ul_pregen_signals(&ue_ul);
}

View File

@ -74,6 +74,7 @@ bool phy::init_(radio* radio_handler_, mac_interface_phy *mac, log *log_h_, bool
for (int i=0;i<NOF_WORKERS;i++) {
workers[i].set_common(&workers_common);
workers_pool.init_worker(i, &workers[i], WORKERS_THREAD_PRIO);
//printf("init worker here is at 0x%x\n", &workers[i]);
}
sf_recv.init(radio_handler, mac, &prach_buffer, &workers_pool, &workers_common, log_h, do_agc, SF_RECV_THREAD_PRIO);
@ -111,7 +112,7 @@ void phy::stop()
sf_recv.stop();
for (int i=0;i<NOF_WORKERS;i++) {
((phch_worker) workers[i]).free_cell();
workers[i].free_cell();
workers[i].stop();
}
@ -243,14 +244,14 @@ void phy::set_rar_grant(uint32_t tti, uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN
void phy::set_crnti(uint16_t rnti) {
for(uint32_t i=0;i<NOF_WORKERS;i++) {
((phch_worker) workers[i]).set_crnti(rnti);
workers[i].set_crnti(rnti);
}
}
void phy::enable_pregen_signals(bool enable)
{
for(uint32_t i=0;i<NOF_WORKERS;i++) {
((phch_worker) workers[i]).enable_pregen_signals(enable);
workers[i].enable_pregen_signals(enable);
}
}