Removed set RNTI from API

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 93752fb2c4
commit 1e55d68b55

@ -362,8 +362,6 @@ static void base_init()
exit(-1);
}
srslte_pdsch_set_rnti(&pdsch, UE_CRNTI);
if (mbsfn_area_id > -1) {
if (srslte_pmch_init(&pmch, cell.nof_prb, 1)) {
ERROR("Error creating PMCH object");

@ -624,9 +624,6 @@ int main(int argc, char** argv)
pdsch_cfg.rnti = prog_args.rnti;
/* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */
srslte_ue_dl_set_rnti(&ue_dl, prog_args.rnti);
/* Configure MBSFN area id and non-MBSFN Region */
if (prog_args.mbsfn_area_id > -1) {
srslte_ue_dl_set_mbsfn_area_id(&ue_dl, prog_args.mbsfn_area_id);

@ -28,14 +28,6 @@ public:
*/
virtual void rem_rnti(uint16_t rnti) = 0;
/**
* Pregenerates the scrambling sequences for a given RNTI.
* WARNING: This function make take several ms to complete.
*
* @param rnti identifier of the user
*/
virtual int pregen_sequences(uint16_t rnti) = 0;
/**
*
* @param stop

@ -103,9 +103,6 @@ struct phy_args_t {
class phy_interface_mac_common
{
public:
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
virtual void set_crnti(uint16_t rnti) = 0;
/* Time advance commands */
virtual void set_timeadv_rar(uint32_t ta_cmd) = 0;
virtual void set_timeadv(uint32_t ta_cmd) = 0;

@ -62,9 +62,9 @@ SRSLTE_API void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_
SRSLTE_API void srslte_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed);
SRSLTE_API void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed);
SRSLTE_API void srslte_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed);
SRSLTE_API void srslte_sequence_apply_bit_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed);
SRSLTE_API void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed);
SRSLTE_API int srslte_sequence_pbch(srslte_sequence_t* seq, srslte_cp_t cp, uint32_t cell_id);
@ -77,9 +77,65 @@ SRSLTE_API int srslte_sequence_pdcch(srslte_sequence_t* seq, uint32_t nslot, uin
SRSLTE_API int
srslte_sequence_pdsch(srslte_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len);
SRSLTE_API void srslte_sequence_pdsch_apply_pack(const uint8_t* in,
uint8_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void srslte_sequence_pdsch_apply_f(const float* in,
float* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void srslte_sequence_pdsch_apply_s(const int16_t* in,
int16_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void srslte_sequence_pdsch_apply_c(const int8_t* in,
int8_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API int
srslte_sequence_pusch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len);
SRSLTE_API void srslte_sequence_pusch_apply_pack(const uint8_t* in,
uint8_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void srslte_sequence_pusch_apply_c(const int8_t* in,
int8_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void srslte_sequence_pusch_apply_s(const int16_t* in,
int16_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len);
SRSLTE_API void
srslte_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len);
SRSLTE_API int srslte_sequence_pucch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id);
SRSLTE_API int srslte_sequence_pmch(srslte_sequence_t* seq, uint32_t nslot, uint32_t mbsfn_id, uint32_t len);

@ -93,10 +93,6 @@ SRSLTE_API void srslte_enb_dl_free(srslte_enb_dl_t* q);
SRSLTE_API int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell);
SRSLTE_API int srslte_enb_dl_add_rnti(srslte_enb_dl_t* q, uint16_t rnti);
SRSLTE_API void srslte_enb_dl_rem_rnti(srslte_enb_dl_t* q, uint16_t rnti);
SRSLTE_API bool srslte_enb_dl_location_is_common_ncce(srslte_enb_dl_t* q, uint32_t ncce);
SRSLTE_API void srslte_enb_dl_put_base(srslte_enb_dl_t* q, srslte_dl_sf_cfg_t* dl_sf);

@ -63,10 +63,6 @@ SRSLTE_API int srslte_enb_ul_set_cell(srslte_enb_ul_t* q,
srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg,
srslte_refsignal_srs_cfg_t* srs_cfg);
SRSLTE_API int srslte_enb_ul_add_rnti(srslte_enb_ul_t* q, uint16_t rnti);
SRSLTE_API void srslte_enb_ul_rem_rnti(srslte_enb_ul_t* q, uint16_t rnti);
SRSLTE_API void srslte_enb_ul_fft(srslte_enb_ul_t* q);
SRSLTE_API int srslte_enb_ul_get_pucch(srslte_enb_ul_t* q,

@ -35,12 +35,6 @@
#include "srslte/phy/phch/sch.h"
#include "srslte/phy/scrambling/scrambling.h"
typedef struct {
srslte_sequence_t seq[SRSLTE_MAX_CODEWORDS][SRSLTE_NOF_SF_X_FRAME];
uint32_t cell_id;
bool sequence_generated;
} srslte_pdsch_user_t;
/* PDSCH object */
typedef struct SRSLTE_API {
srslte_cell_t cell;
@ -48,8 +42,7 @@ typedef struct SRSLTE_API {
uint32_t nof_rx_antennas;
uint32_t max_re;
uint16_t ue_rnti;
bool is_ue;
bool is_ue;
bool llr_is_8bit;
@ -70,11 +63,6 @@ typedef struct SRSLTE_API {
srslte_evm_buffer_t* evm_buffer[SRSLTE_MAX_CODEWORDS];
float avg_evm;
// This is to generate the scrambling seq for multiple CRNTIs
srslte_pdsch_user_t** users;
srslte_sequence_t tmp_seq;
srslte_sch_t dl_sch;
void* coworker_ptr;
@ -99,10 +87,6 @@ SRSLTE_API int srslte_pdsch_enable_coworker(srslte_pdsch_t* q);
SRSLTE_API int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell);
SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t* q, uint16_t rnti);
SRSLTE_API void srslte_pdsch_free_rnti(srslte_pdsch_t* q, uint16_t rnti);
/* These functions do not modify the state and run in real-time */
SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t* q,
srslte_dl_sf_cfg_t* sf,

@ -49,12 +49,6 @@
#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT3 (0.5f)
#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_DMRS (0.4f)
typedef struct {
srslte_sequence_t seq_f2[SRSLTE_NOF_SF_X_FRAME];
uint32_t cell_id;
bool sequence_generated;
} srslte_pucch_user_t;
/* PUCCH object */
typedef struct SRSLTE_API {
srslte_cell_t cell;
@ -62,10 +56,8 @@ typedef struct SRSLTE_API {
srslte_uci_cqi_pucch_t cqi;
srslte_pucch_user_t** users;
srslte_sequence_t tmp_seq;
uint16_t ue_rnti;
bool is_ue;
srslte_sequence_t seq_f2;
bool is_ue;
int16_t llr[SRSLTE_PUCCH3_NOF_BITS];
uint8_t bits_scram[SRSLTE_PUCCH_MAX_BITS];
@ -100,10 +92,6 @@ SRSLTE_API void srslte_pucch_free(srslte_pucch_t* q);
/* These functions modify the state of the object and may take some time */
SRSLTE_API int srslte_pucch_set_cell(srslte_pucch_t* q, srslte_cell_t cell);
SRSLTE_API int srslte_pucch_set_rnti(srslte_pucch_t* q, uint16_t rnti);
SRSLTE_API void srslte_pucch_free_rnti(srslte_pucch_t* q, uint16_t rnti);
/* These functions do not modify the state and run in real-time */
SRSLTE_API void srslte_pucch_uci_gen_cfg(srslte_pucch_t* q, srslte_pucch_cfg_t* cfg, srslte_uci_data_t* uci_data);

@ -36,12 +36,6 @@
#include "srslte/phy/phch/sch.h"
#include "srslte/phy/scrambling/scrambling.h"
typedef struct {
srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME];
uint32_t cell_id;
bool sequence_generated;
} srslte_pusch_user_t;
/* PUSCH object */
typedef struct SRSLTE_API {
srslte_cell_t cell;
@ -67,10 +61,6 @@ typedef struct SRSLTE_API {
srslte_modem_table_t mod[SRSLTE_MOD_NITEMS];
srslte_sch_t ul_sch;
// This is to generate the scrambling seq for multiple CRNTIs
srslte_pusch_user_t** users;
srslte_sequence_t tmp_seq;
// EVM buffer
srslte_evm_buffer_t* evm_buffer;
@ -99,10 +89,6 @@ SRSLTE_API void srslte_pusch_free(srslte_pusch_t* q);
/* These functions modify the state of the object and may take some time */
SRSLTE_API int srslte_pusch_set_cell(srslte_pusch_t* q, srslte_cell_t cell);
SRSLTE_API int srslte_pusch_set_rnti(srslte_pusch_t* q, uint16_t rnti);
SRSLTE_API void srslte_pusch_free_rnti(srslte_pusch_t* q, uint16_t rnti);
/**
* Asserts PUSCH grant attributes are in range
* @param grant Pointer to PUSCH grant

@ -70,7 +70,6 @@ typedef struct SRSLTE_API {
srslte_cell_t cell;
uint32_t nof_rx_antennas;
uint16_t current_mbsfn_area_id;
uint16_t pregen_rnti;
// Objects for all DL Physical Channels
srslte_pcfich_t pcfich;
@ -91,13 +90,11 @@ typedef struct SRSLTE_API {
srslte_ofdm_t fft_mbsfn;
// Buffers to store channel symbols after demodulation
cf_t* sf_symbols[SRSLTE_MAX_PORTS];
cf_t* sf_symbols[SRSLTE_MAX_PORTS];
dci_blind_search_t current_ss_common;
// Variables for blind DCI search
dci_blind_search_t current_ss_ue[SRSLTE_MI_MAX_REGS][SRSLTE_NOF_CFI][SRSLTE_NOF_SF_X_FRAME];
dci_blind_search_t current_ss_common[SRSLTE_MI_MAX_REGS][SRSLTE_NOF_CFI];
srslte_dci_msg_t pending_ul_dci_msg[SRSLTE_MAX_DCI_MSG];
uint32_t pending_ul_dci_count;
srslte_dci_msg_t pending_ul_dci_msg[SRSLTE_MAX_DCI_MSG];
uint32_t pending_ul_dci_count;
srslte_dci_location_t allocated_locations[SRSLTE_MAX_DCI_MSG];
uint32_t nof_allocated_locations;
@ -158,8 +155,6 @@ SRSLTE_API void srslte_ue_dl_free(srslte_ue_dl_t* q);
SRSLTE_API int srslte_ue_dl_set_cell(srslte_ue_dl_t* q, srslte_cell_t cell);
SRSLTE_API void srslte_ue_dl_set_rnti(srslte_ue_dl_t* q, uint16_t rnti);
SRSLTE_API int srslte_ue_dl_set_mbsfn_area_id(srslte_ue_dl_t* q, uint16_t mbsfn_area_id);
SRSLTE_API void srslte_ue_dl_set_non_mbsfn_region(srslte_ue_dl_t* q, uint8_t non_mbsfn_region_length);

@ -70,7 +70,6 @@ typedef enum {
} srslte_ue_ul_normalize_mode_t;
typedef struct SRSLTE_API {
srslte_ul_cfg_t ul_cfg;
bool grant_available;
uint32_t cc_idx;
@ -86,8 +85,7 @@ typedef struct SRSLTE_API {
typedef struct SRSLTE_API {
srslte_cell_t cell;
uint16_t current_rnti;
bool signals_pregenerated;
bool signals_pregenerated;
srslte_ofdm_t fft;
srslte_cfo_t cfo;
@ -114,8 +112,6 @@ SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t* q);
SRSLTE_API int srslte_ue_ul_set_cell(srslte_ue_ul_t* q, srslte_cell_t cell);
SRSLTE_API void srslte_ue_ul_set_rnti(srslte_ue_ul_t* q, uint16_t rnti);
SRSLTE_API int srslte_ue_ul_pregen_signals(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg);
SRSLTE_API int srslte_ue_ul_dci_to_pusch_grant(srslte_ue_ul_t* q,

@ -37,7 +37,7 @@
/**
* Parallel bit generation for x1/x2 sequences parameters. Exploits the fact that the sequence generation is 31 chips
* ahead and the maximum register shift is 3 (for x2).
* ahead and the maximum register shift is 3 (for x2). The maximum number of parallel bits is 28, 16 is optimal for SSE.
*/
#define SEQUENCE_PAR_BITS (28U)
#define SEQUENCE_MASK ((1U << SEQUENCE_PAR_BITS) - 1U)
@ -142,7 +142,6 @@ static uint32_t sequence_x2_init[SEQUENCE_SEED_LEN] = {};
*/
__attribute__((constructor)) __attribute__((unused)) static void srslte_lte_pr_pregen()
{
// Compute transition step
sequence_x1_init = 1;
for (uint32_t n = 0; n < SEQUENCE_NC; n++) {
@ -299,7 +298,6 @@ int srslte_sequence_set_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed
static inline void
sequence_generate_signed(const uint8_t* c_unpacked, int8_t* c_char, int16_t* c_short, float* c_float, uint32_t len)
{
int i = 0;
#ifdef LV_HAVE_SSE
@ -476,7 +474,6 @@ void srslte_sequence_apply_f(const float* in, float* out, uint32_t length, uint3
}
for (; i < length; i++) {
((uint32_t*)out)[i] = ((uint32_t*)in)[i] ^ (((x1 ^ x2) & 1U) << 31U);
// Step sequences
@ -487,8 +484,9 @@ void srslte_sequence_apply_f(const float* in, float* out, uint32_t length, uint3
void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, uint32_t seed)
{
uint32_t x1 = sequence_x1_init; // X1 initial state is fix
uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state
const int16_t s[2] = {+1, -1};
uint32_t x1 = sequence_x1_init; // X1 initial state is fix
uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state
uint32_t i = 0;
@ -520,9 +518,9 @@ void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, u
_mm_storeu_si128((__m128i*)(out + i + j), v);
}
#endif
#endif /* LV_HAVE_SSE */
for (; j < SEQUENCE_PAR_BITS; j++) {
out[i + j] = in[i + j] * (((c >> j) & 1U) ? -1 : +1);
out[i + j] = in[i + j] * s[(c >> j) & 1U];
}
// Step sequences
@ -532,7 +530,7 @@ void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, u
}
for (; i < length; i++) {
out[i] = in[i] * (((x1 ^ x2) & 1U) ? -1 : +1);
out[i] = in[i] * s[(x1 ^ x2) & 1U];
// Step sequences
x1 = sequence_gen_LTE_pr_memless_step_x1(x1);
@ -659,14 +657,11 @@ void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length,
}
}
void srslte_sequence_apply_bit_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed)
void srslte_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed)
{
uint32_t x1 = sequence_x1_init; // X1 initial state is fix
uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state
uint64_t buffer = 0;
uint32_t count = 0;
const uint8_t reverse_lut[256] = {
0b00000000, 0b10000000, 0b01000000, 0b11000000, 0b00100000, 0b10100000, 0b01100000, 0b11100000, 0b00010000,
0b10010000, 0b01010000, 0b11010000, 0b00110000, 0b10110000, 0b01110000, 0b11110000, 0b00001000, 0b10001000,
@ -699,6 +694,10 @@ void srslte_sequence_apply_bit_packed(const uint8_t* in, uint8_t* out, uint32_t
0b00111111, 0b10111111, 0b01111111, 0b11111111,
};
#if SEQUENCE_PAR_BITS % 8 != 0
uint64_t buffer = 0;
uint32_t count = 0;
for (uint32_t i = 0; i < length / 8; i++) {
// Generate sequence bits
while (count < 8) {
@ -718,4 +717,27 @@ void srslte_sequence_apply_bit_packed(const uint8_t* in, uint8_t* out, uint32_t
buffer = buffer >> 8UL;
count -= 8;
}
#else /* SEQUENCE_PAR_BITS % 8 == 0 */
uint32_t i = 0;
while (i < (length / 8 - (SEQUENCE_PAR_BITS - 1) / 8)) {
uint32_t c = (uint32_t)(x1 ^ x2);
for (uint32_t j = 0; j < SEQUENCE_PAR_BITS / 8; j++) {
out[i] = in[i] ^ reverse_lut[c & 255U];
c = c >> 8U;
i++;
}
// Step sequences
x1 = sequence_gen_LTE_pr_memless_step_par_x1(x1);
x2 = sequence_gen_LTE_pr_memless_step_par_x2(x2);
}
uint32_t c = (uint32_t)(x1 ^ x2);
while (i < length / 8) {
out[i] = in[i] ^ reverse_lut[c & 255U];
c = c >> 8U;
i++;
}
#endif /* SEQUENCE_PAR_BITS % 8 == 0 */
}

@ -143,7 +143,7 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le
// Test in-place packed XOR
gettimeofday(&t[1], NULL);
for (uint32_t r = 0; r < repetitions; r++) {
srslte_sequence_apply_bit_packed(ones_packed, c_packed, length, seed);
srslte_sequence_apply_packed(ones_packed, c_packed, length, seed);
}
gettimeofday(&t[2], NULL);
get_time_interval(t);

@ -223,16 +223,6 @@ int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell)
return ret;
}
int srslte_enb_dl_add_rnti(srslte_enb_dl_t* q, uint16_t rnti)
{
return srslte_pdsch_set_rnti(&q->pdsch, rnti);
}
void srslte_enb_dl_rem_rnti(srslte_enb_dl_t* q, uint16_t rnti)
{
srslte_pdsch_free_rnti(&q->pdsch, rnti);
}
#ifdef resolve
void srslte_enb_dl_apply_power_allocation(srslte_enb_dl_t* q)
{

@ -139,25 +139,6 @@ int srslte_enb_ul_set_cell(srslte_enb_ul_t* q,
return ret;
}
int srslte_enb_ul_add_rnti(srslte_enb_ul_t* q, uint16_t rnti)
{
if (srslte_pucch_set_rnti(&q->pucch, rnti)) {
ERROR("Error setting PUCCH rnti");
return -1;
}
if (srslte_pusch_set_rnti(&q->pusch, rnti)) {
ERROR("Error setting PUSCH rnti");
return -1;
}
return 0;
}
void srslte_enb_ul_rem_rnti(srslte_enb_ul_t* q, uint16_t rnti)
{
srslte_pucch_free_rnti(&q->pucch, rnti);
srslte_pusch_free_rnti(&q->pusch, rnti);
}
void srslte_enb_ul_fft(srslte_enb_ul_t* q)
{
srslte_ofdm_rx_sf(&q->fft);

@ -312,16 +312,6 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t
}
}
q->users = calloc(sizeof(srslte_pdsch_user_t*), q->is_ue ? 1 : (1 + SRSLTE_SIRNTI));
if (!q->users) {
ERROR("malloc");
goto clean;
}
if (srslte_sequence_init(&q->tmp_seq, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_256QAM))) {
goto clean;
}
for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
if (!q->csi[i]) {
q->csi[i] = srslte_vec_f_malloc(q->max_re * 2);
@ -450,20 +440,6 @@ void srslte_pdsch_free(srslte_pdsch_t* q)
}
}
}
if (q->users) {
if (q->is_ue) {
srslte_pdsch_free_rnti(q, 0);
} else {
for (int u = 0; u <= SRSLTE_SIRNTI; u++) {
if (q->users[u]) {
srslte_pdsch_free_rnti(q, u);
}
}
}
free(q->users);
}
srslte_sequence_free(&q->tmp_seq);
for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) {
srslte_modem_table_free(&q->mod[i]);
@ -498,68 +474,6 @@ int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell)
return ret;
}
/* Precalculate the PDSCH scramble sequences for a given RNTI. This function takes a while
* to execute, so shall be called once the final C-RNTI has been allocated for the session.
*/
int srslte_pdsch_set_rnti(srslte_pdsch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
// Decide whether re-generating the sequence
if (!q->users[rnti_idx]) {
// If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user");
return SRSLTE_ERROR;
}
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
// The sequence was generated, cell has not changed and it is eNb, save any efforts
return SRSLTE_SUCCESS;
}
// Set sequence as not generated
q->users[rnti_idx]->sequence_generated = false;
// For each subframe
for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
// For each codeword
for (int j = 0; j < SRSLTE_MAX_CODEWORDS; j++) {
if (srslte_sequence_pdsch(&q->users[rnti_idx]->seq[j][sf_idx],
rnti,
j,
SRSLTE_NOF_SLOTS_PER_SF * sf_idx,
q->cell.id,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_256QAM))) {
ERROR("Error initializing PDSCH scrambling sequence");
srslte_pdsch_free_rnti(q, rnti);
return SRSLTE_ERROR;
}
}
}
// Save generation states
q->ue_rnti = rnti;
q->users[rnti_idx]->cell_id = q->cell.id;
q->users[rnti_idx]->sequence_generated = true;
return SRSLTE_SUCCESS;
}
void srslte_pdsch_free_rnti(srslte_pdsch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
if (q->users[rnti_idx]) {
for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
for (int j = 0; j < SRSLTE_MAX_CODEWORDS; j++) {
srslte_sequence_free(&q->users[rnti_idx]->seq[j][i]);
}
}
free(q->users[rnti_idx]);
q->users[rnti_idx] = NULL;
q->ue_rnti = 0;
}
}
static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, cf_t* sf_symbols_m[SRSLTE_MAX_PORTS])
{
uint32_t nof_symbols_slot = cfg->grant.nof_symb_slot[0];
@ -597,21 +511,6 @@ static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg,
return rho_a;
}
static srslte_sequence_t*
get_user_sequence(srslte_pdsch_t* q, uint16_t rnti, uint32_t codeword_idx, uint32_t sf_idx, uint32_t len)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
// The scrambling sequence is pregenerated for all RNTIs in the eNodeB but only for C-RNTI in the UE
if (q->users[rnti_idx] && q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id &&
(!q->is_ue || q->ue_rnti == rnti)) {
return &q->users[rnti_idx]->seq[codeword_idx][sf_idx];
} else {
srslte_sequence_pdsch(&q->tmp_seq, rnti, codeword_idx, 2 * sf_idx, q->cell.id, len);
return &q->tmp_seq;
}
}
static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t codeword_idx, uint32_t tb_idx, void* e)
{
uint32_t qm = 0;
@ -821,19 +720,23 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q,
data[tb_idx].evm = NAN;
}
/* Select scrambling sequence */
srslte_sequence_t* seq =
get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits);
if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1;
}
/* Bit scrambling */
if (q->llr_is_8bit) {
srslte_scrambling_sb_offset(seq, q->e[codeword_idx], 0, cfg->grant.tb[tb_idx].nof_bits);
srslte_sequence_pdsch_apply_c(q->e[codeword_idx],
q->e[codeword_idx],
cfg->rnti,
codeword_idx,
2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME),
q->cell.id,
cfg->grant.tb[tb_idx].nof_bits);
} else {
srslte_scrambling_s_offset(seq, q->e[codeword_idx], 0, cfg->grant.tb[tb_idx].nof_bits);
srslte_sequence_pdsch_apply_s(q->e[codeword_idx],
q->e[codeword_idx],
cfg->rnti,
codeword_idx,
2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME),
q->cell.id,
cfg->grant.tb[tb_idx].nof_bits);
}
if (cfg->csi_enable) {
@ -1098,16 +1001,14 @@ static int srslte_pdsch_codeword_encode(srslte_pdsch_t* q,
return SRSLTE_ERROR;
}
/* Select scrambling sequence */
srslte_sequence_t* seq =
get_user_sequence(q, cfg->rnti, codeword_idx, sf->tti % 10, cfg->grant.tb[tb_idx].nof_bits);
if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1;
}
/* Bit scrambling */
srslte_scrambling_bytes(seq, (uint8_t*)q->e[codeword_idx], cfg->grant.tb[tb_idx].nof_bits);
srslte_sequence_pdsch_apply_pack((uint8_t*)q->e[codeword_idx],
(uint8_t*)q->e[codeword_idx],
cfg->rnti,
codeword_idx,
2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME),
q->cell.id,
cfg->grant.tb[tb_idx].nof_bits);
/* Bit mapping */
srslte_mod_modulate_bytes(

@ -49,13 +49,7 @@ int srslte_pucch_init_(srslte_pucch_t* q, bool is_ue)
q->is_ue = is_ue;
q->users = calloc(sizeof(srslte_pucch_user_t*), q->is_ue ? 1 : (1 + SRSLTE_SIRNTI));
if (!q->users) {
perror("malloc");
goto clean_exit;
}
if (srslte_sequence_init(&q->tmp_seq, 20)) {
if (srslte_sequence_init(&q->seq_f2, 20)) {
goto clean_exit;
}
@ -89,18 +83,7 @@ int srslte_pucch_init_enb(srslte_pucch_t* q)
void srslte_pucch_free(srslte_pucch_t* q)
{
if (q->users) {
if (q->is_ue) {
srslte_pucch_free_rnti(q, 0);
} else {
for (int rnti = 0; rnti <= SRSLTE_SIRNTI; rnti++) {
srslte_pucch_free_rnti(q, rnti);
}
}
free(q->users);
}
srslte_sequence_free(&q->tmp_seq);
srslte_sequence_free(&q->seq_f2);
srslte_uci_cqi_pucch_free(&q->cqi);
if (q->z) {
@ -139,58 +122,6 @@ int srslte_pucch_set_cell(srslte_pucch_t* q, srslte_cell_t cell)
return ret;
}
void srslte_pucch_free_rnti(srslte_pucch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
if (q->users[rnti_idx]) {
for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
srslte_sequence_free(&q->users[rnti_idx]->seq_f2[i]);
}
free(q->users[rnti_idx]);
q->users[rnti_idx] = NULL;
q->ue_rnti = 0;
}
}
int srslte_pucch_set_rnti(srslte_pucch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
// Decide whether re-generating the sequence
if (!q->users[rnti_idx]) {
// If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user");
return SRSLTE_ERROR;
}
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
// The sequence was generated, cell has not changed and it is eNb, save any efforts
return SRSLTE_SUCCESS;
}
// Set sequence as not generated
q->users[rnti_idx]->sequence_generated = false;
// For each subframe
for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
if (srslte_sequence_pucch(
&q->users[rnti_idx]->seq_f2[sf_idx], rnti, SRSLTE_NOF_SLOTS_PER_SF * sf_idx, q->cell.id)) {
ERROR("Error initializing PUCCH scrambling sequence");
srslte_pucch_free_rnti(q, rnti);
return SRSLTE_ERROR;
}
}
// Save generation states
q->ue_rnti = rnti;
q->users[rnti_idx]->cell_id = q->cell.id;
q->users[rnti_idx]->sequence_generated = true;
return SRSLTE_SUCCESS;
}
static cf_t uci_encode_format1()
{
return 1.0;
@ -218,34 +149,11 @@ static cf_t uci_encode_format1b(uint8_t bits[2])
}
}
static srslte_sequence_t* get_user_sequence(srslte_pucch_t* q, uint16_t rnti, uint32_t sf_idx)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
// The scrambling sequence is pregenerated for all RNTIs in the eNodeB but only for C-RNTI in the UE
if (rnti >= SRSLTE_CRNTI_START && rnti < SRSLTE_CRNTI_END) {
if (q->users[rnti_idx] && q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id &&
(!q->is_ue || q->ue_rnti == rnti)) {
return &q->users[rnti_idx]->seq_f2[sf_idx];
} else {
if (srslte_sequence_pucch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence");
return NULL;
}
return &q->tmp_seq;
}
} else {
ERROR("Invalid RNTI=0x%x", rnti);
return NULL;
}
}
/* Encode PUCCH bits according to Table 5.4.1-1 in Section 5.4.1 of 36.211 */
static int
uci_mod_bits(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg, uint8_t bits[SRSLTE_PUCCH_MAX_BITS])
{
uint8_t tmp[2];
srslte_sequence_t* seq;
uint8_t tmp[2];
switch (cfg->format) {
case SRSLTE_PUCCH_FORMAT_1:
q->d[0] = uci_encode_format1();
@ -261,26 +169,22 @@ uci_mod_bits(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg,
case SRSLTE_PUCCH_FORMAT_2:
case SRSLTE_PUCCH_FORMAT_2A:
case SRSLTE_PUCCH_FORMAT_2B:
seq = get_user_sequence(q, cfg->rnti, sf->tti % 10);
if (seq) {
memcpy(q->bits_scram, bits, SRSLTE_PUCCH2_NOF_BITS * sizeof(uint8_t));
srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH2_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH2_NOF_BITS);
} else {
ERROR("Error modulating PUCCH2 bits: could not generate sequence");
return -1;
if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence\n");
return SRSLTE_ERROR;
}
srslte_vec_u8_copy(q->bits_scram, bits, SRSLTE_PUCCH2_NOF_BITS);
srslte_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSLTE_PUCCH2_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH2_NOF_BITS);
break;
case SRSLTE_PUCCH_FORMAT_3:
seq = get_user_sequence(q, cfg->rnti, sf->tti % 10);
if (seq) {
memcpy(q->bits_scram, bits, SRSLTE_PUCCH3_NOF_BITS * sizeof(uint8_t));
srslte_scrambling_b_offset(seq, q->bits_scram, 0, SRSLTE_PUCCH3_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH3_NOF_BITS);
} else {
ERROR("Error modulating PUCCH3 bits: rnti not set");
if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence\n");
return SRSLTE_ERROR;
}
srslte_vec_u8_copy(q->bits_scram, bits, SRSLTE_PUCCH3_NOF_BITS);
srslte_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSLTE_PUCCH3_NOF_BITS);
srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH3_NOF_BITS);
break;
default:
ERROR("PUCCH format %s not supported", srslte_pucch_format_text(cfg->format));
@ -632,19 +536,15 @@ static int decode_signal_format3(srslte_pucch_t* q,
srslte_vec_sc_prod_cfc(q->d, 2.0f / (N_sf_0 + N_sf_1), q->d, SRSLTE_NRE * 2);
srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10);
if (seq) {
srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->d, q->llr, SRSLTE_PUCCH3_NOF_BITS);
srslte_scrambling_s_offset(seq, q->llr, 0, SRSLTE_PUCCH3_NOF_BITS);
srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->d, q->llr, SRSLTE_PUCCH3_NOF_BITS);
return (int)srslte_block_decode_i16(q->llr, SRSLTE_PUCCH3_NOF_BITS, bits, SRSLTE_UCI_MAX_ACK_SR_BITS);
} else {
ERROR("Error modulating PUCCH3 bits: rnti not set");
if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence\n");
return SRSLTE_ERROR;
}
srslte_scrambling_s_offset(&q->seq_f2, q->llr, 0, SRSLTE_PUCCH3_NOF_BITS);
return SRSLTE_SUCCESS;
return (int)srslte_block_decode_i16(q->llr, SRSLTE_PUCCH3_NOF_BITS, bits, SRSLTE_UCI_MAX_ACK_SR_BITS);
}
static int encode_signal(srslte_pucch_t* q,
@ -716,8 +616,7 @@ static bool decode_signal(srslte_pucch_t* q,
float corr = 0, corr_max = -1e9;
uint8_t b_max = 0, b2_max = 0; // default bit value, eg. HI is NACK
srslte_sequence_t* seq;
cf_t ref[SRSLTE_PUCCH_MAX_SYMBOLS];
cf_t ref[SRSLTE_PUCCH_MAX_SYMBOLS];
switch (cfg->format) {
case SRSLTE_PUCCH_FORMAT_1:
@ -772,30 +671,28 @@ static bool decode_signal(srslte_pucch_t* q,
case SRSLTE_PUCCH_FORMAT_2:
case SRSLTE_PUCCH_FORMAT_2A:
case SRSLTE_PUCCH_FORMAT_2B:
seq = get_user_sequence(q, cfg->rnti, sf->tti % SRSLTE_NOF_SF_X_FRAME);
if (seq) {
encode_signal_format12(q, sf, cfg, NULL, ref, true);
srslte_vec_prod_conj_ccc(q->z, ref, q->z_tmp, SRSLTE_PUCCH_MAX_SYMBOLS);
for (int i = 0; i < (SRSLTE_PUCCH2_N_SF * SRSLTE_NOF_SLOTS_PER_SF); i++) {
q->z[i] = srslte_vec_acc_cc(&q->z_tmp[i * SRSLTE_NRE], SRSLTE_NRE) / SRSLTE_NRE;
}
srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->z, llr_pucch2, SRSLTE_PUCCH2_NOF_BITS / 2);
srslte_scrambling_s_offset(seq, llr_pucch2, 0, SRSLTE_PUCCH2_NOF_BITS);
if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) {
ERROR("Error computing PUCCH Format 2 scrambling sequence\n");
return SRSLTE_ERROR;
}
encode_signal_format12(q, sf, cfg, NULL, ref, true);
srslte_vec_prod_conj_ccc(q->z, ref, q->z_tmp, SRSLTE_PUCCH_MAX_SYMBOLS);
for (int i = 0; i < (SRSLTE_PUCCH2_N_SF * SRSLTE_NOF_SLOTS_PER_SF); i++) {
q->z[i] = srslte_vec_acc_cc(&q->z_tmp[i * SRSLTE_NRE], SRSLTE_NRE) / SRSLTE_NRE;
}
srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->z, llr_pucch2, SRSLTE_PUCCH2_NOF_BITS / 2);
srslte_scrambling_s_offset(&q->seq_f2, llr_pucch2, 0, SRSLTE_PUCCH2_NOF_BITS);
// Calculate the LLR RMS for normalising
float llr_pow = srslte_vec_avg_power_sf(llr_pucch2, SRSLTE_PUCCH2_NOF_BITS);
// Calculate the LLR RMS for normalising
float llr_pow = srslte_vec_avg_power_sf(llr_pucch2, SRSLTE_PUCCH2_NOF_BITS);
if (isnormal(llr_pow)) {
float llr_rms = sqrtf(llr_pow) * SRSLTE_PUCCH2_NOF_BITS;
corr = ((float)srslte_uci_decode_cqi_pucch(&q->cqi, llr_pucch2, pucch_bits, nof_uci_bits)) / (llr_rms);
} else {
corr = 0;
}
detected = true;
if (isnormal(llr_pow)) {
float llr_rms = sqrtf(llr_pow) * SRSLTE_PUCCH2_NOF_BITS;
corr = ((float)srslte_uci_decode_cqi_pucch(&q->cqi, llr_pucch2, pucch_bits, nof_uci_bits)) / (llr_rms);
} else {
ERROR("Decoding PUCCH2: could not generate sequence");
return -1;
corr = 0;
}
detected = true;
break;
case SRSLTE_PUCCH_FORMAT_3:
corr = (float)decode_signal_format3(q, sf, cfg, pucch_bits, q->z) / 4800.0f;

@ -116,16 +116,6 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
q->is_ue = is_ue;
q->users = calloc(sizeof(srslte_pusch_user_t*), q->is_ue ? 1 : (1 + SRSLTE_SIRNTI));
if (!q->users) {
perror("malloc");
goto clean;
}
if (srslte_sequence_init(&q->tmp_seq, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
goto clean;
}
srslte_sch_init(&q->ul_sch);
if (srslte_dft_precoding_init(&q->dft_precoding, max_prb, is_ue)) {
@ -210,19 +200,6 @@ void srslte_pusch_free(srslte_pusch_t* q)
}
srslte_dft_precoding_free(&q->dft_precoding);
if (q->users) {
if (q->is_ue) {
srslte_pusch_free_rnti(q, 0);
} else {
for (int rnti = 0; rnti <= SRSLTE_SIRNTI; rnti++) {
srslte_pusch_free_rnti(q, rnti);
}
}
free(q->users);
}
srslte_sequence_free(&q->tmp_seq);
for (i = 0; i < SRSLTE_MOD_NITEMS; i++) {
srslte_modem_table_free(&q->mod[i]);
}
@ -248,86 +225,6 @@ int srslte_pusch_set_cell(srslte_pusch_t* q, srslte_cell_t cell)
return ret;
}
/* Precalculate the PUSCH scramble sequences for a given RNTI. This function takes a while
* to execute, so shall be called once the final C-RNTI has been allocated for the session.
* For the connection procedure, use srslte_pusch_encode() functions */
int srslte_pusch_set_rnti(srslte_pusch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
// Decide whether re-generating the sequence
if (!q->users[rnti_idx]) {
// If the sequence is not allocated generate
q->users[rnti_idx] = calloc(1, sizeof(srslte_pdsch_user_t));
if (!q->users[rnti_idx]) {
ERROR("Alocating PDSCH user");
return SRSLTE_ERROR;
}
} else if (q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id && !q->is_ue) {
// The sequence was generated, cell has not changed and it is eNb, save any efforts
return SRSLTE_SUCCESS;
}
// Set sequence as not generated
q->users[rnti_idx]->sequence_generated = false;
// For each subframe
for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
if (srslte_sequence_pusch(&q->users[rnti_idx]->seq[sf_idx],
rnti,
SRSLTE_NOF_SLOTS_PER_SF * sf_idx,
q->cell.id,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
ERROR("Error initializing PUSCH scrambling sequence");
srslte_pusch_free_rnti(q, rnti);
return SRSLTE_ERROR;
}
}
// Save generation states
q->ue_rnti = rnti;
q->users[rnti_idx]->cell_id = q->cell.id;
q->users[rnti_idx]->sequence_generated = true;
return SRSLTE_SUCCESS;
}
void srslte_pusch_free_rnti(srslte_pusch_t* q, uint16_t rnti)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
if (q->users[rnti_idx]) {
for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
srslte_sequence_free(&q->users[rnti_idx]->seq[i]);
}
free(q->users[rnti_idx]);
q->users[rnti_idx] = NULL;
q->ue_rnti = 0;
}
}
static srslte_sequence_t* get_user_sequence(srslte_pusch_t* q, uint16_t rnti, uint32_t sf_idx, uint32_t len)
{
uint32_t rnti_idx = q->is_ue ? 0 : rnti;
if (SRSLTE_RNTI_ISUSER(rnti)) {
// The scrambling sequence is pregenerated for all RNTIs in the eNodeB but only for C-RNTI in the UE
if (q->users[rnti_idx] && q->users[rnti_idx]->sequence_generated && q->users[rnti_idx]->cell_id == q->cell.id &&
(!q->is_ue || q->ue_rnti == rnti)) {
return &q->users[rnti_idx]->seq[sf_idx];
} else {
if (srslte_sequence_pusch(&q->tmp_seq, rnti, 2 * sf_idx, q->cell.id, len)) {
ERROR("Error generating temporal scrambling sequence");
return NULL;
}
return &q->tmp_seq;
}
} else {
ERROR("Invalid RNTI=0x%x", rnti);
return NULL;
}
}
int srslte_pusch_assert_grant(const srslte_pusch_grant_t* grant)
{
// Check for valid number of PRB
@ -398,15 +295,13 @@ int srslte_pusch_encode(srslte_pusch_t* q,
uint32_t nof_ri_ack_bits = (uint32_t)ret;
// Generate scrambling sequence if not pre-generated
srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits);
if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1;
}
// Run scrambling
srslte_scrambling_bytes(seq, (uint8_t*)q->q, cfg->grant.tb.nof_bits);
srslte_sequence_pusch_apply_pack((uint8_t*)q->q,
(uint8_t*)q->q,
cfg->rnti,
2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME),
q->cell.id,
cfg->grant.tb.nof_bits);
// Correct UCI placeholder/repetition bits
uint8_t* d = q->q;
@ -528,25 +423,25 @@ int srslte_pusch_decode(srslte_pusch_t* q,
out->evm = NAN;
}
// Generate scrambling sequence if not pre-generated
srslte_sequence_t* seq = get_user_sequence(q, cfg->rnti, sf->tti % 10, cfg->grant.tb.nof_bits);
if (!seq) {
ERROR("Error getting user sequence for rnti=0x%x", cfg->rnti);
return -1;
}
// Descrambling
if (q->llr_is_8bit) {
srslte_scrambling_sb_offset(seq, q->q, 0, cfg->grant.tb.nof_bits);
srslte_sequence_pusch_apply_c(
q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits);
} else {
srslte_scrambling_s_offset(seq, q->q, 0, cfg->grant.tb.nof_bits);
srslte_sequence_pusch_apply_s(
q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits);
}
// Generate packed sequence for UCI decoder
uint8_t* c = (uint8_t*)q->z; // Reuse Z
srslte_sequence_pusch_gen_unpack(
c, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits);
// Set max number of iterations
srslte_sch_set_max_noi(&q->ul_sch, cfg->max_nof_iterations);
// Decode
ret = srslte_ulsch_decode(&q->ul_sch, cfg, q->q, q->g, seq->c, out->data, &out->uci);
ret = srslte_ulsch_decode(&q->ul_sch, cfg, q->q, q->g, c, out->data, &out->uci);
out->crc = (ret == 0);
// Save number of iterations

@ -1118,10 +1118,6 @@ int srslte_ulsch_decode(srslte_sch_t* q,
uint32_t Q_prime_ri = (uint32_t)ret;
/*
if (cfg->uci_cfg.cqi.data_enable) {
printf("deinter_input: Qm=%d, nb_q=%d, nof_symb=%d, Q_prime_ri=%d\n", Qm, nb_q, cfg->grant.nof_symb, Q_prime_ri);
}*/
// Deinterleave data and CQI in ULSCH
ulsch_deinterleave(q_bits,
Qm,
@ -1248,13 +1244,8 @@ int srslte_ulsch_encode(srslte_sch_t* q,
}
Q_prime_cqi = (uint32_t)ret;
/*
if (Q_prime_cqi) {
printf("Encoding cqi Q=%d: ", Q_prime_cqi*Qm);
srslte_vec_fprint_b(stdout, q->temp_g_bits, Q_prime_cqi*Qm);
}*/
srslte_bit_pack_vector(q->temp_g_bits, g_bits, Q_prime_cqi * Qm);
// Reset the buffer because will be reused in ulsch_interleave
srslte_vec_u8_zero(q->temp_g_bits, Q_prime_cqi * Qm);
}

@ -12,6 +12,7 @@
#include "srslte/phy/common/phy_common.h"
#include "srslte/phy/common/sequence.h"
#include "srslte/phy/utils/vector.h"
#include <strings.h>
/**
@ -49,17 +50,108 @@ int srslte_sequence_pdcch(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_
/**
* 36.211 6.3.1
*/
static inline uint32_t sequence_pdsch_seed(uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id)
{
return (rnti << 14) + (q << 13) + ((nslot / 2) << 9) + cell_id;
}
int srslte_sequence_pdsch(srslte_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len)
{
return srslte_sequence_LTE_pr(seq, len, (rnti << 14) + (q << 13) + ((nslot / 2) << 9) + cell_id);
return srslte_sequence_LTE_pr(seq, len, sequence_pdsch_seed(rnti, q, nslot, cell_id));
}
void srslte_sequence_pdsch_apply_pack(const uint8_t* in,
uint8_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_packed(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id));
}
void srslte_sequence_pdsch_apply_f(const float* in,
float* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_f(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id));
}
void srslte_sequence_pdsch_apply_s(const int16_t* in,
int16_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_s(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id));
}
void srslte_sequence_pdsch_apply_c(const int8_t* in,
int8_t* out,
uint16_t rnti,
int q,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_c(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id));
}
/**
* 36.211 5.3.1
*/
static inline uint32_t sequence_pusch_seed(uint16_t rnti, uint32_t nslot, uint32_t cell_id)
{
return (rnti << 14) + ((nslot / 2) << 9) + cell_id;
}
int srslte_sequence_pusch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len)
{
return srslte_sequence_LTE_pr(seq, len, (rnti << 14) + ((nslot / 2) << 9) + cell_id);
return srslte_sequence_LTE_pr(seq, len, sequence_pusch_seed(rnti, nslot, cell_id));
}
void srslte_sequence_pusch_apply_pack(const uint8_t* in,
uint8_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_packed(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id));
}
void srslte_sequence_pusch_apply_s(const int16_t* in,
int16_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_s(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id));
}
void srslte_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len)
{
srslte_vec_u8_zero(out, len);
srslte_sequence_apply_bit(out, out, len, sequence_pusch_seed(rnti, nslot, cell_id));
}
void srslte_sequence_pusch_apply_c(const int8_t* in,
int8_t* out,
uint16_t rnti,
uint32_t nslot,
uint32_t cell_id,
uint32_t len)
{
srslte_sequence_apply_c(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id));
}
/**

@ -136,8 +136,6 @@ int base_init()
return -1;
}
srslte_ue_dl_set_rnti(&ue_dl, rnti);
DEBUG("Memory init OK");
return 0;
}

@ -149,16 +149,14 @@ static int check_softbits(srslte_pdsch_t* pdsch_enb,
int ret = SRSLTE_SUCCESS;
if (!pdsch_ue->llr_is_8bit && !tb_cw_swap) {
// Generate sequence
srslte_sequence_pdsch(&pdsch_ue->tmp_seq,
rnti,
pdsch_cfg->grant.tb[tb].cw_idx,
2 * (sf_idx % 10),
cell.id,
pdsch_cfg->grant.tb[tb].nof_bits);
// Scramble
srslte_scrambling_s_offset(&pdsch_ue->tmp_seq, pdsch_ue->e[tb], 0, pdsch_cfg->grant.tb[tb].nof_bits);
srslte_sequence_pdsch_apply_c(pdsch_ue->e[tb],
pdsch_ue->e[tb],
rnti,
pdsch_cfg->grant.tb[tb].cw_idx,
2 * (sf_idx % 10),
cell.id,
pdsch_cfg->grant.tb[tb].nof_bits);
int16_t* rx = pdsch_ue->e[tb];
uint8_t* rx_bytes = pdsch_ue->e[tb];
@ -328,8 +326,6 @@ int main(int argc, char** argv)
pdsch_rx.llr_is_8bit = use_8_bit;
pdsch_rx.dl_sch.llr_is_8bit = use_8_bit;
srslte_pdsch_set_rnti(&pdsch_rx, rnti);
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
softbuffers_rx[i] = calloc(sizeof(srslte_softbuffer_rx_t), 1);
if (!softbuffers_rx[i]) {
@ -375,8 +371,6 @@ int main(int argc, char** argv)
goto quit;
}
srslte_pdsch_set_rnti(&pdsch_tx, rnti);
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
softbuffers_tx[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1);
if (!softbuffers_tx[i]) {

@ -156,10 +156,6 @@ int main(int argc, char** argv)
ERROR("Error creating PDSCH object");
exit(-1);
}
if (srslte_pucch_set_rnti(&pucch_ue, 11)) {
ERROR("Error setting C-RNTI");
goto quit;
}
if (srslte_pucch_init_enb(&pucch_enb)) {
ERROR("Error creating PDSCH object");
exit(-1);
@ -168,10 +164,6 @@ int main(int argc, char** argv)
ERROR("Error creating PDSCH object");
exit(-1);
}
if (srslte_pucch_set_rnti(&pucch_enb, 11)) {
ERROR("Error setting C-RNTI");
goto quit;
}
if (srslte_refsignal_ul_set_cell(&dmrs, cell)) {
ERROR("Error creating PDSCH object");
exit(-1);

@ -236,8 +236,6 @@ int main(int argc, char** argv)
uint16_t rnti = 62;
dci.rnti = rnti;
cfg.rnti = rnti;
srslte_pusch_set_rnti(&pusch_tx, rnti);
srslte_pusch_set_rnti(&pusch_rx, rnti);
uint32_t nof_re = SRSLTE_NRE * cell.nof_prb * 2 * SRSLTE_CP_NSYMB(cell.cp);
sf_symbols = srslte_vec_cf_malloc(nof_re);

@ -67,7 +67,6 @@ int srslte_ue_dl_init(srslte_ue_dl_t* q, cf_t* in_buffer[SRSLTE_MAX_PORTS], uint
q->nof_rx_antennas = nof_rx_antennas;
q->mi_auto = true;
q->mi_manual_index = 0;
q->pregen_rnti = 0;
for (int j = 0; j < SRSLTE_MAX_PORTS; j++) {
q->sf_symbols[j] = srslte_vec_cf_malloc(MAX_SFLEN_RE);
@ -240,9 +239,6 @@ int srslte_ue_dl_set_cell(srslte_ue_dl_t* q, srslte_cell_t cell)
return SRSLTE_ERROR;
}
}
if (q->pregen_rnti) {
srslte_ue_dl_set_rnti(q, q->pregen_rnti);
}
ret = SRSLTE_SUCCESS;
} else {
ERROR("Invalid cell properties ue_dl: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb);
@ -266,34 +262,6 @@ void srslte_ue_dl_set_mi_manual(srslte_ue_dl_t* q, uint32_t mi_idx)
q->mi_manual_index = mi_idx;
}
/* Precalculate the PDSCH scramble sequences for a given RNTI. This function takes a while
* to execute, so shall be called once the final C-RNTI has been allocated for the session.
* For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions
*/
void srslte_ue_dl_set_rnti(srslte_ue_dl_t* q, uint16_t rnti)
{
srslte_pdsch_set_rnti(&q->pdsch, rnti);
srslte_dl_sf_cfg_t sf_cfg;
ZERO_OBJECT(sf_cfg);
// Compute UE-specific and Common search space for this RNTI
for (int i = 0; i < SRSLTE_MI_NOF_REGS; i++) {
srslte_pdcch_set_regs(&q->pdcch, &q->regs[i]);
for (int cfi = 1; cfi <= SRSLTE_NOF_CFI; cfi++) {
sf_cfg.cfi = cfi;
for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
sf_cfg.tti = sf_idx;
q->current_ss_ue[i][SRSLTE_CFI_IDX(cfi)][sf_idx].nof_locations = srslte_pdcch_ue_locations(
&q->pdcch, &sf_cfg, q->current_ss_ue[i][SRSLTE_CFI_IDX(cfi)][sf_idx].loc, SRSLTE_MAX_CANDIDATES_UE, rnti);
}
q->current_ss_common[i][SRSLTE_CFI_IDX(cfi)].nof_locations = srslte_pdcch_common_locations(
&q->pdcch, q->current_ss_common[i][SRSLTE_CFI_IDX(cfi)].loc, SRSLTE_MAX_CANDIDATES_COM, cfi);
}
}
q->pregen_rnti = rnti;
}
/* Set the area ID on pmch and chest_dl to generate scrambling sequence and reference
* signals.
*/
@ -477,9 +445,6 @@ static int dci_blind_search(srslte_ue_dl_t* q,
// Look for the messages found and apply the new format if the location is common
if (search_in_common && (dci_cfg->multiple_csi_request_enabled || dci_cfg->srs_request_enabled)) {
uint32_t sf_idx = sf->tti % 10;
uint32_t cfi = sf->cfi;
/*
* A UE configured to monitor PDCCH candidates whose CRCs are scrambled with C-RNTI or SPS C-RNTI,
* with a common payload size and with the same first CCE index ncce, but with different sets of DCI
@ -487,9 +452,8 @@ static int dci_blind_search(srslte_ue_dl_t* q,
* that only the PDCCH in the common search space is transmitted by the primary cell.
*/
// Find a matching ncce in the common SS
if (srslte_location_find_ncce(q->current_ss_common[MI_IDX(sf_idx)][cfi - 1].loc,
q->current_ss_common[MI_IDX(sf_idx)][cfi - 1].nof_locations,
dci_msg[nof_dci].location.ncce)) {
if (srslte_location_find_ncce(
q->current_ss_common.loc, q->current_ss_common.nof_locations, dci_msg[nof_dci].location.ncce)) {
srslte_dci_cfg_t cfg = *dci_cfg;
srslte_dci_cfg_set_common_ss(&cfg);
// if the payload size is the same that it would have in the common SS (only Format0/1A is allowed there)
@ -547,10 +511,8 @@ static int find_dci_ss(srslte_ue_dl_t* q,
uint32_t nof_formats,
bool is_ue)
{
dci_blind_search_t search_space = {};
dci_blind_search_t* current_ss = &search_space;
dci_blind_search_t search_space = {};
uint32_t sf_idx = sf->tti % SRSLTE_NOF_SF_X_FRAME;
uint32_t cfi = sf->cfi;
srslte_dci_cfg_t dci_cfg = cfg->cfg.dci;
@ -559,39 +521,31 @@ static int find_dci_ss(srslte_ue_dl_t* q,
return SRSLTE_ERROR_INVALID_INPUTS;
}
// Generate Common Search space
q->current_ss_common.nof_locations =
srslte_pdcch_common_locations(&q->pdcch, q->current_ss_common.loc, SRSLTE_MAX_CANDIDATES_COM, cfi);
// Generate Search Space
if (is_ue) {
if (q->pregen_rnti == rnti) {
current_ss = &q->current_ss_ue[MI_IDX(sf_idx)][SRSLTE_CFI_IDX(cfi)][sf_idx];
} else {
// If locations are not pre-generated, generate them now
current_ss->nof_locations =
srslte_pdcch_ue_locations(&q->pdcch, sf, current_ss->loc, SRSLTE_MAX_CANDIDATES_UE, rnti);
}
search_space.nof_locations =
srslte_pdcch_ue_locations(&q->pdcch, sf, search_space.loc, SRSLTE_MAX_CANDIDATES_UE, rnti);
} else {
// Disable extended CSI request and SRS request in common SS
srslte_dci_cfg_set_common_ss(&dci_cfg);
if (q->pregen_rnti == rnti) {
current_ss = &q->current_ss_common[MI_IDX(sf_idx)][SRSLTE_CFI_IDX(cfi)];
} else {
// If locations are not pre-generated, generate them now
current_ss->nof_locations =
srslte_pdcch_common_locations(&q->pdcch, current_ss->loc, SRSLTE_MAX_CANDIDATES_COM, cfi);
}
search_space = q->current_ss_common;
}
// Search for DCI in the SS
current_ss->nof_formats = nof_formats;
memcpy(current_ss->formats, formats, nof_formats * sizeof(srslte_dci_format_t));
search_space.nof_formats = nof_formats;
memcpy(search_space.formats, formats, nof_formats * sizeof(srslte_dci_format_t));
INFO("Searching %d formats in %d locations in %s SS, csi=%d",
nof_formats,
current_ss->nof_locations,
search_space.nof_locations,
is_ue ? "ue" : "common",
dci_cfg.multiple_csi_request_enabled);
return dci_blind_search(q, sf, rnti, current_ss, &dci_cfg, dci_msg, cfg->cfg.dci_common_ss);
return dci_blind_search(q, sf, rnti, &search_space, &dci_cfg, dci_msg, cfg->cfg.dci_common_ss);
}
/*

@ -165,17 +165,6 @@ int srslte_ue_ul_set_cell(srslte_ue_ul_t* q, srslte_cell_t cell)
return ret;
}
/* Precalculate the PUSCH scramble sequences for a given RNTI. This function takes a while
* to execute, so shall be called once the final C-RNTI has been allocated for the session.
* For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions
*/
void srslte_ue_ul_set_rnti(srslte_ue_ul_t* q, uint16_t rnti)
{
srslte_pusch_set_rnti(&q->pusch, rnti);
srslte_pucch_set_rnti(&q->pucch, rnti);
q->current_rnti = rnti;
}
int srslte_ue_ul_pregen_signals(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg)
{
if (q->signals_pregenerated) {
@ -625,7 +614,8 @@ int srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_
} else if ((uci_pending(cfg->ul_cfg.pucch.uci_cfg) || data->uci.scheduling_request) &&
cfg->cc_idx == 0) { // Send PUCCH over PCell only
if (!cfg->ul_cfg.pucch.rnti) {
cfg->ul_cfg.pucch.rnti = q->current_rnti;
ERROR("Encoding PUCCH: rnti not set in ul_cfg\n");
return SRSLTE_ERROR;
}
ret = pucch_encode(q, sf, cfg, &data->uci) ? -1 : 1;
} else if (srs_tx_enabled(&cfg->ul_cfg.srs, sf->tti)) {

@ -249,21 +249,23 @@ check_softbits(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_dl_cfg_
{
int ret = SRSLTE_SUCCESS;
// Generate sequence
srslte_sequence_pdsch(&ue_dl->pdsch.tmp_seq,
rnti,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].cw_idx,
2 * (sf_idx % 10),
cell.id,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits);
// Scramble
if (ue_dl->pdsch.llr_is_8bit) {
srslte_scrambling_sb_offset(
&ue_dl->pdsch.tmp_seq, ue_dl->pdsch.e[tb], 0, ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits);
srslte_sequence_pdsch_apply_c(ue_dl->pdsch.e[tb],
ue_dl->pdsch.e[tb],
rnti,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].cw_idx,
2 * (sf_idx % 10),
cell.id,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits);
} else {
srslte_scrambling_s_offset(
&ue_dl->pdsch.tmp_seq, ue_dl->pdsch.e[tb], 0, ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits);
srslte_sequence_pdsch_apply_s(ue_dl->pdsch.e[tb],
ue_dl->pdsch.e[tb],
rnti,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].cw_idx,
2 * (sf_idx % 10),
cell.id,
ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits);
}
int16_t* rx = ue_dl->pdsch.e[tb];
uint8_t* rx_bytes = ue_dl->pdsch.e[tb];
@ -377,11 +379,6 @@ int main(int argc, char** argv)
goto quit;
}
if (srslte_enb_dl_add_rnti(enb_dl, rnti)) {
ERROR("Error adding RNTI");
goto quit;
}
/*
* Initialise UE
*/
@ -395,8 +392,6 @@ int main(int argc, char** argv)
goto quit;
}
srslte_ue_dl_set_rnti(ue_dl, rnti);
/*
* Create PDCCH Allocations
*/

@ -78,12 +78,10 @@ static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode,
// Init UE
TESTASSERT(!srslte_ue_ul_init(&ue_ul, buffer, cell.nof_prb));
TESTASSERT(!srslte_ue_ul_set_cell(&ue_ul, cell));
srslte_ue_ul_set_rnti(&ue_ul, rnti);
// Init eNb
TESTASSERT(!srslte_enb_ul_init(&enb_ul, buffer, cell.nof_prb));
TESTASSERT(!srslte_enb_ul_set_cell(&enb_ul, cell, &dmrs_pusch_cfg, NULL));
TESTASSERT(!srslte_enb_ul_add_rnti(&enb_ul, rnti));
// The test itself starts here
for (ul_sf.tti = 0; ul_sf.tti < (1U << (nof_carriers * 2U)); ul_sf.tti++) {

@ -37,7 +37,6 @@ public:
int add_rnti(uint16_t rnti);
void rem_rnti(uint16_t rnti);
int pregen_sequences(uint16_t rnti);
uint32_t get_nof_rnti();
/* These are used by the GUI plotting tools */

@ -36,7 +36,6 @@ public:
int add_rnti(uint16_t rnti, uint32_t cc_idx);
void rem_rnti(uint16_t rnti);
int pregen_sequences(uint16_t rnti);
uint32_t get_nof_rnti();
/* These are used by the GUI plotting tools */

@ -43,7 +43,6 @@ public:
/* MAC->PHY interface */
void rem_rnti(uint16_t rnti) final;
int pregen_sequences(uint16_t rnti) override;
void set_mch_period_stop(uint32_t stop) final;
void set_activation_deactivation_scell(uint16_t rnti,
const std::array<bool, SRSLTE_MAX_CARRIERS>& activation) override;

@ -92,8 +92,7 @@ public:
void metrics_dl_cqi(uint32_t dl_cqi);
void metrics_cnt();
bool is_phy_added = false;
int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final;
int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final;
private:
uint32_t allocate_cc_buffers(const uint32_t num_cc = 1); ///< Add and initialize softbuffers for CC

@ -171,17 +171,6 @@ void cc_worker::set_tti(uint32_t tti_)
tti_tx_ul = TTI_RX_ACK(tti_rx);
}
int cc_worker::pregen_sequences(uint16_t rnti)
{
if (srslte_enb_dl_add_rnti(&enb_dl, rnti)) {
return -1;
}
if (srslte_enb_ul_add_rnti(&enb_ul, rnti)) {
return -1;
}
return SRSLTE_SUCCESS;
}
int cc_worker::add_rnti(uint16_t rnti)
{
std::unique_lock<std::mutex> lock(mutex);
@ -199,11 +188,9 @@ void cc_worker::rem_rnti(uint16_t rnti)
if (ue_db.count(rnti)) {
delete ue_db[rnti];
ue_db.erase(rnti);
} else {
Error("Removing user: rnti=0x%x does not exist\n", rnti);
}
// Always try to remove from PHY-lib
srslte_enb_dl_rem_rnti(&enb_dl, rnti);
srslte_enb_ul_rem_rnti(&enb_ul, rnti);
}
uint32_t cc_worker::get_nof_rnti()
@ -533,7 +520,6 @@ int cc_worker::encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srs
int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants)
{
/* Scales the Resources Elements affected by the power allocation (p_b) */
// srslte_enb_dl_prepare_power_allocation(&enb_dl);
for (uint32_t i = 0; i < nof_grants; i++) {

@ -120,16 +120,6 @@ void sf_worker::set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srslte::r
}
}
int sf_worker::pregen_sequences(uint16_t rnti)
{
for (auto& w : cc_workers) {
if (w->pregen_sequences(rnti)) {
return SRSLTE_ERROR;
}
}
return SRSLTE_SUCCESS;
}
int sf_worker::add_rnti(uint16_t rnti, uint32_t cc_idx)
{
int ret = SRSLTE_ERROR;
@ -431,7 +421,6 @@ void* plot_thread_run(void* arg)
void init_plots(srsenb::lte::sf_worker* worker)
{
if (sem_init(&plot_sem, 0, 0)) {
perror("sem_init");
exit(-1);

@ -175,16 +175,6 @@ void phy::rem_rnti(uint16_t rnti)
}
}
int phy::pregen_sequences(uint16_t rnti)
{
for (uint32_t i = 0; i < nof_workers; i++) {
if (lte_workers[i]->pregen_sequences(rnti) != SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
}
return SRSLTE_SUCCESS;
}
void phy::set_mch_period_stop(uint32_t stop)
{
workers_common.set_mch_period_stop(stop);

@ -193,17 +193,6 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg)
// Start TA FSM in UE entity
ue_ptr->start_ta();
// Add RNTI to the PHY (pregenerate signals) now instead of after PRACH
if (not ue_ptr->is_phy_added) {
logger.info("Registering RNTI=0x%X to PHY...", rnti);
// Register new user in PHY with first CC index
if (phy_h->pregen_sequences(rnti) == SRSLTE_ERROR) {
logger.error("Generating sequences for UE RNTI=0x%X", rnti);
}
logger.info("Done registering RNTI=0x%X to PHY...", rnti);
ue_ptr->is_phy_added = true;
}
// Update Scheduler configuration
if (cfg != nullptr and scheduler.ue_cfg(rnti, *cfg) == SRSLTE_ERROR) {
logger.error("Registering new UE rnti=0x%x to SCHED", rnti);

@ -821,9 +821,6 @@ public:
ERROR("Setting UE DL cell");
}
// Set RNTI
srslte_ue_dl_set_rnti(ue_dl, rnti);
// Allocate UE UL
auto* ue_ul = (srslte_ue_ul_t*)srslte_vec_malloc(sizeof(srslte_ue_ul_t));
if (not ue_ul) {
@ -840,9 +837,6 @@ public:
if (srslte_ue_ul_set_cell(ue_ul, cell)) {
ERROR("Setting UE DL cell");
}
// Set RNTI
srslte_ue_ul_set_rnti(ue_ul, rnti);
}
// Initialise softbuffer

@ -42,7 +42,6 @@ public:
void set_tdd_config_unlocked(srslte_tdd_config_t config);
void set_config_unlocked(srslte::phy_cfg_t& phy_cfg);
void upd_config_dci_unlocked(srslte_dci_cfg_t& dci_cfg);
void set_crnti_unlocked(uint16_t rnti);
void enable_pregen_signals_unlocked(bool enabled);
void set_uci_periodic_cqi(srslte_uci_data_t* uci_data);

@ -132,9 +132,6 @@ public:
bool cell_is_camping() final;
/********** MAC INTERFACE ********************/
// Precomputes sequences for the given RNTI. The computation is done in the background.
void set_crnti(uint16_t rnti) final;
/* Transmits PRACH in the next opportunity */
void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) final;
prach_info_t prach_get_info() final;

@ -63,8 +63,6 @@ public:
void start_pcap(srslte::mac_pcap* pcap);
void notify_ra_completed(uint32_t task_id);
bool is_idle() const { return state == IDLE; }
private:
@ -72,7 +70,6 @@ private:
void state_response_reception(uint32_t tti);
void state_backoff_wait(uint32_t tti);
void state_contention_resolution();
void state_completition();
void process_timeadv_cmd(uint32_t ta_cmd);
void initialization();
@ -122,8 +119,6 @@ private:
RESPONSE_RECEPTION,
BACKOFF_WAIT,
CONTENTION_RESOLUTION,
START_WAIT_COMPLETION,
WAITING_COMPLETION
};
std::atomic<ra_state_t> state = {IDLE};

@ -180,12 +180,6 @@ float cc_worker::get_ref_cfo() const
return ue_dl.chest_res.cfo;
}
void cc_worker::set_crnti_unlocked(uint16_t rnti)
{
srslte_ue_dl_set_rnti(&ue_dl, rnti);
srslte_ue_ul_set_rnti(&ue_ul, rnti);
}
void cc_worker::set_tdd_config_unlocked(srslte_tdd_config_t config)
{
sf_cfg_dl.tdd_config = config;
@ -233,7 +227,6 @@ bool cc_worker::work_dl_regular()
// Blind search PHICH mi value
for (uint32_t i = 0; i < mi_set_len && !found_dl_grant; i++) {
if (mi_set_len == 1) {
srslte_ue_dl_set_mi_auto(&ue_dl);
} else {
@ -260,7 +253,6 @@ bool cc_worker::work_dl_regular()
// If found a dci for this carrier, generate a grant, pass it to MAC and decode the associated PDSCH
if (has_dl_grant) {
// Read last TB from last retx for this pid
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
ue_dl_cfg.cfg.pdsch.grant.last_tbs[i] = phy->last_dl_tbs[dci_dl.pid][cc_idx][i];
@ -417,7 +409,6 @@ int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource,
mac_interface_phy_lte::tb_action_dl_t* action,
bool mac_acks[SRSLTE_MAX_CODEWORDS])
{
srslte_pdsch_res_t pdsch_dec[SRSLTE_MAX_CODEWORDS] = {};
// See if at least 1 codeword needs to be decoded. If not need to be decode, resend ACK
@ -499,7 +490,6 @@ int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte
pmch_dec.payload = action->tb[0].payload;
if (action->tb[0].enabled) {
srslte_softbuffer_rx_reset_tbs(pmch_cfg.pdsch_cfg.softbuffers.rx[0], pmch_cfg.pdsch_cfg.grant.tb[0].tbs);
if (srslte_ue_dl_decode_pmch(&ue_dl, &sf_cfg_dl, &pmch_cfg, &pmch_dec)) {
@ -601,7 +591,6 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data)
/* Send UL dci or HARQ information (from PHICH) to MAC and receive actions*/
if (ul_grant_available || ul_mac_grant.phich_available) {
// Read last TB info from last retx for this PID
ue_ul_cfg.ul_cfg.pusch.grant.last_tb = phy->last_ul_tb[pid][cc_idx];
@ -709,7 +698,6 @@ int cc_worker::decode_pdcch_ul()
/* Convert every DCI message to UL dci */
for (int k = 0; k < nof_grants; k++) {
// If the DCI does not have Carrier Indicator Field then indicate in which carrier the dci was found
uint32_t cc_idx_grant = dci[k].cif_present ? dci[k].cif : cc_idx;
@ -833,7 +821,6 @@ void cc_worker::set_uci_ack(srslte_uci_data_t* uci_data,
uint32_t V_dai_ul,
bool is_pusch_available)
{
srslte_pdsch_ack_t ack_info = {};
uint32_t nof_configured_carriers = 0;

@ -129,13 +129,6 @@ void sf_worker::set_cfo_unlocked(const uint32_t& cc_idx, float cfo)
cc_workers[cc_idx]->set_cfo_unlocked(cfo);
}
void sf_worker::set_crnti_unlocked(uint16_t rnti)
{
for (auto& cc_worker : cc_workers) {
cc_worker->set_crnti_unlocked(rnti);
}
}
void sf_worker::set_tdd_config_unlocked(srslte_tdd_config_t config)
{
for (auto& cc_worker : cc_workers) {

@ -402,23 +402,6 @@ void phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rn
common.set_rar_grant(grant_payload, rnti, tdd_config);
}
void phy::set_crnti(uint16_t rnti)
{
// set_crnti() is an operation that takes time, run in background worker
cmd_worker.add_cmd([this, rnti]() {
logger_phy.info("Configuring sequences for C-RNTI=0x%x...", rnti);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
// set_crnti is not protected so run when worker is finished
lte::sf_worker* w = lte_workers.wait_worker_id(i);
if (w) {
w->set_crnti_unlocked(rnti);
w->release();
}
}
logger_phy.info("Finished configuring sequences for C-RNTI=0x%x.", rnti);
});
}
// Start GUI
void phy::start_plot()
{

@ -141,12 +141,6 @@ void ra_proc::step(uint32_t tti_)
case CONTENTION_RESOLUTION:
state_contention_resolution();
break;
case START_WAIT_COMPLETION:
state_completition();
break;
case WAITING_COMPLETION:
// do nothing, bc we are waiting for the phy to finish
break;
}
}
@ -220,36 +214,6 @@ void ra_proc::state_contention_resolution()
}
}
/* This step just configures the PHY to generate the C-RNTI. It is called from a state because it takes a long time to
* compute
*/
void ra_proc::state_completition()
{
state = WAITING_COMPLETION;
uint16_t rnti = rntis->crnti;
uint32_t task_id = current_task_id;
phy_h->set_crnti(rnti);
// signal MAC RA proc to go back to idle
notify_ra_completed(task_id);
}
void ra_proc::notify_ra_completed(uint32_t task_id)
{
if (current_task_id == task_id) {
if (state != WAITING_COMPLETION) {
rError("Received unexpected notification of RA completion");
} else {
rInfo("RA waiting procedure completed");
}
state = IDLE;
} else {
rError(
"Received old notification of RA completition (old task_id=%d, current_task_id=%d)", task_id, current_task_id);
}
}
/* RA procedure initialization as defined in 5.1.1 */
void ra_proc::initialization()
{
@ -516,7 +480,7 @@ void ra_proc::complete()
srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta);
rInfo("Random Access Complete. c-rnti=0x%x, ta=%d", rntis->crnti, current_ta);
state = START_WAIT_COMPLETION;
state = IDLE;
}
void ra_proc::start_mac_order(uint32_t msg_len_bits)

@ -99,7 +99,6 @@ public:
nof_rar_grants = 0;
rar_temp_rnti = 0;
rar_time_adv = 0;
last_crnti = 0;
prach_transmitted = false;
prach_info_tx = false;
}
@ -145,7 +144,6 @@ public:
void set_mch_period_stop(uint32_t stop) override{};
// phy_interface_mac_common
void set_crnti(uint16_t rnti) override { last_crnti = rnti; }
void set_timeadv_rar(uint32_t ta_cmd) override { rar_time_adv = ta_cmd; }
void set_timeadv(uint32_t ta_cmd) override{};
void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) override { scell_cmd = cmd; };
@ -287,8 +285,6 @@ public:
uint32_t get_rar_rnti() { return (prach_tti % 10) + 1; }
uint16_t get_crnti() { return last_crnti; }
const static uint32_t prach_delay = 5;
private:
@ -301,8 +297,6 @@ private:
float last_target_power = 0;
int last_preamble_idx = -1;
uint16_t last_crnti = 0;
srslog::basic_logger& logger = srslog::fetch_basic_logger("PHY");
bool ul_ndi = false;
@ -2078,7 +2072,6 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
if (phy->dl_grant(mac, true, test.crnti, 2, tv_msg4_nocontres)) {
return -1;
}
TESTASSERT(phy->get_crnti() != test.crnti);
// UL grant is checked later
if (test.send_valid_ul_grant) {
@ -2114,7 +2107,6 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
if (test.check_ra_successful) {
stack->run_tti(tti);
stack->run_tti(tti);
TESTASSERT(phy->get_crnti() == (test.crnti ? test.crnti : test.temp_rnti));
TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti));
tti++;
}
@ -2255,7 +2247,6 @@ int mac_random_access_test()
// To trigger a new RA we have to either generate more data for high-prio LCID (e.g. SRB1)
// or wait until BSR-reTX is triggered
rlc.write_sdu(1, 100);
phy.set_crnti(0);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.crnti = my_test.temp_rnti;
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
@ -2270,7 +2261,6 @@ int mac_random_access_test()
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
rrc.ho_finish_successful = false;
phy.set_prach_tti(tti + phy.prach_delay);
phy.set_crnti(0);
rlc.write_sdu(0, 6); // Add new UL-CCCH with Msg3 (DRB SDU still buffered)
stack.run_tti(tti++);
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
@ -2317,7 +2307,6 @@ int mac_random_access_test()
rlc.write_sdu(0, 6); // Add new UL-CCCH with Msg3 (DRB SDU still buffered)
phy.set_prach_tti(tti + phy.prach_delay);
stack.run_tti(tti++);
phy.set_crnti(0);
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number();
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
@ -2336,7 +2325,6 @@ int mac_random_access_test()
rlc.write_sdu(0, 6); // Add new UL-CCCH with Msg3 (DRB SDU still buffered)
phy.set_prach_tti(tti + phy.prach_delay);
stack.run_tti(tti++);
phy.set_crnti(0);
my_test.nof_prachs = 1;
my_test.rar_nof_invalid_rapid = 0;
my_test.check_ra_successful = true;

@ -121,10 +121,6 @@ public:
if (srslte_enb_dl_set_cell(&enb_dl, cell)) {
ERROR("Error setting eNb DL cell");
}
if (srslte_enb_dl_add_rnti(&enb_dl, serving_cell_pdsch_rnti)) {
ERROR("Error adding RNTI");
}
}
int work(srslte_dl_sf_cfg_t* dl_sf,

@ -413,9 +413,6 @@ public:
void configure_dedicated(uint16_t rnti, srslte::phy_cfg_t& phy_cfg)
{
// set RNTI
phy->set_crnti(rnti);
// Set PHY configuration
phy->set_config(phy_cfg, 0);
}

@ -83,7 +83,6 @@ public:
int sr_last_tx_tti() override;
// phy_interface_mac_common
void set_crnti(uint16_t rnti) override;
void set_timeadv_rar(uint32_t ta_cmd) override;
void set_timeadv(uint32_t ta_cmd) override;
void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) override;

@ -215,12 +215,6 @@ int lte_ttcn3_phy::sr_last_tx_tti()
// The RAT-agnostic interface for MAC
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
void lte_ttcn3_phy::set_crnti(uint16_t rnti)
{
logger.debug("Set Temp-RNTI=%d, pregen not used", rnti);
}
/* Time advance commands */
void lte_ttcn3_phy::set_timeadv_rar(uint32_t ta_cmd)
{

Loading…
Cancel
Save