ue,mac_nr: fix generation of padding BSRs

* in Msg3 don't add explicit SBSR (rely on padding BSR to add)
* fix padding BSR generation to always use padding bytes to add it
master
Andre Puschmann 3 years ago
parent 6054e1229b
commit bed4cfb5e5

@ -98,6 +98,7 @@ public:
/// Interface for MUX /// Interface for MUX
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 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(); }

@ -54,11 +54,17 @@ public:
class mac_interface_mux_nr class mac_interface_mux_nr
{ {
public: public:
// MUX can ask MAC if a C-RNTI is present
virtual bool has_crnti() = 0;
// MUX can query MAC for current C-RNTI for Msg3 transmission // MUX can query MAC for current C-RNTI for Msg3 transmission
virtual uint16_t get_crnti() = 0; virtual uint16_t get_crnti() = 0;
// MUX queries MAC to return LCG state for SBSR // MUX queries MAC to return LCG state for SBSR
virtual srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr() = 0; virtual srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr() = 0;
// MUX informs MAC about padding bytes so BSR proc can decide whether to create BSR or not
virtual void set_padding_bytes(uint32_t nof_bytes) = 0;
}; };
/** /**

@ -69,7 +69,7 @@ public:
/// MUX interface for BSR generation /// MUX interface for BSR generation
srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr(); srsran::mac_sch_subpdu_nr::lcg_bsr_t generate_sbsr();
bool generate_padding_bsr(uint32_t nof_padding_bytes); void set_padding_bytes(uint32_t nof_bytes);
private: private:
const static int QUEUE_STATUS_PERIOD_MS = 1000; const static int QUEUE_STATUS_PERIOD_MS = 1000;

@ -209,6 +209,11 @@ srsran::mac_sch_subpdu_nr::lcg_bsr_t mac_nr::generate_sbsr()
return proc_bsr.generate_sbsr(); return proc_bsr.generate_sbsr();
} }
void mac_nr::set_padding_bytes(uint32_t nof_bytes)
{
proc_bsr.set_padding_bytes(nof_bytes);
}
void mac_nr::bch_decoded_ok(uint32_t tti, srsran::unique_byte_buffer_t payload) void mac_nr::bch_decoded_ok(uint32_t tti, srsran::unique_byte_buffer_t payload)
{ {
// Send MIB to RLC // Send MIB to RLC

@ -63,14 +63,15 @@ srsran::unique_byte_buffer_t mux_nr::get_pdu(uint32_t max_pdu_len)
tx_pdu.init_tx(phy_tx_pdu.get(), max_pdu_len, true); tx_pdu.init_tx(phy_tx_pdu.get(), max_pdu_len, true);
if (msg3_is_pending()) { if (msg3_is_pending()) {
// If Msg3 is pending, pack it // only C-RNTI or CCCH SDU can be transmitted in Msg3
// Use the CRNTI which is provided in the RRC reconfiguration (only for DC mode maybe other) if (mac.has_crnti()) {
tx_pdu.add_crnti_ce(mac.get_crnti()); tx_pdu.add_crnti_ce(mac.get_crnti());
tx_pdu.add_sbsr_ce(mac.generate_sbsr()); }
// TODO: add CCCH check
msg3_transmitted(); msg3_transmitted();
} else { } else {
// Pack normal UL data PDU // Pack normal UL data PDU
int32_t remaining_len = tx_pdu.get_remaing_len(); // local variable to reserv space for CEs int32_t remaining_len = tx_pdu.get_remaing_len(); // local variable to reserve space for CEs
if (add_bsr_ce == sbsr_ce) { if (add_bsr_ce == sbsr_ce) {
// reserve space for SBSR // reserve space for SBSR
@ -115,16 +116,26 @@ srsran::unique_byte_buffer_t mux_nr::get_pdu(uint32_t max_pdu_len)
} }
} }
} }
}
// Second add fixed-sized MAC CEs (e.g. SBSR) // check if
if (add_bsr_ce == sbsr_ce) { if (add_bsr_ce == no_bsr) {
tx_pdu.add_sbsr_ce(mac.generate_sbsr()); // tell BSR proc we still have space in PDU and let it decide to create a padding BSR
add_bsr_ce = no_bsr; mac.set_padding_bytes(tx_pdu.get_remaing_len());
} }
// Lastly, add variable-sized MAC CEs // Second add fixed-sized MAC CEs (e.g. SBSR)
if (add_bsr_ce == sbsr_ce) {
tx_pdu.add_sbsr_ce(mac.generate_sbsr());
add_bsr_ce = no_bsr;
} else if (add_bsr_ce == lbsr_ce) {
// TODO: implement LBSR support
tx_pdu.add_sbsr_ce(mac.generate_sbsr());
add_bsr_ce = no_bsr;
} }
// Lastly, add variable-sized MAC CEs
// Pack PDU // Pack PDU
tx_pdu.pack(); tx_pdu.pack();

@ -209,8 +209,8 @@ void proc_bsr_nr::new_grant_ul(uint32_t grant_size)
sr->reset(); sr->reset();
} }
// This function is called by MUX only if Regular BSR has not been triggered before // This function is called by MUX only if no BSR has been triggered before
bool proc_bsr_nr::generate_padding_bsr(uint32_t nof_padding_bytes) void proc_bsr_nr::set_padding_bytes(uint32_t nof_bytes)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
@ -219,16 +219,14 @@ bool proc_bsr_nr::generate_padding_bsr(uint32_t nof_padding_bytes)
const uint32_t LBSR_CE_SUBHEADER_LEN = 1; const uint32_t LBSR_CE_SUBHEADER_LEN = 1;
// if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller // if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller
// than the size of the Long BSR plus its subheader // than the size of the Long BSR plus its subheader
if (nof_padding_bytes >= SBSR_CE_SUBHEADER_LEN + srsran::mac_sch_subpdu_nr::sizeof_ce(SHORT_BSR, true) && if (nof_bytes >= SBSR_CE_SUBHEADER_LEN + srsran::mac_sch_subpdu_nr::sizeof_ce(SHORT_BSR, true) &&
nof_padding_bytes <= LBSR_CE_SUBHEADER_LEN + srsran::mac_sch_subpdu_nr::sizeof_ce(LONG_BSR, true)) { nof_bytes < LBSR_CE_SUBHEADER_LEN + srsran::mac_sch_subpdu_nr::sizeof_ce(LONG_BSR, true)) {
// generate padding BSR // generate short padding BSR
set_trigger(PADDING); mux->generate_bsr_mac_ce(SHORT_BSR);
// generate_bsr(bsr, nof_padding_bytes); } else if (nof_bytes >= LBSR_CE_SUBHEADER_LEN + srsran::mac_sch_subpdu_nr::sizeof_ce(LONG_BSR, true)) {
set_trigger(NONE); // report Long BSR if more than one LCG has data to send
return true; mux->generate_bsr_mac_ce(LONG_BSR);
} }
return false;
} }
int proc_bsr_nr::setup_lcid(uint32_t lcid, uint32_t new_lcg, uint32_t priority) int proc_bsr_nr::setup_lcid(uint32_t lcid, uint32_t new_lcg, uint32_t priority)

Loading…
Cancel
Save