|
|
|
@ -285,13 +285,12 @@ public:
|
|
|
|
|
for (int lcid = 0; lcid < SRSLTE_N_RADIO_BEARERS; 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
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
|
if (msg3_tti != -1 && lcid == 0 && conres_id != 0) {
|
|
|
|
@ -308,16 +307,23 @@ public:
|
|
|
|
|
msg3_tti = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add payload
|
|
|
|
|
// allocate SDUs
|
|
|
|
|
while (buf_state > 0) { // there is pending SDU to allocate
|
|
|
|
|
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) {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
@ -334,9 +340,9 @@ public:
|
|
|
|
|
log.error("Error writing DL MAC PDU\n");
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
@ -1140,7 +1146,6 @@ private:
|
|
|
|
|
|
|
|
|
|
// buffer for DL transmissions
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
uint64_t conres_id = 0;
|
|
|
|
|