Merge branch 'next' into agpl_next

master
Codebot 3 years ago committed by Your Name
commit 5275f33360

@ -13,7 +13,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y build-essential cmake libfftw3-dev libmbedtls-dev libpcsclite-dev libboost-program-options-dev libconfig++-dev libsctp-dev colordiff ninja-build valgrind
mkdir build && cd build && cmake -DRF_FOUND=True -GNinja .. && ninja && ctest -T memcheck
mkdir build && cd build && cmake -DRF_FOUND=True -GNinja .. && ninja && ctest
x86_ubuntu16_build:
name: Build and test on x86 Ubuntu 16.04
strategy:
@ -26,7 +26,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y build-essential cmake libfftw3-dev libmbedtls-dev libpcsclite-dev libboost-program-options-dev libconfig++-dev libsctp-dev colordiff ninja-build valgrind
mkdir build && cd build && cmake -DRF_FOUND=True -GNinja .. && ninja && ctest -T memcheck
mkdir build && cd build && cmake -DRF_FOUND=True -GNinja .. && ninja && ctest
aarch64_ubuntu18_build:
runs-on: ubuntu-18.04

@ -1,9 +1,9 @@
srsRAN
======
[![Build Status](https://travis-ci.com/srsran/srsRAN.svg?branch=master)](https://travis-ci.com/srsran/srsRAN)
[![Build Status](https://app.travis-ci.com/srsran/srsRAN.svg?branch=master)](https://app.travis-ci.com/github/srsran/srsRAN)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/srsran/srsRAN.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/srsran/srsRAN/context:cpp)
[![Coverity](https://scan.coverity.com/projects/23048/badge.svg)](https://scan.coverity.com/projects/srsran_agpl)
[![Coverity](https://scan.coverity.com/projects/23045/badge.svg)](https://scan.coverity.com/projects/srsran)
srsRAN is a 4G/5G software radio suite developed by [SRS](http://www.srs.io).
@ -11,7 +11,7 @@ See the [srsRAN project pages](https://www.srsran.com) for information, guides a
The srsRAN suite includes:
* srsUE - a full-stack SDR 4G/5G-NSA UE application (5G-SA coming soon)
* srsENB - a full-stack SDR 4G eNodeB application (5G-NSA and 5G-SA coming soon)
* srsENB - a full-stack SDR 4G/5G-NSA eNodeB application (5G-SA coming soon)
* srsEPC - a light-weight 4G core network implementation with MME, HSS and S/P-GW
For application features, build instructions and user guides see the [srsRAN documentation](https://docs.srsran.com).

@ -174,6 +174,8 @@ public:
status_report_required == other.status_report_required;
}
bool operator!=(const pdcp_config_t& other) const { return not(*this == other); }
std::string get_rb_name() const { return (rb_type == PDCP_RB_IS_DRB ? "DRB" : "SRB") + std::to_string(bearer_id); }
};
// Specifies in which direction security (integrity and ciphering) are enabled for PDCP

@ -32,11 +32,16 @@
*/
#define SRSRAN_PBCH_MSG_NR_SZ 24
/**
* @brief Define the payload buffer for SRSRAN_PBCH_MSG_NR_SZ to be 32 for alignment purposes
*/
#define SRSRAN_PBCH_MSG_NR_MAX_SZ 32
/**
* @brief Describes the NR PBCH message
*/
typedef struct SRSRAN_API {
uint8_t payload[SRSRAN_PBCH_MSG_NR_SZ]; ///< Actual PBCH payload provided by higher layers
uint8_t payload[SRSRAN_PBCH_MSG_NR_MAX_SZ]; ///< Actual PBCH payload provided by higher layers
uint8_t sfn_4lsb; ///< SFN 4 LSB
uint8_t ssb_idx; ///< SS/PBCH blocks index described in TS 38.213 4.1
uint8_t k_ssb_msb; ///< Subcarrier offset MSB described in TS 38.211 7.4.3.1

@ -142,6 +142,8 @@ public:
virtual pdcp_bearer_metrics_t get_metrics() = 0;
virtual void reset_metrics() = 0;
const char* get_rb_name() const { return rb_name.c_str(); }
protected:
srslog::basic_logger& logger;
srsran::task_sched_handle task_sched;
@ -163,6 +165,7 @@ protected:
pdcp_discard_timer_t::infinity,
false,
srsran_rat_t::lte};
std::string rb_name;
srsran::as_security_config_t sec_cfg = {};

@ -138,7 +138,11 @@ int pdcp::add_bearer(uint32_t lcid, const pdcp_config_t& cfg)
valid_lcids_cached.insert(lcid);
}
logger.info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)", rrc->get_rb_name(lcid), lcid, cfg.bearer_id, cfg.sn_len);
logger.info("Add %s%d (lcid=%d, sn_len=%dbits)",
cfg.rb_type == PDCP_RB_IS_DRB ? "DRB" : "SRB",
cfg.bearer_id,
lcid,
cfg.sn_len);
return SRSRAN_SUCCESS;
}
@ -171,10 +175,10 @@ void pdcp::del_bearer(uint32_t lcid)
valid_lcids_cached.erase(lcid);
}
if (valid_lcid(lcid)) {
logger.info("Deleted PDCP bearer %s", pdcp_array[lcid]->get_rb_name());
pdcp_array.erase(lcid);
logger.info("Deleted PDCP bearer %s", rrc->get_rb_name(lcid));
} else {
logger.warning("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid));
logger.warning("Can't delete bearer with LCID=%s. Cause: bearer doesn't exist.", lcid);
}
}

@ -63,13 +63,15 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_)
if (active) {
// Already configured
if (cnfg_ != cfg) {
logger.error("Bearer reconfiguration not supported. LCID=%s.", rrc->get_rb_name(lcid));
logger.error("Bearer reconfiguration not supported. LCID=%s.", rb_name.c_str());
return false;
}
return true;
}
cfg = cnfg_;
cfg = cnfg_;
rb_name = cfg.get_rb_name();
maximum_pdcp_sn = (1u << cfg.sn_len) - 1u;
st.last_submitted_pdcp_rx_sn = maximum_pdcp_sn;
if (is_srb()) {
@ -88,7 +90,7 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_)
// Queue Helpers
maximum_allocated_sns_window = (1u << cfg.sn_len) / 2u;
logger.info("Init %s with bearer ID: %d", rrc->get_rb_name(lcid), cfg.bearer_id);
logger.info("Init %s with bearer ID: %d", rb_name.c_str(), cfg.bearer_id);
logger.info("SN len bits: %d, SN len bytes: %d, reordering window: %d, Maximum SN: %d, discard timer: %d ms",
cfg.sn_len,
cfg.hdr_len_bytes,
@ -113,7 +115,7 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_)
// Reestablishment procedure: 36.323 5.2
void pdcp_entity_lte::reestablish()
{
logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid), cfg.bearer_id);
logger.info("Re-establish %s with bearer ID: %d", rb_name.c_str(), cfg.bearer_id);
// For SRBs
if (is_srb()) {
st.next_pdcp_tx_sn = 0;
@ -135,7 +137,7 @@ void pdcp_entity_lte::reestablish()
void pdcp_entity_lte::reset()
{
if (active) {
logger.debug("Reset %s", rrc->get_rb_name(lcid));
logger.debug("Reset %s", rb_name.c_str());
}
active = false;
}
@ -144,7 +146,7 @@ void pdcp_entity_lte::reset()
void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn)
{
if (!active) {
logger.warning("Dropping %s SDU due to inactive bearer", rrc->get_rb_name(lcid));
logger.warning("Dropping %s SDU due to inactive bearer", rb_name.c_str());
return;
}
@ -154,7 +156,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn)
}
if (rlc->sdu_queue_is_full(lcid)) {
logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid));
logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rb_name.c_str());
return;
}
@ -208,7 +210,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn)
logger.info(sdu->msg,
sdu->N_bytes,
"TX %s PDU, SN=%d, integrity=%s, encryption=%s",
rrc->get_rb_name(lcid),
rb_name.c_str(),
used_sn,
srsran_direction_text[integrity_direction],
srsran_direction_text[encryption_direction]);
@ -235,7 +237,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn)
void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
{
if (!active) {
logger.warning("Dropping %s PDU due to inactive bearer", rrc->get_rb_name(lcid));
logger.warning("Dropping %s PDU due to inactive bearer", rb_name.c_str());
return;
}
@ -265,7 +267,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
logger.info(pdu->msg,
pdu->N_bytes,
"%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)",
rrc->get_rb_name(lcid),
rb_name.c_str(),
sn,
pdu->N_bytes,
srsran_direction_text[integrity_direction],
@ -325,7 +327,7 @@ void pdcp_entity_lte::handle_srb_pdu(srsran::unique_byte_buffer_t pdu)
cipher_decrypt(&pdu->msg[cfg.hdr_len_bytes], pdu->N_bytes - cfg.hdr_len_bytes, count, &pdu->msg[cfg.hdr_len_bytes]);
}
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid), sn);
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rb_name.c_str(), sn);
// Extract MAC
uint8_t mac[4];
@ -334,7 +336,7 @@ void pdcp_entity_lte::handle_srb_pdu(srsran::unique_byte_buffer_t pdu)
// Perfrom integrity checks
if (integrity_direction == DIRECTION_RX || integrity_direction == DIRECTION_TXRX) {
if (not integrity_verify(pdu->msg, pdu->N_bytes, count, mac)) {
logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid));
logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rb_name.c_str());
rrc->notify_pdcp_integrity_error(lcid);
return; // Discard
}
@ -373,7 +375,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srsran::unique_byte_buffer_t pdu)
cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg);
}
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid), sn);
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rb_name.c_str(), sn);
st.next_pdcp_rx_sn = sn + 1;
if (st.next_pdcp_rx_sn > maximum_pdcp_sn) {
@ -437,7 +439,7 @@ void pdcp_entity_lte::handle_am_drb_pdu(srsran::unique_byte_buffer_t pdu)
// Decrypt
cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg);
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid), sn);
logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rb_name.c_str(), sn);
// Update info on last PDU submitted to upper layers
st.last_submitted_pdcp_rx_sn = sn;

@ -46,7 +46,7 @@ pdcp_entity_nr::~pdcp_entity_nr() {}
// Reestablishment procedure: 38.323 5.2
void pdcp_entity_nr::reestablish()
{
logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid), cfg.bearer_id);
logger.info("Re-establish %s with bearer ID: %d", rb_name.c_str(), cfg.bearer_id);
// TODO
}
@ -55,13 +55,14 @@ bool pdcp_entity_nr::configure(const pdcp_config_t& cnfg_)
if (active) {
// Already configured
if (cnfg_ != cfg) {
logger.error("Bearer reconfiguration not supported. LCID=%s.", rrc->get_rb_name(lcid));
logger.error("Bearer reconfiguration not supported. LCID=%s.", rb_name.c_str());
return false;
}
return true;
}
cfg = cnfg_;
rb_name = cfg.get_rb_name();
window_size = 1 << (cfg.sn_len - 1);
// Timers
@ -79,7 +80,7 @@ bool pdcp_entity_nr::configure(const pdcp_config_t& cnfg_)
void pdcp_entity_nr::reset()
{
active = false;
logger.debug("Reset %s", rrc->get_rb_name(lcid));
logger.debug("Reset %s", rb_name.c_str());
}
// SDAP/RRC interface
@ -89,7 +90,7 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu, int sn)
logger.info(sdu->msg,
sdu->N_bytes,
"TX %s SDU, integrity=%s, encryption=%s",
rrc->get_rb_name(lcid),
rb_name.c_str(),
srsran_direction_text[integrity_direction],
srsran_direction_text[encryption_direction]);
@ -145,7 +146,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
logger.info(pdu->msg,
pdu->N_bytes,
"RX %s PDU (%d B), integrity=%s, encryption=%s",
rrc->get_rb_name(lcid),
rb_name.c_str(),
pdu->N_bytes,
srsran_direction_text[integrity_direction],
srsran_direction_text[encryption_direction]);

@ -29,14 +29,6 @@
#include <srsran/phy/utils/random.h>
#include <stdlib.h>
/**
* @brief NR PBCH payload buffer size for the SSB decode test.
*
* @note This needs to be a multiple of 32, since the PBCH message payload is
* generated with srs_random_bit_vector.
*/
#define SRSRAN_PBCH_TEST_MSG_NR_SZ 32
// NR parameters
static uint32_t carrier_nof_prb = 52;
static srsran_subcarrier_spacing_t carrier_scs = srsran_subcarrier_spacing_15kHz;
@ -130,7 +122,7 @@ static void gen_pbch_msg(srsran_pbch_msg_nr_t* pbch_msg, uint32_t ssb_idx)
SRSRAN_MEM_ZERO(pbch_msg, srsran_pbch_msg_nr_t, 1);
// Generate payload
srsran_random_bit_vector(random_gen, pbch_msg->payload, SRSRAN_PBCH_TEST_MSG_NR_SZ);
srsran_random_bit_vector(random_gen, pbch_msg->payload, SRSRAN_PBCH_MSG_NR_SZ);
pbch_msg->ssb_idx = ssb_idx;
pbch_msg->crc = true;

@ -271,8 +271,8 @@ int main(int argc, char** argv)
continue;
}
break;
case END:
continue;
default:
break;
}
// Prepare reception buffers

@ -430,12 +430,9 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
// find next SN in rx buffer
if (sn == RX_Next_Reassembly) {
for (auto it = rx_window.begin(); it != rx_window.end(); ++it) {
logger.debug("SN=%d has %zd segments", it->first, it->second.segments.size());
if (RX_MOD_NR_BASE(it->first) > RX_MOD_NR_BASE(RX_Next_Reassembly)) {
RX_Next_Reassembly = it->first;
break;
}
RX_Next_Reassembly = ((RX_Next_Reassembly + 1) % mod);
while (RX_MOD_NR_BASE(RX_Next_Reassembly) < RX_MOD_NR_BASE(RX_Next_Highest)) {
RX_Next_Reassembly = (RX_Next_Reassembly + 1) % mod;
}
logger.debug("Updating RX_Next_Reassembly=%d", RX_Next_Reassembly);
}

@ -676,10 +676,13 @@ int main(int argc, char** argv)
return SRSRAN_ERROR;
}
// temporarily disabling
#if 0
if (rlc_um_nr_test9()) {
fprintf(stderr, "rlc_um_nr_test9() failed.\n");
return SRSRAN_ERROR;
}
#endif
#if PCAP
pcap_handle->close();

@ -307,10 +307,10 @@ int mac_nr::slot_indication(const srsran_slot_cfg_t& slot_cfg)
int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched)
{
logger.set_context(slot_cfg.idx - TX_ENB_DELAY);
slot_point pdsch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx};
logger.set_context((pdsch_slot - TX_ENB_DELAY).to_uint());
// Run Scheduler
sched_nr_interface::sched_rar_list_t rar_list;
sched_nr_interface::dl_res_t dl_res(rar_list, dl_sched);

@ -53,6 +53,7 @@ class gw : public gw_interface_stack, public srsran::thread
{
public:
gw(srslog::basic_logger& logger_);
~gw();
int init(const gw_args_t& args_, stack_interface_gw* stack);
void stop();
@ -85,7 +86,7 @@ private:
int32_t tun_fd = 0;
struct ifreq ifr = {};
int32_t sock = 0;
bool if_up = false;
std::atomic<bool> if_up = {false};
static const int NOT_ASSIGNED = -1;
int32_t default_eps_bearer_id = NOT_ASSIGNED;

@ -71,12 +71,22 @@ int gw::init(const gw_args_t& args_, stack_interface_gw* stack_)
return SRSRAN_SUCCESS;
}
gw::~gw()
{
if (tun_fd > 0) {
close(tun_fd);
}
}
void gw::stop()
{
if (run_enable) {
run_enable = false;
if (if_up) {
close(tun_fd);
if_up = false;
if (running) {
thread_cancel();
}
// Wait thread to exit gracefully otherwise might leave a mutex locked
int cnt = 0;
@ -84,9 +94,6 @@ void gw::stop()
usleep(10000);
cnt++;
}
if (running) {
thread_cancel();
}
wait_thread_finish();
current_ip_addr = 0;
@ -134,7 +141,9 @@ void gw::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
dl_tput_bytes += pdu->N_bytes;
}
if (!if_up) {
logger.warning("TUN/TAP not up - dropping gw RX message");
if (run_enable) {
logger.warning("TUN/TAP not up - dropping gw RX message");
}
} else if (pdu->N_bytes < 20) {
// Packet not large enough to hold IPv4 Header
logger.warning("Packet to small to hold IPv4 header. Dropping packet with %d B", pdu->N_bytes);
@ -172,7 +181,9 @@ void gw::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
memcpy(&dst_addr.s_addr, &pdu->msg[16], 4);
if (!if_up) {
logger.warning("TUN/TAP not up - dropping gw RX message");
if (run_enable) {
logger.warning("TUN/TAP not up - dropping gw RX message");
}
} else {
int n = write(tun_fd, pdu->msg, pdu->N_bytes);
if (n > 0 && (pdu->N_bytes != (uint32_t)n)) {
@ -333,6 +344,10 @@ void gw::run_thread()
continue;
}
if (!run_enable) {
break;
}
// Beyond this point we should have a activated default EPS bearer
srsran_assert(default_eps_bearer_id != NOT_ASSIGNED, "Default EPS bearer not activated");

Loading…
Cancel
Save