Skip to content

Commit

Permalink
Merge branch 'next' into agpl_next
Browse files Browse the repository at this point in the history
  • Loading branch information
srs-codebot authored and Your Name committed Oct 29, 2021
2 parents aa9b8ac + dfc2ea0 commit 5275f33
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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).

See the [srsRAN project pages](https://www.srsran.com) for information, guides and project news.

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).
Expand Down
2 changes: 2 additions & 0 deletions lib/include/srsran/interfaces/pdcp_interface_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class pdcp_config_t
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
Expand Down
7 changes: 6 additions & 1 deletion lib/include/srsran/phy/phch/pbch_msg_nr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/include/srsran/upper/pdcp_entity_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class pdcp_entity_base
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;
Expand All @@ -163,6 +165,7 @@ class pdcp_entity_base
pdcp_discard_timer_t::infinity,
false,
srsran_rat_t::lte};
std::string rb_name;

srsran::as_security_config_t sec_cfg = {};

Expand Down
10 changes: 7 additions & 3 deletions lib/src/pdcp/pdcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
30 changes: 16 additions & 14 deletions lib/src/pdcp/pdcp_entity_lte.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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]);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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];
Expand All @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions lib/src/pdcp/pdcp_entity_nr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]);

Expand Down Expand Up @@ -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]);
Expand Down
10 changes: 1 addition & 9 deletions lib/src/phy/sync/test/ssb_decode_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/radio/test/test_radio_rt_gain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ int main(int argc, char** argv)
continue;
}
break;
case END:
continue;
default:
break;
}

// Prepare reception buffers
Expand Down
9 changes: 3 additions & 6 deletions lib/src/rlc/rlc_um_nr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/test/rlc/rlc_um_nr_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions srsenb/src/stack/mac/nr/mac_nr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion srsue/hdr/stack/upper/gw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -85,7 +86,7 @@ class gw : public gw_interface_stack, public srsran::thread
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;
Expand Down
Loading

0 comments on commit 5275f33

Please sign in to comment.