Refactor NR RA files and fix header includes all over library (#2162)

* Refactor NR resource allocation classes. Use DCI instead of grant for dummy PDSCH UE/eNB test

* Minor refactors in NR workers and ue_dl

* Fix include issues

* fix compilation issues
master
Ismael Gomez 4 years ago committed by GitHub
parent 8a3d70f6da
commit a6423442c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,7 @@
#include <memory>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
/*******************************************************************************
DEFINES
@ -75,8 +76,6 @@
#define pool_allocate_blocking (srslte::allocate_unique_buffer(*pool, true))
#endif
#include "srslte/srslte.h"
/*******************************************************************************
TYPEDEFS
*******************************************************************************/

@ -20,6 +20,7 @@
#include "srslte/common/logmap.h"
#include <fstream>
#include <sstream>
#include <thread>
namespace srslte {

@ -14,6 +14,7 @@
#define SRSLTE_CONFIG_FILE_H
#include "common.h"
#include "srslte/phy/common/phy_common.h"
#include <fstream>
#include <pwd.h>
#include <sys/types.h>

@ -14,6 +14,7 @@
#define SRSLTE_INTERFACES_COMMON_H
#include "srslte/common/security.h"
#include "srslte/phy/common/phy_common.h"
#include <string>
namespace srslte {

@ -20,7 +20,6 @@
#define SRSLTE_METRICS_HUB_H
#include "srslte/common/threads.h"
#include "srslte/srslte.h"
#include <chrono>
#include <mutex>
#include <thread>

@ -17,10 +17,14 @@
#include "srslte/common/logmap.h"
#include "srslte/common/threads.h"
#include <arpa/inet.h>
#include <functional>
#include <map>
#include <mutex>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <queue>
#include <sys/socket.h>
#include <sys/types.h>

@ -20,7 +20,7 @@
#ifndef SRSLTE_TIMEOUT_H
#define SRSLTE_TIMEOUT_H
#include "srslte/srslte.h"
#include "srslte/phy/utils/debug.h"
#include <pthread.h>
#include <stdint.h>
#include <sys/time.h>

@ -20,6 +20,7 @@
#ifndef SRSLTE_TIMERS_H
#define SRSLTE_TIMERS_H
#include "srslte/phy/utils/debug.h"
#include <algorithm>
#include <functional>
#include <limits>
@ -30,8 +31,6 @@
#include <time.h>
#include <vector>
#include "srslte/srslte.h"
namespace srslte {
class timer_callback

@ -13,6 +13,8 @@
#ifndef SRSLTE_GNB_INTERFACES_H
#define SRSLTE_GNB_INTERFACES_H
#include "srslte/srslte.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/pdcp_interface_types.h"
@ -210,7 +212,35 @@ public:
virtual void process_pdus() = 0;
};
class stack_interface_phy_nr : public srslte::stack_interface_phy_nr
class mac_interface_phy_nr
{
public:
const static int MAX_GRANTS = 64;
/**
* DL grant structure per UE
*/
struct dl_sched_grant_t {
srslte_dci_dl_nr_t dci = {};
uint8_t* data[SRSLTE_MAX_TB] = {};
srslte_softbuffer_tx_t* softbuffer_tx[SRSLTE_MAX_TB] = {};
};
/**
* DL Scheduling result per cell/carrier
*/
typedef struct {
dl_sched_grant_t pdsch[MAX_GRANTS]; //< DL Grants
uint32_t nof_grants; //< Number of DL grants
} dl_sched_t;
/**
* List of DL scheduling results, one entry per cell/carrier
*/
typedef std::vector<dl_sched_t> dl_sched_list_t;
};
class stack_interface_phy_nr : public mac_interface_phy_nr, public srslte::stack_interface_phy_nr
{
public:
struct rx_data_ind_t {
@ -223,9 +253,6 @@ public:
virtual int rx_data_indication(rx_data_ind_t& grant) = 0;
};
class mac_interface_phy_nr
{};
} // namespace srsenb
#endif // SRSLTE_GNB_INTERFACES_H

@ -19,6 +19,7 @@
#define SRSLTE_PDCP_INTERFACE_TYPES_H
#include "srslte/common/security.h"
#include <math.h>
#include <stdint.h>
namespace srslte {
@ -119,7 +120,7 @@ public:
t_reordering(t_reordering_),
discard_timer(discard_timer_)
{
hdr_len_bytes = ceil((float)sn_len / 8);
hdr_len_bytes = ceilf((float)sn_len / 8);
}
uint8_t bearer_id = 1;

@ -15,6 +15,7 @@
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/config.h"
#include <memory>
#include <stdint.h>
#include <vector>

@ -15,6 +15,7 @@
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logmap.h"
#include <sstream>
#include <stdint.h>
#include <stdio.h>
#include <vector>

@ -14,12 +14,9 @@
#define SRSLTE_DMRS_PDCCH_H
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/dci_nr.h"
#include "srslte/phy/resampling/interp.h"
#include "srslte/phy/resampling/resampler.h"
#include "srslte/srslte.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Puts in the resource grid the DeModulation Reference Signals for decoding PDCCH.
@ -182,8 +179,4 @@ SRSLTE_API int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q,
const srslte_dci_location_t* location,
srslte_dmrs_pdcch_ce_t* ce);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_DMRS_PDCCH_H

@ -13,15 +13,11 @@
#ifndef SRSLTE_DMRS_SCH_H
#define SRSLTE_DMRS_SCH_H
#include "srslte/phy/ch_estimation/chest_dl.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#include "srslte/srslte.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SRSLTE_DMRS_SCH_MAX_SYMBOLS 4
/**
@ -156,8 +152,4 @@ SRSLTE_API int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q,
const cf_t* sf_symbols,
srslte_chest_dl_res_t* chest_res);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_DMRS_SCH_H

@ -13,12 +13,14 @@
#ifndef SRSLTE_CHANNEL_H
#define SRSLTE_CHANNEL_H
#include "ch_awgn.h"
#include "delay.h"
#include "fading.h"
#include "hst.h"
#include "rlf.h"
#include "srslte/common/log_filter.h"
#include "srslte/phy/common/phy_common.h"
#include <memory>
#include <srslte/common/log_filter.h>
#include <string>
namespace srslte {

@ -13,7 +13,10 @@
#ifndef SRSLTE_DELAY_H
#define SRSLTE_DELAY_H
#include <srslte/srslte.h>
#include "srslte/config.h"
#include "srslte/phy/common/timestamp.h"
#include "srslte/phy/utils/ringbuffer.h"
#include <stdint.h>
typedef struct {
float delay_min_us;

@ -13,8 +13,11 @@
#ifndef SRSLTE_FADING_H
#define SRSLTE_FADING_H
#include "srslte/config.h"
#include "srslte/phy/common/timestamp.h"
#include "srslte/phy/dft/dft.h"
#include <inttypes.h>
#include <srslte/srslte.h>
#include <stdint.h>
#define SRSLTE_CHANNEL_FADING_MAXTAPS 9
#define SRSLTE_CHANNEL_FADING_NTERMS 16

@ -13,7 +13,9 @@
#ifndef SRSLTE_HST_H_
#define SRSLTE_HST_H_
#include <srslte/srslte.h>
#include "srslte/config.h"
#include "srslte/phy/common/timestamp.h"
#include <stdint.h>
typedef struct {
// System parameters

@ -13,7 +13,9 @@
#ifndef SRSLTE_RLF_H
#define SRSLTE_RLF_H
#include <srslte/srslte.h>
#include "srslte/config.h"
#include "srslte/phy/common/timestamp.h"
#include <stdint.h>
typedef struct {
uint32_t t_on_ms;

@ -132,6 +132,10 @@ typedef enum SRSLTE_API { srslte_sch_mapping_type_A = 0, srslte_sch_mapping_type
typedef enum SRSLTE_API {
srslte_search_space_type_common = 0,
srslte_search_space_type_common_0,
srslte_search_space_type_common_0A,
srslte_search_space_type_common_1,
srslte_search_space_type_common_2,
srslte_search_space_type_ue,
} srslte_search_space_type_t;

@ -18,10 +18,6 @@
#include "srslte/phy/phch/pdcch_nr.h"
#include "srslte/phy/phch/pdsch_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SRSLTE_API {
srslte_pdsch_nr_args_t pdsch;
srslte_pdcch_nr_args_t pdcch;
@ -59,25 +55,15 @@ SRSLTE_API void srslte_enb_dl_nr_gen_signal(srslte_enb_dl_nr_t* q);
SRSLTE_API int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot_cfg,
const srslte_search_space_t* search_space,
const srslte_dci_dl_nr_t* dci_dl,
const srslte_dci_location_t* dci_location,
uint16_t rnti);
const srslte_dci_dl_nr_t* dci_dl);
SRSLTE_API int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
uint8_t* data[SRSLTE_MAX_TB]);
SRSLTE_API int srslte_enb_dl_nr_pdsch_info(const srslte_enb_dl_nr_t* q,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
char* str,
uint32_t str_len);
SRSLTE_API int
srslte_enb_dl_nr_pdsch_info(const srslte_enb_dl_nr_t* q, const srslte_sch_cfg_nr_t* cfg, char* str, uint32_t str_len);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_ENB_DL_NR_H

@ -13,7 +13,8 @@
#ifndef SRSLTE_EVM_H_
#define SRSLTE_EVM_H_
#include "srslte/config.h"
#include "srslte/phy/modem/mod.h"
#include "srslte/phy/modem/modem_table.h"
#include "srslte/phy/phch/ra.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"

@ -28,7 +28,11 @@ typedef struct SRSLTE_API {
} srslte_dci_msg_nr_t;
typedef struct SRSLTE_API {
uint16_t rnti;
srslte_rnti_type_t rnti_type;
srslte_dci_format_nr_t format;
srslte_dci_location_t location;
srslte_search_space_t search_space;
// Common fields
uint32_t freq_domain_assigment; ///< Frequency domain resource assignment
@ -56,6 +60,11 @@ typedef struct SRSLTE_API {
} srslte_dci_dl_nr_t;
SRSLTE_API int srslte_dci_nr_pack(const srslte_carrier_nr_t* carrier,
const srslte_coreset_t* coreset,
const srslte_dci_dl_nr_t* dci,
srslte_dci_msg_nr_t* msg);
SRSLTE_API SRSLTE_API int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier,
const srslte_coreset_t* coreset,
srslte_rnti_type_t rnti_type);

@ -22,7 +22,6 @@
#define SRSLTE_PDCCH_NR_H
#include "dci_nr.h"
#include "srslte/config.h"
#include "srslte/phy/ch_estimation/dmrs_pdcch.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/fec/crc.h"
@ -30,6 +29,8 @@
#include "srslte/phy/fec/polar/polar_decoder.h"
#include "srslte/phy/fec/polar/polar_encoder.h"
#include "srslte/phy/fec/polar/polar_rm.h"
#include "srslte/phy/modem/evm.h"
#include "srslte/phy/modem/modem_table.h"
/**
* @brief PDCCH configuration initialization arguments

@ -23,6 +23,8 @@
#include "srslte/config.h"
#include "srslte/phy/ch_estimation/dmrs_sch.h"
#include "srslte/phy/modem/evm.h"
#include "srslte/phy/modem/modem_table.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#include "srslte/phy/phch/regs.h"
#include "srslte/phy/phch/sch_nr.h"

@ -24,10 +24,6 @@
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/sch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief PDSCH DMRS type
*/
@ -100,7 +96,7 @@ typedef struct SRSLTE_API {
/// (SLIV). The network configures the field so that the allocation does not cross the slot boundary
uint32_t sliv;
} srslte_pdsch_allocation_t;
} srslte_pdsch_time_ra_t;
/**
* @brief PDSCH grant information provided by the Downlink Control Information (DCI)
@ -119,6 +115,7 @@ typedef struct SRSLTE_API {
/// Frequency domain resources
bool prb_idx[SRSLTE_MAX_PRB_NR];
uint32_t nof_prb;
/// Number of DMRS groups without data
/// Described in TS 38.214 Section 5.1.6.2
@ -153,6 +150,13 @@ typedef struct SRSLTE_API {
srslte_dmrs_sch_cfg_t dmrs_typeA;
srslte_dmrs_sch_cfg_t dmrs_typeB;
srslte_sch_grant_nr_t grant;
bool pdsch_time_is_default; ///< Set to true if pdsch_time_ra contains the configuration from pdsch-ConfigCommon or
///< pdsch-Config
srslte_pdsch_time_ra_t pdsch_time_ra[SRSLTE_MAX_NOF_DL_ALLOCATION];
bool rbg_size_cfg_1; ///< RBG size configuration (1 or 2)
srslte_sch_cfg_t sch_cfg; ///< Common shared channel parameters
@ -160,8 +164,4 @@ typedef struct SRSLTE_API {
bool enable_transform_precoder;
} srslte_sch_cfg_nr_t;
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_PHCH_CFG_NR_H

@ -15,6 +15,8 @@
#include "srslte/config.h"
#include "srslte/phy/ch_estimation/dmrs_sch.h"
#include "srslte/phy/modem/evm.h"
#include "srslte/phy/modem/modem_table.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#include "srslte/phy/phch/regs.h"
#include "srslte/phy/phch/sch_nr.h"

@ -20,27 +20,30 @@
* Reference:
*****************************************************************************/
#ifndef SRSLTE_UE_DL_NR_DATA_H
#define SRSLTE_UE_DL_NR_DATA_H
#ifndef SRSLTE_RA_DL_NR_H
#define SRSLTE_RA_DL_NR_H
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/dci_nr.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Calculates the PDSCH time resource provided by higher layers and stores it in the provided PDSCH NR grant.
* @brief Calculates the PDSCH time resource allocation and stores it in the provided PDSCH NR grant.
*
* @remark Defined by TS 38.214 V15.10.0 section 5.1.2.1.1 Determination of the resource allocation table to be used for
* PDSCH
*
* @param pdsch_alloc Flattened PHY PDSCH allocation configuration provided from higher layers
* @param[out] grant PDSCH mapping type
* @param pdsch_cfg Flattened PDSCH configuration provided from higher layers
* @param rnti_type Type of the RNTI of the corresponding DCI
* @param ss_type Type of the SS for PDCCH
* @param m Time domain resource assignment field value m provided in DCI
* @param[out] Provides grant pointer to fill
* @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code
*/
SRSLTE_API int srslte_ue_dl_nr_pdsch_time_resource_hl(const srslte_pdsch_allocation_t* pdsch_alloc,
SRSLTE_API int srslte_ra_dl_nr_time(const srslte_sch_cfg_nr_t* pdsch_cfg,
const srslte_rnti_type_t rnti_type,
const srslte_search_space_type_t ss_type,
const uint8_t m,
srslte_sch_grant_nr_t* grant);
/**
@ -55,9 +58,8 @@ SRSLTE_API int srslte_ue_dl_nr_pdsch_time_resource_hl(const srslte_pdsch_allocat
* @param[out] grant PDSCH mapping type
* @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code
*/
SRSLTE_API int srslte_ue_dl_nr_pdsch_time_resource_default_A(uint32_t m,
srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos,
srslte_sch_grant_nr_t* grant);
SRSLTE_API int
srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srslte_sch_grant_nr_t* grant);
/**
* @brief Calculates the number of PDSCH-DMRS CDM groups without data for DCI format 1_0
*
@ -67,11 +69,23 @@ SRSLTE_API int srslte_ue_dl_nr_pdsch_time_resource_default_A(uint32_t
* @param[out] grant Provides grant pointer to fill
* @return Returns SRSLTE_SUCCESS if the provided data is valid, otherwise it returns SRSLTE_ERROR code
*/
SRSLTE_API int srslte_ue_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_sch_cfg_nr_t* pdsch_cfg,
SRSLTE_API int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_sch_cfg_nr_t* pdsch_cfg,
srslte_sch_grant_nr_t* grant);
/**
* @brief Calculates the PDSCH frequency resource allocation and stores it in the provided PDSCH NR grant.
*
* @remark Defined by TS 38.214 V15.10.0 section 5.1.2.2
* @param carrier Carrier information
* @param cfg PDSCH NR configuration by upper layers
* @param dci_dl Unpacked DCI used to schedule the PDSCH grant
* @param[out] grant Provides grant pointer to fill
* @return
*/
SRSLTE_API int srslte_ra_dl_nr_freq(const srslte_carrier_nr_t* carrier,
const srslte_sch_cfg_nr_t* cfg,
const srslte_dci_dl_nr_t* dci_dl,
srslte_sch_grant_nr_t* grant);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_UE_DL_NR_DATA_H
#endif // SRSLTE_RA_DL_NR_H

@ -26,12 +26,9 @@
#include "srslte/config.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/dci_nr.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Determines target rate
* @param mcs_table Configured MCS table
@ -85,9 +82,22 @@ SRSLTE_API int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg,
const srslte_sch_grant_nr_t* grant,
uint32_t mcs_idx,
srslte_sch_tb_t* tb);
#ifdef __cplusplus
}
#endif
/**
* @brief Converts an unpacked DL DCI message to a PDSCH grant structure.
* Implements the procedures defined in Section 5 of 38.214 to compute the resource allocation (5.1.2)
* and modulation order, target rate, redundancy version and TBS (5.1.3)
*
* Note: Only TypeA PDSCH mapping type is supported
*
* @param carrier Carrier information struct
* @param pdsch_cfg PDSCH configuration indicated by higher layers
* @param dci_dl DCI downlink (format 1_0 or 1_1)
* @param pdsch_grant Generated PDSCH grant
* @return 0 on success, -1 on error
*/
SRSLTE_API int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrier,
const srslte_sch_cfg_nr_t* pdsch_cfg,
const srslte_dci_dl_nr_t* dci_dl,
srslte_sch_grant_nr_t* pdsch_grant);
#endif // SRSLTE_RA_NR_H

@ -20,10 +20,6 @@
#include "srslte/phy/phch/pdcch_nr.h"
#include "srslte/phy/phch/pdsch_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SRSLTE_API {
srslte_pdsch_nr_args_t pdsch;
srslte_pdcch_nr_args_t pdcch;
@ -71,21 +67,16 @@ SRSLTE_API int srslte_ue_dl_nr_find_dl_dci(srslte_ue_dl_nr_t* q,
srslte_dci_dl_nr_t* dci_dl_list,
uint32_t nof_dci_msg);
SRSLTE_API int srslte_ue_dl_nr_pdsch_get(srslte_ue_dl_nr_t* q,
SRSLTE_API int srslte_ue_dl_nr_decode_pdsch(srslte_ue_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
srslte_pdsch_res_nr_t* res);
SRSLTE_API int srslte_ue_dl_nr_pdsch_info(const srslte_ue_dl_nr_t* q,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
const srslte_pdsch_res_nr_t res[SRSLTE_MAX_CODEWORDS],
char* str,
uint32_t str_len);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_UE_DL_NR_H

@ -26,10 +26,6 @@
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/phch/phch_cfg_nr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Calculates the PUSCH time resource default A and stores it in the provided PUSCH NR grant.
*
@ -54,8 +50,5 @@ SRSLTE_API int srslte_ue_ul_nr_pdsch_time_resource_default_A(uint32_t m, srslte_
SRSLTE_API int srslte_ue_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srslte_sch_cfg_nr_t* cfg,
srslte_sch_grant_nr_t* grant);
#ifdef __cplusplus
}
#endif
#endif // SRSLTE_UE_UL_DATA_H

@ -39,6 +39,8 @@ extern "C" {
#include "srslte/phy/ch_estimation/chest_dl.h"
#include "srslte/phy/ch_estimation/chest_ul.h"
#include "srslte/phy/ch_estimation/dmrs_pdcch.h"
#include "srslte/phy/ch_estimation/dmrs_sch.h"
#include "srslte/phy/ch_estimation/refsignal_dl.h"
#include "srslte/phy/ch_estimation/refsignal_ul.h"
#include "srslte/phy/ch_estimation/wiener_dl.h"
@ -70,6 +72,7 @@ extern "C" {
#include "srslte/phy/modem/demod_hard.h"
#include "srslte/phy/modem/demod_soft.h"
#include "srslte/phy/modem/evm.h"
#include "srslte/phy/modem/mod.h"
#include "srslte/phy/modem/modem_table.h"
@ -79,9 +82,11 @@ extern "C" {
#include "srslte/phy/fec/softbuffer.h"
#include "srslte/phy/phch/cqi.h"
#include "srslte/phy/phch/dci.h"
#include "srslte/phy/phch/dci_nr.h"
#include "srslte/phy/phch/pbch.h"
#include "srslte/phy/phch/pcfich.h"
#include "srslte/phy/phch/pdcch.h"
#include "srslte/phy/phch/pdcch_nr.h"
#include "srslte/phy/phch/pdsch.h"
#include "srslte/phy/phch/phich.h"
#include "srslte/phy/phch/prach.h"
@ -90,6 +95,8 @@ extern "C" {
#include "srslte/phy/phch/pusch.h"
#include "srslte/phy/phch/ra.h"
#include "srslte/phy/phch/ra_dl.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/phch/ra_ul.h"
#include "srslte/phy/phch/regs.h"
#include "srslte/phy/phch/sch.h"
@ -97,11 +104,13 @@ extern "C" {
#include "srslte/phy/ue/ue_cell_search.h"
#include "srslte/phy/ue/ue_dl.h"
#include "srslte/phy/ue/ue_dl_nr.h"
#include "srslte/phy/ue/ue_mib.h"
#include "srslte/phy/ue/ue_sync.h"
#include "srslte/phy/ue/ue_ul.h"
#include "srslte/phy/enb/enb_dl.h"
#include "srslte/phy/enb/enb_dl_nr.h"
#include "srslte/phy/enb/enb_ul.h"
#include "srslte/phy/scrambling/scrambling.h"

@ -13,6 +13,8 @@
#ifndef SRSLTE_IPV6_H
#define SRSLTE_IPV6_H
#include <linux/in6.h>
// as of glibc 2.19, the IPv6 issue seems to be fixed https://sourceware.org/bugzilla/show_bug.cgi?id=15850
#if __GLIBC_PREREQ(2, 19)
#include <linux/ipv6.h>

@ -11,6 +11,8 @@
*/
#include "srslte/common/mac_pcap.h"
#include "srslte/config.h"
#include "srslte/phy/common/phy_common.h"
#include <stdint.h>
namespace srslte {

@ -13,6 +13,7 @@
#include "srslte/common/security.h"
#include "srslte/common/liblte_security.h"
#include "srslte/common/s3g.h"
#include "srslte/config.h"
#ifdef HAVE_MBEDTLS
#include "mbedtls/md5.h"

@ -41,6 +41,6 @@ set(srslte_srcs $<TARGET_OBJECTS:srslte_agc>
$<TARGET_OBJECTS:srslte_enb>
)
add_library(srslte_phy STATIC ${srslte_srcs})
add_library(srslte_phy STATIC ${srslte_srcs} )
target_link_libraries(srslte_phy pthread m ${FFT_LIBRARIES})
INSTALL(TARGETS srslte_phy DESTINATION ${LIBRARY_DIR})

@ -11,6 +11,13 @@
*/
#include "srslte/phy/ch_estimation/dmrs_pdcch.h"
#include "srslte/phy/ch_estimation/chest_common.h"
#include "srslte/phy/common/sequence.h"
#include "srslte/phy/utils/convolution.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
#include <complex.h>
#include <math.h>
/// @brief Every frequency resource is 6 Resource blocks, every resource block carries 3 pilots. So 18 possible pilots
/// per frequency resource.

@ -11,6 +11,7 @@
*/
#include "srslte/phy/ch_estimation/dmrs_sch.h"
#include "srslte/phy/common/sequence.h"
#include <srslte/phy/utils/debug.h>
#define SRSLTE_DMRS_SCH_TYPEA_SINGLE_DURATION_MIN 3

@ -12,7 +12,7 @@
#include "srslte/common/test_common.h"
#include "srslte/phy/ch_estimation/dmrs_sch.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/srslte.h"
#include <complex.h>
#include <stdio.h>
@ -312,7 +312,7 @@ int main(int argc, char** argv)
grant.nof_dmrs_cdm_groups_without_data++) {
// Load default type A grant
srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &grant);
srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &grant);
// Copy configuration
pdsch_cfg.dmrs_typeB = pdsch_cfg.dmrs_typeA;

@ -11,6 +11,9 @@
*/
#include "srslte/phy/channel/hst.h"
#include "srslte/phy/utils/vector.h"
#include <math.h>
#include <strings.h>
int srslte_channel_hst_init(srslte_channel_hst_t* q, float fd_hz, float period_d, float init_time_s)
{

@ -169,35 +169,21 @@ int srslte_enb_dl_nr_base_zero(srslte_enb_dl_nr_t* q)
int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot_cfg,
const srslte_search_space_t* search_space,
const srslte_dci_dl_nr_t* dci_dl,
const srslte_dci_location_t* dci_location,
uint16_t rnti)
const srslte_dci_dl_nr_t* dci_dl)
{
if (q == NULL || search_space == NULL || slot_cfg == NULL || dci_dl == NULL) {
if (q == NULL || slot_cfg == NULL || dci_dl == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
// Hard-coded values
srslte_dci_format_nr_t dci_format = srslte_dci_format_nr_1_0;
srslte_rnti_type_t rnti_type = srslte_rnti_type_c;
// Put DMRS
if (srslte_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, dci_location, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
if (srslte_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, &dci_dl->location, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
ERROR("Error putting PDCCH DMRS\n");
return SRSLTE_ERROR;
}
// Initialise DCI MSG fields
srslte_dci_msg_nr_t dci_msg = {};
dci_msg.location = *dci_location;
dci_msg.search_space = search_space->type;
dci_msg.rnti_type = rnti_type;
dci_msg.rnti = rnti;
dci_msg.format = dci_format;
// Pack DCI
if (srslte_dci_nr_format_1_0_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSLTE_SUCCESS) {
srslte_dci_msg_nr_t dci_msg = {};
if (srslte_dci_nr_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSLTE_SUCCESS) {
ERROR("Error packing DL DCI\n");
return SRSLTE_ERROR;
}
@ -208,7 +194,7 @@ int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q,
return SRSLTE_ERROR;
}
INFO("DCI DL NR: L=%d; ncce=%d;\n", dci_location->L, dci_location->ncce);
INFO("DCI DL NR: L=%d; ncce=%d;\n", dci_dl->location.L, dci_dl->location.ncce);
return SRSLTE_SUCCESS;
}
@ -216,15 +202,14 @@ int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q,
int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
uint8_t* data[SRSLTE_MAX_TB])
{
if (srslte_dmrs_sch_put_sf(&q->dmrs, slot, cfg, grant, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
if (srslte_dmrs_sch_put_sf(&q->dmrs, slot, cfg, &cfg->grant, q->sf_symbols[0]) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
if (srslte_pdsch_nr_encode(&q->pdsch, cfg, grant, data, q->sf_symbols) < SRSLTE_SUCCESS) {
if (srslte_pdsch_nr_encode(&q->pdsch, cfg, &cfg->grant, data, q->sf_symbols) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
@ -233,14 +218,13 @@ int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q,
int srslte_enb_dl_nr_pdsch_info(const srslte_enb_dl_nr_t* q,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
char* str,
uint32_t str_len)
{
int len = 0;
// Append PDSCH info
len += srslte_pdsch_nr_tx_info(&q->pdsch, cfg, grant, &str[len], str_len - len);
len += srslte_pdsch_nr_tx_info(&q->pdsch, cfg, &cfg->grant, &str[len], str_len - len);
return len;
}

@ -35,6 +35,34 @@ static int dci_nr_format_1_0_freq_resource_size(const srslte_carrier_nr_t* carri
return (int)ceil(log2(N_DL_BWP_RB * (N_DL_BWP_RB + 1) / 2.0));
}
int srslte_dci_nr_pack(const srslte_carrier_nr_t* carrier,
const srslte_coreset_t* coreset,
const srslte_dci_dl_nr_t* dci,
srslte_dci_msg_nr_t* msg)
{
// Copy DCI MSG fields
msg->location = dci->location;
msg->search_space = dci->search_space.type;
msg->rnti_type = dci->rnti_type;
msg->rnti = dci->rnti;
msg->format = dci->format;
// Pack DCI
switch (msg->format) {
case srslte_dci_format_nr_1_0:
if (srslte_dci_nr_format_1_0_pack(carrier, coreset, dci, msg) < SRSLTE_SUCCESS) {
ERROR("Error packing DL DCI\n");
return SRSLTE_ERROR;
}
break;
default:
ERROR("Unsupported DCI format %d\n", msg->format);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
int srslte_dci_nr_format_1_0_pack(const srslte_carrier_nr_t* carrier,
const srslte_coreset_t* coreset,
const srslte_dci_dl_nr_t* dci,

@ -11,8 +11,12 @@
*/
#include "srslte/phy/phch/pdcch_nr.h"
#include "srslte/phy/common/sequence.h"
#include "srslte/phy/fec/polar/polar_chanalloc.h"
#include "srslte/phy/fec/polar/polar_interleaver.h"
#include "srslte/phy/mimo/precoding.h"
#include "srslte/phy/modem/demod_soft.h"
#include "srslte/phy/utils/bit.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"

@ -9,8 +9,12 @@
* the distribution.
*
*/
#include "srslte/phy/phch/pdsch_nr.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/mimo/layermap.h"
#include "srslte/phy/mimo/precoding.h"
#include "srslte/phy/modem/demod_soft.h"
#include "srslte/phy/phch/ra_nr.h"
int pdsch_nr_init_common(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args)

@ -11,6 +11,9 @@
*/
#include "srslte/phy/phch/pusch_nr.h"
#include "srslte/phy/common/phy_common_nr.h"
#include "srslte/phy/mimo/layermap.h"
#include "srslte/phy/mimo/precoding.h"
#include "srslte/phy/modem/demod_soft.h"
#include "srslte/phy/phch/ra_nr.h"
int pusch_nr_init_common(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args)

@ -0,0 +1,256 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 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 "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/utils/debug.h"
static void sliv_to_s_and_l(uint32_t sliv, uint32_t* S, uint32_t* L)
{
// S values can be 0 to 3
uint32_t low = sliv % 14;
if (low < 7) {
*S = low;
*L = sliv / 14 + 1;
} else {
*S = 14 - 1 - low;
*L = 14 - sliv / 14 + 1;
}
}
// Validate S and L combination for TypeA time domain resource allocation
static bool check_time_ra_typeA(uint32_t* S, uint32_t* L)
{
// Check values using Table 5.1.2.1-1
if (*S > 3) {
ERROR("S (%d) is out-of-range {0,1,2,3}\n", *S);
return false;
}
if (*L < 3 || *L > 14) {
ERROR("L (%d) is out-of-range {3,...,14}\n", *L);
return false;
}
uint32_t sum = *S + *L;
if (sum < 3) {
ERROR("The sum of S (%d) and L (%d) is lower than 3\n", *S, *L);
return false;
}
if (sum > 14) {
ERROR("The sum of S (%d) and L (%d) is greater than 14\n", *S, *L);
return false;
}
return true;
}
static bool check_time_ra_typeB(uint32_t* S, uint32_t* L)
{
ERROR("Not implemented\n");
return false;
}
bool srslte_ra_dl_nr_time_validate(srslte_sch_grant_nr_t* grant)
{
if (grant->mapping == srslte_sch_mapping_type_A) {
return check_time_ra_typeA(&grant->S, &grant->L);
} else {
return check_time_ra_typeB(&grant->S, &grant->L);
}
}
int srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srslte_sch_grant_nr_t* grant)
{
if (grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) {
ERROR("m (%d) is out-of-range\n", m);
return SRSLTE_ERROR_INVALID_INPUTS;
}
// Select k0
grant->k0 = 0;
// Select PDSCH mapping
static srslte_sch_mapping_type_t pdsch_mapping_lut[16] = {srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B};
grant->mapping = pdsch_mapping_lut[m];
static uint32_t S_pos2[SRSLTE_MAX_NOF_DL_ALLOCATION] = {2, 2, 2, 2, 2, 9, 4, 5, 5, 9, 12, 1, 1, 2, 4, 8};
static uint32_t L_pos2[SRSLTE_MAX_NOF_DL_ALLOCATION] = {12, 10, 9, 7, 5, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4};
static uint32_t S_pos3[SRSLTE_MAX_NOF_DL_ALLOCATION] = {3, 3, 3, 3, 3, 10, 6, 5, 5, 9, 12, 1, 1, 2, 4, 8};
static uint32_t L_pos3[SRSLTE_MAX_NOF_DL_ALLOCATION] = {11, 9, 8, 6, 4, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4};
// Select start symbol (S) and length (L)
switch (dmrs_typeA_pos) {
case srslte_dmrs_sch_typeA_pos_2:
grant->S = S_pos2[m];
grant->L = L_pos2[m];
break;
case srslte_dmrs_sch_typeA_pos_3:
grant->S = S_pos3[m];
grant->L = L_pos3[m];
break;
default:
ERROR("Undefined case (%d)\n", dmrs_typeA_pos);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
void srslte_ra_dl_nr_time_hl(const srslte_pdsch_time_ra_t* hl_ra_cfg, srslte_sch_grant_nr_t* grant)
{
// Compute S and L from SLIV from higher layers
sliv_to_s_and_l(hl_ra_cfg->sliv, &grant->S, &grant->L);
grant->k0 = hl_ra_cfg->k0;
grant->mapping = hl_ra_cfg->mapping_type;
}
int srslte_ra_dl_nr_time(const srslte_sch_cfg_nr_t* cfg,
const srslte_rnti_type_t rnti_type,
const srslte_search_space_type_t ss_type,
const uint8_t m,
srslte_sch_grant_nr_t* grant)
{
if (cfg == NULL || grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) {
ERROR("m (%d) is out-of-range\n", m);
return SRSLTE_ERROR_INVALID_INPUTS;
}
// Determine which PDSCH Time domain RA configuration to apply (Table 5.1.2.1.1-1)
if (cfg->pdsch_time_is_default) {
// Note: Only Default A is supported, which corresponds SS/PBCH block and coreset mux pattern 1
srslte_ra_dl_nr_time_default_A(m, cfg->dmrs_typeA.typeA_pos, grant);
} else {
srslte_ra_dl_nr_time_hl(&cfg->pdsch_time_ra[m], grant);
}
// Validate S and L parameters
if (!srslte_ra_dl_nr_time_validate(grant)) {
ERROR("Invalid Time RA\n");
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_sch_cfg_nr_t* pdsch_cfg,
srslte_sch_grant_nr_t* grant)
{
if (pdsch_cfg == NULL || grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
const srslte_dmrs_sch_cfg_t* dmrs_cfg =
grant->mapping == srslte_sch_mapping_type_A ? &pdsch_cfg->dmrs_typeA : &pdsch_cfg->dmrs_typeB;
/* According to TS 38.214 V15.10.0 5.1.6.1.3 CSI-RS for mobility:
* When receiving PDSCH scheduled by DCI format 1_0, the UE shall assume the number of DM-RS CDM groups without data
* is 1 which corresponds to CDM group 0 for the case of PDSCH with allocation duration of 2 symbols, and the UE shall
* assume that the number of DM-RS CDM groups without data is 2 which corresponds to CDM group {0,1} for all other
* cases.
*/
if (dmrs_cfg->length == srslte_dmrs_sch_len_2) {
grant->nof_dmrs_cdm_groups_without_data = 1;
} else {
grant->nof_dmrs_cdm_groups_without_data = 2;
}
return SRSLTE_SUCCESS;
}
/* RBG size for type0 scheduling as in table 5.1.2.2.1-1 of 36.214 */
uint32_t srslte_ra_dl_nr_type0_P(uint32_t bwp_size, bool config_is_1)
{
if (bwp_size <= 36) {
return config_is_1 ? 2 : 4;
} else if (bwp_size <= 72) {
return config_is_1 ? 4 : 8;
} else if (bwp_size <= 144) {
return config_is_1 ? 8 : 16;
} else {
return 16;
}
}
static int ra_freq_type0(const srslte_carrier_nr_t* carrier,
const srslte_sch_cfg_nr_t* cfg,
const srslte_dci_dl_nr_t* dci_dl,
srslte_sch_grant_nr_t* grant)
{
uint32_t P = srslte_ra_dl_nr_type0_P(carrier->nof_prb, cfg->rbg_size_cfg_1);
uint32_t N_rbg = (int)ceilf((float)(carrier->nof_prb + (carrier->start % P)) / P);
uint32_t rbg_offset = 0;
for (uint32_t i = 0; i < N_rbg; i++) {
uint32_t rbg_size = P;
if (i == 0) {
rbg_size -= (carrier->start % P);
} else if ((i == N_rbg - 1) && ((carrier->nof_prb + carrier->start) % P) > 0) {
rbg_size = (carrier->nof_prb + carrier->start) % P;
}
if (dci_dl->freq_domain_assigment & (1 << (N_rbg - i - 1))) {
for (uint32_t j = 0; j < rbg_size; j++) {
if (rbg_offset + j < carrier->nof_prb) {
grant->prb_idx[rbg_offset + j] = true;
grant->nof_prb++;
}
}
}
rbg_offset += rbg_size;
}
return 0;
}
int srslte_ra_dl_nr_freq(const srslte_carrier_nr_t* carrier,
const srslte_sch_cfg_nr_t* cfg,
const srslte_dci_dl_nr_t* dci_dl,
srslte_sch_grant_nr_t* grant)
{
if (cfg == NULL || grant == NULL || dci_dl == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
// RA scheme
if (dci_dl->format == srslte_dci_format_nr_1_0) {
ra_freq_type0(carrier, cfg, dci_dl, grant);
} else {
ERROR("Only DCI Format 1_0 is supported\n");
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}

@ -12,6 +12,7 @@
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/phch/pdsch_nr.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/utils/debug.h"
typedef struct {
@ -453,3 +454,45 @@ int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg,
return SRSLTE_SUCCESS;
}
int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrier,
const srslte_sch_cfg_nr_t* pdsch_cfg,
const srslte_dci_dl_nr_t* dci_dl,
srslte_sch_grant_nr_t* pdsch_grant)
{
// Time domain resource allocation
if (srslte_ra_dl_nr_time(
pdsch_cfg, dci_dl->rnti_type, dci_dl->search_space.type, dci_dl->time_domain_assigment, pdsch_grant) <
SRSLTE_SUCCESS) {
ERROR("Error computing time domain resource allocation\n");
return SRSLTE_ERROR;
}
// Frequency domain resource allocation
if (srslte_ra_dl_nr_freq(carrier, pdsch_cfg, dci_dl, pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error computing time domain resource allocation\n");
return SRSLTE_ERROR;
}
//???
if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(pdsch_cfg, pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups\n");
return SRSLTE_ERROR;
}
pdsch_grant->nof_layers = 1;
pdsch_grant->dci_format = dci_dl->format;
pdsch_grant->rnti = dci_dl->rnti;
for (uint32_t i = 0; i < carrier->nof_prb; i++) {
pdsch_grant->prb_idx[i] = true;
}
// Compute TB size
if (srslte_ra_nr_fill_tb(pdsch_cfg, pdsch_grant, dci_dl->mcs, &pdsch_grant->tb[0]) < SRSLTE_SUCCESS) {
ERROR("Error filing tb\n");
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}

@ -12,6 +12,7 @@
#include "srslte/common/test_common.h"
#include "srslte/phy/phch/pdcch_nr.h"
#include "srslte/phy/utils/random.h"
#include <getopt.h>
static srslte_carrier_nr_t carrier = {

@ -11,12 +11,14 @@
*/
#include "srslte/phy/phch/pdsch_nr.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/random.h"
#include "srslte/phy/utils/vector.h"
#include <complex.h>
#include <getopt.h>
#include <math.h>
static srslte_carrier_nr_t carrier = {
1, // cell_id
@ -151,13 +153,13 @@ int main(int argc, char** argv)
}
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
goto clean_exit;
}
// Load number of DMRS CDM groups without data
if (srslte_ue_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg, &pdsch_grant) < SRSLTE_SUCCESS) {
if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups without data\n");
goto clean_exit;
}

@ -16,6 +16,7 @@
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/random.h"
#include "srslte/phy/utils/vector.h"
#include <complex.h>
#include <getopt.h>
static srslte_carrier_nr_t carrier = {

@ -0,0 +1,101 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 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 "srslte/common/test_common.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/random.h"
#include <getopt.h>
static srslte_carrier_nr_t carrier = {
1, // cell_id
0, // numerology
SRSLTE_MAX_PRB_NR, // nof_prb
0, // start
1 // max_mimo_layers
};
int test_type0_multiple()
{
srslte_sch_cfg_nr_t sch_cfg = {};
srslte_dci_dl_nr_t dci_dl = {};
srslte_sch_grant_nr_t grant = {};
carrier.nof_prb = 32;
carrier.start = 48;
sch_cfg.rbg_size_cfg_1 = false;
dci_dl.format = srslte_dci_format_nr_1_0;
dci_dl.freq_domain_assigment = 0xC0; // RBG 0 and 1
TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS);
TESTASSERT(grant.nof_prb == 8); // P * 2 RBG
for (uint32_t i = 0; i < grant.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == true);
}
for (uint32_t i = grant.nof_prb; i < carrier.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == false);
}
return SRSLTE_SUCCESS;
}
int test_type0_not_multiple()
{
srslte_sch_cfg_nr_t sch_cfg = {};
srslte_dci_dl_nr_t dci_dl = {};
srslte_sch_grant_nr_t grant = {};
carrier.nof_prb = 33;
carrier.start = 49;
sch_cfg.rbg_size_cfg_1 = false;
dci_dl.format = srslte_dci_format_nr_1_0;
dci_dl.freq_domain_assigment = 0x1C0; // RBG 0, 1 and 2
TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS);
TESTASSERT(grant.nof_prb == 11); // P + (P-1) RBG
for (uint32_t i = 0; i < grant.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == true);
}
for (uint32_t i = grant.nof_prb; i < carrier.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == false);
}
bzero(&grant, sizeof(srslte_sch_grant_nr_t));
dci_dl.freq_domain_assigment = 0x3; // RBG 8 and 9
TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS);
TESTASSERT(grant.nof_prb == 6); // P + (P-1) RBG
for (uint32_t i = 0; i < carrier.nof_prb - grant.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == false);
}
for (uint32_t i = carrier.nof_prb - grant.nof_prb; i < carrier.nof_prb; i++) {
TESTASSERT(grant.prb_idx[i] == true);
}
return SRSLTE_SUCCESS;
}
int main(int argc, char** argv)
{
// TESTASSERT(test_type0_multiple() == SRSLTE_SUCCESS);
TESTASSERT(test_type0_not_multiple() == SRSLTE_SUCCESS);
return SRSLTE_SUCCESS;
}

@ -10,9 +10,9 @@
*
*/
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/phch/sch_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
#include <getopt.h>
@ -132,7 +132,7 @@ int main(int argc, char** argv)
}
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
goto clean_exit;
}

@ -305,24 +305,23 @@ int srslte_ue_dl_nr_find_dl_dci(srslte_ue_dl_nr_t* q,
return (int)count;
}
int srslte_ue_dl_nr_pdsch_get(srslte_ue_dl_nr_t* q,
int srslte_ue_dl_nr_decode_pdsch(srslte_ue_dl_nr_t* q,
const srslte_dl_slot_cfg_t* slot,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
srslte_pdsch_res_nr_t* res)
{
if (srslte_dmrs_sch_estimate(&q->dmrs_pdsch, slot, cfg, grant, q->sf_symbols[0], &q->chest) < SRSLTE_SUCCESS) {
if (srslte_dmrs_sch_estimate(&q->dmrs_pdsch, slot, cfg, &cfg->grant, q->sf_symbols[0], &q->chest) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
if (srslte_pdsch_nr_decode(&q->pdsch, cfg, grant, &q->chest, q->sf_symbols, res) < SRSLTE_SUCCESS) {
if (srslte_pdsch_nr_decode(&q->pdsch, cfg, &cfg->grant, &q->chest, q->sf_symbols, res) < SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) {
char str[512];
srslte_ue_dl_nr_pdsch_info(q, cfg, grant, res, str, sizeof(str));
srslte_ue_dl_nr_pdsch_info(q, cfg, res, str, sizeof(str));
INFO("PDSCH: %s\n", str);
}
@ -331,7 +330,6 @@ int srslte_ue_dl_nr_pdsch_get(srslte_ue_dl_nr_t* q,
int srslte_ue_dl_nr_pdsch_info(const srslte_ue_dl_nr_t* q,
const srslte_sch_cfg_nr_t* cfg,
const srslte_sch_grant_nr_t* grant,
const srslte_pdsch_res_nr_t* res,
char* str,
uint32_t str_len)
@ -342,7 +340,7 @@ int srslte_ue_dl_nr_pdsch_info(const srslte_ue_dl_nr_t* q,
// ...
// Append PDSCH info
len += srslte_pdsch_nr_rx_info(&q->pdsch, cfg, grant, res, &str[len], str_len - len);
len += srslte_pdsch_nr_rx_info(&q->pdsch, cfg, &cfg->grant, res, &str[len], str_len - len);
return len;
}

@ -1,157 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 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 "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/phy/utils/debug.h"
static int srslte_ue_dl_nr_pdsch_time_resource_hl_A(uint32_t sliv, uint32_t* S, uint32_t* L)
{
// S values can be 0 to 3
uint32_t low = sliv % 14;
if (low < 7) {
*S = low;
*L = sliv / 14 + 1;
} else {
*S = 14 - 1 - low;
*L = 14 - sliv / 14 + 1;
}
// Check values using Table 5.1.2.1-1
if (*S > 3) {
ERROR("Invalid SLIV %d. S (%d) is out-of-range {0,1,2,3}\n", sliv, *S);
return SRSLTE_ERROR;
}
if (*L < 3 || *L > 14) {
ERROR("Invalid SLIV %d. L (%d) is out-of-range {3,...,14}\n", sliv, *L);
return SRSLTE_ERROR;
}
uint32_t sum = *S + *L;
if (sum < 3) {
ERROR("Invalid SLIV %d. The sum of S (%d) and L (%d) is lower than 3\n", sliv, *S, *L);
return SRSLTE_ERROR;
}
if (sum > 14) {
ERROR("Invalid SLIV %d. The sum of S (%d) and L (%d) is greater than 14\n", sliv, *S, *L);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
static int srslte_ue_dl_nr_pdsch_time_resource_hl_B(uint32_t sliv, uint32_t* S, uint32_t* L)
{
ERROR("Not implemented\n");
return SRSLTE_ERROR;
}
int srslte_ue_dl_nr_pdsch_time_resource_hl(const srslte_pdsch_allocation_t* pdsch_alloc, srslte_sch_grant_nr_t* grant)
{
if (pdsch_alloc == NULL || grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
grant->k0 = pdsch_alloc->k0;
grant->mapping = pdsch_alloc->mapping_type;
if (pdsch_alloc->mapping_type == srslte_sch_mapping_type_A) {
return srslte_ue_dl_nr_pdsch_time_resource_hl_A(pdsch_alloc->sliv, &grant->S, &grant->L);
}
return srslte_ue_dl_nr_pdsch_time_resource_hl_B(pdsch_alloc->sliv, &grant->S, &grant->L);
}
int srslte_ue_dl_nr_pdsch_time_resource_default_A(uint32_t m,
srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos,
srslte_sch_grant_nr_t* grant)
{
if (grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
if (m >= 16) {
ERROR("m (%d) is out-of-range\n", m);
return SRSLTE_ERROR_INVALID_INPUTS;
}
// Select k0
grant->k0 = 0;
// Select PDSCH mapping
static srslte_sch_mapping_type_t pdsch_mapping_lut[16] = {srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_A,
srslte_sch_mapping_type_B,
srslte_sch_mapping_type_B};
grant->mapping = pdsch_mapping_lut[m];
static uint32_t S_pos2[16] = {2, 2, 2, 2, 2, 9, 4, 5, 5, 9, 12, 1, 1, 2, 4, 8};
static uint32_t L_pos2[16] = {12, 10, 9, 7, 5, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4};
static uint32_t S_pos3[16] = {3, 3, 3, 3, 3, 10, 6, 5, 5, 9, 12, 1, 1, 2, 4, 8};
static uint32_t L_pos3[16] = {11, 9, 8, 6, 4, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4};
// Select start symbol (S) and length (L)
switch (dmrs_typeA_pos) {
case srslte_dmrs_sch_typeA_pos_2:
grant->S = S_pos2[m];
grant->L = L_pos2[m];
break;
case srslte_dmrs_sch_typeA_pos_3:
grant->S = S_pos3[m];
grant->L = L_pos3[m];
break;
default:
ERROR("Undefined case (%d)\n", dmrs_typeA_pos);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
}
int srslte_ue_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_sch_cfg_nr_t* pdsch_cfg,
srslte_sch_grant_nr_t* grant)
{
if (pdsch_cfg == NULL || grant == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
const srslte_dmrs_sch_cfg_t* dmrs_cfg =
grant->mapping == srslte_sch_mapping_type_A ? &pdsch_cfg->dmrs_typeA : &pdsch_cfg->dmrs_typeB;
/* According to TS 38.214 V15.10.0 5.1.6.1.3 CSI-RS for mobility:
* When receiving PDSCH scheduled by DCI format 1_0, the UE shall assume the number of DM-RS CDM groups without data
* is 1 which corresponds to CDM group 0 for the case of PDSCH with allocation duration of 2 symbols, and the UE shall
* assume that the number of DM-RS CDM groups without data is 2 which corresponds to CDM group {0,1} for all other
* cases.
*/
if (dmrs_cfg->length == srslte_dmrs_sch_len_2) {
grant->nof_dmrs_cdm_groups_without_data = 1;
} else {
grant->nof_dmrs_cdm_groups_without_data = 2;
}
return SRSLTE_SUCCESS;
}

@ -12,6 +12,8 @@
#include "srslte/upper/gtpu.h"
#include "srslte/common/int_helpers.h"
#include <arpa/inet.h>
#include <netinet/in.h>
namespace srslte {

@ -12,6 +12,7 @@
#include "srslte/asn1/liblte_mme.h"
#include "srslte/common/common.h"
#include "srslte/phy/common/phy_common.h"
#include <fstream>
#include <iostream>

@ -12,6 +12,8 @@
#include "srslte/asn1/s1ap.h"
#include "srslte/common/test_common.h"
#include <arpa/inet.h>
#include <sys/socket.h>
using namespace asn1;
using namespace asn1::s1ap;

@ -10,7 +10,10 @@
*
*/
extern "C" {
#include "srslte/common/timeout.h"
#include "srslte/config.h"
}
#include <pthread.h>
#include <stdio.h>

@ -11,9 +11,9 @@
*/
#include "srslte/phy/enb/enb_dl_nr.h"
#include "srslte/phy/phch/ra_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/ue/ue_dl_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/random.h"
#include "srslte/phy/utils/vector.h"
@ -95,14 +95,22 @@ int work_gnb_dl(srslte_enb_dl_nr_t* enb_dl,
return SRSLTE_ERROR;
}
// Hard-coded values
dci_dl->format = srslte_dci_format_nr_1_0;
dci_dl->rnti_type = srslte_rnti_type_c;
dci_dl->location = *dci_location;
dci_dl->search_space = *search_space;
dci_dl->rnti = rnti;
// Put actual DCI
if (srslte_enb_dl_nr_pdcch_put(enb_dl, slot, search_space, dci_dl, dci_location, rnti) < SRSLTE_SUCCESS) {
if (srslte_enb_dl_nr_pdcch_put(enb_dl, slot, dci_dl) < SRSLTE_SUCCESS) {
ERROR("Error putting PDCCH\n");
return SRSLTE_ERROR;
}
// Put PDSCH transmission
if (srslte_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, &pdsch_grant, data_tx) < SRSLTE_SUCCESS) {
pdsch_cfg.grant = pdsch_grant;
if (srslte_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, data_tx) < SRSLTE_SUCCESS) {
ERROR("Error putting PDSCH\n");
return SRSLTE_ERROR;
}
@ -131,7 +139,8 @@ int work_ue_dl(srslte_ue_dl_nr_t* ue_dl,
return SRSLTE_ERROR;
}
if (srslte_ue_dl_nr_pdsch_get(ue_dl, slot, &pdsch_cfg, &pdsch_grant, pdsch_res) < SRSLTE_SUCCESS) {
pdsch_cfg.grant = pdsch_grant;
if (srslte_ue_dl_nr_decode_pdsch(ue_dl, slot, &pdsch_cfg, pdsch_res) < SRSLTE_SUCCESS) {
ERROR("Error decoding\n");
return SRSLTE_ERROR;
}
@ -254,7 +263,7 @@ int main(int argc, char** argv)
}
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
goto clean_exit;
}

@ -23,6 +23,7 @@
#define SRSENB_NR_CC_WORKER_H
#include "srslte/common/log.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/phy/enb/enb_dl_nr.h"
#include <array>
#include <vector>
@ -69,9 +70,12 @@ public:
cf_t* get_rx_buffer(uint32_t antenna_idx);
uint32_t get_buffer_len();
bool work_dl();
bool work_dl(const srslte_dl_slot_cfg_t& dl_slot_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants);
private:
int encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants);
int encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants);
srslte_dl_slot_cfg_t dl_slot_cfg = {};
uint32_t cc_idx = 0;
std::array<cf_t*, SRSLTE_MAX_PORTS> tx_buffer = {};
@ -80,10 +84,6 @@ private:
phy_nr_state* phy_state;
srslte_enb_dl_nr_t enb_dl = {};
srslte::log* log_h = nullptr;
// Temporal attributes
srslte_softbuffer_tx_t softbuffer_tx = {};
std::vector<uint8_t> data;
};
} // namespace nr

@ -41,7 +41,7 @@ class sf_worker final : public srslte::thread_pool::worker
{
public:
sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* log);
~sf_worker() = default;
~sf_worker();
bool set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_);
@ -60,6 +60,10 @@ private:
phy_common* phy = nullptr;
phy_nr_state* phy_state = nullptr;
srslte::log* log_h = nullptr;
// Temporal attributes
srslte_softbuffer_tx_t softbuffer_tx = {};
std::vector<uint8_t> data;
};
} // namespace nr

@ -17,6 +17,7 @@
#include "srslte/asn1/rrc.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/enb_rrc_interface_types.h"
#include "srslte/phy/common/phy_common.h"
#include <array>
namespace srsenb {

@ -11,6 +11,7 @@
*/
#include "srsenb/hdr/metrics_csv.h"
#include "srslte/phy/utils/vector.h"
#include <float.h>
#include <iomanip>

@ -11,6 +11,7 @@
*/
#include "srsenb/hdr/metrics_stdout.h"
#include "srslte/phy/utils/vector.h"
#include <float.h>
#include <iomanip>

@ -20,10 +20,7 @@
*/
#include "srsenb/hdr/phy/nr/cc_worker.h"
#include "srslte/common/common.h"
#include "srslte/phy/enb/enb_dl_nr.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/srslte.h"
namespace srsenb {
namespace nr {
@ -44,21 +41,11 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslte::log* log, phy_nr_state* phy_state
ERROR("Error initiating UE DL NR\n");
return;
}
if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) <
SRSLTE_SUCCESS) {
ERROR("Error init soft-buffer\n");
return;
}
data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
srslte_vec_u8_zero(data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
snprintf((char*)data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8, "hello world!");
}
cc_worker::~cc_worker()
{
srslte_enb_dl_nr_free(&enb_dl);
srslte_softbuffer_tx_free(&softbuffer_tx);
for (cf_t* p : rx_buffer) {
if (p != nullptr) {
free(p);
@ -74,6 +61,16 @@ cc_worker::~cc_worker()
bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
{
if (srslte_enb_dl_nr_set_carrier(&enb_dl, carrier) < SRSLTE_SUCCESS) {
ERROR("Error setting carrier\n");
return false;
}
srslte_coreset_t coreset = {};
coreset.freq_resources[0] = true; // Enable the bottom 6 PRB for PDCCH
coreset.duration = 2;
if (srslte_enb_dl_nr_set_coreset(&enb_dl, &coreset) < SRSLTE_SUCCESS) {
ERROR("Error setting coreset\n");
return false;
}
@ -108,50 +105,74 @@ uint32_t cc_worker::get_buffer_len()
return tx_buffer.size();
}
bool cc_worker::work_dl()
int cc_worker::encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants)
{
srslte_sch_grant_nr_t pdsch_grant = {};
srslte_sch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
return false;
for (uint32_t i = 0; i < nof_grants; i++) {
// Get PHY config for UE
// ...
// Put actual DCI
if (srslte_enb_dl_nr_pdcch_put(&enb_dl, &dl_slot_cfg, &grants[i].dci) < SRSLTE_SUCCESS) {
ERROR("Error putting PDCCH\n");
return SRSLTE_ERROR;
}
if (srslte_ue_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups\n");
return false;
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
log_h->info("PDCCH: cc=%d, ...\n", cc_idx);
}
}
pdsch_grant.nof_layers = enb_dl.carrier.max_mimo_layers;
pdsch_grant.dci_format = srslte_dci_format_nr_1_0;
pdsch_grant.rnti = 0x1234;
return SRSLTE_SUCCESS;
}
for (uint32_t i = 0; i < enb_dl.carrier.nof_prb; i++) {
pdsch_grant.prb_idx[i] = true;
}
int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants)
{
for (uint32_t i = 0; i < nof_grants; i++) {
if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, 27, &pdsch_grant.tb[0]) < SRSLTE_SUCCESS) {
ERROR("Error filing tb\n");
return false;
// Get PHY config for UE
// ...
srslte_sch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
// Compute DL grant
if (srslte_ra_dl_dci_to_grant_nr(&enb_dl.carrier, &pdsch_cfg, &grants[i].dci, &pdsch_cfg.grant)) {
ERROR("Computing DL grant\n");
}
uint8_t* data2[SRSLTE_MAX_TB] = {data.data(), data.data()};
pdsch_grant.tb[0].softbuffer.tx = &softbuffer_tx;
srslte_softbuffer_tx_reset(pdsch_grant.tb[0].softbuffer.tx);
// Set soft buffer
for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) {
pdsch_cfg.grant.tb[j].softbuffer.tx = grants[i].softbuffer_tx[j];
}
if (srslte_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, &pdsch_grant, data2) < SRSLTE_SUCCESS) {
ERROR("Error decoding PDSCH\n");
if (srslte_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, grants[i].data) < SRSLTE_SUCCESS) {
ERROR("Error putting PDSCH\n");
return false;
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
char str[512];
srslte_enb_dl_nr_pdsch_info(&enb_dl, &pdsch_cfg, &pdsch_grant, str, sizeof(str));
srslte_enb_dl_nr_pdsch_info(&enb_dl, &pdsch_cfg, str, sizeof(str));
log_h->info("PDSCH: cc=%d, %s\n", cc_idx, str);
}
}
return SRSLTE_SUCCESS;
}
bool cc_worker::work_dl(const srslte_dl_slot_cfg_t& dl_sf_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants)
{
// Reset resource grid
if (srslte_enb_dl_nr_base_zero(&enb_dl) < SRSLTE_SUCCESS) {
ERROR("Error setting base to zero\n");
return SRSLTE_ERROR;
}
// Put DL grants to resource grid. PDSCH data will be encoded as well.
encode_pdcch_dl(dl_grants.pdsch, dl_grants.nof_grants);
encode_pdsch(dl_grants.pdsch, dl_grants.nof_grants);
// Generate signal
srslte_enb_dl_nr_gen_signal(&enb_dl);
return true;

@ -30,6 +30,20 @@ sf_worker::sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* lo
cc_worker* w = new cc_worker(i, log, phy_state);
cc_workers.push_back(std::unique_ptr<cc_worker>(w));
}
if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) <
SRSLTE_SUCCESS) {
ERROR("Error init soft-buffer\n");
return;
}
data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
srslte_vec_u8_zero(data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
snprintf((char*)data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8, "hello world!");
}
sf_worker::~sf_worker()
{
srslte_softbuffer_tx_free(&softbuffer_tx);
}
bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_)
@ -83,8 +97,35 @@ void sf_worker::work_imp()
}
}
// Configure user
phy_state->cfg.pdsch.rbg_size_cfg_1 = false;
phy_state->cfg.pdsch.pdsch_time_is_default = true;
// Fill grant (this comes from the scheduler)
srslte_dl_slot_cfg_t dl_cfg = {};
stack_interface_phy_nr::dl_sched_t grants = {};
grants.nof_grants = 1;
grants.pdsch[0].data[0] = data.data();
grants.pdsch[0].softbuffer_tx[0] = &softbuffer_tx;
srslte_softbuffer_tx_reset(&softbuffer_tx);
grants.pdsch[0].dci.rnti = 0x1234;
grants.pdsch[0].dci.format = srslte_dci_format_nr_1_0;
grants.pdsch[0].dci.freq_domain_assigment = 0x1FFF;
grants.pdsch[0].dci.time_domain_assigment = 0;
grants.pdsch[0].dci.mcs = 27;
grants.pdsch[0].dci.search_space.type = srslte_search_space_type_ue;
for (uint32_t L = 0; L < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) {
grants.pdsch[0].dci.search_space.nof_candidates[L] = 1;
}
grants.pdsch[0].dci.location.L = 0;
grants.pdsch[0].dci.location.ncce = 0;
for (auto& w : cc_workers) {
w->work_dl();
w->work_dl(dl_cfg, grants);
}
phy->worker_end(this, tx_buffer, dummy_ts, true);

@ -11,6 +11,7 @@
*/
#include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h"
#include "srslte/phy/utils/vector.h"
using namespace asn1::rrc;

@ -11,6 +11,7 @@
*/
#include "srsepc/hdr/hss/hss.h"
#include "srslte/common/security.h"
#include <arpa/inet.h>
#include <inttypes.h> // for printing uint64_t
#include <iomanip>
#include <sstream>

@ -21,6 +21,7 @@
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/signal_handler.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#include <boost/program_options.hpp>
#include <iostream>
#include <signal.h>

@ -12,6 +12,7 @@
#include "srsepc/hdr/spgw/gtpc.h"
#include <algorithm>
#include <arpa/inet.h>
#include <cstring>
#include <fcntl.h>
#include <inttypes.h> // for printing uint64_t

@ -14,6 +14,7 @@
#include "srsepc/hdr/mme/mme_gtpc.h"
#include "srslte/upper/gtpu.h"
#include <algorithm>
#include <arpa/inet.h>
#include <fcntl.h>
#include <inttypes.h> // for printing uint64_t
#include <linux/if.h>

@ -23,7 +23,7 @@
#define SRSLTE_NR_CC_WORKER_H
#include "srslte/common/log.h"
#include "srslte/phy/ue/ue_dl_nr.h"
#include "srslte/srslte.h"
#include "srsue/hdr/phy/phy_common.h"
#include <array>
#include <vector>
@ -84,6 +84,13 @@ private:
// Temporal attributes
srslte_softbuffer_rx_t softbuffer_rx = {};
std::vector<uint8_t> data;
// Current rnti
uint16_t rnti = 0;
// Current coreset and search space
srslte_coreset_t coreset = {};
srslte_search_space_t search_space = {};
};
} // namespace nr

@ -20,8 +20,7 @@
*/
#include "srsue/hdr/phy/nr/cc_worker.h"
#include "srslte/phy/phch/ra_nr.h"
#include "srslte/phy/ue/ue_dl_nr_data.h"
#include "srslte/srslte.h"
namespace srsue {
namespace nr {
@ -74,7 +73,6 @@ bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
return false;
}
srslte_coreset_t coreset = {};
coreset.freq_resources[0] = true; // Enable the bottom 6 PRB for PDCCH
coreset.duration = 2;
@ -83,6 +81,10 @@ bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
return false;
}
// Set default PDSCH config
phy_state->cfg.pdsch.rbg_size_cfg_1 = false;
phy_state->cfg.pdsch.pdsch_time_is_default = true;
return true;
}
@ -107,41 +109,50 @@ uint32_t cc_worker::get_buffer_len()
bool cc_worker::work_dl()
{
srslte_sch_grant_nr_t pdsch_grant = {};
srslte_dci_dl_nr_t dci_dl = {};
srslte_sch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
std::array<srslte_pdsch_res_nr_t, SRSLTE_MAX_CODEWORDS> pdsch_res = {};
// Use grant default A time resources with m=0
if (srslte_ue_dl_nr_pdsch_time_resource_default_A(0, pdsch_cfg.dmrs_typeA.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading default grant\n");
return false;
}
// Run FFT
srslte_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg);
if (srslte_ue_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg, &pdsch_grant) < SRSLTE_SUCCESS) {
ERROR("Error loading number of DMRS CDM groups\n");
return false;
// Set rnti
rnti = 0x1234;
// Configure Search space
search_space.type = srslte_search_space_type_ue;
for (uint32_t L = 0; L < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) {
search_space.nof_candidates[L] = srslte_pdcch_nr_max_candidates_coreset(&coreset, L);
}
pdsch_grant.nof_layers = ue_dl.carrier.max_mimo_layers;
pdsch_grant.dci_format = srslte_dci_format_nr_1_0;
pdsch_grant.rnti = 0x1234;
srslte_dci_dl_nr_t dci_dl_rx = {};
int nof_found_dci = srslte_ue_dl_nr_find_dl_dci(&ue_dl, &search_space, &dl_slot_cfg, rnti, &dci_dl_rx, 1);
if (nof_found_dci < SRSLTE_SUCCESS) {
ERROR("Error decoding\n");
return SRSLTE_ERROR;
}
for (uint32_t i = 0; i < ue_dl.carrier.nof_prb; i++) {
pdsch_grant.prb_idx[i] = true;
if (nof_found_dci < 1) {
ERROR("Error DCI not found\n");
}
if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, 27, &pdsch_grant.tb[0]) < SRSLTE_SUCCESS) {
ERROR("Error filing tb\n");
return false;
dci_dl.rnti = 0x1234;
dci_dl.format = srslte_dci_format_nr_1_0;
dci_dl.freq_domain_assigment = 0x1FFF;
dci_dl.time_domain_assigment = 0;
dci_dl.mcs = 27;
// Compute DL grant
if (srslte_ra_dl_dci_to_grant_nr(&ue_dl.carrier, &pdsch_cfg, &dci_dl, &pdsch_cfg.grant)) {
ERROR("Computing DL grant\n");
}
pdsch_res[0].payload = data.data();
pdsch_grant.tb[0].softbuffer.rx = &softbuffer_rx;
srslte_softbuffer_rx_reset(pdsch_grant.tb[0].softbuffer.rx);
srslte_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg);
pdsch_cfg.grant.tb[0].softbuffer.rx = &softbuffer_rx;
srslte_softbuffer_rx_reset(pdsch_cfg.grant.tb[0].softbuffer.rx);
if (srslte_ue_dl_nr_pdsch_get(&ue_dl, &dl_slot_cfg, &pdsch_cfg, &pdsch_grant, pdsch_res.data()) < SRSLTE_SUCCESS) {
if (srslte_ue_dl_nr_decode_pdsch(&ue_dl, &dl_slot_cfg, &pdsch_cfg, pdsch_res.data()) < SRSLTE_SUCCESS) {
ERROR("Error decoding PDSCH\n");
return false;
}
@ -149,7 +160,7 @@ bool cc_worker::work_dl()
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
char str[512];
srslte_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, &pdsch_grant, pdsch_res.data(), str, sizeof(str));
srslte_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, pdsch_res.data(), str, sizeof(str));
log_h->info("PDSCH: cc=%d, %s\n", cc_idx, str);
}

@ -237,7 +237,7 @@ bool tft_packet_filter_t::match_ip(const srslte::unique_byte_buffer_t& pdu)
if (filter_contains(IPV6_REMOTE_ADDR_FLAG | IPV6_REMOTE_ADDR_LENGTH_FLAG)) {
bool match = true;
for (int i = 0; i < ipv6_remote_addr_length; i++) {
match &= ((ipv6_remote_addr[i] ^ ip6_pkt->daddr.__in6_u.__u6_addr8[i]) & ipv6_remote_addr_mask[i]) == 0;
match &= ((ipv6_remote_addr[i] ^ ip6_pkt->daddr.in6_u.u6_addr8[i]) & ipv6_remote_addr_mask[i]) == 0;
if (!match) {
return false;
}

Loading…
Cancel
Save