srsLTE/lib/include/srslte/common/common.h

98 lines
2.9 KiB
C
Raw Normal View History

/**
*
* \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.
*
*/
2018-03-31 10:04:04 -07:00
#ifndef SRSLTE_COMMON_H
#define SRSLTE_COMMON_H
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "srslte/adt/span.h"
#include <chrono>
#include <memory>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
/*******************************************************************************
DEFINES
*******************************************************************************/
2019-10-14 09:39:02 -07:00
#define SRSLTE_UE_CATEGORY 4
2019-10-14 09:39:02 -07:00
#define SRSLTE_N_SRB 3
#define SRSLTE_N_DRB 8
2017-06-06 11:34:09 -07:00
#define SRSLTE_N_RADIO_BEARERS 11
2019-10-14 09:39:02 -07:00
#define SRSLTE_N_MCH_LCIDS 32
2020-03-11 08:30:05 -07:00
#define FDD_HARQ_DELAY_DL_MS 4
#define FDD_HARQ_DELAY_UL_MS 4
#define MSG3_DELAY_MS 2 // Delay added to FDD_HARQ_DELAY_DL_MS
2017-09-29 11:38:12 -07:00
2019-04-23 01:53:11 -07:00
#define TTI_SUB(a, b) ((((a) + 10240) - (b)) % 10240)
#define TTI_ADD(a, b) (((a) + (b)) % 10240)
2020-03-11 08:30:05 -07:00
#define TTI_TX(tti) TTI_ADD(tti, FDD_HARQ_DELAY_DL_MS)
2019-04-23 01:53:11 -07:00
2020-03-11 08:30:05 -07:00
#define TTI_RX(tti) (TTI_SUB(tti, FDD_HARQ_DELAY_UL_MS))
#define TTI_RX_ACK(tti) (TTI_ADD(tti, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS))
2019-04-23 01:53:11 -07:00
#define TTIMOD_SZ 20
2019-10-14 09:39:02 -07:00
#define TTIMOD(tti) (tti % TTIMOD_SZ)
2020-07-06 06:09:58 -07:00
#define INVALID_TTI 10241
#define TX_ENB_DELAY FDD_HARQ_DELAY_UL_MS
2020-07-06 06:09:58 -07:00
2019-04-23 01:53:11 -07:00
#define PHICH_MAX_SF 6 // Maximum PHICH in a subframe (1 in FDD, > 1 in TDD, see table 9.1.2-1 36.213)
2020-03-11 08:30:05 -07:00
#define ASYNC_DL_SCHED (FDD_HARQ_DELAY_UL_MS <= 4)
// Cat 4 UE - Max number of DL-SCH transport block bits received within a TTI
// 3GPP 36.306 v15.4.0 Table 4.1.1 for Category 11 with 2 layers and 256QAM
#define SRSLTE_MAX_TBSIZE_BITS 97896
2019-10-14 09:39:02 -07:00
#define SRSLTE_BUFFER_HEADER_OFFSET 1020
2019-07-15 09:03:28 -07:00
#define SRSLTE_MAX_BUFFER_SIZE_BITS (SRSLTE_MAX_TBSIZE_BITS + SRSLTE_BUFFER_HEADER_OFFSET)
#define SRSLTE_MAX_BUFFER_SIZE_BYTES (SRSLTE_MAX_TBSIZE_BITS / 8 + SRSLTE_BUFFER_HEADER_OFFSET)
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
namespace srslte {
#define ENABLE_TIMESTAMP
2018-03-06 03:37:08 -08:00
// helper functions
inline const char* enum_to_text(const char* const array[], uint32_t nof_types, uint32_t enum_val)
{
return enum_val >= nof_types ? "" : array[enum_val];
}
template <class ItemType>
ItemType enum_to_number(ItemType* array, uint32_t nof_types, uint32_t enum_val)
{
return enum_val >= nof_types ? -1 : array[enum_val];
}
enum class srslte_rat_t { lte, nr, nulltype };
inline std::string to_string(const srslte_rat_t& type)
{
constexpr static const char* options[] = {"LTE", "NR"};
return enum_to_text(options, (uint32_t)srslte_rat_t::nulltype, (uint32_t)type);
}
2018-03-31 10:04:04 -07:00
} // namespace srslte
2018-03-31 10:04:04 -07:00
#endif // SRSLTE_COMMON_H