rewrite packing of DL PDU in SS

the new algo tries to write more than just one RLC PDU inside a MAC PDU
if this is possible
master
Andre Puschmann 5 years ago
parent e919c57a32
commit 8a69772ebc

@ -285,13 +285,12 @@ public:
for (int lcid = 0; lcid < SRSLTE_N_RADIO_BEARERS; lcid++) { for (int lcid = 0; lcid < SRSLTE_N_RADIO_BEARERS; lcid++) {
uint32_t buf_state = rlc.get_buffer_state(lcid); uint32_t buf_state = rlc.get_buffer_state(lcid);
// Schedule DL transmission if there is data in RLC buffer or we need to send Msg4 // Schedule DL transmission if there is data in RLC buffer or we need to send Msg4
if (buf_state > 0 || (msg3_tti != -1 && conres_id != 0)) { if ((buf_state > 0 && bearer_follow_on_map[lcid] == false) || (msg3_tti != -1 && conres_id != 0)) {
log.debug("LCID=%d, buffer_state=%d\n", lcid, buf_state); log.debug("LCID=%d, buffer_state=%d\n", lcid, buf_state);
const uint32_t mac_header_size = 10; // Add MAC header (10 B for all subheaders, etc)
if (tmp_rlc_buffer.get_tailroom() > (buf_state + mac_header_size)) {
uint32_t pdu_size = rlc.read_pdu(lcid, tmp_rlc_buffer.msg, buf_state);
tx_payload_buffer.clear(); tx_payload_buffer.clear();
mac_msg_dl.init_tx(&tx_payload_buffer, pdu_size + mac_header_size, false);
const uint32_t mac_header_size = 10; // Add MAC header (10 B for all subheaders, etc)
mac_msg_dl.init_tx(&tx_payload_buffer, buf_state + mac_header_size, false);
// check if this is Msg4 that needs to contain the contention resolution ID CE // check if this is Msg4 that needs to contain the contention resolution ID CE
if (msg3_tti != -1 && lcid == 0 && conres_id != 0) { if (msg3_tti != -1 && lcid == 0 && conres_id != 0) {
@ -308,16 +307,23 @@ public:
msg3_tti = -1; msg3_tti = -1;
} }
// Add payload // allocate SDUs
while (buf_state > 0) { // there is pending SDU to allocate
if (mac_msg_dl.new_subh()) { if (mac_msg_dl.new_subh()) {
int n = mac_msg_dl.get()->set_sdu(lcid, pdu_size, tmp_rlc_buffer.msg); int n = mac_msg_dl.get()->set_sdu(lcid, buf_state, &rlc);
if (n == -1) { if (n == -1) {
log.error("Error while adding SDU (%d B) to MAC PDU\n", pdu_size); log.error("Error while adding SDU (%d B) to MAC PDU\n", buf_state);
mac_msg_dl.del_subh(); mac_msg_dl.del_subh();
} }
// update buffer state
buf_state = rlc.get_buffer_state(lcid);
}
} }
// Assemble entire MAC PDU
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(&log); uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(&log);
if (mac_pdu_ptr != nullptr) { if (mac_pdu_ptr != nullptr) {
log.info_hex(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU (%d B):\n", mac_msg_dl.get_pdu_len()); log.info_hex(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU (%d B):\n", mac_msg_dl.get_pdu_len());
@ -334,9 +340,9 @@ public:
log.error("Error writing DL MAC PDU\n"); log.error("Error writing DL MAC PDU\n");
} }
mac_msg_dl.reset(); mac_msg_dl.reset();
} else {
log.error("Can't fit RLC PDU into buffer (%d > %d)\n", buf_state, tmp_rlc_buffer.get_tailroom()); } else if (bearer_follow_on_map[lcid]) {
} log.info("Waiting for more PDUs for transmission on LCID=%d\n", lcid);
} }
} }
// Check if we need to provide a UL grant as well // Check if we need to provide a UL grant as well
@ -1140,7 +1146,6 @@ private:
// buffer for DL transmissions // buffer for DL transmissions
srslte::byte_buffer_t rar_buffer; srslte::byte_buffer_t rar_buffer;
srslte::byte_buffer_t tmp_rlc_buffer; // Used to buffer RLC PDU
srslte::byte_buffer_t tx_payload_buffer; // Used to buffer final MAC PDU srslte::byte_buffer_t tx_payload_buffer; // Used to buffer final MAC PDU
uint64_t conres_id = 0; uint64_t conres_id = 0;

Loading…
Cancel
Save