From 62b63462c9556109a8b8396f777501244fa59f3e Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 20 Nov 2016 17:36:21 +0100 Subject: [PATCH] Simplified API for PDSCH and PUSCH. Dynamically handle multiple RNTIs --- srslte/examples/pdsch_enodeb.c | 2 +- srslte/include/srslte/enb/enb_dl.h | 23 +- srslte/include/srslte/enb/enb_ul.h | 35 +-- srslte/include/srslte/phch/pdsch.h | 50 +--- srslte/include/srslte/phch/pusch.h | 73 +---- srslte/lib/enb/enb_dl.c | 37 +-- srslte/lib/enb/enb_ul.c | 156 ++++++----- srslte/lib/phch/pdsch.c | 217 ++++----------- srslte/lib/phch/pusch.c | 271 ++++++------------- srslte/lib/phch/test/pdsch_test.c | 6 +- srslte/lib/phch/test/pdsch_test_mex.c | 5 +- srslte/lib/phch/test/pusch_encode_test_mex.c | 7 +- srslte/lib/phch/test/pusch_test.c | 9 +- srslte/lib/phch/uci.c | 5 +- srslte/lib/ue/ue_dl.c | 4 +- srslte/lib/ue/ue_ul.c | 2 +- 16 files changed, 296 insertions(+), 606 deletions(-) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index fdacde801..c68b4d125 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -624,7 +624,7 @@ int main(int argc, char **argv) { } /* Encode PDSCH */ - if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer, data, sf_symbols)) { + if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer, data, UE_CRNTI, sf_symbols)) { fprintf(stderr, "Error encoding PDSCH\n"); exit(-1); } diff --git a/srslte/include/srslte/enb/enb_dl.h b/srslte/include/srslte/enb/enb_dl.h index eca63d6d3..560441c70 100644 --- a/srslte/include/srslte/enb/enb_dl.h +++ b/srslte/include/srslte/enb/enb_dl.h @@ -87,13 +87,12 @@ typedef struct SRSLTE_API { float sss_signal0[SRSLTE_SSS_LEN]; float sss_signal5[SRSLTE_SSS_LEN]; - uint32_t nof_rnti; float tx_amp; } srslte_enb_dl_t; typedef struct { - int rnti_idx; + uint16_t rnti; srslte_ra_dl_dci_t grant; srslte_dci_location_t location; srslte_softbuffer_tx_t *softbuffer; @@ -101,14 +100,15 @@ typedef struct { } srslte_enb_dl_pdsch_t; typedef struct { + uint16_t rnti; uint8_t ack; - int rnti_idx; + uint32_t n_prb_lowest; + uint32_t n_dmrs; } srslte_enb_dl_phich_t; /* This function shall be called just after the initial synchronization */ SRSLTE_API int srslte_enb_dl_init(srslte_enb_dl_t *q, - srslte_cell_t cell, - uint32_t nof_rntis); + srslte_cell_t cell); SRSLTE_API void srslte_enb_dl_free(srslte_enb_dl_t *q); @@ -144,17 +144,16 @@ SRSLTE_API void srslte_enb_dl_put_base(srslte_enb_dl_t *q, SRSLTE_API void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q, cf_t *signal_buffer); -SRSLTE_API int srslte_enb_dl_cfg_rnti(srslte_enb_dl_t *q, - uint32_t idx, +SRSLTE_API int srslte_enb_dl_add_rnti(srslte_enb_dl_t *q, uint16_t rnti); -SRSLTE_API int srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q, - uint32_t idx); +SRSLTE_API void srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q, + uint16_t rnti); SRSLTE_API int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q, srslte_ra_dl_grant_t *grant, srslte_softbuffer_tx_t *softbuffer, - uint32_t rnti_idx, + uint16_t rnti, uint32_t rv_idx, uint32_t sf_idx, uint8_t *data); @@ -163,13 +162,13 @@ SRSLTE_API int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant, srslte_dci_format_t format, srslte_dci_location_t location, - uint32_t rnti_idx, + uint16_t rnti, uint32_t sf_idx); SRSLTE_API int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant, srslte_dci_location_t location, - uint32_t rnti_idx, + uint16_t rnti, uint32_t sf_idx); diff --git a/srslte/include/srslte/enb/enb_ul.h b/srslte/include/srslte/enb/enb_ul.h index 60eb0e50f..9a05436ba 100644 --- a/srslte/include/srslte/enb/enb_ul.h +++ b/srslte/include/srslte/enb/enb_ul.h @@ -58,9 +58,16 @@ typedef struct { uint32_t n_dmrs; } srslte_enb_ul_phich_info_t; +typedef struct { + bool uci_cfg_en; + bool srs_cfg_en; + srslte_uci_cfg_t uci_cfg; + srslte_refsignal_srs_cfg_t srs_cfg; + srslte_pucch_sched_t pucch_sched; +} srslte_enb_ul_user_t; + typedef struct SRSLTE_API { srslte_cell_t cell; - uint32_t nof_rnti; cf_t *sf_symbols; cf_t *ce; @@ -77,16 +84,12 @@ typedef struct SRSLTE_API { srslte_pusch_hopping_cfg_t hopping_cfg; // Configuration for each user - bool *uci_cfg_en; - bool *srs_cfg_en; - srslte_uci_cfg_t *uci_cfg; - srslte_refsignal_srs_cfg_t *srs_cfg; - srslte_pucch_sched_t *pucch_sched; + srslte_enb_ul_user_t **users; } srslte_enb_ul_t; typedef struct { - int rnti_idx; + uint16_t rnti; srslte_ra_ul_dci_t grant; srslte_dci_location_t location; uint32_t rv_idx; @@ -103,29 +106,27 @@ SRSLTE_API int srslte_enb_ul_init(srslte_enb_ul_t *q, srslte_prach_cfg_t* prach_cfg, srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg, srslte_pusch_hopping_cfg_t *hopping_cfg, - srslte_pucch_cfg_t *pucch_cfg, - uint32_t nof_rntis); + srslte_pucch_cfg_t *pucch_cfg); SRSLTE_API void srslte_enb_ul_free(srslte_enb_ul_t *q); -SRSLTE_API int srslte_enb_ul_cfg_rnti(srslte_enb_ul_t *q, - uint32_t idx, +SRSLTE_API int srslte_enb_ul_add_rnti(srslte_enb_ul_t *q, uint16_t rnti); -SRSLTE_API int srslte_enb_ul_cfg_ue(srslte_enb_ul_t *q, uint32_t idx, +SRSLTE_API void srslte_enb_ul_rem_rnti(srslte_enb_ul_t *q, + uint16_t rnti); + +SRSLTE_API int srslte_enb_ul_cfg_ue(srslte_enb_ul_t *q, uint16_t rnti, srslte_uci_cfg_t *uci_cfg, srslte_pucch_sched_t *pucch_sched, srslte_refsignal_srs_cfg_t *srs_cfg); -SRSLTE_API int srslte_enb_ul_rem_rnti(srslte_enb_ul_t *q, - uint32_t idx); - SRSLTE_API void srslte_enb_ul_fft(srslte_enb_ul_t *q, cf_t *signal_buffer); SRSLTE_API int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, - uint32_t rnti_idx, + uint16_t rnti, uint32_t pdcch_n_cce, uint32_t sf_rx, srslte_uci_data_t *uci_data); @@ -133,7 +134,7 @@ SRSLTE_API int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, SRSLTE_API int srslte_enb_ul_get_pusch(srslte_enb_ul_t *q, srslte_ra_ul_grant_t *grant, srslte_softbuffer_rx_t *softbuffer, - uint32_t rnti_idx, + uint16_t rnti, uint32_t rv_idx, uint32_t current_tx_nb, uint8_t *data, diff --git a/srslte/include/srslte/phch/pdsch.h b/srslte/include/srslte/phch/pdsch.h index 3e6580763..305402de5 100644 --- a/srslte/include/srslte/phch/pdsch.h +++ b/srslte/include/srslte/phch/pdsch.h @@ -47,13 +47,15 @@ #include "srslte/phch/sch.h" #include "srslte/phch/pdsch_cfg.h" +typedef struct { + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; +} srslte_pdsch_user_t; + /* PDSCH object */ typedef struct SRSLTE_API { srslte_cell_t cell; uint32_t max_re; - bool rnti_is_set; - uint16_t rnti; /* buffers */ // void buffers are shared for tx and rx @@ -66,12 +68,8 @@ typedef struct SRSLTE_API { /* tx & rx objects */ srslte_modem_table_t mod[4]; - srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; - // This is to generate the scrambling seq for multiple CRNTIs - uint32_t nof_crnti; - srslte_sequence_t *seq_multi[SRSLTE_NSUBFRAMES_X_FRAME]; - uint16_t *rnti_multi; + srslte_pdsch_user_t **users; srslte_sch_t dl_sch; @@ -85,21 +83,12 @@ SRSLTE_API void srslte_pdsch_free(srslte_pdsch_t *q); SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t *q, uint16_t rnti); -SRSLTE_API int srslte_pdsch_init_rnti_multi(srslte_pdsch_t *q, - uint32_t nof_rntis); - -SRSLTE_API int srslte_pdsch_set_rnti_multi(srslte_pdsch_t *q, - uint32_t idx, - uint16_t rnti); - -SRSLTE_API uint16_t srslte_pdsch_get_rnti_multi(srslte_pdsch_t *q, - uint32_t idx); +SRSLTE_API void srslte_pdsch_free_rnti(srslte_pdsch_t *q, + uint16_t rnti); SRSLTE_API float srslte_pdsch_coderate(uint32_t tbs, uint32_t nof_re); -SRSLTE_API void print_pdsch_coderate(); - SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, @@ -111,39 +100,18 @@ SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, uint8_t *data, + uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS]); -SRSLTE_API int srslte_pdsch_encode_rnti_idx(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, - srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, - uint32_t rnti_idx, - cf_t *sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_pdsch_encode_rnti(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, - srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, - uint16_t rnti, - cf_t *sf_symbols[SRSLTE_MAX_PORTS]); - SRSLTE_API int srslte_pdsch_decode(srslte_pdsch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, + uint16_t rnti, uint8_t *data); -SRSLTE_API int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, - srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, - cf_t *ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint16_t rnti, - uint8_t *data); - SRSLTE_API float srslte_pdsch_average_noi(srslte_pdsch_t *q); SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q); diff --git a/srslte/include/srslte/phch/pusch.h b/srslte/include/srslte/phch/pusch.h index d8a5f3f53..e75b83c63 100644 --- a/srslte/include/srslte/phch/pusch.h +++ b/srslte/include/srslte/phch/pusch.h @@ -51,9 +51,6 @@ #define SRSLTE_PUSCH_MAX_TDEC_ITERS 5 - - - typedef struct { enum { SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1, @@ -63,13 +60,15 @@ typedef struct { uint32_t n_sb; } srslte_pusch_hopping_cfg_t; +typedef struct { + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; +} srslte_pusch_user_t; + /* PUSCH object */ typedef struct SRSLTE_API { srslte_cell_t cell; uint32_t max_re; - bool rnti_is_set; - uint16_t rnti; srslte_dft_precoding_t dft_precoding; @@ -84,13 +83,10 @@ typedef struct SRSLTE_API { /* tx & rx objects */ srslte_modem_table_t mod[4]; - srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq_type2_fo; // This is to generate the scrambling seq for multiple CRNTIs - uint32_t nof_crnti; - srslte_sequence_t *seq_multi[SRSLTE_NSUBFRAMES_X_FRAME]; - uint16_t *rnti_multi; + srslte_pusch_user_t **users; srslte_sch_t ul_sch; bool shortened; @@ -116,44 +112,16 @@ SRSLTE_API int srslte_pusch_cfg(srslte_pusch_t *q, SRSLTE_API int srslte_pusch_set_rnti(srslte_pusch_t *q, uint16_t rnti); -SRSLTE_API int srslte_pusch_init_rnti_multi(srslte_pusch_t *q, - uint32_t nof_rntis); - -SRSLTE_API int srslte_pusch_set_rnti_multi(srslte_pusch_t *q, - uint32_t idx, - uint16_t rnti); - -SRSLTE_API uint16_t srslte_pusch_get_rnti_multi(srslte_pusch_t *q, - uint32_t idx); - +SRSLTE_API void srslte_pusch_clear_rnti(srslte_pusch_t *q, + uint16_t rnti); SRSLTE_API int srslte_pusch_encode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, uint8_t *data, - cf_t *sf_symbols); - -SRSLTE_API int srslte_pusch_encode_rnti(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, - srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, - uint16_t rnti, - cf_t *sf_symbols); - -SRSLTE_API int srslte_pusch_uci_encode(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, - srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, srslte_uci_data_t uci_data, - cf_t *sf_symbols); - -SRSLTE_API int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, - srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, - srslte_uci_data_t uci_data, - uint16_t rnti, - cf_t *sf_symbols); + uint16_t rnti, + cf_t *sf_symbols); SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, @@ -161,26 +129,9 @@ SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q, cf_t *sf_symbols, cf_t *ce, float noise_estimate, - uint8_t *data); - -SRSLTE_API int srslte_pusch_uci_decode(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, - srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, - cf_t *ce, - float noise_estimate, - uint8_t *data, - srslte_uci_data_t *uci_data); - -SRSLTE_API int srslte_pusch_uci_decode_rnti_idx(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, - srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, - cf_t *ce, - float noise_estimate, - uint32_t rnti_idx, - uint8_t *data, - srslte_uci_data_t *uci_data); + uint16_t rnti, + uint8_t *data, + srslte_uci_data_t *uci_data); SRSLTE_API float srslte_pusch_average_noi(srslte_pusch_t *q); diff --git a/srslte/lib/enb/enb_dl.c b/srslte/lib/enb/enb_dl.c index bbe122c96..82fc8491e 100644 --- a/srslte/lib/enb/enb_dl.c +++ b/srslte/lib/enb/enb_dl.c @@ -39,7 +39,7 @@ #define SRSLTE_ENB_RF_AMP 0.1 -int srslte_enb_dl_init(srslte_enb_dl_t *q, srslte_cell_t cell, uint32_t nof_rnti) +int srslte_enb_dl_init(srslte_enb_dl_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -52,7 +52,6 @@ int srslte_enb_dl_init(srslte_enb_dl_t *q, srslte_cell_t cell, uint32_t nof_rnti q->cell = cell; q->cfi = 3; - q->nof_rnti = nof_rnti; q->tx_amp = SRSLTE_ENB_RF_AMP; if (srslte_ofdm_tx_init(&q->ifft, q->cell.cp, q->cell.nof_prb)) { @@ -89,11 +88,6 @@ int srslte_enb_dl_init(srslte_enb_dl_t *q, srslte_cell_t cell, uint32_t nof_rnti goto clean_exit; } - if (srslte_pdsch_init_rnti_multi(&q->pdsch, nof_rnti)) { - fprintf(stderr, "Error initiating multiple RNTIs in PDSCH\n"); - goto clean_exit; - } - if (srslte_refsignal_cs_init(&q->csr_signal, q->cell)) { fprintf(stderr, "Error initializing CSR signal (%d)\n",ret); goto clean_exit; @@ -223,23 +217,21 @@ void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q, cf_t *signal_buffer) srslte_vec_sc_prod_cfc(signal_buffer, q->tx_amp*norm_factor, signal_buffer, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); } -int srslte_enb_dl_cfg_rnti(srslte_enb_dl_t *q, uint32_t idx, uint16_t rnti) +int srslte_enb_dl_add_rnti(srslte_enb_dl_t *q, uint16_t rnti) { - return srslte_pdsch_set_rnti_multi(&q->pdsch, idx, rnti); + return srslte_pdsch_set_rnti(&q->pdsch, rnti); } -int srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q, uint32_t idx) +void srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q, uint16_t rnti) { - return srslte_pdsch_set_rnti_multi(&q->pdsch, idx, 0); + srslte_pdsch_free_rnti(&q->pdsch, rnti); } int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant, srslte_dci_format_t format, srslte_dci_location_t location, - uint32_t rnti_idx, uint32_t sf_idx) + uint16_t rnti, uint32_t sf_idx) { srslte_dci_msg_t dci_msg; - - uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, rnti_idx); bool rnti_is_user = true; if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || (rnti >= SRSLTE_RARNTI_START && rnti <= SRSLTE_RARNTI_END)) { @@ -251,23 +243,16 @@ int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant, fprintf(stderr, "Error encoding DCI message\n"); return SRSLTE_ERROR; } -/* printf("format: %s, sf_idx=%d, rnti=%d, location=%d,%d, cfi=%d\n", - srslte_dci_format_string(format), sf_idx, rnti, location.L, location.ncce, q->cfi); - srslte_ra_pdsch_fprint(stdout, grant, q->cell.nof_prb); - srslte_vec_fprint_hex(stdout, dci_msg.data, dci_msg.nof_bits); -*/ return SRSLTE_SUCCESS; } int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant, srslte_dci_location_t location, - uint32_t rnti_idx, uint32_t sf_idx) + uint16_t rnti, uint32_t sf_idx) { srslte_dci_msg_t dci_msg; - uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, rnti_idx); - srslte_dci_msg_pack_pusch(grant, &dci_msg, q->cell.nof_prb); if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) { fprintf(stderr, "Error encoding DCI message\n"); @@ -278,11 +263,9 @@ int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant, } int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q, srslte_ra_dl_grant_t *grant, srslte_softbuffer_tx_t *softbuffer, - uint32_t rnti_idx, uint32_t rv_idx, uint32_t sf_idx, + uint16_t rnti, uint32_t rv_idx, uint32_t sf_idx, uint8_t *data) -{ - //srslte_ra_dl_grant_fprint(stdout, grant); - +{ /* Configure pdsch_cfg parameters */ if (srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, q->cfi, sf_idx, rv_idx)) { fprintf(stderr, "Error configuring PDSCH\n"); @@ -290,7 +273,7 @@ int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q, srslte_ra_dl_grant_t *grant, srs } /* Encode PDSCH */ - if (srslte_pdsch_encode_rnti_idx(&q->pdsch, &q->pdsch_cfg, softbuffer, data, rnti_idx, q->sf_symbols)) { + if (srslte_pdsch_encode(&q->pdsch, &q->pdsch_cfg, softbuffer, data, rnti, q->sf_symbols)) { fprintf(stderr, "Error encoding PDSCH\n"); return SRSLTE_ERROR; } diff --git a/srslte/lib/enb/enb_ul.c b/srslte/lib/enb/enb_ul.c index cf6f63c99..f966cd508 100644 --- a/srslte/lib/enb/enb_ul.c +++ b/srslte/lib/enb/enb_ul.c @@ -43,8 +43,7 @@ int srslte_enb_ul_init(srslte_enb_ul_t *q, srslte_cell_t cell, srslte_prach_cfg_t *prach_cfg, srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg, srslte_pusch_hopping_cfg_t *hopping_cfg, - srslte_pucch_cfg_t *pucch_cfg, - uint32_t nof_rnti) + srslte_pucch_cfg_t *pucch_cfg) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -56,18 +55,16 @@ int srslte_enb_ul_init(srslte_enb_ul_t *q, srslte_cell_t cell, bzero(q, sizeof(srslte_enb_ul_t)); q->cell = cell; - q->nof_rnti = nof_rnti; if (hopping_cfg) { memcpy(&q->hopping_cfg, hopping_cfg, sizeof(srslte_pusch_hopping_cfg_t)); } - q->uci_cfg_en = calloc(sizeof(bool), nof_rnti); - q->srs_cfg_en = calloc(sizeof(bool), nof_rnti); - - q->uci_cfg = calloc(sizeof(srslte_uci_cfg_t), nof_rnti); - q->srs_cfg = calloc(sizeof(srslte_refsignal_srs_cfg_t), nof_rnti); - q->pucch_sched = calloc(sizeof(srslte_pucch_sched_t), nof_rnti); + q->users = calloc(sizeof(srslte_enb_ul_user_t*), SRSLTE_SIRNTI); + if (!q->users) { + perror("malloc"); + goto clean_exit; + } if (srslte_ofdm_rx_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { fprintf(stderr, "Error initiating FFT\n"); @@ -86,18 +83,14 @@ int srslte_enb_ul_init(srslte_enb_ul_t *q, srslte_cell_t cell, goto clean_exit; } - if (srslte_pusch_init_rnti_multi(&q->pusch, nof_rnti)) { - fprintf(stderr, "Error initiating multiple RNTIs in PUSCH\n"); - goto clean_exit; - } - - if (srslte_prach_init_cfg(&q->prach, prach_cfg, q->cell.nof_prb)) { - fprintf(stderr, "Error initiating PRACH\n"); - goto clean_exit; + if (prach_cfg) { + if (srslte_prach_init_cfg(&q->prach, prach_cfg, q->cell.nof_prb)) { + fprintf(stderr, "Error initiating PRACH\n"); + goto clean_exit; + } + srslte_prach_set_detect_factor(&q->prach, 60); } - srslte_prach_set_detect_factor(&q->prach, 60); - srslte_pucch_set_threshold(&q->pucch, 0.5, 0.5); if (srslte_chest_ul_init(&q->chest, cell)) { @@ -141,20 +134,13 @@ void srslte_enb_ul_free(srslte_enb_ul_t *q) { if (q) { - if (q->uci_cfg) { - free(q->uci_cfg); - } - if (q->uci_cfg_en) { - free(q->uci_cfg_en); - } - if (q->srs_cfg) { - free(q->srs_cfg); - } - if (q->srs_cfg_en) { - free(q->srs_cfg_en); - } - if (q->pucch_sched) { - free(q->pucch_sched); + if (q->users) { + for (int i=0;iusers[i]) { + free(q->users[i]); + } + } + free(q->users); } srslte_prach_free(&q->prach); @@ -172,50 +158,60 @@ void srslte_enb_ul_free(srslte_enb_ul_t *q) } } -int srslte_enb_ul_cfg_rnti(srslte_enb_ul_t *q, uint32_t idx, uint16_t rnti) +int srslte_enb_ul_add_rnti(srslte_enb_ul_t *q, uint16_t rnti) { - return srslte_pusch_set_rnti_multi(&q->pusch, idx, rnti); + if (!q->users[rnti]) { + q->users[rnti] = malloc(sizeof(srslte_enb_ul_user_t)); + return srslte_pusch_set_rnti(&q->pusch, rnti); + } else { + fprintf(stderr, "Error adding rnti=0x%x, already exists\n", rnti); + return -1; + } } -int srslte_enb_ul_cfg_ue(srslte_enb_ul_t *q, uint32_t idx, +void srslte_enb_ul_rem_rnti(srslte_enb_ul_t *q, uint16_t rnti) +{ + if (q->users[rnti]) { + free(q->users[rnti]); + q->users[rnti] = NULL; + srslte_pusch_clear_rnti(&q->pusch, rnti); + } +} + +int srslte_enb_ul_cfg_ue(srslte_enb_ul_t *q, uint16_t rnti, srslte_uci_cfg_t *uci_cfg, srslte_pucch_sched_t *pucch_sched, srslte_refsignal_srs_cfg_t *srs_cfg) { - if (idx < q->nof_rnti) { + if (q->users[rnti]) { if (uci_cfg) { - memcpy(&q->uci_cfg[idx], uci_cfg, sizeof(srslte_uci_cfg_t)); - q->uci_cfg_en[idx] = true; + memcpy(&q->users[rnti]->uci_cfg, uci_cfg, sizeof(srslte_uci_cfg_t)); + q->users[rnti]->uci_cfg_en = true; } else { - q->uci_cfg_en[idx] = false; + q->users[rnti]->uci_cfg_en = false; } if (pucch_sched) { - memcpy(&q->pucch_sched[idx], pucch_sched, sizeof(srslte_pucch_sched_t)); + memcpy(&q->users[rnti]->pucch_sched, pucch_sched, sizeof(srslte_pucch_sched_t)); } if (srs_cfg) { - memcpy(&q->srs_cfg[idx], srs_cfg, sizeof(srslte_refsignal_srs_cfg_t)); - q->srs_cfg_en[idx] = true; + memcpy(&q->users[rnti]->srs_cfg, srs_cfg, sizeof(srslte_refsignal_srs_cfg_t)); + q->users[rnti]->srs_cfg_en = true; } else { - q->srs_cfg_en[idx] = false; + q->users[rnti]->srs_cfg_en = false; } return SRSLTE_SUCCESS; } else { - fprintf(stderr, "Error configuring UE: Invalid idx=%d, max users=%d\n", idx, q->nof_rnti); + fprintf(stderr, "Error configuring UE: rnti=0x%x not found\n", rnti); return SRSLTE_ERROR; } } - -int srslte_enb_ul_rem_rnti(srslte_enb_ul_t *q, uint32_t idx) -{ - return srslte_pusch_set_rnti_multi(&q->pusch, idx, 0); -} void srslte_enb_ul_fft(srslte_enb_ul_t *q, cf_t *signal_buffer) { srslte_ofdm_rx_sf(&q->fft, signal_buffer, q->sf_symbols); } -int get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, +int get_pucch(srslte_enb_ul_t *q, uint16_t rnti, uint32_t pdcch_n_cce, uint32_t sf_rx, srslte_uci_data_t *uci_data, uint8_t bits[SRSLTE_PUCCH_MAX_BITS]) { @@ -223,7 +219,7 @@ int get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, srslte_pucch_format_t format = srslte_pucch_get_format(uci_data, q->cell.cp); - uint32_t n_pucch = srslte_pucch_get_npucch(pdcch_n_cce, format, uci_data->scheduling_request, &q->pucch_sched[rnti_idx]); + uint32_t n_pucch = srslte_pucch_get_npucch(pdcch_n_cce, format, uci_data->scheduling_request, &q->users[rnti]->pucch_sched); if (srslte_chest_ul_estimate_pucch(&q->chest, q->sf_symbols, q->ce, format, n_pucch, sf_rx)) { fprintf(stderr,"Error estimating PUCCH DMRS\n"); @@ -239,21 +235,21 @@ int get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, return ret_val; } -int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, +int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint16_t rnti, uint32_t pdcch_n_cce, uint32_t sf_rx, srslte_uci_data_t *uci_data) { uint8_t bits[SRSLTE_PUCCH_MAX_BITS]; - if (rnti_idx < q->nof_rnti) { + if (q->users[rnti]) { - int ret_val = get_pucch(q, rnti_idx, pdcch_n_cce, sf_rx, uci_data, bits); + int ret_val = get_pucch(q, rnti, pdcch_n_cce, sf_rx, uci_data, bits); // If we are looking for SR and ACK at the same time and ret=0, means there is no SR. // try again to decode ACK only if (uci_data->scheduling_request && uci_data->uci_ack_len && ret_val != 1) { uci_data->scheduling_request = false; - ret_val = get_pucch(q, rnti_idx, pdcch_n_cce, sf_rx, uci_data, bits); + ret_val = get_pucch(q, rnti, pdcch_n_cce, sf_rx, uci_data, bits); } // update schedulign request @@ -271,38 +267,50 @@ int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, uint32_t rnti_idx, } return SRSLTE_SUCCESS; } else { - fprintf(stderr, "Invalid rnti_idx=%d\n", rnti_idx); + fprintf(stderr, "Error getting PUCCH: rnti=0x%x not found\n", rnti); return SRSLTE_ERROR; } } int srslte_enb_ul_get_pusch(srslte_enb_ul_t *q, srslte_ra_ul_grant_t *grant, srslte_softbuffer_rx_t *softbuffer, - uint32_t rnti_idx, uint32_t rv_idx, uint32_t current_tx_nb, + uint16_t rnti, uint32_t rv_idx, uint32_t current_tx_nb, uint8_t *data, srslte_uci_data_t *uci_data, uint32_t tti) { - - if (srslte_pusch_cfg(&q->pusch, - &q->pusch_cfg, - grant, - q->uci_cfg_en[rnti_idx]?&q->uci_cfg[rnti_idx]:NULL, - &q->hopping_cfg, - q->srs_cfg_en[rnti_idx]?&q->srs_cfg[rnti_idx]:NULL, - tti, rv_idx, current_tx_nb)) { - fprintf(stderr, "Error configuring PDSCH\n"); - return SRSLTE_ERROR; + if (q->users[rnti]) { + if (srslte_pusch_cfg(&q->pusch, + &q->pusch_cfg, + grant, + q->users[rnti]->uci_cfg_en?&q->users[rnti]->uci_cfg:NULL, + &q->hopping_cfg, + q->users[rnti]->srs_cfg_en?&q->users[rnti]->srs_cfg:NULL, + tti, rv_idx, current_tx_nb)) { + fprintf(stderr, "Error configuring PDSCH\n"); + return SRSLTE_ERROR; + } + } else { + if (srslte_pusch_cfg(&q->pusch, + &q->pusch_cfg, + grant, + NULL, + &q->hopping_cfg, + NULL, + tti, rv_idx, current_tx_nb)) { + fprintf(stderr, "Error configuring PDSCH\n"); + return SRSLTE_ERROR; + } } - + uint32_t cyclic_shift_for_dmrs = 0; srslte_chest_ul_estimate(&q->chest, q->sf_symbols, q->ce, grant->L_prb, tti%10, cyclic_shift_for_dmrs, grant->n_prb); float noise_power = srslte_chest_ul_get_noise_estimate(&q->chest); - return srslte_pusch_uci_decode_rnti_idx(&q->pusch, &q->pusch_cfg, - softbuffer, q->sf_symbols, - q->ce, noise_power, - rnti_idx, data, - uci_data); + return srslte_pusch_decode(&q->pusch, &q->pusch_cfg, + softbuffer, q->sf_symbols, + q->ce, noise_power, + rnti, data, + uci_data); } diff --git a/srslte/lib/phch/pdsch.c b/srslte/lib/phch/pdsch.c index b6184f0a6..b4ae7621f 100644 --- a/srslte/lib/phch/pdsch.c +++ b/srslte/lib/phch/pdsch.c @@ -216,7 +216,6 @@ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) { q->cell = cell; q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp); - q->nof_crnti = 0; INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports, q->cell.nof_prb, q->max_re); @@ -230,8 +229,6 @@ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) { srslte_sch_init(&q->dl_sch); - q->rnti_is_set = false; - // Allocate int16_t for reception (LLRs) q->e = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); if (!q->e) { @@ -257,7 +254,13 @@ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) { goto clean; } } - + + q->users = calloc(sizeof(srslte_pdsch_user_t*), 1+SRSLTE_SIRNTI); + if (!q->users) { + perror("malloc"); + goto clean; + } + ret = SRSLTE_SUCCESS; } clean: @@ -288,23 +291,14 @@ void srslte_pdsch_free(srslte_pdsch_t *q) { } } - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq[i]); - } - - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - for (int n=0;nnof_crnti;n++) { - srslte_sequence_free(&q->seq_multi[i][n]); - } - if (q->seq_multi[i]) { - free(q->seq_multi[i]); - } - } - - if (q->rnti_multi) { - free(q->rnti_multi); + if (q->users) { + for (uint16_t u=0;uusers[u]) { + srslte_pdsch_free_rnti(q, u); + } + } + free(q->users); } - for (i = 0; i < 4; i++) { srslte_modem_table_free(&q->mod[i]); } @@ -343,102 +337,38 @@ int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_g * 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 i; - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pdsch(&q->seq[i], rnti, 0, 2 * i, q->cell.id, - q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { - return SRSLTE_ERROR; - } - } - q->rnti_is_set = true; - q->rnti = rnti; - return SRSLTE_SUCCESS; -} - -/* Initializes the memory to support pre-calculation of multiple scrambling sequences */ -int srslte_pdsch_init_rnti_multi(srslte_pdsch_t *q, uint32_t nof_rntis) -{ - for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - q->seq_multi[i] = malloc(sizeof(srslte_sequence_t)*nof_rntis); - if (!q->seq_multi[i]) { - perror("malloc"); - return SRSLTE_ERROR; - } - } - - q->rnti_multi = srslte_vec_malloc(sizeof(uint16_t)*nof_rntis); - if (!q->rnti_multi) { - perror("malloc"); - return SRSLTE_ERROR; - } - bzero(q->rnti_multi, sizeof(uint16_t)*nof_rntis); - - q->nof_crnti = nof_rntis; - - return SRSLTE_SUCCESS; -} - -int srslte_pdsch_set_rnti_multi(srslte_pdsch_t *q, uint32_t idx, uint16_t rnti) -{ - if (idx < q->nof_crnti) { - if (q->rnti_multi[idx]) { - for (uint32_t i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq_multi[i][idx]); - } - q->rnti_multi[idx] = 0; - } - if (rnti) { - q->rnti_multi[idx] = rnti; - q->rnti_is_set = true; - for (uint32_t i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pdsch(&q->seq_multi[i][idx], rnti, 0, 2 * i, q->cell.id, + uint32_t i; + if (!q->users[rnti]) { + q->users[rnti] = calloc(1, sizeof(srslte_pdsch_user_t)); + if (q->users[rnti]) { + for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { + if (srslte_sequence_pdsch(&q->users[rnti]->seq[i], rnti, 0, 2 * i, q->cell.id, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { return SRSLTE_ERROR; } } } - return SRSLTE_SUCCESS; - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -uint16_t srslte_pdsch_get_rnti_multi(srslte_pdsch_t *q, uint32_t idx) -{ - if (idx < q->nof_crnti) { - return q->rnti_multi[idx]; - } else { - return SRSLTE_ERROR_INVALID_INPUTS; } + return SRSLTE_SUCCESS; } -int srslte_pdsch_decode(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, - uint8_t *data) +void srslte_pdsch_free_rnti(srslte_pdsch_t* q, uint16_t rnti) { - if (q != NULL && - sf_symbols != NULL && - data != NULL && - cfg != NULL) - { - if (q->rnti_is_set) { - return srslte_pdsch_decode_rnti(q, cfg, softbuffer, sf_symbols, ce, noise_estimate, q->rnti, data); - } else { - fprintf(stderr, "Must call srslte_pdsch_set_rnti() before calling srslte_pdsch_decode()\n"); - return SRSLTE_ERROR; + if (q->users[rnti]) { + for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { + srslte_sequence_free(&q->users[rnti]->seq[i]); } - } else { - return SRSLTE_ERROR_INVALID_INPUTS; + free(q->users[rnti]); + q->users[rnti] = NULL; } } /** Decodes the PDSCH from the received symbols */ -int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, - uint16_t rnti, uint8_t *data) +int srslte_pdsch_decode(srslte_pdsch_t *q, + srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, + cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, + uint16_t rnti, uint8_t *data) { /* Set pointers for layermapping & precoding */ @@ -506,16 +436,8 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, */ srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->e, cfg->nbits.nof_re); - /* - printf("WARNING REMOVE ME!\n"); - int16_t *e=q->e; - for (int i=0;inbits.nof_bits;i++) { - e[i] = e[i]>0?10:-10; - } - */ - /* descramble */ - if (rnti != q->rnti) { + if (!q->users[rnti]) { srslte_sequence_t seq; if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; @@ -523,7 +445,7 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, srslte_scrambling_s_offset(&seq, q->e, 0, cfg->nbits.nof_bits); srslte_sequence_free(&seq); } else { - srslte_scrambling_s_offset(&q->seq[cfg->sf_idx], q->e, 0, cfg->nbits.nof_bits); + srslte_scrambling_s_offset(&q->users[rnti]->seq[cfg->sf_idx], q->e, 0, cfg->nbits.nof_bits); } if (SRSLTE_VERBOSE_ISDEBUG()) { @@ -539,27 +461,8 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, } int srslte_pdsch_encode(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) -{ - if (q != NULL && - data != NULL && - cfg != NULL) - { - if (q->rnti_is_set) { - return srslte_pdsch_encode_rnti(q, cfg, softbuffer, data, q->rnti, sf_symbols); - } else { - fprintf(stderr, "Must call srslte_pdsch_set_rnti() to set the encoder/decoder RNTI\n"); - return SRSLTE_ERROR; - } - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -int srslte_pdsch_encode_seq(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, srslte_sequence_t *seq, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) + srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, + uint8_t *data, uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) { int i; @@ -603,8 +506,18 @@ int srslte_pdsch_encode_seq(srslte_pdsch_t *q, return SRSLTE_ERROR; } - srslte_scrambling_bytes(seq, (uint8_t*) q->e, cfg->nbits.nof_bits); - + /* scramble */ + if (!q->users[rnti]) { + srslte_sequence_t seq; + if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { + return SRSLTE_ERROR; + } + srslte_scrambling_bytes(&q->users[rnti]->seq[cfg->sf_idx], (uint8_t*) q->e, cfg->nbits.nof_bits); + srslte_sequence_free(&seq); + } else { + srslte_scrambling_bytes(&q->users[rnti]->seq[cfg->sf_idx], (uint8_t*) q->e, cfg->nbits.nof_bits); + } + srslte_mod_modulate_bytes(&q->mod[cfg->grant.mcs.mod], (uint8_t*) q->e, q->d, cfg->nbits.nof_bits); /* TODO: only diversity supported */ @@ -626,42 +539,6 @@ int srslte_pdsch_encode_seq(srslte_pdsch_t *q, return ret; } -int srslte_pdsch_encode_rnti_idx(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, uint32_t rnti_idx, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) -{ - if (rnti_idx < q->nof_crnti) { - if (q->rnti_multi[rnti_idx]) { - return srslte_pdsch_encode_seq(q, cfg, softbuffer, data, &q->seq_multi[cfg->sf_idx][rnti_idx], sf_symbols); - } else { - fprintf(stderr, "Error RNTI idx %d not set\n", rnti_idx); - return SRSLTE_ERROR; - } - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -/** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission - */ -int srslte_pdsch_encode_rnti(srslte_pdsch_t *q, - srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) -{ - if (rnti != q->rnti) { - srslte_sequence_t seq; - if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { - return SRSLTE_ERROR; - } - int r = srslte_pdsch_encode_seq(q, cfg, softbuffer, data, &seq, sf_symbols); - srslte_sequence_free(&seq); - return r; - } else { - return srslte_pdsch_encode_seq(q, cfg, softbuffer, data, &q->seq[cfg->sf_idx], sf_symbols); - } -} - - float srslte_pdsch_average_noi(srslte_pdsch_t *q) { return q->dl_sch.average_nof_iterations; diff --git a/srslte/lib/phch/pusch.c b/srslte/lib/phch/pusch.c index 8f73e71da..7c4484872 100644 --- a/srslte/lib/phch/pusch.c +++ b/srslte/lib/phch/pusch.c @@ -209,6 +209,12 @@ int srslte_pusch_init(srslte_pusch_t *q, srslte_cell_t cell) { srslte_modem_table_bytes(&q->mod[i]); } + q->users = calloc(sizeof(srslte_pusch_user_t*), 1+SRSLTE_SIRNTI); + if (!q->users) { + perror("malloc"); + goto clean; + } + /* Precompute sequence for type2 frequency hopping */ if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) { fprintf(stderr, "Error initiating type2 frequency hopping sequence\n"); @@ -222,8 +228,6 @@ int srslte_pusch_init(srslte_pusch_t *q, srslte_cell_t cell) { goto clean; } - q->rnti_is_set = false; - // Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission q->q = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); if (!q->q) { @@ -279,10 +283,12 @@ void srslte_pusch_free(srslte_pusch_t *q) { srslte_dft_precoding_free(&q->dft_precoding); - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq[i]); + if (q->users) { + for (int rnti=0;rntiusers); } - srslte_sequence_free(&q->seq_type2_fo); for (i = 0; i < 4; i++) { @@ -382,118 +388,39 @@ int srslte_pusch_cfg(srslte_pusch_t *q, /* 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 */ + * For the connection procedure, use srslte_pusch_encode() functions */ int srslte_pusch_set_rnti(srslte_pusch_t *q, uint16_t rnti) { uint32_t i; - - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pusch(&q->seq[i], rnti, 2 * i, q->cell.id, - q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { - return SRSLTE_ERROR; - } - } - q->rnti_is_set = true; - q->rnti = rnti; - return SRSLTE_SUCCESS; -} - - -/* Initializes the memory to support pre-calculation of multiple scrambling sequences */ -int srslte_pusch_init_rnti_multi(srslte_pusch_t *q, uint32_t nof_rntis) -{ - for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - q->seq_multi[i] = malloc(sizeof(srslte_sequence_t)*nof_rntis); - if (!q->seq_multi[i]) { - perror("malloc"); - return SRSLTE_ERROR; - } - } - q->rnti_multi = srslte_vec_malloc(sizeof(uint16_t)*nof_rntis); - if (!q->rnti_multi) { - perror("malloc"); - return SRSLTE_ERROR; - } - bzero(q->rnti_multi, sizeof(uint16_t)*nof_rntis); - - q->nof_crnti = nof_rntis; - - return SRSLTE_SUCCESS; -} - -int srslte_pusch_set_rnti_multi(srslte_pusch_t *q, uint32_t idx, uint16_t rnti) -{ - if (idx < q->nof_crnti) { - if (q->rnti_multi[idx]) { - for (uint32_t i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq_multi[i][idx]); - } - q->rnti_multi[idx] = 0; - } - if (rnti) { - q->rnti_multi[idx] = rnti; - q->rnti_is_set = true; - for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pusch(&q->seq_multi[i][idx], rnti, 2 * i, q->cell.id, + if (!q->users[rnti]) { + q->users[rnti] = malloc(sizeof(srslte_pusch_user_t)); + if (q->users[rnti]) { + for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { + if (srslte_sequence_pusch(&q->users[rnti]->seq[i], rnti, 2 * i, q->cell.id, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { return SRSLTE_ERROR; } - } + } } - return SRSLTE_SUCCESS; - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -uint16_t srslte_pusch_get_rnti_multi(srslte_pusch_t *q, uint32_t idx) -{ - if (idx < q->nof_crnti) { - return q->rnti_multi[idx]; - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -int srslte_pusch_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, uint16_t rnti, - cf_t *sf_symbols) -{ - srslte_uci_data_t uci_data; - bzero(&uci_data, sizeof(srslte_uci_data_t)); - return srslte_pusch_uci_encode_rnti(q, cfg, softbuffer, data, uci_data, rnti, sf_symbols); -} - -int srslte_pusch_encode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, cf_t *sf_symbols) -{ - if (q->rnti_is_set) { - srslte_uci_data_t uci_data; - bzero(&uci_data, sizeof(srslte_uci_data_t)); - return srslte_pusch_uci_encode_rnti(q, cfg, softbuffer, data, uci_data, q->rnti, sf_symbols); - } else { - fprintf(stderr, "Must call srslte_pusch_set_rnti() to set the encoder/decoder RNTI\n"); - return SRSLTE_ERROR; } + return SRSLTE_SUCCESS; } -int srslte_pusch_uci_encode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, srslte_uci_data_t uci_data, - cf_t *sf_symbols) -{ - if (q->rnti_is_set) { - return srslte_pusch_uci_encode_rnti(q, cfg, softbuffer, data, uci_data, q->rnti, sf_symbols); - } else { - fprintf(stderr, "Must call srslte_pusch_set_rnti() to set the encoder/decoder RNTI\n"); - return SRSLTE_ERROR; +void srslte_pusch_clear_rnti(srslte_pusch_t *q, uint16_t rnti) { + if (q->users[rnti]) { + for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { + srslte_sequence_free(&q->users[rnti]->seq[i]); + } + free(q->users[rnti]); + q->users[rnti] = NULL; } } /** Converts the PUSCH data bits to symbols mapped to the slot ready for transmission */ -int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, - uint8_t *data, srslte_uci_data_t uci_data, uint16_t rnti, - cf_t *sf_symbols) +int srslte_pusch_encode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, + uint8_t *data, srslte_uci_data_t uci_data, uint16_t rnti, + cf_t *sf_symbols) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -517,7 +444,7 @@ int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srs return SRSLTE_ERROR; } - if (rnti != q->rnti || !q->rnti_is_set) { + if (!q->users[rnti]) { srslte_sequence_t seq; if (srslte_sequence_pusch(&seq, rnti, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; @@ -525,7 +452,7 @@ int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srs srslte_scrambling_bytes(&seq, (uint8_t*) q->q, cfg->nbits.nof_bits); srslte_sequence_free(&seq); } else { - srslte_scrambling_bytes(&q->seq[cfg->sf_idx], (uint8_t*) q->q, cfg->nbits.nof_bits); + srslte_scrambling_bytes(&q->users[rnti]->seq[cfg->sf_idx], (uint8_t*) q->q, cfg->nbits.nof_bits); } // Correct UCI placeholder/repetition bits @@ -560,23 +487,14 @@ int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srs return ret; } + +/** Decodes the PUSCH from the received symbols + */ int srslte_pusch_decode(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, cf_t *sf_symbols, - cf_t *ce, float noise_estimate, - uint8_t *data) -{ - srslte_uci_data_t uci_data; - bzero(&uci_data, sizeof(srslte_uci_data_t)); - return srslte_pusch_uci_decode(q, cfg, softbuffer, sf_symbols, ce, noise_estimate, data, &uci_data); -} - -int srslte_pusch_uci_decode_seq(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - srslte_sequence_t *seq, - cf_t *sf_symbols, - cf_t *ce, float noise_estimate, - uint8_t *data, srslte_uci_data_t *uci_data) + cf_t *ce, float noise_estimate, uint16_t rnti, + uint8_t *data, srslte_uci_data_t *uci_data) { uint32_t n; @@ -587,82 +505,63 @@ int srslte_pusch_uci_decode_seq(srslte_pusch_t *q, cfg != NULL) { - if (q->rnti_is_set) { - INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d\n", - cfg->sf_idx, srslte_mod_string(cfg->grant.mcs.mod), cfg->grant.mcs.tbs, - cfg->nbits.nof_re, cfg->nbits.nof_symb, cfg->nbits.nof_bits, cfg->rv); - - /* extract symbols */ - n = pusch_get(q, &cfg->grant, sf_symbols, q->d); - if (n != cfg->nbits.nof_re) { - fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); - return SRSLTE_ERROR; - } - - /* extract channel estimates */ - n = pusch_get(q, &cfg->grant, ce, q->ce); - if (n != cfg->nbits.nof_re) { - fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); - return SRSLTE_ERROR; - } + INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d\n", + cfg->sf_idx, srslte_mod_string(cfg->grant.mcs.mod), cfg->grant.mcs.tbs, + cfg->nbits.nof_re, cfg->nbits.nof_symb, cfg->nbits.nof_bits, cfg->rv); + + /* extract symbols */ + n = pusch_get(q, &cfg->grant, sf_symbols, q->d); + if (n != cfg->nbits.nof_re) { + fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); + return SRSLTE_ERROR; + } + + /* extract channel estimates */ + n = pusch_get(q, &cfg->grant, ce, q->ce); + if (n != cfg->nbits.nof_re) { + fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); + return SRSLTE_ERROR; + } - // Equalization - srslte_predecoding_single(q->d, q->ce, q->z, cfg->nbits.nof_re, noise_estimate); - - // DFT predecoding - srslte_dft_predecoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->nbits.nof_symb); - - // Soft demodulation - srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re); + // Equalization + srslte_predecoding_single(q->d, q->ce, q->z, cfg->nbits.nof_re, noise_estimate); + + // DFT predecoding + srslte_dft_predecoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->nbits.nof_symb); + + // Soft demodulation + srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re); - // Decode RI/HARQ bits before descrambling - if (srslte_ulsch_uci_decode_ri_ack(&q->ul_sch, cfg, softbuffer, q->q, seq->c, uci_data)) { - fprintf(stderr, "Error decoding RI/HARQ bits\n"); + srslte_sequence_t *seq = NULL; + + // Create sequence if does not exist + if (!q->users[rnti]) { + srslte_sequence_t tmp; + seq = &tmp; + if (srslte_sequence_pusch(seq, rnti, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; } - - // Descrambling - srslte_scrambling_s_offset(seq, q->q, 0, cfg->nbits.nof_bits); - - return srslte_ulsch_uci_decode(&q->ul_sch, cfg, softbuffer, q->q, q->g, data, uci_data); } else { - fprintf(stderr, "Must call srslte_pusch_set_rnti() before calling srslte_pusch_decode()\n"); - return SRSLTE_ERROR; - } - } else { - return SRSLTE_ERROR_INVALID_INPUTS; - } -} - -/** Decodes the PUSCH from the received symbols - */ -int srslte_pusch_uci_decode(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, - cf_t *ce, float noise_estimate, - uint8_t *data, srslte_uci_data_t *uci_data) -{ - return srslte_pusch_uci_decode_seq(q, cfg, softbuffer, &q->seq[cfg->sf_idx], sf_symbols, ce, noise_estimate, data, uci_data); -} - -/** Decodes the PUSCH from the received symbols for a given RNTI index - */ -int srslte_pusch_uci_decode_rnti_idx(srslte_pusch_t *q, - srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - cf_t *sf_symbols, - cf_t *ce, float noise_estimate, - uint32_t rnti_idx, - uint8_t *data, srslte_uci_data_t *uci_data) -{ - if (rnti_idx < q->nof_crnti) { - if (q->rnti_multi[rnti_idx]) { - return srslte_pusch_uci_decode_seq(q, cfg, softbuffer, &q->seq_multi[cfg->sf_idx][rnti_idx], sf_symbols, ce, noise_estimate, data, uci_data); - } else { - fprintf(stderr, "Error RNTI idx %d not set\n", rnti_idx); + seq = &q->users[rnti]->seq[cfg->sf_idx]; + } + + // Decode RI/HARQ bits before descrambling + if (srslte_ulsch_uci_decode_ri_ack(&q->ul_sch, cfg, softbuffer, q->q, seq->c, uci_data)) { + fprintf(stderr, "Error decoding RI/HARQ bits\n"); return SRSLTE_ERROR; } + + // Descrambling + srslte_scrambling_s_offset(seq, q->q, 0, cfg->nbits.nof_bits); + + if (!q->users[rnti]) { + srslte_scrambling_s_offset(seq, q->q, 0, cfg->nbits.nof_bits); + srslte_sequence_free(seq); + } + + return srslte_ulsch_uci_decode(&q->ul_sch, cfg, softbuffer, q->q, q->g, data, uci_data); } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSLTE_ERROR_INVALID_INPUTS; } } diff --git a/srslte/lib/phch/test/pdsch_test.c b/srslte/lib/phch/test/pdsch_test.c index 2e869f6f2..3b3b1e568 100644 --- a/srslte/lib/phch/test/pdsch_test.c +++ b/srslte/lib/phch/test/pdsch_test.c @@ -229,14 +229,14 @@ int main(int argc, char **argv) { if (rv_idx) { /* Do 1st transmission for rv_idx!=0 */ pdsch_cfg.rv = 0; - if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) { + if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, rnti, slot_symbols)) { fprintf(stderr, "Error encoding PDSCH\n"); goto quit; } } pdsch_cfg.rv = rv_idx; - if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) { + if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, rnti, slot_symbols)) { fprintf(stderr, "Error encoding PDSCH\n"); goto quit; } @@ -265,7 +265,7 @@ int main(int argc, char **argv) { srslte_ofdm_rx_sf(&ofdm_rx, sf_symbols, slot_symbols[1]); #endif srslte_softbuffer_rx_reset_tbs(&softbuffer_rx, grant.mcs.tbs); - r = srslte_pdsch_decode(&pdsch, &pdsch_cfg, &softbuffer_rx, slot_symbols[0], ce, 0, data); + r = srslte_pdsch_decode(&pdsch, &pdsch_cfg, &softbuffer_rx, slot_symbols[0], ce, 0, rnti, data); } gettimeofday(&t[2], NULL); get_time_interval(t); diff --git a/srslte/lib/phch/test/pdsch_test_mex.c b/srslte/lib/phch/test/pdsch_test_mex.c index 9deaef2cb..45bd1ae09 100644 --- a/srslte/lib/phch/test/pdsch_test_mex.c +++ b/srslte/lib/phch/test/pdsch_test_mex.c @@ -97,7 +97,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Error initiating PDSCH\n"); return; } - srslte_pdsch_set_rnti(&pdsch, (uint16_t) (rnti32 & 0xffff)); + uint16_t rnti = (uint16_t) (rnti32 & 0xffff); + srslte_pdsch_set_rnti(&pdsch, rnti); if (srslte_softbuffer_rx_init(&softbuffer, cell.nof_prb)) { mexErrMsgTxt("Error initiating soft buffer\n"); @@ -250,7 +251,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) noise_power = srslte_chest_dl_get_noise_estimate(&chest); } - r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes); + r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, rnti, data_bytes); } uint8_t *data = malloc(grant.mcs.tbs); diff --git a/srslte/lib/phch/test/pusch_encode_test_mex.c b/srslte/lib/phch/test/pusch_encode_test_mex.c index 4d8693bbf..59c0bbe15 100644 --- a/srslte/lib/phch/test/pusch_encode_test_mex.c +++ b/srslte/lib/phch/test/pusch_encode_test_mex.c @@ -76,8 +76,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Field RNTI not found in pusch config\n"); return; } - srslte_pusch_set_rnti(&pusch, (uint16_t) (rnti32 & 0xffff)); + uint16_t rnti = (uint16_t) (rnti32 & 0xffff); + srslte_pusch_set_rnti(&pusch, rnti); srslte_pusch_cfg_t cfg; @@ -195,7 +196,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexPrintf("I_cqi: %2d, I_ri: %2d, I_ack=%2d\n", cfg.uci_cfg.I_offset_cqi, cfg.uci_cfg.I_offset_ri, cfg.uci_cfg.I_offset_ack); mexPrintf("NofRE: %3d, NofBits: %3d, TBS: %3d, N_srs=%d\n", cfg.nbits.nof_re, cfg.nbits.nof_bits, grant.mcs.tbs, N_srs); - int r = srslte_pusch_uci_encode(&pusch, &cfg, &softbuffer, trblkin, uci_data, sf_symbols); + int r = srslte_pusch_encode(&pusch, &cfg, &softbuffer, trblkin, uci_data, rnti, sf_symbols); if (r < 0) { mexErrMsgTxt("Error encoding PUSCH\n"); return; @@ -205,7 +206,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } if (cfg.rv > 0) { - r = srslte_pusch_uci_encode(&pusch, &cfg, &softbuffer, trblkin, uci_data, sf_symbols); + r = srslte_pusch_encode(&pusch, &cfg, &softbuffer, trblkin, uci_data, rnti, sf_symbols); if (r < 0) { mexErrMsgTxt("Error encoding PUSCH\n"); return; diff --git a/srslte/lib/phch/test/pusch_test.c b/srslte/lib/phch/test/pusch_test.c index def6b5982..29980a83f 100644 --- a/srslte/lib/phch/test/pusch_test.c +++ b/srslte/lib/phch/test/pusch_test.c @@ -164,7 +164,8 @@ int main(int argc, char **argv) { exit(-1); } - srslte_pusch_set_rnti(&pusch, 1234); + uint16_t rnti = 1234; + srslte_pusch_set_rnti(&pusch, rnti); srslte_uci_data_t uci_data_tx; srslte_uci_data_t uci_data_rx; @@ -208,13 +209,13 @@ int main(int argc, char **argv) { uint32_t ntrials = 100; - if (srslte_pusch_uci_encode(&pusch, &cfg, &softbuffer_tx, data, uci_data_tx, sf_symbols)) { + if (srslte_pusch_encode(&pusch, &cfg, &softbuffer_tx, data, uci_data_tx, rnti, sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); exit(-1); } if (rv_idx > 0) { cfg.rv = rv_idx; - if (srslte_pusch_uci_encode(&pusch, &cfg, &softbuffer_tx, data, uci_data_tx, sf_symbols)) { + if (srslte_pusch_encode(&pusch, &cfg, &softbuffer_tx, data, uci_data_tx, rnti, sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); exit(-1); } @@ -230,7 +231,7 @@ int main(int argc, char **argv) { } gettimeofday(&t[1], NULL); - int r = srslte_pusch_uci_decode(&pusch, &cfg, &softbuffer_rx, sf_symbols, ce, 0, data, &uci_data_rx); + int r = srslte_pusch_decode(&pusch, &cfg, &softbuffer_rx, sf_symbols, ce, 0, rnti, data, &uci_data_rx); gettimeofday(&t[2], NULL); get_time_interval(t); if (r) { diff --git a/srslte/lib/phch/uci.c b/srslte/lib/phch/uci.c index 10a4a99c1..b22ff75ec 100644 --- a/srslte/lib/phch/uci.c +++ b/srslte/lib/phch/uci.c @@ -299,8 +299,9 @@ int decode_cqi_long(srslte_uci_cqi_pusch_t *q, int16_t *q_bits, uint32_t Q, // Set viterbi normalization based on amplitude int16_t max = srslte_vec_max_abs_star_si(q->encoded_cqi_s, 3 * (nof_bits + 8)); - srslte_viterbi_set_gain_quant_s(&q->viterbi, (float) abs(max)/36); - + if (max != 0) { + srslte_viterbi_set_gain_quant_s(&q->viterbi, (float) abs(max)/36); + } DEBUG("cconv_rx=", 0); if (SRSLTE_VERBOSE_ISDEBUG()) { srslte_vec_fprint_s(stdout, q->encoded_cqi_s, 3 * (nof_bits + 8)); diff --git a/srslte/lib/ue/ue_dl.c b/srslte/lib/ue/ue_dl.c index 9444be773..3f4e739fa 100644 --- a/srslte/lib/ue/ue_dl.c +++ b/srslte/lib/ue/ue_dl.c @@ -299,7 +299,7 @@ int srslte_ue_dl_decode_rnti(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, uint float noise_estimate = srslte_chest_dl_get_noise_estimate(&q->chest); if (q->pdsch_cfg.grant.mcs.mod > 0 && q->pdsch_cfg.grant.mcs.tbs >= 0) { - ret = srslte_pdsch_decode_rnti(&q->pdsch, &q->pdsch_cfg, &q->softbuffer, + ret = srslte_pdsch_decode(&q->pdsch, &q->pdsch_cfg, &q->softbuffer, q->sf_symbols, q->ce, noise_estimate, rnti, data); @@ -543,7 +543,7 @@ void srslte_ue_dl_save_signal(srslte_ue_dl_t *q, srslte_softbuffer_rx_t *softbuf snprintf(tmpstr,64,"rmout_%d.dat",i); srslte_vec_save_file(tmpstr, softbuffer->buffer_f[i], (3*cb_len+12)*sizeof(int16_t)); } - printf("Saved files for tti=%d, sf=%d, cfi=%d, mcs=%d, rv=%d, rnti=%d\n", tti, tti%10, cfi, + printf("Saved files for tti=%d, sf=%d, cfi=%d, mcs=%d, rv=%d, rnti=0x%x\n", tti, tti%10, cfi, q->pdsch_cfg.grant.mcs.idx, rv_idx, rnti); } diff --git a/srslte/lib/ue/ue_ul.c b/srslte/lib/ue/ue_ul.c index 483c83820..2b05e2df1 100644 --- a/srslte/lib/ue/ue_ul.c +++ b/srslte/lib/ue/ue_ul.c @@ -394,7 +394,7 @@ int srslte_ue_ul_pusch_encode_rnti_softbuffer(srslte_ue_ul_t *q, bzero(q->sf_symbols, sizeof(cf_t)*SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)); - if (srslte_pusch_uci_encode_rnti(&q->pusch, &q->pusch_cfg, softbuffer, data, uci_data, rnti, q->sf_symbols)) { + if (srslte_pusch_encode(&q->pusch, &q->pusch_cfg, softbuffer, data, uci_data, rnti, q->sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); return ret; }