nr,gnb: small gnb interface refactors and fix of byte buffer operator=

master
Francisco 3 years ago committed by Francisco Paisana
parent 2a5d21164f
commit 96fd3aae3c

@ -13,7 +13,6 @@
#ifndef SRSRAN_RRC_NR_UTILS_H #ifndef SRSRAN_RRC_NR_UTILS_H
#define SRSRAN_RRC_NR_UTILS_H #define SRSRAN_RRC_NR_UTILS_H
#include "srsenb/hdr/stack/mac/sched_interface.h"
#include "srsran/common/phy_cfg_nr.h" #include "srsran/common/phy_cfg_nr.h"
#include "srsran/interfaces/mac_interface_types.h" #include "srsran/interfaces/mac_interface_types.h"
#include "srsran/interfaces/pdcp_interface_types.h" #include "srsran/interfaces/pdcp_interface_types.h"
@ -143,9 +142,4 @@ pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const
} // namespace srsran } // namespace srsran
namespace srsenb {
int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, const asn1::rrc_nr::sib1_s& sib1);
}
#endif // SRSRAN_RRC_NR_UTILS_H #endif // SRSRAN_RRC_NR_UTILS_H

@ -119,7 +119,7 @@ public:
// avoid self assignment // avoid self assignment
if (&buf == this) if (&buf == this)
return *this; return *this;
msg = &buffer[SRSRAN_BUFFER_HEADER_OFFSET]; msg = &buffer[buf.msg - &(*buf.buffer)];
N_bytes = buf.N_bytes; N_bytes = buf.N_bytes;
md = buf.md; md = buf.md;
memcpy(msg, buf.msg, N_bytes); memcpy(msg, buf.msg, N_bytes);

@ -132,8 +132,8 @@ class rrc_interface_mac_nr
{ {
public: public:
// Provides MIB packed message // Provides MIB packed message
virtual int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) = 0; virtual int read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer) = 0;
virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) = 0; virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) = 0;
/// User management /// User management
virtual int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) = 0; virtual int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) = 0;

@ -1595,32 +1595,3 @@ bool fill_phy_pdcch_cfg_common(const asn1::rrc_nr::pdcch_cfg_common_s& pdcch_cfg
} }
} // namespace srsran } // namespace srsran
namespace srsenb {
int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, const asn1::rrc_nr::sib1_s& sib1)
{
bzero(sched_cfg, sizeof(srsenb::sched_interface::cell_cfg_t));
// set SIB1 and SIB2+ period
sched_cfg->sibs[0].period_rf = 16; // SIB1 is always 16 rf
for (uint32_t i = 0; i < sib1.si_sched_info.sched_info_list.size(); i++) {
sched_cfg->sibs[i + 1].period_rf = sib1.si_sched_info.sched_info_list[i].si_periodicity.to_number();
}
// si-WindowLength
sched_cfg->si_window_ms = sib1.si_sched_info.si_win_len.to_number();
// setup PRACH
if (not sib1.si_sched_info.si_request_cfg.rach_occasions_si_present) {
asn1::log_warning("rach_occasions_si option not present");
return SRSRAN_ERROR;
}
sched_cfg->prach_rar_window = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.ra_resp_win.to_number();
sched_cfg->prach_freq_offset = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.msg1_freq_start;
sched_cfg->maxharq_msg3tx = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.preamb_trans_max;
return SRSRAN_SUCCESS;
}
} // namespace srsenb

@ -65,8 +65,8 @@ public:
void config_phy(); void config_phy();
void config_mac(); void config_mac();
int32_t generate_sibs(); int32_t generate_sibs();
int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) final; int read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer) final;
int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) final; int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) final;
/// User manegement /// User manegement
int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg); int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg);

@ -117,7 +117,7 @@ int mac_nr::cell_cfg(const std::vector<srsenb::sched_nr_interface::cell_cfg_t>&
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (rrc->read_pdu_bcch_dlsch(sib.index, sib.payload) != SRSRAN_SUCCESS) { if (rrc->read_pdu_bcch_dlsch(sib.index, *sib.payload) != SRSRAN_SUCCESS) {
logger.error("Couldn't read SIB %d from RRC", sib.index); logger.error("Couldn't read SIB %d from RRC", sib.index);
} }

@ -307,22 +307,6 @@ void rrc_nr::config_mac()
ret2 = srsran::make_duplex_cfg_from_serv_cell(base_sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common, &cell.duplex); ret2 = srsran::make_duplex_cfg_from_serv_cell(base_sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common, &cell.duplex);
srsran_assert(ret2, "Invalid NR cell configuration."); srsran_assert(ret2, "Invalid NR cell configuration.");
// FIXME: entire SI configuration, etc needs to be ported to NR
sched_interface::cell_cfg_t cell_cfg;
set_sched_cell_cfg_sib1(&cell_cfg, cfg.sib1);
// set SIB length
for (uint32_t i = 0; i < nof_si_messages + 1; i++) {
cell_cfg.sibs[i].len = sib_buffer[i]->N_bytes;
}
// PUCCH width
cell_cfg.nrb_pucch = SRSRAN_MAX(cfg.sr_cfg.nof_prb, /* TODO: where is n_rb2 in NR? */ 0);
logger.info("Allocating %d PRBs for PUCCH", cell_cfg.nrb_pucch);
// Copy Cell configuration
// cell_cfg.cell = cfg.cell;
// Configure MAC/scheduler // Configure MAC/scheduler
mac->cell_cfg(sched_cells_cfg); mac->cell_cfg(sched_cells_cfg);
} }
@ -397,33 +381,23 @@ int32_t rrc_nr::generate_sibs()
MAC interface MAC interface
*******************************************************************************/ *******************************************************************************/
int rrc_nr::read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) int rrc_nr::read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer)
{ {
if (mib_buffer == nullptr || buffer->get_tailroom() < mib_buffer->N_bytes) { if (mib_buffer == nullptr || buffer.get_tailroom() < mib_buffer->N_bytes) {
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
memcpy(buffer->msg, mib_buffer->msg, mib_buffer->N_bytes); buffer = *mib_buffer;
buffer->N_bytes = mib_buffer->N_bytes;
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer)
{ {
if (sib_index >= sib_buffer.size()) { if (sib_index >= sib_buffer.size()) {
logger.error("SIB %d is not a configured SIB.", sib_index); logger.error("SIB %d is not a configured SIB.", sib_index);
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (buffer->get_tailroom() < sib_buffer[sib_index]->N_bytes) { buffer = *sib_buffer[sib_index];
logger.error("Not enough space to fit SIB %d into buffer (%d < %d)",
sib_index,
buffer->get_tailroom(),
sib_buffer[sib_index]->N_bytes);
return SRSRAN_ERROR;
}
memcpy(buffer->msg, sib_buffer[sib_index]->msg, sib_buffer[sib_index]->N_bytes);
buffer->N_bytes = sib_buffer[sib_index]->N_bytes;
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

@ -21,8 +21,8 @@ namespace srsenb {
class rrc_nr_dummy : public rrc_interface_mac_nr class rrc_nr_dummy : public rrc_interface_mac_nr
{ {
public: public:
int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) { return SRSRAN_SUCCESS; } int read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer) { return SRSRAN_SUCCESS; }
int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) { return SRSRAN_SUCCESS; } int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) { return SRSRAN_SUCCESS; }
int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) { return SRSRAN_SUCCESS; } int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) { return SRSRAN_SUCCESS; }
int update_user(uint16_t new_rnti, uint16_t old_rnti) { return SRSRAN_SUCCESS; } int update_user(uint16_t new_rnti, uint16_t old_rnti) { return SRSRAN_SUCCESS; }
void set_activity_user(uint16_t rnti) {} void set_activity_user(uint16_t rnti) {}

Loading…
Cancel
Save