Merge branch 'next' into agpl_next

master
Codebot 11 months ago committed by srs-codebot
commit ec29b0c1ff

@ -140,6 +140,7 @@ struct rach_cfg_nr_t {
uint32_t powerRampingStep; uint32_t powerRampingStep;
uint32_t ra_responseWindow; uint32_t ra_responseWindow;
uint32_t ra_ContentionResolutionTimer; uint32_t ra_ContentionResolutionTimer;
uint32_t nof_preambles;
rach_cfg_nr_t() { reset(); } rach_cfg_nr_t() { reset(); }
void reset() void reset()
@ -149,6 +150,7 @@ struct rach_cfg_nr_t {
powerRampingStep = 0; powerRampingStep = 0;
preambleTransMax = 0; preambleTransMax = 0;
ra_responseWindow = 0; ra_responseWindow = 0;
nof_preambles = 0;
} }
}; };

@ -106,6 +106,10 @@ void make_mac_rach_cfg(const rach_cfg_common_s& asn1_type, rach_cfg_nr_t* rach_c
rach_cfg_nr->PreambleReceivedTargetPower = asn1_type.rach_cfg_generic.preamb_rx_target_pwr; rach_cfg_nr->PreambleReceivedTargetPower = asn1_type.rach_cfg_generic.preamb_rx_target_pwr;
rach_cfg_nr->preambleTransMax = asn1_type.rach_cfg_generic.preamb_trans_max.to_number(); rach_cfg_nr->preambleTransMax = asn1_type.rach_cfg_generic.preamb_trans_max.to_number();
rach_cfg_nr->ra_ContentionResolutionTimer = asn1_type.ra_contention_resolution_timer.to_number(); rach_cfg_nr->ra_ContentionResolutionTimer = asn1_type.ra_contention_resolution_timer.to_number();
if (asn1_type.total_nof_ra_preambs_present) {
rach_cfg_nr->nof_preambles = asn1_type.total_nof_ra_preambs;
}
}; };
int make_rlc_config_t(const rlc_cfg_c& asn1_type, uint8_t bearer_id, rlc_config_t* cfg_out) int make_rlc_config_t(const rlc_cfg_c& asn1_type, uint8_t bearer_id, rlc_config_t* cfg_out)

@ -290,22 +290,24 @@ bool mac_rar_pdu_nr::unpack(const uint8_t* payload, const uint32_t& len)
bool ret = false; bool ret = false;
bool have_more_subpdus = false; bool have_more_subpdus = false;
uint32_t offset = 0; uint32_t offset = 0;
bool success = false;
remaining_len = len; remaining_len = len;
do { do {
mac_rar_subpdu_nr rar_subpdu(this); mac_rar_subpdu_nr rar_subpdu(this);
ret = rar_subpdu.read_subpdu(payload + offset); success = rar_subpdu.read_subpdu(payload + offset);
have_more_subpdus = rar_subpdu.has_more_subpdus(); have_more_subpdus = rar_subpdu.has_more_subpdus();
offset += rar_subpdu.get_total_length(); offset += rar_subpdu.get_total_length();
remaining_len -= rar_subpdu.get_total_length(); remaining_len -= rar_subpdu.get_total_length();
// only append if subPDU could be read successfully // only append if subPDU could be read successfully
if (ret == true) { if (success == true) {
subpdus.push_back(rar_subpdu); subpdus.push_back(rar_subpdu);
} }
ret |= success;
// continue reading as long as subPDUs can be extracted ok and we are not overrunning the PDU length // continue reading as long as subPDUs can be extracted ok and we are not overrunning the PDU length
} while (ret && have_more_subpdus && offset <= len); } while (success && have_more_subpdus && offset <= len);
return ret; return ret;
} }

@ -29,6 +29,12 @@
namespace srsue { namespace srsue {
class mac_nr_interface_demux
{
public:
virtual bool received_contention_id(uint64_t id) = 0;
};
/** /**
* @brief Logical Channel Demultiplexing and MAC CE dissassemble according to TS 38.321 * @brief Logical Channel Demultiplexing and MAC CE dissassemble according to TS 38.321
* *
@ -45,7 +51,7 @@ public:
demux_nr(srslog::basic_logger& logger_); demux_nr(srslog::basic_logger& logger_);
~demux_nr(); ~demux_nr();
int32_t init(rlc_interface_mac* rlc_, phy_interface_mac_nr* phy_); int32_t init(rlc_interface_mac* rlc_, phy_interface_mac_nr* phy_, mac_nr_interface_demux* mac_);
void process_pdus(); /// Called by MAC to process received PDUs void process_pdus(); /// Called by MAC to process received PDUs
@ -53,7 +59,7 @@ public:
void push_bcch(srsran::unique_byte_buffer_t pdu); void push_bcch(srsran::unique_byte_buffer_t pdu);
void push_pdu(srsran::unique_byte_buffer_t pdu, uint32_t tti); void push_pdu(srsran::unique_byte_buffer_t pdu, uint32_t tti);
void push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti); void push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti);
uint64_t get_received_crueid(); bool get_uecrid_successful();
private: private:
// internal helpers // internal helpers
@ -62,8 +68,9 @@ private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
rlc_interface_mac* rlc = nullptr; rlc_interface_mac* rlc = nullptr;
phy_interface_mac_nr* phy = nullptr; phy_interface_mac_nr* phy = nullptr;
mac_nr_interface_demux* mac = nullptr;
uint64_t received_crueid = 0; bool is_uecrid_successful = false;
///< currently only DCH & BCH PDUs supported (add PCH, etc) ///< currently only DCH & BCH PDUs supported (add PCH, etc)
srsran::block_queue<srsran::unique_byte_buffer_t> pdu_queue; srsran::block_queue<srsran::unique_byte_buffer_t> pdu_queue;

@ -48,7 +48,8 @@ class mac_nr final : public mac_interface_phy_nr,
public mac_interface_proc_ra_nr, public mac_interface_proc_ra_nr,
public mac_interface_sr_nr, public mac_interface_sr_nr,
public mac_interface_mux_nr, public mac_interface_mux_nr,
public mac_interface_harq_nr public mac_interface_harq_nr,
public mac_nr_interface_demux
{ {
public: public:
mac_nr(srsran::ext_task_sched_handle task_sched_); mac_nr(srsran::ext_task_sched_handle task_sched_);
@ -97,7 +98,6 @@ public:
void start_ra_procedure(); void start_ra_procedure();
/// Interface for internal procedures (RA, MUX, HARQ) /// Interface for internal procedures (RA, MUX, HARQ)
bool received_contention_id(uint64_t rx_contention_id);
uint16_t get_crnti(); uint16_t get_crnti();
uint16_t get_temp_crnti(); uint16_t get_temp_crnti();
uint16_t get_csrnti() { return SRSRAN_INVALID_RNTI; }; // SPS not supported uint16_t get_csrnti() { return SRSRAN_INVALID_RNTI; }; // SPS not supported
@ -111,6 +111,9 @@ public:
srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr(); srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr();
void set_padding_bytes(uint32_t nof_bytes); void set_padding_bytes(uint32_t nof_bytes);
/// Interface for DEMUX
bool received_contention_id(uint64_t rx_contention_id);
void msg3_flush() { mux.msg3_flush(); } void msg3_flush() { mux.msg3_flush(); }
bool msg3_is_transmitted() { return mux.msg3_is_transmitted(); } bool msg3_is_transmitted() { return mux.msg3_is_transmitted(); }
void msg3_prepare() { mux.msg3_prepare(); } void msg3_prepare() { mux.msg3_prepare(); }

@ -90,9 +90,6 @@ public:
// MAC also provides Temp C-RNTI (through RA proc) // MAC also provides Temp C-RNTI (through RA proc)
virtual uint16_t get_temp_crnti() = 0; virtual uint16_t get_temp_crnti() = 0;
// HARQ can query MAC for current C-RNTI
virtual bool received_contention_id(uint64_t rx_contention_id) = 0;
// MAC provides the Currently Scheduled RNTI (for SPS) // MAC provides the Currently Scheduled RNTI (for SPS)
virtual uint16_t get_csrnti() = 0; virtual uint16_t get_csrnti() = 0;
}; };
@ -107,7 +104,7 @@ public:
virtual void push_bcch(srsran::unique_byte_buffer_t pdu) = 0; virtual void push_bcch(srsran::unique_byte_buffer_t pdu) = 0;
virtual void push_pdu(srsran::unique_byte_buffer_t pdu, uint32_t tti) = 0; virtual void push_pdu(srsran::unique_byte_buffer_t pdu, uint32_t tti) = 0;
virtual void push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti) = 0; virtual void push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti) = 0;
virtual uint64_t get_received_crueid() = 0; virtual bool get_uecrid_successful() = 0;
}; };
} // namespace srsue } // namespace srsue

@ -48,6 +48,7 @@ public:
bool msg3_is_transmitted(); bool msg3_is_transmitted();
bool msg3_is_pending(); bool msg3_is_pending();
bool msg3_is_empty(); bool msg3_is_empty();
srsran::unique_byte_buffer_t get_msg3(uint32_t max_pdu_len);
// MAC interface // MAC interface
int setup_lcid(const srsran::logical_channel_config_t& config); int setup_lcid(const srsran::logical_channel_config_t& config);
@ -60,6 +61,7 @@ public:
private: private:
// internal helper methods // internal helper methods
srsran::unique_byte_buffer_t pdu_get_nolock(uint32_t max_pdu_len);
// ctor configured members // ctor configured members
mac_interface_mux_nr& mac; mac_interface_mux_nr& mac;

@ -38,7 +38,7 @@ class proc_ra_nr
{ {
public: public:
proc_ra_nr(mac_interface_proc_ra_nr& mac_, srslog::basic_logger& logger_); proc_ra_nr(mac_interface_proc_ra_nr& mac_, srslog::basic_logger& logger_);
~proc_ra_nr(){}; ~proc_ra_nr() { srsran_random_free(random_gen); };
void init(phy_interface_mac_nr* phy_h_, srsran::ext_task_sched_handle* task_sched_); void init(phy_interface_mac_nr* phy_h_, srsran::ext_task_sched_handle* task_sched_);
void set_config(const srsran::rach_cfg_nr_t& rach_cfg_nr); void set_config(const srsran::rach_cfg_nr_t& rach_cfg_nr);
@ -68,6 +68,8 @@ private:
mac_interface_proc_ra_nr& mac; mac_interface_proc_ra_nr& mac;
srslog::basic_logger& logger; srslog::basic_logger& logger;
srsran_random_t random_gen;
phy_interface_mac_nr* phy = nullptr; phy_interface_mac_nr* phy = nullptr;
srsran::ext_task_sched_handle* task_sched = nullptr; srsran::ext_task_sched_handle* task_sched = nullptr;
srsran::task_multiqueue::queue_handle task_queue; srsran::task_multiqueue::queue_handle task_queue;
@ -120,7 +122,7 @@ private:
void ra_resource_selection(); void ra_resource_selection();
void ra_preamble_transmission(); void ra_preamble_transmission();
void ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb); void ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb);
void ra_contention_resolution(bool received_con_res_matches_ue_id); void ra_contention_resolution(bool is_successful, bool is_ul_grant);
void ra_completion(); void ra_completion();
void ra_error(); void ra_error();
}; };

@ -175,6 +175,8 @@ private:
bool running = false; bool running = false;
srsran::block_queue<cmd_msg_t> cmd_q; srsran::block_queue<cmd_msg_t> cmd_q;
srsran_random_t random_gen;
// PHY config // PHY config
srsran::phy_cfg_nr_t phy_cfg = {}; srsran::phy_cfg_nr_t phy_cfg = {};

@ -247,6 +247,11 @@ bool cc_worker::decode_pdsch_dl()
mac_dl_grant.tti = dl_slot_cfg.idx; mac_dl_grant.tti = dl_slot_cfg.idx;
phy.stack->new_grant_dl(0, mac_dl_grant, &dl_action); phy.stack->new_grant_dl(0, mac_dl_grant, &dl_action);
// check if RA-RNTI, if true reset HARQ buffers
if (pdsch_cfg.grant.rnti_type == srsran_rnti_type_ra && dl_action.tb.softbuffer != nullptr) {
srsran_softbuffer_rx_reset(dl_action.tb.softbuffer);
}
// Abort if MAC says it doesn't need the TB // Abort if MAC says it doesn't need the TB
if (not dl_action.tb.enabled) { if (not dl_action.tb.enabled) {
// Force positive ACK // Force positive ACK

@ -30,16 +30,17 @@ demux_nr::demux_nr(srslog::basic_logger& logger_) : logger(logger_) {}
demux_nr::~demux_nr() {} demux_nr::~demux_nr() {}
int32_t demux_nr::init(rlc_interface_mac* rlc_, phy_interface_mac_nr* phy_) int32_t demux_nr::init(rlc_interface_mac* rlc_, phy_interface_mac_nr* phy_, mac_nr_interface_demux* mac_)
{ {
rlc = rlc_; rlc = rlc_;
phy = phy_; phy = phy_;
mac = mac_;
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
uint64_t demux_nr::get_received_crueid() bool demux_nr::get_uecrid_successful()
{ {
return received_crueid; return is_uecrid_successful;
} }
// Enqueues PDU and returns quickly // Enqueues PDU and returns quickly
@ -64,7 +65,7 @@ void demux_nr::push_bcch(srsran::unique_byte_buffer_t pdu)
*/ */
void demux_nr::push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti) void demux_nr::push_pdu_temp_crnti(srsran::unique_byte_buffer_t pdu, uint32_t tti)
{ {
received_crueid = 0; is_uecrid_successful = false;
handle_pdu(rx_pdu_tcrnti, std::move(pdu)); handle_pdu(rx_pdu_tcrnti, std::move(pdu));
} }
@ -99,6 +100,7 @@ void demux_nr::handle_pdu(srsran::mac_sch_pdu_nr& pdu_buffer, srsran::unique_byt
logger.info("%s", srsran::to_c_str(str_buffer)); logger.info("%s", srsran::to_c_str(str_buffer));
} }
bool con_res_rxed = false;
for (uint32_t i = 0; i < pdu_buffer.get_num_subpdus(); ++i) { for (uint32_t i = 0; i < pdu_buffer.get_num_subpdus(); ++i) {
srsran::mac_sch_subpdu_nr subpdu = pdu_buffer.get_subpdu(i); srsran::mac_sch_subpdu_nr subpdu = pdu_buffer.get_subpdu(i);
logger.debug("Handling subPDU %d/%d: rnti=0x%x lcid=%d, sdu_len=%d", logger.debug("Handling subPDU %d/%d: rnti=0x%x lcid=%d, sdu_len=%d",
@ -108,7 +110,7 @@ void demux_nr::handle_pdu(srsran::mac_sch_pdu_nr& pdu_buffer, srsran::unique_byt
subpdu.get_lcid(), subpdu.get_lcid(),
subpdu.get_sdu_length()); subpdu.get_sdu_length());
// Handle Timing Advance CE // Handle Contention Resolution UE ID and Timing Advance CE
switch (subpdu.get_lcid()) { switch (subpdu.get_lcid()) {
case srsran::mac_sch_subpdu_nr::nr_lcid_sch_t::DRX_CMD: case srsran::mac_sch_subpdu_nr::nr_lcid_sch_t::DRX_CMD:
logger.info("DRX CE not implemented."); logger.info("DRX CE not implemented.");
@ -118,15 +120,20 @@ void demux_nr::handle_pdu(srsran::mac_sch_pdu_nr& pdu_buffer, srsran::unique_byt
phy->set_timeadv(0, subpdu.get_ta().ta_command); phy->set_timeadv(0, subpdu.get_ta().ta_command);
break; break;
case srsran::mac_sch_subpdu_nr::nr_lcid_sch_t::CON_RES_ID: case srsran::mac_sch_subpdu_nr::nr_lcid_sch_t::CON_RES_ID:
received_crueid = subpdu.get_ue_con_res_id_ce_packed(); con_res_rxed = true;
logger.info("Received Contention Resolution ID 0x%lx", subpdu.get_ue_con_res_id_ce_packed()); logger.info("Received Contention Resolution ID 0x%lx", subpdu.get_ue_con_res_id_ce_packed());
if (!is_uecrid_successful) {
is_uecrid_successful = mac->received_contention_id(subpdu.get_ue_con_res_id_ce_packed());
}
break; break;
default: default:
if (!con_res_rxed or (con_res_rxed and is_uecrid_successful)) {
if (subpdu.is_sdu()) { if (subpdu.is_sdu()) {
rlc->write_pdu(subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length()); rlc->write_pdu(subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length());
} }
} }
} }
}
} }
} // namespace srsue } // namespace srsue

@ -244,7 +244,10 @@ void dl_harq_entity_nr::dl_harq_process_nr::tb_decoded(const mac_nr_grant_dl_t&
logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI) not implemented", logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI) not implemented",
grant.tbs); grant.tbs);
harq_entity->demux_unit->push_pdu_temp_crnti(std::move(result.payload), grant.tti); harq_entity->demux_unit->push_pdu_temp_crnti(std::move(result.payload), grant.tti);
result.ack = harq_entity->mac->received_contention_id(harq_entity->demux_unit->get_received_crueid()); result.ack = harq_entity->demux_unit->get_uecrid_successful();
if (not result.ack) {
reset();
}
} else { } else {
logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit", grant.tbs); logger.debug("Delivering PDU=%d bytes to Dissassemble and Demux unit", grant.tbs);
harq_entity->demux_unit->push_pdu(std::move(result.payload), grant.tti); harq_entity->demux_unit->push_pdu(std::move(result.payload), grant.tti);

@ -74,7 +74,7 @@ int mac_nr::init(const mac_nr_args_t& args_,
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (demux.init(rlc, phy) != SRSRAN_SUCCESS) { if (demux.init(rlc, phy, this) != SRSRAN_SUCCESS) {
logger.error("Couldn't initialize demux unit."); logger.error("Couldn't initialize demux unit.");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -358,11 +358,6 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, const mac_nr_grant_dl_t& grant, t
dl_harq.at(cc_idx)->tb_decoded(grant, std::move(result)); dl_harq.at(cc_idx)->tb_decoded(grant, std::move(result));
} }
// If proc ra is in contention resolution (RA connection request procedure)
if (proc_ra.is_contention_resolution() && grant.rnti == rntis.get_temp_rnti()) {
proc_ra.received_contention_resolution(contention_res_successful);
}
} }
void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, tb_action_ul_t* action) void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, tb_action_ul_t* action)
@ -575,6 +570,7 @@ void mac_nr::process_pdus()
bool mac_nr::received_contention_id(uint64_t rx_contention_id) bool mac_nr::received_contention_id(uint64_t rx_contention_id)
{ {
contention_res_successful = rntis.get_contention_id() == rx_contention_id; contention_res_successful = rntis.get_contention_id() == rx_contention_id;
proc_ra.received_contention_resolution(contention_res_successful);
return contention_res_successful; return contention_res_successful;
} }

@ -56,11 +56,8 @@ int mux_nr::setup_lcid(const srsran::logical_channel_config_t& config)
return mux_base::setup_lcid(config); return mux_base::setup_lcid(config);
} }
srsran::unique_byte_buffer_t mux_nr::get_pdu(uint32_t max_pdu_len) srsran::unique_byte_buffer_t mux_nr::pdu_get_nolock(uint32_t max_pdu_len)
{ {
// Lock MAC PDU from current access from PHY workers (will be moved to UL HARQ)
std::lock_guard<std::mutex> lock(mutex);
// initialize MAC PDU // initialize MAC PDU
srsran::unique_byte_buffer_t phy_tx_pdu = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t phy_tx_pdu = srsran::make_byte_buffer();
if (phy_tx_pdu == nullptr) { if (phy_tx_pdu == nullptr) {
@ -199,6 +196,35 @@ bool mux_nr::msg3_is_empty()
return msg3_buff->N_bytes == 0; return msg3_buff->N_bytes == 0;
} }
srsran::unique_byte_buffer_t mux_nr::get_pdu(uint32_t max_pdu_len)
{
// Lock MAC PDU from current access from PHY workers (will be moved to UL HARQ)
std::lock_guard<std::mutex> lock(mutex);
return pdu_get_nolock(max_pdu_len);
}
srsran::unique_byte_buffer_t mux_nr::get_msg3(uint32_t max_pdu_len)
{
// Lock MAC PDU from current access from PHY workers (will be moved to UL HARQ)
std::lock_guard<std::mutex> lock(mutex);
srsran::unique_byte_buffer_t phy_tx_pdu = srsran::make_byte_buffer();
if (max_pdu_len < msg3_buff->get_tailroom()) {
if (msg3_is_empty()) {
msg3_buff = pdu_get_nolock(max_pdu_len);
if (msg3_buff == nullptr) {
logger.error("Moving PDU from Mux unit to Msg3 buffer");
return NULL;
}
}
*phy_tx_pdu = *msg3_buff;
return phy_tx_pdu;
} else {
logger.error("Msg3 size exceeds buffer");
return nullptr;
}
}
void mux_nr::generate_bsr_mac_ce(const srsran::bsr_format_nr_t& format) void mux_nr::generate_bsr_mac_ce(const srsran::bsr_format_nr_t& format)
{ {
switch (format) { switch (format) {

@ -50,6 +50,10 @@ void proc_ra_nr::init(phy_interface_mac_nr* phy_, srsran::ext_task_sched_handle*
rar_timeout_timer = task_sched->get_unique_timer(); rar_timeout_timer = task_sched->get_unique_timer();
contention_resolution_timer = task_sched->get_unique_timer(); contention_resolution_timer = task_sched->get_unique_timer();
backoff_timer = task_sched->get_unique_timer(); backoff_timer = task_sched->get_unique_timer();
struct timeval tv;
gettimeofday(&tv, NULL);
random_gen = srsran_random_init(tv.tv_usec);
} }
/* Sets a new configuration. The configuration is applied by initialization() function */ /* Sets a new configuration. The configuration is applied by initialization() function */
@ -127,7 +131,7 @@ bool proc_ra_nr::has_rar_rnti()
void proc_ra_nr::received_contention_resolution(bool is_successful) void proc_ra_nr::received_contention_resolution(bool is_successful)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
ra_contention_resolution(is_successful); ra_contention_resolution(is_successful, false);
} }
void proc_ra_nr::timer_expired(uint32_t timer_id) void proc_ra_nr::timer_expired(uint32_t timer_id)
@ -175,7 +179,11 @@ void proc_ra_nr::ra_preamble_transmission()
preamble_received_target_power = rach_cfg.PreambleReceivedTargetPower + delta_preamble + preamble_received_target_power = rach_cfg.PreambleReceivedTargetPower + delta_preamble +
(preamble_transmission_counter - 1) * rach_cfg.powerRampingStep + (preamble_transmission_counter - 1) * rach_cfg.powerRampingStep +
power_offset_2step_ra; power_offset_2step_ra;
if (rach_cfg.nof_preambles) {
preamble_index = srsran_random_uniform_int_dist(random_gen, 0, rach_cfg.nof_preambles);
} else {
preamble_index = 0; preamble_index = 0;
}
prach_occasion = 0; prach_occasion = 0;
// instruct the physical layer to transmit the Random Access Preamble using the selected PRACH occasion, corresponding // instruct the physical layer to transmit the Random Access Preamble using the selected PRACH occasion, corresponding
// RA-RNTI (if available), PREAMBLE_INDEX, and PREAMBLE_RECEIVED_TARGET_POWER. // RA-RNTI (if available), PREAMBLE_INDEX, and PREAMBLE_RECEIVED_TARGET_POWER.
@ -197,8 +205,6 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
return; return;
} }
// Stop rar timer
rar_timeout_timer.stop();
if (tb.ack && tb.payload != nullptr) { if (tb.ack && tb.payload != nullptr) {
srsran::mac_rar_pdu_nr pdu; srsran::mac_rar_pdu_nr pdu;
if (!pdu.unpack(tb.payload->msg, tb.payload->N_bytes)) { if (!pdu.unpack(tb.payload->msg, tb.payload->N_bytes)) {
@ -212,6 +218,9 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
for (auto& subpdu : pdu.get_subpdus()) { for (auto& subpdu : pdu.get_subpdus()) {
if (subpdu.has_rapid() && subpdu.get_rapid() == preamble_index) { if (subpdu.has_rapid() && subpdu.get_rapid() == preamble_index) {
// Stop rar timer
rar_timeout_timer.stop();
logger.debug("PROC RA NR: Setting UL grant and prepare Msg3"); logger.debug("PROC RA NR: Setting UL grant and prepare Msg3");
mac.set_temp_crnti(subpdu.get_temp_crnti()); mac.set_temp_crnti(subpdu.get_temp_crnti());
@ -232,18 +241,20 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_
} else { } else {
preamble_backoff = 0; preamble_backoff = 0;
} }
}
} contention_resolution_timer.set(rach_cfg.ra_ContentionResolutionTimer,
} [this](uint32_t tid) { timer_expired(tid); });
contention_resolution_timer.set(rach_cfg.ra_ContentionResolutionTimer, [this](uint32_t tid) { timer_expired(tid); });
contention_resolution_timer.run(); contention_resolution_timer.run();
logger.debug("Waiting for Contention Resolution"); logger.debug("Waiting for Contention Resolution");
state = WAITING_FOR_CONTENTION_RESOLUTION; state = WAITING_FOR_CONTENTION_RESOLUTION;
}
}
}
} }
// TS 38.321 Section 5.1.5 2 ways to resolve contention resolution // TS 38.321 Section 5.1.5 2 ways to resolve contention resolution
// if the C-RNTI MAC CE was included in Msg3: (only this one is implemented) // if the C-RNTI MAC CE was included in Msg3: (only this one is implemented)
void proc_ra_nr::ra_contention_resolution(bool received_con_res_matches_ue_id) void proc_ra_nr::ra_contention_resolution(bool is_successful, bool is_ul_grant)
{ {
if (state != WAITING_FOR_CONTENTION_RESOLUTION) { if (state != WAITING_FOR_CONTENTION_RESOLUTION) {
logger.warning( logger.warning(
@ -252,15 +263,20 @@ void proc_ra_nr::ra_contention_resolution(bool received_con_res_matches_ue_id)
srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION)); srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION));
return; return;
} }
if (started_by == initiators_t::RRC || started_by == initiators_t::MAC || received_con_res_matches_ue_id) { if (started_by == initiators_t::RRC || started_by == initiators_t::MAC || is_successful) {
if (received_con_res_matches_ue_id) { if (is_successful) {
logger.info("Received CONRES ID matches transmitted UE ID"); if (is_ul_grant) {
} else {
logger.info("PDCCH to C-RNTI received with a new UL grant of transmission"); logger.info("PDCCH to C-RNTI received with a new UL grant of transmission");
} else {
logger.info("Received CONRES ID matches transmitted UE ID");
} }
contention_resolution_timer.stop(); contention_resolution_timer.stop();
state = WAITING_FOR_COMPLETION; state = WAITING_FOR_COMPLETION;
ra_completion(); ra_completion();
} else {
logger.info("Received CONRES ID DOES NOT match transmitted UE ID");
mac.set_temp_crnti(SRSRAN_INVALID_RNTI);
}
} else { } else {
logger.error("Not started by the correct initiator MAC or RRC"); logger.error("Not started by the correct initiator MAC or RRC");
} }
@ -376,7 +392,7 @@ void proc_ra_nr::handle_rar_pdu(mac_interface_phy_nr::tb_action_dl_result_t& res
// Called from PHY thread, defer actions therefore. // Called from PHY thread, defer actions therefore.
void proc_ra_nr::pdcch_to_crnti() void proc_ra_nr::pdcch_to_crnti()
{ {
task_queue.push([this]() { ra_contention_resolution(false); }); task_queue.push([this]() { ra_contention_resolution(true, true); });
} }
bool proc_ra_nr::is_contention_resolution() bool proc_ra_nr::is_contention_resolution()

@ -198,8 +198,13 @@ void ul_harq_entity_nr::ul_harq_process_nr::new_grant_ul(const mac_interface_phy
) { ) {
// new transmission // new transmission
// generate new PDU (Msg3 or normal UL) if (grant.is_rar_grant) {
// generate new PDU (Msg3)
harq_buffer = harq_entity->mux->get_msg3(grant.tbs);
} else {
// generate new PDU (normal UL)
harq_buffer = harq_entity->mux->get_pdu(grant.tbs); harq_buffer = harq_entity->mux->get_pdu(grant.tbs);
}
// 3> if a MAC PDU to transmit has been obtained // 3> if a MAC PDU to transmit has been obtained
if (harq_buffer != nullptr) { if (harq_buffer != nullptr) {

@ -45,10 +45,16 @@ rrc_nr::rrc_nr(srsran::task_sched_handle task_sched_) :
cell_selector(*this), cell_selector(*this),
meas_cells(task_sched_) meas_cells(task_sched_)
{ {
struct timeval tv;
gettimeofday(&tv, NULL);
random_gen = srsran_random_init(tv.tv_usec);
set_phy_default_config(); set_phy_default_config();
} }
rrc_nr::~rrc_nr() = default; rrc_nr::~rrc_nr()
{
srsran_random_free(random_gen);
}
int rrc_nr::init(phy_interface_rrc_nr* phy_, int rrc_nr::init(phy_interface_rrc_nr* phy_,
mac_interface_rrc_nr* mac_, mac_interface_rrc_nr* mac_,
@ -610,8 +616,7 @@ void rrc_nr::send_setup_request(srsran::nr_establishment_cause_t cause)
// TODO: implement ng_minus5_g_s_tmsi_part1 // TODO: implement ng_minus5_g_s_tmsi_part1
rrc_setup_req->ue_id.set_random_value(); rrc_setup_req->ue_id.set_random_value();
// TODO use proper RNG uint64_t random_id = srsran_random_uniform_int_dist(random_gen, 0, 12345);
uint64_t random_id = 0;
for (uint i = 0; i < 5; i++) { // fill random ID bytewise, 40 bits = 5 bytes for (uint i = 0; i < 5; i++) { // fill random ID bytewise, 40 bits = 5 bytes
random_id |= ((uint64_t)rand() & 0xFF) << i * 8; random_id |= ((uint64_t)rand() & 0xFF) << i * 8;
} }

Loading…
Cancel
Save