diff --git a/lib/include/srsran/phy/enb/enb_dl_nr.h b/lib/include/srsran/phy/enb/enb_dl_nr.h deleted file mode 100644 index edc7c8ac5..000000000 --- a/lib/include/srsran/phy/enb/enb_dl_nr.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2021 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSRAN_ENB_DL_NR_H -#define SRSRAN_ENB_DL_NR_H - -#include "srsran/phy/common/phy_common_nr.h" -#include "srsran/phy/dft/ofdm.h" -#include "srsran/phy/phch/pdcch_cfg_nr.h" -#include "srsran/phy/phch/pdcch_nr.h" -#include "srsran/phy/phch/pdsch_nr.h" - -typedef struct SRSRAN_API { - srsran_pdsch_nr_args_t pdsch; - srsran_pdcch_nr_args_t pdcch; - uint32_t nof_tx_antennas; - uint32_t nof_max_prb; -} srsran_enb_dl_nr_args_t; - -typedef struct SRSRAN_API { - uint32_t max_prb; - uint32_t nof_tx_antennas; - srsran_carrier_nr_t carrier; - srsran_pdcch_cfg_nr_t pdcch_cfg; - - srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; - - cf_t* sf_symbols[SRSRAN_MAX_PORTS]; - srsran_pdsch_nr_t pdsch; - srsran_dmrs_sch_t dmrs; - - srsran_dci_nr_t dci; ///< Stores DCI configuration - srsran_pdcch_nr_t pdcch; -} srsran_enb_dl_nr_t; - -SRSRAN_API int -srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_enb_dl_nr_args_t* args); - -SRSRAN_API int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_t* carrier); - -SRSRAN_API int srsran_enb_dl_nr_set_pdcch_config(srsran_enb_dl_nr_t* q, - const srsran_pdcch_cfg_nr_t* cfg, - const srsran_dci_cfg_nr_t* dci_cfg); - -SRSRAN_API void srsran_enb_dl_nr_free(srsran_enb_dl_nr_t* q); - -SRSRAN_API int srsran_enb_dl_nr_base_zero(srsran_enb_dl_nr_t* q); - -SRSRAN_API void srsran_enb_dl_nr_gen_signal(srsran_enb_dl_nr_t* q); - -SRSRAN_API int srsran_enb_dl_nr_pdcch_put_dl(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_dci_dl_nr_t* dci_dl); - -SRSRAN_API int srsran_enb_dl_nr_pdcch_put_ul(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_dci_ul_nr_t* dci_ul); - -SRSRAN_API int srsran_enb_dl_nr_pdsch_put(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot, - const srsran_sch_cfg_nr_t* cfg, - uint8_t* data[SRSRAN_MAX_TB]); - -SRSRAN_API int -srsran_enb_dl_nr_pdsch_info(const srsran_enb_dl_nr_t* q, const srsran_sch_cfg_nr_t* cfg, char* str, uint32_t str_len); - -SRSRAN_API int -srsran_enb_dl_nr_pdcch_dl_info(const srsran_enb_dl_nr_t* q, const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len); - -SRSRAN_API int -srsran_enb_dl_nr_pdcch_ul_info(const srsran_enb_dl_nr_t* q, const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len); - -#endif // SRSRAN_ENB_DL_NR_H diff --git a/lib/include/srsran/phy/gnb/gnb_dl.h b/lib/include/srsran/phy/gnb/gnb_dl.h new file mode 100644 index 000000000..680fdacbe --- /dev/null +++ b/lib/include/srsran/phy/gnb/gnb_dl.h @@ -0,0 +1,79 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_GNB_DL_H +#define SRSRAN_GNB_DL_H + +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pdcch_cfg_nr.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/phch/pdsch_nr.h" + +typedef struct SRSRAN_API { + srsran_pdsch_nr_args_t pdsch; + srsran_pdcch_nr_args_t pdcch; + uint32_t nof_tx_antennas; + uint32_t nof_max_prb; +} srsran_gnb_dl_args_t; + +typedef struct SRSRAN_API { + uint32_t max_prb; + uint32_t nof_tx_antennas; + srsran_carrier_nr_t carrier; + srsran_pdcch_cfg_nr_t pdcch_cfg; + + srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_pdsch_nr_t pdsch; + srsran_dmrs_sch_t dmrs; + + srsran_dci_nr_t dci; ///< Stores DCI configuration + srsran_pdcch_nr_t pdcch; +} srsran_gnb_dl_t; + +SRSRAN_API int srsran_gnb_dl_init(srsran_gnb_dl_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_gnb_dl_args_t* args); + +SRSRAN_API int srsran_gnb_dl_set_carrier(srsran_gnb_dl_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_gnb_dl_set_pdcch_config(srsran_gnb_dl_t* q, + const srsran_pdcch_cfg_nr_t* cfg, + const srsran_dci_cfg_nr_t* dci_cfg); + +SRSRAN_API void srsran_gnb_dl_free(srsran_gnb_dl_t* q); + +SRSRAN_API int srsran_gnb_dl_base_zero(srsran_gnb_dl_t* q); + +SRSRAN_API void srsran_gnb_dl_gen_signal(srsran_gnb_dl_t* q); + +SRSRAN_API int +srsran_gnb_dl_pdcch_put_dl(srsran_gnb_dl_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_dl_nr_t* dci_dl); + +SRSRAN_API int +srsran_gnb_dl_pdcch_put_ul(srsran_gnb_dl_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_ul_nr_t* dci_ul); + +SRSRAN_API int srsran_gnb_dl_pdsch_put(srsran_gnb_dl_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + uint8_t* data[SRSRAN_MAX_TB]); + +SRSRAN_API int +srsran_gnb_dl_pdsch_info(const srsran_gnb_dl_t* q, const srsran_sch_cfg_nr_t* cfg, char* str, uint32_t str_len); + +SRSRAN_API int +srsran_gnb_dl_pdcch_dl_info(const srsran_gnb_dl_t* q, const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len); + +SRSRAN_API int +srsran_gnb_dl_pdcch_ul_info(const srsran_gnb_dl_t* q, const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len); + +#endif // SRSRAN_GNB_DL_H diff --git a/lib/include/srsran/phy/gnb/gnb_ul.h b/lib/include/srsran/phy/gnb/gnb_ul.h new file mode 100644 index 000000000..7fa392c17 --- /dev/null +++ b/lib/include/srsran/phy/gnb/gnb_ul.h @@ -0,0 +1,61 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_GNB_UL_H +#define SRSRAN_GNB_UL_H + +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pucch_nr.h" +#include "srsran/phy/phch/pusch_nr.h" + +typedef struct SRSRAN_API { + srsran_pusch_nr_args_t pusch; + srsran_pucch_nr_args_t pucch; + uint32_t nof_max_prb; +} srsran_gnb_ul_args_t; + +typedef struct SRSRAN_API { + uint32_t max_prb; + srsran_carrier_nr_t carrier; + + srsran_ofdm_t fft; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_pusch_nr_t pusch; + srsran_pucch_nr_t pucch; + srsran_dmrs_sch_t dmrs; + srsran_chest_dl_res_t chest; +} srsran_gnb_ul_t; + +SRSRAN_API int srsran_gnb_ul_init(srsran_gnb_ul_t* q, cf_t* input, const srsran_gnb_ul_args_t* args); + +SRSRAN_API void srsran_gnb_ul_free(srsran_gnb_ul_t* q); + +SRSRAN_API int srsran_gnb_ul_set_carrier(srsran_gnb_ul_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_gnb_ul_fft(srsran_gnb_ul_t* q); + +SRSRAN_API int srsran_gnb_ul_get_pusch(srsran_gnb_ul_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_pusch_res_nr_t* data); + +SRSRAN_API int srsran_gnb_ul_get_pucch(srsran_gnb_ul_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_uci_value_nr_t* uci_value); + +#endif // SRSRAN_GNB_UL_H diff --git a/lib/include/srsran/phy/phch/pusch_nr.h b/lib/include/srsran/phy/phch/pusch_nr.h index f917dd195..146831a12 100644 --- a/lib/include/srsran/phy/phch/pusch_nr.h +++ b/lib/include/srsran/phy/phch/pusch_nr.h @@ -104,7 +104,7 @@ SRSRAN_API int srsran_pusch_nr_decode(srsran_pusch_nr_t* q, const srsran_sch_grant_nr_t* grant, srsran_chest_dl_res_t* channel, cf_t* sf_symbols[SRSRAN_MAX_PORTS], - srsran_pusch_res_nr_t* data[SRSRAN_MAX_TB]); + srsran_pusch_res_nr_t* data); SRSRAN_API uint32_t srsran_pusch_nr_rx_info(const srsran_pusch_nr_t* q, const srsran_sch_cfg_nr_t* cfg, diff --git a/lib/include/srsran/srsran.h b/lib/include/srsran/srsran.h index b3bfd641f..0e379a2dc 100644 --- a/lib/include/srsran/srsran.h +++ b/lib/include/srsran/srsran.h @@ -116,8 +116,8 @@ extern "C" { #include "srsran/phy/ue/ue_ul_nr.h" #include "srsran/phy/enb/enb_dl.h" -#include "srsran/phy/enb/enb_dl_nr.h" #include "srsran/phy/enb/enb_ul.h" +#include "srsran/phy/gnb/gnb_dl.h" #include "srsran/phy/scrambling/scrambling.h" diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index 8c166ba89..66018f1dc 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -23,6 +23,7 @@ add_subdirectory(resampling) add_subdirectory(scrambling) add_subdirectory(ue) add_subdirectory(enb) +add_subdirectory(gnb) set(srsran_srcs $ $ $ @@ -39,6 +40,7 @@ set(srsran_srcs $ $ $ $ + $ ) add_library(srsran_phy STATIC ${srsran_srcs} ) diff --git a/lib/src/phy/gnb/CMakeLists.txt b/lib/src/phy/gnb/CMakeLists.txt new file mode 100644 index 000000000..a4950c24b --- /dev/null +++ b/lib/src/phy/gnb/CMakeLists.txt @@ -0,0 +1,10 @@ +# +# Copyright 2013-2021 Software Radio Systems Limited +# +# By using this file, you agree to the terms and conditions set +# forth in the LICENSE file which can be found at the top level of +# the distribution. +# + +file(GLOB SOURCES "*.c") +add_library(srsran_gnb OBJECT ${SOURCES}) diff --git a/lib/src/phy/enb/enb_dl_nr.c b/lib/src/phy/gnb/gnb_dl.c similarity index 70% rename from lib/src/phy/enb/enb_dl_nr.c rename to lib/src/phy/gnb/gnb_dl.c index f98cc411c..0f83f0233 100644 --- a/lib/src/phy/enb/enb_dl_nr.c +++ b/lib/src/phy/gnb/gnb_dl.c @@ -10,10 +10,10 @@ * */ -#include "srsran/phy/enb/enb_dl_nr.h" +#include "srsran/phy/gnb/gnb_dl.h" #include -static int enb_dl_alloc_prb(srsran_enb_dl_nr_t* q, uint32_t new_nof_prb) +static int gnb_dl_alloc_prb(srsran_gnb_dl_t* q, uint32_t new_nof_prb) { if (q->max_prb < new_nof_prb) { q->max_prb = new_nof_prb; @@ -34,7 +34,7 @@ static int enb_dl_alloc_prb(srsran_enb_dl_nr_t* q, uint32_t new_nof_prb) return SRSRAN_SUCCESS; } -int srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_enb_dl_nr_args_t* args) +int srsran_gnb_dl_init(srsran_gnb_dl_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_gnb_dl_args_t* args) { if (!q || !output || !args) { return SRSRAN_ERROR_INVALID_INPUTS; @@ -51,7 +51,7 @@ int srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], return SRSRAN_ERROR; } - if (enb_dl_alloc_prb(q, args->nof_max_prb) < SRSRAN_SUCCESS) { + if (gnb_dl_alloc_prb(q, args->nof_max_prb) < SRSRAN_SUCCESS) { ERROR("Error allocating"); return SRSRAN_ERROR; } @@ -80,7 +80,7 @@ int srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], return SRSRAN_SUCCESS; } -void srsran_enb_dl_nr_free(srsran_enb_dl_nr_t* q) +void srsran_gnb_dl_free(srsran_gnb_dl_t* q) { if (q == NULL) { return; @@ -99,10 +99,10 @@ void srsran_enb_dl_nr_free(srsran_enb_dl_nr_t* q) srsran_pdcch_nr_free(&q->pdcch); - SRSRAN_MEM_ZERO(q, srsran_enb_dl_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_gnb_dl_t, 1); } -int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_t* carrier) +int srsran_gnb_dl_set_carrier(srsran_gnb_dl_t* q, const srsran_carrier_nr_t* carrier) { if (srsran_pdsch_nr_set_carrier(&q->pdsch, carrier) < SRSRAN_SUCCESS) { return SRSRAN_ERROR; @@ -113,7 +113,7 @@ int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_ return SRSRAN_ERROR; } - if (enb_dl_alloc_prb(q, carrier->nof_prb) < SRSRAN_SUCCESS) { + if (gnb_dl_alloc_prb(q, carrier->nof_prb) < SRSRAN_SUCCESS) { ERROR("Error allocating"); return SRSRAN_ERROR; } @@ -135,9 +135,9 @@ int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_ return SRSRAN_SUCCESS; } -int srsran_enb_dl_nr_set_pdcch_config(srsran_enb_dl_nr_t* q, - const srsran_pdcch_cfg_nr_t* cfg, - const srsran_dci_cfg_nr_t* dci_cfg) +int srsran_gnb_dl_set_pdcch_config(srsran_gnb_dl_t* q, + const srsran_pdcch_cfg_nr_t* cfg, + const srsran_dci_cfg_nr_t* dci_cfg) { if (q == NULL || cfg == NULL) { return SRSRAN_ERROR_INVALID_INPUTS; @@ -156,7 +156,7 @@ int srsran_enb_dl_nr_set_pdcch_config(srsran_enb_dl_nr_t* q, return SRSRAN_SUCCESS; } -void srsran_enb_dl_nr_gen_signal(srsran_enb_dl_nr_t* q) +void srsran_gnb_dl_gen_signal(srsran_gnb_dl_t* q) { if (q == NULL) { return; @@ -167,7 +167,7 @@ void srsran_enb_dl_nr_gen_signal(srsran_enb_dl_nr_t* q) } } -int srsran_enb_dl_nr_base_zero(srsran_enb_dl_nr_t* q) +int srsran_gnb_dl_base_zero(srsran_gnb_dl_t* q) { if (q == NULL) { return SRSRAN_ERROR_INVALID_INPUTS; @@ -181,7 +181,7 @@ int srsran_enb_dl_nr_base_zero(srsran_enb_dl_nr_t* q) } static int -enb_dl_nr_pdcch_put_msg(srsran_enb_dl_nr_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_msg_nr_t* dci_msg) +gnb_dl_pdcch_put_msg(srsran_gnb_dl_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_msg_nr_t* dci_msg) { if (dci_msg->ctx.coreset_id >= SRSRAN_UE_DL_NR_MAX_NOF_CORESET || !q->pdcch_cfg.coreset_present[dci_msg->ctx.coreset_id]) { @@ -213,9 +213,7 @@ enb_dl_nr_pdcch_put_msg(srsran_enb_dl_nr_t* q, const srsran_slot_cfg_t* slot_cfg return SRSRAN_SUCCESS; } -int srsran_enb_dl_nr_pdcch_put_dl(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_dci_dl_nr_t* dci_dl) +int srsran_gnb_dl_pdcch_put_dl(srsran_gnb_dl_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_dl_nr_t* dci_dl) { if (q == NULL || slot_cfg == NULL || dci_dl == NULL) { return SRSRAN_ERROR_INVALID_INPUTS; @@ -230,12 +228,10 @@ int srsran_enb_dl_nr_pdcch_put_dl(srsran_enb_dl_nr_t* q, INFO("DCI DL NR: L=%d; ncce=%d;", dci_dl->ctx.location.L, dci_dl->ctx.location.ncce); - return enb_dl_nr_pdcch_put_msg(q, slot_cfg, &dci_msg); + return gnb_dl_pdcch_put_msg(q, slot_cfg, &dci_msg); } -int srsran_enb_dl_nr_pdcch_put_ul(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_dci_ul_nr_t* dci_ul) +int srsran_gnb_dl_pdcch_put_ul(srsran_gnb_dl_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_ul_nr_t* dci_ul) { if (q == NULL || slot_cfg == NULL || dci_ul == NULL) { return SRSRAN_ERROR_INVALID_INPUTS; @@ -250,13 +246,13 @@ int srsran_enb_dl_nr_pdcch_put_ul(srsran_enb_dl_nr_t* q, INFO("DCI DL NR: L=%d; ncce=%d;", dci_ul->ctx.location.L, dci_ul->ctx.location.ncce); - return enb_dl_nr_pdcch_put_msg(q, slot_cfg, &dci_msg); + return gnb_dl_pdcch_put_msg(q, slot_cfg, &dci_msg); } -int srsran_enb_dl_nr_pdsch_put(srsran_enb_dl_nr_t* q, - const srsran_slot_cfg_t* slot, - const srsran_sch_cfg_nr_t* cfg, - uint8_t* data[SRSRAN_MAX_TB]) +int srsran_gnb_dl_pdsch_put(srsran_gnb_dl_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + uint8_t* data[SRSRAN_MAX_TB]) { if (srsran_dmrs_sch_put_sf(&q->dmrs, slot, cfg, &cfg->grant, q->sf_symbols[0]) < SRSRAN_SUCCESS) { return SRSRAN_ERROR; @@ -269,10 +265,7 @@ int srsran_enb_dl_nr_pdsch_put(srsran_enb_dl_nr_t* q, return SRSRAN_SUCCESS; } -int srsran_enb_dl_nr_pdsch_info(const srsran_enb_dl_nr_t* q, - const srsran_sch_cfg_nr_t* cfg, - char* str, - uint32_t str_len) +int srsran_gnb_dl_pdsch_info(const srsran_gnb_dl_t* q, const srsran_sch_cfg_nr_t* cfg, char* str, uint32_t str_len) { int len = 0; @@ -282,10 +275,7 @@ int srsran_enb_dl_nr_pdsch_info(const srsran_enb_dl_nr_t* q, return len; } -int srsran_enb_dl_nr_pdcch_dl_info(const srsran_enb_dl_nr_t* q, - const srsran_dci_dl_nr_t* dci, - char* str, - uint32_t str_len) +int srsran_gnb_dl_pdcch_dl_info(const srsran_gnb_dl_t* q, const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len) { int len = 0; @@ -295,10 +285,7 @@ int srsran_enb_dl_nr_pdcch_dl_info(const srsran_enb_dl_nr_t* q, return len; } -int srsran_enb_dl_nr_pdcch_ul_info(const srsran_enb_dl_nr_t* q, - const srsran_dci_ul_nr_t* dci, - char* str, - uint32_t str_len) +int srsran_gnb_dl_pdcch_ul_info(const srsran_gnb_dl_t* q, const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len) { int len = 0; diff --git a/lib/src/phy/gnb/gnb_ul.c b/lib/src/phy/gnb/gnb_ul.c new file mode 100644 index 000000000..616dae751 --- /dev/null +++ b/lib/src/phy/gnb/gnb_ul.c @@ -0,0 +1,169 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsran/phy/gnb/gnb_ul.h" + +/** + * @brief Shifts FFT window a fraction of the cyclic prefix. Set to 0.0f for disabling. + * @note Increases protection against inter-symbol interference in case of synchronization error in expense of computing + * performance + */ +#define GNB_UL_NR_FFT_WINDOW_OFFSET 0.5f + +static int gnb_ul_alloc_prb(srsran_gnb_ul_t* q, uint32_t new_nof_prb) +{ + if (q->max_prb < new_nof_prb) { + q->max_prb = new_nof_prb; + + srsran_chest_dl_res_free(&q->chest); + if (srsran_chest_dl_res_init(&q->chest, q->max_prb) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (q->sf_symbols[0] != NULL) { + free(q->sf_symbols[0]); + } + + q->sf_symbols[0] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); + if (q->sf_symbols[0] == NULL) { + ERROR("Malloc"); + return SRSRAN_ERROR; + } + } + + return SRSRAN_SUCCESS; +} + +int srsran_gnb_ul_init(srsran_gnb_ul_t* q, cf_t* input, const srsran_gnb_ul_args_t* args) +{ + if (q == NULL || args == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + if (gnb_ul_alloc_prb(q, args->nof_max_prb) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_pusch_nr_init_gnb(&q->pusch, &args->pusch) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_pucch_nr_init(&q->pucch, &args->pucch) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_dmrs_sch_init(&q->dmrs, true) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + srsran_ofdm_cfg_t ofdm_cfg = {}; + ofdm_cfg.nof_prb = args->nof_max_prb; + ofdm_cfg.in_buffer = input; + ofdm_cfg.out_buffer = q->sf_symbols[0]; + ofdm_cfg.rx_window_offset = GNB_UL_NR_FFT_WINDOW_OFFSET; + ofdm_cfg.symbol_sz = srsran_min_symbol_sz_rb(args->nof_max_prb); + ofdm_cfg.keep_dc = true; + + if (srsran_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + return SRSRAN_SUCCESS; +} + +void srsran_gnb_ul_free(srsran_gnb_ul_t* q) +{ + if (q == NULL) { + return; + } + + srsran_ofdm_tx_free(&q->fft); + srsran_pusch_nr_free(&q->pusch); + srsran_pucch_nr_free(&q->pucch); + srsran_dmrs_sch_free(&q->dmrs); + srsran_chest_dl_res_free(&q->chest); + + if (q->sf_symbols[0] != NULL) { + free(q->sf_symbols[0]); + } + + SRSRAN_MEM_ZERO(q, srsran_gnb_ul_t, 1); +} + +int srsran_gnb_ul_set_carrier(srsran_gnb_ul_t* q, const srsran_carrier_nr_t* carrier) +{ + if (q == NULL || carrier == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + q->carrier = *carrier; + + if (gnb_ul_alloc_prb(q, carrier->nof_prb) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_pusch_nr_set_carrier(&q->pusch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_pucch_nr_set_carrier(&q->pucch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_dmrs_sch_set_carrier(&q->dmrs, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + srsran_ofdm_cfg_t ofdm_cfg = {}; + ofdm_cfg.nof_prb = carrier->nof_prb; + ofdm_cfg.rx_window_offset = GNB_UL_NR_FFT_WINDOW_OFFSET; + ofdm_cfg.symbol_sz = srsran_min_symbol_sz_rb(carrier->nof_prb); + ofdm_cfg.keep_dc = true; + + if (srsran_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + return SRSRAN_SUCCESS; +} + +int srsran_gnb_ul_fft(srsran_gnb_ul_t* q) +{ + if (q == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + srsran_ofdm_rx_sf(&q->fft); + + return SRSRAN_SUCCESS; +} + +int srsran_gnb_ul_get_pusch(srsran_gnb_ul_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_pusch_res_nr_t* data) +{ + if (q == NULL || cfg == NULL || grant == NULL || data == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + if (srsran_dmrs_sch_estimate(&q->dmrs, slot_cfg, cfg, grant, q->sf_symbols[0], &q->chest) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + if (srsran_pusch_nr_decode(&q->pusch, cfg, grant, &q->chest, q->sf_symbols, data) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + + return SRSRAN_SUCCESS; +} \ No newline at end of file diff --git a/lib/src/phy/phch/pusch_nr.c b/lib/src/phy/phch/pusch_nr.c index 504136d06..df155d9fe 100644 --- a/lib/src/phy/phch/pusch_nr.c +++ b/lib/src/phy/phch/pusch_nr.c @@ -909,7 +909,7 @@ int srsran_pusch_nr_decode(srsran_pusch_nr_t* q, const srsran_sch_grant_nr_t* grant, srsran_chest_dl_res_t* channel, cf_t* sf_symbols[SRSRAN_MAX_PORTS], - srsran_pusch_res_nr_t* data[SRSRAN_MAX_TB]) + srsran_pusch_res_nr_t* data) { // Check input pointers if (!q || !cfg || !grant || !data || !sf_symbols || !channel) { @@ -978,7 +978,7 @@ int srsran_pusch_nr_decode(srsran_pusch_nr_t* q, // SCH decode for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { - if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], data[0], grant->rnti) < SRSRAN_SUCCESS) { + if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], data, grant->rnti) < SRSRAN_SUCCESS) { ERROR("Error encoding TB %d", tb); return SRSRAN_ERROR; } diff --git a/lib/src/phy/phch/test/pusch_nr_test.c b/lib/src/phy/phch/test/pusch_nr_test.c index f1357c130..f88e1b938 100644 --- a/lib/src/phy/phch/test/pusch_nr_test.c +++ b/lib/src/phy/phch/test/pusch_nr_test.c @@ -266,9 +266,7 @@ int main(int argc, char** argv) } chest.nof_re = pusch_cfg.grant.tb->nof_re; - srsran_pusch_res_nr_t* data_rx_vec[SRSRAN_MAX_TB] = {}; - data_rx_vec[0] = &data_rx; - if (srsran_pusch_nr_decode(&pusch_rx, &pusch_cfg, &pusch_cfg.grant, &chest, sf_symbols, data_rx_vec) < + if (srsran_pusch_nr_decode(&pusch_rx, &pusch_cfg, &pusch_cfg.grant, &chest, sf_symbols, &data_rx) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; diff --git a/lib/test/phy/phy_dl_nr_test.c b/lib/test/phy/phy_dl_nr_test.c index c07bed2a9..07b342b83 100644 --- a/lib/test/phy/phy_dl_nr_test.c +++ b/lib/test/phy/phy_dl_nr_test.c @@ -10,7 +10,7 @@ * */ -#include "srsran/phy/enb/enb_dl_nr.h" +#include "srsran/phy/gnb/gnb_dl.h" #include "srsran/phy/phch/ra_dl_nr.h" #include "srsran/phy/phch/ra_nr.h" #include "srsran/phy/ue/ue_dl_nr.h" @@ -144,13 +144,13 @@ static int parse_args(int argc, char** argv) return SRSRAN_SUCCESS; } -static int work_gnb_dl(srsran_enb_dl_nr_t* enb_dl, +static int work_gnb_dl(srsran_gnb_dl_t* gnb_dl, srsran_slot_cfg_t* slot, srsran_search_space_t* search_space, srsran_dci_location_t* dci_location, uint8_t** data_tx) { - if (srsran_enb_dl_nr_base_zero(enb_dl) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_base_zero(gnb_dl) < SRSRAN_SUCCESS) { ERROR("Error setting base to zero"); return SRSRAN_ERROR; } @@ -170,18 +170,18 @@ static int work_gnb_dl(srsran_enb_dl_nr_t* enb_dl, dci_dl.rv = 0; // Put actual DCI - if (srsran_enb_dl_nr_pdcch_put_dl(enb_dl, slot, &dci_dl) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_pdcch_put_dl(gnb_dl, slot, &dci_dl) < SRSRAN_SUCCESS) { ERROR("Error putting PDCCH"); return SRSRAN_ERROR; } // Put PDSCH transmission - if (srsran_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, data_tx) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_pdsch_put(gnb_dl, slot, &pdsch_cfg, data_tx) < SRSRAN_SUCCESS) { ERROR("Error putting PDSCH"); return SRSRAN_ERROR; } - srsran_enb_dl_nr_gen_signal(enb_dl); + srsran_gnb_dl_gen_signal(gnb_dl); return SRSRAN_SUCCESS; } @@ -214,7 +214,7 @@ static int work_ue_dl(srsran_ue_dl_nr_t* ue_dl, srsran_slot_cfg_t* slot, srsran_ int main(int argc, char** argv) { int ret = SRSRAN_ERROR; - srsran_enb_dl_nr_t enb_dl = {}; + srsran_gnb_dl_t gnb_dl = {}; srsran_ue_dl_nr_t ue_dl = {}; srsran_pdsch_res_nr_t pdsch_res = {}; srsran_random_t rand_gen = srsran_random_init(1234); @@ -251,11 +251,11 @@ int main(int argc, char** argv) ue_dl_args.pdcch.measure_evm = true; ue_dl_args.nof_max_prb = carrier.nof_prb; - srsran_enb_dl_nr_args_t enb_dl_args = {}; - enb_dl_args.nof_tx_antennas = 1; - enb_dl_args.pdsch.sch.disable_simd = false; - enb_dl_args.pdcch.disable_simd = false; - enb_dl_args.nof_max_prb = carrier.nof_prb; + srsran_gnb_dl_args_t gnb_dl_args = {}; + gnb_dl_args.nof_tx_antennas = 1; + gnb_dl_args.pdsch.sch.disable_simd = false; + gnb_dl_args.pdcch.disable_simd = false; + gnb_dl_args.nof_max_prb = carrier.nof_prb; srsran_pdcch_cfg_nr_t pdcch_cfg = {}; @@ -285,7 +285,7 @@ int main(int argc, char** argv) goto clean_exit; } - if (srsran_enb_dl_nr_init(&enb_dl, buffer_gnb, &enb_dl_args)) { + if (srsran_gnb_dl_init(&gnb_dl, buffer_gnb, &gnb_dl_args)) { ERROR("Error UE DL"); goto clean_exit; } @@ -304,12 +304,12 @@ int main(int argc, char** argv) goto clean_exit; } - if (srsran_enb_dl_nr_set_carrier(&enb_dl, &carrier)) { + if (srsran_gnb_dl_set_carrier(&gnb_dl, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srsran_enb_dl_nr_set_pdcch_config(&enb_dl, &pdcch_cfg, &dci_cfg)) { + if (srsran_gnb_dl_set_pdcch_config(&gnb_dl, &pdcch_cfg, &dci_cfg)) { ERROR("Error setting CORESET"); goto clean_exit; } @@ -410,7 +410,7 @@ int main(int argc, char** argv) dci_location.L = L; gettimeofday(&t[1], NULL); - if (work_gnb_dl(&enb_dl, &slot, search_space, &dci_location, data_tx) < SRSRAN_ERROR) { + if (work_gnb_dl(&gnb_dl, &slot, search_space, &dci_location, data_tx) < SRSRAN_ERROR) { ERROR("Error running eNb DL"); goto clean_exit; } @@ -501,7 +501,7 @@ int main(int argc, char** argv) clean_exit: srsran_random_free(rand_gen); - srsran_enb_dl_nr_free(&enb_dl); + srsran_gnb_dl_free(&gnb_dl); srsran_ue_dl_nr_free(&ue_dl); for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data_tx[i]) { diff --git a/srsenb/hdr/phy/nr/slot_worker.h b/srsenb/hdr/phy/nr/slot_worker.h index 7756b2116..dd5fd3985 100644 --- a/srsenb/hdr/phy/nr/slot_worker.h +++ b/srsenb/hdr/phy/nr/slot_worker.h @@ -79,7 +79,7 @@ private: srsran_slot_cfg_t ul_slot_cfg = {}; srsran_pdcch_cfg_nr_t pdcch_cfg = {}; srsran::rf_timestamp_t tx_time = {}; - srsran_enb_dl_nr_t gnb_dl = {}; + srsran_gnb_dl_t gnb_dl = {}; std::vector tx_buffer; ///< Baseband transmit buffers std::vector rx_buffer; ///< Baseband receive buffers }; diff --git a/srsenb/src/phy/nr/slot_worker.cc b/srsenb/src/phy/nr/slot_worker.cc index 9bb1fa0bf..411e319e8 100644 --- a/srsenb/src/phy/nr/slot_worker.cc +++ b/srsenb/src/phy/nr/slot_worker.cc @@ -18,7 +18,9 @@ namespace nr { slot_worker::slot_worker(srsran::phy_common_interface& common_, stack_interface_phy_nr& stack_, srslog::basic_logger& logger_) : - common(common_), stack(stack_), logger(logger_) + common(common_), + stack(stack_), + logger(logger_) { // Do nothing } @@ -53,21 +55,21 @@ bool slot_worker::init(const args_t& args) } // Prepare DL arguments - srsran_enb_dl_nr_args_t dl_args = {}; - dl_args.pdsch.measure_time = true; - dl_args.pdsch.max_layers = args.carrier.max_mimo_layers; - dl_args.pdsch.max_prb = args.carrier.nof_prb; - dl_args.nof_tx_antennas = args.nof_tx_ports; - dl_args.nof_max_prb = args.carrier.nof_prb; + srsran_gnb_dl_args_t dl_args = {}; + dl_args.pdsch.measure_time = true; + dl_args.pdsch.max_layers = args.carrier.max_mimo_layers; + dl_args.pdsch.max_prb = args.carrier.nof_prb; + dl_args.nof_tx_antennas = args.nof_tx_ports; + dl_args.nof_max_prb = args.carrier.nof_prb; // Initialise DL - if (srsran_enb_dl_nr_init(&gnb_dl, tx_buffer.data(), &dl_args) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_init(&gnb_dl, tx_buffer.data(), &dl_args) < SRSRAN_SUCCESS) { logger.error("Error gNb PHY init"); return false; } // Set gNb carrier - if (srsran_enb_dl_nr_set_carrier(&gnb_dl, &args.carrier) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_set_carrier(&gnb_dl, &args.carrier) < SRSRAN_SUCCESS) { logger.error("Error setting carrier"); return false; } @@ -89,7 +91,7 @@ slot_worker::~slot_worker() b = nullptr; } } - srsran_enb_dl_nr_free(&gnb_dl); + srsran_gnb_dl_free(&gnb_dl); } cf_t* slot_worker::get_buffer_rx(uint32_t antenna_idx) @@ -153,7 +155,7 @@ bool slot_worker::work_dl() return false; } - if (srsran_enb_dl_nr_base_zero(&gnb_dl) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_base_zero(&gnb_dl) < SRSRAN_SUCCESS) { logger.error("Error zeroeing RE grid"); return false; } @@ -161,13 +163,13 @@ bool slot_worker::work_dl() // Encode PDCCH for DL transmissions for (const stack_interface_phy_nr::pdcch_dl_t& pdcch : dl_sched.pdcch_dl) { // Set PDCCH configuration, including DCI dedicated - if (srsran_enb_dl_nr_set_pdcch_config(&gnb_dl, &pdcch_cfg, &pdcch.dci_cfg) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_set_pdcch_config(&gnb_dl, &pdcch_cfg, &pdcch.dci_cfg) < SRSRAN_SUCCESS) { logger.error("PDCCH: Error setting DL configuration"); return false; } // Put PDCCH message - if (srsran_enb_dl_nr_pdcch_put_dl(&gnb_dl, &dl_slot_cfg, &pdcch.dci) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_pdcch_put_dl(&gnb_dl, &dl_slot_cfg, &pdcch.dci) < SRSRAN_SUCCESS) { logger.error("PDCCH: Error putting DL message"); return false; } @@ -175,7 +177,7 @@ bool slot_worker::work_dl() // Log PDCCH information if (logger.info.enabled()) { std::array str = {}; - srsran_enb_dl_nr_pdcch_dl_info(&gnb_dl, &pdcch.dci, str.data(), (uint32_t)str.size()); + srsran_gnb_dl_pdcch_dl_info(&gnb_dl, &pdcch.dci, str.data(), (uint32_t)str.size()); logger.info("PDCCH: cc=%d %s tti_tx=%d", cell_index, str.data(), dl_slot_cfg.idx); } } @@ -183,13 +185,13 @@ bool slot_worker::work_dl() // Encode PDCCH for UL transmissions for (const stack_interface_phy_nr::pdcch_ul_t& pdcch : dl_sched.pdcch_ul) { // Set PDCCH configuration, including DCI dedicated - if (srsran_enb_dl_nr_set_pdcch_config(&gnb_dl, &pdcch_cfg, &pdcch.dci_cfg) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_set_pdcch_config(&gnb_dl, &pdcch_cfg, &pdcch.dci_cfg) < SRSRAN_SUCCESS) { logger.error("PDCCH: Error setting DL configuration"); return false; } // Put PDCCH message - if (srsran_enb_dl_nr_pdcch_put_ul(&gnb_dl, &dl_slot_cfg, &pdcch.dci) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_pdcch_put_ul(&gnb_dl, &dl_slot_cfg, &pdcch.dci) < SRSRAN_SUCCESS) { logger.error("PDCCH: Error putting DL message"); return false; } @@ -197,7 +199,7 @@ bool slot_worker::work_dl() // Log PDCCH information if (logger.info.enabled()) { std::array str = {}; - srsran_enb_dl_nr_pdcch_ul_info(&gnb_dl, &pdcch.dci, str.data(), (uint32_t)str.size()); + srsran_gnb_dl_pdcch_ul_info(&gnb_dl, &pdcch.dci, str.data(), (uint32_t)str.size()); logger.info("PDCCH: cc=%d %s tti_tx=%d", cell_index, str.data(), dl_slot_cfg.idx); } } @@ -205,7 +207,7 @@ bool slot_worker::work_dl() // Encode PDSCH for (stack_interface_phy_nr::pdsch_t& pdsch : dl_sched.pdsch) { // Put PDSCH message - if (srsran_enb_dl_nr_pdsch_put(&gnb_dl, &dl_slot_cfg, &pdsch.sch, pdsch.data.data()) < SRSRAN_SUCCESS) { + if (srsran_gnb_dl_pdsch_put(&gnb_dl, &dl_slot_cfg, &pdsch.sch, pdsch.data.data()) < SRSRAN_SUCCESS) { logger.error("PDSCH: Error putting DL message"); return false; } @@ -213,7 +215,7 @@ bool slot_worker::work_dl() // Log PDSCH information if (logger.info.enabled()) { std::array str = {}; - srsran_enb_dl_nr_pdsch_info(&gnb_dl, &pdsch.sch, str.data(), (uint32_t)str.size()); + srsran_gnb_dl_pdsch_info(&gnb_dl, &pdsch.sch, str.data(), (uint32_t)str.size()); logger.info("PDSCH: cc=%d %s tti_tx=%d", cell_index, str.data(), dl_slot_cfg.idx); } } @@ -224,7 +226,7 @@ bool slot_worker::work_dl() } // Generate baseband signal - srsran_enb_dl_nr_gen_signal(&gnb_dl); + srsran_gnb_dl_gen_signal(&gnb_dl); // Add SSB to the baseband signal for (const stack_interface_phy_nr::ssb_t& ssb : dl_sched.ssb) {