Simplified API for PDSCH and PUSCH. Dynamically handle multiple RNTIs

master
Ismael Gomez 8 years ago
parent 015b0e4eb1
commit 62b63462c9

@ -624,7 +624,7 @@ int main(int argc, char **argv) {
} }
/* Encode PDSCH */ /* 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"); fprintf(stderr, "Error encoding PDSCH\n");
exit(-1); exit(-1);
} }

@ -87,13 +87,12 @@ typedef struct SRSLTE_API {
float sss_signal0[SRSLTE_SSS_LEN]; float sss_signal0[SRSLTE_SSS_LEN];
float sss_signal5[SRSLTE_SSS_LEN]; float sss_signal5[SRSLTE_SSS_LEN];
uint32_t nof_rnti;
float tx_amp; float tx_amp;
} srslte_enb_dl_t; } srslte_enb_dl_t;
typedef struct { typedef struct {
int rnti_idx; uint16_t rnti;
srslte_ra_dl_dci_t grant; srslte_ra_dl_dci_t grant;
srslte_dci_location_t location; srslte_dci_location_t location;
srslte_softbuffer_tx_t *softbuffer; srslte_softbuffer_tx_t *softbuffer;
@ -101,14 +100,15 @@ typedef struct {
} srslte_enb_dl_pdsch_t; } srslte_enb_dl_pdsch_t;
typedef struct { typedef struct {
uint16_t rnti;
uint8_t ack; uint8_t ack;
int rnti_idx; uint32_t n_prb_lowest;
uint32_t n_dmrs;
} srslte_enb_dl_phich_t; } srslte_enb_dl_phich_t;
/* This function shall be called just after the initial synchronization */ /* This function shall be called just after the initial synchronization */
SRSLTE_API int srslte_enb_dl_init(srslte_enb_dl_t *q, SRSLTE_API int srslte_enb_dl_init(srslte_enb_dl_t *q,
srslte_cell_t cell, srslte_cell_t cell);
uint32_t nof_rntis);
SRSLTE_API void srslte_enb_dl_free(srslte_enb_dl_t *q); 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, SRSLTE_API void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q,
cf_t *signal_buffer); cf_t *signal_buffer);
SRSLTE_API int srslte_enb_dl_cfg_rnti(srslte_enb_dl_t *q, SRSLTE_API int srslte_enb_dl_add_rnti(srslte_enb_dl_t *q,
uint32_t idx,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q, SRSLTE_API void srslte_enb_dl_rem_rnti(srslte_enb_dl_t *q,
uint32_t idx); uint16_t rnti);
SRSLTE_API int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q, SRSLTE_API int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q,
srslte_ra_dl_grant_t *grant, srslte_ra_dl_grant_t *grant,
srslte_softbuffer_tx_t *softbuffer, srslte_softbuffer_tx_t *softbuffer,
uint32_t rnti_idx, uint16_t rnti,
uint32_t rv_idx, uint32_t rv_idx,
uint32_t sf_idx, uint32_t sf_idx,
uint8_t *data); 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_ra_dl_dci_t *grant,
srslte_dci_format_t format, srslte_dci_format_t format,
srslte_dci_location_t location, srslte_dci_location_t location,
uint32_t rnti_idx, uint16_t rnti,
uint32_t sf_idx); uint32_t sf_idx);
SRSLTE_API int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, SRSLTE_API int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q,
srslte_ra_ul_dci_t *grant, srslte_ra_ul_dci_t *grant,
srslte_dci_location_t location, srslte_dci_location_t location,
uint32_t rnti_idx, uint16_t rnti,
uint32_t sf_idx); uint32_t sf_idx);

@ -58,9 +58,16 @@ typedef struct {
uint32_t n_dmrs; uint32_t n_dmrs;
} srslte_enb_ul_phich_info_t; } 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 { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
uint32_t nof_rnti;
cf_t *sf_symbols; cf_t *sf_symbols;
cf_t *ce; cf_t *ce;
@ -77,16 +84,12 @@ typedef struct SRSLTE_API {
srslte_pusch_hopping_cfg_t hopping_cfg; srslte_pusch_hopping_cfg_t hopping_cfg;
// Configuration for each user // Configuration for each user
bool *uci_cfg_en; srslte_enb_ul_user_t **users;
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_t; } srslte_enb_ul_t;
typedef struct { typedef struct {
int rnti_idx; uint16_t rnti;
srslte_ra_ul_dci_t grant; srslte_ra_ul_dci_t grant;
srslte_dci_location_t location; srslte_dci_location_t location;
uint32_t rv_idx; 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_prach_cfg_t* prach_cfg,
srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg, srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg,
srslte_pusch_hopping_cfg_t *hopping_cfg, srslte_pusch_hopping_cfg_t *hopping_cfg,
srslte_pucch_cfg_t *pucch_cfg, srslte_pucch_cfg_t *pucch_cfg);
uint32_t nof_rntis);
SRSLTE_API void srslte_enb_ul_free(srslte_enb_ul_t *q); 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, SRSLTE_API int srslte_enb_ul_add_rnti(srslte_enb_ul_t *q,
uint32_t idx,
uint16_t rnti); 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_uci_cfg_t *uci_cfg,
srslte_pucch_sched_t *pucch_sched, srslte_pucch_sched_t *pucch_sched,
srslte_refsignal_srs_cfg_t *srs_cfg); 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, SRSLTE_API void srslte_enb_ul_fft(srslte_enb_ul_t *q,
cf_t *signal_buffer); cf_t *signal_buffer);
SRSLTE_API int srslte_enb_ul_get_pucch(srslte_enb_ul_t *q, 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 pdcch_n_cce,
uint32_t sf_rx, uint32_t sf_rx,
srslte_uci_data_t *uci_data); 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_API int srslte_enb_ul_get_pusch(srslte_enb_ul_t *q,
srslte_ra_ul_grant_t *grant, srslte_ra_ul_grant_t *grant,
srslte_softbuffer_rx_t *softbuffer, srslte_softbuffer_rx_t *softbuffer,
uint32_t rnti_idx, uint16_t rnti,
uint32_t rv_idx, uint32_t rv_idx,
uint32_t current_tx_nb, uint32_t current_tx_nb,
uint8_t *data, uint8_t *data,

@ -47,13 +47,15 @@
#include "srslte/phch/sch.h" #include "srslte/phch/sch.h"
#include "srslte/phch/pdsch_cfg.h" #include "srslte/phch/pdsch_cfg.h"
typedef struct {
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
} srslte_pdsch_user_t;
/* PDSCH object */ /* PDSCH object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
uint32_t max_re; uint32_t max_re;
bool rnti_is_set;
uint16_t rnti;
/* buffers */ /* buffers */
// void buffers are shared for tx and rx // void buffers are shared for tx and rx
@ -66,12 +68,8 @@ typedef struct SRSLTE_API {
/* tx & rx objects */ /* tx & rx objects */
srslte_modem_table_t mod[4]; srslte_modem_table_t mod[4];
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
// This is to generate the scrambling seq for multiple CRNTIs // This is to generate the scrambling seq for multiple CRNTIs
uint32_t nof_crnti; srslte_pdsch_user_t **users;
srslte_sequence_t *seq_multi[SRSLTE_NSUBFRAMES_X_FRAME];
uint16_t *rnti_multi;
srslte_sch_t dl_sch; 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, SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t *q,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int srslte_pdsch_init_rnti_multi(srslte_pdsch_t *q, SRSLTE_API void srslte_pdsch_free_rnti(srslte_pdsch_t *q,
uint32_t nof_rntis); uint16_t rnti);
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 float srslte_pdsch_coderate(uint32_t tbs, SRSLTE_API float srslte_pdsch_coderate(uint32_t tbs,
uint32_t nof_re); uint32_t nof_re);
SRSLTE_API void print_pdsch_coderate();
SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg,
srslte_cell_t cell, srslte_cell_t cell,
srslte_ra_dl_grant_t *grant, 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_pdsch_cfg_t *cfg,
srslte_softbuffer_tx_t *softbuffer, srslte_softbuffer_tx_t *softbuffer,
uint8_t *data, uint8_t *data,
uint16_t rnti,
cf_t *sf_symbols[SRSLTE_MAX_PORTS]); 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_API int srslte_pdsch_decode(srslte_pdsch_t *q,
srslte_pdsch_cfg_t *cfg, srslte_pdsch_cfg_t *cfg,
srslte_softbuffer_rx_t *softbuffer, srslte_softbuffer_rx_t *softbuffer,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
uint16_t rnti,
uint8_t *data); 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 float srslte_pdsch_average_noi(srslte_pdsch_t *q);
SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q); SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q);

@ -51,9 +51,6 @@
#define SRSLTE_PUSCH_MAX_TDEC_ITERS 5 #define SRSLTE_PUSCH_MAX_TDEC_ITERS 5
typedef struct { typedef struct {
enum { enum {
SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1, SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1,
@ -63,13 +60,15 @@ typedef struct {
uint32_t n_sb; uint32_t n_sb;
} srslte_pusch_hopping_cfg_t; } srslte_pusch_hopping_cfg_t;
typedef struct {
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
} srslte_pusch_user_t;
/* PUSCH object */ /* PUSCH object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
uint32_t max_re; uint32_t max_re;
bool rnti_is_set;
uint16_t rnti;
srslte_dft_precoding_t dft_precoding; srslte_dft_precoding_t dft_precoding;
@ -84,13 +83,10 @@ typedef struct SRSLTE_API {
/* tx & rx objects */ /* tx & rx objects */
srslte_modem_table_t mod[4]; srslte_modem_table_t mod[4];
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_sequence_t seq_type2_fo; srslte_sequence_t seq_type2_fo;
// This is to generate the scrambling seq for multiple CRNTIs // This is to generate the scrambling seq for multiple CRNTIs
uint32_t nof_crnti; srslte_pusch_user_t **users;
srslte_sequence_t *seq_multi[SRSLTE_NSUBFRAMES_X_FRAME];
uint16_t *rnti_multi;
srslte_sch_t ul_sch; srslte_sch_t ul_sch;
bool shortened; 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, SRSLTE_API int srslte_pusch_set_rnti(srslte_pusch_t *q,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int srslte_pusch_init_rnti_multi(srslte_pusch_t *q, SRSLTE_API void srslte_pusch_clear_rnti(srslte_pusch_t *q,
uint32_t nof_rntis); uint16_t rnti);
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 int srslte_pusch_encode(srslte_pusch_t *q, SRSLTE_API int srslte_pusch_encode(srslte_pusch_t *q,
srslte_pusch_cfg_t *cfg, srslte_pusch_cfg_t *cfg,
srslte_softbuffer_tx_t *softbuffer, srslte_softbuffer_tx_t *softbuffer,
uint8_t *data, 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, srslte_uci_data_t uci_data,
cf_t *sf_symbols); uint16_t rnti,
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);
SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q, SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q,
srslte_pusch_cfg_t *cfg, 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 *sf_symbols,
cf_t *ce, cf_t *ce,
float noise_estimate, float noise_estimate,
uint8_t *data); uint16_t rnti,
uint8_t *data,
SRSLTE_API int srslte_pusch_uci_decode(srslte_pusch_t *q, srslte_uci_data_t *uci_data);
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);
SRSLTE_API float srslte_pusch_average_noi(srslte_pusch_t *q); SRSLTE_API float srslte_pusch_average_noi(srslte_pusch_t *q);

@ -39,7 +39,7 @@
#define SRSLTE_ENB_RF_AMP 0.1 #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; 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->cell = cell;
q->cfi = 3; q->cfi = 3;
q->nof_rnti = nof_rnti;
q->tx_amp = SRSLTE_ENB_RF_AMP; q->tx_amp = SRSLTE_ENB_RF_AMP;
if (srslte_ofdm_tx_init(&q->ifft, q->cell.cp, q->cell.nof_prb)) { 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; 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)) { if (srslte_refsignal_cs_init(&q->csr_signal, q->cell)) {
fprintf(stderr, "Error initializing CSR signal (%d)\n",ret); fprintf(stderr, "Error initializing CSR signal (%d)\n",ret);
goto clean_exit; 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)); 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, 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, 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; srslte_dci_msg_t dci_msg;
uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, rnti_idx);
bool rnti_is_user = true; bool rnti_is_user = true;
if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || (rnti >= SRSLTE_RARNTI_START && rnti <= SRSLTE_RARNTI_END)) { 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"); fprintf(stderr, "Error encoding DCI message\n");
return SRSLTE_ERROR; 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; return SRSLTE_SUCCESS;
} }
int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant, int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant,
srslte_dci_location_t location, 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; 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); 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)) { if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) {
fprintf(stderr, "Error encoding DCI message\n"); 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, 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) uint8_t *data)
{ {
//srslte_ra_dl_grant_fprint(stdout, grant);
/* Configure pdsch_cfg parameters */ /* Configure pdsch_cfg parameters */
if (srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, q->cfi, sf_idx, rv_idx)) { if (srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, q->cfi, sf_idx, rv_idx)) {
fprintf(stderr, "Error configuring PDSCH\n"); 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 */ /* 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"); fprintf(stderr, "Error encoding PDSCH\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -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_prach_cfg_t *prach_cfg,
srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg, srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg,
srslte_pusch_hopping_cfg_t *hopping_cfg, srslte_pusch_hopping_cfg_t *hopping_cfg,
srslte_pucch_cfg_t *pucch_cfg, srslte_pucch_cfg_t *pucch_cfg)
uint32_t nof_rnti)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; 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)); bzero(q, sizeof(srslte_enb_ul_t));
q->cell = cell; q->cell = cell;
q->nof_rnti = nof_rnti;
if (hopping_cfg) { if (hopping_cfg) {
memcpy(&q->hopping_cfg, hopping_cfg, sizeof(srslte_pusch_hopping_cfg_t)); memcpy(&q->hopping_cfg, hopping_cfg, sizeof(srslte_pusch_hopping_cfg_t));
} }
q->uci_cfg_en = calloc(sizeof(bool), nof_rnti); q->users = calloc(sizeof(srslte_enb_ul_user_t*), SRSLTE_SIRNTI);
q->srs_cfg_en = calloc(sizeof(bool), nof_rnti); if (!q->users) {
perror("malloc");
q->uci_cfg = calloc(sizeof(srslte_uci_cfg_t), nof_rnti); goto clean_exit;
q->srs_cfg = calloc(sizeof(srslte_refsignal_srs_cfg_t), nof_rnti); }
q->pucch_sched = calloc(sizeof(srslte_pucch_sched_t), nof_rnti);
if (srslte_ofdm_rx_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { if (srslte_ofdm_rx_init(&q->fft, q->cell.cp, q->cell.nof_prb)) {
fprintf(stderr, "Error initiating FFT\n"); 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; goto clean_exit;
} }
if (srslte_pusch_init_rnti_multi(&q->pusch, nof_rnti)) { if (prach_cfg) {
fprintf(stderr, "Error initiating multiple RNTIs in PUSCH\n"); if (srslte_prach_init_cfg(&q->prach, prach_cfg, q->cell.nof_prb)) {
goto clean_exit; fprintf(stderr, "Error initiating PRACH\n");
} goto clean_exit;
}
if (srslte_prach_init_cfg(&q->prach, prach_cfg, q->cell.nof_prb)) { srslte_prach_set_detect_factor(&q->prach, 60);
fprintf(stderr, "Error initiating PRACH\n");
goto clean_exit;
} }
srslte_prach_set_detect_factor(&q->prach, 60);
srslte_pucch_set_threshold(&q->pucch, 0.5, 0.5); srslte_pucch_set_threshold(&q->pucch, 0.5, 0.5);
if (srslte_chest_ul_init(&q->chest, cell)) { 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) {
if (q->uci_cfg) { if (q->users) {
free(q->uci_cfg); for (int i=0;i<SRSLTE_SIRNTI;i++) {
} if (q->users[i]) {
if (q->uci_cfg_en) { free(q->users[i]);
free(q->uci_cfg_en); }
} }
if (q->srs_cfg) { free(q->users);
free(q->srs_cfg);
}
if (q->srs_cfg_en) {
free(q->srs_cfg_en);
}
if (q->pucch_sched) {
free(q->pucch_sched);
} }
srslte_prach_free(&q->prach); 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_uci_cfg_t *uci_cfg,
srslte_pucch_sched_t *pucch_sched, srslte_pucch_sched_t *pucch_sched,
srslte_refsignal_srs_cfg_t *srs_cfg) srslte_refsignal_srs_cfg_t *srs_cfg)
{ {
if (idx < q->nof_rnti) { if (q->users[rnti]) {
if (uci_cfg) { if (uci_cfg) {
memcpy(&q->uci_cfg[idx], uci_cfg, sizeof(srslte_uci_cfg_t)); memcpy(&q->users[rnti]->uci_cfg, uci_cfg, sizeof(srslte_uci_cfg_t));
q->uci_cfg_en[idx] = true; q->users[rnti]->uci_cfg_en = true;
} else { } else {
q->uci_cfg_en[idx] = false; q->users[rnti]->uci_cfg_en = false;
} }
if (pucch_sched) { 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) { if (srs_cfg) {
memcpy(&q->srs_cfg[idx], srs_cfg, sizeof(srslte_refsignal_srs_cfg_t)); memcpy(&q->users[rnti]->srs_cfg, srs_cfg, sizeof(srslte_refsignal_srs_cfg_t));
q->srs_cfg_en[idx] = true; q->users[rnti]->srs_cfg_en = true;
} else { } else {
q->srs_cfg_en[idx] = false; q->users[rnti]->srs_cfg_en = false;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } 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; 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) 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); 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, uint32_t pdcch_n_cce, uint32_t sf_rx,
srslte_uci_data_t *uci_data, uint8_t bits[SRSLTE_PUCCH_MAX_BITS]) 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); 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)) { 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"); 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; 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, uint32_t pdcch_n_cce, uint32_t sf_rx,
srslte_uci_data_t *uci_data) srslte_uci_data_t *uci_data)
{ {
uint8_t bits[SRSLTE_PUCCH_MAX_BITS]; 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. // 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 // try again to decode ACK only
if (uci_data->scheduling_request && uci_data->uci_ack_len && ret_val != 1) { if (uci_data->scheduling_request && uci_data->uci_ack_len && ret_val != 1) {
uci_data->scheduling_request = false; 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 // 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; return SRSLTE_SUCCESS;
} else { } 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; 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, 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) uint8_t *data, srslte_uci_data_t *uci_data, uint32_t tti)
{ {
if (q->users[rnti]) {
if (srslte_pusch_cfg(&q->pusch, if (srslte_pusch_cfg(&q->pusch,
&q->pusch_cfg, &q->pusch_cfg,
grant, grant,
q->uci_cfg_en[rnti_idx]?&q->uci_cfg[rnti_idx]:NULL, q->users[rnti]->uci_cfg_en?&q->users[rnti]->uci_cfg:NULL,
&q->hopping_cfg, &q->hopping_cfg,
q->srs_cfg_en[rnti_idx]?&q->srs_cfg[rnti_idx]:NULL, q->users[rnti]->srs_cfg_en?&q->users[rnti]->srs_cfg:NULL,
tti, rv_idx, current_tx_nb)) { tti, rv_idx, current_tx_nb)) {
fprintf(stderr, "Error configuring PDSCH\n"); fprintf(stderr, "Error configuring PDSCH\n");
return SRSLTE_ERROR; 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; 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); 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); float noise_power = srslte_chest_ul_get_noise_estimate(&q->chest);
return srslte_pusch_uci_decode_rnti_idx(&q->pusch, &q->pusch_cfg, return srslte_pusch_decode(&q->pusch, &q->pusch_cfg,
softbuffer, q->sf_symbols, softbuffer, q->sf_symbols,
q->ce, noise_power, q->ce, noise_power,
rnti_idx, data, rnti, data,
uci_data); uci_data);
} }

@ -216,7 +216,6 @@ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) {
q->cell = cell; q->cell = cell;
q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp); 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, INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports,
q->cell.nof_prb, q->max_re); 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); srslte_sch_init(&q->dl_sch);
q->rnti_is_set = false;
// Allocate int16_t for reception (LLRs) // 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)); q->e = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->e) { if (!q->e) {
@ -257,7 +254,13 @@ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) {
goto clean; goto clean;
} }
} }
q->users = calloc(sizeof(srslte_pdsch_user_t*), 1+SRSLTE_SIRNTI);
if (!q->users) {
perror("malloc");
goto clean;
}
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
clean: clean:
@ -288,23 +291,14 @@ void srslte_pdsch_free(srslte_pdsch_t *q) {
} }
} }
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (q->users) {
srslte_sequence_free(&q->seq[i]); for (uint16_t u=0;u<SRSLTE_SIRNTI;u++) {
} if (q->users[u]) {
srslte_pdsch_free_rnti(q, u);
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { }
for (int n=0;n<q->nof_crnti;n++) { }
srslte_sequence_free(&q->seq_multi[i][n]); free(q->users);
}
if (q->seq_multi[i]) {
free(q->seq_multi[i]);
}
}
if (q->rnti_multi) {
free(q->rnti_multi);
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
srslte_modem_table_free(&q->mod[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. * 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) { int srslte_pdsch_set_rnti(srslte_pdsch_t *q, uint16_t rnti) {
uint32_t i; uint32_t i;
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (!q->users[rnti]) {
if (srslte_sequence_pdsch(&q->seq[i], rnti, 0, 2 * i, q->cell.id, q->users[rnti] = calloc(1, sizeof(srslte_pdsch_user_t));
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { if (q->users[rnti]) {
return SRSLTE_ERROR; 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->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,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
return SRSLTE_ERROR; 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, void srslte_pdsch_free_rnti(srslte_pdsch_t* q, uint16_t rnti)
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)
{ {
if (q != NULL && if (q->users[rnti]) {
sf_symbols != NULL && for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
data != NULL && srslte_sequence_free(&q->users[rnti]->seq[i]);
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;
} }
} else { free(q->users[rnti]);
return SRSLTE_ERROR_INVALID_INPUTS; q->users[rnti] = NULL;
} }
} }
/** Decodes the PDSCH from the received symbols /** Decodes the PDSCH from the received symbols
*/ */
int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, int srslte_pdsch_decode(srslte_pdsch_t *q,
srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer,
cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate,
uint16_t rnti, uint8_t *data) uint16_t rnti, uint8_t *data)
{ {
/* Set pointers for layermapping & precoding */ /* 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); 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;i<cfg->nbits.nof_bits;i++) {
e[i] = e[i]>0?10:-10;
}
*/
/* descramble */ /* descramble */
if (rnti != q->rnti) { if (!q->users[rnti]) {
srslte_sequence_t seq; srslte_sequence_t seq;
if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) {
return SRSLTE_ERROR; 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_scrambling_s_offset(&seq, q->e, 0, cfg->nbits.nof_bits);
srslte_sequence_free(&seq); srslte_sequence_free(&seq);
} else { } 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()) { 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, int srslte_pdsch_encode(srslte_pdsch_t *q,
srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, srslte_pdsch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer,
uint8_t *data, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) uint8_t *data, uint16_t rnti, 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])
{ {
int i; int i;
@ -603,8 +506,18 @@ int srslte_pdsch_encode_seq(srslte_pdsch_t *q,
return SRSLTE_ERROR; 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); srslte_mod_modulate_bytes(&q->mod[cfg->grant.mcs.mod], (uint8_t*) q->e, q->d, cfg->nbits.nof_bits);
/* TODO: only diversity supported */ /* TODO: only diversity supported */
@ -626,42 +539,6 @@ int srslte_pdsch_encode_seq(srslte_pdsch_t *q,
return ret; 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) float srslte_pdsch_average_noi(srslte_pdsch_t *q)
{ {
return q->dl_sch.average_nof_iterations; return q->dl_sch.average_nof_iterations;

@ -209,6 +209,12 @@ int srslte_pusch_init(srslte_pusch_t *q, srslte_cell_t cell) {
srslte_modem_table_bytes(&q->mod[i]); 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 */ /* Precompute sequence for type2 frequency hopping */
if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) { if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) {
fprintf(stderr, "Error initiating type2 frequency hopping sequence\n"); 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; goto clean;
} }
q->rnti_is_set = false;
// Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission // 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)); q->q = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->q) { if (!q->q) {
@ -279,10 +283,12 @@ void srslte_pusch_free(srslte_pusch_t *q) {
srslte_dft_precoding_free(&q->dft_precoding); srslte_dft_precoding_free(&q->dft_precoding);
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (q->users) {
srslte_sequence_free(&q->seq[i]); for (int rnti=0;rnti<SRSLTE_SIRNTI;rnti++) {
srslte_pusch_clear_rnti(q, rnti);
}
free(q->users);
} }
srslte_sequence_free(&q->seq_type2_fo); srslte_sequence_free(&q->seq_type2_fo);
for (i = 0; i < 4; i++) { 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 /* 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. * 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) { int srslte_pusch_set_rnti(srslte_pusch_t *q, uint16_t rnti) {
uint32_t i; 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->users[rnti]) {
if (!q->rnti_multi) { q->users[rnti] = malloc(sizeof(srslte_pusch_user_t));
perror("malloc"); if (q->users[rnti]) {
return SRSLTE_ERROR; for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
} if (srslte_sequence_pusch(&q->users[rnti]->seq[i], rnti, 2 * i, q->cell.id,
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,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
return SRSLTE_ERROR; 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, void srslte_pusch_clear_rnti(srslte_pusch_t *q, uint16_t rnti) {
uint8_t *data, srslte_uci_data_t uci_data, if (q->users[rnti]) {
cf_t *sf_symbols) for (int i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
{ srslte_sequence_free(&q->users[rnti]->seq[i]);
if (q->rnti_is_set) { }
return srslte_pusch_uci_encode_rnti(q, cfg, softbuffer, data, uci_data, q->rnti, sf_symbols); free(q->users[rnti]);
} else { q->users[rnti] = NULL;
fprintf(stderr, "Must call srslte_pusch_set_rnti() to set the encoder/decoder RNTI\n");
return SRSLTE_ERROR;
} }
} }
/** Converts the PUSCH data bits to symbols mapped to the slot ready for transmission /** 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, 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, uint8_t *data, srslte_uci_data_t uci_data, uint16_t rnti,
cf_t *sf_symbols) cf_t *sf_symbols)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; 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; return SRSLTE_ERROR;
} }
if (rnti != q->rnti || !q->rnti_is_set) { if (!q->users[rnti]) {
srslte_sequence_t seq; srslte_sequence_t seq;
if (srslte_sequence_pusch(&seq, rnti, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { if (srslte_sequence_pusch(&seq, rnti, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) {
return SRSLTE_ERROR; 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_scrambling_bytes(&seq, (uint8_t*) q->q, cfg->nbits.nof_bits);
srslte_sequence_free(&seq); srslte_sequence_free(&seq);
} else { } 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 // 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; return ret;
} }
/** Decodes the PUSCH from the received symbols
*/
int srslte_pusch_decode(srslte_pusch_t *q, int srslte_pusch_decode(srslte_pusch_t *q,
srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce, float noise_estimate, cf_t *ce, float noise_estimate, uint16_t rnti,
uint8_t *data) uint8_t *data, srslte_uci_data_t *uci_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)
{ {
uint32_t n; uint32_t n;
@ -587,82 +505,63 @@ int srslte_pusch_uci_decode_seq(srslte_pusch_t *q,
cfg != NULL) 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",
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->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);
cfg->nbits.nof_re, cfg->nbits.nof_symb, cfg->nbits.nof_bits, cfg->rv);
/* extract symbols */
/* extract symbols */ n = pusch_get(q, &cfg->grant, sf_symbols, q->d);
n = pusch_get(q, &cfg->grant, sf_symbols, q->d); if (n != cfg->nbits.nof_re) {
if (n != cfg->nbits.nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n);
fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); return SRSLTE_ERROR;
return SRSLTE_ERROR; }
}
/* extract channel estimates */
/* extract channel estimates */ n = pusch_get(q, &cfg->grant, ce, q->ce);
n = pusch_get(q, &cfg->grant, ce, q->ce); if (n != cfg->nbits.nof_re) {
if (n != cfg->nbits.nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n);
fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); return SRSLTE_ERROR;
return SRSLTE_ERROR; }
}
// Equalization // Equalization
srslte_predecoding_single(q->d, q->ce, q->z, cfg->nbits.nof_re, noise_estimate); srslte_predecoding_single(q->d, q->ce, q->z, cfg->nbits.nof_re, noise_estimate);
// DFT predecoding // DFT predecoding
srslte_dft_predecoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->nbits.nof_symb); srslte_dft_predecoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->nbits.nof_symb);
// Soft demodulation // Soft demodulation
srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re); srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re);
// Decode RI/HARQ bits before descrambling srslte_sequence_t *seq = NULL;
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"); // 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; 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 { } else {
fprintf(stderr, "Must call srslte_pusch_set_rnti() before calling srslte_pusch_decode()\n"); seq = &q->users[rnti]->seq[cfg->sf_idx];
return SRSLTE_ERROR; }
}
} else { // Decode RI/HARQ bits before descrambling
return SRSLTE_ERROR_INVALID_INPUTS; 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");
}
/** 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);
return SRSLTE_ERROR; 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 { } else {
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} }

@ -229,14 +229,14 @@ int main(int argc, char **argv) {
if (rv_idx) { if (rv_idx) {
/* Do 1st transmission for rv_idx!=0 */ /* Do 1st transmission for rv_idx!=0 */
pdsch_cfg.rv = 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"); fprintf(stderr, "Error encoding PDSCH\n");
goto quit; goto quit;
} }
} }
pdsch_cfg.rv = rv_idx; 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"); fprintf(stderr, "Error encoding PDSCH\n");
goto quit; goto quit;
} }
@ -265,7 +265,7 @@ int main(int argc, char **argv) {
srslte_ofdm_rx_sf(&ofdm_rx, sf_symbols, slot_symbols[1]); srslte_ofdm_rx_sf(&ofdm_rx, sf_symbols, slot_symbols[1]);
#endif #endif
srslte_softbuffer_rx_reset_tbs(&softbuffer_rx, grant.mcs.tbs); 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); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);

@ -97,7 +97,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Error initiating PDSCH\n"); mexErrMsgTxt("Error initiating PDSCH\n");
return; 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)) { if (srslte_softbuffer_rx_init(&softbuffer, cell.nof_prb)) {
mexErrMsgTxt("Error initiating soft buffer\n"); 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); 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); uint8_t *data = malloc(grant.mcs.tbs);

@ -76,8 +76,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Field RNTI not found in pusch config\n"); mexErrMsgTxt("Field RNTI not found in pusch config\n");
return; 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; 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("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); 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) { if (r < 0) {
mexErrMsgTxt("Error encoding PUSCH\n"); mexErrMsgTxt("Error encoding PUSCH\n");
return; return;
@ -205,7 +206,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
if (cfg.rv > 0) { 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) { if (r < 0) {
mexErrMsgTxt("Error encoding PUSCH\n"); mexErrMsgTxt("Error encoding PUSCH\n");
return; return;

@ -164,7 +164,8 @@ int main(int argc, char **argv) {
exit(-1); 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_tx;
srslte_uci_data_t uci_data_rx; srslte_uci_data_t uci_data_rx;
@ -208,13 +209,13 @@ int main(int argc, char **argv) {
uint32_t ntrials = 100; 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"); fprintf(stderr, "Error encoding TB\n");
exit(-1); exit(-1);
} }
if (rv_idx > 0) { if (rv_idx > 0) {
cfg.rv = rv_idx; 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"); fprintf(stderr, "Error encoding TB\n");
exit(-1); exit(-1);
} }
@ -230,7 +231,7 @@ int main(int argc, char **argv) {
} }
gettimeofday(&t[1], NULL); 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); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);
if (r) { if (r) {

@ -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 // Set viterbi normalization based on amplitude
int16_t max = srslte_vec_max_abs_star_si(q->encoded_cqi_s, 3 * (nof_bits + 8)); 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); DEBUG("cconv_rx=", 0);
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
srslte_vec_fprint_s(stdout, q->encoded_cqi_s, 3 * (nof_bits + 8)); srslte_vec_fprint_s(stdout, q->encoded_cqi_s, 3 * (nof_bits + 8));

@ -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); 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) { 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, q->sf_symbols, q->ce,
noise_estimate, noise_estimate,
rnti, data); 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); snprintf(tmpstr,64,"rmout_%d.dat",i);
srslte_vec_save_file(tmpstr, softbuffer->buffer_f[i], (3*cb_len+12)*sizeof(int16_t)); 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); q->pdsch_cfg.grant.mcs.idx, rv_idx, rnti);
} }

@ -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)); 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"); fprintf(stderr, "Error encoding TB\n");
return ret; return ret;
} }

Loading…
Cancel
Save