added nr gnb and ue interfaces

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent d36ae722d5
commit b4b5cd7cd6

@ -32,6 +32,10 @@
* Forward declarations
***********************/
namespace asn1 {
template <uint32_t N, bool aligned>
class fixed_octstring;
namespace rrc {
struct plmn_id_s;
@ -81,6 +85,8 @@ namespace srslte {
plmn_id_t make_plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type);
void to_asn1(asn1::rrc::plmn_id_s* asn1_type, const plmn_id_t& cfg);
plmn_id_t make_plmn_id_t(const asn1::fixed_octstring<3, true>& asn1_type);
void to_asn1(asn1::fixed_octstring<3, true>* asn1_type, const plmn_id_t& cfg);
s_tmsi_t make_s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type);
void to_asn1(asn1::rrc::s_tmsi_s* asn1_type, const s_tmsi_t& cfg);

@ -90,6 +90,9 @@ public:
virtual void notify_background_task_result(srslte::move_task_t task) = 0;
};
class stack_interface_phy_nr
{};
} // namespace srslte
#endif // SRSLTE_INTERFACES_COMMON_H

@ -64,8 +64,6 @@ public:
void info_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
void debug_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
srslte::LOG_LEVEL_ENUM get_level(std::string l);
class time_itf
{
public:

@ -0,0 +1,225 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_GNB_INTERFACES_H
#define SRSLTE_GNB_INTERFACES_H
#include "srslte/common/interfaces_common.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/pdcp_interface_types.h"
#include "srslte/interfaces/rlc_interface_types.h"
#include "srslte/interfaces/rrc_interface_types.h"
#include "srslte/interfaces/sched_interface.h"
namespace srsenb {
/*****************************
* MAC INTERFACES
****************************/
class mac_interface_rrc_nr
{
public:
// Provides cell configuration including SIB periodicity, etc.
virtual int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) = 0;
};
class mac_interface_rlc_nr
{
public:
virtual int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) = 0;
};
/*****************************
* RLC INTERFACES
****************************/
class rlc_interface_mac_nr
{
public:
/* MAC calls RLC to get RLC segment of nof_bytes length.
* Segmentation happens in this function. RLC PDU is stored in payload. */
virtual int read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0;
virtual void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size) = 0;
/* MAC calls RLC to push an RLC PDU. This function is called from an independent MAC thread.
* PDU gets placed into the buffer and higher layer thread gets notified. */
virtual void write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0;
};
class rlc_interface_pdcp_nr
{
public:
/* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls
* RLC PDUs according to TB size. */
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual bool rb_is_um(uint16_t rnti, uint32_t lcid) = 0;
};
class rlc_interface_rrc_nr
{
public:
virtual void clear_buffer(uint16_t rnti) = 0;
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) = 0;
virtual void add_bearer_mrb(uint16_t rnti, uint32_t lcid) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
};
/* PDCP Interfaces */
class pdcp_interface_rlc_nr
{
public:
/* RLC calls PDCP to push a PDCP PDU. */
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
};
class pdcp_interface_rrc_nr
{
public:
virtual void reset(uint16_t rnti) = 0;
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0;
virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
};
class pdcp_interface_sdap_nr
{
public:
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
};
class s1ap_interface_rrc_nr
{};
class gtpu_interface_sdap_nr
{
public:
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
};
/*****************************
* SDAP INTERFACES
****************************/
class sdap_interface_pdcp_nr
{
public:
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
};
class sdap_interface_gtpu_nr
{
public:
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
};
/*****************************
* GTPU INTERFACES
****************************/
class gtpu_interface_rrc_nr
{
public:
};
/*****************************
* RRC INTERFACES
****************************/
class rrc_interface_phy_nr
{};
class rrc_interface_mac_nr
{
public:
// Provides MIB packed message
virtual int read_pdu_bcch_bch(const uint32_t tti, srslte::unique_byte_buffer_t& buffer) = 0;
virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srslte::unique_byte_buffer_t& buffer) = 0;
};
class rrc_interface_rlc_nr
{
public:
virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0;
virtual void max_retx_attempted(uint16_t rnti) = 0;
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
};
class rrc_interface_pdcp_nr
{
public:
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0;
};
class rrc_interface_ngap_nr
{
public:
};
/*****************************
* NGAP INTERFACES
****************************/
class ngap_interface_rrc_nr
{
public:
};
class phy_interface_stack_nr
{
public:
const static int MAX_DL_GRANTS = 4;
typedef struct {
// FIXME: not including NR related fields yet
} dl_sched_grant_t;
typedef struct {
bool mib_present;
} bch_sched_t;
typedef struct {
uint32_t tti;
uint32_t nof_grants;
dl_sched_grant_t pdsch[MAX_DL_GRANTS];
int beam_id;
} dl_config_request_t;
typedef struct {
bch_sched_t pbch;
uint16_t length;
uint16_t index; // index indicated in dl_config
uint8_t* data[SRSLTE_MAX_TB]; // always a pointer in our case
} tx_request_pdu_t;
typedef struct {
uint32_t tti;
uint32_t tb_len;
uint32_t nof_pdus;
tx_request_pdu_t pdus[MAX_DL_GRANTS];
} tx_request_t;
virtual int dl_config_request(const dl_config_request_t& request) = 0;
virtual int tx_request(const tx_request_t& request) = 0;
};
class stack_interface_phy_nr : public srslte::stack_interface_phy_nr
{
public:
virtual int sf_indication(const uint32_t tti) = 0;
};
class mac_interface_phy_nr
{};
} // namespace srsenb
#endif // SRSLTE_GNB_INTERFACES_H

@ -138,6 +138,10 @@ public:
// bool do_rohc;
};
// Specifies in which direction security (integrity and ciphering) are enabled for PDCP
enum srslte_direction_t { DIRECTION_NONE = 0, DIRECTION_TX, DIRECTION_RX, DIRECTION_TXRX, DIRECTION_N_ITEMS };
static const char* srslte_direction_text[DIRECTION_N_ITEMS] = {"none", "tx", "rx", "tx/rx"};
} // namespace srslte
#endif // SRSLTE_PDCP_INTERFACE_TYPES_H

@ -104,6 +104,12 @@ struct plmn_id_t {
}
return from_number(mcc_num, mnc_num);
}
int to_number(uint16_t* mcc_num, uint16_t* mnc_num) const
{
srslte::bytes_to_mcc(&mcc[0], mcc_num);
srslte::bytes_to_mnc(&mnc[0], mnc_num, nof_mnc_digits);
return SRSLTE_SUCCESS;
}
std::string to_string() const
{
std::string mcc_str, mnc_str;

@ -163,10 +163,10 @@ public:
const static int MAX_FOUND_PLMNS = 16;
virtual ~rrc_interface_nas() = default;
virtual void write_sdu(srslte::unique_byte_buffer_t sdu) = 0;
virtual uint16_t get_mcc() = 0;
virtual uint16_t get_mnc() = 0;
virtual void enable_capabilities() = 0;
virtual void write_sdu(srslte::unique_byte_buffer_t sdu) = 0;
virtual uint16_t get_mcc() = 0;
virtual uint16_t get_mnc() = 0;
virtual void enable_capabilities() = 0;
virtual bool plmn_search() = 0;
virtual void plmn_select(srslte::plmn_id_t plmn_id) = 0;
virtual bool connection_request(srslte::establishment_cause_t cause,

@ -0,0 +1,96 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_UE_NR_INTERFACES_H
#define SRSLTE_UE_NR_INTERFACES_H
#include <string>
#include "srslte/common/interfaces_common.h"
namespace srsue {
class rrc_interface_phy_nr
{
public:
virtual void in_sync() = 0;
virtual void out_of_sync() = 0;
virtual void run_tti(const uint32_t tti) = 0;
};
class mac_interface_phy_nr
{
public:
typedef struct {
srslte::unique_byte_buffer_t tb[SRSLTE_MAX_TB];
uint32_t pid;
uint16_t rnti;
uint32_t tti;
} mac_nr_grant_dl_t;
typedef struct {
uint32_t pid;
uint16_t rnti;
uint32_t tti;
uint32_t tbs;
} mac_nr_grant_ul_t;
virtual int sf_indication(const uint32_t tti) = 0; ///< FIXME: rename to slot indication
/// Indicate succussfully received TB to MAC. The TB buffer is allocated in the PHY and handed as unique_ptr to MAC
virtual void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) = 0;
/// Indicate reception of UL grant (only TBS is provided). Buffer for resulting MAC PDU is provided by MAC and is
/// passed as pointer to PHY during tx_reuqest
virtual void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant) = 0;
};
class mac_interface_rrc_nr
{};
class phy_interface_mac_nr
{
public:
typedef struct {
uint32_t tti;
uint32_t tb_len;
uint8_t* data; // always a pointer in our case
} tx_request_t;
virtual int tx_request(const tx_request_t& request) = 0;
};
class phy_interface_rrc_nr
{};
// Combined interface for PHY to access stack (MAC and RRC)
class stack_interface_phy_nr : public mac_interface_phy_nr,
public rrc_interface_phy_nr,
public srslte::stack_interface_phy_nr
{};
// Combined interface for stack (MAC and RRC) to access PHY
class phy_interface_stack_nr : public phy_interface_mac_nr, public phy_interface_rrc_nr
{};
} // namespace srsue
#endif // SRSLTE_UE_NR_INTERFACES_H

@ -52,10 +52,6 @@ typedef enum {
} pdcp_d_c_t;
static const char pdcp_d_c_text[PDCP_D_C_N_ITEMS][20] = {"Control PDU", "Data PDU"};
// Specifies in which direction security (integrity and ciphering) are enabled for PDCP
typedef enum { DIRECTION_NONE = 0, DIRECTION_TX, DIRECTION_RX, DIRECTION_TXRX, DIRECTION_N_ITEMS } srslte_direction_t;
static const char srslte_direction_text[DIRECTION_N_ITEMS][6] = {"none", "tx", "rx", "tx/rx"};
/****************************************************************************
* PDCP Entity interface
* Common interface for LTE and NR PDCP entities
@ -64,6 +60,7 @@ class pdcp_entity_base
{
public:
pdcp_entity_base(srslte::task_handler_interface* task_executor_, srslte::log_ref log_);
pdcp_entity_base(pdcp_entity_base&&) = default;
virtual ~pdcp_entity_base();
virtual void reset() = 0;
virtual void reestablish() = 0;

@ -59,6 +59,27 @@ void to_asn1(asn1::rrc::plmn_id_s* asn1_type, const plmn_id_t& cfg)
std::copy(&cfg.mnc[0], &cfg.mnc[cfg.nof_mnc_digits], &asn1_type->mnc[0]);
}
plmn_id_t make_plmn_id_t(const asn1::fixed_octstring<3, true>& asn1_type) // used for NGAP/S1AP
{
plmn_id_t plmn;
uint16_t mcc, mnc;
uint32_t encoded_plmn = asn1_type.to_number();
// uint32_t encoded_plmn = (asn1_type[0] << 16u) + (asn1_type[1] << 8u) + (asn1_type[2] << 0u);
s1ap_plmn_to_mccmnc(encoded_plmn, &mcc, &mnc);
plmn.from_number(mcc, mnc);
return plmn;
}
void to_asn1(asn1::fixed_octstring<3, true>* asn1_type, const plmn_id_t& cfg)
{
uint16_t mcc, mnc;
cfg.to_number(&mcc, &mnc);
uint32_t encoded_plmn;
s1ap_mccmnc_to_plmn(mcc, mnc, &encoded_plmn);
// uint32_t tmp32 = htonl(encoded_plmn);
asn1_type->from_number(encoded_plmn);
}
/***************************
* s-TMSI
**************************/

@ -71,7 +71,7 @@ int main(int argc, char** argv)
uint8_t* rrc_msg = NULL;
int verbose = 0;
char* file = NULL;
int type = -1;
int type = -1;
if (argc < 2) {
printf("Please only call me with one parameter\n");

@ -24,6 +24,7 @@
#include "srslte/asn1/rrc_asn1_utils.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/interfaces/rrc_interface_types.h"
#include <arpa/inet.h> //for inet_ntop()
#include <iostream>
using namespace asn1::rrc;
@ -92,9 +93,11 @@ int rrc_plmn_test()
int s1ap_plmn_test()
{
uint16_t mcc = 0xF123;
uint16_t mnc = 0xFF45;
uint32_t plmn;
uint16_t mcc = 0xF123;
uint16_t mnc = 0xFF45;
uint32_t plmn;
srslte::plmn_id_t srslte_plmn, srslte_plmn2;
asn1::fixed_octstring<3, true> s1ap_plmn{};
// 2-digit MNC test
srslte::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn);
@ -103,13 +106,34 @@ int s1ap_plmn_test()
TESTASSERT(mcc == 0xF123);
TESTASSERT(mnc == 0xFF45);
// Test MCC/MNC --> S1AP
srslte_plmn.from_number(mcc, mnc);
TESTASSERT(srslte_plmn.to_string() == "12345");
srslte::to_asn1(&s1ap_plmn, srslte_plmn);
TESTASSERT(s1ap_plmn[0] == ((uint8_t*)&plmn)[2]);
TESTASSERT(s1ap_plmn[1] == ((uint8_t*)&plmn)[1]);
TESTASSERT(s1ap_plmn[2] == ((uint8_t*)&plmn)[0]);
srslte_plmn2 = srslte::make_plmn_id_t(s1ap_plmn);
TESTASSERT(srslte_plmn2 == srslte_plmn);
// 3-digit MNC test
mnc = 0xF456;
srslte::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn);
TESTASSERT(plmn == 0x216354);
TESTASSERT(plmn == 0x214365);
srslte::s1ap_plmn_to_mccmnc(plmn, &mcc, &mnc);
TESTASSERT(mcc == 0xF123);
TESTASSERT(mnc == 0xF456);
// Test MCC/MNC --> S1AP
srslte_plmn.from_number(mcc, mnc);
TESTASSERT(srslte_plmn.to_string() == "123456");
srslte::to_asn1(&s1ap_plmn, srslte_plmn);
TESTASSERT(s1ap_plmn[0] == ((uint8_t*)&plmn)[2]);
TESTASSERT(s1ap_plmn[1] == ((uint8_t*)&plmn)[1]);
TESTASSERT(s1ap_plmn[2] == ((uint8_t*)&plmn)[0]);
srslte_plmn2 = srslte::make_plmn_id_t(s1ap_plmn);
TESTASSERT(srslte_plmn2 == srslte_plmn);
return 0;
}

Loading…
Cancel
Save