mirror of https://github.com/pvnis/srsRAN_4G.git
Initial commit
parent
e7fc0f839c
commit
805ccc2414
@ -1,72 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#ifndef BINSEM_H
|
|
||||||
#define BINSEM_H
|
|
||||||
|
|
||||||
/** Implementation of a binary semaphore using POSIX condition variable and mutex
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
|
|
||||||
class binsem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
binsem() {
|
|
||||||
pthread_mutex_init(&mutex, NULL);
|
|
||||||
pthread_cond_init(&cv, NULL);
|
|
||||||
state = true;
|
|
||||||
}
|
|
||||||
~binsem() {
|
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
pthread_cond_destroy(&cv);
|
|
||||||
}
|
|
||||||
void take() {
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
while(!state) {
|
|
||||||
pthread_cond_wait(&cv, &mutex);
|
|
||||||
}
|
|
||||||
state = false;
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
}
|
|
||||||
void give() {
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
pthread_cond_signal(&cv);
|
|
||||||
state = true;
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
pthread_cond_t cv;
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
bool state;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,96 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
/******************************************************************************
|
|
||||||
* File: queue.h
|
|
||||||
*
|
|
||||||
* Description: Queue used at interface of PHY/MAC
|
|
||||||
*
|
|
||||||
* Reference:
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef QUEUE_H
|
|
||||||
#define QUEUE_H
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
class queue
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
class element
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
element() {
|
|
||||||
state = READY;
|
|
||||||
tti = 0;
|
|
||||||
}
|
|
||||||
~element();
|
|
||||||
void release()
|
|
||||||
{
|
|
||||||
state = RELEASED;
|
|
||||||
}
|
|
||||||
bool is_released()
|
|
||||||
{
|
|
||||||
return state == RELEASED;
|
|
||||||
}
|
|
||||||
void ready() {
|
|
||||||
state = READY;
|
|
||||||
}
|
|
||||||
bool is_ready() {
|
|
||||||
return state == READY;
|
|
||||||
}
|
|
||||||
uint32_t tti;
|
|
||||||
protected:
|
|
||||||
enum {
|
|
||||||
RELEASED, READY
|
|
||||||
} state;
|
|
||||||
};
|
|
||||||
|
|
||||||
queue(uint32_t nof_elements, uint32_t element_size);
|
|
||||||
~queue();
|
|
||||||
|
|
||||||
element* get(uint32_t tti);
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t nof_elements;
|
|
||||||
uint32_t element_size;
|
|
||||||
element* *buffer_of_elements;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,80 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TTISYNC_H
|
|
||||||
#define TTISYNC_H
|
|
||||||
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Interface used for PHY-MAC synchronization (producer-consumer model).
|
|
||||||
* The consumer waits while its counter is lower than the producer counter.
|
|
||||||
* The PHY is the consumer. The MAC is the producer.
|
|
||||||
*/
|
|
||||||
class tti_sync
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
tti_sync(uint32_t modulus_)
|
|
||||||
{
|
|
||||||
modulus = modulus_;
|
|
||||||
increment = 1;
|
|
||||||
init_counters(0);
|
|
||||||
}
|
|
||||||
virtual void increase() = 0;
|
|
||||||
virtual void resync() = 0;
|
|
||||||
virtual uint32_t wait() = 0;
|
|
||||||
virtual void set_producer_cntr(uint32_t) = 0;
|
|
||||||
uint32_t get_producer_cntr() { return producer_cntr; }
|
|
||||||
uint32_t get_consumer_cntr() { return consumer_cntr; }
|
|
||||||
void set_increment(uint32_t increment_) {
|
|
||||||
increment = increment_;
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
void increase_producer() { producer_cntr = (producer_cntr + increment)%modulus; }
|
|
||||||
void increase_consumer() { consumer_cntr = (consumer_cntr + increment)%modulus; }
|
|
||||||
bool wait_condition() { return producer_cntr == consumer_cntr; }
|
|
||||||
void init_counters(uint32_t val)
|
|
||||||
{
|
|
||||||
consumer_cntr = val;
|
|
||||||
producer_cntr = val;
|
|
||||||
}
|
|
||||||
uint32_t increment;
|
|
||||||
uint32_t modulus;
|
|
||||||
uint32_t producer_cntr;
|
|
||||||
uint32_t consumer_cntr;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,61 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include "srsapps/common/tti_sync.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TTISYNC_CV_H
|
|
||||||
#define TTISYNC_CV_H
|
|
||||||
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Implements tti_sync interface with condition variables.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class tti_sync_cv : public tti_sync
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
tti_sync_cv(uint32_t modulus = 10240);
|
|
||||||
~tti_sync_cv();
|
|
||||||
void increase();
|
|
||||||
uint32_t wait();
|
|
||||||
void resync();
|
|
||||||
void set_producer_cntr(uint32_t producer_cntr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
pthread_cond_t cond;
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,64 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "srsapps/common/queue.h"
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
queue::queue(uint32_t nof_elements_, uint32_t element_size)
|
|
||||||
{
|
|
||||||
nof_elements = nof_elements_;
|
|
||||||
buffer_of_elements = (queue::element**) malloc(sizeof(queue::element*) * nof_elements);
|
|
||||||
for (int i=0;i<nof_elements;i++) {
|
|
||||||
buffer_of_elements[i] = (queue::element*) malloc(element_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queue::~queue()
|
|
||||||
{
|
|
||||||
for (int i=0;i<nof_elements;i++) {
|
|
||||||
if (buffer_of_elements[i]) {
|
|
||||||
free(buffer_of_elements[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (buffer_of_elements) {
|
|
||||||
free(buffer_of_elements);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queue::element* queue::get(uint32_t tti)
|
|
||||||
{
|
|
||||||
queue::element* el = (queue::element*) buffer_of_elements[tti%nof_elements];
|
|
||||||
el->tti = tti;
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ue
|
|
||||||
} // namespace srslte
|
|
||||||
|
|
@ -1,80 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "srsapps/common/tti_sync_cv.h"
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
tti_sync_cv::tti_sync_cv(uint32_t modulus): tti_sync(modulus)
|
|
||||||
{
|
|
||||||
pthread_mutex_init(&mutex, NULL);
|
|
||||||
pthread_cond_init(&cond, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
tti_sync_cv::~tti_sync_cv()
|
|
||||||
{
|
|
||||||
pthread_cond_destroy(&cond);
|
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t tti_sync_cv::wait()
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
while(wait_condition()) {
|
|
||||||
pthread_cond_wait(&cond, &mutex);
|
|
||||||
}
|
|
||||||
uint32_t x = consumer_cntr;
|
|
||||||
increase_consumer();
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tti_sync_cv::resync()
|
|
||||||
{
|
|
||||||
consumer_cntr = producer_cntr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tti_sync_cv::set_producer_cntr(uint32_t producer_cntr)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
init_counters(producer_cntr);
|
|
||||||
pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tti_sync_cv::increase()
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
increase_producer();
|
|
||||||
pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
#include "srsapps/common/log.h"
|
|
||||||
#include "srsapps/common/queue.h"
|
|
||||||
#include "srsapps/ue/phy/ul_sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/dl_sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/phy_params.h"
|
|
||||||
|
|
||||||
#ifndef UEDLBUFFER_H
|
|
||||||
#define UEDLBUFFER_H
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Class for the processing of Downlink buffers. The MAC obtains a buffer for a given TTI and then
|
|
||||||
* gets ul/dl scheduling grants and/or processes phich/pdsch channels
|
|
||||||
*/
|
|
||||||
class dl_buffer : public queue::element {
|
|
||||||
public:
|
|
||||||
|
|
||||||
int buffer_id;
|
|
||||||
|
|
||||||
bool init_cell(srslte_cell_t cell, phy_params *params_db, log *log_h_);
|
|
||||||
void free_cell();
|
|
||||||
void set_crnti(uint16_t rnti);
|
|
||||||
bool recv_ue_sync(srslte_ue_sync_t *ue_sync, srslte_timestamp_t *rx_time);
|
|
||||||
bool get_ul_grant(ul_sched_grant *grant);
|
|
||||||
bool get_dl_grant(dl_sched_grant *grant);
|
|
||||||
void discard_pending_rar_grant();
|
|
||||||
void set_rar_grant(srslte_dci_rar_grant_t *rar_grant);
|
|
||||||
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN]);
|
|
||||||
void reset_softbuffer();
|
|
||||||
bool decode_ack(ul_sched_grant *pusch_grant);
|
|
||||||
bool decode_data(dl_sched_grant *pdsch_grant, uint8_t *payload); // returns true or false for CRC OK/NOK
|
|
||||||
bool decode_data(dl_sched_grant *grant, srslte_softbuffer_rx_t *softbuffer, uint8_t *payload);
|
|
||||||
|
|
||||||
private:
|
|
||||||
phy_params *params_db;
|
|
||||||
log *log_h;
|
|
||||||
srslte_cell_t cell;
|
|
||||||
srslte_ue_dl_t ue_dl;
|
|
||||||
srslte_phich_t phich;
|
|
||||||
cf_t *signal_buffer;
|
|
||||||
uint32_t cfi;
|
|
||||||
bool sf_symbols_and_ce_done;
|
|
||||||
bool pdcch_llr_extracted;
|
|
||||||
bool pending_rar_grant;
|
|
||||||
srslte_dci_rar_grant_t rar_grant;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,114 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
#include "srsapps/ue/phy/sched_grant.h"
|
|
||||||
|
|
||||||
#ifndef UEDLSCHEDGRANT_H
|
|
||||||
#define UEDLSCHEDGRANT_H
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */
|
|
||||||
class dl_sched_grant : public sched_grant {
|
|
||||||
public:
|
|
||||||
|
|
||||||
dl_sched_grant(rnti_type_t type, uint16_t rnti) : sched_grant(type, rnti) {}
|
|
||||||
dl_sched_grant(uint16_t rnti) : sched_grant(rnti) {}
|
|
||||||
|
|
||||||
uint32_t get_rv() {
|
|
||||||
return dl_dci.rv_idx;
|
|
||||||
}
|
|
||||||
void set_rv(uint32_t rv) {
|
|
||||||
dl_dci.rv_idx = rv;
|
|
||||||
}
|
|
||||||
bool get_ndi() {
|
|
||||||
return dl_dci.ndi;
|
|
||||||
}
|
|
||||||
void set_ndi(bool value) {
|
|
||||||
dl_dci.ndi = value;
|
|
||||||
}
|
|
||||||
uint32_t get_harq_process() {
|
|
||||||
return dl_dci.harq_process;
|
|
||||||
}
|
|
||||||
void get_dl_grant(srslte_ra_dl_grant_t *ul_grant) {
|
|
||||||
memcpy(ul_grant, &grant, sizeof(srslte_ra_dl_grant_t));
|
|
||||||
}
|
|
||||||
bool is_sps_release() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
uint32_t get_tbs() {
|
|
||||||
return grant.mcs.tbs;
|
|
||||||
}
|
|
||||||
uint32_t get_ncce() {
|
|
||||||
return ncce;
|
|
||||||
}
|
|
||||||
uint32_t get_mcs() {
|
|
||||||
return dl_dci.mcs_idx;
|
|
||||||
}
|
|
||||||
const char* get_dciformat_string() {
|
|
||||||
switch(dl_dci.dci_format) {
|
|
||||||
case srslte_ra_dl_dci_t::SRSLTE_RA_DCI_FORMAT1:
|
|
||||||
return "Format1";
|
|
||||||
case srslte_ra_dl_dci_t::SRSLTE_RA_DCI_FORMAT1A:
|
|
||||||
return "Format1A";
|
|
||||||
case srslte_ra_dl_dci_t::SRSLTE_RA_DCI_FORMAT1C:
|
|
||||||
return "Format1C";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool create_from_dci(srslte_dci_msg_t *msg, uint32_t nof_prb, uint32_t ncce_) {
|
|
||||||
ncce = ncce_;
|
|
||||||
if (srslte_dci_msg_to_dl_grant(msg, rnti, nof_prb, &dl_dci, &grant)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool get_pdsch_cfg(uint32_t sf_idx, uint32_t cfi, srslte_ue_dl_t *ue_dl) {
|
|
||||||
memcpy(&ue_dl->pdsch_cfg.grant, &grant, sizeof(srslte_ra_dl_grant_t));
|
|
||||||
|
|
||||||
/* Setup PDSCH configuration for this CFI, SFIDX and RVIDX */
|
|
||||||
if (srslte_ue_dl_cfg_grant(ue_dl, NULL, cfi, sf_idx, rnti, get_rv())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
srslte_ra_dl_grant_t grant;
|
|
||||||
srslte_ra_dl_dci_t dl_dci;
|
|
||||||
uint32_t ncce;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,104 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
#include "srsapps/common/queue.h"
|
|
||||||
|
|
||||||
#ifndef UESCHEDGRANT_H
|
|
||||||
#define UESCHEDGRANT_H
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */
|
|
||||||
class sched_grant {
|
|
||||||
public:
|
|
||||||
typedef enum {
|
|
||||||
RNTI_TYPE_NOTDEFINED = 0,
|
|
||||||
RNTI_TYPE_CRNTI,
|
|
||||||
RNTI_TYPE_RA,
|
|
||||||
RNTI_TYPE_SPS,
|
|
||||||
RNTI_TYPE_TEMP,
|
|
||||||
RNTI_TYPE_SIRNTI,
|
|
||||||
RNTI_TYPE_PRNTI,
|
|
||||||
RNTI_TYPE_TPC_PUSCH,
|
|
||||||
RNTI_TYPE_TPC_PUCCH
|
|
||||||
} rnti_type_t;
|
|
||||||
|
|
||||||
sched_grant(uint16_t rnti_) {
|
|
||||||
rnti = rnti_;
|
|
||||||
rnti_type = RNTI_TYPE_NOTDEFINED;
|
|
||||||
}
|
|
||||||
sched_grant(rnti_type_t rnti_type_, uint16_t rnti_) {
|
|
||||||
rnti = rnti_;
|
|
||||||
rnti_type = rnti_type_;
|
|
||||||
}
|
|
||||||
uint16_t get_rnti() {
|
|
||||||
return rnti;
|
|
||||||
}
|
|
||||||
bool is_temp_rnti() {
|
|
||||||
return rnti_type == RNTI_TYPE_TEMP;
|
|
||||||
}
|
|
||||||
bool is_crnti() {
|
|
||||||
return rnti_type == RNTI_TYPE_CRNTI;
|
|
||||||
}
|
|
||||||
bool is_ra_rnti() {
|
|
||||||
return rnti_type == RNTI_TYPE_RA;
|
|
||||||
}
|
|
||||||
bool is_SPS_rnti() {
|
|
||||||
return rnti_type == RNTI_TYPE_SPS;
|
|
||||||
}
|
|
||||||
bool is_sys_rnti() {
|
|
||||||
return (rnti_type == RNTI_TYPE_SIRNTI || rnti_type == RNTI_TYPE_PRNTI);
|
|
||||||
}
|
|
||||||
bool is_tpc_rnti() {
|
|
||||||
return (rnti_type == RNTI_TYPE_TPC_PUSCH || rnti_type == RNTI_TYPE_TPC_PUCCH);
|
|
||||||
}
|
|
||||||
uint32_t get_tti() {
|
|
||||||
return tti;
|
|
||||||
}
|
|
||||||
void set_tti(uint32_t tti_) {
|
|
||||||
tti = tti_;
|
|
||||||
}
|
|
||||||
virtual uint32_t get_rv() = 0;
|
|
||||||
virtual void set_rv(uint32_t rv) = 0;
|
|
||||||
virtual bool get_ndi() = 0;
|
|
||||||
virtual void set_ndi(bool value) = 0;
|
|
||||||
virtual bool is_sps_release() = 0;
|
|
||||||
virtual uint32_t get_tbs() = 0;
|
|
||||||
protected:
|
|
||||||
uint16_t rnti;
|
|
||||||
rnti_type_t rnti_type;
|
|
||||||
uint32_t tti;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,89 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
#include "srsapps/radio/radio.h"
|
|
||||||
#include "srsapps/common/log.h"
|
|
||||||
#include "srsapps/common/queue.h"
|
|
||||||
#include "srsapps/ue/phy/ul_sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/dl_sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/phy_params.h"
|
|
||||||
#include "srsapps/radio/radio.h"
|
|
||||||
|
|
||||||
#ifndef UEULBUFFER_H
|
|
||||||
#define UEULBUFFER_H
|
|
||||||
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Uplink scheduling assignment. The MAC instructs the PHY to prepare an UL packet (PUSCH or PUCCH)
|
|
||||||
* for transmission. The MAC must call generate_data() to set the packet ready for transmission
|
|
||||||
*/
|
|
||||||
class ul_buffer : public queue::element {
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool init_cell(srslte_cell_t cell, phy_params *params_db, log *log_h, radio *radio_h);
|
|
||||||
void free_cell();
|
|
||||||
void set_crnti(uint16_t rnti);
|
|
||||||
void set_current_tx_nb(uint32_t current_tx_nb);
|
|
||||||
bool generate_ack(bool ack, dl_sched_grant *last_dl_grant);
|
|
||||||
bool generate_ack(bool ack[2]);
|
|
||||||
bool generate_sr();
|
|
||||||
bool generate_cqi_report();
|
|
||||||
bool uci_ready();
|
|
||||||
bool srs_is_ready_to_send();
|
|
||||||
bool generate_data();
|
|
||||||
bool generate_data(ul_sched_grant *pusch_grant, uint8_t *payload);
|
|
||||||
bool generate_data(ul_sched_grant *pusch_grant, srslte_softbuffer_tx_t *softbuffer, uint8_t *payload);
|
|
||||||
void set_tx_params(float cfo, float time_adv_sec, srslte_timestamp_t tx_time);
|
|
||||||
void send_end_of_burst();
|
|
||||||
void send();
|
|
||||||
void pregen_signals();
|
|
||||||
static const uint32_t tx_advance_sf = 1; // Number of subframes to advance transmission
|
|
||||||
static const bool normalize_amp = true;
|
|
||||||
private:
|
|
||||||
log *log_h;
|
|
||||||
phy_params *params_db;
|
|
||||||
radio *radio_h;
|
|
||||||
float cfo;
|
|
||||||
srslte_timestamp_t tx_time;
|
|
||||||
srslte_cell_t cell;
|
|
||||||
srslte_ue_ul_t ue_ul;
|
|
||||||
bool cell_initiated;
|
|
||||||
cf_t* signal_buffer;
|
|
||||||
uint32_t current_tx_nb;
|
|
||||||
uint32_t last_n_cce;
|
|
||||||
srslte_uci_data_t uci_data;
|
|
||||||
bool uci_pending;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,134 +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/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
#include "srsapps/ue/phy/sched_grant.h"
|
|
||||||
|
|
||||||
#ifndef UEULSCHEDGRANT_H
|
|
||||||
#define UEULSCHEDGRANT_H
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
/* Uplink/Downlink scheduling grant generated by a successfully decoded PDCCH */
|
|
||||||
class ul_sched_grant : public sched_grant {
|
|
||||||
public:
|
|
||||||
|
|
||||||
ul_sched_grant(rnti_type_t type, uint16_t rnti) : sched_grant(type, rnti) {}
|
|
||||||
ul_sched_grant(uint16_t rnti) : sched_grant(rnti) {}
|
|
||||||
|
|
||||||
uint32_t get_rv() {
|
|
||||||
return ul_dci.rv_idx;
|
|
||||||
}
|
|
||||||
void set_rv(uint32_t rv) {
|
|
||||||
ul_dci.rv_idx = rv;
|
|
||||||
}
|
|
||||||
bool get_ndi() {
|
|
||||||
return ul_dci.ndi;
|
|
||||||
}
|
|
||||||
void set_ndi(bool value) {
|
|
||||||
ul_dci.ndi = value;
|
|
||||||
}
|
|
||||||
bool get_cqi_request() {
|
|
||||||
return ul_dci.cqi_request;
|
|
||||||
}
|
|
||||||
void get_ul_grant(srslte_ra_ul_grant_t *ul_grant) {
|
|
||||||
memcpy(ul_grant, &grant, sizeof(srslte_ra_ul_grant_t));
|
|
||||||
}
|
|
||||||
bool is_sps_release() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
uint32_t get_tbs() {
|
|
||||||
return grant.mcs.tbs;
|
|
||||||
}
|
|
||||||
uint32_t get_mcs() {
|
|
||||||
return ul_dci.mcs_idx;
|
|
||||||
}
|
|
||||||
uint32_t get_current_tx_nb() {
|
|
||||||
return current_tx_nb;
|
|
||||||
}
|
|
||||||
void set_current_tx_nb(uint32_t current_tx_nb) {
|
|
||||||
current_tx_nb = current_tx_nb;
|
|
||||||
}
|
|
||||||
uint32_t get_I_lowest() {
|
|
||||||
return grant.n_prb[0];
|
|
||||||
}
|
|
||||||
uint32_t get_n_dmrs() {
|
|
||||||
return ul_dci.n_dmrs;
|
|
||||||
}
|
|
||||||
bool is_from_rar() {
|
|
||||||
return grant_is_from_rar;
|
|
||||||
}
|
|
||||||
bool create_from_dci(srslte_dci_msg_t *msg, srslte_cell_t cell, uint32_t n_rb_ho) {
|
|
||||||
grant_is_from_rar = false;
|
|
||||||
if (srslte_dci_msg_to_ul_grant(msg, cell.nof_prb, n_rb_ho, &ul_dci, &grant)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (SRSLTE_VERBOSE_ISINFO()) {
|
|
||||||
srslte_ra_pusch_fprint(stdout, &ul_dci, cell.nof_prb);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool create_from_rar(srslte_dci_rar_grant_t *rar, srslte_cell_t cell, uint32_t n_rb_ho) {
|
|
||||||
grant_is_from_rar = true;
|
|
||||||
if (srslte_dci_rar_to_ul_grant(rar, cell.nof_prb, n_rb_ho, &ul_dci, &grant)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (SRSLTE_VERBOSE_ISINFO()) {
|
|
||||||
srslte_ra_pusch_fprint(stdout, &ul_dci, cell.nof_prb);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool to_pusch_cfg(srslte_pusch_hopping_cfg_t *hopping_cfg, srslte_refsignal_srs_cfg_t *srs_cfg, uint32_t tti, srslte_ue_ul_t *ue_ul) {
|
|
||||||
memcpy(&ue_ul->pusch_cfg.grant, &grant, sizeof(srslte_ra_ul_grant_t));
|
|
||||||
|
|
||||||
uint32_t cyclic_shift_for_dmrs = 0;
|
|
||||||
if (!is_from_rar()) {
|
|
||||||
cyclic_shift_for_dmrs = get_n_dmrs();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srslte_ue_ul_cfg_grant(ue_ul, NULL, hopping_cfg, srs_cfg, tti, cyclic_shift_for_dmrs, get_rv())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
srslte_ra_ul_grant_t grant;
|
|
||||||
srslte_ra_ul_dci_t ul_dci;
|
|
||||||
uint32_t current_tx_nb;
|
|
||||||
uint16_t rnti;
|
|
||||||
bool grant_is_from_rar;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,235 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 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 Lesser 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 Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser 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 <string.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
|
|
||||||
#include "srsapps/common/log.h"
|
|
||||||
#include "srsapps/ue/phy/sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/dl_buffer.h"
|
|
||||||
#include "srsapps/ue/phy/phy.h"
|
|
||||||
#include "srsapps/ue/phy/phy_params.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
bool dl_buffer::init_cell(srslte_cell_t cell_, phy_params *params_db_, log *log_h_)
|
|
||||||
{
|
|
||||||
log_h = log_h_;
|
|
||||||
params_db = params_db_;
|
|
||||||
cell = cell_;
|
|
||||||
sf_symbols_and_ce_done = false;
|
|
||||||
pdcch_llr_extracted = false;
|
|
||||||
pending_rar_grant = false;
|
|
||||||
tti = 0;
|
|
||||||
if (!srslte_ue_dl_init(&ue_dl, cell)) {
|
|
||||||
signal_buffer = (cf_t*) srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
return signal_buffer?true:false;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dl_buffer::free_cell()
|
|
||||||
{
|
|
||||||
if (signal_buffer) {
|
|
||||||
free(signal_buffer);
|
|
||||||
}
|
|
||||||
srslte_ue_dl_free(&ue_dl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dl_buffer::set_crnti(uint16_t rnti)
|
|
||||||
{
|
|
||||||
srslte_ue_dl_set_rnti(&ue_dl, rnti);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Avoid this memcpy modifying ue_sync to directly write into provided pointer
|
|
||||||
bool dl_buffer::recv_ue_sync(srslte_ue_sync_t *ue_sync, srslte_timestamp_t *rx_time)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
cf_t *sf_buffer = NULL;
|
|
||||||
sf_symbols_and_ce_done = false;
|
|
||||||
pdcch_llr_extracted = false;
|
|
||||||
if (signal_buffer) {
|
|
||||||
bzero(signal_buffer, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
if (srslte_ue_sync_get_buffer(ue_sync, &sf_buffer) == 1) {
|
|
||||||
memcpy(signal_buffer, sf_buffer, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
ready();
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
srslte_ue_sync_get_last_timestamp(ue_sync, rx_time);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dl_buffer::discard_pending_rar_grant() {
|
|
||||||
pending_rar_grant = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dl_buffer::get_ul_grant(ul_sched_grant *grant)
|
|
||||||
{
|
|
||||||
if (signal_buffer) {
|
|
||||||
if (pending_rar_grant && grant->is_temp_rnti()) {
|
|
||||||
return grant->create_from_rar(&rar_grant, cell, params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET));
|
|
||||||
} else {
|
|
||||||
if (!sf_symbols_and_ce_done) {
|
|
||||||
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sf_symbols_and_ce_done = true;
|
|
||||||
}
|
|
||||||
if (!pdcch_llr_extracted) {
|
|
||||||
if (srslte_pdcch_extract_llr(&ue_dl.pdcch, ue_dl.sf_symbols, ue_dl.ce, 0, tti%10, cfi)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pdcch_llr_extracted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
srslte_dci_msg_t dci_msg;
|
|
||||||
if (srslte_ue_dl_find_ul_dci(&ue_dl, &dci_msg, cfi, tti%10, grant->get_rnti()) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
grant->set_tti(tti);
|
|
||||||
|
|
||||||
Info("PDCCH: UL DCI Format0 cce_index=%d, n_data_bits=%d\n", ue_dl.last_n_cce, dci_msg.nof_bits);
|
|
||||||
|
|
||||||
return grant->create_from_dci(&dci_msg, cell, params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unpack RAR grant as defined in Section 6.2 of 36.213
|
|
||||||
void dl_buffer::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN])
|
|
||||||
{
|
|
||||||
pending_rar_grant = true;
|
|
||||||
srslte_dci_rar_grant_unpack(&rar_grant, grant_payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dl_buffer::set_rar_grant(srslte_dci_rar_grant_t* rar_grant_)
|
|
||||||
{
|
|
||||||
pending_rar_grant = true;
|
|
||||||
memcpy(&rar_grant, rar_grant_, sizeof(srslte_dci_rar_grant_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dl_buffer::get_dl_grant(dl_sched_grant *grant)
|
|
||||||
{
|
|
||||||
if (signal_buffer && is_ready()) {
|
|
||||||
Debug("DL Buffer TTI %d: Getting DL grant\n", tti);
|
|
||||||
if (!sf_symbols_and_ce_done) {
|
|
||||||
Debug("DL Buffer TTI %d: Getting DL grant. Calling fft estimate\n", tti);
|
|
||||||
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sf_symbols_and_ce_done = true;
|
|
||||||
}
|
|
||||||
if (!pdcch_llr_extracted) {
|
|
||||||
Debug("DL Buffer TTI %d: Getting DL grant. extracting LLR\n", tti);
|
|
||||||
if (srslte_pdcch_extract_llr(&ue_dl.pdcch, ue_dl.sf_symbols, ue_dl.ce, 0, tti%10, cfi)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pdcch_llr_extracted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SRSLTE_VERBOSE_ISDEBUG()) {
|
|
||||||
srslte_vec_save_file((char*) "ce1", ue_dl.ce[0], SRSLTE_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp)*sizeof(cf_t));
|
|
||||||
srslte_vec_save_file((char*) "ce2", ue_dl.ce[1], SRSLTE_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp)*sizeof(cf_t));
|
|
||||||
srslte_vec_save_file((char*) "pdcch_d", ue_dl.pdcch.d, 36*ue_dl.pdcch.nof_cce*sizeof(cf_t));
|
|
||||||
srslte_vec_save_file((char*) "pdcch_llr", ue_dl.pdcch.llr, 72*ue_dl.pdcch.nof_cce*sizeof(cf_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
srslte_dci_msg_t dci_msg;
|
|
||||||
if (srslte_ue_dl_find_dl_dci(&ue_dl, &dci_msg, cfi, tti%10, grant->get_rnti()) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
grant->set_tti(tti);
|
|
||||||
|
|
||||||
Info("PDCCH: DL DCI %s cce_index=%d, n_data_bits=%d\n", grant->get_dciformat_string(), ue_dl.last_n_cce, dci_msg.nof_bits);
|
|
||||||
|
|
||||||
return grant->create_from_dci(&dci_msg, cell.nof_prb, srslte_ue_dl_get_ncce(&ue_dl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dl_buffer::decode_ack(ul_sched_grant *grant)
|
|
||||||
{
|
|
||||||
if (signal_buffer && is_ready()) {
|
|
||||||
if (!sf_symbols_and_ce_done) {
|
|
||||||
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sf_symbols_and_ce_done = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return srslte_ue_dl_decode_phich(&ue_dl, tti%10, grant->get_I_lowest(), grant->get_n_dmrs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dl_buffer::reset_softbuffer()
|
|
||||||
{
|
|
||||||
srslte_softbuffer_rx_reset(&ue_dl.softbuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dl_buffer::decode_data(dl_sched_grant *grant, uint8_t *payload)
|
|
||||||
{
|
|
||||||
return decode_data(grant, &ue_dl.softbuffer, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dl_buffer::decode_data(dl_sched_grant *grant, srslte_softbuffer_rx_t *softbuffer, uint8_t *payload)
|
|
||||||
{
|
|
||||||
if (signal_buffer && is_ready()) {
|
|
||||||
Debug("DL Buffer TTI %d: Decoding PDSCH\n", tti);
|
|
||||||
if (!sf_symbols_and_ce_done) {
|
|
||||||
Debug("DL Buffer TTI %d: Decoding PDSCH. Calling fft estimate\n", tti);
|
|
||||||
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, signal_buffer, tti%10, &cfi) < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sf_symbols_and_ce_done = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
grant->get_pdsch_cfg(tti%10, cfi, &ue_dl);
|
|
||||||
if (ue_dl.pdsch_cfg.grant.mcs.mod > 0 && ue_dl.pdsch_cfg.grant.mcs.tbs >= 0) {
|
|
||||||
|
|
||||||
int ret = srslte_pdsch_decode_rnti(&ue_dl.pdsch, &ue_dl.pdsch_cfg, softbuffer, ue_dl.sf_symbols,
|
|
||||||
ue_dl.ce, 0, grant->get_rnti(), payload);
|
|
||||||
|
|
||||||
if (SRSLTE_VERBOSE_ISDEBUG()) {
|
|
||||||
srslte_vec_save_file((char*) "pdsch_d", ue_dl.pdsch.d, ue_dl.pdsch_cfg.nbits.nof_re*sizeof(cf_t));
|
|
||||||
}
|
|
||||||
if (ret == SRSLTE_SUCCESS) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,344 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 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 Lesser 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 Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser 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 <string.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "srslte/srslte.h"
|
|
||||||
|
|
||||||
#include "srsapps/common/log.h"
|
|
||||||
#include "srsapps/ue/phy/sched_grant.h"
|
|
||||||
#include "srsapps/ue/phy/ul_buffer.h"
|
|
||||||
#include "srsapps/ue/phy/phy.h"
|
|
||||||
#include "srsapps/ue/phy/phy_params.h"
|
|
||||||
|
|
||||||
namespace srslte {
|
|
||||||
namespace ue {
|
|
||||||
|
|
||||||
bool ul_buffer::init_cell(srslte_cell_t cell_, phy_params *params_db_, log *log_h_, radio *radio_h_) {
|
|
||||||
cell = cell_;
|
|
||||||
log_h = log_h_;
|
|
||||||
radio_h = radio_h_;
|
|
||||||
params_db = params_db_;
|
|
||||||
current_tx_nb = 0;
|
|
||||||
|
|
||||||
if (!srslte_ue_ul_init(&ue_ul, cell)) {
|
|
||||||
srslte_ue_ul_set_normalization(&ue_ul, false);
|
|
||||||
signal_buffer = (cf_t*) srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
cell_initiated = (signal_buffer)?true:false;
|
|
||||||
srslte_ue_ul_set_cfo_enable(&ue_ul, true);
|
|
||||||
bzero(&uci_data, sizeof(srslte_uci_data_t));
|
|
||||||
uci_pending = false;
|
|
||||||
return cell_initiated;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::free_cell() {
|
|
||||||
if (cell_initiated) {
|
|
||||||
if (signal_buffer) {
|
|
||||||
free(signal_buffer);
|
|
||||||
}
|
|
||||||
srslte_ue_ul_free(&ue_ul);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::set_crnti(uint16_t rnti)
|
|
||||||
{
|
|
||||||
srslte_ue_ul_set_rnti(&ue_ul, rnti);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::pregen_signals()
|
|
||||||
{
|
|
||||||
srslte_refsignal_dmrs_pusch_cfg_t dmrs_cfg;
|
|
||||||
bzero(&dmrs_cfg, sizeof(srslte_refsignal_dmrs_pusch_cfg_t));
|
|
||||||
dmrs_cfg.beta_pusch = (float) params_db->get_param(phy_params::PUSCH_BETA)/10;
|
|
||||||
bool group_hopping_en = params_db->get_param(phy_params::DMRS_GROUP_HOPPING_EN);
|
|
||||||
bool sequence_hopping_en = params_db->get_param(phy_params::DMRS_SEQUENCE_HOPPING_EN);
|
|
||||||
dmrs_cfg.cyclic_shift = params_db->get_param(phy_params::PUSCH_RS_CYCLIC_SHIFT);
|
|
||||||
dmrs_cfg.delta_ss = params_db->get_param(phy_params::PUSCH_RS_GROUP_ASSIGNMENT);
|
|
||||||
|
|
||||||
srslte_refsignal_srs_cfg_t srs_cfg;
|
|
||||||
bzero(&srs_cfg, sizeof(srslte_refsignal_srs_cfg_t));
|
|
||||||
srs_cfg.configured = params_db->get_param(phy_params::SRS_IS_CONFIGURED)?true:false;
|
|
||||||
srs_cfg.subframe_config = (uint32_t) params_db->get_param(phy_params::SRS_CS_SFCFG);
|
|
||||||
srs_cfg.bw_cfg = (uint32_t) params_db->get_param(phy_params::SRS_CS_BWCFG);
|
|
||||||
srs_cfg.I_srs = (uint32_t) params_db->get_param(phy_params::SRS_UE_CONFIGINDEX);
|
|
||||||
srs_cfg.B = (uint32_t) params_db->get_param(phy_params::SRS_UE_BW);
|
|
||||||
srs_cfg.b_hop = (uint32_t) params_db->get_param(phy_params::SRS_UE_HOP);
|
|
||||||
srs_cfg.n_rrc = (uint32_t) params_db->get_param(phy_params::SRS_UE_NRRC);
|
|
||||||
srs_cfg.k_tc = (uint32_t) params_db->get_param(phy_params::SRS_UE_TXCOMB);
|
|
||||||
srs_cfg.n_srs = (uint32_t) params_db->get_param(phy_params::SRS_UE_CYCLICSHIFT);
|
|
||||||
srs_cfg.beta_srs = ((float) params_db->get_param(phy_params::SRS_BETA))/10;
|
|
||||||
|
|
||||||
srslte_ue_ul_set_cfg(&ue_ul, &dmrs_cfg, NULL, &srs_cfg, NULL, group_hopping_en, sequence_hopping_en);
|
|
||||||
srslte_ue_ul_pregen_signals(&ue_ul);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_ack(bool ack, dl_sched_grant *last_dl_grant)
|
|
||||||
{
|
|
||||||
uci_data.uci_ack_len = 1;
|
|
||||||
uci_data.uci_ack = ack?1:0;
|
|
||||||
uci_pending = true;
|
|
||||||
last_n_cce = last_dl_grant->get_ncce();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_ack(bool ack[2])
|
|
||||||
{
|
|
||||||
uci_data.uci_ack_len = 2;
|
|
||||||
uci_data.uci_ack = ack[0]?1:0;
|
|
||||||
uci_data.uci_ack_2 = ack[1]?1:0;
|
|
||||||
uci_pending = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::set_current_tx_nb(uint32_t current_tx_nb_)
|
|
||||||
{
|
|
||||||
current_tx_nb = current_tx_nb_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_cqi_report()
|
|
||||||
{
|
|
||||||
uci_data.uci_cqi_len = 4;
|
|
||||||
uint8_t cqi[4] = {1, 1, 1, 1};
|
|
||||||
uci_data.uci_cqi = cqi;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_sr() {
|
|
||||||
uci_data.scheduling_request = true;
|
|
||||||
uci_pending = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::uci_ready() {
|
|
||||||
return uci_pending;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_data() {
|
|
||||||
return generate_data(NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ul_buffer::generate_data(ul_sched_grant *grant,
|
|
||||||
uint8_t *payload)
|
|
||||||
{
|
|
||||||
return generate_data(grant, &ue_ul.softbuffer, payload);
|
|
||||||
}
|
|
||||||
//int nof_tx=0;
|
|
||||||
|
|
||||||
|
|
||||||
bool ul_buffer::srs_is_ready_to_send() {
|
|
||||||
if (params_db->get_param(phy_params::SRS_IS_CONFIGURED))
|
|
||||||
{
|
|
||||||
if (srslte_refsignal_srs_send_cs(params_db->get_param(phy_params::SRS_CS_SFCFG), tti%10) == 1 &&
|
|
||||||
srslte_refsignal_srs_send_ue(params_db->get_param(phy_params::SRS_UE_CONFIGINDEX), tti) == 1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int srspkt = 0;
|
|
||||||
|
|
||||||
bool ul_buffer::generate_data(ul_sched_grant *grant, srslte_softbuffer_tx_t *softbuffer, uint8_t *payload)
|
|
||||||
{
|
|
||||||
if (is_ready()) {
|
|
||||||
|
|
||||||
bzero(signal_buffer, sizeof(cf_t)*SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
|
|
||||||
srslte_refsignal_dmrs_pusch_cfg_t dmrs_cfg;
|
|
||||||
bzero(&dmrs_cfg, sizeof(srslte_refsignal_dmrs_pusch_cfg_t));
|
|
||||||
dmrs_cfg.beta_pusch = (float) params_db->get_param(phy_params::PUSCH_BETA)/10;
|
|
||||||
bool group_hopping_en = params_db->get_param(phy_params::DMRS_GROUP_HOPPING_EN);
|
|
||||||
bool sequence_hopping_en = params_db->get_param(phy_params::DMRS_SEQUENCE_HOPPING_EN);
|
|
||||||
dmrs_cfg.cyclic_shift = params_db->get_param(phy_params::PUSCH_RS_CYCLIC_SHIFT);
|
|
||||||
dmrs_cfg.delta_ss = params_db->get_param(phy_params::PUSCH_RS_GROUP_ASSIGNMENT);
|
|
||||||
|
|
||||||
srslte_pusch_hopping_cfg_t pusch_hopping;
|
|
||||||
if (grant) {
|
|
||||||
bzero(&pusch_hopping, sizeof(srslte_pusch_hopping_cfg_t));
|
|
||||||
pusch_hopping.n_sb = params_db->get_param(phy_params::PUSCH_HOPPING_N_SB);
|
|
||||||
pusch_hopping.hop_mode = params_db->get_param(phy_params::PUSCH_HOPPING_INTRA_SF) ?
|
|
||||||
pusch_hopping.SRSLTE_PUSCH_HOP_MODE_INTRA_SF :
|
|
||||||
pusch_hopping.SRSLTE_PUSCH_HOP_MODE_INTER_SF;
|
|
||||||
pusch_hopping.hopping_offset = params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET);
|
|
||||||
pusch_hopping.current_tx_nb = grant->get_current_tx_nb();
|
|
||||||
}
|
|
||||||
|
|
||||||
srslte_pucch_cfg_t pucch_cfg;
|
|
||||||
bzero(&pucch_cfg, sizeof(srslte_pucch_cfg_t));
|
|
||||||
pucch_cfg.beta_pucch = (float) params_db->get_param(phy_params::PUCCH_BETA)/10;
|
|
||||||
pucch_cfg.delta_pucch_shift = params_db->get_param(phy_params::PUCCH_DELTA_SHIFT);
|
|
||||||
pucch_cfg.N_cs = params_db->get_param(phy_params::PUCCH_CYCLIC_SHIFT);
|
|
||||||
pucch_cfg.n_rb_2 = params_db->get_param(phy_params::PUCCH_N_RB_2);
|
|
||||||
pucch_cfg.srs_configured = params_db->get_param(phy_params::SRS_IS_CONFIGURED)?true:false;
|
|
||||||
pucch_cfg.srs_cs_subf_cfg = (uint32_t) params_db->get_param(phy_params::SRS_CS_SFCFG);
|
|
||||||
pucch_cfg.srs_simul_ack = params_db->get_param(phy_params::SRS_CS_ACKNACKSIMUL)?true:false;
|
|
||||||
|
|
||||||
srslte_pucch_sched_t pucch_sched;
|
|
||||||
bzero(&pucch_sched, sizeof(srslte_pucch_sched_t));
|
|
||||||
pucch_sched.n_cce = last_n_cce;
|
|
||||||
pucch_sched.n_pucch_1[0] = params_db->get_param(phy_params::PUCCH_N_PUCCH_1_0);
|
|
||||||
pucch_sched.n_pucch_1[1] = params_db->get_param(phy_params::PUCCH_N_PUCCH_1_1);
|
|
||||||
pucch_sched.n_pucch_1[2] = params_db->get_param(phy_params::PUCCH_N_PUCCH_1_2);
|
|
||||||
pucch_sched.n_pucch_1[3] = params_db->get_param(phy_params::PUCCH_N_PUCCH_1_3);
|
|
||||||
pucch_sched.N_pucch_1 = params_db->get_param(phy_params::PUCCH_N_PUCCH_1);
|
|
||||||
pucch_sched.n_pucch_2 = params_db->get_param(phy_params::PUCCH_N_PUCCH_2);
|
|
||||||
pucch_sched.n_pucch_sr = params_db->get_param(phy_params::PUCCH_N_PUCCH_SR);
|
|
||||||
|
|
||||||
srslte_refsignal_srs_cfg_t srs_cfg;
|
|
||||||
bzero(&srs_cfg, sizeof(srslte_refsignal_srs_cfg_t));
|
|
||||||
srs_cfg.configured = params_db->get_param(phy_params::SRS_IS_CONFIGURED)?true:false;
|
|
||||||
srs_cfg.subframe_config = (uint32_t) params_db->get_param(phy_params::SRS_CS_SFCFG);
|
|
||||||
srs_cfg.bw_cfg = (uint32_t) params_db->get_param(phy_params::SRS_CS_BWCFG);
|
|
||||||
srs_cfg.I_srs = (uint32_t) params_db->get_param(phy_params::SRS_UE_CONFIGINDEX);
|
|
||||||
srs_cfg.B = (uint32_t) params_db->get_param(phy_params::SRS_UE_BW);
|
|
||||||
srs_cfg.b_hop = (uint32_t) params_db->get_param(phy_params::SRS_UE_HOP);
|
|
||||||
srs_cfg.n_rrc = (uint32_t) params_db->get_param(phy_params::SRS_UE_NRRC);
|
|
||||||
srs_cfg.k_tc = (uint32_t) params_db->get_param(phy_params::SRS_UE_TXCOMB);
|
|
||||||
srs_cfg.n_srs = (uint32_t) params_db->get_param(phy_params::SRS_UE_CYCLICSHIFT);
|
|
||||||
srs_cfg.beta_srs = ((float) params_db->get_param(phy_params::SRS_BETA))/10;
|
|
||||||
|
|
||||||
srslte_ue_ul_set_cfg(&ue_ul, &dmrs_cfg, &pucch_cfg, &srs_cfg, &pucch_sched,
|
|
||||||
group_hopping_en, sequence_hopping_en);
|
|
||||||
|
|
||||||
uci_data.I_offset_ack = params_db->get_param(phy_params::UCI_I_OFFSET_ACK);
|
|
||||||
uci_data.I_offset_cqi = params_db->get_param(phy_params::UCI_I_OFFSET_CQI);
|
|
||||||
uci_data.I_offset_ri = params_db->get_param(phy_params::UCI_I_OFFSET_RI);
|
|
||||||
|
|
||||||
srslte_ue_ul_set_cfo(&ue_ul, cfo);
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
// Transmit on PUSCH if UL grant available, otherwise in PUCCH
|
|
||||||
if (grant) {
|
|
||||||
|
|
||||||
if (params_db->get_param(phy_params::CQI_PERIODIC_CONFIGURED)) {
|
|
||||||
if (srslte_cqi_send(params_db->get_param(phy_params::CQI_PERIODIC_PMI_IDX), tti)) {
|
|
||||||
generate_cqi_report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
srslte_pusch_hopping_cfg_t pusch_hopping_cfg;
|
|
||||||
bzero(&pusch_hopping_cfg, sizeof(srslte_pusch_hopping_cfg_t));
|
|
||||||
|
|
||||||
pusch_hopping_cfg.n_sb = params_db->get_param(phy_params::PUSCH_HOPPING_N_SB);
|
|
||||||
pusch_hopping_cfg.hop_mode = params_db->get_param(phy_params::PUSCH_HOPPING_INTRA_SF) ?
|
|
||||||
srslte_pusch_hopping_cfg_t::SRSLTE_PUSCH_HOP_MODE_INTRA_SF :
|
|
||||||
srslte_pusch_hopping_cfg_t::SRSLTE_PUSCH_HOP_MODE_INTER_SF;
|
|
||||||
pusch_hopping_cfg.hopping_offset = params_db->get_param(phy_params::PUSCH_HOPPING_OFFSET);
|
|
||||||
pusch_hopping_cfg.current_tx_nb = grant->get_current_tx_nb();
|
|
||||||
|
|
||||||
grant->to_pusch_cfg(&pusch_hopping_cfg, &srs_cfg, tti, &ue_ul);
|
|
||||||
|
|
||||||
n = srslte_ue_ul_pusch_encode_rnti_softbuffer(&ue_ul,
|
|
||||||
payload, uci_data,
|
|
||||||
softbuffer,
|
|
||||||
grant->get_rnti(),
|
|
||||||
signal_buffer);
|
|
||||||
|
|
||||||
if (ue_ul.pusch.shortened) {
|
|
||||||
Info("PUSCH shortened on tti=%d\n", tti);
|
|
||||||
}
|
|
||||||
|
|
||||||
Info("PUSCH: TTI=%d, CFO= %.1f KHz TBS=%d, mod=%s, rb_start=%d n_prb=%d, ack=%s, sr=%s, rnti=%d, shortened=%s\n",
|
|
||||||
tti, cfo*15e3, grant->get_tbs(), srslte_mod_string(ue_ul.pusch_cfg.grant.mcs.mod), ue_ul.pusch_cfg.grant.n_prb[0],
|
|
||||||
ue_ul.pusch_cfg.grant.L_prb,
|
|
||||||
uci_data.uci_ack_len>0?(uci_data.uci_ack?"1":"0"):"no",uci_data.scheduling_request?"yes":"no",
|
|
||||||
grant->get_rnti(), ue_ul.pusch.shortened?"yes":"no");
|
|
||||||
|
|
||||||
|
|
||||||
} else if (uci_data.scheduling_request || uci_data.uci_cqi_len > 0 || uci_data.uci_ack_len) {
|
|
||||||
n = srslte_ue_ul_pucch_encode(&ue_ul, uci_data, tti, signal_buffer);
|
|
||||||
|
|
||||||
Info("PUCCH: TTI=%d, CFO= %.1f KHz n_cce=%d, ack=%s, sr=%s, shortened=%s\n", tti, cfo*15e3, last_n_cce,
|
|
||||||
uci_data.uci_ack_len>0?(uci_data.uci_ack?"1":"0"):"no",uci_data.scheduling_request?"yes":"no",
|
|
||||||
ue_ul.pucch.shortened?"yes":"no");
|
|
||||||
} else {
|
|
||||||
n = srslte_ue_ul_srs_encode(&ue_ul, tti, signal_buffer);
|
|
||||||
|
|
||||||
Info("SRS: TTI=%d, CFO= %.1f KHz \n", tti, cfo*15e3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset UCI data
|
|
||||||
bzero(&uci_data, sizeof(srslte_uci_data_t));
|
|
||||||
uci_pending = false;
|
|
||||||
|
|
||||||
// Compute peak
|
|
||||||
float max = 0;
|
|
||||||
if (normalize_amp) {
|
|
||||||
float *t = (float*) signal_buffer;
|
|
||||||
for (int i=0;i<2*SRSLTE_SF_LEN_PRB(cell.nof_prb);i++) {
|
|
||||||
if (fabsf(t[i]) > max) {
|
|
||||||
max = fabsf(t[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize before TX
|
|
||||||
srslte_vec_sc_prod_cfc(signal_buffer, 0.9/max, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
|
|
||||||
}
|
|
||||||
|
|
||||||
release();
|
|
||||||
|
|
||||||
if (n < 0) {
|
|
||||||
fprintf(stderr, "Error in UL buffer: Error encoding %s\n", signal_buffer?"PUSCH":"PUCCH");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Error in UL buffer: buffer not released\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int nof_tx = 0;
|
|
||||||
|
|
||||||
void ul_buffer::set_tx_params(float cfo_, float time_adv_sec, srslte_timestamp_t tx_time_)
|
|
||||||
{
|
|
||||||
cfo = cfo_;
|
|
||||||
srslte_timestamp_copy(&tx_time, &tx_time_);
|
|
||||||
srslte_timestamp_add(&tx_time, 0, 4e-3 - time_adv_sec); // UL buffer is configured for tti+4
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::send() {
|
|
||||||
radio_h->tx(signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb), tx_time);
|
|
||||||
Info("TX TTI=%d\n", tti);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ul_buffer::send_end_of_burst()
|
|
||||||
{
|
|
||||||
Info("TTI %d sending end of burst\n", tti);
|
|
||||||
radio_h->tx_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ue
|
|
||||||
} // namespace srslte
|
|
||||||
|
|
Loading…
Reference in New Issue